| |
---|
| | import java.sql.SQLSyntaxErrorException; |
---|
| | import javax.xml.parsers.DocumentBuilder; |
---|
| | import javax.xml.parsers.DocumentBuilderFactory; |
---|
| | import javax.xml.parsers.ParserConfigurationException; |
---|
| | import javax.xml.transform.TransformerException; |
---|
| | |
---|
| | import jp.co.areaweb.tools.database.*; |
---|
| | import org.w3c.dom.NamedNodeMap; |
---|
| | import org.w3c.dom.Node; |
---|
| | import org.w3c.dom.NodeList; |
---|
| | import org.xml.sax.SAXException; |
---|
| | import static osm.jp.coverage.busstop.Busstop.checkFile; |
---|
| | import static osm.jp.coverage.busstop.Busstop.showBusStop; |
---|
| | import static osm.jp.coverage.busstop.Busstop.showED01; |
---|
| | import static osm.jp.coverage.busstop.Busstop.showGmPoint; |
---|
| | import static osm.jp.coverage.busstop.Busstop.showGmlPoint; |
---|
| | |
---|
| | public class DbBusstop { |
---|
| | public static final String TABLE_NAME = "bus_stop"; |
---|
| | public static boolean DROP = false; |
---|
| |
---|
| | * @param args |
---|
| | * @throws IOException |
---|
| | * @throws SQLException |
---|
| | * @throws ClassNotFoundException |
---|
| | * @throws FileNotFoundException */ |
---|
| | * @throws FileNotFoundException |
---|
| | * @throws javax.xml.parsers.ParserConfigurationException |
---|
| | * @throws org.xml.sax.SAXException */ |
---|
| | public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException, SQLException, ParserConfigurationException, SAXException |
---|
| | { |
---|
| | for (String arg : args) { |
---|
| | if (arg.toUpperCase().equals("-DROP")) { |
---|
| |
---|
| | root = builder.parse(iFile); |
---|
| | |
---|
| | iCounter += showNodes(conHsql, root, iStr.substring(0, iStr.length() - 4), timeStampStr, areacode); |
---|
| | System.out.println("("+ areacode +") バス停数["+ iCounter +"]"); |
---|
| | } |
---|
| | |
---|
| | /** |
---|
| | * |
---|
| | * @param con |
---|
| | * @param node |
---|
| | * @param iFileName // ソースファイル名(拡張子を含まない) |
---|
| | * @param timeStampStr |
---|
| | * @param areacode |
---|
| | * @return |
---|
| | * @throws IOException |
---|
| | * @throws SQLException |
---|
| | */ |
---|
| | public static int showNodes(Connection con, Node node, String iFileName, String timeStampStr, int areacode) throws IOException, SQLException { |
---|
| | int iCounter = 0; |
---|
| | NamedNodeMap nodeMap = node.getAttributes(); |
---|
| | if ( null != nodeMap ) { |
---|
| | for ( int j=0; j < nodeMap.getLength(); j++ ) { |
---|
| | if (nodeMap.item(j).getNodeName().equals("timeStamp")) { |
---|
| | timeStampStr = nodeMap.item(j).getNodeValue(); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | NodeList nodes = node.getChildNodes(); |
---|
| | for (int i=0; i<nodes.getLength(); i++) { |
---|
| | Node node2 = nodes.item(i); |
---|
| | switch (node2.getNodeName()) { |
---|
| | case "jps:GM_Point": |
---|
| | showGmPoint(con, node2); |
---|
| | break; |
---|
| | case "gml:Point": |
---|
| | showGmlPoint(con, node2, areacode); |
---|
| | break; |
---|
| | case "ksj:ED01": |
---|
| | iCounter++; |
---|
| | showED01(con, node2, iFileName); |
---|
| | break; |
---|
| | case "ksj:BusStop": |
---|
| | iCounter++; |
---|
| | showBusStop(con, node2, iFileName); |
---|
| | break; |
---|
| | default: |
---|
| | iCounter += showNodes(con, node2, iFileName, timeStampStr, areacode); |
---|
| | break; |
---|
| | } |
---|
| | } |
---|
| | return iCounter; |
---|
| | } |
---|
| | |
---|
| | /** |
---|
| | * 'table.BUS_STOP'を新規に作る |
---|
| |
---|
| | |