diff --git a/src/osm/jp/coverage/busstop/Busstop.java b/src/osm/jp/coverage/busstop/Busstop.java index bb56e84..cc8446d 100644 --- a/src/osm/jp/coverage/busstop/Busstop.java +++ b/src/osm/jp/coverage/busstop/Busstop.java @@ -461,165 +461,8 @@ - /** - * - * @param con - * @param node - * @param iFileName // ソースファイル名(拡張子を含まない) - * @throws IOException - * @throws SQLException - */ - public static void showED01(Connection con, Node node, String iFileName) throws IOException, SQLException { - String idrefStr = ""; - String nameStr = ""; - PreparedStatement ps1 = con.prepareStatement("SELECT idref FROM bus_stop WHERE idref=?"); - PreparedStatement ps2 = con.prepareStatement("INSERT INTO bus_stop (idref,name,ifile) VALUES (?,?,?)"); - try { - ArrayList bris = new ArrayList(); - NodeList nodes = node.getChildNodes(); - for (int i=0; i < nodes.getLength(); i++) { - Node node2 = nodes.item(i); - if (node2.getNodeName().equals("ksj:POS")) { - NamedNodeMap nodeMap = node2.getAttributes(); - if (null != nodeMap) { - for ( int j=0; j < nodeMap.getLength(); j++ ) { - if (nodeMap.item(j).getNodeName().equals("idref")) { - idrefStr = nodeMap.item(j).getNodeValue(); - System.out.println("found idref='"+ idrefStr +"'"); - break; - } - } - } - } - else if (node2.getNodeName().equals("ksj:BSN")) { - nameStr = node2.getTextContent(); - } - else if (node2.getNodeName().equals("ksj:BRI")) { - String[] rtn = anaComm(node2); - if (rtn != null) { - bris.add(rtn); - } - } - } - // idref と nameStr をデータベースに格納する - boolean insert = true; - ps1.setString(1, idrefStr); - ResultSet rset = ps1.executeQuery(); - if (rset.next()) { - insert = false; - } - rset.close(); - if (insert) { - ps2.setString(1, idrefStr); - ps2.setString(2, nameStr); - ps2.setString(3, iFileName); - System.out.println("INSERT INTO bus_stop (idref,name,ifile) VALUES ('"+ idrefStr +"','"+ nameStr +"','"+ iFileName +"')"); - ps2.executeUpdate(); - } - } - finally { - ps1.close(); - ps2.close(); - } - } - - /** - * - * - * 城堀 - * - * - * 1 - * 箱根登山バス - * 小01 - * - * - * - * - * 1 - * 箱根登山バス - * 湯07 - * - * - * - * - * 1 - * 箱根登山バス - * 湯11 - * - * - * - * - * @param con - * @param node - * @param iFileName // ソースファイル名(拡張子を含まない) - * @throws IOException - * @throws SQLException - */ - public static void showBusStop(Connection con, Node node, String iFileName) throws IOException, SQLException { - String idrefStr = ""; - String nameStr = ""; - PreparedStatement ps2 = con.prepareStatement("UPDATE bus_stop SET name=?,ifile=? WHERE idref=?"); - - ArrayList bris = new ArrayList(); - NodeList nodes = node.getChildNodes(); - for (int i=0; i < nodes.getLength(); i++) { - Node node2 = nodes.item(i); - if (node2.getNodeName().equals("ksj:position")) { - NamedNodeMap nodeMap = node2.getAttributes(); - if (null != nodeMap) { - for ( int j=0; j < nodeMap.getLength(); j++ ) { - if (nodeMap.item(j).getNodeName().equals("xlink:href")) { - idrefStr = nodeMap.item(j).getNodeValue(); - idrefStr = idrefStr.substring(1); - System.out.println("found idref='"+ idrefStr +"'"); - break; - } - } - } - } - else if (node2.getNodeName().equals("ksj:busStopName")) { - nameStr = node2.getTextContent(); - } - else if (node2.getNodeName().equals("ksj:busRouteInformation")) { - String[] rtn = anaCommJGD(node2); - if (rtn != null) { - bris.add(rtn); - } - } - } - - // idref と nameStr をデータベースに格納する - ps2.setString(1, nameStr); - ps2.setString(2, iFileName); - ps2.setString(3, idrefStr); - ps2.executeUpdate(); - ps2.close(); - } - - public static String[] anaComm(Node briNode) { - String[] rtn = new String[3]; - rtn[0] = ""; // corp type - rtn[1] = ""; // course name - rtn[2] = ""; // corp name - - NodeList nodes = briNode.getChildNodes(); - for (int i=0; i < nodes.getLength(); i++) { - Node node2 = nodes.item(i); - if (node2.getNodeName().equals("ksj:BSC")) { - rtn[0] = node2.getTextContent(); - } - else if (node2.getNodeName().equals("ksj:BLN")) { - rtn[1] = node2.getTextContent(); - } - else if (node2.getNodeName().equals("ksj:BOC")) { - rtn[2] = node2.getTextContent(); - } - } - return rtn; - } /** * diff --git a/src/osm/jp/coverage/busstop/DbBusstop.java b/src/osm/jp/coverage/busstop/DbBusstop.java index 79d1382..2005bca 100644 --- a/src/osm/jp/coverage/busstop/DbBusstop.java +++ b/src/osm/jp/coverage/busstop/DbBusstop.java @@ -16,7 +16,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import static osm.jp.coverage.busstop.Busstop.anaComm; import static osm.jp.coverage.busstop.Busstop.anaCommJGD; public class DbBusstop { @@ -421,6 +420,32 @@ } } + public static String[] anaComm(Node briNode) { + String[] rtn = new String[3]; + rtn[0] = ""; // corp type + rtn[1] = ""; // course name + rtn[2] = ""; // corp name + + NodeList nodes = briNode.getChildNodes(); + for (int i=0; i < nodes.getLength(); i++) { + Node node2 = nodes.item(i); + switch (node2.getNodeName()) { + case "ksj:BSC": + rtn[0] = node2.getTextContent(); + break; + case "ksj:BLN": + rtn[1] = node2.getTextContent(); + break; + case "ksj:BOC": + rtn[2] = node2.getTextContent(); + break; + default: + break; + } + } + return rtn; + } + /** * 'table.BUS_STOP'を新規に作る * 既にテーブルが存在する時には何もしない