@itwin/core-frontend 4.3.0-dev.6 → 4.3.0-dev.8

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.
@@ -38,6 +38,7 @@ export declare class BackgroundMapGeometry {
38
38
  dbToWGS84CartographicFromGcs(db: XYAndZ[]): Promise<Cartographic[]>;
39
39
  dbToCartographic(db: XYAndZ, result?: Cartographic): Cartographic;
40
40
  cartographicToDbFromGcs(cartographic: Cartographic[]): Promise<Point3d[]>;
41
+ cartographicToDbFromWgs84Gcs(cartographic: Cartographic[]): Promise<Point3d[]>;
41
42
  cartographicToDb(cartographic: Cartographic, result?: Point3d): Point3d;
42
43
  getEarthEllipsoid(radiusOffset?: number): Ellipsoid;
43
44
  getPlane(offset?: number): Plane3dByOriginAndUnitNormal;
@@ -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,EAAc,MAAM,oBAAoB,CAAC;AACzH,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,GAA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AG,YAAY;IAa3D,uBAAuB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAsBzE,4BAA4B,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA8BpF,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAUvE,iBAAiB,CAAC,YAAY,SAAI,GAAG,SAAS;IAK9C,QAAQ,CAAC,MAAM,SAAI;IAInB,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS;IAmCxE,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAgBzD,gBAAgB;IACT,gCAAgC,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,4BAA4B,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO;IAwHxK,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"}
@@ -158,6 +158,34 @@ class BackgroundMapGeometry {
158
158
  });
159
159
  return Promise.all(promises);
160
160
  }
