diff --git a/.gitignore b/.gitignore index fbc9269..148fd8f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ Icon? ehthumbs.db [Tt]humbs.db -/nbproject/private/ -/build/ -/dist/ \ No newline at end of file +**/nbproject/private/ +/build/** +!/build/ +/dist/** \ No newline at end of file diff --git a/src/osm/jp/coverage/busstop/ToGeoJSON.java b/src/osm/jp/coverage/busstop/ToGeoJSON.java index 05533ce..ed02d4b 100644 --- a/src/osm/jp/coverage/busstop/ToGeoJSON.java +++ b/src/osm/jp/coverage/busstop/ToGeoJSON.java @@ -25,13 +25,20 @@ */ public class ToGeoJSON { public static void main (String[] argv) throws Exception { + boolean slim = false; + for (String arg : argv) { + if (arg.equals("-slim")) { + slim = true; + } + } Connection con = DatabaseTool.openDb("postgis"); - outputDb(con, "WHERE fixed=0", new File("busstop0.json")); - outputDb(con, "WHERE fixed=1", new File("busstop1.json")); - outputDb(con, "WHERE fixed>1", new File("busstop2.json")); + outputDb(con, "", new File("busstop.json"), false); + outputDb(con, "WHERE fixed=0", new File("busstop0.json"), slim); + outputDb(con, "WHERE fixed=1", new File("busstop1.json"), slim); + outputDb(con, "WHERE fixed>1", new File("busstop2.json"), slim); } - public static void outputDb(Connection con, String whereStr, File outputFile) throws Exception { + public static void outputDb(Connection con, String whereStr, File outputFile, boolean slim) throws Exception { try (BufferedWriter ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"))) { String line = "{" + "\"type\": \"FeatureCollection\"," + @@ -40,8 +47,16 @@ ow.write(line); ow.newLine(); - PreparedStatement ps8 = con.prepareStatement("SELECT row_to_json(feature) FROM (" - + "select 'Feature' As type, ST_AsGeoJSON(ST_Transform(t_busstop.geom,4326))::json As geometry From t_busstop "+ whereStr +" order by area,gmlid) As feature"); + String sql = "SELECT row_to_json(feature) FROM (" + + "select 'Feature' As type, " + + "ST_AsGeoJSON(ST_Transform(t_busstop.geom,4326))::json As geometry, row_to_json((" + + "SELECT p FROM (SELECT t_busstop.gmlid, t_busstop.fixed) AS p" + + ")) AS properties From t_busstop "+ whereStr +" order by area,gmlid) As feature"; + if (slim) { + sql = "SELECT row_to_json(feature) FROM (" + + "select 'Feature' As type, ST_AsGeoJSON(ST_Transform(t_busstop.geom,4326))::json As geometry From t_busstop "+ whereStr +" order by area,gmlid) As feature"; + } + PreparedStatement ps8 = con.prepareStatement(sql); try (ResultSet rset8 = ps8.executeQuery()) { boolean top = true; while (rset8.next()) { diff --git a/src/osm/jp/coverage/fuel/ToGeoJSON.java b/src/osm/jp/coverage/fuel/ToGeoJSON.java index f2d705f..c2a5067 100644 --- a/src/osm/jp/coverage/fuel/ToGeoJSON.java +++ b/src/osm/jp/coverage/fuel/ToGeoJSON.java @@ -9,7 +9,6 @@ import java.sql.ResultSet; import jp.co.areaweb.tools.database.DatabaseTool; -import static osm.jp.coverage.fuel.DbFuel.TABLE_NAME; /** * PostGISデータをGeoJSONファイルに出力する。