feature.Schema()
¶
-
class
feature.
Schema
(config)¶ - Arguments
config (Object) – Configuration object.
Create a new schema.
Example Use¶
Sample code to create a new schema:
>> var Schema = require("geoscript/feature").Schema;
>> var cities = Schema({
.. name: "cities",
.. fields: [{
.. name: "the_geom",
.. type: "Point",
.. projection: "EPSG:4326"
.. }, {
.. name: "name",
.. type: "String"
.. }]
.. });
>> cities.fields.length
2
>> cities.geometry.name
the_geom
>> cities.get("the_geom").type
Point
>> cities.get("the_geom").projection
<Projection EPSG:4326>
Config Properties¶
-
fields
Array
Field definitions. Each item in the array must be afeature.Field()
object or a valid field config.
-
name
String
The schema name. Default is"feature"
. The schema name typically matches the layer name within a workspace.
Properties¶
-
Schema.
fieldNames
¶ Array
Array of field names.
-
Schema.
fields
¶ Array
Field definitions. Field definitions are objects with at leastname
andtype
properties. Geometry field definitions may have aprojection
property. See thefeature.Field()
documentation for more detail.
-
Schema.
geometry
¶ Object
Default geometry field definition. Will beundefined
if the schema doesn’t include a geometry field.
-
Schema.
name
¶ String
The schema name.
Methods¶
-
Schema.
clone
()¶ - Arguments
config –
Object
- Returns
Create a complete copy of this schema.
-
Schema.
get
()¶ - Arguments
name –
String
A field name.
- Returns
feature.Field()
A field definition.
Get the definition for a named field. Field definitions have at least
name
andtype
properties. Geometry field definitions may have aprojection
property. Returnsundefined
if no field is found with the given name.