Coder Social home page Coder Social logo

camptocamp / ogc-client Goto Github PK

View Code? Open in Web Editor NEW
61.0 15.0 7.0 4.97 MB

A TypeScript library for interacting with geospatial services

Home Page: https://camptocamp.github.io/ogc-client/

License: BSD 3-Clause "New" or "Revised" License

JavaScript 1.74% HTML 0.37% Vue 10.62% CSS 0.13% TypeScript 87.14%
typescript ogc ogc-api wfs wms

ogc-client's Introduction

ogc-client Latest version on NPM Latest @dev version on NPM

A Typescript library for interacting with OGC-compliant services

ogc-client is a Typescript library which implements several OGC standards and will help you interact with them in a user-friendly and consistent way.

Documentation and live demo here!

The following standards are partially implemented:

  • WMS - Web Map Service
  • WFS - Web Feature Service
  • WMTS - Web Map Tile Service
  • OGC API (Records and Features)

Why use it?

  1. ogc-client will abstract the service version so you don't have to worry about it
  2. ogc-client will handle XML so you only have to deal with native Javascript objects
  3. ogc-client will hide the complexity of OGC standards behind straightforward APIs
  4. ogc-client will run heavy tasks in a worker to avoid blocking the main thread
  5. ogc-client will keep a persistent cache of operations to minimize requests and processing
  6. ogc-client will tell you if a service is not usable for CORS-related issues

Instructions

To install ogc-client, run:

$ npm install --save @camptocamp/ogc-client

To use, import API symbols like so:

import { WmsEndpoint, WfsEndpoint } from '@camptocamp/ogc-client';

Note: if you want to disable web worker usage, for example to solve issues with the Referer header on outgoing requests, use:

import { enableFallbackWithoutWorker } from '@camptocamp/ogc-client';

enableFallbackWithoutWorker();

All processing will be done on the main thread after this call, including HTTP requests.

Use the latest development version

The @camptocamp/ogc-client NPM package is updated on every commit on the main branch under the @dev tag. To use it:

$ npm install --save @camptocamp/ogc-client@dev

Application

A provided application containing the documentation and demo is located in the app folder. To start it locally, clone the repository and run the following commands:

$ npm install
$ cd app
$ npm install
$ npm start

The app is based on Vue.js and will showcase most features implemented in the library. You will need to supply it with valid OGC service urls.

ogc-client's People

Contributors

angi-kinas avatar cmoinier avatar fgravin avatar jahow avatar jakobmiksch avatar lukaslohoff avatar robquincey-dc avatar ronitjadhav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ogc-client's Issues

Demo app fails with Node 18

when I run the demo app with Node 18 it fails with this error:


> [email protected] serve
> vue-cli-service serve

 INFO  Starting development server...
10% building 2/5 modules 3 active ...ksch/Code/ogc-client/app/node_modules/babel-loader/lib/index.js!/mnt/c/Users/johndoe/Code/ogc-client/app/src/main.js n
ode:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/webpack/lib/NormalModule.js:471:10)
    at /mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/webpack/lib/NormalModule.js:503:5
    at /mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/webpack/lib/NormalModule.js:358:12
    at /mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /mnt/c/Users/johndoe/Code/ogc-client/app/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.16.0

It works with Node 16 for me

Handle the case where the Cache Storage is not reachable.

OGC client internally uses the Browser Cache Storage abilities to cache the requests.

Issue
In some cases, for instance on Firefox in Privacy Mode, we are not allowed to read or write in the cache storage.
It results that the OGC client fails requesting the cache, but still does not perform the original request.

It triggers the following error

Uncaught (in promise) DOMException: **The operation is insecure**.
    4505 https://www.datagrandest.fr/datahub/main.7acf17b8ce68852b.js:133
    r https://www.datagrandest.fr/datahub/runtime.4381662fc90e13c0.js:1
    <anonymous> https://www.datagrandest.fr/datahub/main.7acf17b8ce68852b.js:133
    n https://www.datagrandest.fr/datahub/runtime.4381662fc90e13c0.js:1
    <anonymous> https://www.datagrandest.fr/datahub/main.7acf17b8ce68852b.js:1

Todo
Handle the case where the Cache Storage is not accessible and performs original requests without caching

Support for 'Keywords' in WMS and WFS

