diff --git a/src/Do_sqlfiles.sh b/src/Do_sqlfiles.sh index 3240223..f591a7a 100755 --- a/src/Do_sqlfiles.sh +++ b/src/Do_sqlfiles.sh @@ -1 +1 @@ -java -cp .:postgis.jar:hayashi_0225.jar:postgresql-9.4.1212.jar osm.jp.postgis.Do_sqlfiles \ No newline at end of file +java -cp .:osmCoverage.jar:hayashi_0225.jar:postgresql-9.4.1212.jar osm.jp.postgis.Do_sqlfiles diff --git a/src/Do_update.sh b/src/Do_update.sh new file mode 100755 index 0000000..fde0113 --- /dev/null +++ b/src/Do_update.sh @@ -0,0 +1 @@ +java -cp .:osmCoverage.jar:hayashi_0225.jar:postgresql-9.4.1212.jar osm.jp.postgis.Do_sqlfiles -update diff --git a/src/osm/jp/api/HttpPOST.java b/src/osm/jp/api/HttpPOST.java index 76c91e8..0eaad13 100644 --- a/src/osm/jp/api/HttpPOST.java +++ b/src/osm/jp/api/HttpPOST.java @@ -54,62 +54,71 @@ public static void getCapabilities(BufferedWriter hw, String key, String value, double minLat, double maxLat, double minLon, double maxLon) throws MalformedURLException, ProtocolException, IOException { System.out.println(host + "/api/interpreter"); URL url = new URL(host + "/api/interpreter"); + int responsecode = 0; - HttpURLConnection urlconn = (HttpURLConnection)url.openConnection(); - urlconn.setRequestMethod("POST"); - urlconn.setDoOutput(true); // POSTのデータを後ろに付ける - urlconn.setInstanceFollowRedirects(false); // 勝手にリダイレクトさせない - urlconn.setRequestProperty("Accept-Language", "ja;q=0.7,en;q=0.3"); - urlconn.setRequestProperty("Content-Type","text/xml;charset=utf-8"); - urlconn.connect(); + do { + HttpURLConnection urlconn = (HttpURLConnection)url.openConnection(); + urlconn.setRequestMethod("POST"); + urlconn.setDoOutput(true); // POSTのデータを後ろに付ける + urlconn.setInstanceFollowRedirects(false); // 勝手にリダイレクトさせない + urlconn.setRequestProperty("Accept-Language", "ja;q=0.7,en;q=0.3"); + urlconn.setRequestProperty("Content-Type","text/xml;charset=utf-8"); + urlconn.connect(); - // 送信 - PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(urlconn.getOutputStream(), "utf-8"))); - outputWriter(pw, ""); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, " "); - outputWriter(pw, ""); - pw.close(); // closeで送信完了 - - try { - TimeUnit.SECONDS.sleep(1); - } catch (InterruptedException e) { - } + // 送信 + PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(urlconn.getOutputStream(), "utf-8"))); + outputWriter(pw, ""); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, " "); + outputWriter(pw, ""); + pw.close(); // closeで送信完了 + + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) {} - System.out.println("レスポンスコード[" + urlconn.getResponseCode() + "] " + - "レスポンスメッセージ[" + urlconn.getResponseMessage() + "]"); - Map> headers = urlconn.getHeaderFields(); - for (Map.Entry> bar : headers.entrySet()) { - System.out.print("\t" + bar.getKey() +"\t: "); // キーを取得 - List vals = bar.getValue(); // 値を取得 - for(String str : vals) { - System.out.print("["+ str +"],"); + responsecode = urlconn.getResponseCode(); + System.out.println("レスポンスコード[" + responsecode + "] " + + "レスポンスメッセージ[" + urlconn.getResponseMessage() + "]"); + Map> headers = urlconn.getHeaderFields(); + for (Map.Entry> bar : headers.entrySet()) { + System.out.print("\t" + bar.getKey() +"\t: "); // キーを取得 + List vals = bar.getValue(); // 値を取得 + for(String str : vals) { + System.out.print("["+ str +"],"); + } + System.out.println(); } - System.out.println(); - } - - System.out.println("\n---- ボディ ----"); - - BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream(), "UTF-8")); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; + if (responsecode == 429) { + try { + TimeUnit.MINUTES.sleep(5); + } catch (InterruptedException e) {} } - hw.write(line); - hw.newLine(); + else { + System.out.println("\n---- ボディ ----"); + + BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream(), "UTF-8")); + while (true) { + String line = reader.readLine(); + if (line == null) { + break; + } + hw.write(line); + hw.newLine(); + } + reader.close(); + } + urlconn.disconnect(); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) {} } - reader.close(); - urlconn.disconnect(); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - } + while (responsecode == 429); } public static Japan[] all = new Japan[] { @@ -128,10 +137,7 @@ new Japan(141D, 43D, 1D), new Japan(142D, 43D, 1D), new Japan(143D, 43D, 1D), - new Japan(144.0D, 43.0D, 0.5D), - new Japan(144.5D, 43.0D, 0.5D), - new Japan(144.0D, 43.5D, 0.5D), - new Japan(144.5D, 43.5D, 0.5D), + new Japan(144D, 43D, 1D), new Japan(145D, 43D, 1D), new Japan(139D, 42D, 1D), diff --git a/src/update.sh b/src/update.sh new file mode 100755 index 0000000..7427d6d --- /dev/null +++ b/src/update.sh @@ -0,0 +1,2 @@ +java -cp .:osmCoverage.jar:hayashi_0225.jar:postgresql-9.4.1212.jar:hsqldb_2.2.9.jar osm.jp.coverage.busstop.Busstop -update +java -cp .:osmCoverage.jar:hayashi_0225.jar:postgresql-9.4.1212.jar osm.jp.postgis.Do_sqlfiles -update