diff --git a/src/osm/jp/api/OsmExist.java b/src/osm/jp/api/OsmExist.java index 08df520..c5ed8c7 100644 --- a/src/osm/jp/api/OsmExist.java +++ b/src/osm/jp/api/OsmExist.java @@ -96,9 +96,10 @@ * * @param hsqldb * @param features + * @param boxes * @throws Exception */ - public void getJapanCapabilities(Connection hsqldb, ArrayList features) throws Exception { + public void getJapanCapabilities(Connection hsqldb, ArrayList features, Japan[] boxes) throws Exception { /* ``` @@ -134,7 +135,7 @@ String startDate = sdf.format(now.getTime()) +"T09:00:00Z"; StringBuilder sb = new StringBuilder(); - for (Japan box : Japan.all2) { + for (Japan box : boxes) { String boxq = String.format("(%2.1f,%3.1f,%2.1f,%3.1f)", box.minLat, box.minLon, box.maxLat, box.maxLon); sb.append(String.format("(node(changed:\"%s\")%s;)->.a;\n", startDate, boxq)); sb.append(String.format("(node(newer:\"%s\")%s;)->.b;\n", startDate, boxq)); diff --git a/src/osm/jp/coverage/fuel/OsmExist.java b/src/osm/jp/coverage/fuel/OsmExist.java index a66e1b2..f80bcb5 100644 --- a/src/osm/jp/coverage/fuel/OsmExist.java +++ b/src/osm/jp/coverage/fuel/OsmExist.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import jp.co.areaweb.tools.database.*; import osm.jp.api.Feature; +import osm.jp.api.Japan; public class OsmExist extends osm.jp.api.OsmExist { @@ -40,7 +41,7 @@ * 既存のOSMガソリンスタンドを読み込む * OSM OverPassAPI を使って、既存のGSデータを取得して、「HSQLDB.FUEL_EXIST」にSTOREする */ - (new OsmExist()).getJapanCapabilities(hsqldb, features); + (new OsmExist()).getJapanCapabilities(hsqldb, features, Japan.all2); OsmExist.export(hsqldb); } diff --git a/test/osm/jp/coverage/fuel/DbExistTest.java b/test/osm/jp/coverage/fuel/DbExistTest.java index 80ca038..39c52ce 100644 --- a/test/osm/jp/coverage/fuel/DbExistTest.java +++ b/test/osm/jp/coverage/fuel/DbExistTest.java @@ -6,6 +6,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import jp.co.areaweb.tools.database.DatabaseTool; @@ -13,6 +14,12 @@ import org.junit.*; import static org.junit.Assert.*; import org.junit.runners.MethodSorters; +import osm.jp.api.Feature; +import osm.jp.api.HttpPOST; +import osm.jp.api.Japan; +import static osm.jp.api.Osmdb.POINT_FIXME; +import static osm.jp.api.Osmdb.POINT_NO; +import static osm.jp.api.Osmdb.POINT_NO_BRAND; import static osm.jp.api.Osmdb.create; @FixMethodOrder (MethodSorters.NAME_ASCENDING) @@ -249,4 +256,49 @@ System.out.println("d1: "+ d1 +" : "+ str +" --> "+ (ret ? "IN" : "out")); return ret; } + + @Test + public void test02_main() throws Exception { + Connection hsqldb = null; + try { + // DB.tableを作成 + hsqldb = DatabaseTool.openDb("database"); + + ArrayList features = new ArrayList<>(); + features.add(new Feature(Feature.NODE, "amenity", "fuel", POINT_NO_BRAND | POINT_FIXME)); + features.add(new Feature(Feature.NODE, "disused:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "abandoned:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "demolished:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "historic:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "was:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "removed:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.NODE, "no:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "amenity", "fuel", POINT_NO_BRAND | POINT_FIXME)); + features.add(new Feature(Feature.AREA, "disused:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "abandoned:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "demolished:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "historic:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "was:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "removed:amenity", "fuel", POINT_NO)); + features.add(new Feature(Feature.AREA, "no:amenity", "fuel", POINT_NO)); + + /** + * 既存のOSMガソリンスタンドを読み込む + * OSM OverPassAPI を使って、既存のGSデータを取得して、「HSQLDB.FUEL_EXIST」にSTOREする + */ + (new OsmExist()).getJapanCapabilities(hsqldb, features, testBoxes); + + OsmExist.export(hsqldb); + } + finally { + if (hsqldb != null) { + DatabaseTool.closeDb(hsqldb); + } + } + } + + public static Japan[] testBoxes = new Japan[] { + // 神奈川県東部 + new Japan(138D, 34D, 2D) + }; }