kopia lustrzana https://github.com/JOSM/MapWithAI
Remove apache dependency
Signed-off-by: Taylor Smock <smocktaylor@gmail.com>pull/1/head
rodzic
5caa086231
commit
c2551c6dcf
|
@ -58,7 +58,6 @@ dependencies {
|
|||
testImplementation("org.openstreetmap.josm:josm-unittest:"){changing=true}
|
||||
testImplementation("com.github.tomakehurst:wiremock:2.21.0")
|
||||
testImplementation("org.awaitility:awaitility:3.1.6")
|
||||
compile 'org.apache.httpcomponents:httpclient:4.5.10'
|
||||
}
|
||||
|
||||
// Add dependencies from ivy.xml
|
||||
|
|
|
@ -2,14 +2,11 @@
|
|||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.openstreetmap.josm.data.osm.BBox;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.io.IllegalDataException;
|
||||
|
@ -31,24 +28,24 @@ public final class RapiDDataUtils {
|
|||
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
|
||||
public static DataSet getData(BBox bbox) {
|
||||
Logging.setLogLevel(Logging.LEVEL_DEBUG);
|
||||
CloseableHttpResponse response = null;
|
||||
InputStream inputStream = null;
|
||||
DataSet dataSet = new DataSet();
|
||||
try {
|
||||
final URI uri = new URIBuilder().setScheme("https").setHost("www.facebook.com").setPath("/maps/ml_roads")
|
||||
.setParameter("conflate_with_osm", "true").setParameter("theme", "ml_road_vector")
|
||||
.setParameter("collaborator", "fbid").setParameter("token", RAPID_API_TOKEN)
|
||||
.setParameter("hash", "ASYM8LPNy8k1XoJiI7A").setParameter("bbox", bbox.toStringCSV(",")).build();
|
||||
final HttpGet httpget = new HttpGet(uri);
|
||||
final CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
final String query = new StringBuilder().append("conflate_with_osm=").append(true).append("theme=")
|
||||
.append("ml_road_vector").append("&").append("collaborator=").append("fbid").append("&")
|
||||
.append("token=").append(RAPID_API_TOKEN).append("&").append("hash=").append("ASYM8LPNy8k1XoJiI7A")
|
||||
.append("&").append("bbox=").append(bbox.toString()).toString();
|
||||
final URI uri = new URI("https", null, "www.facebook.com", 80, "/maps/ml_roads", query, null);
|
||||
final URL url = uri.toURL();
|
||||
inputStream = url.openStream();
|
||||
Logging.info("{0}: Getting {1}", RapiDPlugin.NAME, uri.toASCIIString());
|
||||
response = httpclient.execute(httpget);
|
||||
dataSet = OsmReader.parseDataSet(response.getEntity().getContent(), null);
|
||||
dataSet = OsmReader.parseDataSet(inputStream, null);
|
||||
} catch (URISyntaxException | UnsupportedOperationException | IllegalDataException | IOException e) {
|
||||
Logging.debug(e);
|
||||
} finally {
|
||||
if (response != null) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
response.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
Logging.debug(e);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue