Changeset 36122 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2023-08-22T17:40:36+02:00 (18 months ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/build.xml
r35758 r36122 4 4 <property name="commit.message" value="recompile for compatibility with JOSM r17896"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 7896"/>6 <property name="plugin.main.version" value="18723"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/api/CadastreAPI.java
r35831 r36122 5 5 6 6 import java.io.IOException; 7 import java.io.StringReader;8 7 import java.net.MalformedURLException; 8 import java.net.URI; 9 9 import java.net.URL; 10 10 import java.util.Set; 11 11 import java.util.stream.Collectors; 12 12 13 import javax.json.Json; 14 import javax.json.JsonArray; 15 import javax.json.JsonObject; 16 import javax.json.JsonStructure; 13 import jakarta.json.Json; 14 import jakarta.json.JsonArray; 15 import jakarta.json.JsonObject; 16 import jakarta.json.JsonReader; 17 import jakarta.json.JsonStructure; 17 18 18 19 import org.openstreetmap.josm.data.Bounds; … … 55 56 */ 56 57 public static Set<String> getSheets(double minlon, double minlat, double maxlon, double maxlat) throws IOException { 57 URL url = new URL(API_ENDPOINT.get() + "/feuilles?bbox=" + String.join(",", 58 Double.toString(minlon), Double.toString(minlat), Double.toString(maxlon), Double.toString(maxlat))); 58 URL url = URI.create(API_ENDPOINT.get() + "/feuilles?bbox=" + String.join(",", 59 Double.toString(minlon), Double.toString(minlat), Double.toString(maxlon), Double.toString(maxlat))) 60 .toURL(); 59 61 try { 60 62 Response response = HttpClient.create(url).connect(); … … 65 67 "geo@data.gouv.fr")); 66 68 } 67 JsonStructure json = Json.createReader(new StringReader(response.fetchContent())).read(); 68 if (json instanceof JsonArray) { 69 return json.asJsonArray().stream().map(x -> x.asJsonObject().getString("id")).collect(Collectors.toSet()); 70 } else { 71 JsonObject obj = json.asJsonObject(); 72 throw new IOException(new OsmApiException(obj.getInt("code"), null, obj.getString("message"), url.toExternalForm())); 69 try (JsonReader reader = Json.createReader(response.getContentReader())) { 70 JsonStructure json = reader.read(); 71 if (json instanceof JsonArray) { 72 return json.asJsonArray().stream().map(x -> x.asJsonObject().getString("id")).collect(Collectors.toSet()); 73 } else { 74 JsonObject obj = json.asJsonObject(); 75 throw new IOException(new OsmApiException(obj.getInt("code"), null, obj.getString("message"), url.toExternalForm())); 76 } 73 77 } 74 78 } catch (MalformedURLException e) {
Note:
See TracChangeset
for help on using the changeset viewer.