Newer
Older
osmCoverage / src / osm / jp / api / Coverage.java
package osm.jp.api;

import java.io.File;
import java.sql.Connection;
import java.util.ArrayList;
import jp.co.areaweb.tools.database.DatabaseTool;
import osm.jp.postgis.CoverageAll;

public abstract class Coverage {

    //public static String DB_PORP_GISDB = "gisdb";
    public static final String DB_PORP_LOCALDB = "database";

    public static void output(File dir, String tableName, String comment, String gisdb) throws Exception {
        output(dir, tableName, tableName.toLowerCase(), comment, null, gisdb);
    }
    
    public static void output(File dir, String tableName, String name, String comment, String where, String gisdb) throws Exception {
        File outputFileCsv = new File(dir, "coverage."+ name +".csv");
        File outputFileJson = new File(dir, "coverage."+ name +".json");
        
        CoverageAll obj = new CoverageAll(new File(dir, "pbfDate.json"));
        obj.setTablename(tableName);
        obj.setData(new ArrayList<>());
        
        Connection conPost = DatabaseTool.openDb(gisdb);
        Connection conHsql = DatabaseTool.openDb(DB_PORP_LOCALDB);
        try {
            obj.load(conPost, conHsql, tableName, where);
            obj.outputCSV(outputFileCsv);
            obj.outputJson(outputFileJson, comment);
        }
        finally {
            DatabaseTool.closeDb(conHsql);
            DatabaseTool.closeDb(conPost);
        }
    }
}