Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@geo-xml/wfs-t-2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@geo-xml/wfs-t-2
A library to create string Web Feature Service XML from geojson. As a string formatting library, @geo-xml/wfs-t-2 has only one dependency and will work in any environment.
Installation
pnpm
pnpm add @geo-xml/wfs-t-2npm
npm install @geo-xml/wfs-t-2yarn
yarn add @geo-xml/wfs-t-2Usage
import { test, expect } from 'vitest';
import { insert, transaction } from '@geo-xml/wfs-t-2';
import { point, geometry } from 'geojson-to-gml-3';
import { Feature, Point } from 'geojson';
const nsUri = 'http://example.com/myFeature' as const;
test('empty transaction', () => {
const actual = transaction([], { srsName: 'EPSG:4326' })();
// prettier-ignore
expect(actual).toBe(''
+ `<wfs:Transaction service="WFS" srsName="EPSG:4326" version="2.0.2" xmlns:wfs="http://www.opengis.net/wfs/2.0"/>`
);
});
const f: Feature<Point, { a: number }> & { lyr: { id: string } } = {
type: 'Feature',
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { a: 1 },
lyr: { id: 'myLayer' },
};
test('use a specific geojson-to-gml converter', () => {
const actual = transaction([insert(f, { nsUri, convertGeom: point })])();
// prettier-ignore
expect(actual).toBe(''
+ `<wfs:Transaction service="WFS" version="2.0.2" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:myFeature="http://example.com/myFeature" xmlns:wfs="http://www.opengis.net/wfs/2.0">`
+ `<wfs:Insert>`
+ `<myFeature:myFeature>`
+ `<myFeature:geometry>`
+ `<gml:Point>`
+ `<gml:pos>`
+ `0 0`
+ `</gml:pos>`
+ `</gml:Point>`
+ `</myFeature:geometry>`
+ `<myFeature:a>`
+ `1`
+ `</myFeature:a>`
+ `</myFeature:myFeature>`
+ `</wfs:Insert>`
+ `</wfs:Transaction>`
);
});
test('when in doubt, use the default geojson-to-gml converter', () => {
const actual = transaction([insert(f, { nsUri, convertGeom: geometry })])();
// prettier-ignore
expect(actual).toBe(''
+ `<wfs:Transaction service="WFS" version="2.0.2" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:myFeature="http://example.com/myFeature" xmlns:wfs="http://www.opengis.net/wfs/2.0">`
+ `<wfs:Insert>`
+ `<myFeature:myFeature>`
+ `<myFeature:geometry>`
+ `<gml:Point>`
+ `<gml:pos>`
+ `0 0`
+ `</gml:pos>`
+ `</gml:Point>`
+ `</myFeature:geometry>`
+ `<myFeature:a>`
+ `1`
+ `</myFeature:a>`
+ `</myFeature:myFeature>`
+ `</wfs:Insert>`
+ `</wfs:Transaction>`
);
});Further notes:
to avoid conflicting with the
deletekeyword, the function to create awfs:Deleteisdelete_.While you should make sure to secure permissions to your data elsewhere (such as the geoserver layer-level permissions), avoiding importing potentially-dangerous actions
updateordelete_is a good idea.