SKalt / geojson-to-wfs-t-2

A lightweight javascript module to format WFS-T-2 statements from GeoJSON features
25 stars 7 forks source link
geojson geoserver gis wfs wfst

geojson-to-wfs-t-2

npm version Build Status

A library to create string Web Feature Service XML from geojson. As a string formatting library, geojson-to-wfst-2 has only one dependency and will work in any environment.

Installation

get the library by executing

npm install geojson-to-wfs-t-2

or

git clone https://github.com/SKalt/geojson-to-wfs-t-2.git

and import/require-ing es6 or transpiled es5 commonjs, UMD, or es modules from geojson-to-wfs-t-2/dist/.

Usage

import wfs from 'geojson-to-wfs-t-2';

const nullIsland = {
  type: 'Feature',
  properties: {place_name: 'null island'},
  geometry: {
    type: 'Point',
    coordinates: [0, 0]
  }
  id: 'feature_id'
}
const params = {geometry_name: 'geom', layer: 'my_lyr', ns: 'my_namespace'};

// create a stringified transaction inserting null island
wfs.Transaction(
  wfs.Insert(nullIsland, params),
  {
    nsAssignments: {
      my_namespace: 'https://example.com/namespace_defn.xsd'
    }
  }
);

// create a stringified transaction updating null island's name
wfs.Transaction(
  wfs.Update({properties: {place_name: 'not Atlantis'}, id: nullIsland.id }),
  {nsAssignments: ...}
)
// same deal, but deleting it
wfs.Transaction(
  wfs.Delete({id: nullIsland.id}, params),
  {nsAssignments: ...}
)

See API.md for the full API documentation.

Further notes:

Contributing

Features, refactors, documentation, and tests are welcome! To contribute, branch or fork this repo, optionally open an issue, and then open a pull request. Please include tests and well-commented commits in all work.

Here's an example script to start developing a feature on this project:

git clone https://github.com/SKalt/geojson-to-wfs-t-2.git # or your fork
cd geojson-to-wfs-t-2
git checkout -b informative-feature-branch
npm install