Interface Feature
-
Method Summary
Modifier and TypeMethodDescriptiondefault double
area()
Measures the area of a feature.boolean
boolean
Checks whether this Feature is a member of a Relation.boolean
booleanValue
(String key) bounds()
Retrieves the bounding box of the feature.double
doubleValue
(String key) Returns the value of the given key as adouble
.boolean
Checks whether this feature has a tag with the given key.boolean
Checks whether this feature has a tag with the given key and value.long
id()
Returns the OSM ID of the feature.int
Returns the value of a tag as anint
.boolean
isArea()
Checks whether this Feature represents an area.default boolean
isNode()
Checks if this Feature is an OSM node.boolean
Checks whether this feature is a placeholder.default boolean
Checks if this Feature is an OSM relation.default boolean
isWay()
Checks if this Feature is an OSM way.default double
lat()
Returns the latitude of this feature.default double
length()
Measures the length of this feature.default double
lon()
Returns the longitude of this feature.default Features
members()
Returns the members of thisRelation
.default Features
Returns the members of thisRelation
that match the given query.default Features
nodes()
Returns the way's nodes.default Features
Returns 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 JTSGeometry
object for this feature.int[]
toXY()
Returns the way's coordinates as an array of integers.type()
Returns the feature's type.int
x()
Returns the X coordinate of this feature.int
y()
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 aWay
orRelation
, 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 aWay
orRelation
, 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
null
if 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
0
if 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
0
if 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:
true
if 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
0
if 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
Geometry
object 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
:Polygon
if it represents an area, otherwiseLinearRing
- For a
Relation
that 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
-