kopia lustrzana https://github.com/JOSM/MapWithAI
Update country list
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
36a65b1966
commit
220de3cb5d
|
@ -32,7 +32,8 @@ import org.openstreetmap.josm.tools.Logging;
|
|||
import org.openstreetmap.josm.tools.Territories;
|
||||
|
||||
public final class MapWithAIAvailability {
|
||||
private static String rapidReleases = "https://github.com/facebookmicrosites/Open-Mapping-At-Facebook/raw/master/data/rapid_releases.geojson";
|
||||
private static String rapidReleases = "https://raw.githubusercontent.com/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson";
|
||||
/** A map of country to a map of available types */
|
||||
private static final Map<String, Map<String, Boolean>> COUNTRIES = new HashMap<>();
|
||||
private static final Map<String, String> POSSIBLE_DATA_POINTS = new TreeMap<>();
|
||||
/** Original country, replacement countries */
|
||||
|
@ -109,7 +110,17 @@ public final class MapWithAIAvailability {
|
|||
final Optional<OsmPrimitive> realCountry = territories.allPrimitives().parallelStream()
|
||||
.filter(primitive -> countryName.equalsIgnoreCase(primitive.get("name:en"))).findFirst();
|
||||
if (realCountry.isPresent()) {
|
||||
final String key = realCountry.get().get("ISO3166-1:alpha2");
|
||||
final OsmPrimitive countryLoop = realCountry.get();
|
||||
final String key = Optional.ofNullable(countryLoop.get("ISO3166-1:alpha2"))
|
||||
.orElse(Optional.ofNullable(countryLoop.get("ISO3166-2")).orElse(""));
|
||||
if ("".equals(key)) {
|
||||
Logging.error("{0}: {1} does not have a \"ISO3166-1:alpha2\" or \"ISO3166-2\" key. {2}",
|
||||
MapWithAIPlugin.NAME,
|
||||
countryLoop, countryLoop.getInterestingTags());
|
||||
} else {
|
||||
Logging.trace("{0}: {1} has a country code of {2}", MapWithAIPlugin.NAME,
|
||||
countryLoop.get("name:en"), key);
|
||||
}
|
||||
// We need to handle cases like Alaska more elegantly
|
||||
final Map<String, Boolean> data = returnCountries.getOrDefault(key, new TreeMap<>());
|
||||
for (final Entry<String, String> entry : POSSIBLE_DATA_POINTS.entrySet()) {
|
||||
|
@ -152,6 +163,7 @@ public final class MapWithAIAvailability {
|
|||
public boolean hasData(LatLon latLon) {
|
||||
boolean returnBoolean = false;
|
||||
for (final Entry<String, Map<String, Boolean>> entry : COUNTRIES.entrySet()) {
|
||||
Logging.debug(entry.getKey());
|
||||
if (Territories.isIso3166Code(entry.getKey(), latLon)) {
|
||||
returnBoolean = entry.getValue().entrySet().parallelStream().anyMatch(Entry::getValue);
|
||||
break;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"id" : "c23bbc7a-641a-4cdb-abf0-d9b4e5a4e36f",
|
||||
"name" : "facebookmicrosites_open-mapping-at-facebook_raw_master_data_rapid_releasesgeojson",
|
||||
"request" : {
|
||||
"url" : "/facebookmicrosites/Open-Mapping-At-Facebook/raw/master/data/rapid_releases.geojson",
|
||||
"method" : "GET"
|
||||
},
|
||||
"response" : {
|
||||
"status" : 302,
|
||||
"body" : "<html><body>You are being <a href=\"https://raw.githubusercontent.com/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson\">redirected</a>.</body></html>",
|
||||
"headers" : {
|
||||
"Server" : "GitHub.com",
|
||||
"Date" : "Thu, 24 Oct 2019 16:54:29 GMT",
|
||||
"Content-Type" : "text/html; charset=utf-8",
|
||||
"Status" : "302 Found",
|
||||
"Vary" : "X-PJAX",
|
||||
"Access-Control-Allow-Origin" : "https://render.githubusercontent.com",
|
||||
"Location" : "https://raw.githubusercontent.com/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson",
|
||||
"Cache-Control" : "no-cache",
|
||||
"Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options" : "deny",
|
||||
"X-Content-Type-Options" : "nosniff",
|
||||
"X-XSS-Protection" : "1; mode=block",
|
||||
"Expect-CT" : "max-age=2592000, report-uri=\"https://api.github.com/_private/browser/errors\"",
|
||||
"Content-Security-Policy" : "default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com *.githubusercontent.com; manifest-src 'self'; media-src 'none'; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com",
|
||||
"Age" : "0",
|
||||
"X-GitHub-Request-Id" : "CA53:239D:1BDBEC:33B854:5DB1D745"
|
||||
}
|
||||
},
|
||||
"uuid" : "c23bbc7a-641a-4cdb-abf0-d9b4e5a4e36f",
|
||||
"persistent" : true,
|
||||
"insertionIndex" : 31
|
||||
}
|
Ładowanie…
Reference in New Issue