class Feature extends java.lang.Object
A Feature contains a set of named attributes with values.
A Feature is created from a Map of name value pairs and an identifier.
Without a Schema (see below) the data types are inferred).
Feature f = new Feature(['name': 'anvil', 'price': 100.0], 'widgets.1')
A Feature can also be created from a list of values, an identifier, and a Schema
Schema s = new Schema('widgets', [['name','string'],['price','float']]) Feature f = new Feature(['anvil', 100.0], '1', s)
A Feature can also be created from a Map of name value pairs, an identifier, and a Schema
Schema s = new Schema('widgets', [['name','string'],['price','float']]) Feature f = new Feature(['name': 'anvil', 'price': 100.0], '1', s)
Constructor and description |
---|
Feature
(SimpleFeature f) Create a new Feature by wrapping a GeoTools SimpleFeature |
Feature
(Map attributes, java.lang.String id, Schema schema) Create a new Feature with a Map of attributes, an id, and a Schema. |
Feature
(java.util.List attributes, java.lang.String id, Schema schema) Create a new Feature with a List of values, an id, and a Schema. |
Feature
(Map attributes, java.lang.String id) Create a new Feature with a Map of Attributes and an Id. |
Type Params | Return Type | Name and description |
---|---|---|
|
java.lang.Object |
get(java.lang.String name) Get a value by Field name. |
|
java.lang.Object |
get(Field field) Get a value by a Field. |
|
java.lang.Object |
getAt(java.lang.String name) Get a value by Field name. |
|
java.lang.Object |
getAt(Field field) Get a value by Field. |
|
Map |
getAttributes() Get a Map of all attributes |
|
Bounds |
getBounds() The Bounds of the Feature's Geometry. |
|
Geometry |
getGeom() Get the Feature's Geometry |
|
java.lang.String |
getId() Get the Feature's ID |
|
void |
putAt(java.lang.String name, java.lang.Object value) Another way of setting a value. |
|
void |
putAt(Field field, java.lang.Object value) Set a value |
|
void |
set(java.lang.String name, java.lang.Object value) Set a value. |
|
void |
set(Field field, java.lang.Object value) Set a value. |
|
void |
set(Feature f) Set the values of this Feature based on values from another Feature |
|
void |
set(Map attributes) Set the values of this Feature based on values from a Map |
|
void |
setGeom(Geometry geom) Set the Feature's Geometry |
|
java.lang.String |
toString() The string representation |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The wrapped GeoTools SimpleFeature
The Layer the Feature was read from
The Schema
Create a new Feature by wrapping a GeoTools SimpleFeature
f
- The GeoTools SimpleFeatureCreate a new Feature with a Map of attributes, an id, and a Schema.
Schema s = new Schema('widgets', [['name','string'],['price','float']])
Feature f = new Feature(['name': 'anvil', 'price': 100.0], '1', s)
attributes
- A Map of name value pairsid
- A String identifierschema
- The SchemaCreate a new Feature with a List of values, an id, and a Schema. The List of values must be in the same order as the Schema's fields.
Schema s = new Schema('widgets', [['name','string'],['price','float']])
Feature f = new Feature(['anvil', 100.0], '1', s)
attributes
- A List of attribute valuesid
- A String identifierschema
- The SchemaCreate a new Feature with a Map of Attributes and an Id. The Schema is inferred from the attribute values.
Feature f = new Feature(['name': 'anvil', 'price': 100.0], 'widgets.1')
atributes
- A Map of name value pairsid
- The string identiferGet a value by Field name.
String name = feature.get("name")
name
- The Field nameGet a value by a Field.
Field fld = feature.schema.get("name")
String name = feature.get(fld)
name
- The Field nameGet a value by Field name. This method supports a the following syntax:
String name = feature["name"]
name
- The Field nameGet a value by Field. This method supports a the following syntax:
Field fld = feature.schema.get("name")
String name = feature[fld]
name
- The FieldGet a Map of all attributes
The Bounds of the Feature's Geometry.
The
- Bounds of the Feature's GeometryGet the Feature's Geometry
Get the Feature's ID
Another way of setting a value. This method supports the following syntax:
feature["name"] = "lighthouse"
name
- The Field namevalue
- The new valueSet a value
Field fld = feature.schema.get("name")
feature[fld] = "lighthouse"
name
- The Fieldvalue
- The new attribute valueSet a value.
feature.set("name") = "lighthouse"
name
- The Field namevalue
- The new attribute valueSet a value.
Field fld = feature.schema.get("name")
feature.set(fld) = "lighthouse"
name
- The Fieldvalue
- The new attribute valueSet the values of this Feature based on values from another Feature
f
- The other Feature whose values we wantSet the values of this Feature based on values from a Map
attributes
- A Map of valuesSet the Feature's Geometry
geom
- The new GeometryThe string representation
Groovy Documentation