@itwin/core-frontend 3.0.0-dev.180 → 3.0.0-dev.184
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 +89 -1
- package/lib/cjs/ApproximateTerrainHeights.d.ts.map +1 -1
- package/lib/cjs/ApproximateTerrainHeights.js +6 -2
- package/lib/cjs/ApproximateTerrainHeights.js.map +1 -1
- package/lib/cjs/BackgroundMapGeometry.d.ts +1 -1
- package/lib/cjs/BackgroundMapGeometry.d.ts.map +1 -1
- package/lib/cjs/BackgroundMapGeometry.js +2 -2
- package/lib/cjs/BackgroundMapGeometry.js.map +1 -1
- package/lib/cjs/BingLocation.js +2 -2
- package/lib/cjs/BingLocation.js.map +1 -1
- package/lib/cjs/DisplayStyleState.d.ts +9 -3
- package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleState.js +66 -41
- package/lib/cjs/DisplayStyleState.js.map +1 -1
- package/lib/cjs/FrontendLoggerCategory.d.ts +2 -8
- package/lib/cjs/FrontendLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/FrontendLoggerCategory.js +2 -8
- package/lib/cjs/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/NativeApp.d.ts +1 -1
- package/lib/cjs/NativeApp.d.ts.map +1 -1
- package/lib/cjs/NativeApp.js +3 -3
- package/lib/cjs/NativeApp.js.map +1 -1
- package/lib/cjs/NotificationManager.d.ts +3 -1
- package/lib/cjs/NotificationManager.d.ts.map +1 -1
- package/lib/cjs/NotificationManager.js +2 -0
- package/lib/cjs/NotificationManager.js.map +1 -1
- package/lib/cjs/RealityDataSource.js +11 -6
- package/lib/cjs/RealityDataSource.js.map +1 -1
- package/lib/cjs/ViewContext.js.map +1 -1
- package/lib/cjs/ViewCreator2d.js +1 -1
- package/lib/cjs/ViewCreator2d.js.map +1 -1
- package/lib/cjs/ViewCreator3d.d.ts +1 -1
- package/lib/cjs/ViewCreator3d.d.ts.map +1 -1
- package/lib/cjs/ViewCreator3d.js +2 -2
- package/lib/cjs/ViewCreator3d.js.map +1 -1
- package/lib/cjs/ViewingSpace.js +1 -1
- package/lib/cjs/ViewingSpace.js.map +1 -1
- package/lib/cjs/core-frontend.d.ts +4 -0
- package/lib/cjs/core-frontend.d.ts.map +1 -1
- package/lib/cjs/core-frontend.js +4 -0
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/render/GraphicBuilder.d.ts +6 -0
- package/lib/cjs/render/GraphicBuilder.d.ts.map +1 -1
- package/lib/cjs/render/GraphicBuilder.js.map +1 -1
- package/lib/cjs/render/primitives/geometry/GeometryAccumulator.d.ts +2 -0
- package/lib/cjs/render/primitives/geometry/GeometryAccumulator.d.ts.map +1 -1
- package/lib/cjs/render/primitives/geometry/GeometryAccumulator.js +2 -1
- package/lib/cjs/render/primitives/geometry/GeometryAccumulator.js.map +1 -1
- package/lib/cjs/render/primitives/geometry/GeometryListBuilder.d.ts.map +1 -1
- package/lib/cjs/render/primitives/geometry/GeometryListBuilder.js +1 -0
- package/lib/cjs/render/primitives/geometry/GeometryListBuilder.js.map +1 -1
- package/lib/cjs/render/primitives/mesh/MeshPrimitives.d.ts +2 -2
- package/lib/cjs/render/primitives/mesh/MeshPrimitives.d.ts.map +1 -1
- package/lib/cjs/render/primitives/mesh/MeshPrimitives.js +3 -3
- package/lib/cjs/render/primitives/mesh/MeshPrimitives.js.map +1 -1
- package/lib/cjs/render/webgl/BranchUniforms.d.ts.map +1 -1
- package/lib/cjs/render/webgl/BranchUniforms.js +8 -5
- package/lib/cjs/render/webgl/BranchUniforms.js.map +1 -1
- package/lib/cjs/render/webgl/SolarShadowMap.js +1 -1
- package/lib/cjs/render/webgl/SolarShadowMap.js.map +1 -1
- package/lib/cjs/render/webgl/System.d.ts +1 -1
- package/lib/cjs/request/Request.d.ts +167 -0
- package/lib/cjs/request/Request.d.ts.map +1 -0
- package/lib/cjs/request/Request.js +315 -0
- package/lib/cjs/request/Request.js.map +1 -0
- package/lib/cjs/tile/internal.d.ts +1 -0
- package/lib/cjs/tile/internal.d.ts.map +1 -1
- package/lib/cjs/tile/internal.js +1 -0
- package/lib/cjs/tile/internal.js.map +1 -1
- package/lib/cjs/tile/map/ArcGISTileMap.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGISTileMap.js +6 -2
- package/lib/cjs/tile/map/ArcGISTileMap.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisTokenGenerator.js +3 -3
- package/lib/cjs/tile/map/ArcGisTokenGenerator.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.d.ts +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.js +18 -10
- package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/tile/map/BingElevation.js +4 -4
- package/lib/cjs/tile/map/BingElevation.js.map +1 -1
- package/lib/cjs/tile/map/CesiumTerrainProvider.js +3 -3
- package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +4 -4
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js +2 -2
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerAuthentication.d.ts +20 -0
- package/lib/cjs/tile/map/MapLayerAuthentication.d.ts.map +1 -0
- package/lib/cjs/tile/map/MapLayerAuthentication.js +18 -0
- package/lib/cjs/tile/map/MapLayerAuthentication.js.map +1 -0
- package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +6 -3
- package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerFormatRegistry.js +3 -1
- package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts +2 -2
- package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.js +4 -2
- package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +2 -2
- package/lib/cjs/tile/map/MapLayerImageryProvider.js +5 -5
- package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerSources.d.ts +3 -1
- package/lib/cjs/tile/map/MapLayerSources.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerSources.js +5 -3
- package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
- package/lib/cjs/tile/map/MapTileLoader.js +2 -2
- package/lib/cjs/tile/map/MapTileLoader.js.map +1 -1
- package/lib/cjs/tile/map/TerrainMeshProvider.d.ts +1 -1
- package/lib/cjs/tile/map/TerrainMeshProvider.js.map +1 -1
- package/lib/cjs/tile/map/WmsCapabilities.d.ts +1 -1
- package/lib/cjs/tile/map/WmsCapabilities.js +2 -2
- package/lib/cjs/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.d.ts +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.js +2 -2
- package/lib/cjs/tile/map/WmtsCapabilities.js.map +1 -1
- package/lib/esm/ApproximateTerrainHeights.d.ts.map +1 -1
- package/lib/esm/ApproximateTerrainHeights.js +6 -2
- package/lib/esm/ApproximateTerrainHeights.js.map +1 -1
- package/lib/esm/BackgroundMapGeometry.d.ts +1 -1
- package/lib/esm/BackgroundMapGeometry.d.ts.map +1 -1
- package/lib/esm/BackgroundMapGeometry.js +2 -2
- package/lib/esm/BackgroundMapGeometry.js.map +1 -1
- package/lib/esm/BingLocation.js +1 -1
- package/lib/esm/BingLocation.js.map +1 -1
- package/lib/esm/DisplayStyleState.d.ts +9 -3
- package/lib/esm/DisplayStyleState.d.ts.map +1 -1
- package/lib/esm/DisplayStyleState.js +66 -41
- package/lib/esm/DisplayStyleState.js.map +1 -1
- package/lib/esm/FrontendLoggerCategory.d.ts +2 -8
- package/lib/esm/FrontendLoggerCategory.d.ts.map +1 -1
- package/lib/esm/FrontendLoggerCategory.js +2 -8
- package/lib/esm/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/NativeApp.d.ts +1 -1
- package/lib/esm/NativeApp.d.ts.map +1 -1
- package/lib/esm/NativeApp.js +1 -1
- package/lib/esm/NativeApp.js.map +1 -1
- package/lib/esm/NotificationManager.d.ts +3 -1
- package/lib/esm/NotificationManager.d.ts.map +1 -1
- package/lib/esm/NotificationManager.js +2 -0
- package/lib/esm/NotificationManager.js.map +1 -1
- package/lib/esm/RealityDataSource.js +9 -4
- package/lib/esm/RealityDataSource.js.map +1 -1
- package/lib/esm/ViewContext.js.map +1 -1
- package/lib/esm/ViewCreator2d.js +1 -1
- package/lib/esm/ViewCreator2d.js.map +1 -1
- package/lib/esm/ViewCreator3d.d.ts +1 -1
- package/lib/esm/ViewCreator3d.d.ts.map +1 -1
- package/lib/esm/ViewCreator3d.js +2 -2
- package/lib/esm/ViewCreator3d.js.map +1 -1
- package/lib/esm/ViewingSpace.js +1 -1
- package/lib/esm/ViewingSpace.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +4 -0
- package/lib/esm/core-frontend.d.ts.map +1 -1
- package/lib/esm/core-frontend.js +4 -0
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/render/GraphicBuilder.d.ts +6 -0
- package/lib/esm/render/GraphicBuilder.d.ts.map +1 -1
- package/lib/esm/render/GraphicBuilder.js.map +1 -1
- package/lib/esm/render/primitives/geometry/GeometryAccumulator.d.ts +2 -0
- package/lib/esm/render/primitives/geometry/GeometryAccumulator.d.ts.map +1 -1
- package/lib/esm/render/primitives/geometry/GeometryAccumulator.js +2 -1
- package/lib/esm/render/primitives/geometry/GeometryAccumulator.js.map +1 -1
- package/lib/esm/render/primitives/geometry/GeometryListBuilder.d.ts.map +1 -1
- package/lib/esm/render/primitives/geometry/GeometryListBuilder.js +1 -0
- package/lib/esm/render/primitives/geometry/GeometryListBuilder.js.map +1 -1
- package/lib/esm/render/primitives/mesh/MeshPrimitives.d.ts +2 -2
- package/lib/esm/render/primitives/mesh/MeshPrimitives.d.ts.map +1 -1
- package/lib/esm/render/primitives/mesh/MeshPrimitives.js +3 -3
- package/lib/esm/render/primitives/mesh/MeshPrimitives.js.map +1 -1
- package/lib/esm/render/webgl/BranchUniforms.d.ts.map +1 -1
- package/lib/esm/render/webgl/BranchUniforms.js +8 -5
- package/lib/esm/render/webgl/BranchUniforms.js.map +1 -1
- package/lib/esm/render/webgl/SolarShadowMap.js +1 -1
- package/lib/esm/render/webgl/SolarShadowMap.js.map +1 -1
- package/lib/esm/render/webgl/System.d.ts +1 -1
- package/lib/esm/request/Request.d.ts +167 -0
- package/lib/esm/request/Request.d.ts.map +1 -0
- package/lib/esm/request/Request.js +289 -0
- package/lib/esm/request/Request.js.map +1 -0
- package/lib/esm/tile/internal.d.ts +1 -0
- package/lib/esm/tile/internal.d.ts.map +1 -1
- package/lib/esm/tile/internal.js +1 -0
- package/lib/esm/tile/internal.js.map +1 -1
- package/lib/esm/tile/map/ArcGISTileMap.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGISTileMap.js +6 -2
- package/lib/esm/tile/map/ArcGISTileMap.js.map +1 -1
- package/lib/esm/tile/map/ArcGisTokenGenerator.js +1 -1
- package/lib/esm/tile/map/ArcGisTokenGenerator.js.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.d.ts +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.js +14 -6
- package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/tile/map/BingElevation.js +1 -1
- package/lib/esm/tile/map/BingElevation.js.map +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.js +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapLayerAuthentication.d.ts +20 -0
- package/lib/esm/tile/map/MapLayerAuthentication.d.ts.map +1 -0
- package/lib/esm/tile/map/MapLayerAuthentication.js +15 -0
- package/lib/esm/tile/map/MapLayerAuthentication.js.map +1 -0
- package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +6 -3
- package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerFormatRegistry.js +3 -1
- package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.d.ts +2 -2
- package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.js +5 -3
- package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +2 -2
- package/lib/esm/tile/map/MapLayerImageryProvider.js +2 -2
- package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapLayerSources.d.ts +3 -1
- package/lib/esm/tile/map/MapLayerSources.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerSources.js +4 -2
- package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
- package/lib/esm/tile/map/MapTileLoader.js +1 -1
- package/lib/esm/tile/map/MapTileLoader.js.map +1 -1
- package/lib/esm/tile/map/TerrainMeshProvider.d.ts +1 -1
- package/lib/esm/tile/map/TerrainMeshProvider.js.map +1 -1
- package/lib/esm/tile/map/WmsCapabilities.d.ts +1 -1
- package/lib/esm/tile/map/WmsCapabilities.js +1 -1
- package/lib/esm/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.d.ts +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.js +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.js.map +1 -1
- package/package.json +28 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WmtsCapabilities.js","sourceRoot":"","sources":["../../../../src/tile/map/WmtsCapabilities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAwD;AACxD,wDAAyF;AACzF,mCAAkC;AAClC,0CAA8D,CAAC,qCAAqC;AAEpG;;;;GAIG;AACH,KAAK,UAAU,MAAM,CAAC,GAAW,EAAE,WAAqC;IACtE,MAAM,OAAO,GAAmB;QAC9B,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,MAAM;QACpB,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC5B,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,WAAW;KAClB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,IAAA,sBAAO,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,IAAiB,cAAc,CA2b9B;AA3bD,WAAiB,cAAc;IAE7B,MAAsB,YAAY;;IAChC,oBAAoB;IACG,4BAAe,GAAG,cAAc,CAAC;IACjC,qCAAwB,GAAG,uBAAuB,CAAC;IACnD,iCAAoB,GAAG,mBAAmB,CAAC;IAC3C,+BAAkB,GAAG,iBAAiB,CAAC;IACvC,8BAAiB,GAAG,gBAAgB,CAAC;IACrC,uBAAU,GAAG,SAAS,CAAC;IACvB,wBAAW,GAAG,UAAU,CAAC;IACzB,uBAAU,GAAG,SAAS,CAAC;IACvB,wBAAW,GAAG,UAAU,CAAC;IACzB,8BAAiB,GAAG,gBAAgB,CAAC;IAC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AAI,CAAC,eAAe;YAClB,OAAO,SAAS,CAAC;QAEnB,MAAM,YAAY,GAAG,gBAAgB,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACrE,IAAI,YAAY;YACd,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAE7D,OAAO,YAAY,CAAC;IACtB,CAAC;;AAnDH,4CAoDC;AAnDgB,mCAAkB,GAAG,IAAI,GAAG,EAAwC,CAAC","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 Views\r\n */\r\n\r\nimport { Point2d, Range2d } from \"@itwin/core-geometry\";\r\nimport { request, RequestBasicCredentials, RequestOptions } from \"@bentley/itwin-client\";\r\nimport { xml2json } from \"xml-js\";\r\nimport { MapCartoRectangle, WmsUtilities } from \"../internal\"; // WmsUtilities needed for getBaseUrl\r\n\r\n/**\r\n * fetch XML from HTTP request\r\n * @param url server URL to address the request\r\n * @internal\r\n */\r\nasync function getXml(url: string, credentials?: RequestBasicCredentials): Promise<any> {\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"text\",\r\n timeout: { response: 20000 },\r\n retries: 2,\r\n auth: credentials,\r\n };\r\n const data = await request(url, options);\r\n return data.text;\r\n}\r\n\r\n/** Encapsulation of the capabilities for an WMTS server\r\n * @internal\r\n */\r\nexport namespace WmtsCapability {\r\n\r\n export abstract class OwsConstants {\r\n // OWS xml tag names\r\n public static readonly ABSTRACT_XMLTAG = \"ows:Abstract\";\r\n public static readonly ACCESSCONSTRAINTS_XMLTAG = \"ows:AccessConstraints\";\r\n public static readonly ALLOWEDVALUES_XMLTAG = \"ows:AllowedValues\";\r\n public static readonly BOUNDINGBOX_XMLTAG = \"ows:BoundingBox\";\r\n public static readonly CONSTRAINT_XMLTAG = \"ows:Constraint\";\r\n public static readonly DCP_XMLTAG = \"ows:DCP\";\r\n public static readonly FEES_XMLTAG = \"ows:Fees\";\r\n public static readonly GET_XMLTAG = \"ows:Get\";\r\n public static readonly HTTP_XMLTAG = \"ows:HTTP\";\r\n public static readonly IDENTIFIER_XMLTAG = \"ows:Identifier\";\r\n public static readonly KEYWORDS_XMLTAG = \"ows:Keywords\";\r\n public static readonly KEYWORD_XMLTAG = \"ows:Keyword\";\r\n public static readonly LOWERCORNER_XMLTAG = \"ows:LowerCorner\";\r\n public static readonly OPERATION_XMLTAG = \"ows:Operation\";\r\n public static readonly OPERATIONSMETADATA_XMLTAG = \"ows:OperationsMetadata\";\r\n public static readonly POST_XMLTAG = \"ows:Post\";\r\n public static readonly SERVICEIDENTIFICATION_XMLTAG = \"ows:ServiceIdentification\";\r\n public static readonly SERVICETYPE_XMLTAG = \"ows:ServiceType\";\r\n public static readonly SERVICETYPEVERSION_XMLTAG = \"ows:ServiceTypeVersion\";\r\n public static readonly SUPPORTEDCRS_XMLTAG = \"ows:SupportedCRS\";\r\n public static readonly TITLE_XMLTAG = \"ows:Title\";\r\n public static readonly UPPERCORNER_XMLTAG = \"ows:UpperCorner\";\r\n public static readonly VALUE_XMLTAG = \"ows:Value\";\r\n public static readonly WGS84BOUNDINGBOX_XMLTAG = \"ows:WGS84BoundingBox\";\r\n }\r\n\r\n export abstract class XmlConstants {\r\n // Operations names\r\n public static readonly GETCAPABILITIES = \"GetCapabilities\";\r\n public static readonly GETTILE = \"GetTile\";\r\n public static readonly GETFEATUREINFO = \"GetFeatureInfo\";\r\n\r\n public static readonly MATRIXWIDTH_XMLTAG = \"MatrixWidth\";\r\n public static readonly MATRIXHEIGHT_XMLTAG = \"MatrixHeight\";\r\n public static readonly SCALEDENOMINATOR_XMLTAG = \"ScaleDenominator\";\r\n\r\n public static readonly TILEHEIGHT_XMLTAG = \"TileHeight\";\r\n public static readonly TILEMATRIX_XMLTAG = \"TileMatrix\";\r\n public static readonly TILEMATRIXSETLINK_XMLTAG = \"TileMatrixSetLink\";\r\n public static readonly TILEWIDTH_XMLTAG = \"TileWidth\";\r\n public static readonly TOPLEFTCORNER_XMLTAG = \"TopLeftCorner\";\r\n public static readonly WELLKNOWNSCALESET_XMLTAG = \"WellKnownScaleSet\";\r\n\r\n public static readonly CONSTRAINT_NAME_FILTER = \"Encoding\";\r\n public static readonly STYLE_ISDEFAULT = \"IsDefault\";\r\n public static readonly XLINK_HREF = \"xlink:href\";\r\n }\r\n\r\n export abstract class Constants {\r\n public static readonly GOOGLEMAPS_LEVEL0_SCALE_DENOM = 559082264.0287178;\r\n public static readonly GOOGLEMAPS_COMPATIBLE_WELLKNOWNNAME = \"googlemapscompatible\";\r\n }\r\n\r\n export class ServiceIdentification {\r\n public readonly abstract?: string;\r\n public readonly accessConstraints?: string;\r\n public readonly fees?: string;\r\n public readonly serviceType?: string;\r\n public readonly serviceTypeVersion?: string;\r\n public readonly title?: string;\r\n public readonly keywords?: string[];\r\n\r\n constructor(json: any) {\r\n this.abstract = json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n this.serviceType = json[OwsConstants.SERVICETYPE_XMLTAG]?._text;\r\n this.serviceTypeVersion = json[OwsConstants.SERVICETYPEVERSION_XMLTAG]?._text;\r\n this.title = json[OwsConstants.TITLE_XMLTAG]?._text;\r\n\r\n const keywords = json[OwsConstants.KEYWORDS_XMLTAG]?.[OwsConstants.KEYWORD_XMLTAG];\r\n if (keywords !== undefined) {\r\n this.keywords = [];\r\n\r\n if (Array.isArray(keywords)) {\r\n for (const keyword of keywords) {\r\n if (keyword !== undefined) {\r\n this.keywords.push(keyword._text);\r\n }\r\n }\r\n } else {\r\n this.keywords.push(keywords._text);\r\n }\r\n }\r\n\r\n this.accessConstraints = json[OwsConstants.ACCESSCONSTRAINTS_XMLTAG]?._text;\r\n this.fees = json[OwsConstants.FEES_XMLTAG]?._text;\r\n }\r\n }\r\n\r\n export class OperationMetadata {\r\n private _getCapabilities?: Operation;\r\n public get getCapabilities(): Operation | undefined { return this._getCapabilities; }\r\n\r\n private _getFeatureInfo?: Operation;\r\n public get getFeatureInfo(): Operation | undefined { return this._getFeatureInfo; }\r\n\r\n private _getTile?: Operation;\r\n public get getTile(): Operation | undefined { return this._getTile; }\r\n\r\n private readOperation(op: any) {\r\n if (op?._attributes?.name === XmlConstants.GETCAPABILITIES)\r\n this._getCapabilities = new Operation(op);\r\n else if (op?._attributes?.name === XmlConstants.GETTILE)\r\n this._getTile = new Operation(op);\r\n else if (op?._attributes?.name === XmlConstants.GETFEATUREINFO)\r\n this._getFeatureInfo = new Operation(op);\r\n }\r\n\r\n constructor(json: any) {\r\n const operation = (json ? json[OwsConstants.OPERATION_XMLTAG] : undefined);\r\n if (operation) {\r\n if (Array.isArray(operation)) {\r\n operation.forEach((op: any) => {\r\n this.readOperation(op);\r\n });\r\n } else {\r\n this.readOperation(operation);\r\n }\r\n }\r\n }\r\n }\r\n\r\n export class HttpDcp {\r\n public readonly url?: string;\r\n public readonly constraintName?: string;\r\n\r\n // For simplicity of use we create a 'static' encoding property instead of having\r\n // a generic constraint data model.\r\n // We make sure the constraint name is 'encoding' related.\r\n public readonly encoding?: string;\r\n\r\n constructor(json: any) {\r\n this.url = json?._attributes[XmlConstants.XLINK_HREF];\r\n this.constraintName = (json ? json[OwsConstants.CONSTRAINT_XMLTAG]?._attributes?.name : undefined);\r\n if (this.constraintName?.endsWith(XmlConstants.CONSTRAINT_NAME_FILTER))\r\n this.encoding = json[OwsConstants.CONSTRAINT_XMLTAG]?.[OwsConstants.ALLOWEDVALUES_XMLTAG]?.[OwsConstants.VALUE_XMLTAG]?._text;\r\n }\r\n }\r\n\r\n export class Operation {\r\n public readonly name?: string;\r\n private _getDcpHttp?: HttpDcp[];\r\n public get getDcpHttp(): HttpDcp[] | undefined { return this._getDcpHttp; }\r\n private _postDcpHttp?: HttpDcp[];\r\n public get postDcpHttp(): HttpDcp[] | undefined { return this._postDcpHttp; }\r\n\r\n constructor(json: any) {\r\n this.name = json?._attributes?.name;\r\n\r\n const dcpHttp = (json ? json[OwsConstants.DCP_XMLTAG]?.[OwsConstants.HTTP_XMLTAG] : undefined);\r\n if (!dcpHttp)\r\n return;\r\n\r\n const get = dcpHttp[OwsConstants.GET_XMLTAG];\r\n if (get) {\r\n this._getDcpHttp = [];\r\n\r\n if (Array.isArray(get)) {\r\n get.forEach((getItem: any) => {\r\n this._getDcpHttp?.push(new WmtsCapability.HttpDcp(getItem));\r\n });\r\n } else {\r\n this._getDcpHttp?.push(new WmtsCapability.HttpDcp(get));\r\n }\r\n }\r\n\r\n const post = dcpHttp[OwsConstants.POST_XMLTAG];\r\n if (post) {\r\n this._postDcpHttp = [];\r\n\r\n if (Array.isArray(post)) {\r\n post.forEach((postItem: any) => {\r\n this._postDcpHttp?.push(new WmtsCapability.HttpDcp(postItem));\r\n });\r\n } else {\r\n this._postDcpHttp?.push(new WmtsCapability.HttpDcp(post));\r\n }\r\n }\r\n }\r\n }\r\n\r\n export class Contents {\r\n public readonly layers: WmtsCapability.Layer[] = [];\r\n public readonly tileMatrixSets: WmtsCapability.TileMatrixSet[] = [];\r\n\r\n constructor(private _json: any) {\r\n\r\n // Layers\r\n const jsonLayer = _json?.Layer;\r\n if (jsonLayer) {\r\n if (Array.isArray(jsonLayer)) {\r\n jsonLayer.forEach((layer: any) => {\r\n this.layers.push(new WmtsCapability.Layer(layer));\r\n });\r\n } else {\r\n this.layers.push(new WmtsCapability.Layer(jsonLayer));\r\n }\r\n }\r\n\r\n // TileMatrixSet\r\n const jsonTileMatrixSet = _json?.TileMatrixSet;\r\n if (jsonTileMatrixSet) {\r\n if (Array.isArray(jsonTileMatrixSet)) {\r\n jsonTileMatrixSet.forEach((matrixSet: any) => {\r\n this.tileMatrixSets.push(new WmtsCapability.TileMatrixSet(matrixSet));\r\n });\r\n } else {\r\n this.tileMatrixSets.push(new WmtsCapability.TileMatrixSet(jsonTileMatrixSet));\r\n }\r\n }\r\n }\r\n\r\n public getGoogleMapsCompatibleTileMatrixSet(): WmtsCapability.TileMatrixSet[] {\r\n const googleMapsTms: WmtsCapability.TileMatrixSet[] = [];\r\n this.tileMatrixSets.forEach((tms) => {\r\n if (tms.wellKnownScaleSet?.toLowerCase().includes(Constants.GOOGLEMAPS_COMPATIBLE_WELLKNOWNNAME))\r\n googleMapsTms.push(tms);\r\n\r\n // In case wellKnownScaleSet was not been set properly, infer from scaleDenominator\r\n // Note: some servers are quite inaccurate in their scale values, hence I used a delta value of 1.\r\n else if (tms.tileMatrix.length > 0\r\n && Math.abs(tms.tileMatrix[0].scaleDenominator - Constants.GOOGLEMAPS_LEVEL0_SCALE_DENOM) < 1\r\n && (tms.supportedCrs.includes(\"3857\") || tms.supportedCrs.includes(\"900913\")))\r\n googleMapsTms.push(tms);\r\n });\r\n return googleMapsTms;\r\n }\r\n\r\n public getEpsg4326CompatibleTileMatrixSet(): WmtsCapability.TileMatrixSet[] {\r\n return this.tileMatrixSets.filter((tms) => tms.supportedCrs.includes(\"4326\"));\r\n }\r\n }\r\n\r\n export class Style {\r\n public readonly isDefault: boolean = false;\r\n public readonly title?: string;\r\n public readonly identifier?: string;\r\n // TODO: LegendURL\r\n\r\n constructor(private _json: any) {\r\n if (!_json)\r\n return;\r\n\r\n if (_json._attributes?.isDefault)\r\n this.isDefault = _json._attributes.isDefault.toLowerCase() === \"true\";\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n }\r\n }\r\n export class BoundingBox {\r\n public readonly crs?: string;\r\n public readonly range?: Range2d;\r\n\r\n constructor(_json: any) {\r\n this.crs = _json._attributes?.crs;\r\n const lowerCorner = _json[OwsConstants.LOWERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n const upperCorner = _json[OwsConstants.UPPERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (lowerCorner.length === 2 && upperCorner.length === 2)\r\n this.range = Range2d.createXYXY(lowerCorner[0], lowerCorner[1], upperCorner[0], upperCorner[1]);\r\n }\r\n }\r\n\r\n export class TileMatrixSetLimits {\r\n public limits?: Range2d;\r\n public tileMatrix?: string;\r\n\r\n constructor(_json: any) {\r\n this.tileMatrix = _json.TileMatrix;\r\n if (_json.MinTileRow !== undefined && _json.MaxTileRow !== undefined && _json.MinTileCol !== undefined && _json.MaxTileCol)\r\n this.limits = Range2d.createXYXY(Number(_json.MinTileCol._text), Number(_json.MinTileRow._text), Number(_json.MaxTileCol._text), Number(_json.MaxTileRow._text));\r\n }\r\n }\r\n\r\n export class TileMatrixSetLink {\r\n public readonly tileMatrixSet: string;\r\n public readonly tileMatrixSetLimits = new Array<TileMatrixSetLimits>();\r\n\r\n constructor(_json: any) {\r\n this.tileMatrixSet = (_json?.TileMatrixSet?._text ? _json.TileMatrixSet._text : \"\");\r\n const tileMatrixLimits = _json?.TileMatrixSetLimits?.TileMatrixLimits;\r\n if (Array.isArray(tileMatrixLimits))\r\n tileMatrixLimits.forEach((tml: any) => this.tileMatrixSetLimits.push(new TileMatrixSetLimits(tml)));\r\n }\r\n }\r\n\r\n export class TileMatrixSet {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly supportedCrs: string;\r\n public readonly wellKnownScaleSet: string;\r\n public readonly tileMatrix: TileMatrix[] = [];\r\n\r\n constructor(_json: any) {\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n if (!this.identifier)\r\n throw new Error(\"No Identifier found.\");\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.abstract = _json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n this.supportedCrs = _json[OwsConstants.SUPPORTEDCRS_XMLTAG]?._text;\r\n if (!this.supportedCrs)\r\n throw new Error(\"No supported CRS found.\");\r\n\r\n this.wellKnownScaleSet = _json[XmlConstants.WELLKNOWNSCALESET_XMLTAG]?._text;\r\n\r\n // TileMatrix:\r\n // TileMatrix is mandatory on TileMatrixSet, if it doesn't exists, something is OFF with the capability.\r\n const tileMatrix = _json[XmlConstants.TILEMATRIX_XMLTAG];\r\n if (!tileMatrix)\r\n throw new Error(\"No matrix set link found for WMTS layer\");\r\n\r\n if (Array.isArray(tileMatrix)) {\r\n tileMatrix.forEach((tm: any) => {\r\n this.tileMatrix.push(new TileMatrix(tm));\r\n });\r\n } else {\r\n this.tileMatrix.push(new TileMatrix(tileMatrix));\r\n }\r\n }\r\n }\r\n\r\n export class TileMatrix {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly scaleDenominator: number;\r\n public readonly topLeftCorner: Point2d;\r\n public readonly tileWidth: number;\r\n public readonly tileHeight: number;\r\n public readonly matrixWidth: number;\r\n public readonly matrixHeight: number;\r\n\r\n constructor(_json: any) {\r\n if (!_json)\r\n throw new Error(\"Invalid json data provided\");\r\n\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n if (!this.identifier)\r\n throw new Error(\"No Identifier found.\");\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.abstract = _json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n\r\n // Scale denominator\r\n const scaleDenomStr = _json[XmlConstants.SCALEDENOMINATOR_XMLTAG]?._text;\r\n if (!scaleDenomStr)\r\n throw new Error(\"No scale denominator found on TileMatrix.\");\r\n this.scaleDenominator = +scaleDenomStr;\r\n\r\n // Top left corner\r\n const topLeftCorner = _json[XmlConstants.TOPLEFTCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (topLeftCorner?.length !== 2)\r\n throw new Error(\"No TopLeftCorner found on TileMatrix.\");\r\n this.topLeftCorner = Point2d.create(topLeftCorner[0], topLeftCorner[1]);\r\n\r\n // Tile Width\r\n const tileWidthStr = _json[XmlConstants.TILEWIDTH_XMLTAG]?._text;\r\n if (!tileWidthStr)\r\n throw new Error(\"No tile width found on TileMatrix.\");\r\n this.tileWidth = +tileWidthStr;\r\n\r\n // Tile Height\r\n const tileHeightStr = _json[XmlConstants.TILEHEIGHT_XMLTAG]?._text;\r\n if (!tileHeightStr)\r\n throw new Error(\"No tile eight found on TileMatrix.\");\r\n this.tileHeight = +tileHeightStr;\r\n\r\n // Matrix Width\r\n const matrixWidthStr = _json[XmlConstants.MATRIXWIDTH_XMLTAG]?._text;\r\n if (!matrixWidthStr)\r\n throw new Error(\"No tile width found on TileMatrix.\");\r\n this.matrixWidth = +matrixWidthStr;\r\n\r\n // Matrix Height\r\n const matrixHeightStr = _json[XmlConstants.MATRIXHEIGHT_XMLTAG]?._text;\r\n if (!matrixHeightStr)\r\n throw new Error(\"No tile eight found on TileMatrix.\");\r\n this.matrixHeight = +matrixHeightStr;\r\n }\r\n }\r\n\r\n export class Layer {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly format?: string;\r\n public readonly wsg84BoundingBox?: MapCartoRectangle;\r\n public readonly boundingBox?: BoundingBox;\r\n public readonly styles: Style[] = [];\r\n public readonly tileMatrixSetLinks: TileMatrixSetLink[] = [];\r\n\r\n constructor(_json: any) {\r\n if (!_json)\r\n throw new Error(\"Invalid json data provided\");\r\n\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.format = _json.Format?._text;\r\n\r\n // BoundingBox\r\n this.boundingBox = (_json[OwsConstants.BOUNDINGBOX_XMLTAG] ? new BoundingBox(_json[OwsConstants.BOUNDINGBOX_XMLTAG]) : undefined);\r\n\r\n // WSG84 BoundingBox\r\n const lowerCorner = _json[OwsConstants.WGS84BOUNDINGBOX_XMLTAG]?.[OwsConstants.LOWERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n const upperCorner = _json[OwsConstants.WGS84BOUNDINGBOX_XMLTAG]?.[OwsConstants.UPPERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (lowerCorner?.length === 2 && upperCorner?.length === 2)\r\n this.wsg84BoundingBox = MapCartoRectangle.createFromDegrees(lowerCorner[0], lowerCorner[1], upperCorner[0], upperCorner[1]);\r\n\r\n // If we could not initialized WSG84 bounding box, attempt to initialized it from Bounding Box\r\n if (!this.wsg84BoundingBox && (this.boundingBox?.crs?.includes(\"EPSG:4326\") || this.boundingBox?.crs?.includes(\"CRS:84\"))) {\r\n this.wsg84BoundingBox = MapCartoRectangle.createFromDegrees(this.boundingBox.range?.low.x, this.boundingBox.range?.low.y, this.boundingBox.range?.high.x, this.boundingBox.range?.high.y);\r\n }\r\n\r\n // Style\r\n if (Array.isArray(_json.Style)) {\r\n _json.Style.forEach((style: any) => {\r\n this.styles.push(new Style(style));\r\n });\r\n } else if (_json.Style) {\r\n this.styles.push(new Style(_json.Style));\r\n }\r\n\r\n // TileMatrixSetLink\r\n // TileMatrixSetLink is mandatory on Layer, if it doesn't exists, something is OFF with the capability.\r\n const tileMatrixSetLink = _json[XmlConstants.TILEMATRIXSETLINK_XMLTAG];\r\n\r\n if (!tileMatrixSetLink)\r\n throw new Error(\"No matrix set link found for WMTS layer\");\r\n\r\n if (Array.isArray(tileMatrixSetLink)) {\r\n tileMatrixSetLink.forEach((tmsl: any) => {\r\n this.tileMatrixSetLinks.push(new TileMatrixSetLink(tmsl));\r\n });\r\n } else {\r\n this.tileMatrixSetLinks.push(new TileMatrixSetLink(tileMatrixSetLink));\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class WmtsCapabilities {\r\n private static _capabilitiesCache = new Map<string, WmtsCapabilities | undefined>();\r\n\r\n public get json() { return this._json; }\r\n\r\n public readonly version?: string;\r\n public readonly serviceIdentification?: WmtsCapability.ServiceIdentification;\r\n public readonly contents?: WmtsCapability.Contents;\r\n\r\n public readonly operationsMetadata?: WmtsCapability.OperationMetadata;\r\n\r\n constructor(private _json: any) {\r\n // Capabilities version\r\n this.version = _json?.Capabilities?._attributes.version;\r\n\r\n // Service Identification\r\n if (_json?.Capabilities?.[WmtsCapability.OwsConstants.SERVICEIDENTIFICATION_XMLTAG])\r\n this.serviceIdentification = new WmtsCapability.ServiceIdentification(_json?.Capabilities?.[WmtsCapability.OwsConstants.SERVICEIDENTIFICATION_XMLTAG]);\r\n\r\n // Operations metadata\r\n if (_json?.Capabilities?.[WmtsCapability.OwsConstants.OPERATIONSMETADATA_XMLTAG])\r\n this.operationsMetadata = new WmtsCapability.OperationMetadata(_json?.Capabilities?.[WmtsCapability.OwsConstants.OPERATIONSMETADATA_XMLTAG]);\r\n\r\n // Contents\r\n if (_json.Capabilities?.Contents)\r\n this.contents = new WmtsCapability.Contents(_json.Capabilities?.Contents);\r\n }\r\n\r\n public static createFromXml(xmlCapabilities: string): WmtsCapabilities | undefined {\r\n const jsonCapabilities = xml2json(xmlCapabilities, { compact: true, nativeType: false, ignoreComment: true });\r\n const capabilities = JSON.parse(jsonCapabilities);\r\n return new WmtsCapabilities(capabilities);\r\n }\r\n\r\n public static async create(url: string, credentials?: RequestBasicCredentials, ignoreCache?: boolean): Promise<WmtsCapabilities | undefined> {\r\n if (!ignoreCache) {\r\n const cached = WmtsCapabilities._capabilitiesCache.get(url);\r\n if (cached !== undefined)\r\n return cached;\r\n }\r\n\r\n const xmlCapabilities = await getXml(`${WmsUtilities.getBaseUrl(url)}?request=GetCapabilities&service=WMTS`, credentials);\r\n\r\n if (!xmlCapabilities)\r\n return undefined;\r\n\r\n const capabilities = WmtsCapabilities.createFromXml(xmlCapabilities);\r\n if (capabilities)\r\n WmtsCapabilities._capabilitiesCache.set(url, capabilities);\r\n\r\n return capabilities;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WmtsCapabilities.js","sourceRoot":"","sources":["../../../../src/tile/map/WmtsCapabilities.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAwD;AACxD,mDAAyF;AACzF,mCAAkC;AAClC,0CAA8D,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CAAC,YAAY,0CAAE,QAAQ,CAAC,CAAC;IAC9E,CAAC;IAvBD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAyBjC,MAAM,CAAC,aAAa,CAAC,eAAuB;QACjD,MAAM,gBAAgB,GAAG,IAAA,iBAAQ,EAAC,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9G,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAClD,OAAO,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,WAAqC,EAAE,WAAqB;QAClG,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,MAAM,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5D,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,MAAM,CAAC;SACjB;QAED,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,GAAG,uBAAY,CAAC,UAAU,CAAC,GAAG,CAAC,uCAAuC,EAAE,WAAW,CAAC,CAAC;QAE1H,IAAI,CAAC,eAAe;YAClB,OAAO,SAAS,CAAC;QAEnB,MAAM,YAAY,GAAG,gBAAgB,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACrE,IAAI,YAAY;YACd,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAE7D,OAAO,YAAY,CAAC;IACtB,CAAC;;AAnDH,4CAoDC;AAnDgB,mCAAkB,GAAG,IAAI,GAAG,EAAwC,CAAC","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 Views\r\n */\r\n\r\nimport { Point2d, Range2d } from \"@itwin/core-geometry\";\r\nimport { request, RequestBasicCredentials, RequestOptions } from \"../../request/Request\";\r\nimport { xml2json } from \"xml-js\";\r\nimport { MapCartoRectangle, WmsUtilities } from \"../internal\"; // WmsUtilities needed for getBaseUrl\r\n\r\n/**\r\n * fetch XML from HTTP request\r\n * @param url server URL to address the request\r\n * @internal\r\n */\r\nasync function getXml(url: string, credentials?: RequestBasicCredentials): Promise<any> {\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"text\",\r\n timeout: { response: 20000 },\r\n retries: 2,\r\n auth: credentials,\r\n };\r\n const data = await request(url, options);\r\n return data.text;\r\n}\r\n\r\n/** Encapsulation of the capabilities for an WMTS server\r\n * @internal\r\n */\r\nexport namespace WmtsCapability {\r\n\r\n export abstract class OwsConstants {\r\n // OWS xml tag names\r\n public static readonly ABSTRACT_XMLTAG = \"ows:Abstract\";\r\n public static readonly ACCESSCONSTRAINTS_XMLTAG = \"ows:AccessConstraints\";\r\n public static readonly ALLOWEDVALUES_XMLTAG = \"ows:AllowedValues\";\r\n public static readonly BOUNDINGBOX_XMLTAG = \"ows:BoundingBox\";\r\n public static readonly CONSTRAINT_XMLTAG = \"ows:Constraint\";\r\n public static readonly DCP_XMLTAG = \"ows:DCP\";\r\n public static readonly FEES_XMLTAG = \"ows:Fees\";\r\n public static readonly GET_XMLTAG = \"ows:Get\";\r\n public static readonly HTTP_XMLTAG = \"ows:HTTP\";\r\n public static readonly IDENTIFIER_XMLTAG = \"ows:Identifier\";\r\n public static readonly KEYWORDS_XMLTAG = \"ows:Keywords\";\r\n public static readonly KEYWORD_XMLTAG = \"ows:Keyword\";\r\n public static readonly LOWERCORNER_XMLTAG = \"ows:LowerCorner\";\r\n public static readonly OPERATION_XMLTAG = \"ows:Operation\";\r\n public static readonly OPERATIONSMETADATA_XMLTAG = \"ows:OperationsMetadata\";\r\n public static readonly POST_XMLTAG = \"ows:Post\";\r\n public static readonly SERVICEIDENTIFICATION_XMLTAG = \"ows:ServiceIdentification\";\r\n public static readonly SERVICETYPE_XMLTAG = \"ows:ServiceType\";\r\n public static readonly SERVICETYPEVERSION_XMLTAG = \"ows:ServiceTypeVersion\";\r\n public static readonly SUPPORTEDCRS_XMLTAG = \"ows:SupportedCRS\";\r\n public static readonly TITLE_XMLTAG = \"ows:Title\";\r\n public static readonly UPPERCORNER_XMLTAG = \"ows:UpperCorner\";\r\n public static readonly VALUE_XMLTAG = \"ows:Value\";\r\n public static readonly WGS84BOUNDINGBOX_XMLTAG = \"ows:WGS84BoundingBox\";\r\n }\r\n\r\n export abstract class XmlConstants {\r\n // Operations names\r\n public static readonly GETCAPABILITIES = \"GetCapabilities\";\r\n public static readonly GETTILE = \"GetTile\";\r\n public static readonly GETFEATUREINFO = \"GetFeatureInfo\";\r\n\r\n public static readonly MATRIXWIDTH_XMLTAG = \"MatrixWidth\";\r\n public static readonly MATRIXHEIGHT_XMLTAG = \"MatrixHeight\";\r\n public static readonly SCALEDENOMINATOR_XMLTAG = \"ScaleDenominator\";\r\n\r\n public static readonly TILEHEIGHT_XMLTAG = \"TileHeight\";\r\n public static readonly TILEMATRIX_XMLTAG = \"TileMatrix\";\r\n public static readonly TILEMATRIXSETLINK_XMLTAG = \"TileMatrixSetLink\";\r\n public static readonly TILEWIDTH_XMLTAG = \"TileWidth\";\r\n public static readonly TOPLEFTCORNER_XMLTAG = \"TopLeftCorner\";\r\n public static readonly WELLKNOWNSCALESET_XMLTAG = \"WellKnownScaleSet\";\r\n\r\n public static readonly CONSTRAINT_NAME_FILTER = \"Encoding\";\r\n public static readonly STYLE_ISDEFAULT = \"IsDefault\";\r\n public static readonly XLINK_HREF = \"xlink:href\";\r\n }\r\n\r\n export abstract class Constants {\r\n public static readonly GOOGLEMAPS_LEVEL0_SCALE_DENOM = 559082264.0287178;\r\n public static readonly GOOGLEMAPS_COMPATIBLE_WELLKNOWNNAME = \"googlemapscompatible\";\r\n }\r\n\r\n export class ServiceIdentification {\r\n public readonly abstract?: string;\r\n public readonly accessConstraints?: string;\r\n public readonly fees?: string;\r\n public readonly serviceType?: string;\r\n public readonly serviceTypeVersion?: string;\r\n public readonly title?: string;\r\n public readonly keywords?: string[];\r\n\r\n constructor(json: any) {\r\n this.abstract = json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n this.serviceType = json[OwsConstants.SERVICETYPE_XMLTAG]?._text;\r\n this.serviceTypeVersion = json[OwsConstants.SERVICETYPEVERSION_XMLTAG]?._text;\r\n this.title = json[OwsConstants.TITLE_XMLTAG]?._text;\r\n\r\n const keywords = json[OwsConstants.KEYWORDS_XMLTAG]?.[OwsConstants.KEYWORD_XMLTAG];\r\n if (keywords !== undefined) {\r\n this.keywords = [];\r\n\r\n if (Array.isArray(keywords)) {\r\n for (const keyword of keywords) {\r\n if (keyword !== undefined) {\r\n this.keywords.push(keyword._text);\r\n }\r\n }\r\n } else {\r\n this.keywords.push(keywords._text);\r\n }\r\n }\r\n\r\n this.accessConstraints = json[OwsConstants.ACCESSCONSTRAINTS_XMLTAG]?._text;\r\n this.fees = json[OwsConstants.FEES_XMLTAG]?._text;\r\n }\r\n }\r\n\r\n export class OperationMetadata {\r\n private _getCapabilities?: Operation;\r\n public get getCapabilities(): Operation | undefined { return this._getCapabilities; }\r\n\r\n private _getFeatureInfo?: Operation;\r\n public get getFeatureInfo(): Operation | undefined { return this._getFeatureInfo; }\r\n\r\n private _getTile?: Operation;\r\n public get getTile(): Operation | undefined { return this._getTile; }\r\n\r\n private readOperation(op: any) {\r\n if (op?._attributes?.name === XmlConstants.GETCAPABILITIES)\r\n this._getCapabilities = new Operation(op);\r\n else if (op?._attributes?.name === XmlConstants.GETTILE)\r\n this._getTile = new Operation(op);\r\n else if (op?._attributes?.name === XmlConstants.GETFEATUREINFO)\r\n this._getFeatureInfo = new Operation(op);\r\n }\r\n\r\n constructor(json: any) {\r\n const operation = (json ? json[OwsConstants.OPERATION_XMLTAG] : undefined);\r\n if (operation) {\r\n if (Array.isArray(operation)) {\r\n operation.forEach((op: any) => {\r\n this.readOperation(op);\r\n });\r\n } else {\r\n this.readOperation(operation);\r\n }\r\n }\r\n }\r\n }\r\n\r\n export class HttpDcp {\r\n public readonly url?: string;\r\n public readonly constraintName?: string;\r\n\r\n // For simplicity of use we create a 'static' encoding property instead of having\r\n // a generic constraint data model.\r\n // We make sure the constraint name is 'encoding' related.\r\n public readonly encoding?: string;\r\n\r\n constructor(json: any) {\r\n this.url = json?._attributes[XmlConstants.XLINK_HREF];\r\n this.constraintName = (json ? json[OwsConstants.CONSTRAINT_XMLTAG]?._attributes?.name : undefined);\r\n if (this.constraintName?.endsWith(XmlConstants.CONSTRAINT_NAME_FILTER))\r\n this.encoding = json[OwsConstants.CONSTRAINT_XMLTAG]?.[OwsConstants.ALLOWEDVALUES_XMLTAG]?.[OwsConstants.VALUE_XMLTAG]?._text;\r\n }\r\n }\r\n\r\n export class Operation {\r\n public readonly name?: string;\r\n private _getDcpHttp?: HttpDcp[];\r\n public get getDcpHttp(): HttpDcp[] | undefined { return this._getDcpHttp; }\r\n private _postDcpHttp?: HttpDcp[];\r\n public get postDcpHttp(): HttpDcp[] | undefined { return this._postDcpHttp; }\r\n\r\n constructor(json: any) {\r\n this.name = json?._attributes?.name;\r\n\r\n const dcpHttp = (json ? json[OwsConstants.DCP_XMLTAG]?.[OwsConstants.HTTP_XMLTAG] : undefined);\r\n if (!dcpHttp)\r\n return;\r\n\r\n const get = dcpHttp[OwsConstants.GET_XMLTAG];\r\n if (get) {\r\n this._getDcpHttp = [];\r\n\r\n if (Array.isArray(get)) {\r\n get.forEach((getItem: any) => {\r\n this._getDcpHttp?.push(new WmtsCapability.HttpDcp(getItem));\r\n });\r\n } else {\r\n this._getDcpHttp?.push(new WmtsCapability.HttpDcp(get));\r\n }\r\n }\r\n\r\n const post = dcpHttp[OwsConstants.POST_XMLTAG];\r\n if (post) {\r\n this._postDcpHttp = [];\r\n\r\n if (Array.isArray(post)) {\r\n post.forEach((postItem: any) => {\r\n this._postDcpHttp?.push(new WmtsCapability.HttpDcp(postItem));\r\n });\r\n } else {\r\n this._postDcpHttp?.push(new WmtsCapability.HttpDcp(post));\r\n }\r\n }\r\n }\r\n }\r\n\r\n export class Contents {\r\n public readonly layers: WmtsCapability.Layer[] = [];\r\n public readonly tileMatrixSets: WmtsCapability.TileMatrixSet[] = [];\r\n\r\n constructor(private _json: any) {\r\n\r\n // Layers\r\n const jsonLayer = _json?.Layer;\r\n if (jsonLayer) {\r\n if (Array.isArray(jsonLayer)) {\r\n jsonLayer.forEach((layer: any) => {\r\n this.layers.push(new WmtsCapability.Layer(layer));\r\n });\r\n } else {\r\n this.layers.push(new WmtsCapability.Layer(jsonLayer));\r\n }\r\n }\r\n\r\n // TileMatrixSet\r\n const jsonTileMatrixSet = _json?.TileMatrixSet;\r\n if (jsonTileMatrixSet) {\r\n if (Array.isArray(jsonTileMatrixSet)) {\r\n jsonTileMatrixSet.forEach((matrixSet: any) => {\r\n this.tileMatrixSets.push(new WmtsCapability.TileMatrixSet(matrixSet));\r\n });\r\n } else {\r\n this.tileMatrixSets.push(new WmtsCapability.TileMatrixSet(jsonTileMatrixSet));\r\n }\r\n }\r\n }\r\n\r\n public getGoogleMapsCompatibleTileMatrixSet(): WmtsCapability.TileMatrixSet[] {\r\n const googleMapsTms: WmtsCapability.TileMatrixSet[] = [];\r\n this.tileMatrixSets.forEach((tms) => {\r\n if (tms.wellKnownScaleSet?.toLowerCase().includes(Constants.GOOGLEMAPS_COMPATIBLE_WELLKNOWNNAME))\r\n googleMapsTms.push(tms);\r\n\r\n // In case wellKnownScaleSet was not been set properly, infer from scaleDenominator\r\n // Note: some servers are quite inaccurate in their scale values, hence I used a delta value of 1.\r\n else if (tms.tileMatrix.length > 0\r\n && Math.abs(tms.tileMatrix[0].scaleDenominator - Constants.GOOGLEMAPS_LEVEL0_SCALE_DENOM) < 1\r\n && (tms.supportedCrs.includes(\"3857\") || tms.supportedCrs.includes(\"900913\")))\r\n googleMapsTms.push(tms);\r\n });\r\n return googleMapsTms;\r\n }\r\n\r\n public getEpsg4326CompatibleTileMatrixSet(): WmtsCapability.TileMatrixSet[] {\r\n return this.tileMatrixSets.filter((tms) => tms.supportedCrs.includes(\"4326\"));\r\n }\r\n }\r\n\r\n export class Style {\r\n public readonly isDefault: boolean = false;\r\n public readonly title?: string;\r\n public readonly identifier?: string;\r\n // TODO: LegendURL\r\n\r\n constructor(private _json: any) {\r\n if (!_json)\r\n return;\r\n\r\n if (_json._attributes?.isDefault)\r\n this.isDefault = _json._attributes.isDefault.toLowerCase() === \"true\";\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n }\r\n }\r\n export class BoundingBox {\r\n public readonly crs?: string;\r\n public readonly range?: Range2d;\r\n\r\n constructor(_json: any) {\r\n this.crs = _json._attributes?.crs;\r\n const lowerCorner = _json[OwsConstants.LOWERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n const upperCorner = _json[OwsConstants.UPPERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (lowerCorner.length === 2 && upperCorner.length === 2)\r\n this.range = Range2d.createXYXY(lowerCorner[0], lowerCorner[1], upperCorner[0], upperCorner[1]);\r\n }\r\n }\r\n\r\n export class TileMatrixSetLimits {\r\n public limits?: Range2d;\r\n public tileMatrix?: string;\r\n\r\n constructor(_json: any) {\r\n this.tileMatrix = _json.TileMatrix;\r\n if (_json.MinTileRow !== undefined && _json.MaxTileRow !== undefined && _json.MinTileCol !== undefined && _json.MaxTileCol)\r\n this.limits = Range2d.createXYXY(Number(_json.MinTileCol._text), Number(_json.MinTileRow._text), Number(_json.MaxTileCol._text), Number(_json.MaxTileRow._text));\r\n }\r\n }\r\n\r\n export class TileMatrixSetLink {\r\n public readonly tileMatrixSet: string;\r\n public readonly tileMatrixSetLimits = new Array<TileMatrixSetLimits>();\r\n\r\n constructor(_json: any) {\r\n this.tileMatrixSet = (_json?.TileMatrixSet?._text ? _json.TileMatrixSet._text : \"\");\r\n const tileMatrixLimits = _json?.TileMatrixSetLimits?.TileMatrixLimits;\r\n if (Array.isArray(tileMatrixLimits))\r\n tileMatrixLimits.forEach((tml: any) => this.tileMatrixSetLimits.push(new TileMatrixSetLimits(tml)));\r\n }\r\n }\r\n\r\n export class TileMatrixSet {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly supportedCrs: string;\r\n public readonly wellKnownScaleSet: string;\r\n public readonly tileMatrix: TileMatrix[] = [];\r\n\r\n constructor(_json: any) {\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n if (!this.identifier)\r\n throw new Error(\"No Identifier found.\");\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.abstract = _json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n this.supportedCrs = _json[OwsConstants.SUPPORTEDCRS_XMLTAG]?._text;\r\n if (!this.supportedCrs)\r\n throw new Error(\"No supported CRS found.\");\r\n\r\n this.wellKnownScaleSet = _json[XmlConstants.WELLKNOWNSCALESET_XMLTAG]?._text;\r\n\r\n // TileMatrix:\r\n // TileMatrix is mandatory on TileMatrixSet, if it doesn't exists, something is OFF with the capability.\r\n const tileMatrix = _json[XmlConstants.TILEMATRIX_XMLTAG];\r\n if (!tileMatrix)\r\n throw new Error(\"No matrix set link found for WMTS layer\");\r\n\r\n if (Array.isArray(tileMatrix)) {\r\n tileMatrix.forEach((tm: any) => {\r\n this.tileMatrix.push(new TileMatrix(tm));\r\n });\r\n } else {\r\n this.tileMatrix.push(new TileMatrix(tileMatrix));\r\n }\r\n }\r\n }\r\n\r\n export class TileMatrix {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly scaleDenominator: number;\r\n public readonly topLeftCorner: Point2d;\r\n public readonly tileWidth: number;\r\n public readonly tileHeight: number;\r\n public readonly matrixWidth: number;\r\n public readonly matrixHeight: number;\r\n\r\n constructor(_json: any) {\r\n if (!_json)\r\n throw new Error(\"Invalid json data provided\");\r\n\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n if (!this.identifier)\r\n throw new Error(\"No Identifier found.\");\r\n\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.abstract = _json[OwsConstants.ABSTRACT_XMLTAG]?._text;\r\n\r\n // Scale denominator\r\n const scaleDenomStr = _json[XmlConstants.SCALEDENOMINATOR_XMLTAG]?._text;\r\n if (!scaleDenomStr)\r\n throw new Error(\"No scale denominator found on TileMatrix.\");\r\n this.scaleDenominator = +scaleDenomStr;\r\n\r\n // Top left corner\r\n const topLeftCorner = _json[XmlConstants.TOPLEFTCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (topLeftCorner?.length !== 2)\r\n throw new Error(\"No TopLeftCorner found on TileMatrix.\");\r\n this.topLeftCorner = Point2d.create(topLeftCorner[0], topLeftCorner[1]);\r\n\r\n // Tile Width\r\n const tileWidthStr = _json[XmlConstants.TILEWIDTH_XMLTAG]?._text;\r\n if (!tileWidthStr)\r\n throw new Error(\"No tile width found on TileMatrix.\");\r\n this.tileWidth = +tileWidthStr;\r\n\r\n // Tile Height\r\n const tileHeightStr = _json[XmlConstants.TILEHEIGHT_XMLTAG]?._text;\r\n if (!tileHeightStr)\r\n throw new Error(\"No tile eight found on TileMatrix.\");\r\n this.tileHeight = +tileHeightStr;\r\n\r\n // Matrix Width\r\n const matrixWidthStr = _json[XmlConstants.MATRIXWIDTH_XMLTAG]?._text;\r\n if (!matrixWidthStr)\r\n throw new Error(\"No tile width found on TileMatrix.\");\r\n this.matrixWidth = +matrixWidthStr;\r\n\r\n // Matrix Height\r\n const matrixHeightStr = _json[XmlConstants.MATRIXHEIGHT_XMLTAG]?._text;\r\n if (!matrixHeightStr)\r\n throw new Error(\"No tile eight found on TileMatrix.\");\r\n this.matrixHeight = +matrixHeightStr;\r\n }\r\n }\r\n\r\n export class Layer {\r\n public readonly identifier: string;\r\n public readonly title?: string;\r\n public readonly abstract?: string;\r\n public readonly format?: string;\r\n public readonly wsg84BoundingBox?: MapCartoRectangle;\r\n public readonly boundingBox?: BoundingBox;\r\n public readonly styles: Style[] = [];\r\n public readonly tileMatrixSetLinks: TileMatrixSetLink[] = [];\r\n\r\n constructor(_json: any) {\r\n if (!_json)\r\n throw new Error(\"Invalid json data provided\");\r\n\r\n this.identifier = _json[OwsConstants.IDENTIFIER_XMLTAG]?._text;\r\n this.title = _json[OwsConstants.TITLE_XMLTAG]?._text;\r\n this.format = _json.Format?._text;\r\n\r\n // BoundingBox\r\n this.boundingBox = (_json[OwsConstants.BOUNDINGBOX_XMLTAG] ? new BoundingBox(_json[OwsConstants.BOUNDINGBOX_XMLTAG]) : undefined);\r\n\r\n // WSG84 BoundingBox\r\n const lowerCorner = _json[OwsConstants.WGS84BOUNDINGBOX_XMLTAG]?.[OwsConstants.LOWERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n const upperCorner = _json[OwsConstants.WGS84BOUNDINGBOX_XMLTAG]?.[OwsConstants.UPPERCORNER_XMLTAG]?._text?.split(\" \").map((x: string) => +x);\r\n if (lowerCorner?.length === 2 && upperCorner?.length === 2)\r\n this.wsg84BoundingBox = MapCartoRectangle.createFromDegrees(lowerCorner[0], lowerCorner[1], upperCorner[0], upperCorner[1]);\r\n\r\n // If we could not initialized WSG84 bounding box, attempt to initialized it from Bounding Box\r\n if (!this.wsg84BoundingBox && (this.boundingBox?.crs?.includes(\"EPSG:4326\") || this.boundingBox?.crs?.includes(\"CRS:84\"))) {\r\n this.wsg84BoundingBox = MapCartoRectangle.createFromDegrees(this.boundingBox.range?.low.x, this.boundingBox.range?.low.y, this.boundingBox.range?.high.x, this.boundingBox.range?.high.y);\r\n }\r\n\r\n // Style\r\n if (Array.isArray(_json.Style)) {\r\n _json.Style.forEach((style: any) => {\r\n this.styles.push(new Style(style));\r\n });\r\n } else if (_json.Style) {\r\n this.styles.push(new Style(_json.Style));\r\n }\r\n\r\n // TileMatrixSetLink\r\n // TileMatrixSetLink is mandatory on Layer, if it doesn't exists, something is OFF with the capability.\r\n const tileMatrixSetLink = _json[XmlConstants.TILEMATRIXSETLINK_XMLTAG];\r\n\r\n if (!tileMatrixSetLink)\r\n throw new Error(\"No matrix set link found for WMTS layer\");\r\n\r\n if (Array.isArray(tileMatrixSetLink)) {\r\n tileMatrixSetLink.forEach((tmsl: any) => {\r\n this.tileMatrixSetLinks.push(new TileMatrixSetLink(tmsl));\r\n });\r\n } else {\r\n this.tileMatrixSetLinks.push(new TileMatrixSetLink(tileMatrixSetLink));\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class WmtsCapabilities {\r\n private static _capabilitiesCache = new Map<string, WmtsCapabilities | undefined>();\r\n\r\n public get json() { return this._json; }\r\n\r\n public readonly version?: string;\r\n public readonly serviceIdentification?: WmtsCapability.ServiceIdentification;\r\n public readonly contents?: WmtsCapability.Contents;\r\n\r\n public readonly operationsMetadata?: WmtsCapability.OperationMetadata;\r\n\r\n constructor(private _json: any) {\r\n // Capabilities version\r\n this.version = _json?.Capabilities?._attributes.version;\r\n\r\n // Service Identification\r\n if (_json?.Capabilities?.[WmtsCapability.OwsConstants.SERVICEIDENTIFICATION_XMLTAG])\r\n this.serviceIdentification = new WmtsCapability.ServiceIdentification(_json?.Capabilities?.[WmtsCapability.OwsConstants.SERVICEIDENTIFICATION_XMLTAG]);\r\n\r\n // Operations metadata\r\n if (_json?.Capabilities?.[WmtsCapability.OwsConstants.OPERATIONSMETADATA_XMLTAG])\r\n this.operationsMetadata = new WmtsCapability.OperationMetadata(_json?.Capabilities?.[WmtsCapability.OwsConstants.OPERATIONSMETADATA_XMLTAG]);\r\n\r\n // Contents\r\n if (_json.Capabilities?.Contents)\r\n this.contents = new WmtsCapability.Contents(_json.Capabilities?.Contents);\r\n }\r\n\r\n public static createFromXml(xmlCapabilities: string): WmtsCapabilities | undefined {\r\n const jsonCapabilities = xml2json(xmlCapabilities, { compact: true, nativeType: false, ignoreComment: true });\r\n const capabilities = JSON.parse(jsonCapabilities);\r\n return new WmtsCapabilities(capabilities);\r\n }\r\n\r\n public static async create(url: string, credentials?: RequestBasicCredentials, ignoreCache?: boolean): Promise<WmtsCapabilities | undefined> {\r\n if (!ignoreCache) {\r\n const cached = WmtsCapabilities._capabilitiesCache.get(url);\r\n if (cached !== undefined)\r\n return cached;\r\n }\r\n\r\n const xmlCapabilities = await getXml(`${WmsUtilities.getBaseUrl(url)}?request=GetCapabilities&service=WMTS`, credentials);\r\n\r\n if (!xmlCapabilities)\r\n return undefined;\r\n\r\n const capabilities = WmtsCapabilities.createFromXml(xmlCapabilities);\r\n if (capabilities)\r\n WmtsCapabilities._capabilitiesCache.set(url, capabilities);\r\n\r\n return capabilities;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApproximateTerrainHeights.d.ts","sourceRoot":"","sources":["../../src/ApproximateTerrainHeights.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAA0B,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKjE;;;GAGG;AACH,qBAAa,yBAAyB;IACpC,gBAAuB,QAAQ,KAAK;IACpC,SAAgB,iBAAiB,UAAiC;IAClE,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgH;IAChJ,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwB;IAEvD,WAAkB,QAAQ,IAAI,yBAAyB,CAKtD;IAED;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ApproximateTerrainHeights.d.ts","sourceRoot":"","sources":["../../src/ApproximateTerrainHeights.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAA0B,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKjE;;;GAGG;AACH,qBAAa,yBAAyB;IACpC,gBAAuB,QAAQ,KAAK;IACpC,SAAgB,iBAAiB,UAAiC;IAClE,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgH;IAChJ,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwB;IAEvD,WAAkB,QAAQ,IAAI,yBAAyB,CAKtD;IAED;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAsB7D,wBAAwB,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAmB9E,OAAO,CAAC,eAAe;CA0CxB"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
9
|
import { Point2d, Range1d } from "@itwin/core-geometry";
|
|
10
10
|
import { Cartographic } from "@itwin/core-common";
|
|
11
|
-
import {
|
|
11
|
+
import { request } from "./request/Request";
|
|
12
12
|
import { GeographicTilingScheme } from "./tile/internal";
|
|
13
13
|
import { IModelApp } from "./IModelApp";
|
|
14
14
|
let instance;
|
|
@@ -34,7 +34,11 @@ export class ApproximateTerrainHeights {
|
|
|
34
34
|
*/
|
|
35
35
|
async initialize() {
|
|
36
36
|
if (undefined === this._terrainHeights) {
|
|
37
|
-
|
|
37
|
+
const data = await request(`${IModelApp.publicPath}assets/approximateTerrainHeights.json`, {
|
|
38
|
+
method: "GET",
|
|
39
|
+
responseType: "json",
|
|
40
|
+
});
|
|
41
|
+
this._terrainHeights = data.body;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
getTileHeightRange(quadId, result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApproximateTerrainHeights.js","sourceRoot":"","sources":["../../src/ApproximateTerrainHeights.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAW,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ApproximateTerrainHeights.js","sourceRoot":"","sources":["../../src/ApproximateTerrainHeights.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAW,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAU,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,IAAI,QAA+C,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAAtC;QAEkB,sBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,6BAA6B;QAE/E,oBAAe,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,YAAY,CAAC,UAAU,EAAE,EAAE,YAAY,CAAC,UAAU,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a,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;gBACxE,IAAI,CAAC,KAAK,CAAC,EAAE;oBACX,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;oBACjC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;iBAClC;qBAAM,IAAI,QAAQ,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE;oBACnF,MAAM,GAAG,IAAI,CAAC;oBACd,MAAM;iBACP;aACF;YAED,IAAI,MAAM;gBACR,MAAM;YAER,UAAU,GAAG,QAAQ,CAAC;YACtB,UAAU,GAAG,QAAQ,CAAC;SACvB;QAED,IAAI,CAAC,KAAK,CAAC,EAAE;YACX,OAAO,SAAS,CAAC;SAClB;QAED,OAAO;YACL,CAAC,EAAE,UAAU;YACb,CAAC,EAAE,UAAU;YACb,KAAK,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SAC3C,CAAC;IACJ,CAAC;;AA9GsB,kCAAQ,GAAG,CAAC,CAAC","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 Views\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Point2d, Range1d, Range2d } from \"@itwin/core-geometry\";\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { request } from \"./request/Request\";\r\nimport { GeographicTilingScheme, QuadId } from \"./tile/internal\";\r\nimport { IModelApp } from \"./IModelApp\";\r\n\r\nlet instance: ApproximateTerrainHeights | undefined;\r\n\r\n/**\r\n * A collection of functions for approximating terrain height\r\n * @internal\r\n */\r\nexport class ApproximateTerrainHeights {\r\n public static readonly maxLevel = 6;\r\n public readonly globalHeightRange = Range1d.createXX(-400, 90000); // Dead Sea to Mount Everest.\r\n private _terrainHeights: any;\r\n private readonly _scratchCorners = [Cartographic.createZero(), Cartographic.createZero(), Cartographic.createZero(), Cartographic.createZero()];\r\n private readonly _tilingScheme = new GeographicTilingScheme(2, 1, true); // Y at top... ?\r\n private readonly _scratchTileXY = Point2d.createZero();\r\n\r\n public static get instance(): ApproximateTerrainHeights {\r\n if (undefined === instance)\r\n instance = new ApproximateTerrainHeights();\r\n\r\n return instance;\r\n }\r\n\r\n /**\r\n * Initializes the minimum and maximum terrain heights.\r\n * @return {Promise}\r\n */\r\n public async initialize(): Promise<void> {\r\n if (undefined === this._terrainHeights) {\r\n const data = await request(`${IModelApp.publicPath}assets/approximateTerrainHeights.json`, {\r\n method: \"GET\",\r\n responseType: \"json\",\r\n });\r\n this._terrainHeights = data.body;\r\n }\r\n }\r\n\r\n public getTileHeightRange(quadId: QuadId, result?: Range1d): Range1d {\r\n result = Range1d.createFrom(this.globalHeightRange, result);\r\n if (undefined === this._terrainHeights)\r\n return result; // Not initialized.\r\n\r\n let level = quadId.level, column = quadId.column, row = quadId.row;\r\n if (level > 6) {\r\n column = column >> (level - 6);\r\n row = row >> quadId.row >> ((level - 6));\r\n level = 6;\r\n }\r\n\r\n const key = `${level}-${column}-${row}`;\r\n const heights = this._terrainHeights[key];\r\n assert(undefined !== heights);\r\n\r\n result.low = heights[0];\r\n result.high = heights[1];\r\n\r\n return result;\r\n }\r\n\r\n public getMinimumMaximumHeights(rectangle: Range2d, result?: Range1d): Range1d {\r\n result = Range1d.createFrom(this.globalHeightRange, result);\r\n if (undefined === this._terrainHeights)\r\n return result; // Not initialized.\r\n\r\n const xyLevel = this._getTileXYLevel(rectangle);\r\n if (undefined !== xyLevel) {\r\n const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;\r\n const heights = this._terrainHeights[key];\r\n assert(undefined !== heights);\r\n if (undefined !== heights) {\r\n result.low = heights[0];\r\n result.high = heights[1];\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private _getTileXYLevel(rectangle: Range2d): { x: number, y: number, level: number } | undefined {\r\n Cartographic.fromRadians({ longitude: rectangle.low.x, latitude: rectangle.high.y, height: 0.0 }, this._scratchCorners[0]);\r\n Cartographic.fromRadians({ longitude: rectangle.high.x, latitude: rectangle.high.y, height: 0.0 }, this._scratchCorners[1]);\r\n Cartographic.fromRadians({ longitude: rectangle.low.x, latitude: rectangle.low.y, height: 0.0 }, this._scratchCorners[2]);\r\n Cartographic.fromRadians({ longitude: rectangle.high.x, latitude: rectangle.low.y, height: 0.0 }, this._scratchCorners[3]);\r\n\r\n // Determine which tile the bounding rectangle is in\r\n let lastLevelX = 0, lastLevelY = 0;\r\n let currentX = 0, currentY = 0;\r\n const maxLevel = ApproximateTerrainHeights.maxLevel;\r\n let i;\r\n for (i = 0; i <= maxLevel; ++i) {\r\n let failed = false;\r\n for (let j = 0; j < 4; ++j) {\r\n const corner = this._scratchCorners[j];\r\n this._tilingScheme.cartographicToTileXY(corner, i, this._scratchTileXY);\r\n if (j === 0) {\r\n currentX = this._scratchTileXY.x;\r\n currentY = this._scratchTileXY.y;\r\n } else if (currentX !== this._scratchTileXY.x || currentY !== this._scratchTileXY.y) {\r\n failed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (failed)\r\n break;\r\n\r\n lastLevelX = currentX;\r\n lastLevelY = currentY;\r\n }\r\n\r\n if (i === 0) {\r\n return undefined;\r\n }\r\n\r\n return {\r\n x: lastLevelX,\r\n y: lastLevelY,\r\n level: (i > maxLevel) ? maxLevel : (i - 1),\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -43,7 +43,7 @@ export declare class BackgroundMapGeometry {
|
|
|
43
43
|
getRayIntersection(ray: Ray3d, positiveOnly: boolean): Ray3d | undefined;
|
|
44
44
|
getPointHeight(point: Point3d): number | undefined;
|
|
45
45
|
/** @internal */
|
|
46
|
-
getFrustumIntersectionDepthRange(frustum: Frustum, heightRange?: Range1d, gridPlane?: Plane3dByOriginAndUnitNormal, doGlobalScope?: boolean): Range1d;
|
|
46
|
+
getFrustumIntersectionDepthRange(frustum: Frustum, bimRange: Range3d, heightRange?: Range1d, gridPlane?: Plane3dByOriginAndUnitNormal, doGlobalScope?: boolean): Range1d;
|
|
47
47
|
addFrustumDecorations(builder: GraphicBuilder, frustum: Frustum): void;
|
|
48
48
|
}
|
|
49
49
|
/** Calculate the ECEF to database (IModel) coordinate transform at a provided location, using the GCS of the iModel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackgroundMapGeometry.d.ts","sourceRoot":"","sources":["../../src/BackgroundMapGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAA2E,SAAS,EAA6C,QAAQ,EAAE,4BAA4B,EAAW,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAY,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9R,OAAO,EAAE,YAAY,EAAyB,OAAO,EAAkB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA4CzD,gBAAgB;AAChB,wBAAgB,qCAAqC,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAOpH;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAqBpB,OAAO,CAAC,iBAAiB;IAAgC,OAAO,CAAC,OAAO;IApBpF,SAAgB,SAAS,EAAE,SAAS,CAAC;IACrC,SAAgB,QAAQ,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACnE,SAAgB,WAAW,EAAE,OAAO,CAAC;IACrC,SAAgB,WAAW,EAAE,QAAQ,CAAC;IACtC,SAAgB,cAAc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AC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,4BAA4B,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO;IAuHxK,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO;CAoDvE;AAED;;;GAGG;AACH,wBAAsB,oCAAoC,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAsCtI"}
|
|
@@ -182,7 +182,7 @@ export class BackgroundMapGeometry {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
/** @internal */
|
|
185
|
-
getFrustumIntersectionDepthRange(frustum, heightRange, gridPlane, doGlobalScope) {
|
|
185
|
+
getFrustumIntersectionDepthRange(frustum, bimRange, heightRange, gridPlane, doGlobalScope) {
|
|
186
186
|
const clipPlanes = frustum.getRangePlanes(false, false, 0);
|
|
187
187
|
const eyePoint = frustum.getEyePoint(scratchEyePoint);
|
|
188
188
|
const viewRotation = frustum.getRotation(scratchViewRotation);
|
|
@@ -239,7 +239,7 @@ export class BackgroundMapGeometry {
|
|
|
239
239
|
}
|
|
240
240
|
else {
|
|
241
241
|
/* If parallel projection - clip toward side of ellipsoid with BIM geometry */
|
|
242
|
-
if (
|
|
242
|
+
if (Vector3d.createStartEnd(silhouette.center, bimRange.center).dotProduct(scratchSilhouetteNormal) < 0)
|
|
243
243
|
scratchSilhouetteNormal.negate(scratchSilhouetteNormal);
|
|
244
244
|
}
|
|
245
245
|
clipPlanes.planes.push(ClipPlane.createNormalAndDistance(scratchSilhouetteNormal, scratchSilhouetteNormal.dotProduct(silhouette.center)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackgroundMapGeometry.js","sourceRoot":"","sources":["../../src/BackgroundMapGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/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;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,SAAS,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,OAAO,EAAG,CAAC;AACpF,CAAC","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 Views\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Angle, Arc3d, ClipPlane, ClipPlaneContainment, Constant, CurvePrimitive, Ellipsoid, GrowableXYZArray, LongitudeLatitudeNumber, Matrix3d, Plane3dByOriginAndUnitNormal, Point2d, Point3d, Point4d, Range1d, Range3d, Ray3d, Transform, Vector3d, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorByName, ColorDef, Frustum, GeoCoordStatus, GlobeMode } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { GraphicBuilder } from \"./render/GraphicBuilder\";\r\nimport { WebMercatorTilingScheme } from \"./tile/internal\";\r\n\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchZeroPoint = Point3d.createZero();\r\nconst scratchPoint = Point3d.create();\r\nconst scratchVector = Vector3d.create();\r\nconst scratchCenterPoint = Point3d.createZero();\r\nconst scratchIntersectRay = Ray3d.create(Point3d.create(), Vector3d.create());\r\nconst scratchEyePoint = Point3d.createZero();\r\nconst scratchViewRotation = Matrix3d.createIdentity();\r\nconst scratchSilhouetteNormal = Vector3d.create();\r\nconst scratchCartoRectangle = new GrowableXYZArray();\r\nconst scratchWorkArray = new GrowableXYZArray();\r\n\r\nfunction accumulateDepthRange(point: Point3d, viewRotation: Matrix3d, range: Range3d) {\r\n viewRotation.multiplyXYZtoXYZ(point, scratchPoint);\r\n range.extend(scratchPoint);\r\n}\r\n\r\nfunction accumulateFrustumPlaneDepthRange(frustum: Frustum, plane: Plane3dByOriginAndUnitNormal, viewRotation: Matrix3d, range: Range3d, eyePoint?: Point3d) {\r\n let includeHorizon = false;\r\n for (let i = 0; i < 4; i++) {\r\n const frustumRay = Ray3d.createStartEnd(eyePoint ? eyePoint : frustum.points[i + 4], frustum.points[i]);\r\n const thisFraction = frustumRay.intersectionWithPlane(plane, scratchPoint);\r\n if (undefined !== thisFraction && (!eyePoint || thisFraction > 0))\r\n accumulateDepthRange(scratchPoint, viewRotation, range);\r\n else\r\n includeHorizon = true;\r\n }\r\n if (includeHorizon) {\r\n if (eyePoint !== undefined) {\r\n const eyeHeight = plane.altitude(eyePoint);\r\n if (eyeHeight < 0)\r\n accumulateDepthRange(eyePoint, viewRotation, range);\r\n else {\r\n const viewZ = viewRotation.getRow(2);\r\n const horizonDistance = Math.sqrt(eyeHeight * eyeHeight + 2 * eyeHeight * Constant.earthRadiusWGS84.equator);\r\n accumulateDepthRange(eyePoint.plusScaled(viewZ, -horizonDistance, scratchPoint), viewRotation, range);\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function getFrustumPlaneIntersectionDepthRange(frustum: Frustum, plane: Plane3dByOriginAndUnitNormal): Range1d {\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewRotation = frustum.getRotation(scratchViewRotation)!;\r\n const intersectRange = Range3d.createNull();\r\n accumulateFrustumPlaneDepthRange(frustum, plane, viewRotation, intersectRange, eyePoint);\r\n\r\n return intersectRange.isNull ? Range1d.createNull() : Range1d.createXX(intersectRange.low.z, intersectRange.high.z);\r\n}\r\n\r\n/** Geometry of background map - either an ellipsoid or a plane as defined by GlobeMode.\r\n * @internal\r\n */\r\nexport class BackgroundMapGeometry {\r\n public readonly globeMode: GlobeMode;\r\n public readonly geometry: Plane3dByOriginAndUnitNormal | Ellipsoid;\r\n public readonly globeOrigin: Point3d;\r\n public readonly globeMatrix: Matrix3d;\r\n public readonly cartesianRange: Range3d;\r\n public readonly cartesianTransitionRange: Range3d;\r\n public readonly cartesianPlane: Plane3dByOriginAndUnitNormal;\r\n public readonly cartesianDiagonal: number;\r\n public readonly cartesianChordHeight: number;\r\n public readonly maxGeometryChordHeight: number;\r\n private _mercatorFractionToDb: Transform;\r\n private _mercatorTilingScheme: WebMercatorTilingScheme;\r\n private _ecefToDb: Transform;\r\n public static maxCartesianDistance = 1E4; // If globe is 3D we still consider the map geometry flat within this distance of the project extents.\r\n private static _transitionDistanceMultiplier = .25; // In the transition range which extends beyond the cartesian range we interpolate between cartesian and ellipsoid.\r\n\r\n private static _scratchRayFractions = new Array<number>();\r\n private static _scratchRayAngles = new Array<LongitudeLatitudeNumber>();\r\n private static _scratchPoint = Point3d.createZero();\r\n\r\n constructor(private _bimElevationBias: number, globeMode: GlobeMode, private _iModel: IModelConnection) {\r\n this._ecefToDb = _iModel.getMapEcefToDb(_bimElevationBias);\r\n this.globeMode = globeMode;\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(_iModel);\r\n this.cartesianTransitionRange = this.cartesianRange.clone();\r\n this.cartesianTransitionRange.expandInPlace(BackgroundMapGeometry.getCartesianTransitionDistance(_iModel));\r\n this.cartesianDiagonal = this.cartesianRange.diagonal().magnitudeXY();\r\n const earthRadius = Constant.earthRadiusWGS84.equator;\r\n this.globeOrigin = this._ecefToDb.origin.cloneAsPoint3d();\r\n this.globeMatrix = this._ecefToDb.matrix.clone();\r\n this.cartesianChordHeight = Math.sqrt(this.cartesianDiagonal * this.cartesianDiagonal + earthRadius * earthRadius) - earthRadius; // Maximum chord height deviation of the cartesian area.\r\n const halfChordAngle = Angle.piOver2Radians / 10;\r\n this.maxGeometryChordHeight = (1 - Math.cos(halfChordAngle)) * earthRadius;\r\n this.cartesianPlane = this.getPlane();\r\n this.geometry = (globeMode === GlobeMode.Ellipsoid) ? this.getEarthEllipsoid() : this.cartesianPlane;\r\n this._mercatorTilingScheme = new WebMercatorTilingScheme();\r\n this._mercatorFractionToDb = this._mercatorTilingScheme.computeMercatorFractionToDb(this._ecefToDb, _bimElevationBias, _iModel, false);\r\n }\r\n public static getCartesianRange(iModel: IModelConnection, result?: Range3d): Range3d {\r\n const cartesianRange = Range3d.createFrom(iModel.projectExtents, result);\r\n cartesianRange.expandInPlace(BackgroundMapGeometry.maxCartesianDistance);\r\n return cartesianRange;\r\n }\r\n public static getCartesianTransitionDistance(iModel: IModelConnection): number {\r\n return BackgroundMapGeometry.getCartesianRange(iModel, scratchRange).diagonal().magnitudeXY() * BackgroundMapGeometry._transitionDistanceMultiplier;\r\n }\r\n\r\n public async dbToCartographicFromGcs(db: XYAndZ, result?: Cartographic): Promise<Cartographic> {\r\n return this.cartesianRange.containsPoint(Point3d.createFrom(db)) ? this._iModel.spatialToCartographic(db, result) : this.dbToCartographic(db, result);\r\n }\r\n\r\n public dbToCartographic(db: XYAndZ, result?: Cartographic): Cartographic {\r\n if (undefined === result)\r\n result = Cartographic.createZero();\r\n\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const mercatorFraction = this._mercatorFractionToDb.multiplyInversePoint3d(db)!;\r\n return this._mercatorTilingScheme.fractionToCartographic(mercatorFraction.x, mercatorFraction.y, result, mercatorFraction.z);\r\n } else {\r\n const ecef = this._ecefToDb.multiplyInversePoint3d(db)!;\r\n return Cartographic.fromEcef(ecef, result)!;\r\n }\r\n }\r\n\r\n public async cartographicToDbFromGcs(cartographic: Cartographic, result?: Point3d): Promise<Point3d> {\r\n let db;\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n this._mercatorTilingScheme.cartographicToFraction(cartographic.latitude, cartographic.longitude, fraction);\r\n db = this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, cartographic.height, result);\r\n } else {\r\n db = this._ecefToDb.multiplyPoint3d(cartographic.toEcef())!;\r\n }\r\n return (!this._iModel.noGcsDefined && this.cartesianRange.containsPoint(db)) ? this._iModel.cartographicToSpatialFromGcs(cartographic) : db;\r\n }\r\n public cartographicToDb(cartographic: Cartographic, result?: Point3d): Point3d {\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n this._mercatorTilingScheme.cartographicToFraction(cartographic.latitude, cartographic.longitude, fraction);\r\n return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, cartographic.height, result);\r\n } else {\r\n return this._ecefToDb.multiplyPoint3d(cartographic.toEcef())!;\r\n }\r\n }\r\n\r\n public getEarthEllipsoid(radiusOffset = 0): Ellipsoid {\r\n const equatorRadius = Constant.earthRadiusWGS84.equator + radiusOffset, polarRadius = Constant.earthRadiusWGS84.polar + radiusOffset;\r\n return Ellipsoid.createCenterMatrixRadii(this.globeOrigin, this.globeMatrix, equatorRadius, equatorRadius, polarRadius);\r\n }\r\n public getPlane(offset = 0) {\r\n return Plane3dByOriginAndUnitNormal.create(Point3d.create(0, 0, this._bimElevationBias + offset), Vector3d.create(0, 0, 1))!;\r\n }\r\n\r\n public getRayIntersection(ray: Ray3d, positiveOnly: boolean): Ray3d | undefined {\r\n let intersect;\r\n if (this.globeMode === GlobeMode.Ellipsoid) {\r\n const ellipsoid = this.geometry as Ellipsoid;\r\n BackgroundMapGeometry._scratchRayAngles.length = 0;\r\n BackgroundMapGeometry._scratchRayFractions.length = 0;\r\n\r\n const count = ellipsoid.intersectRay(ray, BackgroundMapGeometry._scratchRayFractions, undefined, BackgroundMapGeometry._scratchRayAngles);\r\n let intersectDistance;\r\n for (let i = 0; i < count; i++) {\r\n const thisFraction = BackgroundMapGeometry._scratchRayFractions[i];\r\n if ((!positiveOnly || thisFraction > 0) && (undefined === intersectDistance || thisFraction < intersectDistance)) {\r\n intersectDistance = thisFraction;\r\n intersect = scratchIntersectRay;\r\n ellipsoid.radiansToUnitNormalRay(BackgroundMapGeometry._scratchRayAngles[i].longitudeRadians, BackgroundMapGeometry._scratchRayAngles[i].latitudeRadians, intersect);\r\n if (intersect.direction.dotProduct(ray.direction) < 0) {\r\n if (this.cartesianRange.containsPoint(intersect.origin)) { // If we're in the cartesian range, correct to planar intersection.\r\n const planeFraction = ray.intersectionWithPlane(this.cartesianPlane, scratchIntersectRay.origin);\r\n if (undefined !== planeFraction && (!positiveOnly || planeFraction > 0)) {\r\n intersect.direction.setFromVector3d(this.cartesianPlane.getNormalRef());\r\n }\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const plane = this.geometry as Plane3dByOriginAndUnitNormal;\r\n const thisFraction = ray.intersectionWithPlane(plane, scratchIntersectRay.origin);\r\n if (undefined !== thisFraction && (!positiveOnly || thisFraction > 0)) {\r\n intersect = scratchIntersectRay;\r\n intersect.direction.setFromVector3d(plane.getNormalRef());\r\n }\r\n }\r\n return intersect;\r\n }\r\n public getPointHeight(point: Point3d): number | undefined {\r\n if (this.globeMode === GlobeMode.Ellipsoid) {\r\n const ellipsoid = this.geometry as Ellipsoid;\r\n const projected = ellipsoid.projectPointToSurface(point);\r\n if (undefined === projected)\r\n return undefined;\r\n\r\n const distance = ellipsoid.radiansToPoint(projected.longitudeRadians, projected.latitudeRadians).distance(point);\r\n const ellipsePoint = ellipsoid.transformRef.multiplyInversePoint3d(point, BackgroundMapGeometry._scratchPoint)!;\r\n return ellipsePoint.magnitude() < 1 ? -distance : distance;\r\n } else {\r\n const plane = this.geometry as Plane3dByOriginAndUnitNormal;\r\n return plane.altitude(point);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getFrustumIntersectionDepthRange(frustum: Frustum, heightRange?: Range1d, gridPlane?: Plane3dByOriginAndUnitNormal, doGlobalScope?: boolean): Range1d {\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewRotation = frustum.getRotation(scratchViewRotation);\r\n if (undefined === viewRotation)\r\n return Range1d.createNull(); // Degenerate frustum...\r\n const viewZ = viewRotation.getRow(2);\r\n const cartoRange = this.cartesianTransitionRange;\r\n const intersectRange = Range3d.createNull();\r\n const doAccumulate = ((point: Point3d) => accumulateDepthRange(point, viewRotation, intersectRange));\r\n\r\n if (gridPlane)\r\n accumulateFrustumPlaneDepthRange(frustum, gridPlane, viewRotation, intersectRange, eyePoint);\r\n if (this.geometry instanceof Plane3dByOriginAndUnitNormal) {\r\n // Intersection with a planar background projection...\r\n const heights = heightRange ? [heightRange.low, heightRange.high] : [0];\r\n for (const height of heights) {\r\n accumulateFrustumPlaneDepthRange(frustum, this.getPlane(height), viewRotation, intersectRange, eyePoint);\r\n }\r\n } else {\r\n const minOffset = heightRange ? heightRange.low : 0, maxOffset = (heightRange ? heightRange.high : 0) + this.cartesianChordHeight;\r\n const radiusOffsets = [minOffset, maxOffset];\r\n\r\n // If we are doing global scope then include minimum ellipsoid that represents the chordal approximation of the low level tiles.\r\n // this substantially expands the frustum so don't do it for non-global views, but this clipping out the low level tiles.\r\n if (doGlobalScope)\r\n radiusOffsets.push(minOffset - this.maxGeometryChordHeight);\r\n\r\n const toView = Transform.createRefs(Point3d.createZero(), viewRotation);\r\n const eyePoint4d = eyePoint ? Point4d.createFromPointAndWeight(eyePoint, 1) : Point4d.createFromPointAndWeight(viewZ, 0);\r\n\r\n for (const radiusOffset of radiusOffsets) {\r\n const ellipsoid = this.getEarthEllipsoid(radiusOffset);\r\n const isInside = eyePoint && ellipsoid.worldToLocal(eyePoint)!.magnitude() < 1.0;\r\n const center = ellipsoid.localToWorld(scratchZeroPoint, scratchCenterPoint);\r\n const clipPlaneCount = clipPlanes.planes.length;\r\n\r\n // Extrema...\r\n let angles, extremaPoint;\r\n if (undefined !== (angles = ellipsoid.surfaceNormalToAngles(viewZ)) &&\r\n undefined !== (extremaPoint = ellipsoid.radiansToPoint(angles.longitudeRadians, angles.latitudeRadians)) &&\r\n (eyePoint === undefined || viewZ.dotProductStartEnd(extremaPoint, eyePoint) > 0) &&\r\n clipPlanes.classifyPointContainment([extremaPoint], false) !== ClipPlaneContainment.StronglyOutside)\r\n doAccumulate(extremaPoint);\r\n\r\n if (isInside) {\r\n if (eyePoint) doAccumulate(eyePoint);\r\n } else {\r\n const silhouette = ellipsoid.silhouetteArc(eyePoint4d);\r\n if (silhouette !== undefined) {\r\n silhouette.perpendicularVector.clone(scratchSilhouetteNormal);\r\n // Push the silhouette plane as clip so that we do not include geometry at other side of ellipsoid.\r\n // First make sure that it is pointing in the right direction.\r\n if (eyePoint) {\r\n // Clip toward eye.\r\n if (scratchSilhouetteNormal.dotProduct(viewZ) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n } else {\r\n /* If parallel projection - clip toward side of ellipsoid with BIM geometry */\r\n if (viewZ.dotProduct(scratchSilhouetteNormal) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n }\r\n clipPlanes.planes.push(ClipPlane.createNormalAndDistance(scratchSilhouetteNormal, scratchSilhouetteNormal.dotProduct(silhouette.center))!);\r\n } else {\r\n clipPlanes.planes.push(ClipPlane.createNormalAndPoint(viewZ, center)!);\r\n }\r\n }\r\n if (!isInside || radiusOffset === radiusOffsets[0]) {\r\n // Intersections of ellipsoid with frustum planes...\r\n const viewingInside = eyePoint !== undefined && viewZ.dotProduct(Vector3d.createStartEnd(center, eyePoint)) < 0;\r\n if (eyePoint === undefined || !isInside || viewingInside) {\r\n for (const clipPlane of clipPlanes.planes) {\r\n const plane = clipPlane.getPlane3d();\r\n const arc = ellipsoid.createPlaneSection(plane);\r\n if (undefined !== arc) {\r\n arc.announceClipIntervals(clipPlanes, (a0: number, a1: number, cp: CurvePrimitive) => {\r\n if (Math.abs(a1 - a0) < 1.0E-8) {\r\n doAccumulate(cp.fractionToPoint(a0)); // Tiny sweep - avoid problem with rangeMethod (not worth doing anyway).\r\n } else {\r\n const segment = cp.clonePartialCurve(a0, a1);\r\n if (segment !== undefined)\r\n segment.extendRange(intersectRange, toView);\r\n\r\n }\r\n });\r\n }\r\n }\r\n }\r\n // Intersections of the cartesian region with frustum planes.\r\n scratchCartoRectangle.resize(0);\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.low.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.high.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.high.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: radiusOffset });\r\n\r\n clipPlanes.clipConvexPolygonInPlace(scratchCartoRectangle, scratchWorkArray);\r\n for (let i = 0; i < scratchCartoRectangle.length; i++)\r\n doAccumulate(scratchCartoRectangle.getPoint3dAtUncheckedPointIndex(i));\r\n while (clipPlanes.planes.length > clipPlaneCount) // Remove pushed silhouette plane.\r\n clipPlanes.planes.pop();\r\n }\r\n }\r\n }\r\n\r\n if (intersectRange.zLength() < 5) {\r\n // For the case where the fitted depth is small (less than 5 meters) we must be viewing planar projection or the\r\n // planar portion of the iModel in plan view. In this case use a constant (arbitrarily 100 meters) depth so that the frustum\r\n // Z is doesn't change and cause nearly planar geometry to jitter in Z buffer.\r\n const zCenter = (intersectRange.low.z + intersectRange.high.z) / 2;\r\n const zExpand = 50;\r\n return Range1d.createXX(zCenter - zExpand, zCenter + zExpand);\r\n } else {\r\n const diagonal = intersectRange.diagonal(scratchVector).magnitudeXY();\r\n const expansion = diagonal * .01;\r\n return Range1d.createXX(intersectRange.low.z - expansion, intersectRange.high.z + expansion);\r\n }\r\n }\r\n\r\n public addFrustumDecorations(builder: GraphicBuilder, frustum: Frustum) {\r\n if (this.geometry instanceof Ellipsoid) {\r\n const ellipsoid = this.geometry;\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewRotation = frustum.getRotation()!;\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewZ = viewRotation.getRow(2);\r\n const eyePoint4d = eyePoint ? Point4d.createFromPointAndWeight(eyePoint, 1) : Point4d.createFromPointAndWeight(viewZ, 0);\r\n const isInside = eyePoint && ellipsoid.worldToLocal(eyePoint)!.magnitude() < 1.0;\r\n const center = ellipsoid.localToWorld(scratchZeroPoint, scratchCenterPoint);\r\n const cartoRange = this.cartesianTransitionRange;\r\n\r\n if (!isInside) {\r\n const silhouette = ellipsoid.silhouetteArc(eyePoint4d);\r\n if (silhouette !== undefined) {\r\n silhouette.perpendicularVector.clone(scratchSilhouetteNormal);\r\n if (scratchSilhouetteNormal.dotProduct(viewZ) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n clipPlanes.planes.push(ClipPlane.createNormalAndDistance(scratchSilhouetteNormal, scratchSilhouetteNormal.dotProduct(silhouette.center))!);\r\n } else {\r\n clipPlanes.planes.push(ClipPlane.createNormalAndPoint(viewZ, center)!);\r\n }\r\n\r\n const ellipsoidColor = ColorDef.create(ColorByName.yellow);\r\n builder.setSymbology(ellipsoidColor, ellipsoidColor, 1, 2);\r\n for (const clipPlane of clipPlanes.planes) {\r\n const plane = clipPlane.getPlane3d();\r\n const arc = ellipsoid.createPlaneSection(plane);\r\n if (undefined !== arc) {\r\n arc.announceClipIntervals(clipPlanes, (a0: number, a1: number, cp: CurvePrimitive) => {\r\n const segment = cp.clonePartialCurve(a0, a1);\r\n if (segment !== undefined)\r\n builder.addArc(segment as Arc3d, false, false);\r\n });\r\n }\r\n\r\n // Intersections of the cartesian region with frustum planes.\r\n scratchCartoRectangle.resize(0);\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.low.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.high.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.high.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: 0 });\r\n\r\n clipPlanes.clipConvexPolygonInPlace(scratchCartoRectangle, scratchWorkArray);\r\n if (scratchCartoRectangle.length > 0) {\r\n builder.addLineString(scratchCartoRectangle.getPoint3dArray());\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Calculate the ECEF to database (IModel) coordinate transform at a provided location, using the GCS of the iModel.\r\n * The transform will exactly represent the GCS at the provided location.\r\n * @public\r\n */\r\nexport async function calculateEcefToDbTransformAtLocation(originIn: Point3d, iModel: IModelConnection): Promise<Transform | undefined> {\r\n const geoConverter = iModel.noGcsDefined ? undefined : iModel.geoServices.getConverter(\"WGS84\");\r\n if (geoConverter === undefined)\r\n return undefined;\r\n\r\n const origin = Point3d.create(originIn.x, originIn.y, 0); // Always Test at zero.\r\n const eastPoint = origin.plusXYZ(1, 0, 0);\r\n const northPoint = origin.plusXYZ(0, 1, 0);\r\n\r\n const response = await geoConverter.getGeoCoordinatesFromIModelCoordinates([origin, northPoint, eastPoint]);\r\n if (response.geoCoords[0].s !== GeoCoordStatus.Success || response.geoCoords[1].s !== GeoCoordStatus.Success || response.geoCoords[2].s !== GeoCoordStatus.Success)\r\n return undefined;\r\n\r\n const geoOrigin = Point3d.fromJSON(response.geoCoords[0].p);\r\n const geoNorth = Point3d.fromJSON(response.geoCoords[1].p);\r\n const geoEast = Point3d.fromJSON(response.geoCoords[2].p);\r\n const ecefOrigin = Cartographic.fromDegrees({ longitude: geoOrigin.x, latitude: geoOrigin.y, height: geoOrigin.z }).toEcef()!;\r\n const ecefNorth = Cartographic.fromDegrees({ longitude: geoNorth.x, latitude: geoNorth.y, height: geoNorth.z }).toEcef()!;\r\n const ecefEast = Cartographic.fromDegrees({ longitude: geoEast.x, latitude: geoEast.y, height: geoEast.z }).toEcef()!;\r\n\r\n const xVector = Vector3d.createStartEnd(ecefOrigin, ecefEast);\r\n const yVector = Vector3d.createStartEnd(ecefOrigin, ecefNorth);\r\n const zVector = xVector.unitCrossProduct(yVector);\r\n if (undefined === zVector) {\r\n assert(false); // Should never occur.\r\n return undefined;\r\n }\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector);\r\n if (matrix === undefined)\r\n return undefined;\r\n\r\n const inverse = matrix.inverse();\r\n if (inverse === undefined) {\r\n assert(false); // Should never occur.\r\n return undefined;\r\n }\r\n\r\n return Transform.createMatrixPickupPutdown(matrix, origin, ecefOrigin).inverse()!;\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"BackgroundMapGeometry.js","sourceRoot":"","sources":["../../src/BackgroundMapGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAS,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAkB,SAAS,EAAE,gBAAgB,EAA2B,QAAQ,EAAE,4BAA4B,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAU,MAAM,sBAAsB,CAAC;AAC9R,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAW,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG7G,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;AAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;AAC9C,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AACtC,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;AACxC,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;AAChD,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9E,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;AAC7C,MAAM,mBAAmB,GAAG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AAE;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAY,sBAAsB;QAChD,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,IAAI,MAAM,KAAK,SAAS;QACtB,OAAO,SAAS,CAAC;IAEnB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAe,sBAAsB;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,SAAS,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,OAAO,EAAG,CAAC;AACpF,CAAC","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 Views\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Angle, Arc3d, ClipPlane, ClipPlaneContainment, Constant, CurvePrimitive, Ellipsoid, GrowableXYZArray, LongitudeLatitudeNumber, Matrix3d, Plane3dByOriginAndUnitNormal, Point2d, Point3d, Point4d, Range1d, Range3d, Ray3d, Transform, Vector3d, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorByName, ColorDef, Frustum, GeoCoordStatus, GlobeMode } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { GraphicBuilder } from \"./render/GraphicBuilder\";\r\nimport { WebMercatorTilingScheme } from \"./tile/internal\";\r\n\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchZeroPoint = Point3d.createZero();\r\nconst scratchPoint = Point3d.create();\r\nconst scratchVector = Vector3d.create();\r\nconst scratchCenterPoint = Point3d.createZero();\r\nconst scratchIntersectRay = Ray3d.create(Point3d.create(), Vector3d.create());\r\nconst scratchEyePoint = Point3d.createZero();\r\nconst scratchViewRotation = Matrix3d.createIdentity();\r\nconst scratchSilhouetteNormal = Vector3d.create();\r\nconst scratchCartoRectangle = new GrowableXYZArray();\r\nconst scratchWorkArray = new GrowableXYZArray();\r\n\r\nfunction accumulateDepthRange(point: Point3d, viewRotation: Matrix3d, range: Range3d) {\r\n viewRotation.multiplyXYZtoXYZ(point, scratchPoint);\r\n range.extend(scratchPoint);\r\n}\r\n\r\nfunction accumulateFrustumPlaneDepthRange(frustum: Frustum, plane: Plane3dByOriginAndUnitNormal, viewRotation: Matrix3d, range: Range3d, eyePoint?: Point3d) {\r\n let includeHorizon = false;\r\n for (let i = 0; i < 4; i++) {\r\n const frustumRay = Ray3d.createStartEnd(eyePoint ? eyePoint : frustum.points[i + 4], frustum.points[i]);\r\n const thisFraction = frustumRay.intersectionWithPlane(plane, scratchPoint);\r\n if (undefined !== thisFraction && (!eyePoint || thisFraction > 0))\r\n accumulateDepthRange(scratchPoint, viewRotation, range);\r\n else\r\n includeHorizon = true;\r\n }\r\n if (includeHorizon) {\r\n if (eyePoint !== undefined) {\r\n const eyeHeight = plane.altitude(eyePoint);\r\n if (eyeHeight < 0)\r\n accumulateDepthRange(eyePoint, viewRotation, range);\r\n else {\r\n const viewZ = viewRotation.getRow(2);\r\n const horizonDistance = Math.sqrt(eyeHeight * eyeHeight + 2 * eyeHeight * Constant.earthRadiusWGS84.equator);\r\n accumulateDepthRange(eyePoint.plusScaled(viewZ, -horizonDistance, scratchPoint), viewRotation, range);\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function getFrustumPlaneIntersectionDepthRange(frustum: Frustum, plane: Plane3dByOriginAndUnitNormal): Range1d {\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewRotation = frustum.getRotation(scratchViewRotation)!;\r\n const intersectRange = Range3d.createNull();\r\n accumulateFrustumPlaneDepthRange(frustum, plane, viewRotation, intersectRange, eyePoint);\r\n\r\n return intersectRange.isNull ? Range1d.createNull() : Range1d.createXX(intersectRange.low.z, intersectRange.high.z);\r\n}\r\n\r\n/** Geometry of background map - either an ellipsoid or a plane as defined by GlobeMode.\r\n * @internal\r\n */\r\nexport class BackgroundMapGeometry {\r\n public readonly globeMode: GlobeMode;\r\n public readonly geometry: Plane3dByOriginAndUnitNormal | Ellipsoid;\r\n public readonly globeOrigin: Point3d;\r\n public readonly globeMatrix: Matrix3d;\r\n public readonly cartesianRange: Range3d;\r\n public readonly cartesianTransitionRange: Range3d;\r\n public readonly cartesianPlane: Plane3dByOriginAndUnitNormal;\r\n public readonly cartesianDiagonal: number;\r\n public readonly cartesianChordHeight: number;\r\n public readonly maxGeometryChordHeight: number;\r\n private _mercatorFractionToDb: Transform;\r\n private _mercatorTilingScheme: WebMercatorTilingScheme;\r\n private _ecefToDb: Transform;\r\n public static maxCartesianDistance = 1E4; // If globe is 3D we still consider the map geometry flat within this distance of the project extents.\r\n private static _transitionDistanceMultiplier = .25; // In the transition range which extends beyond the cartesian range we interpolate between cartesian and ellipsoid.\r\n\r\n private static _scratchRayFractions = new Array<number>();\r\n private static _scratchRayAngles = new Array<LongitudeLatitudeNumber>();\r\n private static _scratchPoint = Point3d.createZero();\r\n\r\n constructor(private _bimElevationBias: number, globeMode: GlobeMode, private _iModel: IModelConnection) {\r\n this._ecefToDb = _iModel.getMapEcefToDb(_bimElevationBias);\r\n this.globeMode = globeMode;\r\n this.cartesianRange = BackgroundMapGeometry.getCartesianRange(_iModel);\r\n this.cartesianTransitionRange = this.cartesianRange.clone();\r\n this.cartesianTransitionRange.expandInPlace(BackgroundMapGeometry.getCartesianTransitionDistance(_iModel));\r\n this.cartesianDiagonal = this.cartesianRange.diagonal().magnitudeXY();\r\n const earthRadius = Constant.earthRadiusWGS84.equator;\r\n this.globeOrigin = this._ecefToDb.origin.cloneAsPoint3d();\r\n this.globeMatrix = this._ecefToDb.matrix.clone();\r\n this.cartesianChordHeight = Math.sqrt(this.cartesianDiagonal * this.cartesianDiagonal + earthRadius * earthRadius) - earthRadius; // Maximum chord height deviation of the cartesian area.\r\n const halfChordAngle = Angle.piOver2Radians / 10;\r\n this.maxGeometryChordHeight = (1 - Math.cos(halfChordAngle)) * earthRadius;\r\n this.cartesianPlane = this.getPlane();\r\n this.geometry = (globeMode === GlobeMode.Ellipsoid) ? this.getEarthEllipsoid() : this.cartesianPlane;\r\n this._mercatorTilingScheme = new WebMercatorTilingScheme();\r\n this._mercatorFractionToDb = this._mercatorTilingScheme.computeMercatorFractionToDb(this._ecefToDb, _bimElevationBias, _iModel, false);\r\n }\r\n public static getCartesianRange(iModel: IModelConnection, result?: Range3d): Range3d {\r\n const cartesianRange = Range3d.createFrom(iModel.projectExtents, result);\r\n cartesianRange.expandInPlace(BackgroundMapGeometry.maxCartesianDistance);\r\n return cartesianRange;\r\n }\r\n public static getCartesianTransitionDistance(iModel: IModelConnection): number {\r\n return BackgroundMapGeometry.getCartesianRange(iModel, scratchRange).diagonal().magnitudeXY() * BackgroundMapGeometry._transitionDistanceMultiplier;\r\n }\r\n\r\n public async dbToCartographicFromGcs(db: XYAndZ, result?: Cartographic): Promise<Cartographic> {\r\n return this.cartesianRange.containsPoint(Point3d.createFrom(db)) ? this._iModel.spatialToCartographic(db, result) : this.dbToCartographic(db, result);\r\n }\r\n\r\n public dbToCartographic(db: XYAndZ, result?: Cartographic): Cartographic {\r\n if (undefined === result)\r\n result = Cartographic.createZero();\r\n\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const mercatorFraction = this._mercatorFractionToDb.multiplyInversePoint3d(db)!;\r\n return this._mercatorTilingScheme.fractionToCartographic(mercatorFraction.x, mercatorFraction.y, result, mercatorFraction.z);\r\n } else {\r\n const ecef = this._ecefToDb.multiplyInversePoint3d(db)!;\r\n return Cartographic.fromEcef(ecef, result)!;\r\n }\r\n }\r\n\r\n public async cartographicToDbFromGcs(cartographic: Cartographic, result?: Point3d): Promise<Point3d> {\r\n let db;\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n this._mercatorTilingScheme.cartographicToFraction(cartographic.latitude, cartographic.longitude, fraction);\r\n db = this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, cartographic.height, result);\r\n } else {\r\n db = this._ecefToDb.multiplyPoint3d(cartographic.toEcef())!;\r\n }\r\n return (!this._iModel.noGcsDefined && this.cartesianRange.containsPoint(db)) ? this._iModel.cartographicToSpatialFromGcs(cartographic) : db;\r\n }\r\n public cartographicToDb(cartographic: Cartographic, result?: Point3d): Point3d {\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n this._mercatorTilingScheme.cartographicToFraction(cartographic.latitude, cartographic.longitude, fraction);\r\n return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, cartographic.height, result);\r\n } else {\r\n return this._ecefToDb.multiplyPoint3d(cartographic.toEcef())!;\r\n }\r\n }\r\n\r\n public getEarthEllipsoid(radiusOffset = 0): Ellipsoid {\r\n const equatorRadius = Constant.earthRadiusWGS84.equator + radiusOffset, polarRadius = Constant.earthRadiusWGS84.polar + radiusOffset;\r\n return Ellipsoid.createCenterMatrixRadii(this.globeOrigin, this.globeMatrix, equatorRadius, equatorRadius, polarRadius);\r\n }\r\n public getPlane(offset = 0) {\r\n return Plane3dByOriginAndUnitNormal.create(Point3d.create(0, 0, this._bimElevationBias + offset), Vector3d.create(0, 0, 1))!;\r\n }\r\n\r\n public getRayIntersection(ray: Ray3d, positiveOnly: boolean): Ray3d | undefined {\r\n let intersect;\r\n if (this.globeMode === GlobeMode.Ellipsoid) {\r\n const ellipsoid = this.geometry as Ellipsoid;\r\n BackgroundMapGeometry._scratchRayAngles.length = 0;\r\n BackgroundMapGeometry._scratchRayFractions.length = 0;\r\n\r\n const count = ellipsoid.intersectRay(ray, BackgroundMapGeometry._scratchRayFractions, undefined, BackgroundMapGeometry._scratchRayAngles);\r\n let intersectDistance;\r\n for (let i = 0; i < count; i++) {\r\n const thisFraction = BackgroundMapGeometry._scratchRayFractions[i];\r\n if ((!positiveOnly || thisFraction > 0) && (undefined === intersectDistance || thisFraction < intersectDistance)) {\r\n intersectDistance = thisFraction;\r\n intersect = scratchIntersectRay;\r\n ellipsoid.radiansToUnitNormalRay(BackgroundMapGeometry._scratchRayAngles[i].longitudeRadians, BackgroundMapGeometry._scratchRayAngles[i].latitudeRadians, intersect);\r\n if (intersect.direction.dotProduct(ray.direction) < 0) {\r\n if (this.cartesianRange.containsPoint(intersect.origin)) { // If we're in the cartesian range, correct to planar intersection.\r\n const planeFraction = ray.intersectionWithPlane(this.cartesianPlane, scratchIntersectRay.origin);\r\n if (undefined !== planeFraction && (!positiveOnly || planeFraction > 0)) {\r\n intersect.direction.setFromVector3d(this.cartesianPlane.getNormalRef());\r\n }\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const plane = this.geometry as Plane3dByOriginAndUnitNormal;\r\n const thisFraction = ray.intersectionWithPlane(plane, scratchIntersectRay.origin);\r\n if (undefined !== thisFraction && (!positiveOnly || thisFraction > 0)) {\r\n intersect = scratchIntersectRay;\r\n intersect.direction.setFromVector3d(plane.getNormalRef());\r\n }\r\n }\r\n return intersect;\r\n }\r\n public getPointHeight(point: Point3d): number | undefined {\r\n if (this.globeMode === GlobeMode.Ellipsoid) {\r\n const ellipsoid = this.geometry as Ellipsoid;\r\n const projected = ellipsoid.projectPointToSurface(point);\r\n if (undefined === projected)\r\n return undefined;\r\n\r\n const distance = ellipsoid.radiansToPoint(projected.longitudeRadians, projected.latitudeRadians).distance(point);\r\n const ellipsePoint = ellipsoid.transformRef.multiplyInversePoint3d(point, BackgroundMapGeometry._scratchPoint)!;\r\n return ellipsePoint.magnitude() < 1 ? -distance : distance;\r\n } else {\r\n const plane = this.geometry as Plane3dByOriginAndUnitNormal;\r\n return plane.altitude(point);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public getFrustumIntersectionDepthRange(frustum: Frustum, bimRange: Range3d, heightRange?: Range1d, gridPlane?: Plane3dByOriginAndUnitNormal, doGlobalScope?: boolean): Range1d {\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewRotation = frustum.getRotation(scratchViewRotation);\r\n if (undefined === viewRotation)\r\n return Range1d.createNull(); // Degenerate frustum...\r\n const viewZ = viewRotation.getRow(2);\r\n const cartoRange = this.cartesianTransitionRange;\r\n const intersectRange = Range3d.createNull();\r\n const doAccumulate = ((point: Point3d) => accumulateDepthRange(point, viewRotation, intersectRange));\r\n\r\n if (gridPlane)\r\n accumulateFrustumPlaneDepthRange(frustum, gridPlane, viewRotation, intersectRange, eyePoint);\r\n if (this.geometry instanceof Plane3dByOriginAndUnitNormal) {\r\n // Intersection with a planar background projection...\r\n const heights = heightRange ? [heightRange.low, heightRange.high] : [0];\r\n for (const height of heights) {\r\n accumulateFrustumPlaneDepthRange(frustum, this.getPlane(height), viewRotation, intersectRange, eyePoint);\r\n }\r\n } else {\r\n const minOffset = heightRange ? heightRange.low : 0, maxOffset = (heightRange ? heightRange.high : 0) + this.cartesianChordHeight;\r\n const radiusOffsets = [minOffset, maxOffset];\r\n\r\n // If we are doing global scope then include minimum ellipsoid that represents the chordal approximation of the low level tiles.\r\n // this substantially expands the frustum so don't do it for non-global views, but this clipping out the low level tiles.\r\n if (doGlobalScope)\r\n radiusOffsets.push(minOffset - this.maxGeometryChordHeight);\r\n\r\n const toView = Transform.createRefs(Point3d.createZero(), viewRotation);\r\n const eyePoint4d = eyePoint ? Point4d.createFromPointAndWeight(eyePoint, 1) : Point4d.createFromPointAndWeight(viewZ, 0);\r\n\r\n for (const radiusOffset of radiusOffsets) {\r\n const ellipsoid = this.getEarthEllipsoid(radiusOffset);\r\n const isInside = eyePoint && ellipsoid.worldToLocal(eyePoint)!.magnitude() < 1.0;\r\n const center = ellipsoid.localToWorld(scratchZeroPoint, scratchCenterPoint);\r\n const clipPlaneCount = clipPlanes.planes.length;\r\n\r\n // Extrema...\r\n let angles, extremaPoint;\r\n if (undefined !== (angles = ellipsoid.surfaceNormalToAngles(viewZ)) &&\r\n undefined !== (extremaPoint = ellipsoid.radiansToPoint(angles.longitudeRadians, angles.latitudeRadians)) &&\r\n (eyePoint === undefined || viewZ.dotProductStartEnd(extremaPoint, eyePoint) > 0) &&\r\n clipPlanes.classifyPointContainment([extremaPoint], false) !== ClipPlaneContainment.StronglyOutside)\r\n doAccumulate(extremaPoint);\r\n\r\n if (isInside) {\r\n if (eyePoint) doAccumulate(eyePoint);\r\n } else {\r\n const silhouette = ellipsoid.silhouetteArc(eyePoint4d);\r\n if (silhouette !== undefined) {\r\n silhouette.perpendicularVector.clone(scratchSilhouetteNormal);\r\n // Push the silhouette plane as clip so that we do not include geometry at other side of ellipsoid.\r\n // First make sure that it is pointing in the right direction.\r\n if (eyePoint) {\r\n // Clip toward eye.\r\n if (scratchSilhouetteNormal.dotProduct(viewZ) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n } else {\r\n /* If parallel projection - clip toward side of ellipsoid with BIM geometry */\r\n if (Vector3d.createStartEnd(silhouette.center, bimRange.center).dotProduct(scratchSilhouetteNormal) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n }\r\n clipPlanes.planes.push(ClipPlane.createNormalAndDistance(scratchSilhouetteNormal, scratchSilhouetteNormal.dotProduct(silhouette.center))!);\r\n } else {\r\n clipPlanes.planes.push(ClipPlane.createNormalAndPoint(viewZ, center)!);\r\n }\r\n }\r\n if (!isInside || radiusOffset === radiusOffsets[0]) {\r\n // Intersections of ellipsoid with frustum planes...\r\n const viewingInside = eyePoint !== undefined && viewZ.dotProduct(Vector3d.createStartEnd(center, eyePoint)) < 0;\r\n if (eyePoint === undefined || !isInside || viewingInside) {\r\n for (const clipPlane of clipPlanes.planes) {\r\n const plane = clipPlane.getPlane3d();\r\n const arc = ellipsoid.createPlaneSection(plane);\r\n if (undefined !== arc) {\r\n arc.announceClipIntervals(clipPlanes, (a0: number, a1: number, cp: CurvePrimitive) => {\r\n if (Math.abs(a1 - a0) < 1.0E-8) {\r\n doAccumulate(cp.fractionToPoint(a0)); // Tiny sweep - avoid problem with rangeMethod (not worth doing anyway).\r\n } else {\r\n const segment = cp.clonePartialCurve(a0, a1);\r\n if (segment !== undefined)\r\n segment.extendRange(intersectRange, toView);\r\n\r\n }\r\n });\r\n }\r\n }\r\n }\r\n // Intersections of the cartesian region with frustum planes.\r\n scratchCartoRectangle.resize(0);\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.low.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.high.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.high.y, z: radiusOffset });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: radiusOffset });\r\n\r\n clipPlanes.clipConvexPolygonInPlace(scratchCartoRectangle, scratchWorkArray);\r\n for (let i = 0; i < scratchCartoRectangle.length; i++)\r\n doAccumulate(scratchCartoRectangle.getPoint3dAtUncheckedPointIndex(i));\r\n while (clipPlanes.planes.length > clipPlaneCount) // Remove pushed silhouette plane.\r\n clipPlanes.planes.pop();\r\n }\r\n }\r\n }\r\n\r\n if (intersectRange.zLength() < 5) {\r\n // For the case where the fitted depth is small (less than 5 meters) we must be viewing planar projection or the\r\n // planar portion of the iModel in plan view. In this case use a constant (arbitrarily 100 meters) depth so that the frustum\r\n // Z is doesn't change and cause nearly planar geometry to jitter in Z buffer.\r\n const zCenter = (intersectRange.low.z + intersectRange.high.z) / 2;\r\n const zExpand = 50;\r\n return Range1d.createXX(zCenter - zExpand, zCenter + zExpand);\r\n } else {\r\n const diagonal = intersectRange.diagonal(scratchVector).magnitudeXY();\r\n const expansion = diagonal * .01;\r\n return Range1d.createXX(intersectRange.low.z - expansion, intersectRange.high.z + expansion);\r\n }\r\n }\r\n\r\n public addFrustumDecorations(builder: GraphicBuilder, frustum: Frustum) {\r\n if (this.geometry instanceof Ellipsoid) {\r\n const ellipsoid = this.geometry;\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewRotation = frustum.getRotation()!;\r\n const eyePoint = frustum.getEyePoint(scratchEyePoint);\r\n const viewZ = viewRotation.getRow(2);\r\n const eyePoint4d = eyePoint ? Point4d.createFromPointAndWeight(eyePoint, 1) : Point4d.createFromPointAndWeight(viewZ, 0);\r\n const isInside = eyePoint && ellipsoid.worldToLocal(eyePoint)!.magnitude() < 1.0;\r\n const center = ellipsoid.localToWorld(scratchZeroPoint, scratchCenterPoint);\r\n const cartoRange = this.cartesianTransitionRange;\r\n\r\n if (!isInside) {\r\n const silhouette = ellipsoid.silhouetteArc(eyePoint4d);\r\n if (silhouette !== undefined) {\r\n silhouette.perpendicularVector.clone(scratchSilhouetteNormal);\r\n if (scratchSilhouetteNormal.dotProduct(viewZ) < 0)\r\n scratchSilhouetteNormal.negate(scratchSilhouetteNormal);\r\n clipPlanes.planes.push(ClipPlane.createNormalAndDistance(scratchSilhouetteNormal, scratchSilhouetteNormal.dotProduct(silhouette.center))!);\r\n } else {\r\n clipPlanes.planes.push(ClipPlane.createNormalAndPoint(viewZ, center)!);\r\n }\r\n\r\n const ellipsoidColor = ColorDef.create(ColorByName.yellow);\r\n builder.setSymbology(ellipsoidColor, ellipsoidColor, 1, 2);\r\n for (const clipPlane of clipPlanes.planes) {\r\n const plane = clipPlane.getPlane3d();\r\n const arc = ellipsoid.createPlaneSection(plane);\r\n if (undefined !== arc) {\r\n arc.announceClipIntervals(clipPlanes, (a0: number, a1: number, cp: CurvePrimitive) => {\r\n const segment = cp.clonePartialCurve(a0, a1);\r\n if (segment !== undefined)\r\n builder.addArc(segment as Arc3d, false, false);\r\n });\r\n }\r\n\r\n // Intersections of the cartesian region with frustum planes.\r\n scratchCartoRectangle.resize(0);\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.low.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.high.x, y: cartoRange.high.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.high.y, z: 0 });\r\n scratchCartoRectangle.push({ x: cartoRange.low.x, y: cartoRange.low.y, z: 0 });\r\n\r\n clipPlanes.clipConvexPolygonInPlace(scratchCartoRectangle, scratchWorkArray);\r\n if (scratchCartoRectangle.length > 0) {\r\n builder.addLineString(scratchCartoRectangle.getPoint3dArray());\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Calculate the ECEF to database (IModel) coordinate transform at a provided location, using the GCS of the iModel.\r\n * The transform will exactly represent the GCS at the provided location.\r\n * @public\r\n */\r\nexport async function calculateEcefToDbTransformAtLocation(originIn: Point3d, iModel: IModelConnection): Promise<Transform | undefined> {\r\n const geoConverter = iModel.noGcsDefined ? undefined : iModel.geoServices.getConverter(\"WGS84\");\r\n if (geoConverter === undefined)\r\n return undefined;\r\n\r\n const origin = Point3d.create(originIn.x, originIn.y, 0); // Always Test at zero.\r\n const eastPoint = origin.plusXYZ(1, 0, 0);\r\n const northPoint = origin.plusXYZ(0, 1, 0);\r\n\r\n const response = await geoConverter.getGeoCoordinatesFromIModelCoordinates([origin, northPoint, eastPoint]);\r\n if (response.geoCoords[0].s !== GeoCoordStatus.Success || response.geoCoords[1].s !== GeoCoordStatus.Success || response.geoCoords[2].s !== GeoCoordStatus.Success)\r\n return undefined;\r\n\r\n const geoOrigin = Point3d.fromJSON(response.geoCoords[0].p);\r\n const geoNorth = Point3d.fromJSON(response.geoCoords[1].p);\r\n const geoEast = Point3d.fromJSON(response.geoCoords[2].p);\r\n const ecefOrigin = Cartographic.fromDegrees({ longitude: geoOrigin.x, latitude: geoOrigin.y, height: geoOrigin.z }).toEcef()!;\r\n const ecefNorth = Cartographic.fromDegrees({ longitude: geoNorth.x, latitude: geoNorth.y, height: geoNorth.z }).toEcef()!;\r\n const ecefEast = Cartographic.fromDegrees({ longitude: geoEast.x, latitude: geoEast.y, height: geoEast.z }).toEcef()!;\r\n\r\n const xVector = Vector3d.createStartEnd(ecefOrigin, ecefEast);\r\n const yVector = Vector3d.createStartEnd(ecefOrigin, ecefNorth);\r\n const zVector = xVector.unitCrossProduct(yVector);\r\n if (undefined === zVector) {\r\n assert(false); // Should never occur.\r\n return undefined;\r\n }\r\n const matrix = Matrix3d.createColumns(xVector, yVector, zVector);\r\n if (matrix === undefined)\r\n return undefined;\r\n\r\n const inverse = matrix.inverse();\r\n if (inverse === undefined) {\r\n assert(false); // Should never occur.\r\n return undefined;\r\n }\r\n\r\n return Transform.createMatrixPickupPutdown(matrix, origin, ecefOrigin).inverse()!;\r\n}\r\n\r\n"]}
|
package/lib/esm/BingLocation.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Tiles
|
|
7
7
|
*/
|
|
8
8
|
import { Cartographic } from "@itwin/core-common";
|
|
9
|
-
import { request } from "
|
|
9
|
+
import { request } from "./request/Request";
|
|
10
10
|
import { IModelApp } from "./IModelApp";
|
|
11
11
|
/** Provides an interface to the [Bing Maps location services](https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/).
|
|
12
12
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BingLocation.js","sourceRoot":"","sources":["../../src/BingLocation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAA4B,MAAM,
|
|
1
|
+
{"version":3,"file":"BingLocation.js","sourceRoot":"","sources":["../../src/BingLocation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA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AAC,CAAC,CAAC,CAAC;YAC9B,OAAO;gBACL,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrG,IAAI,EAAE;oBACJ,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;oBAC1F,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;iBAC3F;aACF,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF","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 Tiles\r\n */\r\n\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { request, RequestOptions, Response } from \"./request/Request\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { GlobalLocation } from \"./ViewGlobalLocation\";\r\n\r\n/** Provides an interface to the [Bing Maps location services](https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/).\r\n * @public\r\n */\r\nexport class BingLocationProvider {\r\n private _locationRequestTemplate: string;\r\n\r\n constructor() {\r\n let bingKey = \"\";\r\n if (IModelApp.mapLayerFormatRegistry.configOptions.BingMaps) {\r\n bingKey = IModelApp.mapLayerFormatRegistry.configOptions.BingMaps.value;\r\n }\r\n this._locationRequestTemplate = \"https://dev.virtualearth.net/REST/v1/Locations?query={query}&key={BingMapsAPIKey}\".replace(\"{BingMapsAPIKey}\", bingKey);\r\n }\r\n /** Return the location of a query (or undefined if not found). The strings \"Space Needle\" (a landmark) and \"1 Microsoft Way Redmond WA\" (an address) are examples of query strings with location information.\r\n * These strings can be specified as a structured URL parameter or as a query parameter value. See [Bing Location Services documentation](https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-query) for additional\r\n * information on queries.\r\n * @public\r\n */\r\n public async getLocation(query: string): Promise<GlobalLocation | undefined> {\r\n const requestUrl = this._locationRequestTemplate.replace(\"{query}\", query);\r\n const requestOptions: RequestOptions = { method: \"GET\", responseType: \"json\" };\r\n try {\r\n const locationResponse: Response = await request(requestUrl, requestOptions);\r\n const point = locationResponse.body.resourceSets[0].resources[0].point;\r\n const bbox = locationResponse.body.resourceSets[0].resources[0].bbox;\r\n const southLatitude = bbox[0];\r\n const westLongitude = bbox[1];\r\n const northLatitude = bbox[2];\r\n const eastLongitude = bbox[3];\r\n return {\r\n center: Cartographic.fromDegrees({ longitude: point.coordinates[1], latitude: point.coordinates[0] }),\r\n area: {\r\n southwest: Cartographic.fromDegrees({ longitude: westLongitude, latitude: southLatitude }),\r\n northeast: Cartographic.fromDegrees({ longitude: eastLongitude, latitude: northLatitude }),\r\n },\r\n };\r\n } catch (error) {\r\n return undefined;\r\n }\r\n }\r\n}\r\n"]}
|