feature.Feature()

class feature.Feature(config)
Arguments
  • config (Object) – Configuration object.

Create a new feature.

Example Use

Sample code to create a new feature:

>> var Feature = require("geoscript/feature").Feature;
>> var Point = require("geoscript/geom").Point;
>> var city = Feature({
..   properties: {
..     location: Point([-110, 45]),
..     name: "Metropolis"
..   }
.. });

>> city.get("name");
Metropolis
>> city.get("location");
<Point [-110, 45]>

Config Properties

schema

feature.Schema() The feature schema. If not provided, a schema will be derived from the provided properties in the configuration.

properties

Object An object with all the feature property names and values.

Properties

Feature.bounds

geom.Bounds() The bounds of the default geometry (if any) for this feature. Will be undefined if the feature has no geometry.

Feature.geometry

geom.Geometry() The default geometry (if any) for the feature. Will be undefined if the feature does not have a geometry.

Feature.geometryName

String Field name for the default geoemtry, or undefined if the feature has no geometry.

Feature.id

String The feature identifier. Read only.

Feature.json

String The JSON representation of the feature (see http://geojson.org).

Feature.projection

proj.Projection() Optional projection for the feature. This corresponds to the projection of the default geometry for the feature.

Feature.schema

feature.Schema() The feature schema (read-only).

Feature.properties

Object An object with all the feature property names and values. Used for property access only. Use set() to set property values.

Methods

Feature.clone()
Returns

feature.Feature()

Create a clone of this feature.

Feature.get()
Arguments
  • nameString Attribute name.

Get an attribute value.

Feature.set()
Arguments
  • nameString Attribute name.

  • valueString Attribute value.

Set a feature attribute.