diff --git a/src/osm/jp/postgis/Postgis.java b/src/osm/jp/postgis/Postgis.java index 0cdeda3..7d87ef1 100644 --- a/src/osm/jp/postgis/Postgis.java +++ b/src/osm/jp/postgis/Postgis.java @@ -22,8 +22,16 @@ */ public class Postgis implements AutoCloseable { + /** + * + * $ java -cp .:osmCoverage.jar:hayashi.jar:postgresql.jar \ + * osm.jp.postgis.Postgis ./share + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { - try (Postgis db = new Postgis()) { + File dir = new File(args[0]); + try (Postgis db = new Postgis(dir)) { db.initTableAll(); db.importCsvAll(); } @@ -31,6 +39,7 @@ TableInfo[] tables; Connection con = null; + File workspaceDir; class TableInfo { String tableName; @@ -42,7 +51,13 @@ } } - public Postgis() throws ClassNotFoundException, SQLException, IOException { + public Postgis(File workspace) throws ClassNotFoundException, SQLException, IOException { + if (workspace == null) { + this.workspaceDir = new File("."); + } + else { + this.workspaceDir = workspace; + } ArrayList list = new ArrayList<>(); list.add(new TableInfo("t_busstop", "GML_BUSSTOP/t_busstop.csv")); list.add(new TableInfo("t_fuel", "GML_FUEL/t_fuel.csv")); @@ -89,7 +104,7 @@ public void importCsv(TableInfo info) throws Exception { String charsetName = "UTF-8"; - File csvFile = new File(info.csvPath); + File csvFile = new File(this.workspaceDir, info.csvPath); try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(csvFile), charsetName))) { String line; ArrayList header = new ArrayList<>();