diff --git a/src/coverage_PoliceJson.sh b/src/coverage_PoliceJson.sh index 4eab335..1517b7f 100644 --- a/src/coverage_PoliceJson.sh +++ b/src/coverage_PoliceJson.sh @@ -16,7 +16,8 @@ tar czvf policeJSON.tgz vtile/*.json ### export from PostGIS -java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToGeoJSON -slim +#java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToGeoJSON -slim +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToGeoJSON # output file "coverage.police2.csv" and "coverage.police2.json" java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.Coverage2 diff --git a/src/osm/jp/coverage/police/Coverage5.java b/src/osm/jp/coverage/police/Coverage5.java index 8bed251..08977f2 100644 --- a/src/osm/jp/coverage/police/Coverage5.java +++ b/src/osm/jp/coverage/police/Coverage5.java @@ -11,11 +11,10 @@ import org.xml.sax.SAXException; import jp.co.areaweb.tools.database.DatabaseTool; import osm.jp.postgis.CoverageAll; -import osm.jp.postgis.CoverageData; /** * 国土数値情報 警察署データ(平成24年:2012) - * code = 派出所 + * code = 駐在所 * @author yuu */ public class Coverage5 { @@ -35,7 +34,7 @@ try { obj.load(conPost, conHsql, DbPolice.TABLE_NAME, "code=5"); obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)5:派出所"); + obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)5:駐在所"); } finally { DatabaseTool.closeDb(conHsql); diff --git a/src/osm/jp/coverage/police/Coverage6.java b/src/osm/jp/coverage/police/Coverage6.java new file mode 100644 index 0000000..c9bef35 --- /dev/null +++ b/src/osm/jp/coverage/police/Coverage6.java @@ -0,0 +1,48 @@ +package osm.jp.coverage.police; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import org.xml.sax.SAXException; +import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.postgis.CoverageAll; + +/** + * 国土数値情報 警察署データ(平成24年:2012) + * code = 派出所 + * @author yuu + */ +public class Coverage6 { + + public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException + { + File dir = new File("GML_POLICE"); + File outputFileCsv = new File(dir, "coverage.police6.csv"); + File outputFileJson = new File(dir, "coverage.police6.json"); + + CoverageAll obj = new CoverageAll(); + obj.setTablename(DbPolice.TABLE_NAME); + obj.setData(new ArrayList<>()); + + Connection conPost = DatabaseTool.openDb("postgis"); + Connection conHsql = DatabaseTool.openDb("database"); + try { + obj.load(conPost, conHsql, DbPolice.TABLE_NAME, "code=6"); + obj.outputCSV(outputFileCsv); + obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)6:派出所"); + } + finally { + DatabaseTool.closeDb(conHsql); + DatabaseTool.closeDb(conPost); + } + } + + public Coverage6() throws ClassNotFoundException, SQLException, IOException { + super(); + } +} diff --git a/src/osm/jp/coverage/police/ToGeoJSON.java b/src/osm/jp/coverage/police/ToGeoJSON.java index 6155d0f..496a185 100644 --- a/src/osm/jp/coverage/police/ToGeoJSON.java +++ b/src/osm/jp/coverage/police/ToGeoJSON.java @@ -38,6 +38,8 @@ obj.outputDb(con, "WHERE fixed>0 and code=4", new File(dir, "police4.json"), slim); obj.outputDb(con, "WHERE fixed=0 and code=5", new File(dir, "police5z.json"), slim); obj.outputDb(con, "WHERE fixed>0 and code=5", new File(dir, "police5.json"), slim); + obj.outputDb(con, "WHERE fixed=0 and code=6", new File(dir, "police6z.json"), slim); + obj.outputDb(con, "WHERE fixed>0 and code=6", new File(dir, "police6.json"), slim); } finally { DatabaseTool.closeDb(con); diff --git a/src/osm/jp/postgis/ToGeoJSON.java b/src/osm/jp/postgis/ToGeoJSON.java index e1237ff..c18b89e 100644 --- a/src/osm/jp/postgis/ToGeoJSON.java +++ b/src/osm/jp/postgis/ToGeoJSON.java @@ -55,12 +55,15 @@ try (BufferedWriter ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"))) { String sql = "SELECT row_to_json(feature) FROM (" + "select 'Feature' As type, " - + "ST_AsGeoJSON(ST_Transform(t_"+ this.tableName +".geom,4326))::json As geometry, row_to_json((" - + "SELECT p FROM (SELECT t_"+ this.tableName +".idref, t_"+ this.tableName +".fixed) AS p" + + "ST_AsGeoJSON(ST_Transform(t_"+ this.tableName +".geom,4326))::json As geometry, " + + "row_to_json((" + + "SELECT p FROM (SELECT t_"+ this.tableName +".idref, t_"+ this.tableName +".fixed) AS p" + ")) AS properties From t_"+ this.tableName +" "+ whereStr +" order by area,idref) As feature"; if (slim) { sql = "SELECT row_to_json(feature) FROM (" - + "select 'Feature' As type, ST_AsGeoJSON(ST_Transform(t_"+ this.tableName +".geom,4326))::json As geometry From t_"+ this.tableName +" "+ whereStr +" order by area,idref) As feature"; + + "select 'Feature' As type, " + + "ST_AsGeoJSON(ST_Transform(t_"+ this.tableName +".geom,4326))::json As geometry From t_"+ this.tableName +" " + + whereStr +" order by area,idref) As feature"; } System.out.println(sql); diff --git a/test/newfile.json b/test/newfile.json new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/newfile.json diff --git a/test/osm/jp/coverage/police/AllTest.java b/test/osm/jp/coverage/police/AllTest.java index 452b3bb..ef6cabe 100644 --- a/test/osm/jp/coverage/police/AllTest.java +++ b/test/osm/jp/coverage/police/AllTest.java @@ -17,7 +17,8 @@ ToGeoJSONTest.class, Coverage2Test.class, Coverage4Test.class, - Coverage5Test.class + Coverage5Test.class, + Coverage6Test.class }) public class AllTest { diff --git a/test/osm/jp/coverage/police/Coverage6Test.java b/test/osm/jp/coverage/police/Coverage6Test.java new file mode 100644 index 0000000..b2f9deb --- /dev/null +++ b/test/osm/jp/coverage/police/Coverage6Test.java @@ -0,0 +1,29 @@ +package osm.jp.coverage.police; + +import java.io.IOException; +import java.sql.SQLException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import org.junit.Test; +import static org.junit.Assert.*; +import org.xml.sax.SAXException; + +/** + * + * @author yuu + */ +public class Coverage6Test { + + @Test + public void testMain() { + try { + System.out.println("main"); + String[] args = new String[0]; + Coverage5.main(args); + } + catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + fail("The test case is a prototype."); + } + } + +}