Giter Club home page Giter Club logo

ogc-client's Introduction

ogc-client

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.

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:

$ 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 fgravin avatar jahow avatar jakobmiksch 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

Watchers

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

ogc-client's Issues

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

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

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!

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>

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

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.