GeoStyler WFS Parser is an npm package that provides a robust implementation of a GeoStyler Data Parser specifically designed for interacting with Web Feature Services (WFS). Currently at stable version 3.0.1, the library sees active development with recent releases, including major updates in July 2024. Its primary function is to read and interpret data from WFS endpoints, converting it into a GeoStyler-compatible data structure for further styling and manipulation within the GeoStyler ecosystem. A key differentiator is its tight integration into the GeoStyler project, offering a standardized approach to WFS data consumption. Users should note that for successful operation, the target WFS service must support `application/json` as an output format, and its application server needs to be configured to send CORS headers if the WFS service is hosted on a different origin than the consuming application. The package ships with TypeScript types, facilitating robust development.
npm install geostyler-wfs-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the WfsParser and use its `read` method to fetch and parse data from a WFS service, logging the resulting GeoStyler-compatible data object. It highlights the use of `requestParams` and the necessity of `application/json` output.
Migrate your project to use ES modules (`import ... from '...'`) instead of CommonJS `require()`. Adjust your bundler configuration to correctly resolve ESM dependencies.
Update calls to the `read` method. Instead of `parser.read(url, version, typeName)`, use `parser.read(url, { requestParams: { version, typeName } })`.Ensure your WFS service is configured to provide JSON output. If not, the parser will fail to interpret the response. You might need to adjust the `outputFormat` in `requestParams` if the service supports other JSON variants.
If encountering network errors related to cross-origin access, contact the administrator of the WFS service to ensure it has CORS enabled for your client's origin. Alternatively, consider proxying the WFS requests through your own backend.
Change `const WfsParser = require('geostyler-wfs-parser');` to `import { WfsParser } from 'geostyler-wfs-parser';`. Ensure your project's `package.json` has `"type": "module"` or that your build system is configured for ESM.Refactor your `read` method call. Instead of `parser.read(url, { version: '1.1.0' })`, use `parser.read(url, { requestParams: { version: '1.1.0' } })`.Verify that the WFS service's server is configured to include `Access-Control-Allow-Origin` headers that permit requests from your application's origin. Alternatively, use a proxy server to forward requests.
Ensure the `outputFormat` in your `requestParams` is correctly set to `application/json` and that the WFS service truly supports this format. Check the network tab in your browser's developer tools for the actual response from the WFS server.
No dependency data recorded yet.