161
+ async cartographicToDbFromWgs84Gcs(cartographic) {
162
+ let db;
163
+ if (this.globeMode === core_common_1.GlobeMode.Plane) {
164
+ const fraction = core_geometry_1.Point2d.create(0, 0);
165
+ db = cartographic.map((p) => {
166
+ this._mercatorTilingScheme.cartographicToFraction(p.latitude, p.longitude, fraction);
167
+ return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, p.height);
168
+ });
169
+ }
170
+ else {
171
+ db = cartographic.map((p) => this._ecefToDb.multiplyPoint3d(p.toEcef()));
172
+ }
173
+ if (this._iModel.noGcsDefined)
174
+ return db;
175
+ const toReprojectCoords = [];
176
+ const toReprojectIdx = [];
177
+ db.forEach(async (p, i) => {
178
+ if (this.cartesianRange.containsPoint(p)) {
179
+ toReprojectCoords.push({ x: cartographic[i].longitudeDegrees, y: cartographic[i].latitudeDegrees, z: cartographic[i].height });
180
+ toReprojectIdx.push(i);
181
+ }
182
+ });
183
+ const spatialPoints = await this._iModel.toSpatialFromGcs(toReprojectCoords, { horizontalCRS: { epsg: 4326 }, verticalCRS: { id: "ELLIPSOID" } });
184
+ return db.map((p, i) => {
185
+ const reprojectedIdx = toReprojectIdx.findIndex((value) => value === i);
186
+ return (reprojectedIdx === -1 ? p : spatialPoints[reprojectedIdx]);
187
+ });
188
+ }
161
189
  cartographicToDb(cartographic, result) {
162
190
  if (this.globeMode === core_common_1.GlobeMode.Plane) {
163
191
  const fraction = core_geometry_1.Point2d.create(0, 0);
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundMapGeometry.js","sourceRoot":"","sources":["../../src/BackgroundMapGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,wDAA8R;AAC9R,oDAAyH;AAGzH,8CAA0D;AAE1D,MAAM,YAAY,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC1C,MAAM,gBAAgB,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC9C,MAAM,YAAY,GAAG,uBAAO,CAAC,MAAM,EAAE,CAAC;AACtC,MAAM,aAAa,GAAG,wBAAQ,CAAC,MAAM,EAAE,CAAC;AACxC,MAAM,kBAAkB,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAChD,MAAM,mBAAmB,GAAG,qBAAK,CAAC,MAAM,CAAC,uBAAO,CAAC,MAAM,EAAE,EAAE,wBAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9E,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yB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,OAAO,EAAG,CAAC;AACpF,CAAC;AAtCD,oFAsCC","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, LinePixels } 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[]): Promise<Cartographic[]> {\r\n const scratch = new Point3d();\r\n const promises = db.map(async (p) => {\r\n return this.cartesianRange.containsPoint(Point3d.createFrom(p, scratch)) ? this._iModel.spatialToCartographic(p) : this.dbToCartographic(p);\r\n });\r\n\r\n return Promise.all(promises);\r\n }\r\n\r\n public async dbToWGS84CartographicFromGcs(db: XYAndZ[]): Promise<Cartographic[]> {\r\n if (db.length === 0)\r\n return [];\r\n\r\n const result: Cartographic[] = Array(db.length);\r\n const reproject: XYAndZ[] = [];\r\n const reprojectIdx: number[] = [];\r\n const scratch = new Point3d();\r\n for (let i = 0; i < db.length; i++) {\r\n Point3d.createFrom(db[i], scratch);\r\n if (this.cartesianRange.containsPoint(scratch) ) {\r\n reprojectIdx.push(i);\r\n reproject.push(db[i]);\r\n } else {\r\n result[i] = this.dbToCartographic(db[i]);\r\n }\r\n }\r\n\r\n if (reproject.length === 0)\r\n return result;\r\n\r\n const reprojectPromise = this._iModel.wgs84CartographicFromSpatial(reproject);\r\n return reprojectPromise.then((reprojected) => {\r\n if (reprojected.length === reprojectIdx.length) { // reprojected array size must match our index array, otherwise something is OFF\r\n for (let i = 0; i < reprojected.length; i++) {\r\n result[reprojectIdx[i]] = reprojected[i]; // Insert the reprojected values at their original index\r\n }\r\n }\r\n return result;\r\n });\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[]): Promise<Point3d[]> {\r\n let db;\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n db = cartographic.map((p) => {\r\n this._mercatorTilingScheme.cartographicToFraction(p.latitude, p.longitude, fraction);\r\n return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, p.height);\r\n });\r\n } else {\r\n db = cartographic.map((p) => this._ecefToDb.multiplyPoint3d(p.toEcef())!);\r\n }\r\n\r\n if (this._iModel.noGcsDefined)\r\n return db;\r\n\r\n const promises = db.map(async (p, i) => {\r\n return this.cartesianRange.containsPoint(p) ? this._iModel.cartographicToSpatialFromGcs(cartographic[i]) : p;\r\n });\r\n\r\n return Promise.all(promises);\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\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)\r\n 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, LinePixels.Code2);\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,sDAA6C;AAC7C,wDAA8S;AAC9S,oDAAyH;AAGzH,8CAA0D;AAE1D,MAAM,YAAY,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC1C,MAAM,g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CAAC,CAAC,MAAM,EAAG,CAAC;IAC1H,MAAM,QAAQ,GAAG,0BAAY,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAG,CAAC;IAEtH,MAAM,OAAO,GAAG,wBAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,wBAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,SAAS,KAAK,OAAO,EAAE;QACzB,IAAA,qBAAM,EAAC,KAAK,CAAC,CAAC,CAAY,sBAAsB;QAChD,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,MAAM,GAAG,wBAAQ,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,IAAA,qBAAM,EAAC,KAAK,CAAC,CAAC,CAAe,sBAAsB;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,yBAAS,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,OAAO,EAAG,CAAC;AACpF,CAAC;AAtCD,oFAsCC","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, WritableXYAndZ, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { Cartographic, ColorByName, ColorDef, Frustum, GeoCoordStatus, GlobeMode, LinePixels } 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[]): Promise<Cartographic[]> {\r\n const scratch = new Point3d();\r\n const promises = db.map(async (p) => {\r\n return this.cartesianRange.containsPoint(Point3d.createFrom(p, scratch)) ? this._iModel.spatialToCartographic(p) : this.dbToCartographic(p);\r\n });\r\n\r\n return Promise.all(promises);\r\n }\r\n\r\n public async dbToWGS84CartographicFromGcs(db: XYAndZ[]): Promise<Cartographic[]> {\r\n if (db.length === 0)\r\n return [];\r\n\r\n const result: Cartographic[] = Array(db.length);\r\n const reproject: XYAndZ[] = [];\r\n const reprojectIdx: number[] = [];\r\n const scratch = new Point3d();\r\n for (let i = 0; i < db.length; i++) {\r\n Point3d.createFrom(db[i], scratch);\r\n if (this.cartesianRange.containsPoint(scratch) ) {\r\n reprojectIdx.push(i);\r\n reproject.push(db[i]);\r\n } else {\r\n result[i] = this.dbToCartographic(db[i]);\r\n }\r\n }\r\n\r\n if (reproject.length === 0)\r\n return result;\r\n\r\n const reprojectPromise = this._iModel.wgs84CartographicFromSpatial(reproject);\r\n return reprojectPromise.then((reprojected) => {\r\n if (reprojected.length === reprojectIdx.length) { // reprojected array size must match our index array, otherwise something is OFF\r\n for (let i = 0; i < reprojected.length; i++) {\r\n result[reprojectIdx[i]] = reprojected[i]; // Insert the reprojected values at their original index\r\n }\r\n }\r\n return result;\r\n });\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[]): Promise<Point3d[]> {\r\n let db;\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n db = cartographic.map((p) => {\r\n this._mercatorTilingScheme.cartographicToFraction(p.latitude, p.longitude, fraction);\r\n return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, p.height);\r\n });\r\n } else {\r\n db = cartographic.map((p) => this._ecefToDb.multiplyPoint3d(p.toEcef())!);\r\n }\r\n\r\n if (this._iModel.noGcsDefined)\r\n return db;\r\n\r\n const promises = db.map(async (p, i) => {\r\n return this.cartesianRange.containsPoint(p) ? this._iModel.cartographicToSpatialFromGcs(cartographic[i]) : p;\r\n });\r\n\r\n return Promise.all(promises);\r\n }\r\n\r\n public async cartographicToDbFromWgs84Gcs(cartographic: Cartographic[]): Promise<Point3d[]> {\r\n let db;\r\n if (this.globeMode === GlobeMode.Plane) {\r\n const fraction = Point2d.create(0, 0);\r\n db = cartographic.map((p) => {\r\n this._mercatorTilingScheme.cartographicToFraction(p.latitude, p.longitude, fraction);\r\n return this._mercatorFractionToDb.multiplyXYZ(fraction.x, fraction.y, p.height);\r\n });\r\n } else {\r\n db = cartographic.map((p) => this._ecefToDb.multiplyPoint3d(p.toEcef())!);\r\n }\r\n\r\n if (this._iModel.noGcsDefined)\r\n return db;\r\n\r\n const toReprojectCoords: WritableXYAndZ[] = [];\r\n const toReprojectIdx: number[] = [];\r\n db.forEach(async (p, i) => {\r\n if (this.cartesianRange.containsPoint(p)) {\r\n toReprojectCoords.push({x:cartographic[i].longitudeDegrees, y:cartographic[i].latitudeDegrees, z:cartographic[i].height});\r\n toReprojectIdx.push(i);\r\n }\r\n });\r\n const spatialPoints = await this._iModel.toSpatialFromGcs(toReprojectCoords, { horizontalCRS: { epsg: 4326 }, verticalCRS: { id: \"ELLIPSOID\" } });\r\n return db.map((p, i) => {\r\n const reprojectedIdx = toReprojectIdx.findIndex((value) => value === i);\r\n return (reprojectedIdx === -1 ? p : spatialPoints[reprojectedIdx]);\r\n });\r\n }\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\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)\r\n 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, LinePixels.Code2);\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"]}
@@ -267,7 +267,7 @@ class ArcGISMapLayerImageryProvider extends internal_1.ArcGISImageryProvider {
267
267
  const tolerancePixel = options?.tolerance ?? 7;
268
268
  const json = await this.getIdentifyData(quadId, carto, tolerancePixel, true, maxAllowableOffset);
269
269
  if (json && Array.isArray(json.results)) {
270
- const renderer = new internal_1.ArcGisGraphicsRenderer(hit.iModel);
270
+ const renderer = new internal_1.ArcGisGraphicsRenderer({ viewport: hit.viewport });
271
271
  const layerInfo = { layerName: this._settings.name, subLayerInfos: [] };
272
272
  // The 'identify' service returns us a flat/unordered list of records..
273
273
  // results may represent features for the a common subLayer.
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISMapLayerImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAiH;AACjH,kDAA+C;AAC/C,6CAIwB;AACxB,0DAA+E;AAC/E,wDAA+E;AAC/E,sDAA6C;AAG7C,MAAM,cAAc,GAAI,uDAAuD,CAAC;AA6DhF,gBAAgB;AAChB,MAAa,wBAAwB;IAC5B,MAAM,CAAC,QAAQ,CAAC,OAAmB,EAAE,IAAmC,EAAE,gBAAyB;QAExG,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,QAAQ,GAAG,GAAG,MAAM,CAAC,QAAQ,WAAW,CAAC;QAEhD,IAAI,IAAI,CAAC,CAAC,EAAE;YACV,MAAM,CAA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AgB,UAAU,SAAS,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,WAAW,IAAI,CAAC,cAAc,EAAE,2BAA2B,IAAI,CAAC,2BAA2B,+BAA+B,CAAC;SAC3N;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/TD,sEA+TC","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\nimport { Cartographic, ImageMapLayerSettings, ImageSource, IModelStatus, ServerError } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../../../IModelApp\";\r\nimport {\r\n ArcGisErrorCode, ArcGisGeometryReaderJSON, ArcGisGraphicsRenderer, ArcGISImageryProvider, ArcGISTileMap,\r\n ArcGisUtilities, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeature,\r\n MapLayerFeatureInfo, MapLayerImageryProviderStatus, MapSubLayerFeatureInfo, QuadId,\r\n} from \"../../internal\";\r\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\r\nimport { Point2d, Range2d, Range2dProps, XYProps } from \"@itwin/core-geometry\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { HitDetail } from \"../../../HitDetail\";\r\n\r\nconst loggerCategory = \"MapLayerImageryProvider.ArcGISMapLayerImageryProvider\";\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyImageDisplayProps {\r\n width: number;\r\n height: number;\r\n dpi: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyLayersProps {\r\n prefix: \"top\"|\"visible\"|\"all\";\r\n layerIds?: string[];\r\n}\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyRequestUrlProps {\r\n /** The geometry to identify on. Point only support */\r\n geometry: XYProps;\r\n\r\n /** The type of geometry specified by the geometry parameter. Point only support */\r\n geometryType: \"esriGeometryPoint\";\r\n\r\n /** The well-known ID of the spatial reference of the input and output geometries as well as the mapExtent. */\r\n sr?: number;\r\n\r\n /** The layers to perform the identify operation on. The default value is top.\r\n * Format: [top | visible | all]:layerId1,layerId2\r\n */\r\n layers?: ArcGISIdentifyLayersProps;\r\n\r\n /** The distance in screen pixels from the specified geometry within which the identify operation should be performed.\r\n * The value for the tolerance is an integer.\r\n */\r\n tolerance: number;\r\n\r\n /** The extent or bounding box of the map currently being viewed.\r\n * Format: <xmin>, <ymin>, <xmax>, <ymax>\r\n */\r\n mapExtent: Range2dProps;\r\n\r\n /** The screen image display parameters (width, height, and DPI) of the map being currently viewed. T\r\n * Format: <width>,<height>,<dpi>\r\n */\r\n imageDisplay: ArcGISIdentifyImageDisplayProps;\r\n\r\n /** If true, the result set will include the geometries associated with each result. The default is true.\r\n */\r\n returnGeometry?: boolean;\r\n\r\n /** This option can be used to specify the maximum allowable offset to be used for generalizing geometries returned by the identify operation.\r\n * The maxAllowableOffset is in the units of the sr.\r\n */\r\n maxAllowableOffset?: number;\r\n\r\n /** The response format. The default response format is html.\r\n */\r\n f?: \"json\"|\"html\";\r\n\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGISIdentifyRequestUrl {\r\n public static fromJSON(baseUrl: URL|string, json: ArcGISIdentifyRequestUrlProps, srFractionDigits?: number): URL {\r\n\r\n const newUrl = new URL(baseUrl);\r\n newUrl.pathname = `${newUrl.pathname}/identify`;\r\n\r\n if (json.f) {\r\n newUrl.searchParams.append(\"f\", json.f);\r\n }\r\n\r\n const geomPt = Point2d.fromJSON(json.geometry);\r\n newUrl.searchParams.append(\"geometry\", `${this.toFixed(geomPt.x, srFractionDigits)},${this.toFixed(geomPt.y, srFractionDigits)}`);\r\n newUrl.searchParams.append(\"geometryType\", json.geometryType);\r\n\r\n if (json.sr) {\r\n newUrl.searchParams.append(\"sr\", `${json.geometryType}`);\r\n }\r\n\r\n if (json.layers) {\r\n newUrl.searchParams.append(\"layers\", `${json.layers.prefix}${json.layers.layerIds?.length ? `: ${json.layers.layerIds.join(\",\")}` : \"\"}`);\r\n }\r\n\r\n newUrl.searchParams.append(\"tolerance\", `${json.tolerance}`);\r\n\r\n newUrl.searchParams.append(\"mapExtent\", ArcGISIdentifyRequestUrl.getExtentString(json.mapExtent, srFractionDigits));\r\n\r\n newUrl.searchParams.append(\"imageDisplay\", `${json.imageDisplay.width},${json.imageDisplay.height},${json.imageDisplay.dpi}`);\r\n\r\n if (json.returnGeometry !== undefined) {\r\n newUrl.searchParams.append(\"returnGeometry\", json.returnGeometry ? \"true\" : \"false\");\r\n }\r\n\r\n if (json.maxAllowableOffset !== undefined) {\r\n newUrl.searchParams.append(\"maxAllowableOffset\", `${this.toFixed(json.maxAllowableOffset, srFractionDigits)}`);\r\n }\r\n\r\n return newUrl;\r\n }\r\n\r\n public static toFixed(value: number, srFractionDigits?: number) {\r\n return srFractionDigits === undefined ? value.toString() : value.toFixed(srFractionDigits);\r\n }\r\n\r\n public static getExtentString(range: Range2dProps, srFractionDigits?: number) {\r\n const extent = Range2d.fromJSON(range);\r\n const extentStringArray: string[] = [];\r\n extent.toFloat64Array().forEach((value) => extentStringArray.push(this.toFixed(value, srFractionDigits)));\r\n return extentStringArray.join(\",\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGISMapLayerImageryProvider extends ArcGISImageryProvider {\r\n private _maxDepthFromLod = 0;\r\n private _minDepthFromLod = 0;\r\n private _copyrightText = \"Copyright\";\r\n private _tileMapSupported = false;\r\n private _mapSupported = false;\r\n private _tilesOnly = false;\r\n private _tileMap: ArcGISTileMap|undefined;\r\n\r\n public serviceJson: any;\r\n constructor(settings: ImageMapLayerSettings) {\r\n super(settings, false);\r\n this._accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(settings.formatId);\r\n }\r\n\r\n protected override get _filterByCartoRange() { return false; } // Can't trust footprint ranges (USGS Hydro)\r\n\r\n public override get minimumZoomLevel() { return Math.max(super.minimumZoomLevel, this._minDepthFromLod); }\r\n public override get maximumZoomLevel() { return this._maxDepthFromLod > 0 ? this._maxDepthFromLod : super.maximumZoomLevel; }\r\n\r\n public uintToString(uintArray: any) {\r\n return Buffer.from(uintArray).toJSON();\r\n\r\n }\r\n\r\n private async fetchTile(row: number, column: number, zoomLevel: number) {\r\n const tileUrl: string = await this.constructUrl(row, column, zoomLevel);\r\n if (tileUrl.length === 0)\r\n return undefined;\r\n return this.fetch(new URL(tileUrl), { method: \"GET\" });\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\r\n return undefined;\r\n }\r\n\r\n try {\r\n const tileResponse = await this.fetchTile(row, column, zoomLevel);\r\n if (tileResponse === undefined)\r\n return undefined;\r\n\r\n if (!this._hasSuccessfullyFetchedTile) {\r\n this._hasSuccessfullyFetchedTile = true;\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error) {\r\n Logger.logError(loggerCategory, `Error occurred when loading tile(${row},${column},${zoomLevel}) : ${error}`);\r\n return undefined;\r\n }\r\n }\r\n\r\n protected override _generateChildIds(quadId: QuadId, resolveChildren: (childIds: QuadId[]) => void) {\r\n const childIds = this.getPotentialChildIds(quadId);\r\n if (quadId.level < Math.max(1, this.minimumZoomLevel-1)) {\r\n resolveChildren(childIds);\r\n return;\r\n }\r\n\r\n if (this._tileMap) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._tileMap.getChildrenAvailability(childIds).then((availability) => {\r\n const availableChildIds = new Array<QuadId>();\r\n for (let i = 0; i < availability.length; i++)\r\n if (availability[i])\r\n availableChildIds.push(childIds[i]);\r\n\r\n resolveChildren (availableChildIds);\r\n });\r\n } else if (this._usesCachedTiles && this.cartoRange) {\r\n // Filter children by range\r\n const availableChildIds = new Array<QuadId>();\r\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\r\n for (let i = 0; i < childIds.length; i++) {\r\n const childExtent = this.getEPSG4326Extent(childIds[i].row, childIds[i].column, childIds[i].level);\r\n\r\n const childRange = MapCartoRectangle.fromDegrees(childExtent.longitudeLeft, childExtent.latitudeBottom, childExtent.longitudeRight, childExtent.latitudeTop);\r\n if (childRange.intersectsRange(this.cartoRange)) {\r\n availableChildIds.push(childIds[i]);\r\n }\r\n }\r\n resolveChildren (availableChildIds);\r\n } else {\r\n resolveChildren (childIds); // Resolve all children\r\n }\r\n }\r\n\r\n public override async initialize(): Promise<void> {\r\n\r\n const metadata = await this.getServiceJson();\r\n\r\n if (metadata?.content === undefined)\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n\r\n const json = metadata.content;\r\n if (json?.error?.code === ArcGisErrorCode.TokenRequired || json?.error?.code === ArcGisErrorCode.InvalidToken) {\r\n // Check again layer status, it might have change during await.\r\n if (this.status === MapLayerImageryProviderStatus.Valid) {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n return; // By returning (i.e not throwing), we ensure the tileTree get created and current provider is preserved to report status.\r\n }\r\n }\r\n\r\n this.serviceJson = json;\r\n\r\n if (json.capabilities) {\r\n const capabilities = json.capabilities.split(\",\");\r\n\r\n this._querySupported = capabilities.includes(\"Query\");\r\n this._tileMapSupported = capabilities.includes(\"Tilemap\");\r\n this._mapSupported = capabilities.includes(\"Map\");\r\n this._tilesOnly = capabilities.includes(\"TilesOnly\");\r\n }\r\n\r\n if (json.copyrightText)\r\n this._copyrightText = json.copyrightText;\r\n\r\n this._usesCachedTiles = !!json.tileInfo;\r\n\r\n if (this._usesCachedTiles) {\r\n // Only EPSG:3857 is supported with pre-rendered tiles. Fall back to 'Export' queries if possible otherwise throw.\r\n if (!ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\r\n if (this._mapSupported && !this._tilesOnly) {\r\n this._usesCachedTiles = false;\r\n } else {\r\n throw new ServerError(IModelStatus.ValidationFailed, \"Invalid coordinate system\");\r\n }\r\n }\r\n }\r\n\r\n if (this._usesCachedTiles) {\r\n // Read max LOD\r\n if (json.maxScale !== undefined && json.maxScale !== 0 && Array.isArray(json.tileInfo.lods)) {\r\n for (; this._maxDepthFromLod < json.tileInfo.lods.length && json.tileInfo.lods[this._maxDepthFromLod].scale > json.maxScale; this._maxDepthFromLod++)\r\n ;\r\n }\r\n\r\n // Create tile map object only if we are going to request tiles from this server and it support tilemap requests.\r\n if (this._tileMapSupported) {\r\n this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, json.tileInfo?.lods?.length, this._accessClient);\r\n }\r\n }\r\n\r\n // Read range using fullextent from service metadata\r\n if (json.fullExtent) {\r\n if (json.fullExtent.spatialReference.latestWkid === 3857 || json.fullExtent.spatialReference.wkid === 102100) {\r\n const range3857 = Range2d.createFrom({\r\n low: {x: json.fullExtent.xmin, y: json.fullExtent.ymin},\r\n high: {x: json.fullExtent.xmax, y: json.fullExtent.ymax} });\r\n\r\n const west = this.getEPSG4326Lon(range3857.xLow);\r\n const south = this.getEPSG4326Lat(range3857.yLow);\r\n const east = this.getEPSG4326Lon(range3857.xHigh);\r\n const north = this.getEPSG4326Lat(range3857.yHigh);\r\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\r\n }\r\n }\r\n\r\n // Read minLOD if available\r\n if (json.minLOD !== undefined) {\r\n const minLod = parseInt(json.minLOD, 10);\r\n if (!Number.isNaN(minLod)) {\r\n this._minDepthFromLod = minLod;\r\n }\r\n } else if (json.minScale) {\r\n // Read min LOD using minScale\r\n const minScale = json.minScale;\r\n if (json.tileInfo?.lods !== undefined && Array.isArray(json.tileInfo.lods)) {\r\n for (const lod of json.tileInfo.lods) {\r\n if (lod.scale < minScale) {\r\n this._minDepthFromLod = lod.level;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n }\r\n\r\n public override addLogoCards(cards: HTMLTableElement): void {\r\n if (!cards.dataset.arcGisLogoCard) {\r\n cards.dataset.arcGisLogoCard = \"true\";\r\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"ArcGIS\", notice: this._copyrightText }));\r\n }\r\n }\r\n\r\n // Translates the provided Cartographic into a EPSG:3857 point, and retrieve information.\r\n // tolerance is in pixels\r\n private async getIdentifyData(quadId: QuadId, carto: Cartographic, tolerance: number, returnGeometry?: boolean, maxAllowableOffset?: number): Promise<any> {\r\n\r\n const bbox = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const layerIds = new Array<string>();\r\n this._settings.subLayers.forEach((subLayer) => {\r\n if (this._settings.isSubLayerVisible(subLayer))\r\n layerIds.push(subLayer.idString);\r\n });\r\n const urlObj = ArcGISIdentifyRequestUrl.fromJSON(this._settings.url, {\r\n f: \"json\",\r\n geometry: {x: this.getEPSG3857X(carto.longitudeDegrees), y: this.getEPSG3857Y(carto.latitudeDegrees)},\r\n geometryType: \"esriGeometryPoint\",\r\n tolerance,\r\n mapExtent: {low: {x: bbox.left, y: bbox.bottom}, high: {x: bbox.right, y: bbox.top}},\r\n imageDisplay: {width: this.tileSize, height: this.tileSize, dpi: 96},\r\n layers: {prefix: \"visible\", layerIds},\r\n returnGeometry,\r\n maxAllowableOffset}, 3 /* 1mm accuracy*/);\r\n\r\n const response = await this.fetch(urlObj, { method: \"GET\" } );\r\n return response.json();\r\n }\r\n\r\n // Makes an identify request to ESRI MapService server, and return it as a list of formatted strings\r\n public override async getToolTip(strings: string[], quadId: QuadId, carto: Cartographic, tree: ImageryMapTileTree): Promise<void> {\r\n await super.getToolTip(strings, quadId, carto, tree);\r\n\r\n if (!this._querySupported)\r\n return;\r\n\r\n const stringSet = new Set<string>();\r\n const json = await this.getIdentifyData(quadId, carto, 1);\r\n\r\n if (json && Array.isArray(json.results)) {\r\n for (const result of json.results) {\r\n if (result.attributes !== undefined && result.attributes[result.displayFieldName] !== undefined) {\r\n const thisString = `${result.displayFieldName}: ${result.attributes[result.displayFieldName]}`;\r\n if (!stringSet.has(thisString)) {\r\n strings.push(thisString);\r\n stringSet.add(thisString);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\r\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\r\n if (!this._querySupported)\r\n return;\r\n\r\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n const maxAllowableOffsetFactor = 2;\r\n const maxAllowableOffset = maxAllowableOffsetFactor*toleranceWorld;\r\n\r\n const tolerancePixel = options?.tolerance ?? 7;\r\n const json = await this.getIdentifyData(quadId, carto, tolerancePixel, true, maxAllowableOffset);\r\n if (json && Array.isArray(json.results)) {\r\n const renderer = new ArcGisGraphicsRenderer(hit.iModel);\r\n\r\n const layerInfo: MapLayerFeatureInfo = { layerName: this._settings.name, subLayerInfos: [] };\r\n\r\n // The 'identify' service returns us a flat/unordered list of records..\r\n // results may represent features for the a common subLayer.\r\n // For simplicity, we group together features for a given sub-layer.\r\n const subLayers = new Map<string, MapSubLayerFeatureInfo> ();\r\n\r\n for (const result of json.results) {\r\n\r\n let subLayerInfo = subLayers.get(result.layerName);\r\n if (!subLayerInfo) {\r\n subLayerInfo = {\r\n subLayerName: result.layerName ?? \"\",\r\n displayFieldName: result.displayFieldName,\r\n features: [],\r\n };\r\n subLayers.set(result.layerName, subLayerInfo);\r\n }\r\n const feature: MapLayerFeature = {geometries: [], attributes: []};\r\n\r\n // Read all feature attributes\r\n for (const [key, value] of Object.entries(result.attributes)) {\r\n // Convert everything to string for now\r\n const strValue = String(value);\r\n feature.attributes.push({\r\n value: { valueFormat: PropertyValueFormat.Primitive, value: strValue, displayValue: strValue },\r\n property: { name: key, displayLabel: key, typename: StandardTypeNames.String },\r\n });\r\n }\r\n\r\n // Read feature geometries\r\n const geomReader = new ArcGisGeometryReaderJSON(result.geometryType, renderer);\r\n await geomReader.readGeometry(result.geometry);\r\n const graphics = renderer.moveGraphics();\r\n feature.geometries = graphics.map((graphic) => {\r\n return {graphic};\r\n });\r\n subLayerInfo.features.push(feature);\r\n\r\n }\r\n\r\n for ( const value of subLayers.values()) {\r\n layerInfo.subLayerInfos!.push(value);\r\n }\r\n\r\n featureInfos.push(layerInfo);\r\n }\r\n }\r\n\r\n protected getLayerString(prefix = \"show\"): string {\r\n const layers = new Array<string>();\r\n this._settings.subLayers.forEach((subLayer) => {\r\n if (this._settings.isSubLayerVisible(subLayer))\r\n layers.push(subLayer.idString);\r\n });\r\n\r\n return `${prefix}: ${layers.join(\",\")} `;\r\n }\r\n\r\n // construct the Url from the desired Tile\r\n public async constructUrl(row: number, column: number, zoomLevel: number): Promise<string> {\r\n let tmpUrl;\r\n if (this._usesCachedTiles) {\r\n tmpUrl = `${this._settings.url}/tile/${zoomLevel}/${row}/${column} `;\r\n } else {\r\n const bboxString = `${this.getEPSG3857ExtentString(row, column, zoomLevel)}&bboxSR=3857`;\r\n tmpUrl = `${this._settings.url}/export?bbox=${bboxString}&size=${this.tileSize},${this.tileSize}&layers=${this.getLayerString()}&format=png&transparent=${this.transparentBackgroundString}&f=image&sr=3857&imagesr=3857`;\r\n }\r\n return tmpUrl;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ArcGISMapLayerImageryProvider.js","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAiH;AACjH,kDAA+C;AAC/C,6CAIwB;AACxB,0DAA+E;AAC/E,wDAA+E;AAC/E,sDAA6C;AAG7C,MAAM,cAAc,GAAI,uDAAuD,CAAC;AA6DhF,gBAAgB;AAChB,MAAa,wBAAwB;IAC5B,MAAM,CAAC,QAAQ,CAAC,OAAmB,EAAE,IAAmC,EAAE,gBAAyB;QAExG,MAAM,MAAM,GAAG,IAAI,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AAC;SACtE;aAAM;YACL,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC;YACzF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,gBAAgB,UAAU,SAAS,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,WAAW,IAAI,CAAC,cAAc,EAAE,2BAA2B,IAAI,CAAC,2BAA2B,+BAA+B,CAAC;SAC3N;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/TD,sEA+TC","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\nimport { Cartographic, ImageMapLayerSettings, ImageSource, IModelStatus, ServerError } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../../../IModelApp\";\r\nimport {\r\n ArcGisErrorCode, ArcGisGeometryReaderJSON, ArcGisGraphicsRenderer, ArcGISImageryProvider, ArcGISTileMap,\r\n ArcGisUtilities, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeature,\r\n MapLayerFeatureInfo, MapLayerImageryProviderStatus, MapSubLayerFeatureInfo, QuadId,\r\n} from \"../../internal\";\r\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\r\nimport { Point2d, Range2d, Range2dProps, XYProps } from \"@itwin/core-geometry\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { HitDetail } from \"../../../HitDetail\";\r\n\r\nconst loggerCategory = \"MapLayerImageryProvider.ArcGISMapLayerImageryProvider\";\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyImageDisplayProps {\r\n width: number;\r\n height: number;\r\n dpi: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyLayersProps {\r\n prefix: \"top\"|\"visible\"|\"all\";\r\n layerIds?: string[];\r\n}\r\n\r\n/** @internal */\r\nexport interface ArcGISIdentifyRequestUrlProps {\r\n /** The geometry to identify on. Point only support */\r\n geometry: XYProps;\r\n\r\n /** The type of geometry specified by the geometry parameter. Point only support */\r\n geometryType: \"esriGeometryPoint\";\r\n\r\n /** The well-known ID of the spatial reference of the input and output geometries as well as the mapExtent. */\r\n sr?: number;\r\n\r\n /** The layers to perform the identify operation on. The default value is top.\r\n * Format: [top | visible | all]:layerId1,layerId2\r\n */\r\n layers?: ArcGISIdentifyLayersProps;\r\n\r\n /** The distance in screen pixels from the specified geometry within which the identify operation should be performed.\r\n * The value for the tolerance is an integer.\r\n */\r\n tolerance: number;\r\n\r\n /** The extent or bounding box of the map currently being viewed.\r\n * Format: <xmin>, <ymin>, <xmax>, <ymax>\r\n */\r\n mapExtent: Range2dProps;\r\n\r\n /** The screen image display parameters (width, height, and DPI) of the map being currently viewed. T\r\n * Format: <width>,<height>,<dpi>\r\n */\r\n imageDisplay: ArcGISIdentifyImageDisplayProps;\r\n\r\n /** If true, the result set will include the geometries associated with each result. The default is true.\r\n */\r\n returnGeometry?: boolean;\r\n\r\n /** This option can be used to specify the maximum allowable offset to be used for generalizing geometries returned by the identify operation.\r\n * The maxAllowableOffset is in the units of the sr.\r\n */\r\n maxAllowableOffset?: number;\r\n\r\n /** The response format. The default response format is html.\r\n */\r\n f?: \"json\"|\"html\";\r\n\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGISIdentifyRequestUrl {\r\n public static fromJSON(baseUrl: URL|string, json: ArcGISIdentifyRequestUrlProps, srFractionDigits?: number): URL {\r\n\r\n const newUrl = new URL(baseUrl);\r\n newUrl.pathname = `${newUrl.pathname}/identify`;\r\n\r\n if (json.f) {\r\n newUrl.searchParams.append(\"f\", json.f);\r\n }\r\n\r\n const geomPt = Point2d.fromJSON(json.geometry);\r\n newUrl.searchParams.append(\"geometry\", `${this.toFixed(geomPt.x, srFractionDigits)},${this.toFixed(geomPt.y, srFractionDigits)}`);\r\n newUrl.searchParams.append(\"geometryType\", json.geometryType);\r\n\r\n if (json.sr) {\r\n newUrl.searchParams.append(\"sr\", `${json.geometryType}`);\r\n }\r\n\r\n if (json.layers) {\r\n newUrl.searchParams.append(\"layers\", `${json.layers.prefix}${json.layers.layerIds?.length ? `: ${json.layers.layerIds.join(\",\")}` : \"\"}`);\r\n }\r\n\r\n newUrl.searchParams.append(\"tolerance\", `${json.tolerance}`);\r\n\r\n newUrl.searchParams.append(\"mapExtent\", ArcGISIdentifyRequestUrl.getExtentString(json.mapExtent, srFractionDigits));\r\n\r\n newUrl.searchParams.append(\"imageDisplay\", `${json.imageDisplay.width},${json.imageDisplay.height},${json.imageDisplay.dpi}`);\r\n\r\n if (json.returnGeometry !== undefined) {\r\n newUrl.searchParams.append(\"returnGeometry\", json.returnGeometry ? \"true\" : \"false\");\r\n }\r\n\r\n if (json.maxAllowableOffset !== undefined) {\r\n newUrl.searchParams.append(\"maxAllowableOffset\", `${this.toFixed(json.maxAllowableOffset, srFractionDigits)}`);\r\n }\r\n\r\n return newUrl;\r\n }\r\n\r\n public static toFixed(value: number, srFractionDigits?: number) {\r\n return srFractionDigits === undefined ? value.toString() : value.toFixed(srFractionDigits);\r\n }\r\n\r\n public static getExtentString(range: Range2dProps, srFractionDigits?: number) {\r\n const extent = Range2d.fromJSON(range);\r\n const extentStringArray: string[] = [];\r\n extent.toFloat64Array().forEach((value) => extentStringArray.push(this.toFixed(value, srFractionDigits)));\r\n return extentStringArray.join(\",\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGISMapLayerImageryProvider extends ArcGISImageryProvider {\r\n private _maxDepthFromLod = 0;\r\n private _minDepthFromLod = 0;\r\n private _copyrightText = \"Copyright\";\r\n private _tileMapSupported = false;\r\n private _mapSupported = false;\r\n private _tilesOnly = false;\r\n private _tileMap: ArcGISTileMap|undefined;\r\n\r\n public serviceJson: any;\r\n constructor(settings: ImageMapLayerSettings) {\r\n super(settings, false);\r\n this._accessClient = IModelApp.mapLayerFormatRegistry.getAccessClient(settings.formatId);\r\n }\r\n\r\n protected override get _filterByCartoRange() { return false; } // Can't trust footprint ranges (USGS Hydro)\r\n\r\n public override get minimumZoomLevel() { return Math.max(super.minimumZoomLevel, this._minDepthFromLod); }\r\n public override get maximumZoomLevel() { return this._maxDepthFromLod > 0 ? this._maxDepthFromLod : super.maximumZoomLevel; }\r\n\r\n public uintToString(uintArray: any) {\r\n return Buffer.from(uintArray).toJSON();\r\n\r\n }\r\n\r\n private async fetchTile(row: number, column: number, zoomLevel: number) {\r\n const tileUrl: string = await this.constructUrl(row, column, zoomLevel);\r\n if (tileUrl.length === 0)\r\n return undefined;\r\n return this.fetch(new URL(tileUrl), { method: \"GET\" });\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n if ((this.status === MapLayerImageryProviderStatus.RequireAuth)) {\r\n return undefined;\r\n }\r\n\r\n try {\r\n const tileResponse = await this.fetchTile(row, column, zoomLevel);\r\n if (tileResponse === undefined)\r\n return undefined;\r\n\r\n if (!this._hasSuccessfullyFetchedTile) {\r\n this._hasSuccessfullyFetchedTile = true;\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error) {\r\n Logger.logError(loggerCategory, `Error occurred when loading tile(${row},${column},${zoomLevel}) : ${error}`);\r\n return undefined;\r\n }\r\n }\r\n\r\n protected override _generateChildIds(quadId: QuadId, resolveChildren: (childIds: QuadId[]) => void) {\r\n const childIds = this.getPotentialChildIds(quadId);\r\n if (quadId.level < Math.max(1, this.minimumZoomLevel-1)) {\r\n resolveChildren(childIds);\r\n return;\r\n }\r\n\r\n if (this._tileMap) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._tileMap.getChildrenAvailability(childIds).then((availability) => {\r\n const availableChildIds = new Array<QuadId>();\r\n for (let i = 0; i < availability.length; i++)\r\n if (availability[i])\r\n availableChildIds.push(childIds[i]);\r\n\r\n resolveChildren (availableChildIds);\r\n });\r\n } else if (this._usesCachedTiles && this.cartoRange) {\r\n // Filter children by range\r\n const availableChildIds = new Array<QuadId>();\r\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\r\n for (let i = 0; i < childIds.length; i++) {\r\n const childExtent = this.getEPSG4326Extent(childIds[i].row, childIds[i].column, childIds[i].level);\r\n\r\n const childRange = MapCartoRectangle.fromDegrees(childExtent.longitudeLeft, childExtent.latitudeBottom, childExtent.longitudeRight, childExtent.latitudeTop);\r\n if (childRange.intersectsRange(this.cartoRange)) {\r\n availableChildIds.push(childIds[i]);\r\n }\r\n }\r\n resolveChildren (availableChildIds);\r\n } else {\r\n resolveChildren (childIds); // Resolve all children\r\n }\r\n }\r\n\r\n public override async initialize(): Promise<void> {\r\n\r\n const metadata = await this.getServiceJson();\r\n\r\n if (metadata?.content === undefined)\r\n throw new ServerError(IModelStatus.ValidationFailed, \"\");\r\n\r\n const json = metadata.content;\r\n if (json?.error?.code === ArcGisErrorCode.TokenRequired || json?.error?.code === ArcGisErrorCode.InvalidToken) {\r\n // Check again layer status, it might have change during await.\r\n if (this.status === MapLayerImageryProviderStatus.Valid) {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n return; // By returning (i.e not throwing), we ensure the tileTree get created and current provider is preserved to report status.\r\n }\r\n }\r\n\r\n this.serviceJson = json;\r\n\r\n if (json.capabilities) {\r\n const capabilities = json.capabilities.split(\",\");\r\n\r\n this._querySupported = capabilities.includes(\"Query\");\r\n this._tileMapSupported = capabilities.includes(\"Tilemap\");\r\n this._mapSupported = capabilities.includes(\"Map\");\r\n this._tilesOnly = capabilities.includes(\"TilesOnly\");\r\n }\r\n\r\n if (json.copyrightText)\r\n this._copyrightText = json.copyrightText;\r\n\r\n this._usesCachedTiles = !!json.tileInfo;\r\n\r\n if (this._usesCachedTiles) {\r\n // Only EPSG:3857 is supported with pre-rendered tiles. Fall back to 'Export' queries if possible otherwise throw.\r\n if (!ArcGisUtilities.isEpsg3857Compatible(json.tileInfo)) {\r\n if (this._mapSupported && !this._tilesOnly) {\r\n this._usesCachedTiles = false;\r\n } else {\r\n throw new ServerError(IModelStatus.ValidationFailed, \"Invalid coordinate system\");\r\n }\r\n }\r\n }\r\n\r\n if (this._usesCachedTiles) {\r\n // Read max LOD\r\n if (json.maxScale !== undefined && json.maxScale !== 0 && Array.isArray(json.tileInfo.lods)) {\r\n for (; this._maxDepthFromLod < json.tileInfo.lods.length && json.tileInfo.lods[this._maxDepthFromLod].scale > json.maxScale; this._maxDepthFromLod++)\r\n ;\r\n }\r\n\r\n // Create tile map object only if we are going to request tiles from this server and it support tilemap requests.\r\n if (this._tileMapSupported) {\r\n this._tileMap = new ArcGISTileMap(this._settings.url, this._settings, json.tileInfo?.lods?.length, this._accessClient);\r\n }\r\n }\r\n\r\n // Read range using fullextent from service metadata\r\n if (json.fullExtent) {\r\n if (json.fullExtent.spatialReference.latestWkid === 3857 || json.fullExtent.spatialReference.wkid === 102100) {\r\n const range3857 = Range2d.createFrom({\r\n low: {x: json.fullExtent.xmin, y: json.fullExtent.ymin},\r\n high: {x: json.fullExtent.xmax, y: json.fullExtent.ymax} });\r\n\r\n const west = this.getEPSG4326Lon(range3857.xLow);\r\n const south = this.getEPSG4326Lat(range3857.yLow);\r\n const east = this.getEPSG4326Lon(range3857.xHigh);\r\n const north = this.getEPSG4326Lat(range3857.yHigh);\r\n this.cartoRange = MapCartoRectangle.fromDegrees(west, south, east, north);\r\n }\r\n }\r\n\r\n // Read minLOD if available\r\n if (json.minLOD !== undefined) {\r\n const minLod = parseInt(json.minLOD, 10);\r\n if (!Number.isNaN(minLod)) {\r\n this._minDepthFromLod = minLod;\r\n }\r\n } else if (json.minScale) {\r\n // Read min LOD using minScale\r\n const minScale = json.minScale;\r\n if (json.tileInfo?.lods !== undefined && Array.isArray(json.tileInfo.lods)) {\r\n for (const lod of json.tileInfo.lods) {\r\n if (lod.scale < minScale) {\r\n this._minDepthFromLod = lod.level;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n }\r\n\r\n public override addLogoCards(cards: HTMLTableElement): void {\r\n if (!cards.dataset.arcGisLogoCard) {\r\n cards.dataset.arcGisLogoCard = \"true\";\r\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"ArcGIS\", notice: this._copyrightText }));\r\n }\r\n }\r\n\r\n // Translates the provided Cartographic into a EPSG:3857 point, and retrieve information.\r\n // tolerance is in pixels\r\n private async getIdentifyData(quadId: QuadId, carto: Cartographic, tolerance: number, returnGeometry?: boolean, maxAllowableOffset?: number): Promise<any> {\r\n\r\n const bbox = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const layerIds = new Array<string>();\r\n this._settings.subLayers.forEach((subLayer) => {\r\n if (this._settings.isSubLayerVisible(subLayer))\r\n layerIds.push(subLayer.idString);\r\n });\r\n const urlObj = ArcGISIdentifyRequestUrl.fromJSON(this._settings.url, {\r\n f: \"json\",\r\n geometry: {x: this.getEPSG3857X(carto.longitudeDegrees), y: this.getEPSG3857Y(carto.latitudeDegrees)},\r\n geometryType: \"esriGeometryPoint\",\r\n tolerance,\r\n mapExtent: {low: {x: bbox.left, y: bbox.bottom}, high: {x: bbox.right, y: bbox.top}},\r\n imageDisplay: {width: this.tileSize, height: this.tileSize, dpi: 96},\r\n layers: {prefix: \"visible\", layerIds},\r\n returnGeometry,\r\n maxAllowableOffset}, 3 /* 1mm accuracy*/);\r\n\r\n const response = await this.fetch(urlObj, { method: \"GET\" } );\r\n return response.json();\r\n }\r\n\r\n // Makes an identify request to ESRI MapService server, and return it as a list of formatted strings\r\n public override async getToolTip(strings: string[], quadId: QuadId, carto: Cartographic, tree: ImageryMapTileTree): Promise<void> {\r\n await super.getToolTip(strings, quadId, carto, tree);\r\n\r\n if (!this._querySupported)\r\n return;\r\n\r\n const stringSet = new Set<string>();\r\n const json = await this.getIdentifyData(quadId, carto, 1);\r\n\r\n if (json && Array.isArray(json.results)) {\r\n for (const result of json.results) {\r\n if (result.attributes !== undefined && result.attributes[result.displayFieldName] !== undefined) {\r\n const thisString = `${result.displayFieldName}: ${result.attributes[result.displayFieldName]}`;\r\n if (!stringSet.has(thisString)) {\r\n strings.push(thisString);\r\n stringSet.add(thisString);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Makes an identify request to ESRI MapService , and return it as a list MapLayerFeatureInfo object\r\n public override async getFeatureInfo(featureInfos: MapLayerFeatureInfo[], quadId: QuadId, carto: Cartographic, _tree: ImageryMapTileTree, hit: HitDetail, options?: MapFeatureInfoOptions): Promise<void> {\r\n if (!this._querySupported)\r\n return;\r\n\r\n const tileExtent = this.getEPSG3857Extent(quadId.row, quadId.column, quadId.level);\r\n const toleranceWorld = (tileExtent.top - tileExtent.bottom) / this.tileSize;\r\n const maxAllowableOffsetFactor = 2;\r\n const maxAllowableOffset = maxAllowableOffsetFactor*toleranceWorld;\r\n\r\n const tolerancePixel = options?.tolerance ?? 7;\r\n const json = await this.getIdentifyData(quadId, carto, tolerancePixel, true, maxAllowableOffset);\r\n if (json && Array.isArray(json.results)) {\r\n const renderer = new ArcGisGraphicsRenderer({viewport: hit.viewport});\r\n\r\n const layerInfo: MapLayerFeatureInfo = { layerName: this._settings.name, subLayerInfos: [] };\r\n\r\n // The 'identify' service returns us a flat/unordered list of records..\r\n // results may represent features for the a common subLayer.\r\n // For simplicity, we group together features for a given sub-layer.\r\n const subLayers = new Map<string, MapSubLayerFeatureInfo> ();\r\n\r\n for (const result of json.results) {\r\n\r\n let subLayerInfo = subLayers.get(result.layerName);\r\n if (!subLayerInfo) {\r\n subLayerInfo = {\r\n subLayerName: result.layerName ?? \"\",\r\n displayFieldName: result.displayFieldName,\r\n features: [],\r\n };\r\n subLayers.set(result.layerName, subLayerInfo);\r\n }\r\n const feature: MapLayerFeature = {geometries: [], attributes: []};\r\n\r\n // Read all feature attributes\r\n for (const [key, value] of Object.entries(result.attributes)) {\r\n // Convert everything to string for now\r\n const strValue = String(value);\r\n feature.attributes.push({\r\n value: { valueFormat: PropertyValueFormat.Primitive, value: strValue, displayValue: strValue },\r\n property: { name: key, displayLabel: key, typename: StandardTypeNames.String },\r\n });\r\n }\r\n\r\n // Read feature geometries\r\n const geomReader = new ArcGisGeometryReaderJSON(result.geometryType, renderer);\r\n await geomReader.readGeometry(result.geometry);\r\n const graphics = renderer.moveGraphics();\r\n feature.geometries = graphics.map((graphic) => {\r\n return {graphic};\r\n });\r\n subLayerInfo.features.push(feature);\r\n\r\n }\r\n\r\n for ( const value of subLayers.values()) {\r\n layerInfo.subLayerInfos!.push(value);\r\n }\r\n\r\n featureInfos.push(layerInfo);\r\n }\r\n }\r\n\r\n protected getLayerString(prefix = \"show\"): string {\r\n const layers = new Array<string>();\r\n this._settings.subLayers.forEach((subLayer) => {\r\n if (this._settings.isSubLayerVisible(subLayer))\r\n layers.push(subLayer.idString);\r\n });\r\n\r\n return `${prefix}: ${layers.join(\",\")} `;\r\n }\r\n\r\n // construct the Url from the desired Tile\r\n public async constructUrl(row: number, column: number, zoomLevel: number): Promise<string> {\r\n let tmpUrl;\r\n if (this._usesCachedTiles) {\r\n tmpUrl = `${this._settings.url}/tile/${zoomLevel}/${row}/${column} `;\r\n } else {\r\n const bboxString = `${this.getEPSG3857ExtentString(row, column, zoomLevel)}&bboxSR=3857`;\r\n tmpUrl = `${this._settings.url}/export?bbox=${bboxString}&size=${this.tileSize},${this.tileSize}&layers=${this.getLayerString()}&format=png&transparent=${this.transparentBackgroundString}&f=image&sr=3857&imagesr=3857`;\r\n }\r\n return tmpUrl;\r\n }\r\n}\r\n"]}
@@ -1,6 +1,14 @@
1
1
  import { ArcGisAttributeDrivenSymbology, ArcGisGeometryBaseRenderer } from "../../internal";
2
2
  import { GraphicPrimitive } from "../../../render/GraphicPrimitive";
3
- import { IModelConnection } from "../../../IModelConnection";
3
+ import { Viewport } from "../../../Viewport";
4
+ /**
5
+ * Properties of [[ArcGisGraphicsRenderer]]
6
+ * @internal
7
+ */
8
+ export interface ArcGisGraphicsRendererProps {
9
+ /** The viewport in which the resultant [GraphicPrimitive]($frontend) is to be drawn. */
10
+ viewport: Viewport;
11
+ }
4
12
  /** ArcGIS geometry renderer implementation that will "render" a list of [GraphicPrimitive]($frontend)
5
13
  * This renderer initial objective is to read geometries when a call to [[MapLayerImageryProvider.getFeatureInfo]] is performed.
6
14
  * @internal
@@ -10,8 +18,9 @@ export declare class ArcGisGraphicsRenderer extends ArcGisGeometryBaseRenderer {
10
18
  private _scratchPaths;
11
19
  private _graphics;
12
20
  private _iModel;
21
+ private _viewport;
13
22
  get attributeSymbology(): ArcGisAttributeDrivenSymbology | undefined;
14
- constructor(iModel: IModelConnection);
23
+ constructor(props: ArcGisGraphicsRendererProps);
15
24
  moveGraphics(): GraphicPrimitive[];
16
25
  protected beginPath(): void;
17
26
  protected closePath(): void;
@@ -21,7 +30,6 @@ export declare class ArcGisGraphicsRenderer extends ArcGisGeometryBaseRenderer {
21
30
  protected stroke(): Promise<void>;
22
31
  protected drawPoint(x: number, y: number): void;
23
32
  protected finishPoints(): Promise<void>;
24
- private toSpatialFromGcs;
25
- private toSpatialFromEcf;
33
+ private toSpatial;
26
34
  }
27
35
  //# sourceMappingURL=ArcGisGraphicsRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGisGraphicsRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/tile/map/ImageryProviders/ArcGisGraphicsRenderer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAAe,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;IACpE,OAAO,CAAC,mBAAmB,CAA0B;IACrD,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,SAAS,CA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