Skip to content

Latest commit

 

History

History
449 lines (329 loc) · 17.8 KB

API.md

File metadata and controls

449 lines (329 loc) · 17.8 KB

Modules

ensure

common checks, coersions, and informative errors/ warnings

geojsonToWfst

A library of functions to turn geojson into WFS transactions.

utils

Common utilities for handling parameters for creation of WFS trasactions.

xml

xml utilities.

Functions

filter(filter, features, params)String

Builds a filter from feature ids if one is not already input.

Typedefs

Params : Object

An object containing optional named parameters.

TransactionParams : Object

An object containing optional named parameters for a transaction in addition to parameters used elsewhere.

Feature : Object

A GeoJSON feature with the following optional foreign members (see rfc7965 § 6). or an object with some of the following members. Members of Feature will be used over those in Params except for layer, id, and properties.

FeatureCollection : Object

a GeoJSON FeatureCollection with optional foreign members as in Feature.

ensure

common checks, coersions, and informative errors/ warnings

ensure.id(lyr, id) ⇒ String

Ensures a layer.id format of an input id.

Kind: static method of ensure
Returns: String - a correctly-formatted gml:id

Param Type Description
lyr String layer name
id String id, possibly already in correct layer.id format.

ensure.typeName(ns, layer, typeName) ⇒ String

return a correctly-formatted typeName

Kind: static method of ensure
Returns: String - a correctly-formatted typeName
Throws:

  • Error if typeName it cannot form a typeName from ns and layer
Param Type Description
ns String namespace
layer String layer name
typeName String typeName to check

ensure~allowedActions(action) ⇒ Boolean

Checks the type of the input action

Kind: inner method of ensure
Returns: Boolean - whether the action is allowed

Param Type
action String

geojsonToWfst

A library of functions to turn geojson into WFS transactions.

geojsonToWfst.Insert(features, params) ⇒ string

Returns a wfs:Insert tag wrapping a translated feature

Kind: static method of geojsonToWfst
Returns: string - a wfs:Insert string.
See: translateFeatures

Param Type Description
features Array.<Feature> | FeatureCollection | Feature Feature(s) to pass to
params Params to be passed to @see translateFeatures, with optional inputFormat, srsName, handle for the wfs:Insert tag.

geojsonToWfst.Update(features, params) ⇒ string

Updates the input features in bulk with params.properties or by id.

Kind: static method of geojsonToWfst
Returns: string - a string wfs:Upate action.

Param Type Description
features Array.<Feature> | FeatureCollection features to update. These may pass in geometry_name, properties, and layer (overruled by params) and ns, layer, srsName (overruling params).
params Params with optional properties, ns (namespace), layer, geometry_name, filter, typeName, whitelist.

geojsonToWfst.Delete(features, params) ⇒ string

Creates a wfs:Delete action, creating a filter and typeName from feature ids if none are supplied.

Kind: static method of geojsonToWfst
Returns: string - a wfs:Delete string.

Param Type Description
features Array.<Feature> | FeatureCollection | Feature
params Params optional parameter overrides.
[params.ns] string @see Params.ns
[params.layer] string | Object @see Params.layer
[params.typeName] string @see Params.typeName. This will be inferred from feature/params layer and ns if this is left undefined.
[params.filter] filter @see Params.filter. This will be inferred from feature ids and layer(s) if left undefined (@see ensureFilter).

geojsonToWfst.Replace(features, params) ⇒ string

Returns a string wfs:Replace action.

Kind: static method of geojsonToWfst
Returns: string - a string wfs:Replace action.

Param Type Description
features Array.<Feature> | FeatureCollection | Feature feature(s) to replace
params Params with optional filter, inputFormat, srsName

geojsonToWfst.Transaction(actions, params) ⇒ string

Wraps the input actions in a wfs:Transaction.

Kind: static method of geojsonToWfst
Returns: string - A wfs:transaction wrapping the input actions.
Throws:

  • Error if actions is not an array of strings, a string, or {@see Insert, @see Update, @see Delete}, where each action are valid inputs to the eponymous function.
Param Type Description
actions Object | Array.<string> | string an object mapping {Insert, Update, Delete} to feature(s) to pass to Insert, Update, Delete, or wfs:action string(s) to wrap in a transaction.
params TransactionParams optional srsName, lockId, releaseAction, handle, inputFormat, version, and required nsAssignments, schemaLocations.

utils

Common utilities for handling parameters for creation of WFS trasactions.

utils.useWhitelistIfAvailable(whitelist, properties, cb)

Iterates over the key-value pairs, filtering by a whitelist if available.

Kind: static method of utils

Param Type Description
whitelist Array.<String> a whitelist of property names
properties Object an object mapping property names to values
cb function a function to call on each (whitelisted key, value) pair

utils.unpack(feature, params, args) ⇒ Object

Resolves attributes from feature, then params unless they are normally found in the feature

