Interface Feature
-
Method Summary
Modifier and TypeMethodDescriptiondefault doublearea()Measures the area of a feature.booleanbooleanChecks whether this Feature is a member of a Relation.booleanbooleanValue(String key) bounds()Retrieves the bounding box of the feature.doubledoubleValue(String key) Returns the value of the given key as adouble.booleanChecks whether this feature has a tag with the given key.booleanChecks whether this feature has a tag with the given key and value.longid()Returns the OSM ID of the feature.intReturns the value of a tag as anint.booleanisArea()Checks whether this Feature represents an area.default booleanisNode()Checks if this Feature is an OSM node.booleanChecks whether this feature is a placeholder.default booleanChecks if this Feature is an OSM relation.default booleanisWay()Checks if this Feature is an OSM way.default doublelat()Returns the latitude of this feature.default doublelength()Measures the length of this feature.default doublelon()Returns the longitude of this feature.default Featuresmembers()Returns the members of thisRelation.default FeaturesReturns the members of thisRelationthat match the given query.default Featuresnodes()Returns the way's nodes.default FeaturesReturns the way's nodes that match the given query.parents()Returns all ways and relations to which this Feature belongs.Returns all ways and relations to which this Feature belongs that match the given query.role()If this Feature was returned by a call tomembers()(or its variants) of a Relation, returns this Feature's role in that Relation.stringValue(String key) Returns the value of a tag as aString.Returns the string value of the given key.tags()Returns the tags of this feature.Creates a JTSGeometryobject for this feature.int[]toXY()Returns the way's coordinates as an array of integers.type()Returns the feature's type.intx()Returns the X coordinate of this feature.inty()Returns the Y coordinate of this feature.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
id
long id()Returns the OSM ID of the feature. For nodes that have no tags and are not member of any relation, the ID may be 0.- Returns:
- the feature's OSM ID
-
type
-
isNode
default boolean isNode()Checks if this Feature is an OSM node. -
isWay
default boolean isWay()Checks if this Feature is an OSM way. -
isRelation
default boolean isRelation()Checks if this Feature is an OSM relation. -
x
int x()Returns the X coordinate of this feature. For aWayorRelation, this is the horizontal midpoint of its bounding box.- Returns:
- X coordinate in Mercator projection
-
y
int y()Returns the Y coordinate of this feature. For aWayorRelation, this is the vertical midpoint of its bounding box.- Returns:
- Y coordinate in Mercator projection
-
lon
-
lat
-
bounds
Box bounds()Retrieves the bounding box of the feature.- Returns:
- a copy of the Feature's bounding box
-
toXY
int[] toXY()Returns the way's coordinates as an array of integers. X coordinates are stored at even index positions, Y at odd.- Returns:
- an array of coordinate pairs
-
tags
-
tag
-
hasTag
Checks whether this feature has a tag with the given key.- Parameters:
key- the key (e.g.highway)- Returns:
- true if feature is tagged with this key, otherwise false
-
hasTag
-
belongsTo
-
role
String role()If this Feature was returned by a call tomembers()(or its variants) of a Relation, returns this Feature's role in that Relation.- Returns:
- the feature's role, or an empty String (if the feature is a
member without an assigned role), or
nullif it was obtained via another kind of query
-
stringValue
-
intValue
Returns the value of a tag as anint.- Parameters:
key- the key of the tag- Returns:
- the tag's value, or
0if the tag does not exist or has a value that cannot be converted to an integer
-
doubleValue
Returns the value of the given key as adouble.- Parameters:
key-- Returns:
- the key's value, or
0if the key does not exist, or its value is not a valid number
-
booleanValue
-
belongsToRelation
boolean belongsToRelation()Checks whether this Feature is a member of a Relation.- Returns:
trueif this Feature belongs to at least one Relation
-
isArea
boolean isArea()Checks whether this Feature represents an area. Areas are closed ways that have certain tags (e.g.landuse), or are explicitly tagged witharea=yes; or relations that represent (multi-) polygons.- Returns:
- true if this feature is an area, otherwise false
-
isPlaceholder
boolean isPlaceholder()Checks whether this feature is a placeholder. A placeholder is a feature that is referenced by a relation, but is not actually present in a dataset.- Returns:
-
length
default double length()Measures the length of this feature.- Returns:
- length (in meters), or
0if the feature is not lineal. TODO: should return circumference for areas
-
area
default double area()Measures the area of a feature.- Returns:
- area (in square meters), or 0 if the feature is not polygonal
-
toGeometry
Geometry toGeometry()Creates a JTS
Geometryobject for this feature. The returned following types of geometries are created:- For a
Node:Point - For a non-closed
Way:LineString - For a closed
Way:Polygonif it represents an area, otherwiseLinearRing - For a
Relationthat is an area:Polygon - For a non-area
Relation:GeometryCollection
- Returns:
- a newly created Geometry
- For a
-
nodes
-
nodes
-
members
Returns the members of thisRelation.- Returns:
- a collection of features that belong to this relation, or an empty collection if this relation has no members
-
members
-
parents
Features parents()Returns all ways and relations to which this Feature belongs.- Returns:
- a collection of ways and/or relations (may be empty)
-
parents
-