Class Feature
- java.lang.Object
-
- gov.usgs.earthquake.nshmp.geo.json.Feature
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Feature.Builder
A single-use feature builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocationList
asLineString()
Return the geometry of this feature as a line string.List<LocationList>
asMultiLineString()
Return the geometry of the feature as multi-line string.Location
asPoint()
Return the geometry of this feature as a point.LocationList
asPolygonBorder()
Return the border of this polygon feature.Optional<double[]>
bbox()
The bounding box value array; If bbox isnull
, returns Optional.empty(), else returns anOptional<double[]>
copy of the bbox value array.static Feature.Builder
copyOf(Feature feature)
Create a single-use feature builder with the geometry, id, and bounding box of the supplied feature.boolean
equals(Object obj)
int
hashCode()
OptionalInt
idAsInt()
The 'id' of this feature as aOptionalInt
.Optional<String>
idAsString()
The 'id' of this feature as aOptional<String>
.static Feature.Builder
lineString(LocationList line)
Create a single-use line string feature builder.static Feature.Builder
multiLineString(List<LocationList> multiLine)
Create a single-use multi-line string feature builder.static Feature.Builder
point(Location location)
Create a single-use point feature builder.static Feature.Builder
polygon(LocationList exterior, LocationList... interiors)
Create a single-use polygon feature builder.Properties
properties()
Get the property map associated with this feature as aProperties
helper object.String
toJson()
Return the serialized form of this GeoJSON feature.com.google.gson.JsonElement
toJsonTree()
Returns theFeature
as aJsonElement
.GeoJson.Type
type()
The GeoJSON geometry type of this feature, one of:[POINT, LINE_STRING, POLYGON, MULTI_LINE_STRING]
.void
write(Path path)
Write the serialized form of this GeoJSON feature to the file atpath
.
-
-
-
Method Detail
-
point
public static Feature.Builder point(Location location)
Create a single-use point feature builder.- Parameters:
location
- of point
-
lineString
public static Feature.Builder lineString(LocationList line)
Create a single-use line string feature builder.- Parameters:
line
- locations
-
multiLineString
public static Feature.Builder multiLineString(List<LocationList> multiLine)
Create a single-use multi-line string feature builder.- Parameters:
multiLine
- locations
-
polygon
public static Feature.Builder polygon(LocationList exterior, LocationList... interiors)
Create a single-use polygon feature builder.- Parameters:
exterior
- linear ring boundary of polygoninteriors
- optional interior linear rings
-
copyOf
public static Feature.Builder copyOf(Feature feature)
Create a single-use feature builder with the geometry, id, and bounding box of the supplied feature. The properties of the supplied feature are not copied. UseProperties.fromFeature(Feature)
to build a new property map from those in the supplied feature.- Parameters:
feature
- to copy into builder- See Also:
Properties.fromFeature(Feature)
-
idAsString
public Optional<String> idAsString()
The 'id' of this feature as aOptional<String>
. If this feature does not contain an 'id' member, returnOptional.empty()
.
-
idAsInt
public OptionalInt idAsInt()
The 'id' of this feature as aOptionalInt
. If this feature does not contain an 'id' member, returnOptionalInt.empty()
.
-
bbox
public Optional<double[]> bbox()
The bounding box value array; If bbox isnull
, returns Optional.empty(), else returns anOptional<double[]>
copy of the bbox value array.
-
properties
public Properties properties()
Get the property map associated with this feature as aProperties
helper object. May be null or empty.
-
type
public GeoJson.Type type()
The GeoJSON geometry type of this feature, one of:[POINT, LINE_STRING, POLYGON, MULTI_LINE_STRING]
.- See Also:
GeoJson.Type
-
asPoint
public Location asPoint()
Return the geometry of this feature as a point.- Throws:
UnsupportedOperationException
- if feature is not a point.
-
asLineString
public LocationList asLineString()
Return the geometry of this feature as a line string.- Throws:
UnsupportedOperationException
- if feature is not a line string.
-
asMultiLineString
public List<LocationList> asMultiLineString()
Return the geometry of the feature as multi-line string.- Throws:
UnsupportedOperationException
- if feature is not a multi-line string.
-
asPolygonBorder
public LocationList asPolygonBorder()
Return the border of this polygon feature.- Throws:
UnsupportedOperationException
- if feature is not a polygon.
-
toJson
public String toJson()
Return the serialized form of this GeoJSON feature.
-
toJsonTree
public com.google.gson.JsonElement toJsonTree()
Returns theFeature
as aJsonElement
.
-
write
public void write(Path path) throws IOException
Write the serialized form of this GeoJSON feature to the file atpath
.- Throws:
IOException
-
-