Kind: static method of utils
Returns: Object - an object mapping each named parameter to its resolved value

Param Type Description
feature Object a geojson feature
params Object an object of backup / override parameters
args Array.<String> parameter names to resolve from feature or params

utils.generateNsAssignments(nsAssignments, xml) ⇒ Object

Generates an object to be passed to @see xml.attrs xmlns:ns="uri" definitions for a wfs:Transaction

Kind: static method of utils
Returns: Object - an object mapping each ns to its URI as 'xmlns:ns' : 'URI'.
Throws:

  • Error if any namespace used within xml is missing a URI definition
Param Type Description
nsAssignments Object @see Params.nsAssignments
xml String arbitrary xml.

utils.generateSchemaLines(schemaLocations) ⇒ string

Returns a string alternating uri, whitespace, and the uri's schema's location.

Kind: static method of utils
Returns: string - a string that is a valid xsi:schemaLocation value.

Param Type Description
schemaLocations Object an object mapping uri:schemalocation

utils.translateFeatures(features, params) ⇒ String

Turns an array of geojson features into gml:_feature strings describing them.

Kind: static method of utils
Returns: String - a gml:_feature string.

Param Type Description
features Array.<Feature> an array of features to translate to gml:_features.
params Params an object of backup / override parameters

xml

xml utilities.

xml.wfs ⇒ String

Shorthand for creating a wfs xml tag.

Kind: static constant of xml
Returns: String - a wfs element.

Param Type Description
tagName String a valid wfs tag name.
attrsObj Object @see xml.attrs.
inner String @see xml.tag.

xml.attrs(attrs) ⇒ String

Turns an object into a string of xml attribute key-value pairs.

Kind: static method of xml
Returns: String - a string of xml attribute key-value pairs

Param Type Description
attrs Object an object mapping attribute names to attribute values

xml.tag(ns, tagName, attrsObj, inner) ⇒ String

Creates a string xml tag.

Kind: static method of xml
Returns: String - an xml string.

Param Type Description
ns String the tag's xml namespace abbreviation.
tagName String the tag name.
attrsObj Object @see xml.attrs.
inner String inner xml.

xml.idFilter(lyr, id) ⇒ String

Creates a fes:ResourceId filter from a layername and id

Kind: static method of xml
Returns: String - a filter-ecoding of the filter.

Param Type Description
lyr String layer name of the filtered feature
id String feature id

xml.escape(input) ⇒ String

Creates an xml-safe string from a given input string

Kind: static method of xml
Returns: String - XML-safe string

Param Type Description
input String String to escape

filter(filter, features, params) ⇒ String

Builds a filter from feature ids if one is not already input.

Kind: global function
Returns: String - A filter, or the input filter if it was a string.

Param Type Description
filter String a possible string filter
features Array.<Object> an array of geojson feature objects
params Object an object of backup / override parameters

Params : Object

An object containing optional named parameters.

Kind: global typedef
Properties

Name Type Description
ns string an xml namespace alias.
layer string | Object a string layer name or {id}, where id is the layer name
geometry_name string the name of the feature geometry field.
properties Object an object mapping feature field names to feature properties
id string a string feature id.
whitelist Array.<string> an array of string field names to use from @see Params.properties
inputFormat string inputFormat, as specified at OGC 09-025r2 § 7.6.5.4.
srsName string srsName, as specified at OGC 09-025r2 § 7.6.5.5. if undefined, the gml3 module will default to 'EPSG:4326'.
handle string handle parameter, as specified at OGC 09-025r2 § 7.6.2.6
filter string a string fes:Filter.
typeName string a string specifying the feature type within its namespace. See 09-025r2 § 7.9.2.4.1.
schemaLocations Object an object mapping uri to schema locations
nsAssignments Object an object mapping ns to uri

TransactionParams : Object

An object containing optional named parameters for a transaction in addition to parameters used elsewhere.

Kind: global typedef
Extends: Params
Properties

Name Type Description
lockId string lockId parameter, as specified at OGC 09-025r2 § 15.2.3.1.2.
releaseAction string releaseAction parameter, as specified at OGC 09-025r2 § 15.2.3.2.

Feature : Object

A GeoJSON feature with the following optional foreign members (see rfc7965 § 6). or an object with some of the following members. Members of Feature will be used over those in Params except for layer, id, and properties.

Kind: global typedef
Extends: Params
Properties

Name Type Description
geometry Object a GeoJSON geometry.
type string 'Feature'.

Example

{'id':'tasmania_roads.1', 'typeName':'topp:tasmania_roadsType'}
// can be passed to Delete

FeatureCollection : Object

a GeoJSON FeatureCollection with optional foreign members as in Feature.

Kind: global typedef
Extends: Feature
Properties

Name Type Description
type string 'FeatureCollection'.
features Array.<Feature> an array of GeoJSON Features.