@itwin/map-layers-formats 5.0.0-dev.7 → 5.0.0-dev.72
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 +31 -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 +13 -13
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module MapLayersFormats
|
|
3
|
+
*/
|
|
4
|
+
import { ImageMapLayerSettings, ImageSource } from "@itwin/core-common";
|
|
5
|
+
import { DecorateContext, MapLayerImageryProvider, MapLayerSourceValidation, ScreenViewport } from "@itwin/core-frontend";
|
|
6
|
+
import { GoogleMapsSession } from "./GoogleMaps";
|
|
7
|
+
export declare class GoogleMapsImageryProvider extends MapLayerImageryProvider {
|
|
8
|
+
private _decorator;
|
|
9
|
+
private _hadUnrecoverableError;
|
|
10
|
+
private _tileSize;
|
|
11
|
+
constructor(settings: ImageMapLayerSettings);
|
|
12
|
+
static validateUrlTemplate(template: string): MapLayerSourceValidation;
|
|
13
|
+
protected createSession(): Promise<GoogleMapsSession | undefined>;
|
|
14
|
+
get tileSize(): number;
|
|
15
|
+
initialize(): Promise<void>;
|
|
16
|
+
private createCreateSessionOptions;
|
|
17
|
+
constructUrl(row: number, column: number, level: number): Promise<string>;
|
|
18
|
+
private fetchAttributions;
|
|
19
|
+
private logJsonError;
|
|
20
|
+
loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined>;
|
|
21
|
+
decorate(context: DecorateContext): void;
|
|
22
|
+
private getSelectedTiles;
|
|
23
|
+
addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=GoogleMapsImageryProvider.d.ts.map
|
|
@@ -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,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module MapLayersFormats
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GoogleMapsImageryProvider = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const GoogleMapDecorator_1 = require("./GoogleMapDecorator");
|
|
14
|
+
const GoogleMapsUtils_1 = require("../internal/GoogleMapsUtils");
|
|
15
|
+
const loggerCategory = "MapLayersFormats.GoogleMaps";
|
|
16
|
+
const levelToken = "{level}";
|
|
17
|
+
const rowToken = "{row}";
|
|
18
|
+
const columnToken = "{column}";
|
|
19
|
+
const urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;
|
|
20
|
+
/*
|
|
21
|
+
* Google Maps imagery provider
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider {
|
|
25
|
+
_decorator;
|
|
26
|
+
_hadUnrecoverableError = false;
|
|
27
|
+
_tileSize = 256;
|
|
28
|
+
constructor(settings) {
|
|
29
|
+
super(settings, true);
|
|
30
|
+
this._decorator = new GoogleMapDecorator_1.GoogleMapsDecorator();
|
|
31
|
+
}
|
|
32
|
+
static validateUrlTemplate(template) {
|
|
33
|
+
return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? core_frontend_1.MapLayerSourceStatus.Valid : core_frontend_1.MapLayerSourceStatus.InvalidUrl };
|
|
34
|
+
}
|
|
35
|
+
async createSession() {
|
|
36
|
+
const sessionOptions = this.createCreateSessionOptions();
|
|
37
|
+
if (this._settings.accessKey) {
|
|
38
|
+
// Create session and store in query parameters
|
|
39
|
+
const sessionObj = await GoogleMapsUtils_1.GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);
|
|
40
|
+
this._settings.unsavedQueryParams = { session: sessionObj.session };
|
|
41
|
+
return sessionObj;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
core_bentley_1.Logger.logError(loggerCategory, `Missing GoogleMaps api key`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
get tileSize() { return this._tileSize; }
|
|
49
|
+
async initialize() {
|
|
50
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
51
|
+
if (layerPropertyKeys === undefined ||
|
|
52
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
53
|
+
!layerPropertyKeys.includes("language") ||
|
|
54
|
+
!layerPropertyKeys.includes("region")) {
|
|
55
|
+
const msg = "Missing session options";
|
|
56
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
57
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
58
|
+
}
|
|
59
|
+
const session = await this.createSession();
|
|
60
|
+
if (!session) {
|
|
61
|
+
const msg = `Failed to create session`;
|
|
62
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
63
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
64
|
+
}
|
|
65
|
+
this._tileSize = session.tileWidth; // assuming here tiles are square
|
|
66
|
+
const isActivated = await this._decorator.activate(this._settings.properties.mapType);
|
|
67
|
+
if (!isActivated) {
|
|
68
|
+
const msg = `Failed to activate decorator`;
|
|
69
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
70
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
createCreateSessionOptions() {
|
|
74
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
75
|
+
if (layerPropertyKeys === undefined ||
|
|
76
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
77
|
+
!layerPropertyKeys.includes("language") ||
|
|
78
|
+
!layerPropertyKeys.includes("region")) {
|
|
79
|
+
const msg = "Missing session options";
|
|
80
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
81
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
82
|
+
}
|
|
83
|
+
const createSessionOptions = {
|
|
84
|
+
mapType: this._settings.properties.mapType,
|
|
85
|
+
region: this._settings.properties.region,
|
|
86
|
+
language: this._settings.properties.language,
|
|
87
|
+
};
|
|
88
|
+
if (this._settings.properties?.layerTypes !== undefined) {
|
|
89
|
+
createSessionOptions.layerTypes = this._settings.properties.layerTypes;
|
|
90
|
+
}
|
|
91
|
+
if (this._settings.properties?.scale !== undefined) {
|
|
92
|
+
createSessionOptions.scale = this._settings.properties.scale;
|
|
93
|
+
}
|
|
94
|
+
if (this._settings.properties?.overlay !== undefined) {
|
|
95
|
+
createSessionOptions.overlay = this._settings.properties.overlay;
|
|
96
|
+
}
|
|
97
|
+
if (this._settings.properties?.apiOptions !== undefined) {
|
|
98
|
+
createSessionOptions.apiOptions = this._settings.properties.apiOptions;
|
|
99
|
+
}
|
|
100
|
+
return createSessionOptions;
|
|
101
|
+
}
|
|
102
|
+
// construct the Url from the desired Tile
|
|
103
|
+
async constructUrl(row, column, level) {
|
|
104
|
+
const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());
|
|
105
|
+
const obj = new URL(tmpUrl);
|
|
106
|
+
if (this._settings.accessKey) {
|
|
107
|
+
obj.searchParams.append("key", this._settings.accessKey.value);
|
|
108
|
+
}
|
|
109
|
+
// We assume the 'session' param to be already part of the query parameters (checked in initialize)
|
|
110
|
+
return this.appendCustomParams(obj.toString());
|
|
111
|
+
}
|
|
112
|
+
async fetchAttributions(tiles) {
|
|
113
|
+
const zooms = new Set();
|
|
114
|
+
const matchingAttributions = [];
|
|
115
|
+
// Viewport info requests must be made for a specific zoom level
|
|
116
|
+
tiles.forEach((tile) => zooms.add(tile.depth));
|
|
117
|
+
for (const zoom of zooms) {
|
|
118
|
+
let cartoRect;
|
|
119
|
+
for (const tile of tiles) {
|
|
120
|
+
if (tile.depth === zoom && tile instanceof core_frontend_1.MapTile) {
|
|
121
|
+
const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);
|
|
122
|
+
const rect = core_frontend_1.MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop);
|
|
123
|
+
if (cartoRect)
|
|
124
|
+
cartoRect.union(rect);
|
|
125
|
+
else
|
|
126
|
+
cartoRect = rect;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (cartoRect) {
|
|
130
|
+
try {
|
|
131
|
+
const viewportInfo = await GoogleMapsUtils_1.GoogleMapsUtils.getViewportInfo({
|
|
132
|
+
rectangle: cartoRect,
|
|
133
|
+
session: this._settings.collectQueryParams().session,
|
|
134
|
+
key: this._settings.accessKey.value,
|
|
135
|
+
zoom
|
|
136
|
+
});
|
|
137
|
+
if (viewportInfo?.copyright) {
|
|
138
|
+
matchingAttributions.push(viewportInfo.copyright);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message ?? "Unknown error"}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return matchingAttributions;
|
|
147
|
+
}
|
|
148
|
+
async logJsonError(tileResponse) {
|
|
149
|
+
try {
|
|
150
|
+
const error = await tileResponse.json();
|
|
151
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async loadTile(row, column, zoomLevel) {
|
|
158
|
+
if (this._hadUnrecoverableError)
|
|
159
|
+
return undefined;
|
|
160
|
+
try {
|
|
161
|
+
let tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
162
|
+
let tileResponse = await this.makeTileRequest(tileUrl);
|
|
163
|
+
if (!tileResponse.ok) {
|
|
164
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
165
|
+
// Session might have expired, lets try to re-new it.
|
|
166
|
+
const isSessionCreated = await this.createSession();
|
|
167
|
+
if (isSessionCreated) {
|
|
168
|
+
tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
169
|
+
tileResponse = await this.makeTileRequest(tileUrl);
|
|
170
|
+
if (!tileResponse.ok) {
|
|
171
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
172
|
+
await this.logJsonError(tileResponse);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
176
|
+
}
|
|
177
|
+
this._hadUnrecoverableError = true; // Prevent from doing more invalid requests
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
await this.logJsonError(tileResponse);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return await this.getImageFromTileResponse(tileResponse, zoomLevel);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error?.code === 401) {
|
|
194
|
+
core_bentley_1.Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
decorate(context) {
|
|
203
|
+
this._decorator.decorate(context);
|
|
204
|
+
}
|
|
205
|
+
getSelectedTiles(vp) {
|
|
206
|
+
return core_frontend_1.IModelApp.tileAdmin.getTilesForUser(vp)?.selected;
|
|
207
|
+
}
|
|
208
|
+
async addAttributions(cards, vp) {
|
|
209
|
+
let copyrightMsg = "";
|
|
210
|
+
const tiles = this.getSelectedTiles(vp);
|
|
211
|
+
if (tiles) {
|
|
212
|
+
try {
|
|
213
|
+
const attrList = await this.fetchAttributions(tiles);
|
|
214
|
+
for (const attr of attrList) {
|
|
215
|
+
attr.split(",").forEach((line) => {
|
|
216
|
+
copyrightMsg += `${copyrightMsg.length === 0 ? "" : "<br"}${line}`;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message ?? "Unknown error"}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
cards.appendChild(core_frontend_1.IModelApp.makeLogoCard({
|
|
225
|
+
iconSrc: `${core_frontend_1.IModelApp.publicPath}images/google_on_white_hdpi.png`,
|
|
226
|
+
heading: "Google Maps",
|
|
227
|
+
notice: copyrightMsg
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.GoogleMapsImageryProvider = GoogleMapsImageryProvider;
|
|
232
|
+
//# 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,wDAA6L;AAE7L,sDAA0E;AAC1E,6DAA2D;AAC3D,iEAA8D;AAC9D,MAAM,cAAc,GAAG,6BAA6B,CAAC;AACrD,MAAM,UAAU,GAAG,SAAS,CAAC;AA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O,CAAC,CAAC;IACpC,CAAC;IAEO,gBAAgB,CAAC,EAAkB;QACzC,OAAO,yBAAS,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,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,yBAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CAEF;AA7ND,8DA6NC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession } from \"./GoogleMaps\";\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils\";\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\nconst levelToken = \"{level}\";\r\nconst rowToken = \"{row}\";\r\nconst columnToken = \"{column}\";\r\n\r\nconst urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @internal\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256\r\n constructor(settings: ImageMapLayerSettings) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n }\r\n public static validateUrlTemplate(template: string): MapLayerSourceValidation {\r\n return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl };\r\n }\r\n\r\n protected async createSession() : Promise<GoogleMapsSession|undefined> {\r\n const sessionOptions = this.createCreateSessionOptions();\r\n if (this._settings.accessKey ) {\r\n // Create session and store in query parameters\r\n const sessionObj = await GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);\r\n this._settings.unsavedQueryParams = {session: sessionObj.session};\r\n return sessionObj;\r\n } else {\r\n Logger.logError(loggerCategory, `Missing GoogleMaps api key`);\r\n return undefined;\r\n }\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n\r\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\r\n if (layerPropertyKeys === undefined ||\r\n !layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const session = await this.createSession();\r\n if (!session) {\r\n const msg = `Failed to create session`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n this._tileSize = session.tileWidth; // assuming here tiles are square\r\n\r\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n private createCreateSessionOptions(): GoogleMapsCreateSessionOptions {\r\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\r\n if (layerPropertyKeys === undefined ||\r\n !layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: this._settings.properties!.mapType as GoogleMapsMapTypes,\r\n region: this._settings.properties!.region as string,\r\n language: this._settings.properties!.language as string,\r\n }\r\n\r\n if (this._settings.properties?.layerTypes !== undefined) {\r\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\r\n }\r\n\r\n if (this._settings.properties?.scale !== undefined) {\r\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\r\n }\r\n\r\n if (this._settings.properties?.overlay !== undefined) {\r\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\r\n }\r\n\r\n if (this._settings.properties?.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\r\n }\r\n return createSessionOptions;\r\n }\r\n\r\n // construct the Url from the desired Tile\r\n public async constructUrl(row: number, column: number, level: number): Promise<string> {\r\n const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());\r\n const obj = new URL(tmpUrl);\r\n if (this._settings.accessKey ) {\r\n obj.searchParams.append(\"key\", this._settings.accessKey.value);\r\n }\r\n\r\n // We assume the 'session' param to be already part of the query parameters (checked in initialize)\r\n return this.appendCustomParams(obj.toString());\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect) {\r\n try {\r\n const viewportInfo = await GoogleMapsUtils.getViewportInfo({\r\n rectangle: cartoRect,\r\n session: this._settings.collectQueryParams().session,\r\n key: this._settings.accessKey!.value,\r\n zoom});\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n try {\r\n let tileUrl: string = await this.constructUrl(row, column, zoomLevel);\r\n let tileResponse: Response = await this.makeTileRequest(tileUrl);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n // Session might have expired, lets try to re-new it.\r\n const isSessionCreated = await this.createSession();\r\n if (isSessionCreated) {\r\n tileUrl = await this.constructUrl(row, column, zoomLevel);\r\n tileResponse = await this.makeTileRequest(tileUrl);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n } else {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\r\n }\r\n\r\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n let copyrightMsg = \"\";\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\r\n heading: \"Google Maps\",\r\n notice: copyrightMsg }));\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -5,6 +5,7 @@ const core_frontend_1 = require("@itwin/core-frontend");
|
|
|
5
5
|
const OgcApiFeaturesProvider_1 = require("./OgcApiFeaturesProvider");
|
|
6
6
|
/** @internal */
|
|
7
7
|
class OgcApiFeaturesMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat {
|
|
8
|
+
static formatId = "OgcApiFeatures";
|
|
8
9
|
static createImageryProvider(settings) { return new OgcApiFeaturesProvider_1.OgcApiFeaturesProvider(settings); }
|
|
9
10
|
static async validate(args) {
|
|
10
11
|
const { source } = args;
|
|
@@ -90,5 +91,4 @@ class OgcApiFeaturesMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
exports.OgcApiFeaturesMapLayerFormat = OgcApiFeaturesMapLayerFormat;
|
|
93
|
-
OgcApiFeaturesMapLayerFormat.formatId = "OgcApiFeatures";
|
|
94
94
|
//# sourceMappingURL=OgcApiFeaturesFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":";;;AAKA,wDAAoM;AACpM,qEAAkE;AAElE,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,qCAAqB;
|
|
1
|
+
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":";;;AAKA,wDAAoM;AACpM,qEAAkE;AAElE,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,qCAAqB;IAC9D,MAAM,CAAU,QAAQ,GAAG,gBAAgB,CAAC;IAC5C,MAAM,CAAU,qBAAqB,CAAC,QAA+B,IAAyC,OAAO,IAAI,+CAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5J,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,IAAwB;QAE5D,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QACtB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACtC,IAAI,MAAM,GAAG,oCAAoB,CAAC,UAAU,CAAC;QAC7C,IAAI,CAAC;YAEH,IAAI,OAA4B,CAAC;YACjC,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBACzB,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;gBACxB,IAAA,qCAAqB,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,GAAgB;gBACxB,MAAM,EAAE,KAAK;gBACb,OAAO;aACR,CAAC;YAEF,IAAI,GAAG,GAAG,IAAA,iCAAiB,EAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACjE,GAAG,GAAG,IAAA,iCAAiB,EAAC,GAAG,EAAE,MAA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CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,oCAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,oCAAoB,CAAC,WAAW,CAAC,CAAC;YACjH,CAAC;YACD,OAAO,EAAE,MAAM,EAAC,CAAC;QACnB,CAAC;IACH,CAAC;;AA1FH,oEA2FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { ImageMapLayerSettings, MapSubLayerProps } from \"@itwin/core-common\";\r\nimport { appendQueryParams, ImageryMapLayerFormat, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, setBasicAuthorization, ValidateSourceArgs } from \"@itwin/core-frontend\";\r\nimport { OgcApiFeaturesProvider } from \"./OgcApiFeaturesProvider\";\r\n\r\n/** @internal */\r\nexport class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {\r\n public static override formatId = \"OgcApiFeatures\";\r\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined { return new OgcApiFeaturesProvider(settings); }\r\n\r\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\r\n\r\n const {source} = args;\r\n const { userName, password } = source;\r\n let status = MapLayerSourceStatus.InvalidUrl;\r\n try {\r\n\r\n let headers: Headers | undefined;\r\n if (userName && password) {\r\n headers = new Headers();\r\n setBasicAuthorization(headers, userName, password);\r\n }\r\n const opts: RequestInit = {\r\n method: \"GET\",\r\n headers,\r\n };\r\n\r\n let url = appendQueryParams(source.url, source.savedQueryParams);\r\n url = appendQueryParams(url, source.unsavedQueryParams);\r\n let response = await fetch(url, opts);\r\n let json = await response.json();\r\n if (!json) {\r\n return { status };\r\n }\r\n\r\n const createCollectionsList = (data: any) => {\r\n let array: MapSubLayerProps[] | undefined;\r\n for (const collection of data.collections) {\r\n if (collection.itemType === \"feature\") {\r\n const subLayerProps = {\r\n id: collection.id,\r\n name: collection.id,\r\n title: collection.title,\r\n visible: true,\r\n parent: undefined,\r\n children: undefined,\r\n };\r\n if (array)\r\n array.push(subLayerProps);\r\n else\r\n array = [subLayerProps];\r\n }\r\n }\r\n return array;\r\n };\r\n\r\n let subLayers: MapSubLayerProps[] | undefined;\r\n if (Array.isArray(json.collections)) {\r\n subLayers = createCollectionsList(json);\r\n status = MapLayerSourceStatus.Valid;\r\n } else if (json.itemType === \"feature\" || json.type === \"FeatureCollection\") {\r\n // We expect one of the following URL:\r\n // http://server/collections/<collectionName>\r\n // http://server/collections/<collectionName>/items\r\n subLayers = [{\r\n id: json.id,\r\n name: json.id,\r\n title: json.title,\r\n visible: true,\r\n parent: undefined,\r\n children: undefined,\r\n }];\r\n status = MapLayerSourceStatus.Valid;\r\n } else if (Array.isArray(json.links)) {\r\n // This might be the main landing page\r\n const collectionsLink = json.links.find((link: any)=> link.rel.includes(\"data\") && link.type === \"application/json\");\r\n let collectionsUrl = appendQueryParams(collectionsLink.href, source.savedQueryParams);\r\n collectionsUrl = appendQueryParams(collectionsUrl, source.unsavedQueryParams);\r\n response = await fetch(collectionsUrl, opts);\r\n json = await response.json();\r\n if (Array.isArray(json.collections)) {\r\n subLayers = createCollectionsList(json);\r\n status = MapLayerSourceStatus.Valid;\r\n }\r\n\r\n }\r\n\r\n return { status, subLayers };\r\n\r\n } catch (err: any) {\r\n status = MapLayerSourceStatus.InvalidUrl;\r\n if (err?.status === 401) {\r\n status = ((userName && password) ? MapLayerSourceStatus.InvalidCredentials : MapLayerSourceStatus.RequireAuth);\r\n }\r\n return { status};\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -21,8 +21,31 @@ const dataUrlHeaderToken = "base64,";
|
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
23
|
class DefaultOgcSymbology {
|
|
24
|
+
static _defaultPMSProps = {
|
|
25
|
+
type: "esriPMS",
|
|
26
|
+
url: "",
|
|
27
|
+
width: 16,
|
|
28
|
+
height: 24,
|
|
29
|
+
// 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)
|
|
30
|
+
xoffset: 0,
|
|
31
|
+
yoffset: -12,
|
|
32
|
+
};
|
|
33
|
+
_defaultPMS;
|
|
34
|
+
static _defaultSLSProps = {
|
|
35
|
+
type: "esriSLS",
|
|
36
|
+
color: [0, 0, 255, 255],
|
|
37
|
+
width: 1,
|
|
38
|
+
style: "esriSLSSolid",
|
|
39
|
+
};
|
|
40
|
+
_defaultSLS;
|
|
41
|
+
static _defaultSFSProps = {
|
|
42
|
+
type: "esriSFS",
|
|
43
|
+
color: [0, 0, 255, 255], // blue fill
|
|
44
|
+
style: "esriSFSSolid",
|
|
45
|
+
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
46
|
+
};
|
|
47
|
+
_defaultSFS = EsriSymbology_1.EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
24
48
|
constructor(randomColor) {
|
|
25
|
-
this._defaultSFS = EsriSymbology_1.EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
26
49
|
const color = randomColor ? randomColor.getColorDef() : core_common_1.ColorDef.blue;
|
|
27
50
|
this._defaultPMS = EsriSymbology_1.EsriPMS.fromJSON({
|
|
28
51
|
...DefaultMarkerIcon_1.DefaultMarkerIcon.getContent(color),
|
|
@@ -63,43 +86,27 @@ class DefaultOgcSymbology {
|
|
|
63
86
|
}
|
|
64
87
|
}
|
|
65
88
|
exports.DefaultOgcSymbology = DefaultOgcSymbology;
|
|
66
|
-
DefaultOgcSymbology._defaultPMSProps = {
|
|
67
|
-
type: "esriPMS",
|
|
68
|
-
url: "",
|
|
69
|
-
width: 16,
|
|
70
|
-
height: 24,
|
|
71
|
-
// 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)
|
|
72
|
-
xoffset: 0,
|
|
73
|
-
yoffset: -12,
|
|
74
|
-
};
|
|
75
|
-
DefaultOgcSymbology._defaultSLSProps = {
|
|
76
|
-
type: "esriSLS",
|
|
77
|
-
color: [0, 0, 255, 255],
|
|
78
|
-
width: 1,
|
|
79
|
-
style: "esriSLSSolid",
|
|
80
|
-
};
|
|
81
|
-
DefaultOgcSymbology._defaultSFSProps = {
|
|
82
|
-
type: "esriSFS",
|
|
83
|
-
color: [0, 0, 255, 255], // blue fill
|
|
84
|
-
style: "esriSFSSolid",
|
|
85
|
-
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
86
|
-
};
|
|
87
89
|
/** @internal */
|
|
88
90
|
class OgcApiFeaturesProvider extends core_frontend_1.MapLayerImageryProvider {
|
|
91
|
+
// Debug flags, should always be committed to FALSE !
|
|
92
|
+
_drawDebugInfo = false;
|
|
93
|
+
/// ////////////////////////////
|
|
94
|
+
_limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
95
|
+
_tiledModeMinLod = 14;
|
|
96
|
+
_staticModeFetchTimeout = 10000;
|
|
97
|
+
_tileModeFetchTimeout = 10000;
|
|
98
|
+
_forceTileMode = false;
|
|
99
|
+
_spatialIdx;
|
|
100
|
+
_defaultSymbol = new DefaultOgcSymbology(new RandomMapColor_1.RandomMapColor());
|
|
101
|
+
_renderer;
|
|
102
|
+
_collectionUrl = "";
|
|
103
|
+
_itemsUrl = "";
|
|
104
|
+
_itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
105
|
+
_queryables;
|
|
106
|
+
serviceJson;
|
|
107
|
+
_staticData;
|
|
89
108
|
constructor(settings) {
|
|
90
109
|
super(settings, true);
|
|
91
|
-
// Debug flags, should always be committed to FALSE !
|
|
92
|
-
this._drawDebugInfo = false;
|
|
93
|
-
/// ////////////////////////////
|
|
94
|
-
this._limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
95
|
-
this._tiledModeMinLod = 14;
|
|
96
|
-
this._staticModeFetchTimeout = 10000;
|
|
97
|
-
this._tileModeFetchTimeout = 10000;
|
|
98
|
-
this._forceTileMode = false;
|
|
99
|
-
this._defaultSymbol = new DefaultOgcSymbology(new RandomMapColor_1.RandomMapColor());
|
|
100
|
-
this._collectionUrl = "";
|
|
101
|
-
this._itemsUrl = "";
|
|
102
|
-
this._itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
103
110
|
}
|
|
104
111
|
get supportsMapFeatureInfo() { return true; }
|
|
105
112
|
get minimumZoomLevel() { return this.staticMode ? super.minimumZoomLevel : this._tiledModeMinLod; }
|