ogcopenapis 0.0.4 → 0.0.6
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.
- package/lib/OgcOpenApiCrsTools.d.ts +1 -1
- package/lib/OgcOpenApiCrsTools.js +8 -1
- package/lib/OgcOpenApiFeatureStore.d.ts +6 -0
- package/lib/OgcOpenApiFeatureStore.js +10 -4
- package/lib/OgcOpenApiFetchTools.d.ts +2 -4
- package/lib/OgcOpenApiGetCapabilities.d.ts +5 -4
- package/lib/OgcOpenApiMapsModel.d.ts +4 -0
- package/lib/OgcOpenApiMapsModel.js +7 -1
- package/lib/OgcOpenApiTilesModel.d.ts +4 -1
- package/lib/OgcOpenApiTilesModel.js +8 -1
- package/package.json +1 -1
|
@@ -4,7 +4,14 @@ class OgcOpenApiCrsTools {
|
|
|
4
4
|
* @param uriOrName
|
|
5
5
|
* @private
|
|
6
6
|
*/
|
|
7
|
-
static getReferenceName(
|
|
7
|
+
static getReferenceName(uriOrNameI) {
|
|
8
|
+
let uriOrName;
|
|
9
|
+
if (typeof uriOrNameI === "undefined") {
|
|
10
|
+
uriOrName = "http://www.opengis.net/def/crs/OGC/1.3/CRS84";
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
uriOrName = uriOrNameI.replace(/[<>]/g, '');
|
|
14
|
+
}
|
|
8
15
|
if (!uriOrName.startsWith('http')) {
|
|
9
16
|
return uriOrName;
|
|
10
17
|
}
|
|
@@ -5,12 +5,14 @@ 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
|
+
import { ProxifyFunction } from "./OgcOpenApiGetCapabilities";
|
|
8
9
|
export interface OgcOpenApiFeatureStoreConstructorOptions {
|
|
9
10
|
dataUrl: string;
|
|
10
11
|
featureUrl?: string;
|
|
11
12
|
outputFormat: string;
|
|
12
13
|
useCrs84Bounds?: boolean;
|
|
13
14
|
codec: Codec;
|
|
15
|
+
credentials?: boolean;
|
|
14
16
|
requestHeaders?: {
|
|
15
17
|
[key: string]: string;
|
|
16
18
|
};
|
|
@@ -21,6 +23,7 @@ export interface OgcOpenApiFeatureStoreConstructorOptions {
|
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
25
|
reference: CoordinateReference;
|
|
26
|
+
proxify?: ProxifyFunction;
|
|
24
27
|
}
|
|
25
28
|
export interface OgcOpenApiFeatureStoreQueryOptions {
|
|
26
29
|
f?: string;
|
|
@@ -74,6 +77,9 @@ export declare class OgcOpenApiFeatureStore implements Store, Evented {
|
|
|
74
77
|
private outputFormat;
|
|
75
78
|
private useCrs84Bounds;
|
|
76
79
|
private featureUrl;
|
|
80
|
+
private proxy;
|
|
81
|
+
private credentials;
|
|
82
|
+
private serverOptions;
|
|
77
83
|
constructor(options: OgcOpenApiFeatureStoreConstructorOptions);
|
|
78
84
|
on(event: string, callback: any, context: any, options: any): Handle;
|
|
79
85
|
get(id: number | string, optionsInput?: any): Promise<Feature>;
|
|
@@ -5,6 +5,7 @@ import { createTransformation } from "@luciad/ria/transformation/TransformationF
|
|
|
5
5
|
import { OgcOpenApiCrsTools } from "./OgcOpenApiCrsTools";
|
|
6
6
|
import { GeoJsonCodec } from "@luciad/ria/model/codec/GeoJsonCodec";
|
|
7
7
|
import { GMLCodec } from "@luciad/ria/model/codec/GMLCodec";
|
|
8
|
+
import { OgcOpenApiFetchTools } from "./OgcOpenApiFetchTools";
|
|
8
9
|
export class OgcOpenApiFeatureStore {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
// console.log(options);
|
|
@@ -20,6 +21,9 @@ export class OgcOpenApiFeatureStore {
|
|
|
20
21
|
this.eventedSupport = new EventedSupport();
|
|
21
22
|
this.requestHeaders = options.requestHeaders ? options.requestHeaders : {};
|
|
22
23
|
this.reference = options.reference;
|
|
24
|
+
this.proxy = options.proxify;
|
|
25
|
+
this.credentials = options.credentials;
|
|
26
|
+
this.serverOptions = OgcOpenApiFetchTools.createFetchOptions({ originalUrl: this.dataUrl, proxify: options.proxify });
|
|
23
27
|
if (options.extent &&
|
|
24
28
|
options.extent.spatial &&
|
|
25
29
|
options.extent.spatial.bbox &&
|
|
@@ -63,10 +67,11 @@ export class OgcOpenApiFeatureStore {
|
|
|
63
67
|
request += "?" + queryString;
|
|
64
68
|
}
|
|
65
69
|
const headers = Object.assign(Object.assign({}, this.requestHeaders), { Accept: accept });
|
|
66
|
-
fetch(request, {
|
|
70
|
+
OgcOpenApiFetchTools.fetch(request, {
|
|
67
71
|
method: 'GET',
|
|
72
|
+
credentials: this.credentials ? "same-origin" : "omit",
|
|
68
73
|
headers,
|
|
69
|
-
}).then((response) => {
|
|
74
|
+
}, this.serverOptions).then((response) => {
|
|
70
75
|
if (response.status === 200) {
|
|
71
76
|
response.text().then((content) => {
|
|
72
77
|
let contentType = response.headers.get('Content-Type');
|
|
@@ -123,10 +128,11 @@ export class OgcOpenApiFeatureStore {
|
|
|
123
128
|
}
|
|
124
129
|
const headers = Object.assign(Object.assign({}, this.requestHeaders), { Accept: accept });
|
|
125
130
|
// const headers = { ...this.requestHeaders };
|
|
126
|
-
fetch(request, {
|
|
131
|
+
OgcOpenApiFetchTools.fetch(request, {
|
|
127
132
|
method: 'GET',
|
|
133
|
+
credentials: this.credentials ? "same-origin" : "omit",
|
|
128
134
|
headers,
|
|
129
|
-
}).then((response) => {
|
|
135
|
+
}, this.serverOptions).then((response) => {
|
|
130
136
|
if (response.status === 200) {
|
|
131
137
|
response.text().then((content) => {
|
|
132
138
|
let contentType = response.headers.get('Content-Type');
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { ProxifyFunction } from "./OgcOpenApiGetCapabilities";
|
|
1
2
|
interface ExtFetchOptions {
|
|
2
3
|
originalUrl: string;
|
|
3
4
|
complete?: (url: string) => string;
|
|
4
|
-
proxify?:
|
|
5
|
-
url: string;
|
|
6
|
-
fetchOptions: RequestInit;
|
|
7
|
-
};
|
|
5
|
+
proxify?: ProxifyFunction;
|
|
8
6
|
}
|
|
9
7
|
export interface FetchServerOptions {
|
|
10
8
|
proxy: (url: string, fetchOptions: any) => {
|
|
@@ -76,16 +76,17 @@ export declare enum CollectionLinkType {
|
|
|
76
76
|
Map = "map",
|
|
77
77
|
Tiles = "tiles"
|
|
78
78
|
}
|
|
79
|
+
export type ProxifyFunction = (url: string, fetchOptions: RequestInit) => {
|
|
80
|
+
url: string;
|
|
81
|
+
fetchOptions: RequestInit;
|
|
82
|
+
};
|
|
79
83
|
export interface OgcOpenApiGetCapabilitiesFromURL {
|
|
80
84
|
filterCollectionsByLinkType?: CollectionLinkType;
|
|
81
85
|
credentials?: boolean;
|
|
82
86
|
requestHeaders?: {
|
|
83
87
|
[headerName: string]: string;
|
|
84
88
|
} | null;
|
|
85
|
-
proxify?:
|
|
86
|
-
url: string;
|
|
87
|
-
fetchOptions: RequestInit;
|
|
88
|
-
};
|
|
89
|
+
proxify?: ProxifyFunction;
|
|
89
90
|
}
|
|
90
91
|
export declare class OgcOpenApiGetCapabilities {
|
|
91
92
|
static fromURL(inputRequest: string, options?: OgcOpenApiGetCapabilitiesFromURL): Promise<OgcOpenApiCapabilitiesObject>;
|
|
@@ -2,12 +2,14 @@ import { RasterDataType } from "@luciad/ria/model/tileset/RasterDataType";
|
|
|
2
2
|
import { RasterSamplingMode } from "@luciad/ria/model/tileset/RasterSamplingMode";
|
|
3
3
|
import { WMSTileSetModel } from "@luciad/ria/model/tileset/WMSTileSetModel";
|
|
4
4
|
import { TileCoordinate } from "@luciad/ria/model/tileset/TileCoordinate";
|
|
5
|
+
import { ProxifyFunction } from "./OgcOpenApiGetCapabilities";
|
|
5
6
|
interface OgcOpenApiMapsModelConstructorOptions {
|
|
6
7
|
crs: string;
|
|
7
8
|
baseURL: string;
|
|
8
9
|
collection: string;
|
|
9
10
|
dataType?: RasterDataType;
|
|
10
11
|
samplingMode?: RasterSamplingMode;
|
|
12
|
+
credentials?: boolean;
|
|
11
13
|
requestHeaders?: {
|
|
12
14
|
[p: string]: string;
|
|
13
15
|
};
|
|
@@ -17,6 +19,7 @@ interface OgcOpenApiMapsModelConstructorOptions {
|
|
|
17
19
|
subset?: string[];
|
|
18
20
|
transparent?: boolean;
|
|
19
21
|
bgcolor?: string;
|
|
22
|
+
proxify?: ProxifyFunction;
|
|
20
23
|
}
|
|
21
24
|
declare class OgcOpenApiMapsModel extends WMSTileSetModel {
|
|
22
25
|
private format;
|
|
@@ -25,6 +28,7 @@ declare class OgcOpenApiMapsModel extends WMSTileSetModel {
|
|
|
25
28
|
private datetime;
|
|
26
29
|
private subset;
|
|
27
30
|
private bgcolor;
|
|
31
|
+
private proxy;
|
|
28
32
|
constructor(o: OgcOpenApiMapsModelConstructorOptions);
|
|
29
33
|
getTileURL(baseURL: string, tile: TileCoordinate): string | null;
|
|
30
34
|
private static createURLParameters;
|
|
@@ -11,6 +11,7 @@ class OgcOpenApiMapsModel extends WMSTileSetModel {
|
|
|
11
11
|
layers: [o.collection],
|
|
12
12
|
dataType: o.dataType,
|
|
13
13
|
samplingMode: o.samplingMode,
|
|
14
|
+
credentials: o.credentials,
|
|
14
15
|
requestHeaders: o.requestHeaders
|
|
15
16
|
});
|
|
16
17
|
this.crs = o.crs;
|
|
@@ -20,6 +21,7 @@ class OgcOpenApiMapsModel extends WMSTileSetModel {
|
|
|
20
21
|
this.subset = o.subset;
|
|
21
22
|
this.transparent = typeof o.transparent !== "undefined" ? o.transparent : true;
|
|
22
23
|
this.bgcolor = o.bgcolor;
|
|
24
|
+
this.proxy = o.proxify;
|
|
23
25
|
this.modelDescriptor = {
|
|
24
26
|
source: o.baseURL,
|
|
25
27
|
name: o.collection,
|
|
@@ -46,7 +48,11 @@ class OgcOpenApiMapsModel extends WMSTileSetModel {
|
|
|
46
48
|
bgcolor: this.transparent ? undefined : this.bgcolor
|
|
47
49
|
};
|
|
48
50
|
const query = OgcOpenApiMapsModel.createURLParameters(urlParameters);
|
|
49
|
-
|
|
51
|
+
let transformedUrl = url + "?" + query;
|
|
52
|
+
if (typeof this.proxy === "function") {
|
|
53
|
+
const proxyfied = this.proxy(transformedUrl, {});
|
|
54
|
+
transformedUrl = proxyfied.url;
|
|
55
|
+
}
|
|
50
56
|
return transformedUrl;
|
|
51
57
|
}
|
|
52
58
|
else {
|
|
@@ -2,18 +2,20 @@ import { UrlTileSetModel } from "@luciad/ria/model/tileset/UrlTileSetModel";
|
|
|
2
2
|
import { RasterDataType } from "@luciad/ria/model/tileset/RasterDataType";
|
|
3
3
|
import { RasterSamplingMode } from "@luciad/ria/model/tileset/RasterSamplingMode";
|
|
4
4
|
import { TileCoordinate } from "@luciad/ria/model/tileset/TileCoordinate";
|
|
5
|
-
import { TileSetData } from "./OgcOpenApiGetCapabilities";
|
|
5
|
+
import { ProxifyFunction, TileSetData } from "./OgcOpenApiGetCapabilities";
|
|
6
6
|
export interface OgcOpenApiTilesModelOptions {
|
|
7
7
|
tileMatrix: TileSetData;
|
|
8
8
|
baseURL: string;
|
|
9
9
|
collection: string;
|
|
10
10
|
dataType?: RasterDataType;
|
|
11
11
|
samplingMode?: RasterSamplingMode;
|
|
12
|
+
credentials?: boolean;
|
|
12
13
|
requestHeaders?: {
|
|
13
14
|
[p: string]: string;
|
|
14
15
|
};
|
|
15
16
|
transparent?: boolean;
|
|
16
17
|
bgcolor?: string;
|
|
18
|
+
proxify?: ProxifyFunction;
|
|
17
19
|
}
|
|
18
20
|
export declare class OgcOpenApiTilesModel extends UrlTileSetModel {
|
|
19
21
|
private tileMatrix;
|
|
@@ -21,6 +23,7 @@ export declare class OgcOpenApiTilesModel extends UrlTileSetModel {
|
|
|
21
23
|
private plevel0Rows;
|
|
22
24
|
private transparent;
|
|
23
25
|
private bgcolor;
|
|
26
|
+
private proxy;
|
|
24
27
|
constructor(options: OgcOpenApiTilesModelOptions);
|
|
25
28
|
getTileURL(baseURL: string, tile: TileCoordinate): string | null;
|
|
26
29
|
debugAsImage(tileCorrected: TileCoordinate): string;
|
|
@@ -61,6 +61,7 @@ export class OgcOpenApiTilesModel extends UrlTileSetModel {
|
|
|
61
61
|
level0Rows,
|
|
62
62
|
dataType: options.dataType,
|
|
63
63
|
samplingMode: options.samplingMode,
|
|
64
|
+
credentials: options.credentials,
|
|
64
65
|
requestHeaders: options.requestHeaders ? options.requestHeaders : {},
|
|
65
66
|
};
|
|
66
67
|
super(o);
|
|
@@ -69,6 +70,7 @@ export class OgcOpenApiTilesModel extends UrlTileSetModel {
|
|
|
69
70
|
this.bgcolor = options.bgcolor;
|
|
70
71
|
this.invertY = invertY;
|
|
71
72
|
this.tileMatrix = options.tileMatrix;
|
|
73
|
+
this.proxy = options.proxify;
|
|
72
74
|
this.modelDescriptor = {
|
|
73
75
|
source: options.baseURL,
|
|
74
76
|
name: options.collection,
|
|
@@ -89,7 +91,12 @@ export class OgcOpenApiTilesModel extends UrlTileSetModel {
|
|
|
89
91
|
};
|
|
90
92
|
const query = OgcOpenApiTilesModel.createURLParameters(urlParameters);
|
|
91
93
|
const targetUrl = baseURL.replace("{tileMatrix}", level).replace("{tileRow}", tileCorrected.y.toString()).replace("{tileCol}", tileCorrected.x.toString());
|
|
92
|
-
|
|
94
|
+
let tileUrl = targetUrl + (query && query !== "") ? targetUrl + "?" + query : targetUrl;
|
|
95
|
+
if (typeof this.proxy === "function") {
|
|
96
|
+
const proxyfied = this.proxy(tileUrl, {});
|
|
97
|
+
tileUrl = proxyfied.url;
|
|
98
|
+
}
|
|
99
|
+
return tileUrl;
|
|
93
100
|
}
|
|
94
101
|
debugAsImage(tileCorrected) {
|
|
95
102
|
const canvas = document.createElement('canvas');
|