Package org.openstreetmap.josm.data.osm
Class OsmUtils
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.OsmUtils
-
public final class OsmUtils extends java.lang.Object
Utility methods/constants that are useful for generic OSM tag handling.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FALSE_VALUE
A value that should be used to indicate falsestatic java.lang.String
falseval
Deprecated.since 18801, useFALSE_VALUE
instead.static java.lang.String
REVERSE_VALUE
A value that should be used to indicate that a property applies reversed on the waystatic java.lang.String
reverseval
Deprecated.since 18801, useREVERSE_VALUE
instead.static java.lang.String
TRUE_VALUE
A value that should be used to indicate truestatic java.lang.String
trueval
Deprecated.since 18801, useTRUE_VALUE
instead.
-
Constructor Summary
Constructors Modifier Constructor Description private
OsmUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OsmPrimitive
createPrimitive(java.lang.String assertion)
Creates a new OSM primitive around (0,0) according to the given assertion.static OsmPrimitive
createPrimitive(java.lang.String assertion, LatLon around, boolean enforceLocation)
Creates a new OSM primitive according to the given assertion.static java.lang.String
getLayer(IPrimitive w)
Returns the layer value of primitive (null for layer 0).static java.lang.String
getNamedOsmBoolean(java.lang.String value)
Normalizes the OSM boolean valuestatic java.lang.Boolean
getOsmBoolean(java.lang.String value)
Converts a string to a boolean valuestatic boolean
isFalse(java.lang.String value)
Check if a tag value represents a boolean false valuestatic boolean
isOsmCollectionEditable(java.util.Collection<? extends IPrimitive> collection)
Determines if the given collection contains primitives, and that none of them belong to a locked layer.static boolean
isReversed(java.lang.String value)
Check if the value is a value indicating that a property applies reversed.static boolean
isTrue(java.lang.String value)
Check if a tag value represents a boolean true valueprivate static Node
newNode(LatLon around)
private static Relation
newRelation(LatLon around, boolean enforceLocation)
private static Way
newWay(LatLon around, boolean enforceLocation)
static java.util.stream.Stream<java.lang.String>
splitMultipleValues(java.lang.String value)
Splits a tag value by semi-colon value separator.
-
-
-
Field Detail
-
TRUE_VALUE
public static final java.lang.String TRUE_VALUE
A value that should be used to indicate true- Since:
- 12186
- See Also:
- Constant Field Values
-
FALSE_VALUE
public static final java.lang.String FALSE_VALUE
A value that should be used to indicate false- Since:
- 12186
- See Also:
- Constant Field Values
-
REVERSE_VALUE
public static final java.lang.String REVERSE_VALUE
A value that should be used to indicate that a property applies reversed on the way- Since:
- 12186
- See Also:
- Constant Field Values
-
trueval
@Deprecated public static final java.lang.String trueval
Deprecated.since 18801, useTRUE_VALUE
instead.Discouraged synonym forTRUE_VALUE
- See Also:
- Constant Field Values
-
falseval
@Deprecated public static final java.lang.String falseval
Deprecated.since 18801, useFALSE_VALUE
instead.Discouraged synonym forFALSE_VALUE
- See Also:
- Constant Field Values
-
reverseval
@Deprecated public static final java.lang.String reverseval
Deprecated.since 18801, useREVERSE_VALUE
instead.Discouraged synonym forREVERSE_VALUE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OsmUtils
private OsmUtils()
-
-
Method Detail
-
getOsmBoolean
public static java.lang.Boolean getOsmBoolean(java.lang.String value)
Converts a string to a boolean value- Parameters:
value
- The string to convert- Returns:
Boolean.TRUE
if that string represents a true value,
Boolean.FALSE
if it represents a false value,
null
otherwise.
-
getNamedOsmBoolean
public static java.lang.String getNamedOsmBoolean(java.lang.String value)
Normalizes the OSM boolean value- Parameters:
value
- The tag value- Returns:
- The best true/false value or the old value if the input cannot be converted.
- See Also:
TRUE_VALUE
,FALSE_VALUE
-
isReversed
public static boolean isReversed(java.lang.String value)
Check if the value is a value indicating that a property applies reversed.- Parameters:
value
- The value to check- Returns:
- true if it is reversed.
-
isTrue
public static boolean isTrue(java.lang.String value)
Check if a tag value represents a boolean true value- Parameters:
value
- The value to check- Returns:
- true if it is a true value.
-
isFalse
public static boolean isFalse(java.lang.String value)
Check if a tag value represents a boolean false value- Parameters:
value
- The value to check- Returns:
- true if it is a false value.
-
createPrimitive
public static OsmPrimitive createPrimitive(java.lang.String assertion)
Creates a new OSM primitive around (0,0) according to the given assertion. Originally written for unit tests, this can also be used in other places like validation of local MapCSS validator rules. Ways and relations created using this method are empty.- Parameters:
assertion
- The assertion describing OSM primitive (ex: "way name=Foo railway=rail")- Returns:
- a new OSM primitive according to the given assertion
- Throws:
java.lang.IllegalArgumentException
- if assertion is null or if the primitive type cannot be deduced from it- Since:
- 7356
-
createPrimitive
public static OsmPrimitive createPrimitive(java.lang.String assertion, LatLon around, boolean enforceLocation)
Creates a new OSM primitive according to the given assertion. Originally written for unit tests, this can also be used in other places like validation of local MapCSS validator rules.- Parameters:
assertion
- The assertion describing OSM primitive (ex: "way name=Foo railway=rail")around
- the coordinate at which the primitive will be locatedenforceLocation
- iftrue
, ways and relations will not be empty to force a physical location- Returns:
- a new OSM primitive according to the given assertion
- Throws:
java.lang.IllegalArgumentException
- if assertion is null or if the primitive type cannot be deduced from it- Since:
- 14486
-
newRelation
private static Relation newRelation(LatLon around, boolean enforceLocation)
-
getLayer
public static java.lang.String getLayer(IPrimitive w)
Returns the layer value of primitive (null for layer 0).- Parameters:
w
- OSM primitive- Returns:
- the value of "layer" key, or null if absent or set to 0 (default value)
- Since:
- 12986, 13637 (signature)
-
isOsmCollectionEditable
public static boolean isOsmCollectionEditable(java.util.Collection<? extends IPrimitive> collection)
Determines if the given collection contains primitives, and that none of them belong to a locked layer.- Parameters:
collection
- collection of OSM primitives- Returns:
true
if the given collection is not empty and does not contain any primitive in a locked layer.- Since:
- 13611, 13957 (signature)
-
splitMultipleValues
public static java.util.stream.Stream<java.lang.String> splitMultipleValues(java.lang.String value)
Splits a tag value by semi-colon value separator. Spaces around the ; are ignored.- Parameters:
value
- the value to separate- Returns:
- the separated values as Stream
- Since:
- 15671
-
-