package jmap.DataSources.Misc;

import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
import jmap.Base.MapComponent;
import jmap.Base.Viewer;

/*
 * GetListOfHills.java
 * 
 * Copyright (c) 2010 Rob Sim <robsim91 at users.sourceforge.net>. Sim <robsim91 at users.sourceforge.net>.
 * 
 * This file is part of jmap.
 * 
 * jmap is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * jmap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with jmap.  If not, see <http ://www.gnu.org/licenses/>.
 */

/**
 *
 * @author Rob Sim <robsim91 at users.sourceforge.net>
 */

@Deprecated
public class ListOfBritishHills extends MapComponent{
    ArrayList<String> headings = new ArrayList<>();
    ArrayList<Properties> hills = new ArrayList<>();
    public ListOfBritishHills(){
    }
    public ListOfBritishHills(String file) throws FileNotFoundException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        headings.addAll(Arrays.asList(in.readLine().split(",")));
        for(String s = in.readLine(); s != null; s = in.readLine()){
            String s1[] = s.split("\"");
            String s2 = s1[0];
            for(int q = 1; q < s1.length; q +=2){
                s2 += s1[q].replaceAll(",", "\n") + s1[q+1];
            }
            Properties p = new Properties();
            s1 = s2.split(",");
            for(int q = 0; q < s1.length; q++)
                p.setProperty(headings.get(q), s1[q].replaceAll("\n", ","));
            hills.add(p);
        }
        for(Properties p : hills)
            System.out.println(p.getProperty("Name"));
    }

    @Override
    public void draw(Graphics g, Point2D topLeft, int bottem, double xRatio, double yRatio) {
        //TODOMaybe: Draw waypoints at poi.
    }
    @Override
    public JPanel getSidebarDisplay(Viewer viewer) {
        JPanel mainPanel = new JPanel();
        
        return mainPanel;
    }
    


    public static void main(String[] args) {
        try {
            new ListOfBritishHills("/home/rob/Desktop/Maps/hills_v11_5.csv");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(ListOfBritishHills.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ListOfBritishHills.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
