diff --git a/src/osm/jp/coverage/police/CoverageAll.java b/src/osm/jp/coverage/police/CoverageAll.java new file mode 100644 index 0000000..b140a5a --- /dev/null +++ b/src/osm/jp/coverage/police/CoverageAll.java @@ -0,0 +1,37 @@ +package osm.jp.coverage.police; + +import osm.jp.postgis.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import org.xml.sax.SAXException; +import jp.co.areaweb.tools.database.DatabaseTool; + +public class CoverageAll extends ArrayList { + + public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException, TransformerException + { + File dir = new File("GML_POLICE"); + File outputFileCsv = new File(dir, "coverage.police.csv"); + File outputFileJson = new File(dir, "coverage.police.json"); + + osm.jp.postgis.CoverageAll obj = new osm.jp.postgis.CoverageAll(DbPolice.TABLE_NAME); + + Connection conPost = DatabaseTool.openDb("postgis"); + Connection conHsql = DatabaseTool.openDb("database"); + try { + obj.load(conPost, conHsql); + obj.outputCSV(outputFileCsv); + obj.outputJson(outputFileJson, "国土数値情報 警察署データ(平成25年)"); + } + finally { + DatabaseTool.closeDb(conHsql); + DatabaseTool.closeDb(conPost); + } + } +} diff --git a/src/osm/jp/coverage/police/ToGeoJSON.java b/src/osm/jp/coverage/police/ToGeoJSON.java new file mode 100644 index 0000000..871057a --- /dev/null +++ b/src/osm/jp/coverage/police/ToGeoJSON.java @@ -0,0 +1,43 @@ +package osm.jp.coverage.police; + +import osm.jp.coverage.postoffice.*; +import java.io.File; +import java.sql.Connection; + +import jp.co.areaweb.tools.database.DatabaseTool; + +/** + * PostGISデータをGeoJSONファイルに出力する。 + * 出力ファイル名: "police.json" + * テーブル名: POSTGIS.t_POLICE + * fixed OSMの周辺に存在するかどうか、存在しない場合は0,存在する場合は50 + * geom PostGIS形式の位置情報(4612:) + * SELECT row_to_json(feature) FROM ( +select 'Feature' As type, ST_AsGeoJSON(ST_Transform(t_POLICE.geom,4326))::json As geometry, row_to_json(( + SELECT p FROM (SELECT t_POLICE.idref, t_POLICE.fixed) AS p)) AS properties From t_POLICE) As feature +* + * @author yuu + * + */ +public class ToGeoJSON { + public static void main (String[] argv) throws Exception { + boolean slim = false; + for (String arg : argv) { + if (arg.equals("-slim")) { + slim = true; + } + } + + File dir = new File("GML_POLICE"); + osm.jp.postgis.ToGeoJSON obj = new osm.jp.postgis.ToGeoJSON(DbPostoffice.TABLE_NAME); + Connection con = DatabaseTool.openDb("postgis"); + try { + obj.outputDb(con, "", new File(dir, "police.json"), false); + obj.outputDb(con, "WHERE fixed=0", new File(dir, "police0.json"), slim); + obj.outputDb(con, "WHERE fixed>0", new File(dir, "police1.json"), slim); + } + finally { + DatabaseTool.closeDb(con); + } + } +} diff --git a/src/osmCoverage_PoliceJson b/src/osmCoverage_PoliceJson new file mode 100644 index 0000000..9ca04f7 --- /dev/null +++ b/src/osmCoverage_PoliceJson @@ -0,0 +1,38 @@ +### dummy +pwd + +# git http://surveyor.mydns.jp/gitbucket/git/yuu/osmCoverageBin.git + +curl --user yuu:yuu8844 -O http://surveyor.mydns.jp/gitbucket/yuu/osmCoverage/raw/master/lib/hsqldb_2.2.9.jar +curl --user yuu:yuu8844 -O http://surveyor.mydns.jp/gitbucket/yuu/osmCoverage/raw/master/lib/postgresql-9.4.1212.jar +curl --user yuu:yuu8844 -O http://localhost:8080/job/hayashiLib/lastSuccessfulBuild/artifact/dist/hayashi.jar +curl --user yuu:yuu8844 -O http://localhost:8080/job/osmCoverage/lastSuccessfulBuild/artifact/osmCoverage.jar + +### export from PostGIS +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToGeoJSON + +ls -l +rm -rf vtile +mkdir -m +w vtile +mv ./GML_POLICE/police?.json vtile +tar czvf policeJSON.tgz vtile/*.json + +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.ToGeoJSON -slim +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.Coverage coverage.police.csv +java -cp .:osmCoverage.jar:hayashi.jar:hsqldb_2.2.9.jar:postgresql-9.4.1212.jar osm.jp.coverage.police.Coverage coverage.police.json +ls -l +mv coverage.police.json GML_POLICE +mv coverage.police.csv GML_POLICE +mv police?.json GML_POLICE +mv police.json GML_POLICE +tar czvf coverage.policeJSON.tgz GML_POLICE/*.json GML_POLICE/*.csv + +git config --global user.name "hayashi" +git config --global user.email hayashi.yuu@gmail.com +git add *.json +git add GML_POLICE/*.json +git commit --allow-empty -m "coverage police update $(date +%Y-%m-%d_%H:%M)" + +git remote -v +#git push gitbucket HEAD:master +