A Schema describes the structure of a Feature. It is contains a name, and a set of Fields.
You can create a Schema from a name and a List of Fields
Schema s1 = new Schema("widgets", [new Field("geom","Point"), new Field("name","string"), new Field("price","float")])
You can create a Schema from a name and a List of Lists which contain a name and type
Schema s2 = new Schema("widgets", [["geom","Point"], ["name","string"], ["price","float"]])
You can create a Schema from a name and a List of Maps containing name, type, and optionally proj keys
Schema s3 = new Schema("widgets", [[name: "geom",type: "Point"], [name: "name", type: "string"], [name: "price", type: "float"]])
You can create a Schema from a name and a type spec:
Schema s4 = new Schema("widgets","geom:Point:srid=4326,name:String,price:float")
Type | Name and description |
---|---|
SimpleFeatureType |
featureType The wrapped GeoTools SimpleFeatureType |
Constructor and description |
---|
Schema
(SimpleFeatureType featureType) Create a new Schema wrapping a GeoTools SimpleFeatureType |
Schema
(java.lang.String name, java.lang.String typeSpec, java.lang.String uri = "http://geoscript.org/feature") Create a new Schema with a name and a String containing a comma delimited list of fields. |
Schema
(java.lang.String name, java.lang.Object fields, java.lang.String uri = "http://geoscript.org/feature") Create a new Schema with a name and a List of Fields. |
Type Params | Return Type | Name and description |
---|---|---|
|
Schema |
addField(Field field, java.lang.String name) Create a new Schema with a new name by adding a Field to the current Schema |
|
Schema |
addFields(java.util.List<Field> newFields, java.lang.String name) Create a new Schema with a new name by adding a List of Fields to the current Schema |
|
Map |
addSchema(Map options = [:], Schema otherSchema, java.lang.String newName) Create a new Schema by adding another Schema to this current Schema. |
|
Schema |
changeField(Field oldField, Field newField, java.lang.String name) Create a new Schema by changing an existing Field's definition. |
|
Schema |
changeFields(java.util.Map<Field, Field> fieldsToChange, java.lang.String name) Create a new Schema by changing one or more Field's definition. |
|
Schema |
changeGeometryType(java.lang.String geometryType, java.lang.String name) Create a new Schema with the same fields as this Schema but with a different Geometry type |
|
boolean |
equals(java.lang.Object obj) |
|
Feature |
feature() Create a Feature from this Schema with default values |
|
Feature |
feature(Feature f) Create a Feature from an existing Feature |
|
Feature |
feature(java.util.List values, java.lang.String id = SimpleFeatureBuilder.createDefaultFeatureId() Create a Feature from this Schema with a List of values and the id. |
|
Feature |
feature(Map values, java.lang.String id = SimpleFeatureBuilder.createDefaultFeatureId() Create a Feature from this Schema with a Map of values and the id. |
|
Field |
field(java.lang.String name) Get a Field by name |
|
Field |
get(java.lang.String name) Get a Field by name |
|
java.util.List<Field> |
getFields() Get the List of Fields |
|
Field |
getGeom() Get the Schema's geometry Field or null if none exists |
|
java.lang.String |
getName() Get the Schema's name |
|
Projection |
getProj() Get the Schema's Projection or null if one doesn't exist |
|
java.lang.String |
getSpec() Get the spec string |
|
java.lang.String |
getUri() Get the namespace uri of this Schema |
|
boolean |
has(java.lang.Object field) Whether this Schema contains a Field by the given name or not |
|
int |
hashCode() |
|
Schema |
includeFields(java.util.List fieldsToInclude, java.lang.String name) Create a new Schema with only a subset of Fields |
|
static boolean |
isValidFieldType(java.lang.String type) |
|
static java.lang.String |
lookUpAlias(java.lang.String binding) Look up the alias of a GeoTools binding. |
|
static java.lang.String |
lookUpBinding(java.lang.String alias) Look up a GeoTools binding for the alias. |
|
Schema |
removeField(Field field, java.lang.String name) Create a new Schema with a new name by removing a Field from the current Schema |
|
Schema |
removeFields(java.util.List<Field> fieldsToRemove, java.lang.String name) Create a new Schema with a new name by removing a List of Fields from the current Schema |
|
Schema |
reproject(java.lang.Object prj) Reproject the Schema. |
|
Schema |
reproject(java.lang.Object prj, java.lang.String name) Reproject the schema with a new name |
|
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 SimpleFeatureType
Create a new Schema wrapping a GeoTools SimpleFeatureType
The
- wrapped GeoTools SimpleFeatureTypeCreate a new Schema with a name and a String containing a comma delimited list of fields.
Schema s = new Schema("widgets","geom:Point:srid=4326,name:String,price:float")
name
- The Schema nametypeSpec
- The Schema String.uri
- The namespace uriCreate a new Schema with a name and a List of Fields.
Schema s1 = new Schema("widgets", [new Field("geom","Point"), new Field("name","string"), new Field("price","float")])
Schema s2 = new Schema("widgets", [["geom","Point"], ["name","string"], ["price","float"]])
Schema s3 = new Schema("widgets", [[name: "geom",type: "Point"], [name: "name", type: "string"], [name: "price", type: "float"]])
name
- The Schema's namefields
- A List of Fields, a List of Lists, or a List of Mapsuri
- The namespace uriCreate a new Schema with a new name by adding a Field to the current Schema
field
- The Field to addname
- The name of the new SchemaCreate a new Schema with a new name by adding a List of Fields to the current Schema
fields
- The List of Fields to addname
- The name of the new SchemaCreate a new Schema by adding another Schema to this current Schema. The Geometry Field is taken from the current Schema.
otherSchema
- The other SchemanewName
- The new Schema's nameoptions
- A Map of optional parameters:
Create a new Schema by changing an existing Field's definition.
oldField
- The old existing FieldnewField
- The new Field definitionname
- The new Schema nameCreate a new Schema by changing one or more Field's definition.
fieldsToChange
- A Map of old existing Fields as keys and new Fields as valuesname
- The new Schema nameCreate a new Schema with the same fields as this Schema but with a different Geometry type
geometryType
- The new type of Geometryname
- The new Schema nameCreate a Feature from this Schema with default values
Create a Feature from an existing Feature
f
- The exiting FeatureCreate a Feature from this Schema with a List of values and the id.
The
- List of valuesid
- The Feature ID (defaults to feature)Create a Feature from this Schema with a Map of values and the id.
The
- Map of key value pairsid
- The Feature ID (defaults to feature)Get a Field by name
name
- The name of the FieldGet a Field by name
The
- name of the FieldGet the List of Fields
Get the Schema's geometry Field or null if none exists
Get the Schema's name
Get the Schema's Projection or null if one doesn't exist
Get the spec string
Get the namespace uri of this Schema
Whether this Schema contains a Field by the given name or not
field
- The Field or Field nameCreate a new Schema with only a subset of Fields
fieldsToInclude
- A List of Fields or Field names to includename
- The new nameLook up the alias of a GeoTools binding. For example: "org.locationtech.jts.geom.LinearRing" => "LinearRing"
The
- Class nameLook up a GeoTools binding for the alias. For example: "geoscript.geom.LinearRing" => "org.locationtech.jts.geom.LinearRing"
alias
- The aliasCreate a new Schema with a new name by removing a Field from the current Schema
field
- The Field to removename
- The name of the new SchemaCreate a new Schema with a new name by removing a List of Fields from the current Schema
fieldsToRemove
- The List of Fields to removename
- The name of the new SchemaReproject the Schema.
prj
- A Projection or a StringReproject the schema with a new name
prj
- A Projection or a Stringname
- The new name of the reprojected SchemaThe string representation
Groovy Documentation