diff --git a/src/osm/jp/api/Osmdb.java b/src/osm/jp/api/Osmdb.java index a9f8224..0bb9e84 100644 --- a/src/osm/jp/api/Osmdb.java +++ b/src/osm/jp/api/Osmdb.java @@ -89,18 +89,26 @@ * @param point 評価ポイント[POINT_NO|POINT_BRAND|POINT_NAME] 1: 'brand' 2:'name' * @throws Exception エラー */ - public void readExistingNodes(Connection hsqldb, String sqlWhere, int point) throws Exception { + public void readExisting(Connection hsqldb, String sqlWhere, int point) throws Exception { Connection osmdb = null; long counter = 0L; try { osmdb = DatabaseTool.openDb("osmdb"); - PreparedStatement ps1 = osmdb.prepareStatement("select osm_id,amenity,brand,disused,name,ST_Y(ST_Transform(way,4326)) as lat,ST_X(ST_Transform(way,4326)) as lon from planet_osm_point " + sqlWhere); + PreparedStatement ps1 = osmdb.prepareStatement("select osm_id,brand,disused,name,ST_Y(ST_Transform(way,4326)) as lat,ST_X(ST_Transform(way,4326)) as lon from planet_osm_point " + sqlWhere); try (ResultSet rset1 = ps1.executeQuery()) { while (rset1.next()) { counter += importExistingNode(hsqldb, rset1, point); } } + + PreparedStatement ps2 = osmdb.prepareStatement("select osm_id,brand,disused,name,ST_Y(ST_Transform(ST_Centroid(way),4326)) as lat,ST_X(ST_Transform(ST_Centroid(way),4326)) as lon from planet_osm_polygon " + sqlWhere); + try (ResultSet rset2 = ps2.executeQuery()) { + while (rset2.next()) { + counter += importExistingNode(hsqldb, rset2, point); + } + } + System.out.println("Exists Node count = " + counter); } finally { diff --git a/src/osm/jp/coverage/fuel/DbExist.java b/src/osm/jp/coverage/fuel/DbExist.java index 9a325da..a7cd4ef 100644 --- a/src/osm/jp/coverage/fuel/DbExist.java +++ b/src/osm/jp/coverage/fuel/DbExist.java @@ -43,7 +43,12 @@ ノード: エネオス (2015835273) 場所: 35.4367770, 139.4035710 ノード: ENEOS (1769261234) 場所: 35.4330583, 139.4006876 brand=no ノード: 出光 (3877535257) 場所: 45.3985390, 141.6882450 brand=no - select osm_id,amenity,brand,disused,name from planet_osm_point where amenity='fuel'; + + select osm_id,amenity,brand,disused,name, + ST_Y(ST_Transform(way,4326)) as lat, + ST_X(ST_Transform(way,4326)) as lon + from planet_osm_point + where amenity='fuel'; ウェイ: 出光 (161877397) ノード @@ -53,8 +58,15 @@ 1738352024 1738352017 1738352013 - select osm_id,amenity,brand,name,way_area,ST_Astext(ST_Transform(way,4326)) from planet_osm_polygon where amenity='fuel'; + select osm_id,amenity,brand,name,way_area, + ST_Astext(ST_Transform(way,4326)) , + ST_Y(ST_Transform(ST_Centroid(way),4326)) as lat, + ST_X(ST_Transform(ST_Centroid(way),4326)) as lon + from planet_osm_polygon + where amenity='fuel'; + 161877397;"fuel";"出光";"出光";1415.14;"POLYGON((139.402982078119 35.4372453832977,139.403208992559 35.4373490207424,139.4033330499 35.4371591650393,139.403407160911 35.4370741177365,139.403148446109 35.4369273706731,139.402982078119 35.4372453832977))" + ST_Centroid(way) */ /** @@ -88,7 +100,7 @@ // 通常 → 50ポイント // BRANDなし → 1ポイント // FIXMEあり → 1ポイント - readExistingNodes(hsqldb, "where amenity='fuel'", POINT_BRAND | POINT_FIXME); + readExisting(hsqldb, "where amenity='fuel'", POINT_BRAND | POINT_FIXME); } /** diff --git a/src/osmdb.class.violet.html b/src/osmdb.class.violet.html index 51b8238..1ba7f80 100644 --- a/src/osmdb.class.violet.html +++ b/src/osmdb.class.violet.html @@ -20,7 +20,7 @@ - + 1 @@ -72,7 +72,7 @@ - + 1 @@ -94,12 +94,13 @@ public_transport: text - + ST_Y(ST_Transform(way,4326)) as lat +ST_X(ST_Transform(way,4326)) as lon - + 1 @@ -110,12 +111,13 @@ + osm_id: bigint -+ way: geometry ++ way: geometry(Geometry,900913) - z_order: integer - (keys): text - + ST_Y(ST_Transform(ST_Centroid(way),4326)) as lat : 重心点 +ST_X(ST_Transform(ST_Centroid(way),4326)) as lon : 重心点 @@ -143,7 +145,7 @@ - + 1 @@ -165,7 +167,7 @@ - + 1 @@ -252,61 +254,66 @@ amenity='fuel' - + + 255 + 228 + 181 + 255 + - - + + - - - - + + + + 1 - + - - - - + + + + 1 osm_id id - + - - - - + + + + 1 - + - - - - + + + + 1 nodes id - + - - - - + + + + 1 osm_id @@ -317,1188 +324,1311 @@ ]]>

- embedded diagram image + embedded diagram image \ No newline at end of file diff --git a/test/osm/jp/coverage/fuel/DbExistTest.java b/test/osm/jp/coverage/fuel/DbExistTest.java index e8ac020..e661d11 100644 --- a/test/osm/jp/coverage/fuel/DbExistTest.java +++ b/test/osm/jp/coverage/fuel/DbExistTest.java @@ -74,7 +74,6 @@ fail(); } } - PreparedStatement ps1 = hsqldb.prepareStatement("SELECT count(*) FROM OSM_EXIST"); try (ResultSet rset1 = ps1.executeQuery()) { @@ -186,6 +185,18 @@ } } + // ウェイ: 出光 (161877397) 139.402982078119 35.4372453832977 + ps1 = hsqldb.prepareStatement("SELECT score,name,lat,lon FROM OSM_EXIST where idref='161877397'"); + try (ResultSet rset1 = ps1.executeQuery()) { + if (rset1.next()) { + assertThat(rset1.getInt("score"), is(50)); + assertThat(checkRenge(rset1, "35.4371428029181", "139.403185626731"), is(true)); + } + else { + fail(); + } + } + } catch (ClassNotFoundException ex) { Logger.getLogger(DbExistTest.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) {