Package org.openstreetmap.josm.tools
Class Territories
- java.lang.Object
-
- org.openstreetmap.josm.tools.Territories
-
public final class Territories extends java.lang.Object
Look up territories ISO3166 codes at a certain place.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Map<java.lang.String,TagMap>
customTagsCache
private static DataSet
dataSet
static java.lang.String
FILENAME
Internal OSM filenameprivate static java.lang.String
ISO3166_1
private static java.lang.String
ISO3166_1_LC
private static java.lang.String
ISO3166_2
private static java.lang.String
ISO3166_2_LC
(package private) static java.util.Map<java.lang.String,GeoPropertyIndex<java.lang.Boolean>>
iso3166Cache
private static java.util.List<java.lang.String>
KNOWN_KEYS
private static java.lang.String
TAGINFO
(package private) static java.util.Map<java.lang.String,TaginfoRegionalInstance>
taginfoCache
(package private) static java.util.Map<java.lang.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(java.lang.String code, GeoPropertyIndex<java.lang.Boolean> gpi, TagMap tags)
static TagMap
getCustomTags(java.lang.String code)
Returns the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code.static GeoPropertyIndex<java.lang.Boolean>
getGeoPropertyIndex(java.lang.String code)
Returns theGeoPropertyIndex
for the given ISO3166-1 or ISO3166-2 code.static java.util.Set<java.lang.String>
getKnownIso3166Codes()
Get all known ISO3166-1 and ISO3166-2 codes.static DataSet
getOriginalDataSet()
Returns the original territories dataset.static java.util.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(java.lang.String source, java.lang.String path)
static void
initializeInternalData()
Initializes territories using the internal data only.static boolean
isIso3166Code(java.lang.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(java.util.Map<java.lang.String,TaginfoRegionalInstance> cache, java.lang.String taginfo, jakarta.json.JsonArray jsonCodes, java.lang.String source)
-
-
-
Field Detail
-
FILENAME
public static final java.lang.String FILENAME
Internal OSM filename- See Also:
- Constant Field Values
-
ISO3166_1
private static final java.lang.String ISO3166_1
- See Also:
- Constant Field Values
-
ISO3166_2
private static final java.lang.String ISO3166_2
- See Also:
- Constant Field Values
-
ISO3166_1_LC
private static final java.lang.String ISO3166_1_LC
-
ISO3166_2_LC
private static final java.lang.String ISO3166_2_LC
-
TAGINFO
private static final java.lang.String TAGINFO
- See Also:
- Constant Field Values
-
iso3166Cache
static volatile java.util.Map<java.lang.String,GeoPropertyIndex<java.lang.Boolean>> iso3166Cache
-
taginfoCache
static volatile java.util.Map<java.lang.String,TaginfoRegionalInstance> taginfoCache
-
taginfoGeofabrikCache
static volatile java.util.Map<java.lang.String,TaginfoRegionalInstance> taginfoGeofabrikCache
-
customTagsCache
static volatile java.util.Map<java.lang.String,TagMap> customTagsCache
-
KNOWN_KEYS
private static final java.util.List<java.lang.String> KNOWN_KEYS
-
-
Constructor Detail
-
Territories
private Territories()
-
-
Method Detail
-
getKnownIso3166Codes
public static java.util.Set<java.lang.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<java.lang.Boolean> getGeoPropertyIndex(java.lang.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(java.lang.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(java.lang.String code, GeoPropertyIndex<java.lang.Boolean> gpi, TagMap tags)
-
initializeExternalData
private static void initializeExternalData()
-
initializeExternalData
static void initializeExternalData(java.lang.String source, java.lang.String path)
-
readExternalTaginfo
private static void readExternalTaginfo(java.util.Map<java.lang.String,TaginfoRegionalInstance> cache, java.lang.String taginfo, jakarta.json.JsonArray jsonCodes, java.lang.String source)
-
getRegionalTaginfoUrls
public static java.util.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(java.lang.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
-
-