Package org.openstreetmap.josm.tools
Class Territories
- java.lang.Object
-
- org.openstreetmap.josm.tools.Territories
-
public final class Territories extends Object
Look up territories ISO3166 codes at a certain place.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Map<String,TagMap>
customTagsCache
private static DataSet
dataSet
static String
FILENAME
Internal OSM filenameprivate static String
ISO3166_1
private static String
ISO3166_1_LC
private static String
ISO3166_2
private static String
ISO3166_2_LC
(package private) static Map<String,GeoPropertyIndex<Boolean>>
iso3166Cache
private static List<String>
KNOWN_KEYS
private static String
TAGINFO
(package private) static Map<String,TaginfoRegionalInstance>
taginfoCache
(package private) static Map<String,TaginfoRegionalInstance>
taginfoGeofabrikCache
-
Constructor Summary
Constructors Modifier Constructor Description private
Territories()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addInCache(String code, GeoPropertyIndex<Boolean> gpi, TagMap tags)
static TagMap
getCustomTags(String code)
Returns the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code.static GeoPropertyIndex<Boolean>
getGeoPropertyIndex(String code)
Returns theGeoPropertyIndex
for the given ISO3166-1 or ISO3166-2 code.static Set<String>
getKnownIso3166Codes()
Get all known ISO3166-1 and ISO3166-2 codes.static DataSet
getOriginalDataSet()
Returns the original territories dataset.static List<TaginfoRegionalInstance>
getRegionalTaginfoUrls(LatLon ll)
Returns regional taginfo instances for the given location.static void
initialize()
Initializes territories.private static void
initializeExternalData()
(package private) static void
initializeExternalData(String source, String path)
static void
initializeInternalData()
Initializes territories using the internal data only.static boolean
isIso3166Code(String code, LatLon ll)
Determine, if a point is inside a territory with the given ISO3166-1 or ISO3166-2 code.private static void
readExternalTaginfo(Map<String,TaginfoRegionalInstance> cache, String taginfo, javax.json.JsonArray jsonCodes, String source)
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
Internal OSM filename- See Also:
- Constant Field Values
-
ISO3166_1
private static final String ISO3166_1
- See Also:
- Constant Field Values
-
ISO3166_2
private static final String ISO3166_2
- See Also:
- Constant Field Values
-
ISO3166_1_LC
private static final String ISO3166_1_LC
-
ISO3166_2_LC
private static final String ISO3166_2_LC
-
TAGINFO
private static final String TAGINFO
- See Also:
- Constant Field Values
-
iso3166Cache
static volatile Map<String,GeoPropertyIndex<Boolean>> iso3166Cache
-
taginfoCache
static volatile Map<String,TaginfoRegionalInstance> taginfoCache
-
taginfoGeofabrikCache
static volatile Map<String,TaginfoRegionalInstance> taginfoGeofabrikCache
-
customTagsCache
static volatile Map<String,TagMap> customTagsCache
-
KNOWN_KEYS
private static final List<String> KNOWN_KEYS
-
-
Constructor Detail
-
Territories
private Territories()
-
-
Method Detail
-
getKnownIso3166Codes
public static Set<String> getKnownIso3166Codes()
Get all known ISO3166-1 and ISO3166-2 codes.- Returns:
- the ISO3166-1 and ISO3166-2 codes for the given location
-
getGeoPropertyIndex
public static GeoPropertyIndex<Boolean> getGeoPropertyIndex(String code)
Returns theGeoPropertyIndex
for the given ISO3166-1 or ISO3166-2 code.- Parameters:
code
- the ISO3166-1 or ISO3166-2 code- Returns:
- the
GeoPropertyIndex
for the givencode
- Since:
- 14484
-
isIso3166Code
public static boolean isIso3166Code(String code, LatLon ll)
Determine, if a point is inside a territory with the given ISO3166-1 or ISO3166-2 code.- Parameters:
code
- the ISO3166-1 or ISO3166-2 codell
- the coordinates of the point- Returns:
- true, if the point is inside a territory with the given code
-
getOriginalDataSet
public static DataSet getOriginalDataSet()
Returns the original territories dataset. Be extra cautious when manipulating it!- Returns:
- the original territories dataset
- Since:
- 15565
-
initialize
public static void initialize()
Initializes territories. TODO: Synchronization can be refined inside theGeoPropertyIndex
as most look-ups are read-only.- See Also:
initializeInternalData()
-
initializeInternalData
public static void initializeInternalData()
Initializes territories using the internal data only.
-
addInCache
private static void addInCache(String code, GeoPropertyIndex<Boolean> gpi, TagMap tags)
-
initializeExternalData
private static void initializeExternalData()
-
initializeExternalData
static void initializeExternalData(String source, String path)
-
readExternalTaginfo
private static void readExternalTaginfo(Map<String,TaginfoRegionalInstance> cache, String taginfo, javax.json.JsonArray jsonCodes, String source)
-
getRegionalTaginfoUrls
public static List<TaginfoRegionalInstance> getRegionalTaginfoUrls(LatLon ll)
Returns regional taginfo instances for the given location.- Parameters:
ll
- lat/lon where to look.- Returns:
- regional taginfo instances for the given location (code / url)
- Since:
- 15876
-
getCustomTags
public static TagMap getCustomTags(String code)
Returns the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code.- Parameters:
code
- the ISO3166-1 or ISO3166-2 code- Returns:
- the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code, or
null
- Since:
- 16109
-
-