ogcopenapis 0.0.3 → 0.0.4

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.
@@ -5,11 +5,11 @@ 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
7
  import { CoordinateReference } from '@luciad/ria/reference/CoordinateReference';
8
- interface OAPIFeatureStoreConstructorOptions {
8
+ export interface OgcOpenApiFeatureStoreConstructorOptions {
9
9
  dataUrl: string;
10
10
  featureUrl?: string;
11
11
  outputFormat: string;
12
- useCrs84Bounds: boolean;
12
+ useCrs84Bounds?: boolean;
13
13
  codec: Codec;
14
14
  requestHeaders?: {
15
15
  [key: string]: string;
@@ -22,7 +22,7 @@ interface OAPIFeatureStoreConstructorOptions {
22
22
  };
23
23
  reference: CoordinateReference;
24
24
  }
25
- interface OAPIFeatureStoreQueryOptions {
25
+ export interface OgcOpenApiFeatureStoreQueryOptions {
26
26
  f?: string;
27
27
  limit?: number;
28
28
  offset?: number;
@@ -57,7 +57,7 @@ interface OAPIFeatureStoreQueryOptions {
57
57
  wkhrCode?: string;
58
58
  wkhrRemark?: string;
59
59
  }
60
- interface OgcOpenApiCodecDecodeOptions extends CodecDecodeOptions {
60
+ interface OgcOpenApiFeaturesCodecDecodeOptions extends CodecDecodeOptions {
61
61
  contentCrs?: string;
62
62
  contentLength?: number;
63
63
  }
@@ -74,13 +74,13 @@ export declare class OgcOpenApiFeatureStore implements Store, Evented {
74
74
  private outputFormat;
75
75
  private useCrs84Bounds;
76
76
  private featureUrl;
77
- constructor(options: OAPIFeatureStoreConstructorOptions);
77
+ constructor(options: OgcOpenApiFeatureStoreConstructorOptions);
78
78
  on(event: string, callback: any, context: any, options: any): Handle;
79
79
  get(id: number | string, optionsInput?: any): Promise<Feature>;
80
- query(receivedQuery?: OAPIFeatureStoreQueryOptions, options?: any): Cursor | Promise<Cursor>;
81
- spatialQuery(bounds?: Bounds, receivedQuery?: OAPIFeatureStoreQueryOptions, options?: any): Promise<Cursor> | Cursor;
80
+ query(receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Cursor | Promise<Cursor>;
81
+ spatialQuery(bounds?: Bounds, receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Promise<Cursor> | Cursor;
82
82
  private static getCRS84BoundingBox;
83
83
  private static cleanUrl;
84
84
  private static dataFormatInQuery;
85
85
  }
86
- export { OgcOpenApiCodecDecodeOptions };
86
+ export { OgcOpenApiFeaturesCodecDecodeOptions };
@@ -2,6 +2,9 @@ import { EventedSupport } from '@luciad/ria/util/EventedSupport';
2
2
  import { createBounds } from '@luciad/ria/shape/ShapeFactory';
3
3
  import { getReference } from "@luciad/ria/reference/ReferenceProvider";
4
4
  import { createTransformation } from "@luciad/ria/transformation/TransformationFactory";
5
+ import { OgcOpenApiCrsTools } from "./OgcOpenApiCrsTools";
6
+ import { GeoJsonCodec } from "@luciad/ria/model/codec/GeoJsonCodec";
7
+ import { GMLCodec } from "@luciad/ria/model/codec/GMLCodec";
5
8
  export class OgcOpenApiFeatureStore {
6
9
  constructor(options) {
7
10
  // console.log(options);
@@ -67,7 +70,7 @@ export class OgcOpenApiFeatureStore {
67
70
  if (response.status === 200) {
68
71
  response.text().then((content) => {
69
72
  let contentType = response.headers.get('Content-Type');
70
- const contentCrs = response.headers.get('content-crs');
73
+ const contentCrs = response.headers.get('content-crs') ? response.headers.get('content-crs') : this.customCrs;
71
74
  const contentLengthStr = response.headers.get('Content-Length');
72
75
  const contentLength = Number(contentLengthStr);
73
76
  contentType = contentType ? contentType : 'text/plain';
@@ -127,7 +130,7 @@ export class OgcOpenApiFeatureStore {
127
130
  if (response.status === 200) {
128
131
  response.text().then((content) => {
129
132
  let contentType = response.headers.get('Content-Type');
130
- const contentCrs = response.headers.get('content-crs');
133
+ const contentCrs = response.headers.get('content-crs') ? response.headers.get('content-crs') : this.customCrs;
131
134
  const contentLengthStr = response.headers.get('Content-Length');
132
135
  const contentLength = Number(contentLengthStr);
133
136
  contentType = contentType ? contentType : 'text/plain';
@@ -137,8 +140,14 @@ export class OgcOpenApiFeatureStore {
137
140
  const codecOptions = {
138
141
  content, contentType, contentCrs, contentLength
139
142
  };
140
- const cursor = this.codec.decode(codecOptions);
141
- resolve(cursor);
143
+ if (this.codec instanceof GeoJsonCodec || this.codec instanceof GMLCodec) {
144
+ const cursor = this.codec.decode(Object.assign(Object.assign({}, codecOptions), { reference: getReference(OgcOpenApiCrsTools.getReferenceName(contentCrs)) }));
145
+ resolve(cursor);
146
+ }
147
+ else {
148
+ const cursor = this.codec.decode(codecOptions);
149
+ resolve(cursor);
150
+ }
142
151
  });
143
152
  }
144
153
  });
@@ -18,6 +18,8 @@ class OgcOpenApiFetchTools {
18
18
  return fetch(result.url, result.fetchOptions);
19
19
  }
20
20
  static addHostURL(url, HostUrl) {
21
+ if (typeof url === "undefined")
22
+ return url;
21
23
  const hostUrl = HostUrl ? HostUrl : "";
22
24
  if (url.startsWith("http://") || url.startsWith("https://")) {
23
25
  return url;
@@ -98,10 +98,7 @@ export declare class OgcOpenApiGetCapabilities {
98
98
  requestHeaders?: RequestHeaders;
99
99
  }): Promise<TileSetData[]>;
100
100
  static getQuadTreeCompatibleLevelOffset(tileMatrixSet: TileSetData): number;
101
- static fetchTileSets(capabilities: OgcOpenApiCapabilitiesObject | null, options?: {
102
- credentials?: boolean;
103
- requestHeaders?: RequestHeaders;
104
- }): Promise<TileSetMeta[]>;
101
+ private static fetchTileSets;
105
102
  static getTilesLink(capabilities: OgcOpenApiCapabilitiesObject | null, currentCollection: OgcOpenApiCapabilitiesCollection, tileMatrixId: string, options?: {
106
103
  credentials?: boolean;
107
104
  requestHeaders?: RequestHeaders;
@@ -64,12 +64,13 @@ export class OgcOpenApiGetCapabilities {
64
64
  const layer = Object.assign({ description: collection.description, id: name, name, title: collection.title, keywords: collection.keywords
65
65
  ? collection.keywords
66
66
  : [], defaultReference: 'CRS:84', links: collection.links, outputFormats: options.filterCollectionsByLinkType ?
67
- this.filterCollectionLinks(collection.links, options.filterCollectionsByLinkType).map(link => this.detectTypeFormat(link)) :
68
- collection.links.map(link => this.detectTypeFormat(link)), extent: collection.extent }, collectionCrsObject);
67
+ this.filterCollectionLinks(collection.links, options.filterCollectionsByLinkType).map(link => this.detectTypeFormat(link))
68
+ :
69
+ collection.links.map(link => this.detectTypeFormat(link)), extent: collection.extent }, collectionCrsObject);
69
70
  return layer;
70
71
  });
71
72
  // console.log(featureTypes);
72
- const o = Object.assign(Object.assign({ name: '', collections: foundCollections, version: responseOpenApi ? responseOpenApi.openapi : '', service: '', info: responseOpenApi ? responseOpenApi.info : {} }, crsArray), { serverOptions: serverOptions, baseUrl });
73
+ const o = Object.assign(Object.assign({ name: '', collections: foundCollections.map(col => (Object.assign(Object.assign({}, col), { crs: col.crs ? col.crs : [], links: col.links.map(l => (Object.assign(Object.assign({}, l), { href: serverOptions.complete(l.href) }))) }))), version: responseOpenApi ? responseOpenApi.openapi : '', service: '', info: responseOpenApi ? responseOpenApi.info : {} }, crsArray), { serverOptions: serverOptions, baseUrl });
73
74
  resolve(o);
74
75
  });
75
76
  }
@@ -183,7 +184,7 @@ export class OgcOpenApiGetCapabilities {
183
184
  if (result.status === 200) {
184
185
  result.json().then((data) => {
185
186
  if (data.tileMatrixSets) {
186
- resolve(data.tileMatrixSets);
187
+ resolve(data.tileMatrixSets.map(tml => (Object.assign(Object.assign({}, tml), { href: capabilities.serverOptions.complete(tml.href) }))));
187
188
  }
188
189
  else {
189
190
  reject({ error: true, message: "tileMatrixSets not defined" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ogcopenapis",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Implements OGC OPEN API Features/Maps/Tiles capabilities and models for LuciadRIA",
5
5
  "files": [
6
6
  "lib/"