diff --git a/src/coverage_BUSSTOP.sh b/src/coverage_BUSSTOP.sh index d03052d..873490b 100755 --- a/src/coverage_BUSSTOP.sh +++ b/src/coverage_BUSSTOP.sh @@ -22,7 +22,7 @@ java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.busstop.DbBusstop -OUTPUT GML_BUSSTOP/P11-10.removed.txt mv GML_BUSSTOP/P11-10.removed.txt GML_BUSSTOP/P11-10.removed.json.txt -java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.busstop.ToPostgis postgis +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.busstop.ToPostgis osmdb java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.busstop.ToPostgis gisdb diff --git a/src/coverage_FUEL.sh b/src/coverage_FUEL.sh index 9abf86f..b256d37 100755 --- a/src/coverage_FUEL.sh +++ b/src/coverage_FUEL.sh @@ -21,7 +21,7 @@ java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar:javax.json.jar osm.jp.coverage.fuel.DbFuel -OUTPUT GML_FUEL/P07-15.removed.txt mv GML_FUEL/P07-15.removed.txt GML_FUEL/P07-15.removed.json.txt -java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.fuel.ToPostgis postgis +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.fuel.ToPostgis osmdb java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.coverage.fuel.ToPostgis gisdb ## create 't_fuel.carto.csv' diff --git a/src/coverage_POLICE.sh b/src/coverage_POLICE.sh index b8f3e60..9c1ce5e 100755 --- a/src/coverage_POLICE.sh +++ b/src/coverage_POLICE.sh @@ -22,7 +22,8 @@ java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.DbPolice java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.DbExist java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.Police -java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToPostgis +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToPostgis osmdb +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToPostgis gisdb diff --git a/src/coverage_toPostGIS.sh b/src/coverage_toPostGIS.sh new file mode 100755 index 0000000..ef065c2 --- /dev/null +++ b/src/coverage_toPostGIS.sh @@ -0,0 +1,12 @@ +# +# HOST ~/docker/osm_get +# +# cd ~/docker/osm_get +# docker run --rm -it -v $(pwd)/share:/root/osmCoverageBin/share haya4/osmget bash +# docker run --rm -t -v $(pwd)/share:/root/osmCoverageBin/share haya4/osmget bash coverage_toPostGIS.sh +# +pwd +ls -l + +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb.jar:postgresql.jar osm.jp.postgis.Postgis ./share + diff --git a/src/osm/jp/api/Coverage.java b/src/osm/jp/api/Coverage.java new file mode 100644 index 0000000..8071b9b --- /dev/null +++ b/src/osm/jp/api/Coverage.java @@ -0,0 +1,37 @@ +package osm.jp.api; + +import java.io.File; +import java.sql.Connection; +import java.util.ArrayList; +import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.postgis.CoverageAll; + +public abstract class Coverage { + public static final String DB_PORP_GISDB = "gisdb"; + public static final String DB_PORP_LOCALDB = "database"; + + public static void output(File dir, String tableName, String comment) throws Exception { + output(dir, tableName, tableName.toLowerCase(), comment, null); + } + + public static void output(File dir, String tableName, String name, String comment, String where) throws Exception { + File outputFileCsv = new File(dir, "coverage."+ name +".csv"); + File outputFileJson = new File(dir, "coverage."+ name +".json"); + + CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); + obj.setTablename(tableName); + obj.setData(new ArrayList<>()); + + Connection conPost = DatabaseTool.openDb(DB_PORP_GISDB); + Connection conHsql = DatabaseTool.openDb(DB_PORP_LOCALDB); + try { + obj.load(conPost, conHsql, tableName, where); + obj.outputCSV(outputFileCsv); + obj.outputJson(outputFileJson, comment); + } + finally { + DatabaseTool.closeDb(conHsql); + DatabaseTool.closeDb(conPost); + } + } +} diff --git a/src/osm/jp/api/Osmdb.java b/src/osm/jp/api/Osmdb.java index ad965c1..6aa1bf4 100644 --- a/src/osm/jp/api/Osmdb.java +++ b/src/osm/jp/api/Osmdb.java @@ -26,7 +26,7 @@ public abstract class Osmdb { public String tableName; - public Connection hsqldb = null; // hsqldb DatabaseTool.openDb("database"); + public Connection hsqldb = null; // hsqldb DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); public Osmdb(Connection hsqldb, String tableName) { this.hsqldb = hsqldb; diff --git a/src/osm/jp/coverage/busstop/Busstop.java b/src/osm/jp/coverage/busstop/Busstop.java index a648ad8..429d627 100644 --- a/src/osm/jp/coverage/busstop/Busstop.java +++ b/src/osm/jp/coverage/busstop/Busstop.java @@ -13,6 +13,7 @@ import java.text.SimpleDateFormat; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Japan; public class Busstop { @@ -28,15 +29,16 @@ * @param args * @throws java.lang.Exception * */ + @SuppressWarnings("ResultOfObjectAllocationIgnored") public static void main(String[] args) throws Exception { // HSQLディレクトリがなければ作る - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { dbdir.mkdir(); } - try (Connection hsql = DatabaseTool.openDb("database")) { + try (Connection hsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { new Busstop(hsql); } } @@ -76,9 +78,9 @@ int score = rset1.getInt("score"); String name = rset1.getString("name"); boolean removed = rset1.getBoolean("removed"); - String gmlid = null; - int area = 0; - int fixed1 = 0; + String gmlid; + int area; + int fixed1; // 指定の緯度経度を中心とする半径200x2m四方の矩形領域 RectArea rect = new RectArea(lat, lon, NEER*2); // 600m 四方 diff --git a/src/osm/jp/coverage/busstop/Coverage.java b/src/osm/jp/coverage/busstop/Coverage.java deleted file mode 100644 index bd42fcd..0000000 --- a/src/osm/jp/coverage/busstop/Coverage.java +++ /dev/null @@ -1,40 +0,0 @@ -package osm.jp.coverage.busstop; - -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; - -public class Coverage { - public static final String TABLE_NAME = "t_busstop"; - - public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException - { - File dir = new File("GML_BUSSTOP"); - File outputFileCsv = new File(dir, "coverage.busstop.csv"); - File outputFileJson = new File(dir, "coverage.busstop.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - obj.setTablename(DbBusstop.TABLE_NAME); - obj.setData(new ArrayList<>()); - - Connection conPost = DatabaseTool.openDb("postgis"); - Connection conHsql = DatabaseTool.openDb("database"); - try { - obj.load(conPost, conHsql, "busstop", null); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 バス停留所データ 平成22年"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } -} diff --git a/src/osm/jp/coverage/busstop/CoverageBusstop.java b/src/osm/jp/coverage/busstop/CoverageBusstop.java new file mode 100644 index 0000000..33e5670 --- /dev/null +++ b/src/osm/jp/coverage/busstop/CoverageBusstop.java @@ -0,0 +1,17 @@ +package osm.jp.coverage.busstop; + +import java.io.File; +import osm.jp.api.Coverage; +import static osm.jp.api.Coverage.output; + +public class CoverageBusstop extends Coverage { + + public static void main(String[] args) throws Exception + { + output( + new File("GML_BUSSTOP"), + DbBusstop.TABLE_NAME, + "国土数値情報 バス停留所データ 平成22年" + ); + } +} diff --git a/src/osm/jp/coverage/busstop/DbBusstop.java b/src/osm/jp/coverage/busstop/DbBusstop.java index 1455baa..5055005 100644 --- a/src/osm/jp/coverage/busstop/DbBusstop.java +++ b/src/osm/jp/coverage/busstop/DbBusstop.java @@ -15,6 +15,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.Db; import osm.jp.api.Osmdb; @@ -65,12 +66,12 @@ } // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { throw new FileNotFoundException("Directory 'database' is not found."); } - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { switch (args[0]) { case "-INIT": { @@ -251,9 +252,9 @@ * @throws SQLException */ public static void showGmlPoint(Connection con, Node node, int areacode) throws IOException, SQLException { - String positionStr = ""; - String latStr = ""; - String lonStr = ""; + String positionStr; + String latStr; + String lonStr; String idStr = ""; NamedNodeMap nodeMap = node.getAttributes(); @@ -453,6 +454,7 @@ * 'table.BUSSTOP'の内容をCSV形式にして標準出力に出力する */ @Override + @SuppressWarnings("CallToPrintStackTrace") public void export() { try { System.out.println("TABLE: "+ tableName); diff --git a/src/osm/jp/coverage/busstop/DbExistBusstop.java b/src/osm/jp/coverage/busstop/DbExistBusstop.java index 6dcd71a..7310997 100644 --- a/src/osm/jp/coverage/busstop/DbExistBusstop.java +++ b/src/osm/jp/coverage/busstop/DbExistBusstop.java @@ -13,6 +13,7 @@ import java.sql.SQLException; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.OsmExist; public class DbExistBusstop extends OsmExist { @@ -49,12 +50,12 @@ } // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { throw new FileNotFoundException("Directory 'database' is not found."); } - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { switch (args[0]) { case "-INIT": { diff --git a/src/osm/jp/coverage/busstop/NagoyaBusstop.java b/src/osm/jp/coverage/busstop/NagoyaBusstop.java index 2784e9a..7a0786d 100644 --- a/src/osm/jp/coverage/busstop/NagoyaBusstop.java +++ b/src/osm/jp/coverage/busstop/NagoyaBusstop.java @@ -28,6 +28,7 @@ import jp.co.areaweb.tools.csv.CsvFile; import jp.co.areaweb.tools.csv.CsvRecord; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; public class NagoyaBusstop { @@ -56,12 +57,12 @@ } // HSQLディレクトリがなければ作る - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { dbdir.mkdir(); } - Connection con = DatabaseTool.openDb("database"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); NagoyaBusstop.initDb(con); try { @@ -80,7 +81,7 @@ Connection conPost = null; try { - conPost = DatabaseTool.openDb("postgis"); + conPost = DatabaseTool.openDb(CoverageBusstop.DB_PORP_GISDB); DoSQL.sqlExecute(conPost, "DROP TABLE nagoya_busstop;"); DoSQL.sqlExecute(conPost, "CREATE TABLE nagoya_busstop (gid SERIAL PRIMARY KEY, name text, kana text, fixed integer, area integer, geom GEOMETRY(POINT, 4612));"); DoSQL.sqlExecute(conPost, "CREATE INDEX ix_nagoya_busstop_geom ON nagoya_busstop USING GiST (geom);"); diff --git a/src/osm/jp/coverage/busstop/ToCartoCSV.java b/src/osm/jp/coverage/busstop/ToCartoCSV.java index 834c2e0..cfc62b6 100644 --- a/src/osm/jp/coverage/busstop/ToCartoCSV.java +++ b/src/osm/jp/coverage/busstop/ToCartoCSV.java @@ -25,6 +25,7 @@ public class ToCartoCSV { public static final String CSV_FILE_NAME = "busstop.carto.csv"; + @SuppressWarnings("CallToPrintStackTrace") public static void main (String[] argv) { try { outputDb(); @@ -36,7 +37,7 @@ public static void outputDb() throws Exception { File csvFile = new File(CSV_FILE_NAME); try (BufferedWriter ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile), "UTF-8"))) { - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(CoverageBusstop.DB_PORP_GISDB); // CSV header System.out.println("gid,geom,score"); ow.write("gid,geom,score"); diff --git a/src/osm/jp/coverage/busstop/ToGeoJSON.java b/src/osm/jp/coverage/busstop/ToGeoJSON.java index 40503ef..43a60fa 100644 --- a/src/osm/jp/coverage/busstop/ToGeoJSON.java +++ b/src/osm/jp/coverage/busstop/ToGeoJSON.java @@ -32,7 +32,7 @@ + "row_to_json((" + "SELECT p FROM (SELECT t_%s.gmlid, t_%s.fixed) AS p" + ")) AS properties From t_%s %s order by area,gmlid) As feature"; - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(CoverageBusstop.DB_PORP_GISDB); obj.outputDb(con, "", new File("GML_BUSSTOP", "busstop.json"), false); obj.outputDb(con, "WHERE fixed=0", new File("GML_BUSSTOP", "busstop0.json"), false); obj.outputDb(con, "WHERE fixed=1", new File("GML_BUSSTOP", "busstop1.json"), false); diff --git a/src/osm/jp/coverage/fuel/Coverage.java b/src/osm/jp/coverage/fuel/Coverage.java deleted file mode 100644 index 80418db..0000000 --- a/src/osm/jp/coverage/fuel/Coverage.java +++ /dev/null @@ -1,39 +0,0 @@ -package osm.jp.coverage.fuel; - -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; - -public class Coverage { - - public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException - { - File dir = new File("GML_FUEL"); - File outputFileCsv = new File(dir, "coverage.fuel.csv"); - File outputFileJson = new File(dir, "coverage.fuel.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - obj.setTablename(DbFuel.TABLE_NAME); - obj.setData(new ArrayList<>()); - - Connection conPost = DatabaseTool.openDb("postgis"); - Connection conHsql = DatabaseTool.openDb("database"); - try { - obj.load(conPost, conHsql, DbFuel.TABLE_NAME, null); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 燃料給油所データ 平成28年(2016)"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } -} diff --git a/src/osm/jp/coverage/fuel/CoverageFuel.java b/src/osm/jp/coverage/fuel/CoverageFuel.java new file mode 100644 index 0000000..61a9980 --- /dev/null +++ b/src/osm/jp/coverage/fuel/CoverageFuel.java @@ -0,0 +1,15 @@ +package osm.jp.coverage.fuel; + +import java.io.File; +import osm.jp.api.Coverage; + +public class CoverageFuel extends Coverage { + + public static void main(String[] args) throws Exception { + output( + new File("GML_FUEL"), + DbFuel.TABLE_NAME, + "国土数値情報 燃料給油所データ 平成28年(2016)" + ); + } +} diff --git a/src/osm/jp/coverage/fuel/DbExistFuel.java b/src/osm/jp/coverage/fuel/DbExistFuel.java index aaa3520..b259563 100644 --- a/src/osm/jp/coverage/fuel/DbExistFuel.java +++ b/src/osm/jp/coverage/fuel/DbExistFuel.java @@ -4,6 +4,7 @@ import java.io.FileNotFoundException; import java.sql.Connection; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.OsmExist; public class DbExistFuel extends OsmExist { @@ -25,12 +26,12 @@ } // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { - throw new FileNotFoundException("Directory 'database' is not found."); + throw new FileNotFoundException("Directory 'Coverage.DB_PORP_LOCALDB' is not found."); } - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { switch (args[0]) { case "-INIT": { diff --git a/src/osm/jp/coverage/fuel/DbFuel.java b/src/osm/jp/coverage/fuel/DbFuel.java index aee0f42..3aa7a2f 100644 --- a/src/osm/jp/coverage/fuel/DbFuel.java +++ b/src/osm/jp/coverage/fuel/DbFuel.java @@ -14,6 +14,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.Db; import osm.jp.api.Osmdb; @@ -41,12 +42,12 @@ } // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { throw new FileNotFoundException("Directory 'database' is not found."); } - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { switch (args[0]) { case "-INIT": { diff --git a/src/osm/jp/coverage/fuel/Fuel.java b/src/osm/jp/coverage/fuel/Fuel.java index f32472b..e63117f 100644 --- a/src/osm/jp/coverage/fuel/Fuel.java +++ b/src/osm/jp/coverage/fuel/Fuel.java @@ -11,6 +11,7 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Japan; public class Fuel { @@ -40,12 +41,12 @@ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException { // HSQLディレクトリがなければ作る - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { dbdir.mkdir(); } - try (Connection hsql = DatabaseTool.openDb("database")) { + try (Connection hsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { new Fuel(hsql); } } diff --git a/src/osm/jp/coverage/fuel/OsmExistFuel.java b/src/osm/jp/coverage/fuel/OsmExistFuel.java index c0aa614..87b6624 100644 --- a/src/osm/jp/coverage/fuel/OsmExistFuel.java +++ b/src/osm/jp/coverage/fuel/OsmExistFuel.java @@ -3,6 +3,7 @@ import java.sql.Connection; import java.util.ArrayList; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Feature; import osm.jp.api.Japan; @@ -17,7 +18,7 @@ Connection hsqldb = null; try { // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); ArrayList features = new ArrayList<>(); features.add(new Feature(Feature.NODE, "amenity", "fuel", POINT_NO_BRAND | POINT_FIXME)); diff --git a/src/osm/jp/coverage/fuel/ToCartoCSV.java b/src/osm/jp/coverage/fuel/ToCartoCSV.java index 90692f6..d11c741 100644 --- a/src/osm/jp/coverage/fuel/ToCartoCSV.java +++ b/src/osm/jp/coverage/fuel/ToCartoCSV.java @@ -9,6 +9,7 @@ import java.sql.ResultSet; import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.api.Coverage; /** * PostGISデータをCarto用のCSVファイルに出力する。 @@ -25,7 +26,7 @@ public static final String CSV_FILE_NAME = "t_fuel.carto.csv"; public static void main (String[] argv) throws Exception { - outputDb(DatabaseTool.openDb("postgis")); + outputDb(DatabaseTool.openDb(Coverage.DB_PORP_GISDB)); } public static void outputDb(Connection con) throws Exception { diff --git a/src/osm/jp/coverage/fuel/ToGeoJSON.java b/src/osm/jp/coverage/fuel/ToGeoJSON.java index 8d4c684..55d1c14 100644 --- a/src/osm/jp/coverage/fuel/ToGeoJSON.java +++ b/src/osm/jp/coverage/fuel/ToGeoJSON.java @@ -3,6 +3,7 @@ import java.io.File; import java.sql.Connection; import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.api.Coverage; /** * PostGISデータをGeoJSONファイルに出力する。 @@ -27,7 +28,7 @@ } osm.jp.postgis.ToGeoJSON obj = new osm.jp.postgis.ToGeoJSON(DbFuel.TABLE_NAME); - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); try { obj.outputDb(con, "", new File("fuel.json"), false); obj.outputDb(con, "WHERE fixed=0", new File("fuel0.json"), slim); diff --git a/src/osm/jp/coverage/fuel/ToPostgis.java b/src/osm/jp/coverage/fuel/ToPostgis.java index b63b3af..72c96db 100644 --- a/src/osm/jp/coverage/fuel/ToPostgis.java +++ b/src/osm/jp/coverage/fuel/ToPostgis.java @@ -5,7 +5,7 @@ /** * 国土数値情報から読み取ったデータをPostGISへインサートする。 - * 出力dbプロパティ: "postgis.properties" + * 出力dbプロパティ: "gisdb.properties" * テーブル名: t_FUEL * インデックス: ix_t_FUEL_geom * gid PostGISの識別ID diff --git a/src/osm/jp/coverage/police/Coverage2.java b/src/osm/jp/coverage/police/Coverage2.java deleted file mode 100644 index 6549121..0000000 --- a/src/osm/jp/coverage/police/Coverage2.java +++ /dev/null @@ -1,44 +0,0 @@ -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 Coverage2 { - - 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.police2.csv"); - File outputFileJson = new File(dir, "coverage.police2.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - 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=2"); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)2:警察署"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } -} diff --git a/src/osm/jp/coverage/police/Coverage4.java b/src/osm/jp/coverage/police/Coverage4.java deleted file mode 100644 index 5b489cb..0000000 --- a/src/osm/jp/coverage/police/Coverage4.java +++ /dev/null @@ -1,44 +0,0 @@ -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 Coverage4 { - - 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.police4.csv"); - File outputFileJson = new File(dir, "coverage.police4.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - 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=4"); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)4:交番"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } -} diff --git a/src/osm/jp/coverage/police/Coverage5.java b/src/osm/jp/coverage/police/Coverage5.java deleted file mode 100644 index 5b927ae..0000000 --- a/src/osm/jp/coverage/police/Coverage5.java +++ /dev/null @@ -1,48 +0,0 @@ -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 Coverage5 { - - 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.police5.csv"); - File outputFileJson = new File(dir, "coverage.police5.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - 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=5"); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成24年:2012)5:駐在所"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } - - public Coverage5() throws ClassNotFoundException, SQLException, IOException { - super(); - } -} diff --git a/src/osm/jp/coverage/police/Coverage6.java b/src/osm/jp/coverage/police/Coverage6.java deleted file mode 100644 index bcc5115..0000000 --- a/src/osm/jp/coverage/police/Coverage6.java +++ /dev/null @@ -1,48 +0,0 @@ -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(new File(dir, "pbfDate.json")); - 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/CoveragePolice2.java b/src/osm/jp/coverage/police/CoveragePolice2.java new file mode 100644 index 0000000..d360a97 --- /dev/null +++ b/src/osm/jp/coverage/police/CoveragePolice2.java @@ -0,0 +1,24 @@ +package osm.jp.coverage.police; + +import java.io.File; +import osm.jp.api.Coverage; +import static osm.jp.api.Coverage.output; + +/** + * 国土数値情報 警察署データ(平成24年:2012) + * code = 警察署 + * @author yuu + */ +public class CoveragePolice2 extends Coverage { + + public static void main(String[] args) throws Exception + { + output( + new File("GML_POLICE"), + DbPolice.TABLE_NAME, + "police2", + "国土数値情報 警察署データ(平成24年:2012)2:警察署", + "code=2" + ); + } +} diff --git a/src/osm/jp/coverage/police/CoveragePolice4.java b/src/osm/jp/coverage/police/CoveragePolice4.java new file mode 100644 index 0000000..dc91f73 --- /dev/null +++ b/src/osm/jp/coverage/police/CoveragePolice4.java @@ -0,0 +1,23 @@ +package osm.jp.coverage.police; + +import java.io.File; +import osm.jp.api.Coverage; + +/** + * 国土数値情報 警察署データ(平成24年:2012) + * code = 交番 + * @author yuu + */ +public class CoveragePolice4 extends Coverage { + + public static void main(String[] args) throws Exception + { + output( + new File("GML_POLICE"), + DbPolice.TABLE_NAME, + "police4", + "国土数値情報 警察署データ(平成24年:2012)4:交番", + "code=4" + ); + } +} diff --git a/src/osm/jp/coverage/police/CoveragePolice5.java b/src/osm/jp/coverage/police/CoveragePolice5.java new file mode 100644 index 0000000..0ca65d2 --- /dev/null +++ b/src/osm/jp/coverage/police/CoveragePolice5.java @@ -0,0 +1,22 @@ +package osm.jp.coverage.police; + +import java.io.File; +import osm.jp.api.Coverage; + +/** + * 国土数値情報 警察署データ(平成24年:2012) + * code = 駐在所 + * @author yuu + */ +public class CoveragePolice5 extends Coverage +{ + public static void main(String[] args) throws Exception { + output( + new File("GML_POLICE"), + DbPolice.TABLE_NAME, + "police5", + "国土数値情報 警察署データ(平成24年:2012)5:駐在所", + "code=5" + ); + } +} diff --git a/src/osm/jp/coverage/police/CoveragePolice6.java b/src/osm/jp/coverage/police/CoveragePolice6.java new file mode 100644 index 0000000..5208702 --- /dev/null +++ b/src/osm/jp/coverage/police/CoveragePolice6.java @@ -0,0 +1,23 @@ +package osm.jp.coverage.police; + +import java.io.File; +import osm.jp.api.Coverage; + +/** + * 国土数値情報 警察署データ(平成24年:2012) + * code = 派出所 + * @author yuu + */ +public class CoveragePolice6 extends Coverage +{ + public static void main(String[] args) throws Exception + { + output( + new File("GML_POLICE"), + DbPolice.TABLE_NAME, + "police6", + "国土数値情報 警察署データ(平成24年:2012)6:派出所", + "code=6" + ); + } +} diff --git a/src/osm/jp/coverage/police/DbExistPolice.java b/src/osm/jp/coverage/police/DbExistPolice.java index c7c25d0..262431a 100644 --- a/src/osm/jp/coverage/police/DbExistPolice.java +++ b/src/osm/jp/coverage/police/DbExistPolice.java @@ -3,6 +3,7 @@ import java.sql.Connection; import java.sql.SQLException; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.OsmExist; public class DbExistPolice extends OsmExist { @@ -17,7 +18,7 @@ Connection hsqldb = null; try { // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); /** * 既存のOSM:amenity=policeを読み込む diff --git a/src/osm/jp/coverage/police/DbPolice.java b/src/osm/jp/coverage/police/DbPolice.java index 259fd51..a7d95d1 100644 --- a/src/osm/jp/coverage/police/DbPolice.java +++ b/src/osm/jp/coverage/police/DbPolice.java @@ -14,6 +14,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.Db; public class DbPolice { @@ -39,15 +40,15 @@ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException { // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { - throw new FileNotFoundException("Directory 'database' is not found."); + throw new FileNotFoundException("Directory 'Coverage.DB_PORP_LOCALDB' is not found."); } Connection conHsql = null; try { // DB.tableを作成 - conHsql = DatabaseTool.openDb("database"); + conHsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); create(conHsql); /** diff --git a/src/osm/jp/coverage/police/Police.java b/src/osm/jp/coverage/police/Police.java index be96a32..9df36ab 100644 --- a/src/osm/jp/coverage/police/Police.java +++ b/src/osm/jp/coverage/police/Police.java @@ -14,6 +14,7 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Japan; public class Police { @@ -44,7 +45,7 @@ */ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException { - Connection con = DatabaseTool.openDb("database"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); try { new Police(con); } diff --git a/src/osm/jp/coverage/police/ToGeoJSON.java b/src/osm/jp/coverage/police/ToGeoJSON.java index 496a185..24384b6 100644 --- a/src/osm/jp/coverage/police/ToGeoJSON.java +++ b/src/osm/jp/coverage/police/ToGeoJSON.java @@ -4,6 +4,7 @@ import java.sql.Connection; import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.api.Coverage; /** * PostGISデータをGeoJSONファイルに出力する。 @@ -29,7 +30,7 @@ File dir = new File("GML_POLICE"); osm.jp.postgis.ToGeoJSON obj = new osm.jp.postgis.ToGeoJSON(DbPolice.TABLE_NAME); - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); try { obj.outputDb(con, "", new File(dir, "police.json"), false); obj.outputDb(con, "WHERE fixed=0 and code=2", new File(dir, "police2z.json"), slim); diff --git a/src/osm/jp/coverage/postoffice/Coverage.java b/src/osm/jp/coverage/postoffice/Coverage.java deleted file mode 100644 index 2c80498..0000000 --- a/src/osm/jp/coverage/postoffice/Coverage.java +++ /dev/null @@ -1,39 +0,0 @@ -package osm.jp.coverage.postoffice; - -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; - -public class Coverage { - - public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException - { - File dir = new File("GML_POSTOFFICE"); - File outputFileCsv = new File(dir, "coverage.postoffice.csv"); - File outputFileJson = new File(dir, "coverage.postoffice.json"); - - CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json")); - obj.setTablename(DbPostoffice.TABLE_NAME); - obj.setData(new ArrayList<>()); - - Connection conPost = DatabaseTool.openDb("postgis"); - Connection conHsql = DatabaseTool.openDb("database"); - try { - obj.load(conPost, conHsql, DbPostoffice.TABLE_NAME, null); - obj.outputCSV(outputFileCsv); - obj.outputJson(outputFileJson, "国土数値情報 郵便局データ(平成25年)"); - } - finally { - DatabaseTool.closeDb(conHsql); - DatabaseTool.closeDb(conPost); - } - } -} diff --git a/src/osm/jp/coverage/postoffice/CoveragePostoffice.java b/src/osm/jp/coverage/postoffice/CoveragePostoffice.java new file mode 100644 index 0000000..967de53 --- /dev/null +++ b/src/osm/jp/coverage/postoffice/CoveragePostoffice.java @@ -0,0 +1,15 @@ +package osm.jp.coverage.postoffice; + +import java.io.File; +import osm.jp.api.Coverage; + +public class CoveragePostoffice extends Coverage +{ + public static void main(String[] args) throws Exception { + output( + new File("GML_POSTOFFICE"), + DbPostoffice.TABLE_NAME, + "国土数値情報 郵便局データ(平成25年)" + ); + } +} diff --git a/src/osm/jp/coverage/postoffice/DbExistPostoffice.java b/src/osm/jp/coverage/postoffice/DbExistPostoffice.java index 945ab2b..d3f4463 100644 --- a/src/osm/jp/coverage/postoffice/DbExistPostoffice.java +++ b/src/osm/jp/coverage/postoffice/DbExistPostoffice.java @@ -1,8 +1,8 @@ package osm.jp.coverage.postoffice; import java.sql.Connection; -import java.sql.SQLException; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.OsmExist; public class DbExistPostoffice extends OsmExist { @@ -17,7 +17,7 @@ Connection hsqldb = null; try { // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); /** * 既存のOSM郵便局を読み込む diff --git a/src/osm/jp/coverage/postoffice/DbPostoffice.java b/src/osm/jp/coverage/postoffice/DbPostoffice.java index b37e1dc..7209b52 100644 --- a/src/osm/jp/coverage/postoffice/DbPostoffice.java +++ b/src/osm/jp/coverage/postoffice/DbPostoffice.java @@ -14,6 +14,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.Db; public class DbPostoffice { @@ -32,7 +33,7 @@ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException { // HSQLディレクトリがなければエラー - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { throw new FileNotFoundException("Directory 'database' is not found."); } @@ -40,7 +41,7 @@ Connection con = null; try { // DB.tableを作成 - con = DatabaseTool.openDb("database"); + con = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); create(con); File gmlDir = new File("GML_POSTOFFICE"); diff --git a/src/osm/jp/coverage/postoffice/Postoffice.java b/src/osm/jp/coverage/postoffice/Postoffice.java index b3efeed..87e7d29 100644 --- a/src/osm/jp/coverage/postoffice/Postoffice.java +++ b/src/osm/jp/coverage/postoffice/Postoffice.java @@ -14,6 +14,7 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Japan; public class Postoffice { @@ -44,7 +45,7 @@ */ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException { - Connection con = DatabaseTool.openDb("database"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); try { new Postoffice(con); } diff --git a/src/osm/jp/coverage/postoffice/ToGeoJSON.java b/src/osm/jp/coverage/postoffice/ToGeoJSON.java index 8be1a3b..c376e41 100644 --- a/src/osm/jp/coverage/postoffice/ToGeoJSON.java +++ b/src/osm/jp/coverage/postoffice/ToGeoJSON.java @@ -4,6 +4,7 @@ import java.sql.Connection; import jp.co.areaweb.tools.database.DatabaseTool; +import osm.jp.api.Coverage; /** * PostGISデータをGeoJSONファイルに出力する。 @@ -28,7 +29,7 @@ } osm.jp.postgis.ToGeoJSON obj = new osm.jp.postgis.ToGeoJSON(DbPostoffice.TABLE_NAME); - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); try { obj.outputDb(con, "", new File("GML_POSTOFFICE", "postoffice.json"), false); obj.outputDb(con, "WHERE fixed=0", new File("GML_POSTOFFICE", "postoffice0.json"), slim); diff --git a/src/osm/jp/postgis/CoverageAll.java b/src/osm/jp/postgis/CoverageAll.java index 8525c81..68e9824 100644 --- a/src/osm/jp/postgis/CoverageAll.java +++ b/src/osm/jp/postgis/CoverageAll.java @@ -21,7 +21,6 @@ import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonReader; -import javax.json.JsonValue; import jp.co.areaweb.tools.csv.CsvFile; import jp.co.areaweb.tools.csv.CsvRecord; import osm.jp.api.Japan; @@ -41,8 +40,8 @@ CoverageAll obj = new CoverageAll(tableName); - Connection conPost = DatabaseTool.openDb("postgis"); - Connection conHsql = DatabaseTool.openDb("database"); + Connection conPost = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); + Connection conHsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); try { obj.load(conPost, conHsql); obj.outputCSV(outputFileCsv); diff --git a/src/osm/jp/postgis/ToGeoJSON.java b/src/osm/jp/postgis/ToGeoJSON.java index 328c603..ea2d7ef 100644 --- a/src/osm/jp/postgis/ToGeoJSON.java +++ b/src/osm/jp/postgis/ToGeoJSON.java @@ -32,7 +32,7 @@ } ToGeoJSON obj = new ToGeoJSON(DbPostoffice.TABLE_NAME); - Connection con = DatabaseTool.openDb("postgis"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); try { obj.outputDb(con, "", new File("postoffice.json"), false); obj.outputDb(con, "WHERE fixed=0", new File("postoffice0.json"), slim); diff --git a/src/osm/jp/postgis/ToPostgis.java b/src/osm/jp/postgis/ToPostgis.java index f0691f5..a625eac 100644 --- a/src/osm/jp/postgis/ToPostgis.java +++ b/src/osm/jp/postgis/ToPostgis.java @@ -13,11 +13,12 @@ import javax.xml.parsers.ParserConfigurationException; import jp.co.areaweb.tools.database.DatabaseTool; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.HttpPOST; /** * 国土数値情報から読み取ったデータをPostGISへインサートする。 - * 出力db名: "postgis.properties" + * 出力db名: "gisdb.properties" * テーブル名: t_POSTOFFICE * インデックス: ix_t_POSTOFFICE_geom * gid PostGISの識別ID @@ -57,10 +58,10 @@ * @throws Exception */ public void transport() throws Exception { - transport("postgis"); + transport(Coverage.DB_PORP_GISDB); } public void transport(String toPropertiy) throws Exception { - try (Connection conHsql = DatabaseTool.openDb("database"); + try (Connection conHsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); Connection conPost = DatabaseTool.openDb(toPropertiy)) { transportNew(conHsql, conPost); @@ -154,7 +155,7 @@ public void toCsv (File csvFile) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException { - try (Connection conPost = DatabaseTool.openDb("postgis"); + try (Connection conPost = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); BufferedWriter ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile), "UTF-8"))) { String header = items.getCsvHeader(); diff --git a/test/gisdb.properties b/test/gisdb.properties new file mode 100644 index 0000000..04ba2fe --- /dev/null +++ b/test/gisdb.properties @@ -0,0 +1,4 @@ +db_driver=org.postgresql.Driver +db_url=jdbc:postgresql://surveyor.mydns.jp:5432/gisdb +db_user=gisuser +db_passwd=gisuser diff --git a/test/osm/jp/coverage/AllTest.java b/test/osm/jp/coverage/AllTest.java index 3e1c7a5..bb1b75a 100644 --- a/test/osm/jp/coverage/AllTest.java +++ b/test/osm/jp/coverage/AllTest.java @@ -7,6 +7,7 @@ import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import osm.jp.api.Coverage; @RunWith(Suite.class) @Suite.SuiteClasses({ @@ -19,7 +20,7 @@ @BeforeClass public static void setUpClass() throws Exception { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); dir.deleteOnExit(); dir.mkdir(); } diff --git a/test/osm/jp/coverage/HsqldbTest.java b/test/osm/jp/coverage/HsqldbTest.java index affc301..0e0d0e1 100644 --- a/test/osm/jp/coverage/HsqldbTest.java +++ b/test/osm/jp/coverage/HsqldbTest.java @@ -12,6 +12,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import osm.jp.api.Coverage; /** * database connect test. @@ -40,7 +41,7 @@ */ @Test public void connectTest_database() { - connect("database"); + connect(Coverage.DB_PORP_LOCALDB); } void connect(String dbname) { diff --git a/test/osm/jp/coverage/PoiTest.java b/test/osm/jp/coverage/PoiTest.java index 58fa1ba..5cfd6e4 100644 --- a/test/osm/jp/coverage/PoiTest.java +++ b/test/osm/jp/coverage/PoiTest.java @@ -11,6 +11,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; +import osm.jp.api.Coverage; import osm.jp.coverage.postoffice.PostofficeTest; public abstract class PoiTest { @@ -82,7 +83,7 @@ Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); String where = String.format("(lat > '%s') and (lat < '%s') and (lon > '%s') and (lon < '%s')", String.valueOf(lat-0.001D), String.valueOf(lat+0.001D), diff --git a/test/osm/jp/coverage/PostgresqlTest.java b/test/osm/jp/coverage/PostgresqlTest.java index d2080e5..04a4efc 100644 --- a/test/osm/jp/coverage/PostgresqlTest.java +++ b/test/osm/jp/coverage/PostgresqlTest.java @@ -9,6 +9,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import osm.jp.api.Coverage; /** * database connect test. @@ -33,12 +34,12 @@ } /** - * postgresql `postgis.properties` + * postgresql `gisdb.properties` * postgresql - PostGIS : gisdb */ @Test public void connectTest_postgis() { - connect("postgis"); + connect("gisdb"); } /** @@ -47,7 +48,7 @@ */ @Test public void connectTest_database() { - connect("database"); + connect(Coverage.DB_PORP_LOCALDB); } /** diff --git a/test/osm/jp/coverage/Test.java b/test/osm/jp/coverage/Test.java index 30d0911..9da8dcc 100644 --- a/test/osm/jp/coverage/Test.java +++ b/test/osm/jp/coverage/Test.java @@ -12,6 +12,7 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import jp.co.areaweb.tools.database.*; +import osm.jp.api.Coverage; import osm.jp.api.Japan; import osm.jp.api.RectArea; @@ -42,12 +43,12 @@ public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException { // HSQLディレクトリがなければ作る - File dbdir = new File("database"); + File dbdir = new File(Coverage.DB_PORP_LOCALDB); if (!dbdir.isDirectory()) { dbdir.mkdir(); } - Connection con = DatabaseTool.openDb("database"); + Connection con = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); try { new Test(con); diff --git a/test/osm/jp/coverage/ToPostgis.java b/test/osm/jp/coverage/ToPostgis.java index d0a08d7..3ce1f78 100644 --- a/test/osm/jp/coverage/ToPostgis.java +++ b/test/osm/jp/coverage/ToPostgis.java @@ -10,6 +10,7 @@ import javax.xml.parsers.ParserConfigurationException; import jp.co.areaweb.tools.database.DatabaseTool; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.api.HttpPOST; /** @@ -29,8 +30,8 @@ Connection conPost = null; try { // DB.tableを作成 - conHsql = DatabaseTool.openDb("database"); - conPost = DatabaseTool.openDb("postgis"); + conHsql = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); + conPost = DatabaseTool.openDb(Coverage.DB_PORP_GISDB); transportNew(conHsql, conPost); } diff --git a/test/osm/jp/coverage/busstop/BusstopTest.java b/test/osm/jp/coverage/busstop/BusstopTest.java index 699b8e6..c9ad97b 100644 --- a/test/osm/jp/coverage/busstop/BusstopTest.java +++ b/test/osm/jp/coverage/busstop/BusstopTest.java @@ -12,6 +12,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.api.Japan; import osm.jp.api.RectArea; import osm.jp.coverage.DbTest; @@ -53,7 +54,7 @@ */ @Test public void test01Busstop_dataread() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { String sql = "SELECT * FROM " + DbBusstop.TABLE_NAME +" WHERE (lat > '34.69161765717579') and (lat < '34.697025680375795') and (lon > '135.79486712544522') and (lon < '135.80144696784524')"; @@ -80,11 +81,11 @@ */ @Test public void test02Busstop_busstop() { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { PreparedStatement ps1 = hsqldb.prepareStatement("SELECT count(*) FROM "+ DbExistBusstop.TABLE_NAME); try (ResultSet rset1 = ps1.executeQuery()) { if (rset1.next()) { @@ -108,7 +109,7 @@ */ @Test public void test02Busstop_3152604023() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { PreparedStatement ps1 = hsqldb.prepareStatement( "SELECT * FROM "+ DbBusstop.TABLE_NAME +" where name='八幡前' and area=38" ); @@ -143,7 +144,7 @@ */ @Test public void test02Busstop_4940018338() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { String gmlid = getGmlid(hsqldb, Double.parseDouble("35.5909251"), Double.parseDouble("139.1498642"), 150); @@ -178,7 +179,7 @@ */ @Test public void test02Busstop_2043102034() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { String gmlid = getGmlid(hsqldb, Double.parseDouble("35.4435042"), Double.parseDouble("139.3878934"), 150); @@ -212,7 +213,7 @@ */ @Test public void test02Busstop_n3249() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { String gmlid = getGmlid(hsqldb, Double.parseDouble("35.41318"), Double.parseDouble("139.39504"), 150); @@ -244,7 +245,7 @@ */ @Test public void test03Busstop_dataread() { - try (Connection hsqldb = DatabaseTool.openDb("database")) { + try (Connection hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB)) { String sqlStr1 = "SELECT * FROM "+ DbExistBusstop.TABLE_NAME; String sqlStr2 = "SELECT gmlid,lat,lon,fixed,fixed1,area,name FROM "+ DbBusstop.TABLE_NAME +" WHERE (lat > ?) and (lat < ?) and (lon > ?) and (lon < ?)"; @@ -332,7 +333,7 @@ @Test public void test40_main_output() throws Exception { int cnt = 0; - String databaseName = "database"; + String databaseName = Coverage.DB_PORP_LOCALDB; String tableName = "busstop"; try (Connection hsqldb = DatabaseTool.openDb(databaseName)) { diff --git a/test/osm/jp/coverage/busstop/CoverageTest.java b/test/osm/jp/coverage/busstop/CoverageTest.java index ebadfb2..bdf9c26 100644 --- a/test/osm/jp/coverage/busstop/CoverageTest.java +++ b/test/osm/jp/coverage/busstop/CoverageTest.java @@ -1,13 +1,8 @@ package osm.jp.coverage.busstop; -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.junit.BeforeClass; -import org.xml.sax.SAXException; public class CoverageTest extends osm.jp.coverage.CoverageTest { @SuppressWarnings("FieldNameHidesFieldInSuperclass") @@ -24,9 +19,9 @@ System.out.println("testBusstopCoverage_main"); try { String[] args = new String[]{}; - Coverage.main(args); + CoverageBusstop.main(args); } - catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + catch (Exception e) { fail(e.toString()); } diff --git a/test/osm/jp/coverage/busstop/DbBusstopTest.java b/test/osm/jp/coverage/busstop/DbBusstopTest.java index c34afcc..a9da386 100644 --- a/test/osm/jp/coverage/busstop/DbBusstopTest.java +++ b/test/osm/jp/coverage/busstop/DbBusstopTest.java @@ -12,6 +12,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.coverage.DbTest; import tools.Copy; @@ -20,7 +21,7 @@ @SuppressWarnings("FieldNameHidesFieldInSuperclass") public static String gmlFolderName = "GML_BUSSTOP"; - String databaseName = "database"; + String databaseName = Coverage.DB_PORP_LOCALDB; String tableName = "busstop"; static final int REMOVED_COUNT = 12; static final String REMOVED_FILE_NAME = "P11-10.removed.json.txt"; diff --git a/test/osm/jp/coverage/busstop/DbExistBusstopTest.java b/test/osm/jp/coverage/busstop/DbExistBusstopTest.java index d45d603..36aac6b 100644 --- a/test/osm/jp/coverage/busstop/DbExistBusstopTest.java +++ b/test/osm/jp/coverage/busstop/DbExistBusstopTest.java @@ -14,6 +14,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import static osm.jp.api.Osmdb.POINT_BUS_NO; import static osm.jp.api.Osmdb.POINT_FIXME; import static osm.jp.api.Osmdb.POINT_NO_NAME; @@ -25,7 +26,7 @@ */ @FixMethodOrder (MethodSorters.NAME_ASCENDING) public class DbExistBusstopTest { - String databaseName = "database"; + String databaseName = Coverage.DB_PORP_LOCALDB; String tableName = "BUSSTOP_EXIST"; /** @@ -215,7 +216,7 @@ public void test03DbExistBusstopTest_busstop() { Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); DbExistBusstop osmExist = new DbExistBusstop(hsqldb); JsonBuilderFactory factory = Json.createBuilderFactory(null); JsonArrayBuilder abuilder = factory.createArrayBuilder(); diff --git a/test/osm/jp/coverage/fuel/AllTest.java b/test/osm/jp/coverage/fuel/AllTest.java index 765f6c2..40f4d2e 100644 --- a/test/osm/jp/coverage/fuel/AllTest.java +++ b/test/osm/jp/coverage/fuel/AllTest.java @@ -7,6 +7,7 @@ import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import osm.jp.api.Coverage; @RunWith(Suite.class) @Suite.SuiteClasses({ @@ -20,7 +21,7 @@ @BeforeClass public static void setUpClass() throws Exception { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); dir.deleteOnExit(); dir.mkdir(); } diff --git a/test/osm/jp/coverage/fuel/CoverageTest.java b/test/osm/jp/coverage/fuel/CoverageTest.java index a99805d..f3d10da 100644 --- a/test/osm/jp/coverage/fuel/CoverageTest.java +++ b/test/osm/jp/coverage/fuel/CoverageTest.java @@ -20,7 +20,7 @@ try { System.out.println("testFuelCoverage_main"); String[] args = new String[]{}; - Coverage.main(args); + CoverageFuel.main(args); } catch (Exception e) { fail("The test case is a prototype."); diff --git a/test/osm/jp/coverage/fuel/DbExistTest.java b/test/osm/jp/coverage/fuel/DbExistTest.java index 7dca265..7eb4515 100644 --- a/test/osm/jp/coverage/fuel/DbExistTest.java +++ b/test/osm/jp/coverage/fuel/DbExistTest.java @@ -9,6 +9,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.api.Feature; import osm.jp.api.Japan; import static osm.jp.api.Osmdb.POINT_FIXME; @@ -18,7 +19,7 @@ @FixMethodOrder (MethodSorters.NAME_ASCENDING) public class DbExistTest { - String databaseName = "database"; + String databaseName = Coverage.DB_PORP_LOCALDB; String tableName = "FUEL_EXIST"; /** @@ -232,7 +233,7 @@ Connection hsqldb = null; try { // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); ArrayList features = new ArrayList<>(); features.add(new Feature(Feature.NODE, "amenity", "fuel", POINT_NO_BRAND | POINT_FIXME)); diff --git a/test/osm/jp/coverage/fuel/DbFuelTest.java b/test/osm/jp/coverage/fuel/DbFuelTest.java index 0f043a1..e2d3fdd 100644 --- a/test/osm/jp/coverage/fuel/DbFuelTest.java +++ b/test/osm/jp/coverage/fuel/DbFuelTest.java @@ -15,6 +15,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.coverage.DbTest; import tools.Copy; @@ -43,7 +44,7 @@ @SuppressWarnings("FieldNameHidesFieldInSuperclass") public static String gmlFolderName = "GML_FUEL"; - String databaseName = "database"; + String databaseName = Coverage.DB_PORP_LOCALDB; String tableName = "FUEL"; static final int REMOVED_COUNT = 46; static final String REMOVED_FILE_NAME = "P07-15.removed.json.txt"; diff --git a/test/osm/jp/coverage/fuel/FuelTest.java b/test/osm/jp/coverage/fuel/FuelTest.java index 0e33186..3ba7806 100644 --- a/test/osm/jp/coverage/fuel/FuelTest.java +++ b/test/osm/jp/coverage/fuel/FuelTest.java @@ -11,6 +11,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.coverage.PoiTest; @FixMethodOrder (MethodSorters.NAME_ASCENDING) @@ -44,7 +45,7 @@ public void test01_dataread() { Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); double lat = 35.43035D; // 35.43035 35.4305614, 139.3662339 double lon = 139.36622D; //139.36622 @@ -83,7 +84,7 @@ Connection hsqldb = null; String sql1 = String.format("SELECT * FROM %s where idref='%s'", DbExistFuel.TABLE_NAME, "5338111023"); try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); try (PreparedStatement ps1 = hsqldb.prepareStatement(sql1)){ try (ResultSet rset1 = ps1.executeQuery()) { assertTrue(rset1.next()); diff --git a/test/osm/jp/coverage/fuel/OsmExistTest.java b/test/osm/jp/coverage/fuel/OsmExistTest.java index 6c477d5..90e9fb9 100644 --- a/test/osm/jp/coverage/fuel/OsmExistTest.java +++ b/test/osm/jp/coverage/fuel/OsmExistTest.java @@ -5,6 +5,7 @@ import jp.co.areaweb.tools.database.DatabaseTool; import org.junit.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; import osm.jp.api.Feature; import osm.jp.api.Japan; import static osm.jp.api.Osmdb.POINT_FIXME; @@ -30,7 +31,7 @@ Connection hsqldb = null; try { // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); ArrayList features = new ArrayList<>(); features.add(new Feature(Feature.NODE, "amenity", "fuel", POINT_NO_BRAND | POINT_FIXME)); diff --git a/test/osm/jp/coverage/police/AllTest.java b/test/osm/jp/coverage/police/AllTest.java index ef6cabe..e75df4d 100644 --- a/test/osm/jp/coverage/police/AllTest.java +++ b/test/osm/jp/coverage/police/AllTest.java @@ -7,6 +7,7 @@ import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import osm.jp.api.Coverage; @RunWith(Suite.class) @Suite.SuiteClasses({ @@ -24,7 +25,7 @@ @BeforeClass public static void setUpClass() throws Exception { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); dir.deleteOnExit(); dir.mkdir(); } diff --git a/test/osm/jp/coverage/police/Coverage2Test.java b/test/osm/jp/coverage/police/Coverage2Test.java index abf1cd7..ae0fbad 100644 --- a/test/osm/jp/coverage/police/Coverage2Test.java +++ b/test/osm/jp/coverage/police/Coverage2Test.java @@ -1,13 +1,8 @@ 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.junit.BeforeClass; -import org.xml.sax.SAXException; public class Coverage2Test { @SuppressWarnings("FieldNameHidesFieldInSuperclass") @@ -24,9 +19,9 @@ System.out.println("Coverage2Test"); try { String[] args = new String[0]; - Coverage2.main(args); + CoveragePolice2.main(args); } - catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + catch (Exception e) { fail("The test case is a prototype."); } diff --git a/test/osm/jp/coverage/police/Coverage4Test.java b/test/osm/jp/coverage/police/Coverage4Test.java index e1392b5..7da5314 100644 --- a/test/osm/jp/coverage/police/Coverage4Test.java +++ b/test/osm/jp/coverage/police/Coverage4Test.java @@ -1,13 +1,8 @@ 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.junit.BeforeClass; -import org.xml.sax.SAXException; public class Coverage4Test { @SuppressWarnings("FieldNameHidesFieldInSuperclass") @@ -24,9 +19,9 @@ try { System.out.println("main"); String[] args = new String[0]; - Coverage4.main(args); + CoveragePolice4.main(args); } - catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + catch (Exception e) { fail("The test case is a prototype."); } diff --git a/test/osm/jp/coverage/police/Coverage5Test.java b/test/osm/jp/coverage/police/Coverage5Test.java index c998e8d..b5c38b3 100644 --- a/test/osm/jp/coverage/police/Coverage5Test.java +++ b/test/osm/jp/coverage/police/Coverage5Test.java @@ -1,13 +1,8 @@ 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.junit.BeforeClass; -import org.xml.sax.SAXException; public class Coverage5Test { @SuppressWarnings("FieldNameHidesFieldInSuperclass") @@ -24,9 +19,9 @@ try { System.out.println("main"); String[] args = new String[0]; - Coverage5.main(args); + CoveragePolice5.main(args); } - catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + catch (Exception e) { fail("The test case is a prototype."); } diff --git a/test/osm/jp/coverage/police/Coverage6Test.java b/test/osm/jp/coverage/police/Coverage6Test.java index 1d56fb6..3630f4f 100644 --- a/test/osm/jp/coverage/police/Coverage6Test.java +++ b/test/osm/jp/coverage/police/Coverage6Test.java @@ -1,18 +1,9 @@ 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.junit.BeforeClass; -import org.xml.sax.SAXException; -/** - * - * @author yuu - */ public class Coverage6Test { @SuppressWarnings("FieldNameHidesFieldInSuperclass") static String gmlFolderName = "GML_POLICE"; @@ -28,9 +19,9 @@ try { System.out.println("main"); String[] args = new String[0]; - Coverage5.main(args); + CoveragePolice5.main(args); } - catch (IOException | ClassNotFoundException | SQLException | ParserConfigurationException | TransformerException | SAXException e) { + catch (Exception e) { fail("The test case is a prototype."); } diff --git a/test/osm/jp/coverage/police/DbExistTest.java b/test/osm/jp/coverage/police/DbExistTest.java index 25c7cd5..1d125e2 100644 --- a/test/osm/jp/coverage/police/DbExistTest.java +++ b/test/osm/jp/coverage/police/DbExistTest.java @@ -13,6 +13,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; @FixMethodOrder (MethodSorters.NAME_ASCENDING) public class DbExistTest { @@ -41,13 +42,13 @@ @Test public void test021_police() { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); PreparedStatement ps8 = hsqldb.prepareStatement("SELECT count(*) FROM AREA_NODE"); try (ResultSet rset8 = ps8.executeQuery()) { diff --git a/test/osm/jp/coverage/police/DbPoliceTest.java b/test/osm/jp/coverage/police/DbPoliceTest.java index 40cb663..eb9fdf0 100644 --- a/test/osm/jp/coverage/police/DbPoliceTest.java +++ b/test/osm/jp/coverage/police/DbPoliceTest.java @@ -13,6 +13,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; /** * @@ -38,13 +39,13 @@ fail(ex.toString()); } - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); PreparedStatement ps1 = hsqldb.prepareStatement("SELECT count(*) FROM "+ DbPolice.TABLE_NAME); try (ResultSet rset1 = ps1.executeQuery()) { diff --git a/test/osm/jp/coverage/police/PoliceTest.java b/test/osm/jp/coverage/police/PoliceTest.java index 90d8e69..266e90d 100644 --- a/test/osm/jp/coverage/police/PoliceTest.java +++ b/test/osm/jp/coverage/police/PoliceTest.java @@ -15,6 +15,7 @@ import static org.junit.Assert.*; import org.junit.runners.MethodSorters; import org.xml.sax.SAXException; +import osm.jp.api.Coverage; import osm.jp.coverage.PoiTest; import osm.jp.coverage.postoffice.PostofficeTest; @@ -90,7 +91,7 @@ Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); String where = String.format("(POLICE.area = %d) and (lat > '%s') and (lat < '%s') and (lon > '%s') and (lon < '%s')", area, diff --git a/test/osm/jp/coverage/postoffice/AllTest.java b/test/osm/jp/coverage/postoffice/AllTest.java index f277d70..3012d8d 100644 --- a/test/osm/jp/coverage/postoffice/AllTest.java +++ b/test/osm/jp/coverage/postoffice/AllTest.java @@ -7,6 +7,7 @@ import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import osm.jp.api.Coverage; @RunWith(Suite.class) @Suite.SuiteClasses({ @@ -20,7 +21,7 @@ @BeforeClass public static void setUpClass() throws Exception { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); dir.deleteOnExit(); dir.mkdir(); } diff --git a/test/osm/jp/coverage/postoffice/CoverageTest.java b/test/osm/jp/coverage/postoffice/CoverageTest.java index 3296ec3..a1bd797 100644 --- a/test/osm/jp/coverage/postoffice/CoverageTest.java +++ b/test/osm/jp/coverage/postoffice/CoverageTest.java @@ -20,7 +20,7 @@ try { System.out.println("main"); String[] args = new String[0]; - Coverage.main(args); + CoveragePostoffice.main(args); } catch (Exception e) { fail(e.toString()); diff --git a/test/osm/jp/coverage/postoffice/DbExistTest.java b/test/osm/jp/coverage/postoffice/DbExistTest.java index ad2c42a..fb2bc8d 100644 --- a/test/osm/jp/coverage/postoffice/DbExistTest.java +++ b/test/osm/jp/coverage/postoffice/DbExistTest.java @@ -13,6 +13,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; /** * @@ -32,7 +33,7 @@ public void test00_hsqldbの生成確認() { Connection hsqldb = null; try { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); if (dir.exists()) { if (dir.isDirectory()) { dir.deleteOnExit(); @@ -43,7 +44,7 @@ } // DB.tableを作成 - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); DbExistPostoffice osmExist = new DbExistPostoffice(hsqldb); osmExist.create(); } @@ -58,13 +59,13 @@ @Test public void test01_hsqldbの生成確認() { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); PreparedStatement ps8 = hsqldb.prepareStatement("SELECT count(*) FROM AREA_NODE"); try (ResultSet rset8 = ps8.executeQuery()) { @@ -109,13 +110,13 @@ @Test public void test03_check() { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); PreparedStatement ps8 = hsqldb.prepareStatement("SELECT count(*) FROM AREA_NODE"); try (ResultSet rset8 = ps8.executeQuery()) { diff --git a/test/osm/jp/coverage/postoffice/DbPostofficeTest.java b/test/osm/jp/coverage/postoffice/DbPostofficeTest.java index b56d823..b8e785d 100644 --- a/test/osm/jp/coverage/postoffice/DbPostofficeTest.java +++ b/test/osm/jp/coverage/postoffice/DbPostofficeTest.java @@ -13,6 +13,7 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Coverage; /** * @@ -42,13 +43,13 @@ @Test public void test02_postoffice() { - File dir = new File("database"); + File dir = new File(Coverage.DB_PORP_LOCALDB); assertTrue(dir.exists()); assertTrue(dir.isDirectory()); Connection hsqldb = null; try { - hsqldb = DatabaseTool.openDb("database"); + hsqldb = DatabaseTool.openDb(Coverage.DB_PORP_LOCALDB); PreparedStatement ps1 = hsqldb.prepareStatement("SELECT count(*) FROM "+ DbPostoffice.TABLE_NAME2); try (ResultSet rset1 = ps1.executeQuery()) { diff --git a/test/postgis.properties b/test/postgis.properties deleted file mode 100644 index 04ba2fe..0000000 --- a/test/postgis.properties +++ /dev/null @@ -1,4 +0,0 @@ -db_driver=org.postgresql.Driver -db_url=jdbc:postgresql://surveyor.mydns.jp:5432/gisdb -db_user=gisuser -db_passwd=gisuser