diff --git a/src/osm/jp/coverage/busstop/DbBusstop.java b/src/osm/jp/coverage/busstop/DbBusstop.java index 4e2545a..c1fb0f6 100644 --- a/src/osm/jp/coverage/busstop/DbBusstop.java +++ b/src/osm/jp/coverage/busstop/DbBusstop.java @@ -148,7 +148,7 @@ break; case "ksj:BusStop": iCounter++; - showBusStop(con, node2, iFileName); + showBusStop(con, node2, iFileName, areacode); break; default: iCounter += showNodes(con, node2, iFileName, areacode); @@ -361,13 +361,14 @@ * @param con * @param node * @param iFileName // ソースファイル名(拡張子を含まない) + * @param areacode * @throws IOException * @throws SQLException */ - public static void showBusStop(Connection con, Node node, String iFileName) throws IOException, SQLException { + public static void showBusStop(Connection con, Node node, String iFileName, int areacode) throws IOException, SQLException { String gmlidStr = ""; String nameStr = ""; - try (PreparedStatement ps2 = con.prepareStatement("UPDATE bus_stop SET name=?,ifile=? WHERE gmlid=?")) { + try (PreparedStatement ps2 = con.prepareStatement("UPDATE bus_stop SET name=?,ifile=? WHERE (gmlid=? and area=?)")) { ArrayList bris = new ArrayList<>(); NodeList nodes = node.getChildNodes(); for (int i=0; i < nodes.getLength(); i++) { @@ -402,7 +403,8 @@ ps2.setString(1, nameStr); ps2.setString(2, iFileName); ps2.setString(3, gmlidStr); - System.out.println("UPDATE bus_stop SET name='"+ nameStr +"',ifile='"+ iFileName +"' WHERE gmlid='"+ gmlidStr +"'"); + ps2.setInt(4, areacode); + System.out.println("UPDATE bus_stop SET name='"+ nameStr +"',ifile='"+ iFileName +"' WHERE (gmlid='"+ gmlidStr +"' and area="+ areacode +")"); ps2.executeUpdate(); } } @@ -495,7 +497,7 @@ String createSt; // 'table.BUS_STOP'を新規に作る - createSt = "CREATE TABLE bus_stop (gmlid VARCHAR(12) NOT NULL, gid LONG, name VARCHAR(128), kana VARCHAR(128), lat DOUBLE, lon DOUBLE, fixed INT, area INT, ifile VARCHAR(128), up INT, CONSTRAINT bus_stop_pk PRIMARY KEY(gmlid));"; + createSt = "CREATE TABLE bus_stop (gmlid VARCHAR(12) NOT NULL, name VARCHAR(128), lat DOUBLE, lon DOUBLE, fixed INT, area INT, ifile VARCHAR(128), up INT, CONSTRAINT bus_stop_pk PRIMARY KEY(gmlid, area));"; create(conHsql, createSt); //createSt = "CREATE TABLE existing_data (gmlid VARCHAR(12) NOT NULL, name VARCHAR(128), lat DOUBLE, lon DOUBLE, score INT, CONSTRAINT existing_pk PRIMARY KEY(gmlid, lat, lon));"; diff --git a/src/t_BUSSTOP.sql b/src/t_BUSSTOP.sql index d3519c1..aefa6c4 100644 --- a/src/t_BUSSTOP.sql +++ b/src/t_BUSSTOP.sql @@ -40,7 +40,7 @@ area INT, ifile VARCHAR(128), up INT, - CONSTRAINT bus_stop_pk PRIMARY KEY(gmlid)); + CONSTRAINT bus_stop_pk PRIMARY KEY(gmlid,area)); CREATE TABLE existing_data ( idref VARCHAR(12) NOT NULL,