diff --git a/src/osm/jp/api/HttpPOST.java b/src/osm/jp/api/HttpPOST.java index 25b5725..d3636e7 100644 --- a/src/osm/jp/api/HttpPOST.java +++ b/src/osm/jp/api/HttpPOST.java @@ -511,45 +511,5 @@ } return null; } - - - public static File overpassAPI(String query, File outputFile) { - StringBuilder sb = new StringBuilder(); - //File outputFile = new File("overpassAPI.xml"); - - try { - // https://overpass-api.de/api/interpreter - URL url = new URL("https://overpass-api.de/api/interpreter"); - HttpURLConnection connection = null; - - try (FileWriter fw = new FileWriter(outputFile)) { - connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setRequestMethod("POST"); - - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8)); - writer.write(query); - writer.flush(); - - if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { - try (InputStreamReader isr = new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8); - BufferedReader reader = new BufferedReader(isr)) { - String line; - while ((line = reader.readLine()) != null) { - fw.write(line); - } - fw.flush(); - } - } - } finally { - if (connection != null) { - connection.disconnect(); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - return outputFile; - } } diff --git a/test/osm/jp/coverage/OsmExistTest.java b/test/osm/jp/coverage/OsmExistTest.java index dcd9276..0e62714 100644 --- a/test/osm/jp/coverage/OsmExistTest.java +++ b/test/osm/jp/coverage/OsmExistTest.java @@ -31,7 +31,7 @@ @Test public void test00_main() throws Exception { try { - HttpPOST.overpassAPI("(node(changed:\"2018-05-20T09:00:00Z\")(34.0,138.0,36.0,140.0);)->.a;\n" + + HttpPOST.getQuery("(node(changed:\"2018-05-20T09:00:00Z\")(34.0,138.0,36.0,140.0);)->.a;\n" + "(node(newer:\"2018-05-20T09:00:00Z\")(34.0,138.0,36.0,140.0);)->.b;\n" + "(way(changed:\"2018-05-20T09:00:00Z\")(34.0,138.0,36.0,140.0);)->.c;\n" + "(way(newer:\"2018-05-20T09:00:00Z\")(34.0,138.0,36.0,140.0);)->.d;\n" + @@ -53,7 +53,7 @@ " way.c.d[\"removed:amenity\"=\"fuel\"];\n" + " way.c.d[\"no:amenity\"=\"fuel\"];\n" + ");\n" + -"out meta;", new File("overpassAPI.xml")); +"out meta;"); } catch(Exception e) { fail(e.toString());