diff --git a/src/Do_to_cartoCSV.bat b/src/Do_to_cartoCSV.bat new file mode 100644 index 0000000..e412b33 --- /dev/null +++ b/src/Do_to_cartoCSV.bat @@ -0,0 +1 @@ +java -cp .;osmCoverage.jar;hayashi_0225.jar;hsqldb_2.2.9.jar;postgresql-9.4.1212.jar osm.jp.coverage.busstop.ToCartoCSV diff --git a/src/osm/jp/coverage/busstop/ToCartoCSV.java b/src/osm/jp/coverage/busstop/ToCartoCSV.java index af3df23..3493309 100644 --- a/src/osm/jp/coverage/busstop/ToCartoCSV.java +++ b/src/osm/jp/coverage/busstop/ToCartoCSV.java @@ -27,22 +27,31 @@ * */ public class ToCartoCSV { - public static final String CSV_FILE_NAME = "carto.csv"; + public static final String CSV_FILE_NAME = "busstop"; public static boolean NAGOYA_MODE = false; BufferedWriter ow = null; + BufferedWriter ow0 = null; + BufferedWriter ow1 = null; + BufferedWriter ow2 = null; - public static void main () { + public static void main (String[] argv) { try { ToCartoCSV obj = new ToCartoCSV(new File(".")); - obj.outputDb(DatabaseTool.openDb("database")); + obj.outputDb(DatabaseTool.openDb("postgis")); } catch (Exception e) { e.printStackTrace(); } } public ToCartoCSV(File dir) throws UnsupportedEncodingException, FileNotFoundException { - File csvFile = new File(dir, CSV_FILE_NAME); + File csvFile = new File(dir, CSV_FILE_NAME+".csv"); + File csv0File = new File(dir, CSV_FILE_NAME+"0.csv"); + File csv1File = new File(dir, CSV_FILE_NAME+"1.csv"); + File csv2File = new File(dir, CSV_FILE_NAME+"2.csv"); this.ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile), "UTF-8")); + this.ow0 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv0File), "UTF-8")); + this.ow1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv1File), "UTF-8")); + this.ow2 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csv2File), "UTF-8")); } public void setNagoyaMode(boolean mode) { @@ -57,29 +66,48 @@ int counter = 0; // CSV header - System.out.println("name,fixed,area,geom"); - this.ow.write("name,fixed,area,geom"); + System.out.println("name,score,lon,lat"); + this.ow.write("name,score,lon,lat"); + this.ow0.write("name,score,lon,lat"); + this.ow1.write("name,score,lon,lat"); + this.ow2.write("name,score,lon,lat"); this.ow.newLine(); + this.ow0.newLine(); + this.ow1.newLine(); + this.ow2.newLine(); - PreparedStatement ps8 = con.prepareStatement("SELECT idref,name,kana,lat,lon,fixed FROM bus_stop"); + PreparedStatement ps8 = con.prepareStatement("SELECT name,ST_X(ST_TRANSFORM(geom,4612)) as lon, ST_Y(ST_TRANSFORM(geom,4612)) as lat,fixed FROM t_busstop"); ResultSet rset8 = ps8.executeQuery(); while (rset8.next()) { - //String idref = rset8.getString("idref"); String name = rset8.getString("name"); - //String kana = rset8.getString("kana"); Double lat = rset8.getDouble("lat"); Double lon = rset8.getDouble("lon"); int score = rset8.getInt("fixed"); counter++; String osm_node; - osm_node = "\""+ escapeStr(name) +"\",\""+ score +"\",\"0\",\""+ Double.toString(lon) +"\",\""+ Double.toString(lat) +"\""; + osm_node = "\""+ escapeStr(name) +"\",\""+ score +"\",\""+ Double.toString(lon) +"\",\""+ Double.toString(lat) +"\""; System.out.println(osm_node); this.ow.write(osm_node); this.ow.newLine(); + if (score == 0) { + this.ow0.write(osm_node); + this.ow0.newLine(); + } + else if (score < 100) { + this.ow1.write(osm_node); + this.ow1.newLine(); + } + else { + this.ow2.write(osm_node); + this.ow2.newLine(); + } } rset8.close(); this.ow.flush(); + this.ow0.flush(); + this.ow1.flush(); + this.ow2.flush(); return counter; }