@itwin/map-layers-formats 5.0.0-dev.8 → 5.0.0-dev.82
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/CHANGELOG.md +46 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js +43 -40
- package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js +17 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js +2 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js +3 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js +1 -0
- package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js +37 -32
- package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/cjs/ArcGisFeature/EsriSymbology.js +26 -5
- package/lib/cjs/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js +48 -72
- package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
- package/lib/cjs/Feature/FeatureCanvasRenderer.js +2 -0
- package/lib/cjs/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/cjs/Feature/FeatureInfoReader.js +20 -20
- package/lib/cjs/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/cjs/Feature/RandomMapColor.js +10 -10
- package/lib/cjs/Feature/RandomMapColor.js.map +1 -1
- package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js +1 -0
- package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts +36 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js +83 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts +166 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.js +56 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts +10 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js +20 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts +25 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +232 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -0
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js +41 -34
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js +1 -0
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.d.ts +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.d.ts.map +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.js +10 -6
- package/lib/cjs/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js +56 -52
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoTool.js +13 -16
- package/lib/cjs/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.d.ts +38 -0
- package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -0
- package/lib/cjs/internal/GoogleMapsUtils.js +104 -0
- package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -0
- package/lib/cjs/map-layers-formats.d.ts +1 -0
- package/lib/cjs/map-layers-formats.d.ts.map +1 -1
- package/lib/cjs/map-layers-formats.js +1 -0
- package/lib/cjs/map-layers-formats.js.map +1 -1
- package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
- package/lib/cjs/mapLayersFormats.js +4 -1
- package/lib/cjs/mapLayersFormats.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js +43 -40
- package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js +17 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js +2 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js +3 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js +1 -0
- package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js +37 -32
- package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/esm/ArcGisFeature/EsriSymbology.js +26 -5
- package/lib/esm/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/esm/ArcGisFeature/esriPBuffer.gen.js +48 -72
- package/lib/esm/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
- package/lib/esm/Feature/FeatureCanvasRenderer.js +2 -0
- package/lib/esm/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/esm/Feature/FeatureInfoReader.js +20 -20
- package/lib/esm/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/esm/Feature/RandomMapColor.js +10 -10
- package/lib/esm/Feature/RandomMapColor.js.map +1 -1
- package/lib/esm/GeoJSON/GeoJSONGeometryReader.js +1 -0
- package/lib/esm/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts +36 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js +78 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts +166 -0
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMaps.js +53 -0
- package/lib/esm/GoogleMaps/GoogleMaps.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts +10 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js +16 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts +25 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +228 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -0
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js +41 -34
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js +1 -0
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.d.ts +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.d.ts.map +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.js +10 -6
- package/lib/esm/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.js +56 -52
- package/lib/esm/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoTool.js +13 -16
- package/lib/esm/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.d.ts +38 -0
- package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -0
- package/lib/esm/internal/GoogleMapsUtils.js +101 -0
- package/lib/esm/internal/GoogleMapsUtils.js.map +1 -0
- package/lib/esm/map-layers-formats.d.ts +1 -0
- package/lib/esm/map-layers-formats.d.ts.map +1 -1
- package/lib/esm/map-layers-formats.js +1 -0
- package/lib/esm/map-layers-formats.js.map +1 -1
- package/lib/esm/mapLayersFormats.d.ts.map +1 -1
- package/lib/esm/mapLayersFormats.js +4 -1
- package/lib/esm/mapLayersFormats.js.map +1 -1
- package/lib/public/images/google_on_non_white.png +0 -0
- package/lib/public/images/google_on_non_white_hdpi.png +0 -0
- package/lib/public/images/google_on_white.png +0 -0
- package/lib/public/images/google_on_white_hdpi.png +0 -0
- package/package.json +21 -25
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAgC,uBAAuB,EAAwB,wBAAwB,EAAW,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAC7L,OAAO,EAAoG,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAenJ,qBAAa,yBAA0B,SAAQ,uBAAuB;IAEpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAM;gBACX,QAAQ,EAAE,qBAAqB;WAI7B,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB;cAI7D,aAAa,IAAK,OAAO,CAAC,iBAAiB,GAAC,SAAS,CAAC;IAYtE,IAAoB,QAAQ,IAAI,MAAM,CAA2B;IAE3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BjD,OAAO,CAAC,0BAA0B;IAoCrB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAWxE,iBAAiB;YAqCjB,YAAY;IASJ,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IA0ChG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxD,OAAO,CAAC,gBAAgB;IAIF,eAAe,CAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBnG"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module MapLayersFormats
|
|
7
|
+
*/
|
|
8
|
+
import { IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapTile } from "@itwin/core-frontend";
|
|
9
|
+
import { BentleyError, BentleyStatus, Logger } from "@itwin/core-bentley";
|
|
10
|
+
import { GoogleMapsDecorator } from "./GoogleMapDecorator";
|
|
11
|
+
import { GoogleMapsUtils } from "../internal/GoogleMapsUtils";
|
|
12
|
+
const loggerCategory = "MapLayersFormats.GoogleMaps";
|
|
13
|
+
const levelToken = "{level}";
|
|
14
|
+
const rowToken = "{row}";
|
|
15
|
+
const columnToken = "{column}";
|
|
16
|
+
const urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;
|
|
17
|
+
/*
|
|
18
|
+
* Google Maps imagery provider
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export class GoogleMapsImageryProvider extends MapLayerImageryProvider {
|
|
22
|
+
_decorator;
|
|
23
|
+
_hadUnrecoverableError = false;
|
|
24
|
+
_tileSize = 256;
|
|
25
|
+
constructor(settings) {
|
|
26
|
+
super(settings, true);
|
|
27
|
+
this._decorator = new GoogleMapsDecorator();
|
|
28
|
+
}
|
|
29
|
+
static validateUrlTemplate(template) {
|
|
30
|
+
return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl };
|
|
31
|
+
}
|
|
32
|
+
async createSession() {
|
|
33
|
+
const sessionOptions = this.createCreateSessionOptions();
|
|
34
|
+
if (this._settings.accessKey) {
|
|
35
|
+
// Create session and store in query parameters
|
|
36
|
+
const sessionObj = await GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);
|
|
37
|
+
this._settings.unsavedQueryParams = { session: sessionObj.session };
|
|
38
|
+
return sessionObj;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
Logger.logError(loggerCategory, `Missing GoogleMaps api key`);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
get tileSize() { return this._tileSize; }
|
|
46
|
+
async initialize() {
|
|
47
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
48
|
+
if (layerPropertyKeys === undefined ||
|
|
49
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
50
|
+
!layerPropertyKeys.includes("language") ||
|
|
51
|
+
!layerPropertyKeys.includes("region")) {
|
|
52
|
+
const msg = "Missing session options";
|
|
53
|
+
Logger.logError(loggerCategory, msg);
|
|
54
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
55
|
+
}
|
|
56
|
+
const session = await this.createSession();
|
|
57
|
+
if (!session) {
|
|
58
|
+
const msg = `Failed to create session`;
|
|
59
|
+
Logger.logError(loggerCategory, msg);
|
|
60
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
61
|
+
}
|
|
62
|
+
this._tileSize = session.tileWidth; // assuming here tiles are square
|
|
63
|
+
const isActivated = await this._decorator.activate(this._settings.properties.mapType);
|
|
64
|
+
if (!isActivated) {
|
|
65
|
+
const msg = `Failed to activate decorator`;
|
|
66
|
+
Logger.logError(loggerCategory, msg);
|
|
67
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
createCreateSessionOptions() {
|
|
71
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
72
|
+
if (layerPropertyKeys === undefined ||
|
|
73
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
74
|
+
!layerPropertyKeys.includes("language") ||
|
|
75
|
+
!layerPropertyKeys.includes("region")) {
|
|
76
|
+
const msg = "Missing session options";
|
|
77
|
+
Logger.logError(loggerCategory, msg);
|
|
78
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
79
|
+
}
|
|
80
|
+
const createSessionOptions = {
|
|
81
|
+
mapType: this._settings.properties.mapType,
|
|
82
|
+
region: this._settings.properties.region,
|
|
83
|
+
language: this._settings.properties.language,
|
|
84
|
+
};
|
|
85
|
+
if (this._settings.properties?.layerTypes !== undefined) {
|
|
86
|
+
createSessionOptions.layerTypes = this._settings.properties.layerTypes;
|
|
87
|
+
}
|
|
88
|
+
if (this._settings.properties?.scale !== undefined) {
|
|
89
|
+
createSessionOptions.scale = this._settings.properties.scale;
|
|
90
|
+
}
|
|
91
|
+
if (this._settings.properties?.overlay !== undefined) {
|
|
92
|
+
createSessionOptions.overlay = this._settings.properties.overlay;
|
|
93
|
+
}
|
|
94
|
+
if (this._settings.properties?.apiOptions !== undefined) {
|
|
95
|
+
createSessionOptions.apiOptions = this._settings.properties.apiOptions;
|
|
96
|
+
}
|
|
97
|
+
return createSessionOptions;
|
|
98
|
+
}
|
|
99
|
+
// construct the Url from the desired Tile
|
|
100
|
+
async constructUrl(row, column, level) {
|
|
101
|
+
const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());
|
|
102
|
+
const obj = new URL(tmpUrl);
|
|
103
|
+
if (this._settings.accessKey) {
|
|
104
|
+
obj.searchParams.append("key", this._settings.accessKey.value);
|
|
105
|
+
}
|
|
106
|
+
// We assume the 'session' param to be already part of the query parameters (checked in initialize)
|
|
107
|
+
return this.appendCustomParams(obj.toString());
|
|
108
|
+
}
|
|
109
|
+
async fetchAttributions(tiles) {
|
|
110
|
+
const zooms = new Set();
|
|
111
|
+
const matchingAttributions = [];
|
|
112
|
+
// Viewport info requests must be made for a specific zoom level
|
|
113
|
+
tiles.forEach((tile) => zooms.add(tile.depth));
|
|
114
|
+
for (const zoom of zooms) {
|
|
115
|
+
let cartoRect;
|
|
116
|
+
for (const tile of tiles) {
|
|
117
|
+
if (tile.depth === zoom && tile instanceof MapTile) {
|
|
118
|
+
const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);
|
|
119
|
+
const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop);
|
|
120
|
+
if (cartoRect)
|
|
121
|
+
cartoRect.union(rect);
|
|
122
|
+
else
|
|
123
|
+
cartoRect = rect;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (cartoRect) {
|
|
127
|
+
try {
|
|
128
|
+
const viewportInfo = await GoogleMapsUtils.getViewportInfo({
|
|
129
|
+
rectangle: cartoRect,
|
|
130
|
+
session: this._settings.collectQueryParams().session,
|
|
131
|
+
key: this._settings.accessKey.value,
|
|
132
|
+
zoom
|
|
133
|
+
});
|
|
134
|
+
if (viewportInfo?.copyright) {
|
|
135
|
+
matchingAttributions.push(viewportInfo.copyright);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message ?? "Unknown error"}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return matchingAttributions;
|
|
144
|
+
}
|
|
145
|
+
async logJsonError(tileResponse) {
|
|
146
|
+
try {
|
|
147
|
+
const error = await tileResponse.json();
|
|
148
|
+
Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async loadTile(row, column, zoomLevel) {
|
|
155
|
+
if (this._hadUnrecoverableError)
|
|
156
|
+
return undefined;
|
|
157
|
+
try {
|
|
158
|
+
let tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
159
|
+
let tileResponse = await this.makeTileRequest(tileUrl);
|
|
160
|
+
if (!tileResponse.ok) {
|
|
161
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
162
|
+
// Session might have expired, lets try to re-new it.
|
|
163
|
+
const isSessionCreated = await this.createSession();
|
|
164
|
+
if (isSessionCreated) {
|
|
165
|
+
tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
166
|
+
tileResponse = await this.makeTileRequest(tileUrl);
|
|
167
|
+
if (!tileResponse.ok) {
|
|
168
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
169
|
+
await this.logJsonError(tileResponse);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
173
|
+
}
|
|
174
|
+
this._hadUnrecoverableError = true; // Prevent from doing more invalid requests
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
await this.logJsonError(tileResponse);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return await this.getImageFromTileResponse(tileResponse, zoomLevel);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (error?.code === 401) {
|
|
191
|
+
Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
decorate(context) {
|
|
200
|
+
this._decorator.decorate(context);
|
|
201
|
+
}
|
|
202
|
+
getSelectedTiles(vp) {
|
|
203
|
+
return IModelApp.tileAdmin.getTilesForUser(vp)?.selected;
|
|
204
|
+
}
|
|
205
|
+
async addAttributions(cards, vp) {
|
|
206
|
+
let copyrightMsg = "";
|
|
207
|
+
const tiles = this.getSelectedTiles(vp);
|
|
208
|
+
if (tiles) {
|
|
209
|
+
try {
|
|
210
|
+
const attrList = await this.fetchAttributions(tiles);
|
|
211
|
+
for (const attr of attrList) {
|
|
212
|
+
attr.split(",").forEach((line) => {
|
|
213
|
+
copyrightMsg += `${copyrightMsg.length === 0 ? "" : "<br"}${line}`;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message ?? "Unknown error"}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
cards.appendChild(IModelApp.makeLogoCard({
|
|
222
|
+
iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,
|
|
223
|
+
heading: "Google Maps",
|
|
224
|
+
notice: copyrightMsg
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=GoogleMapsImageryProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAmB,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAoB,EAA4B,OAAO,EAAwB,MAAM,sBAAsB,CAAC;AAE7L,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,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AC;QACnB,CAAC;IACH,CAAC;IAEe,QAAQ,CAAC,OAAwB;QAC/C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEO,gBAAgB,CAAC,EAAkB;QACzC,OAAO,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAA;IAC1D,CAAC;IAEe,KAAK,CAAC,eAAe,CAAE,KAAuB,EAAE,EAAkB;QAChF,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACrD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,YAAY,IAAI,GAAG,YAAY,CAAC,MAAM,KAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession } from \"./GoogleMaps\";\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils\";\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\nconst levelToken = \"{level}\";\nconst rowToken = \"{row}\";\nconst columnToken = \"{column}\";\n\nconst urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;\n\n/*\n* Google Maps imagery provider\n* @internal\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256\n constructor(settings: ImageMapLayerSettings) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n }\n public static validateUrlTemplate(template: string): MapLayerSourceValidation {\n return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl };\n }\n\n protected async createSession() : Promise<GoogleMapsSession|undefined> {\n const sessionOptions = this.createCreateSessionOptions();\n if (this._settings.accessKey ) {\n // Create session and store in query parameters\n const sessionObj = await GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);\n this._settings.unsavedQueryParams = {session: sessionObj.session};\n return sessionObj;\n } else {\n Logger.logError(loggerCategory, `Missing GoogleMaps api key`);\n return undefined;\n }\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const session = await this.createSession();\n if (!session) {\n const msg = `Failed to create session`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n this._tileSize = session.tileWidth; // assuming here tiles are square\n\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n private createCreateSessionOptions(): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: this._settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (this._settings.properties?.layerTypes !== undefined) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // construct the Url from the desired Tile\n public async constructUrl(row: number, column: number, level: number): Promise<string> {\n const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());\n const obj = new URL(tmpUrl);\n if (this._settings.accessKey ) {\n obj.searchParams.append(\"key\", this._settings.accessKey.value);\n }\n\n // We assume the 'session' param to be already part of the query parameters (checked in initialize)\n return this.appendCustomParams(obj.toString());\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect) {\n try {\n const viewportInfo = await GoogleMapsUtils.getViewportInfo({\n rectangle: cartoRect,\n session: this._settings.collectQueryParams().session,\n key: this._settings.accessKey!.value,\n zoom});\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n if (this._hadUnrecoverableError)\n return undefined;\n\n try {\n let tileUrl: string = await this.constructUrl(row, column, zoomLevel);\n let tileResponse: Response = await this.makeTileRequest(tileUrl);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n // Session might have expired, lets try to re-new it.\n const isSessionCreated = await this.createSession();\n if (isSessionCreated) {\n tileUrl = await this.constructUrl(row, column, zoomLevel);\n tileResponse = await this.makeTileRequest(tileUrl);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n } else {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { appendQueryParams, ImageryMapLayerFormat, MapLayerSourceStatus, setBasi
|
|
|
2
2
|
import { OgcApiFeaturesProvider } from "./OgcApiFeaturesProvider";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {
|
|
5
|
+
static formatId = "OgcApiFeatures";
|
|
5
6
|
static createImageryProvider(settings) { return new OgcApiFeaturesProvider(settings); }
|
|
6
7
|
static async validate(args) {
|
|
7
8
|
const { source } = args;
|
|
@@ -86,5 +87,4 @@ export class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
|
-
OgcApiFeaturesMapLayerFormat.formatId = "OgcApiFeatures";
|
|
90
90
|
//# sourceMappingURL=OgcApiFeaturesFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAA2B,oBAAoB,EAA4B,qBAAqB,EAAsB,MAAM,sBAAsB,CAAC;AACpM,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,gBAAgB;AAChB,MAAM,OAAO,4BAA6B,SAAQ,qBAAqB;
|
|
1
|
+
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAA2B,oBAAoB,EAA4B,qBAAqB,EAAsB,MAAM,sBAAsB,CAAC;AACpM,OAAO,E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C;gBACtC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAS,EAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC;gBACrH,IAAI,cAAc,GAAG,iBAAiB,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBACtF,cAAc,GAAG,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC;gBAC9E,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;gBAC7C,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;oBACpC,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBACxC,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC;gBACtC,CAAC;YAEH,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAE/B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,GAAG,oBAAoB,CAAC,UAAU,CAAC;YACzC,IAAI,GAAG,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YACjH,CAAC;YACD,OAAO,EAAE,MAAM,EAAC,CAAC;QACnB,CAAC;IACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ImageMapLayerSettings, MapSubLayerProps } from \"@itwin/core-common\";\nimport { appendQueryParams, ImageryMapLayerFormat, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, setBasicAuthorization, ValidateSourceArgs } from \"@itwin/core-frontend\";\nimport { OgcApiFeaturesProvider } from \"./OgcApiFeaturesProvider\";\n\n/** @internal */\nexport class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {\n public static override formatId = \"OgcApiFeatures\";\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined { return new OgcApiFeaturesProvider(settings); }\n\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\n\n const {source} = args;\n const { userName, password } = source;\n let status = MapLayerSourceStatus.InvalidUrl;\n try {\n\n let headers: Headers | undefined;\n if (userName && password) {\n headers = new Headers();\n setBasicAuthorization(headers, userName, password);\n }\n const opts: RequestInit = {\n method: \"GET\",\n headers,\n };\n\n let url = appendQueryParams(source.url, source.savedQueryParams);\n url = appendQueryParams(url, source.unsavedQueryParams);\n let response = await fetch(url, opts);\n let json = await response.json();\n if (!json) {\n return { status };\n }\n\n const createCollectionsList = (data: any) => {\n let array: MapSubLayerProps[] | undefined;\n for (const collection of data.collections) {\n if (collection.itemType === \"feature\") {\n const subLayerProps = {\n id: collection.id,\n name: collection.id,\n title: collection.title,\n visible: true,\n parent: undefined,\n children: undefined,\n };\n if (array)\n array.push(subLayerProps);\n else\n array = [subLayerProps];\n }\n }\n return array;\n };\n\n let subLayers: MapSubLayerProps[] | undefined;\n if (Array.isArray(json.collections)) {\n subLayers = createCollectionsList(json);\n status = MapLayerSourceStatus.Valid;\n } else if (json.itemType === \"feature\" || json.type === \"FeatureCollection\") {\n // We expect one of the following URL:\n // http://server/collections/<collectionName>\n // http://server/collections/<collectionName>/items\n subLayers = [{\n id: json.id,\n name: json.id,\n title: json.title,\n visible: true,\n parent: undefined,\n children: undefined,\n }];\n status = MapLayerSourceStatus.Valid;\n } else if (Array.isArray(json.links)) {\n // This might be the main landing page\n const collectionsLink = json.links.find((link: any)=> link.rel.includes(\"data\") && link.type === \"application/json\");\n let collectionsUrl = appendQueryParams(collectionsLink.href, source.savedQueryParams);\n collectionsUrl = appendQueryParams(collectionsUrl, source.unsavedQueryParams);\n response = await fetch(collectionsUrl, opts);\n json = await response.json();\n if (Array.isArray(json.collections)) {\n subLayers = createCollectionsList(json);\n status = MapLayerSourceStatus.Valid;\n }\n\n }\n\n return { status, subLayers };\n\n } catch (err: any) {\n status = MapLayerSourceStatus.InvalidUrl;\n if (err?.status === 401) {\n status = ((userName && password) ? MapLayerSourceStatus.InvalidCredentials : MapLayerSourceStatus.RequireAuth);\n }\n return { status};\n }\n }\n}\n"]}
|
|
@@ -18,8 +18,31 @@ const dataUrlHeaderToken = "base64,";
|
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
20
|
export class DefaultOgcSymbology {
|
|
21
|
+
static _defaultPMSProps = {
|
|
22
|
+
type: "esriPMS",
|
|
23
|
+
url: "",
|
|
24
|
+
width: 16,
|
|
25
|
+
height: 24,
|
|
26
|
+
// We want the anchor point to be the bottom of the push pin, so apply offset on the y-axis (anchor point is already in the center of the icon)
|
|
27
|
+
xoffset: 0,
|
|
28
|
+
yoffset: -12,
|
|
29
|
+
};
|
|
30
|
+
_defaultPMS;
|
|
31
|
+
static _defaultSLSProps = {
|
|
32
|
+
type: "esriSLS",
|
|
33
|
+
color: [0, 0, 255, 255],
|
|
34
|
+
width: 1,
|
|
35
|
+
style: "esriSLSSolid",
|
|
36
|
+
};
|
|
37
|
+
_defaultSLS;
|
|
38
|
+
static _defaultSFSProps = {
|
|
39
|
+
type: "esriSFS",
|
|
40
|
+
color: [0, 0, 255, 255], // blue fill
|
|
41
|
+
style: "esriSFSSolid",
|
|
42
|
+
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
43
|
+
};
|
|
44
|
+
_defaultSFS = EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
21
45
|
constructor(randomColor) {
|
|
22
|
-
this._defaultSFS = EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
23
46
|
const color = randomColor ? randomColor.getColorDef() : ColorDef.blue;
|
|
24
47
|
this._defaultPMS = EsriPMS.fromJSON({
|
|
25
48
|
...DefaultMarkerIcon.getContent(color),
|
|
@@ -59,43 +82,27 @@ export class DefaultOgcSymbology {
|
|
|
59
82
|
throw new Error(`Could not get default symbology for geometry type ${geometryType}`);
|
|
60
83
|
}
|
|
61
84
|
}
|
|
62
|
-
DefaultOgcSymbology._defaultPMSProps = {
|
|
63
|
-
type: "esriPMS",
|
|
64
|
-
url: "",
|
|
65
|
-
width: 16,
|
|
66
|
-
height: 24,
|
|
67
|
-
// We want the anchor point to be the bottom of the push pin, so apply offset on the y-axis (anchor point is already in the center of the icon)
|
|
68
|
-
xoffset: 0,
|
|
69
|
-
yoffset: -12,
|
|
70
|
-
};
|
|
71
|
-
DefaultOgcSymbology._defaultSLSProps = {
|
|
72
|
-
type: "esriSLS",
|
|
73
|
-
color: [0, 0, 255, 255],
|
|
74
|
-
width: 1,
|
|
75
|
-
style: "esriSLSSolid",
|
|
76
|
-
};
|
|
77
|
-
DefaultOgcSymbology._defaultSFSProps = {
|
|
78
|
-
type: "esriSFS",
|
|
79
|
-
color: [0, 0, 255, 255], // blue fill
|
|
80
|
-
style: "esriSFSSolid",
|
|
81
|
-
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
82
|
-
};
|
|
83
85
|
/** @internal */
|
|
84
86
|
export class OgcApiFeaturesProvider extends MapLayerImageryProvider {
|
|
87
|
+
// Debug flags, should always be committed to FALSE !
|
|
88
|
+
_drawDebugInfo = false;
|
|
89
|
+
/// ////////////////////////////
|
|
90
|
+
_limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
91
|
+
_tiledModeMinLod = 14;
|
|
92
|
+
_staticModeFetchTimeout = 10000;
|
|
93
|
+
_tileModeFetchTimeout = 10000;
|
|
94
|
+
_forceTileMode = false;
|
|
95
|
+
_spatialIdx;
|
|
96
|
+
_defaultSymbol = new DefaultOgcSymbology(new RandomMapColor());
|
|
97
|
+
_renderer;
|
|
98
|
+
_collectionUrl = "";
|
|
99
|
+
_itemsUrl = "";
|
|
100
|
+
_itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
101
|
+
_queryables;
|
|
102
|
+
serviceJson;
|
|
103
|
+
_staticData;
|
|
85
104
|
constructor(settings) {
|
|
86
105
|
super(settings, true);
|
|
87
|
-
// Debug flags, should always be committed to FALSE !
|
|
88
|
-
this._drawDebugInfo = false;
|
|
89
|
-
/// ////////////////////////////
|
|
90
|
-
this._limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
91
|
-
this._tiledModeMinLod = 14;
|
|
92
|
-
this._staticModeFetchTimeout = 10000;
|
|
93
|
-
this._tileModeFetchTimeout = 10000;
|
|
94
|
-
this._forceTileMode = false;
|
|
95
|
-
this._defaultSymbol = new DefaultOgcSymbology(new RandomMapColor());
|
|
96
|
-
this._collectionUrl = "";
|
|
97
|
-
this._itemsUrl = "";
|
|
98
|
-
this._itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
99
106
|
}
|
|
100
107
|
get supportsMapFeatureInfo() { return true; }
|
|
101
108
|
get minimumZoomLevel() { return this.staticMode ? super.minimumZoomLevel : this._tiledModeMinLod; }
|