本文整理了Java中slash.navigation.rest.Get.executeAsString()
方法的一些代码示例,展示了Get.executeAsString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Get.executeAsString()
方法的具体详情如下:
包路径:slash.navigation.rest.Get
类名称:Get
方法名:executeAsString
暂无
代码示例来源:origin: cpesch/RouteConverter
CatalogType fetch(String url) throws IOException {
long start = System.currentTimeMillis();
String urlWithXml = url + FORMAT_XML;
try {
Get get = new Get(urlWithXml);
String result = get.executeAsString();
if (get.isSuccessful())
try {
return unmarshal(result);
} catch (JAXBException e) {
throw new IOException("Cannot unmarshall " + result + ": " + e, e);
}
}
finally {
long end = System.currentTimeMillis();
log.info("Fetching from " + urlWithXml + " took " + (end - start) + " milliseconds");
}
return null;
}
代码示例来源:origin: cpesch/RouteConverter
private String execute(String uri) throws IOException {
String url = getNominatimUrl() + uri;
Get get = new Get(url);
String result = get.executeAsString();
if (get.isSuccessful())
return result;
return null;
}
代码示例来源:origin: cpesch/RouteConverter
private String execute(String uri) throws IOException {
String url = getPhotonUrl() + uri;
Get get = new Get(url);
String result = get.executeAsString();
if (get.isSuccessful())
return result;
return null;
}
代码示例来源:origin: cpesch/RouteConverter
private void recursiveCollect(String uri, Set<String> uris, Set<String> visitedUris) throws IOException {
if (visitedUris.contains(uri))
return;
visitedUris.add(uri);
log.info(format("Downloading %s", getUrl() + uri));
Get get = new Get(getUrl() + uri);
String result = get.executeAsString();
List<String> anchors = new AnchorParser().parseAnchors(result.replaceAll("<area", "<a"));
List<String> included = new AnchorFilter().filterAnchors(baseUrl, anchors, extensions, includes, excludes);
for (String anchor : included) {
// create the anchor relative to the current uri
String nextUri = appendURIs(uri, anchor);
uris.add(nextUri);
}
List<String> recurse = new AnchorFilter().filterAnchors(baseUrl, anchors, new HashSet<>(asList(".html", "/")), null, null);
for (String anchor : recurse) {
if((getUrl() + anchor).equals(baseUrl) || baseUrl.endsWith(anchor))
continue;
// create the anchor relative to the current uri
String nextUri = appendURIs(uri, anchor);
recursiveCollect(nextUri, uris, visitedUris);
}
}
代码示例来源:origin: cpesch/RouteConverter
public Double getElevationFor(double longitude, double latitude) throws IOException {
String url = getElevationUrl("locations=" + latitude + "," + longitude); // could be up to 512 locations
Get get = get(url);
log.info("Getting elevation for " + longitude + "," + latitude);
String result = get.executeAsString();
if (get.isSuccessful())
try {
ElevationResponse elevationResponse = unmarshalElevation(result);
if (elevationResponse != null) {
String status = elevationResponse.getStatus();
checkForError(url, status);
List<Double> elevations = extractElevations(elevationResponse.getResult());
return elevations != null && elevations.size() > 0 ? elevations.get(0) : null;
}
} catch (JAXBException e) {
throw new IOException("Cannot unmarshall " + result + ": " + e, e);
}
return null;
}
代码示例来源:origin: cpesch/RouteConverter
public List<NavigationPosition> getPositionsFor(String address) throws IOException {
String url = getGeocodingUrl("address=" + encodeUri(address));
Get get = get(url);
log.info("Getting positions for " + address);
String result = get.executeAsString();
if (get.isSuccessful())
try {
GeocodeResponse geocodeResponse = unmarshalGeocode(result);
if (geocodeResponse != null) {
String status = geocodeResponse.getStatus();
checkForError(url, status);
return extractAdresses(geocodeResponse.getResult());
}
} catch (JAXBException e) {
throw new IOException("Cannot unmarshall " + result + ": " + e, e);
}
return null;
}
代码示例来源:origin: cpesch/RouteConverter
private String execute(String uri, String apiType) throws IOException {
String userName = trim(APIKeyRegistry.getInstance().getAPIKey("geonames", apiType));
if(userName == null)
return null;
String url = getGeoNamesApiUrl() + uri + "&username=" + userName;
Get get = new Get(url);
String result = get.executeAsString();
if (get.isSuccessful()) {
checkCurrentlyOverloaded(url, result);
return result;
}
return null;
}
代码示例来源:origin: cpesch/RouteConverter
public String getAddressFor(NavigationPosition position) throws IOException {
String url = getGeocodingUrl("latlng=" + position.getLatitude() + "," + position.getLongitude());
Get get = get(url);
log.info("Getting location for " + position.getLongitude() + "," + position.getLatitude());
String result = get.executeAsString();
if (get.isSuccessful())
try {
GeocodeResponse geocodeResponse = unmarshalGeocode(result);
if (geocodeResponse != null) {
String status = geocodeResponse.getStatus();
checkForError(url, status);
return extractClosestLocation(geocodeResponse.getResult(), position.getLongitude(), position.getLatitude());
}
} catch (JAXBException e) {
throw new IOException("Cannot unmarshall " + result + ": " + e, e);
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!