Changeset 35727 in osm
- Timestamp:
- 2021-03-14T17:42:43+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/api/CadastreAPI.java
r34711 r35727 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.api; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.IOException; … … 17 19 import org.openstreetmap.josm.io.OsmApiException; 18 20 import org.openstreetmap.josm.tools.HttpClient; 21 import org.openstreetmap.josm.tools.HttpClient.Response; 19 22 import org.openstreetmap.josm.tools.JosmRuntimeException; 20 23 … … 24 27 public final class CadastreAPI { 25 28 26 private static final String API_ENDPOINT = "https://sandbox.geo.api.gouv.fr/cadastre /";29 private static final String API_ENDPOINT = "https://sandbox.geo.api.gouv.fr/cadastre"; 27 30 28 31 private CadastreAPI() { … … 53 56 Double.toString(minlon), Double.toString(minlat), Double.toString(maxlon), Double.toString(maxlat))); 54 57 try { 55 JsonStructure json = Json.createReader(new StringReader(HttpClient.create(url).connect().fetchContent())).read(); 58 Response response = HttpClient.create(url).connect(); 59 if (response.getResponseCode() >= 400) { 60 throw new IOException( 61 tr("Cadastre GeoAPI returned HTTP error {0}. This is not a JOSM bug.\nPlease report the issue to {1}, {2} or {3}", 62 response.getResponseCode(), "https://github.com/etalab/geo.data.gouv.fr/issues", "https://twitter.com/geodatagouv", 63 "geo@data.gouv.fr")); 64 } 65 JsonStructure json = Json.createReader(new StringReader(response.fetchContent())).read(); 56 66 if (json instanceof JsonArray) { 57 67 return json.asJsonArray().stream().map(x -> x.asJsonObject().getString("id")).collect(Collectors.toSet());
Note:
See TracChangeset
for help on using the changeset viewer.