public class Feature extends Object implements GeoJSON
Modifier | Constructor and Description |
---|---|
protected |
Feature(Geometry geometry,
com.google.gson.JsonObject properties,
String id)
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBooleanProperty(String key,
Boolean value)
Convenience method to add a Boolean member.
|
void |
addCharacterProperty(String key,
Character value)
Convenience method to add a Character member.
|
void |
addNumberProperty(String key,
Number value)
Convenience method to add a Number member.
|
void |
addProperty(String key,
com.google.gson.JsonElement value)
Convenience method to add a JsonElement member.
|
void |
addStringProperty(String key,
String value)
Convenience method to add a String member.
|
static Feature |
fromGeometry(Geometry geometry)
Create a feature from geometry.
|
static Feature |
fromGeometry(Geometry geometry,
com.google.gson.JsonObject properties)
Create a feature from geometry.
|
static Feature |
fromGeometry(Geometry geometry,
com.google.gson.JsonObject properties,
String id)
Create a feature from geometry.
|
static Feature |
fromJson(String json)
Create a GeoJSON feature object from JSON.
|
Boolean |
getBooleanProperty(String key)
Convenience method to get a Boolean member.
|
Character |
getCharacterProperty(String key)
Convenience method to get a Character member.
|
Geometry |
getGeometry()
Get the features
Geometry . |
String |
getId()
The optional, common identifier of this feature.
|
Number |
getNumberProperty(String key)
Convenience method to get a Number member.
|
com.google.gson.JsonObject |
getProperties()
Returns the optional properties of this feature as JSON.
|
com.google.gson.JsonElement |
getProperty(String key)
Convenience method to get a JsonElement member.
|
String |
getStringProperty(String key)
Convenience method to get a String member.
|
String |
getType()
Should always be "Feature".
|
boolean |
hasNonNullValueForProperty(String key)
Convenience method to check for a member by name as well as non-null value.
|
boolean |
hasProperty(String key)
Convenience method to check if a member with the specified name is present in this object.
|
com.google.gson.JsonElement |
removeProperty(String key)
Removes the property from the object properties
|
void |
setGeometry(Geometry geometry) |
void |
setId(String id) |
void |
setProperties(com.google.gson.JsonObject properties) |
String |
toJson()
Convert feature into JSON.
|
public String getType()
public Geometry getGeometry()
Geometry
.Geometry
of the feature or null if not set.public void setGeometry(Geometry geometry)
public com.google.gson.JsonObject getProperties()
public void setProperties(com.google.gson.JsonObject properties)
public String getId()
public void setId(String id)
public static Feature fromGeometry(Geometry geometry, com.google.gson.JsonObject properties)
public static Feature fromGeometry(Geometry geometry, com.google.gson.JsonObject properties, String id)
public static Feature fromJson(String json)
json
- String of JSON making up a feature.Feature
GeoJSON object.public String toJson()
public void addStringProperty(String key, String value)
key
- name of the membervalue
- the String value associated with the memberpublic void addNumberProperty(String key, Number value)
key
- name of the membervalue
- the Number value associated with the memberpublic void addBooleanProperty(String key, Boolean value)
key
- name of the membervalue
- the Boolean value associated with the memberpublic void addCharacterProperty(String key, Character value)
key
- name of the membervalue
- the Character value associated with the memberpublic void addProperty(String key, com.google.gson.JsonElement value)
key
- name of the membervalue
- the JsonElement value associated with the memberpublic String getStringProperty(String key)
key
- name of the memberpublic Number getNumberProperty(String key)
key
- name of the memberpublic Boolean getBooleanProperty(String key)
key
- name of the memberpublic Character getCharacterProperty(String key)
key
- name of the memberpublic com.google.gson.JsonElement getProperty(String key)
key
- name of the memberpublic com.google.gson.JsonElement removeProperty(String key)
key
- name of the memberproperty
from the key string passed in through the parameter.public boolean hasProperty(String key)
key
- name of the memberpublic boolean hasNonNullValueForProperty(String key)
key
- name of the member© 2015–2016 Mapbox. All rights reserved.