ogcopenapis 0.0.6 → 0.0.7
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.
|
@@ -7,6 +7,7 @@ import { Codec, CodecDecodeOptions } from '@luciad/ria/model/codec/Codec';
|
|
|
7
7
|
import { CoordinateReference } from '@luciad/ria/reference/CoordinateReference';
|
|
8
8
|
import { ProxifyFunction } from "./OgcOpenApiGetCapabilities";
|
|
9
9
|
export interface OgcOpenApiFeatureStoreConstructorOptions {
|
|
10
|
+
swapAxes?: string[];
|
|
10
11
|
dataUrl: string;
|
|
11
12
|
featureUrl?: string;
|
|
12
13
|
outputFormat: string;
|
|
@@ -16,13 +17,13 @@ export interface OgcOpenApiFeatureStoreConstructorOptions {
|
|
|
16
17
|
requestHeaders?: {
|
|
17
18
|
[key: string]: string;
|
|
18
19
|
};
|
|
19
|
-
customCrs: string;
|
|
20
20
|
extent?: {
|
|
21
21
|
spatial: {
|
|
22
22
|
bbox: any[];
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
reference: CoordinateReference;
|
|
26
|
+
crs: string;
|
|
26
27
|
proxify?: ProxifyFunction;
|
|
27
28
|
}
|
|
28
29
|
export interface OgcOpenApiFeatureStoreQueryOptions {
|
|
@@ -80,12 +81,14 @@ export declare class OgcOpenApiFeatureStore implements Store, Evented {
|
|
|
80
81
|
private proxy;
|
|
81
82
|
private credentials;
|
|
82
83
|
private serverOptions;
|
|
84
|
+
private swapAxes;
|
|
83
85
|
constructor(options: OgcOpenApiFeatureStoreConstructorOptions);
|
|
84
86
|
on(event: string, callback: any, context: any, options: any): Handle;
|
|
85
87
|
get(id: number | string, optionsInput?: any): Promise<Feature>;
|
|
86
88
|
query(receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Cursor | Promise<Cursor>;
|
|
87
89
|
spatialQuery(bounds?: Bounds, receivedQuery?: OgcOpenApiFeatureStoreQueryOptions, options?: any): Promise<Cursor> | Cursor;
|
|
88
90
|
private static getCRS84BoundingBox;
|
|
91
|
+
private static targetBounds;
|
|
89
92
|
private static cleanUrl;
|
|
90
93
|
private static dataFormatInQuery;
|
|
91
94
|
}
|
|
@@ -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,7 +17,7 @@ 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.
|
|
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 : {};
|
|
@@ -29,13 +30,14 @@ export class OgcOpenApiFeatureStore {
|
|
|
29
30
|
options.extent.spatial.bbox &&
|
|
30
31
|
options.extent.spatial.bbox.length > 0) {
|
|
31
32
|
const bbox = options.extent.spatial.bbox[0];
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const WGS84 = getReference("CRS:84");
|
|
34
|
+
const tmpBounds = createBounds(WGS84, [
|
|
34
35
|
bbox[0],
|
|
35
36
|
bbox[2] - bbox[0],
|
|
36
37
|
bbox[1],
|
|
37
38
|
bbox[3] - bbox[1],
|
|
38
39
|
]);
|
|
40
|
+
this.bounds = OgcOpenApiFeatureStore.targetBounds(tmpBounds, this.reference);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
on(event, callback, context, options) {
|
|
@@ -85,8 +87,14 @@ export class OgcOpenApiFeatureStore {
|
|
|
85
87
|
const codecOptions = {
|
|
86
88
|
content, contentType, contentCrs, contentLength
|
|
87
89
|
};
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
+
let cursor = null;
|
|
91
|
+
if (this.codec instanceof GeoJsonCodec || this.codec instanceof GMLCodec) {
|
|
92
|
+
cursor = this.codec.decode(Object.assign(Object.assign({}, codecOptions), { reference: getReference(OgcOpenApiCrsTools.getReferenceName(contentCrs)) }));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
cursor = this.codec.decode(codecOptions);
|
|
96
|
+
}
|
|
97
|
+
if (cursor && cursor.hasNext()) {
|
|
90
98
|
const feaure = cursor.next();
|
|
91
99
|
resolve(feaure);
|
|
92
100
|
}
|
|
@@ -187,6 +195,10 @@ export class OgcOpenApiFeatureStore {
|
|
|
187
195
|
if (this.customCrs) {
|
|
188
196
|
query["bbox-crs"] = this.customCrs;
|
|
189
197
|
}
|
|
198
|
+
const referenceName = OgcOpenApiCrsTools.getReferenceName(this.customCrs);
|
|
199
|
+
if (this.swapAxes && this.swapAxes.findIndex(f => f === referenceName) > -1) {
|
|
200
|
+
query.bbox = [query.bbox[1], query.bbox[0], query.bbox[3], query.bbox[2]];
|
|
201
|
+
}
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
return this.query(query, options);
|
|
@@ -198,6 +210,12 @@ export class OgcOpenApiFeatureStore {
|
|
|
198
210
|
const newBounds = toWgs84.transformBounds(bounds);
|
|
199
211
|
return newBounds;
|
|
200
212
|
}
|
|
213
|
+
static targetBounds(bounds, targetReferenceBounds) {
|
|
214
|
+
const WGS84 = getReference("CRS:84");
|
|
215
|
+
const toTargetReference = createTransformation(WGS84, targetReferenceBounds);
|
|
216
|
+
const newBounds = toTargetReference.transformBounds(bounds);
|
|
217
|
+
return newBounds;
|
|
218
|
+
}
|
|
201
219
|
static cleanUrl(dataUrl) {
|
|
202
220
|
const parts = dataUrl.split('?');
|
|
203
221
|
const cleanUrl = parts[0].endsWith('/') ? parts[0] : parts[0] + '/';
|