Currently, keywords for the service are retrieved from the WMS/WFS capability documents, but keywords added to each layer or featuretype are not included.

I propose adding a keywords property to the layers/featuretypes in the same way it is done at the top level capability document.

Support for WMS GetMap 'Formats'

The WMS spec defines Output Formats for WMS GetMap requests.

OpenGIS Web Map Service (WMS) Implementation Specification
6.6: â€ĻA server may offer multiple map formats. The formats it offers are enumerated in elements in its service
metadata

Currently, there is an outputFormats property on the GenericEndpointInfo type, but this is only filled for WFS Services, not WMS.

I propose filling this outputFormats property with the results of enumerating the GetMap - Format elements in the WMS Capabilities response. This can then be used by consuming applications to decide on an appropriate format to use in GetMap requests.

Vue3 - ReferenceError: exports is not defined

In a Vue3 application using Node 20 I get this error.

Do you a hint what the problem could be?

Uncaught ReferenceError: exports is not defined
    at node_modules/@camptocamp/ogc-client/dist/worker/index.js (index.js:2:23)
    at __init (chunk-GFT2G5UO.js?v=951b9568:15:56)
    at node_modules/@camptocamp/ogc-client/dist/wfs/endpoint.js (endpoint.js:3:16)
    at __require2 (chunk-GFT2G5UO.js?v=951b9568:18:50)
    at node_modules/@camptocamp/ogc-client/dist/index.js (index.js:4:18)
    at __require2 (chunk-GFT2G5UO.js?v=951b9568:18:50)
    at index.js:16:1

or as screenshot of the browser console

image

What is the license of this repository?

Hi,

I looked for a license (LICENSE file or license when searching the documentation), but could not find any information.

Would it be possible to know more about how this code can be used?

Thanks a lot!

`WfsEndpoint.isReady()` throws: Failed to execute 'put' on 'Cache': Entry already exists.

Using this two lines of code:

const endpoint  = new WfsEndpoint(url);
await endpoint.isReady();

I get this exception:
image

Initially it was working fine, but suddenly it started throwing this error.

This is the call causing the exception (I cannot step i further):

export async function storeCacheEntry(object: unknown, ...keys: string[]) {
  const cache = await getCache();
  if (!cache) return;
  const entryUrl = 'https://cache/' + keys.join('/');
  await cache.put(
    entryUrl,
    new Response(JSON.stringify(object), {
      headers: {
        'x-expiry': (Date.now() + getCacheExpiryDuration()).toString(10),
      },
    })
  );
}

Support for `OGC API - Tiles` and `OGC API - Styles`

First of all, thanks for providing this library! So far it looks great, especially the caching is very useful.

Do you have plans for supporting Tiles and Styles? We would like to query styles, style metadata, tile collections and tileMatrixSets.

I noticed that there is already active development for tiles. But we're also willing to contribute if possible, e.g. for styles.

Capabilities: Handle more bbox elements

It seems that the bounding boxes of the layers are only fetched from the BoundingBox element of the layer in the getCapabilities.
eg.

<BoundingBox CRS="EPSG:2056" minx="2.1e+06" miny="105000" maxx="2.85e+06" maxy="1.4e+06"/>

Additionally, it could exist more elements about the layer extent.

  • EX_GeographicBoundingBox
  • ows:WGS84BoundingBox

Those elements are in EPSG:4326 which simplifies the process afterwards, as it's a standard CRS.

eg.

<ows:WGS84BoundingBox>
  <ows:LowerCorner>5.140242 45.398181</ows:LowerCorner>
  <ows:UpperCorner>11.47757 48.230651</ows:UpperCorner>
</ows:WGS84BoundingBox>

<EX_GeographicBoundingBox>
  <westBoundLongitude>0.659866</westBoundLongitude>
  <eastBoundLongitude>10.8359</eastBoundLongitude>
  <southBoundLatitude>36.982</southBoundLatitude>
  <northBoundLatitude>48.7511</northBoundLatitude>
</EX_GeographicBoundingBox>

Add queryable property to WMS layers

WMS layers can have an attribute called 'queryable' which indicates whether the layer can be queried using GetFeatureInfo requests. The spec says this is optional and defaults to 0.

I propose adding a simple boolean property to the WMS model to indicate if the layer is queryable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.