ogcopenapis 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,9 @@ import { Feature } from '@luciad/ria/model/feature/Feature';
4
4
  import { Evented, Handle } from '@luciad/ria/util/Evented';
5
5
  import { Bounds } from '@luciad/ria/shape/Bounds';
6
6
  import { Codec, CodecDecodeOptions } from '@luciad/ria/model/codec/Codec';
7
- import { CoordinateReference } from '@luciad/ria/reference/CoordinateReference';
8
7
  import { ProxifyFunction } from "./OgcOpenApiGetCapabilities";
9
8
  export interface OgcOpenApiFeatureStoreConstructorOptions {
9
+ swapAxes?: string[];
10
10
  dataUrl: string;
11
11
  featureUrl?: string;
12
12
  outputFormat: string;
@@ -16,13 +16,12 @@ export interface OgcOpenApiFeatureStoreConstructorOptions {
16
16
  requestHeaders?: {
17
17
  [key: string]: string;
18
18
  };
19
- customCrs: string;
20
19
  extent?: {
21
20
  spatial: {
22
21
  bbox: any[];
23
22
  };
24
23
  };
25
- reference: CoordinateReference;
24
+ crs: string;
26
25
  proxify?: ProxifyFunction;
27
26
  }
28
27
  export interface OgcOpenApiFeatureStoreQueryOptions {
@@ -80,12 +79,14 @@ export declare class OgcOpenApiFeatureStore implements Store, Evented {
80
79
  private proxy;
81
80
  private credentials;
82
81
  private serverOptions;
82
+ private swapAxes;
83
83
  constructor(options: OgcOpenApiFeatureStoreConstructorOptions);
84
84
  on(event: string, callback: any, context: any, options: any): Handle;
85
85
  get(id: number | string, optionsInput?: any): Promise<Feature>;
86
86
  query(receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Cursor | Promise<Cursor>;
87
87
  spatialQuery(bounds?: Bounds, receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Promise<Cursor> | Cursor;
88
88
  private static getCRS84BoundingBox;
89
+ private static targetBounds;
89
90
  private static cleanUrl;
90
91
  private static dataFormatInQuery;
91
92
  }
@@ -9,6 +9,7 @@ import { OgcOpenApiFetchTools } from "./OgcOpenApiFetchTools";
9
9
  export class OgcOpenApiFeatureStore {
10
10
  constructor(options) {
11
11
  // console.log(options);
12
+ this.swapAxes = options.swapAxes;
12
13
  this.useCrs84Bounds = typeof options.useCrs84Bounds !== "undefined" ? options.useCrs84Bounds : false;
13
14
  this.dataUrl = options.dataUrl;
14
15
  this.outputFormat = options.outputFormat;
@@ -16,11 +17,12 @@ export class OgcOpenApiFeatureStore {
16
17
  this.featureUrl = options.featureUrl ? OgcOpenApiFeatureStore.cleanUrl(options.featureUrl) : OgcOpenApiFeatureStore.cleanUrl(predictedFeatureUrl);
17
18
  this.baseUrl = OgcOpenApiFeatureStore.cleanUrl(this.dataUrl);
18
19
  this.dataFormat = OgcOpenApiFeatureStore.dataFormatInQuery(this.dataUrl);
19
- this.customCrs = options.customCrs;
20
+ this.customCrs = options.crs === "http://www.opengis.net/def/crs/OGC/1.3/CRS84" ? undefined : options.crs;
20
21
  this.codec = options.codec;
21
22
  this.eventedSupport = new EventedSupport();
22
23
  this.requestHeaders = options.requestHeaders ? options.requestHeaders : {};
23
- this.reference = options.reference;
24
+ const referenceName = OgcOpenApiCrsTools.getReferenceName(options.crs);
25
+ this.reference = getReference(referenceName);
24
26
  this.proxy = options.proxify;
25
27
  this.credentials = options.credentials;
26
28
  this.serverOptions = OgcOpenApiFetchTools.createFetchOptions({ originalUrl: this.dataUrl, proxify: options.proxify });
@@ -29,13 +31,14 @@ export class OgcOpenApiFeatureStore {
29
31
  options.extent.spatial.bbox &&
30
32
  options.extent.spatial.bbox.length > 0) {
31
33
  const bbox = options.extent.spatial.bbox[0];
32
- // console.log(options.extent.spatial);
33
- this.bounds = createBounds(this.reference, [
34
+ const WGS84 = getReference("CRS:84");
35
+ const tmpBounds = createBounds(WGS84, [
34
36
  bbox[0],
35
37
  bbox[2] - bbox[0],
36
38
  bbox[1],
37
39
  bbox[3] - bbox[1],
38
40
  ]);
41
+ this.bounds = OgcOpenApiFeatureStore.targetBounds(tmpBounds, this.reference);
39
42
  }
40
43
  }
41
44
  on(event, callback, context, options) {
@@ -85,8 +88,14 @@ export class OgcOpenApiFeatureStore {
85
88
  const codecOptions = {
86
89
  content, contentType, contentCrs, contentLength
87
90
  };
88
- const cursor = this.codec.decode(codecOptions);
89
- if (cursor.hasNext()) {
91
+ let cursor = null;
92
+ if (this.codec instanceof GeoJsonCodec || this.codec instanceof GMLCodec) {
93
+ cursor = this.codec.decode(Object.assign(Object.assign({}, codecOptions), { reference: getReference(OgcOpenApiCrsTools.getReferenceName(contentCrs)) }));
94
+ }
95
+ else {
96
+ cursor = this.codec.decode(codecOptions);
97
+ }
98
+ if (cursor && cursor.hasNext()) {
90
99
  const feaure = cursor.next();
91
100
  resolve(feaure);
92
101
  }
@@ -187,6 +196,10 @@ export class OgcOpenApiFeatureStore {
187
196
  if (this.customCrs) {
188
197
  query["bbox-crs"] = this.customCrs;
189
198
  }
199
+ const referenceName = OgcOpenApiCrsTools.getReferenceName(this.customCrs);
200
+ if (this.swapAxes && this.swapAxes.findIndex(f => f === referenceName) > -1) {
201
+ query.bbox = [query.bbox[1], query.bbox[0], query.bbox[3], query.bbox[2]];
202
+ }
190
203
  }
191
204
  }
192
205
  return this.query(query, options);
@@ -198,6 +211,12 @@ export class OgcOpenApiFeatureStore {
198
211
  const newBounds = toWgs84.transformBounds(bounds);
199
212
  return newBounds;
200
213
  }
214
+ static targetBounds(bounds, targetReferenceBounds) {
215
+ const WGS84 = getReference("CRS:84");
216
+ const toTargetReference = createTransformation(WGS84, targetReferenceBounds);
217
+ const newBounds = toTargetReference.transformBounds(bounds);
218
+ return newBounds;
219
+ }
201
220
  static cleanUrl(dataUrl) {
202
221
  const parts = dataUrl.split('?');
203
222
  const cleanUrl = parts[0].endsWith('/') ? parts[0] : parts[0] + '/';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ogcopenapis",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Implements OGC OPEN API Features/Maps/Tiles capabilities and models for LuciadRIA",
5
5
  "files": [
6
6
  "lib/"