diff --git a/src/osm/jp/coverage/fuel/Fuel.java b/src/osm/jp/coverage/fuel/Fuel.java index 9f4bdab..8d3b1cb 100644 --- a/src/osm/jp/coverage/fuel/Fuel.java +++ b/src/osm/jp/coverage/fuel/Fuel.java @@ -74,7 +74,7 @@ public Fuel(Connection con) throws SQLException, FileNotFoundException, ClassNotFoundException, IOException, ParserConfigurationException, SAXException, TransformerException { try ( PreparedStatement ps2 = con.prepareStatement("SELECT idref,lat,lon,fixed FROM "+ DbFuel.TABLE_NAME +" WHERE (lat > ?) and (lat < ?) and (lon > ?) and (lon < ?) and (fixed1=0)"); PreparedStatement ps1 = con.prepareStatement("SELECT idref,lat,lon,score FROM "+ DbExist.TABLE_NAME); - PreparedStatement ps3 = con.prepareStatement("UPDATE "+ DbFuel.TABLE_NAME +" SET fixed=? WHERE idref=?");) + PreparedStatement ps3 = con.prepareStatement("UPDATE "+ DbFuel.TABLE_NAME +" SET fixed1=? WHERE idref=?");) { try (ResultSet rset1 = ps1.executeQuery()) { while (rset1.next()) { @@ -92,26 +92,26 @@ ps2.setDouble(3, rect.minlon); ps2.setDouble(4, rect.maxlon); try (ResultSet rset2 = ps2.executeQuery()) { - double distance = NEER * 2; + double distance = 999999.9D; while (rset2.next()) { - fixed = rset2.getInt("fixed"); - if (fixed == 0) { - double lat2 = rset2.getDouble("lat"); - double lon2 = rset2.getDouble("lon"); - double dd = distance(lat,lat2,lon,lon2); - if (dd < distance) { - distance = dd; - idref = rset2.getString("idref"); - } + double lat2 = rset2.getDouble("lat"); + double lon2 = rset2.getDouble("lon"); + double dd = distance(lat,lat2,lon,lon2); + if (dd < distance) { + distance = dd; + idref = rset2.getString("idref"); } } } if (idref != null) { - System.out.println("UPDATE "+ DbFuel.TABLE_NAME +" SET fixed="+ score +" WHERE idref="+ idref); + System.out.println("UPDATE "+ DbFuel.TABLE_NAME +" SET fixed1="+ score +" WHERE idref="+ idref); ps3.setInt(1, score); ps3.setString(2, idref); ps3.executeUpdate(); } + else { + System.out.println("NOT FOUND! idref="+ idref); + } } } }