@itwin/core-frontend 4.10.0-dev.29 → 4.10.0-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/tile/map/MapTilingScheme.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTilingScheme.js +4 -0
- package/lib/cjs/tile/map/MapTilingScheme.js.map +1 -1
- package/lib/esm/tile/map/MapTilingScheme.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTilingScheme.js +4 -0
- package/lib/esm/tile/map/MapTilingScheme.js.map +1 -1
- package/package.json +26 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapTilingScheme.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/MapTilingScheme.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAmB,OAAO,EAAW,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,8BAAsB,eAAe;IACnC;;OAEG;IACH,SAAgB,kBAAkB,EAAE,OAAO,CAAC;IAC5C,0EAA0E;IAC1E,SAAgB,uBAAuB,SAAC;IACxC,0EAA0E;IAC1E,SAAgB,uBAAuB,SAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwB;IAExD,wFAAwF;IACjF,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAI7C,2FAA2F;IACpF,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAI7C,8FAA8F;aAC9E,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAE9D,8FAA8F;aAC9E,mBAAmB,CAAC,QAAQ,EAAE,MAAM,G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Q;IAIvG,0DAA0D;IACnD,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIrD,0DAA0D;IACnD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGrD;AAED,aAAa;AACb,qBAAa,qBAAqB;IAChC;;;;;;OAMG;WACW,+BAA+B,CAAC,aAAa,EAAE,MAAM;IAInE,OAAc,eAAe,SAA0E;WAEzF,+BAA+B,CAAC,QAAQ,EAAE,MAAM;CAU/D;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;gBACvC,uBAAuB,SAAI,EAAE,uBAAuB,SAAI,EAAE,kBAAkB,UAAO;IAItG,0DAA0D;IACnD,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAKrD,wDAAwD;IACjD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAUrD"}
|
|
@@ -143,6 +143,8 @@ class MapTilingScheme {
|
|
|
143
143
|
/** @alpha */
|
|
144
144
|
ecefToPixelFraction(point, applyTerrain) {
|
|
145
145
|
const cartoGraphic = core_common_1.Cartographic.fromEcef(point);
|
|
146
|
+
if (!cartoGraphic)
|
|
147
|
+
return undefined;
|
|
146
148
|
return core_geometry_1.Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);
|
|
147
149
|
}
|
|
148
150
|
/** @alpha */
|
|
@@ -154,6 +156,8 @@ class MapTilingScheme {
|
|
|
154
156
|
const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);
|
|
155
157
|
const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);
|
|
156
158
|
const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);
|
|
159
|
+
if (!mercatorOrigin || !mercatorX || !mercatorY)
|
|
160
|
+
return core_geometry_1.Transform.createIdentity();
|
|
157
161
|
const deltaX = core_geometry_1.Vector3d.createStartEnd(mercatorOrigin, mercatorX);
|
|
158
162
|
const deltaY = core_geometry_1.Vector3d.createStartEnd(mercatorOrigin, mercatorY);
|
|
159
163
|
const matrix = core_geometry_1.Matrix3d.createColumns(deltaX, deltaY, core_geometry_1.Vector3d.create(0, 0, 1));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapTilingScheme.js","sourceRoot":"","sources":["../../../../src/tile/map/MapTilingScheme.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAA8F;AAC9F,oDAAkD;AAElD,0CAAgD;AAEhD;;;;;;;;;GASG;AACH,MAAsB,eAAe;IAYnC,wFAAwF;IACjF,oBAAoB,CAAC,SAAiB;QAC3C,OAAO,SAAS,GAAG,qBAAK,CAAC,UAAU,GAAG,EAAE,CAAC;IAC3C,CAAC;IAED,2FAA2F;IACpF,oBAAoB,CAAC,SAAiB;QAC3C,OAAO,qBAAK,CAAC,UAAU,GAAG,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;IAC7C,CAAC;IAQD,YAAsB,uBAA+B,EAAE,uBAA+B,EAAE,kBAA2B;QAnBlG,qBAAgB,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;QACxC,oBAAe,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;QAmBtD,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QACvD,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;IACzD,CAAC;IAED;;OAEG;IACI,wBAAwB,CAAC,KAAa;QAC3C,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,uBAAuB,IAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACI,wBAAwB,CAAC,KAAa;QAC3C,OAAQ,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CAAC;QACpD,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,qBAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAG,yDAAyD;IAC3J,CAAC;CACF;AAtBD,0DAsBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { Angle, Matrix3d, Point2d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapCartoRectangle } from \"../internal\";\r\n\r\n/** A scheme for converting between two representations of the surface of the Earth: an ellipsoid and a rectangular [tiled map](https://en.wikipedia.org/wiki/Tiled_web_map).\r\n * Positions on the surface of the ellipsoid are expressed in [Cartographic]($common) coordinates.\r\n * Rectangular [[MapTile]]s are projected onto this ellipsoid by the tiling scheme. Tile coordinates are represented by [[QuadId]]s.\r\n *\r\n * The tiling scheme represents the (x,y) coordinates of its tiles as fractions in [0,1] along the X and Y axes.\r\n * An X fraction of 0 corresponds to the easternmost longitude and an X fraction of 1 to the westernmost longitude.\r\n * The scheme can choose to correlate a Y fraction of 0 with either the north or south pole, as specified by [[rowZeroAtNorthPole]].\r\n * Implementing a tiling scheme only requires implementing the abstract method [[yFractionToLatitude]] and its inverse, [[latitudeToYFraction]].\r\n * @public\r\n */\r\nexport abstract class MapTilingScheme {\r\n /** If true, the fractional Y coordinate 0 corresponds to the north pole and 1 to the south pole; otherwise,\r\n * 0 corresponds to the south pole and 1 to the north.\r\n */\r\n public readonly rowZeroAtNorthPole: boolean;\r\n /** The number of tiles in the X direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesX;\r\n /** The number of tiles in the Y direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesY;\r\n private readonly _scratchFraction = Point2d.createZero();\r\n private readonly _scratchPoint2d = Point2d.createZero();\r\n\r\n /** Convert a longitude in [-pi, pi] radisn to a fraction in [0, 1] along the X axis. */\r\n public longitudeToXFraction(longitude: number) {\r\n return longitude / Angle.pi2Radians + .5;\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the X axis into a longitude in [-pi, pi] radians. */\r\n public xFractionToLongitude(xFraction: number) {\r\n return Angle.pi2Radians * (xFraction - .5);\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the Y axis into a latitude in [-pi/2, pi/2] radians. */\r\n public abstract yFractionToLatitude(yFraction: number): number;\r\n\r\n /** Convert a latitude in [-pi/2, pi/2] radians into a fraction in [0, 1] along the Y axis. */\r\n public abstract latitudeToYFraction(latitude: number): number;\r\n\r\n protected constructor(numberOfLevelZeroTilesX: number, numberOfLevelZeroTilesY: number, rowZeroAtNorthPole: boolean) {\r\n this.rowZeroAtNorthPole = rowZeroAtNorthPole;\r\n this.numberOfLevelZeroTilesX = numberOfLevelZeroTilesX;\r\n this.numberOfLevelZeroTilesY = numberOfLevelZeroTilesY;\r\n }\r\n\r\n /** The total number of tiles in the X direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfXTilesAtLevel(level: number) {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesX << level;\r\n }\r\n\r\n /** The total number of tiles in the Y direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfYTilesAtLevel(level: number): number {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesY << level;\r\n }\r\n\r\n /** @alpha */\r\n public get rootLevel() {\r\n return this.numberOfLevelZeroTilesX > 1 || this.numberOfLevelZeroTilesY > 1 ? -1 : 0;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfXChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesX : 2;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfYChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesY : 2;\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], convert it to a fractional distance along the X axis. */\r\n public tileXToFraction(x: number, level: number): number {\r\n return x / this.getNumberOfXTilesAtLevel(level);\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], convert it to a fractional distance along the Y axis. */\r\n public tileYToFraction(y: number, level: number): number {\r\n return y / this.getNumberOfYTilesAtLevel(level);\r\n }\r\n\r\n /** Given a fractional distance along the X axis and a level of the quad tree, compute the X component of the corresponding [[QuadId]]. */\r\n public xFractionToTileX(xFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfXTilesAtLevel(level);\r\n return Math.min(Math.floor(xFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given a fractional distance along the Y axis and a level of the quad tree, compute the Y component of the corresponding [[QuadId]]. */\r\n public yFractionToTileY(yFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfYTilesAtLevel(level);\r\n return Math.min(Math.floor(yFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], compute its longitude in [-pi, pi] radians. */\r\n public tileXToLongitude(x: number, level: number) {\r\n return this.xFractionToLongitude(this.tileXToFraction(x, level));\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], compute its latitude in [-pi/2, pi/2] radians. */\r\n public tileYToLatitude(y: number, level: number) {\r\n return this.yFractionToLatitude(this.tileYToFraction(y, level));\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute its fractional coordinates in the XY plane. */\r\n public tileXYToFraction(x: number, y: number, level: number, result?: Point2d): Point2d {\r\n if (undefined === result)\r\n result = Point2d.createZero();\r\n\r\n result.x = this.tileXToFraction(x, level);\r\n result.y = this.tileYToFraction(y, level);\r\n\r\n return result;\r\n }\r\n\r\n /** Given the components of a [[QuadId]] and an elevation, compute the corresponding [Cartographic]($common) position.\r\n * @param x The X component of the QuadId.\r\n * @param y The Y component of the QuadId.\r\n * @param level The level component of the QuadId.\r\n * @param height The elevation above the ellipsoid.\r\n * @returns the corresponding cartographic position.\r\n */\r\n public tileXYToCartographic(x: number, y: number, level: number, result: Cartographic, height = 0): Cartographic {\r\n const pt = this.tileXYToFraction(x, y, level, this._scratchFraction);\r\n return this.fractionToCartographic(pt.x, pt.y, result, height);\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute the corresponding region of the Earth's surface. */\r\n public tileXYToRectangle(x: number, y: number, level: number, result?: MapCartoRectangle) {\r\n if (level < 0)\r\n return MapCartoRectangle.createMaximum();\r\n\r\n return MapCartoRectangle.fromRadians(\r\n this.tileXToLongitude(x, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? (y + 1) : y, level),\r\n this.tileXToLongitude(x + 1, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? y : (y + 1), level),\r\n result,\r\n );\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the north pole. */\r\n public tileBordersNorthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row, level) === 0.0 : this.tileYToFraction(row + 1, level) === 1.0;\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the south pole. */\r\n public tileBordersSouthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row + 1, level) === 1.0 : this.tileYToFraction(row, level) === 0.0;\r\n }\r\n\r\n /** Given a cartographic position, compute the corresponding position on the surface of the Earth as fractional distances along the\r\n * X and Y axes.\r\n */\r\n public cartographicToTileXY(carto: Cartographic, level: number, result?: Point2d): Point2d {\r\n const fraction = this.cartographicToFraction(carto.latitude, carto.longitude, this._scratchPoint2d);\r\n return Point2d.create(this.xFractionToTileX(fraction.x, level), this.yFractionToTileY(fraction.y, level), result);\r\n\r\n }\r\n\r\n /** Given fractional coordinates in the XY plane and an elevation, compute the corresponding cartographic position. */\r\n public fractionToCartographic(xFraction: number, yFraction: number, result: Cartographic, height = 0): Cartographic {\r\n result.longitude = this.xFractionToLongitude(xFraction);\r\n result.latitude = this.yFractionToLatitude(yFraction);\r\n result.height = height;\r\n return result;\r\n }\r\n\r\n /** Given a cartographic location on the surface of the Earth, convert it to fractional coordinates in the XY plane. */\r\n public cartographicToFraction(latitudeRadians: number, longitudeRadians: number, result: Point2d): Point2d {\r\n result.x = this.longitudeToXFraction(longitudeRadians);\r\n result.y = this.latitudeToYFraction(latitudeRadians);\r\n return result;\r\n }\r\n\r\n /** @alpha */\r\n private ecefToPixelFraction(point: Point3d, applyTerrain: boolean): Point3d {\r\n const cartoGraphic = Cartographic.fromEcef(point)!;\r\n return Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);\r\n }\r\n\r\n /** @alpha */\r\n public computeMercatorFractionToDb(ecefToDb: Transform, bimElevationOffset: number, iModel: IModelConnection, applyTerrain: boolean) {\r\n const dbToEcef = ecefToDb.inverse()!;\r\n\r\n const projectCenter = Point3d.create(iModel.projectExtents.center.x, iModel.projectExtents.center.y, bimElevationOffset);\r\n const projectEast = projectCenter.plusXYZ(1, 0, 0);\r\n const projectNorth = projectCenter.plusXYZ(0, 1, 0);\r\n\r\n const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);\r\n const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);\r\n const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);\r\n\r\n const deltaX = Vector3d.createStartEnd(mercatorOrigin, mercatorX);\r\n const deltaY = Vector3d.createStartEnd(mercatorOrigin, mercatorY);\r\n const matrix = Matrix3d.createColumns(deltaX, deltaY, Vector3d.create(0, 0, 1));\r\n\r\n const dbToMercator = Transform.createMatrixPickupPutdown(matrix, projectCenter, mercatorOrigin);\r\n const mercatorToDb = dbToMercator.inverse();\r\n return mercatorToDb === undefined ? Transform.createIdentity() : mercatorToDb;\r\n }\r\n\r\n /** @alpha */\r\n protected yFractionFlip(fraction: number) {\r\n return this.rowZeroAtNorthPole ? (1.0 - fraction) : fraction;\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using a simple geographic projection by which longitude and latitude are mapped directly to X and Y.\r\n * This projection is commonly known as \"geographic\", \"equirectangular\", \"equidistant cylindrical\", or \"plate carrée\".\r\n * @beta\r\n */\r\nexport class GeographicTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 2, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = false) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n return Math.PI * (this.yFractionFlip(yFraction) - .5);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction]]. */\r\n public latitudeToYFraction(latitude: number): number {\r\n return this.yFractionFlip(.5 + latitude / Math.PI);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class WebMercatorProjection {\r\n /**\r\n * Converts a Mercator angle, in the range -PI to PI, to a geodetic latitude\r\n * in the range -PI/2 to PI/2.\r\n *\r\n * @param {Number} mercatorAngle The angle to convert.\r\n * @returns {Number} The geodetic latitude in radians.\r\n */\r\n public static mercatorAngleToGeodeticLatitude(mercatorAngle: number) {\r\n return Angle.piOver2Radians - (2.0 * Math.atan(Math.exp(-mercatorAngle)));\r\n }\r\n\r\n public static maximumLatitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(Angle.piRadians);\r\n\r\n public static geodeticLatitudeToMercatorAngle(latitude: number) {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude)\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n else if (latitude < -WebMercatorProjection.maximumLatitude)\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n\r\n const sinLatitude = Math.sin(latitude);\r\n return 0.5 * Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude));\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using the [EPSG:3857](https://en.wikipedia.org/wiki/Web_Mercator_projection) projection.\r\n * This scheme is used by most [tiled web maps](https://en.wikipedia.org/wiki/Tiled_web_map), including Bing Maps and Google Maps.\r\n * @beta\r\n */\r\nexport class WebMercatorTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 1, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = true) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n const mercatorAngle = Angle.pi2Radians * (this.rowZeroAtNorthPole ? (.5 - yFraction) : (yFraction - .5));\r\n return WebMercatorProjection.mercatorAngleToGeodeticLatitude(mercatorAngle);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction. */\r\n public latitudeToYFraction(latitude: number): number {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude) {\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n } else if (latitude < -WebMercatorProjection.maximumLatitude) {\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n }\r\n const sinLatitude = Math.sin(latitude);\r\n return (0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Angle.piRadians)); // https://msdn.microsoft.com/en-us/library/bb259689.aspx\r\n }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C,CAAC;QACvC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,qBAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAG,yDAAyD;IAC3J,CAAC;CACF;AAtBD,0DAsBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { Angle, Matrix3d, Point2d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapCartoRectangle } from \"../internal\";\r\n\r\n/** A scheme for converting between two representations of the surface of the Earth: an ellipsoid and a rectangular [tiled map](https://en.wikipedia.org/wiki/Tiled_web_map).\r\n * Positions on the surface of the ellipsoid are expressed in [Cartographic]($common) coordinates.\r\n * Rectangular [[MapTile]]s are projected onto this ellipsoid by the tiling scheme. Tile coordinates are represented by [[QuadId]]s.\r\n *\r\n * The tiling scheme represents the (x,y) coordinates of its tiles as fractions in [0,1] along the X and Y axes.\r\n * An X fraction of 0 corresponds to the easternmost longitude and an X fraction of 1 to the westernmost longitude.\r\n * The scheme can choose to correlate a Y fraction of 0 with either the north or south pole, as specified by [[rowZeroAtNorthPole]].\r\n * Implementing a tiling scheme only requires implementing the abstract method [[yFractionToLatitude]] and its inverse, [[latitudeToYFraction]].\r\n * @public\r\n */\r\nexport abstract class MapTilingScheme {\r\n /** If true, the fractional Y coordinate 0 corresponds to the north pole and 1 to the south pole; otherwise,\r\n * 0 corresponds to the south pole and 1 to the north.\r\n */\r\n public readonly rowZeroAtNorthPole: boolean;\r\n /** The number of tiles in the X direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesX;\r\n /** The number of tiles in the Y direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesY;\r\n private readonly _scratchFraction = Point2d.createZero();\r\n private readonly _scratchPoint2d = Point2d.createZero();\r\n\r\n /** Convert a longitude in [-pi, pi] radisn to a fraction in [0, 1] along the X axis. */\r\n public longitudeToXFraction(longitude: number) {\r\n return longitude / Angle.pi2Radians + .5;\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the X axis into a longitude in [-pi, pi] radians. */\r\n public xFractionToLongitude(xFraction: number) {\r\n return Angle.pi2Radians * (xFraction - .5);\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the Y axis into a latitude in [-pi/2, pi/2] radians. */\r\n public abstract yFractionToLatitude(yFraction: number): number;\r\n\r\n /** Convert a latitude in [-pi/2, pi/2] radians into a fraction in [0, 1] along the Y axis. */\r\n public abstract latitudeToYFraction(latitude: number): number;\r\n\r\n protected constructor(numberOfLevelZeroTilesX: number, numberOfLevelZeroTilesY: number, rowZeroAtNorthPole: boolean) {\r\n this.rowZeroAtNorthPole = rowZeroAtNorthPole;\r\n this.numberOfLevelZeroTilesX = numberOfLevelZeroTilesX;\r\n this.numberOfLevelZeroTilesY = numberOfLevelZeroTilesY;\r\n }\r\n\r\n /** The total number of tiles in the X direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfXTilesAtLevel(level: number) {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesX << level;\r\n }\r\n\r\n /** The total number of tiles in the Y direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfYTilesAtLevel(level: number): number {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesY << level;\r\n }\r\n\r\n /** @alpha */\r\n public get rootLevel() {\r\n return this.numberOfLevelZeroTilesX > 1 || this.numberOfLevelZeroTilesY > 1 ? -1 : 0;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfXChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesX : 2;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfYChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesY : 2;\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], convert it to a fractional distance along the X axis. */\r\n public tileXToFraction(x: number, level: number): number {\r\n return x / this.getNumberOfXTilesAtLevel(level);\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], convert it to a fractional distance along the Y axis. */\r\n public tileYToFraction(y: number, level: number): number {\r\n return y / this.getNumberOfYTilesAtLevel(level);\r\n }\r\n\r\n /** Given a fractional distance along the X axis and a level of the quad tree, compute the X component of the corresponding [[QuadId]]. */\r\n public xFractionToTileX(xFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfXTilesAtLevel(level);\r\n return Math.min(Math.floor(xFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given a fractional distance along the Y axis and a level of the quad tree, compute the Y component of the corresponding [[QuadId]]. */\r\n public yFractionToTileY(yFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfYTilesAtLevel(level);\r\n return Math.min(Math.floor(yFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], compute its longitude in [-pi, pi] radians. */\r\n public tileXToLongitude(x: number, level: number) {\r\n return this.xFractionToLongitude(this.tileXToFraction(x, level));\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], compute its latitude in [-pi/2, pi/2] radians. */\r\n public tileYToLatitude(y: number, level: number) {\r\n return this.yFractionToLatitude(this.tileYToFraction(y, level));\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute its fractional coordinates in the XY plane. */\r\n public tileXYToFraction(x: number, y: number, level: number, result?: Point2d): Point2d {\r\n if (undefined === result)\r\n result = Point2d.createZero();\r\n\r\n result.x = this.tileXToFraction(x, level);\r\n result.y = this.tileYToFraction(y, level);\r\n\r\n return result;\r\n }\r\n\r\n /** Given the components of a [[QuadId]] and an elevation, compute the corresponding [Cartographic]($common) position.\r\n * @param x The X component of the QuadId.\r\n * @param y The Y component of the QuadId.\r\n * @param level The level component of the QuadId.\r\n * @param height The elevation above the ellipsoid.\r\n * @returns the corresponding cartographic position.\r\n */\r\n public tileXYToCartographic(x: number, y: number, level: number, result: Cartographic, height = 0): Cartographic {\r\n const pt = this.tileXYToFraction(x, y, level, this._scratchFraction);\r\n return this.fractionToCartographic(pt.x, pt.y, result, height);\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute the corresponding region of the Earth's surface. */\r\n public tileXYToRectangle(x: number, y: number, level: number, result?: MapCartoRectangle) {\r\n if (level < 0)\r\n return MapCartoRectangle.createMaximum();\r\n\r\n return MapCartoRectangle.fromRadians(\r\n this.tileXToLongitude(x, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? (y + 1) : y, level),\r\n this.tileXToLongitude(x + 1, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? y : (y + 1), level),\r\n result,\r\n );\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the north pole. */\r\n public tileBordersNorthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row, level) === 0.0 : this.tileYToFraction(row + 1, level) === 1.0;\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the south pole. */\r\n public tileBordersSouthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row + 1, level) === 1.0 : this.tileYToFraction(row, level) === 0.0;\r\n }\r\n\r\n /** Given a cartographic position, compute the corresponding position on the surface of the Earth as fractional distances along the\r\n * X and Y axes.\r\n */\r\n public cartographicToTileXY(carto: Cartographic, level: number, result?: Point2d): Point2d {\r\n const fraction = this.cartographicToFraction(carto.latitude, carto.longitude, this._scratchPoint2d);\r\n return Point2d.create(this.xFractionToTileX(fraction.x, level), this.yFractionToTileY(fraction.y, level), result);\r\n\r\n }\r\n\r\n /** Given fractional coordinates in the XY plane and an elevation, compute the corresponding cartographic position. */\r\n public fractionToCartographic(xFraction: number, yFraction: number, result: Cartographic, height = 0): Cartographic {\r\n result.longitude = this.xFractionToLongitude(xFraction);\r\n result.latitude = this.yFractionToLatitude(yFraction);\r\n result.height = height;\r\n return result;\r\n }\r\n\r\n /** Given a cartographic location on the surface of the Earth, convert it to fractional coordinates in the XY plane. */\r\n public cartographicToFraction(latitudeRadians: number, longitudeRadians: number, result: Point2d): Point2d {\r\n result.x = this.longitudeToXFraction(longitudeRadians);\r\n result.y = this.latitudeToYFraction(latitudeRadians);\r\n return result;\r\n }\r\n\r\n /** @alpha */\r\n private ecefToPixelFraction(point: Point3d, applyTerrain: boolean): Point3d | undefined {\r\n const cartoGraphic = Cartographic.fromEcef(point);\r\n if (!cartoGraphic)\r\n return undefined;\r\n return Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);\r\n }\r\n\r\n /** @alpha */\r\n public computeMercatorFractionToDb(ecefToDb: Transform, bimElevationOffset: number, iModel: IModelConnection, applyTerrain: boolean) {\r\n const dbToEcef = ecefToDb.inverse()!;\r\n\r\n const projectCenter = Point3d.create(iModel.projectExtents.center.x, iModel.projectExtents.center.y, bimElevationOffset);\r\n const projectEast = projectCenter.plusXYZ(1, 0, 0);\r\n const projectNorth = projectCenter.plusXYZ(0, 1, 0);\r\n\r\n const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);\r\n const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);\r\n const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);\r\n\r\n if (!mercatorOrigin || !mercatorX || !mercatorY)\r\n return Transform.createIdentity();\r\n\r\n const deltaX = Vector3d.createStartEnd(mercatorOrigin, mercatorX);\r\n const deltaY = Vector3d.createStartEnd(mercatorOrigin, mercatorY);\r\n const matrix = Matrix3d.createColumns(deltaX, deltaY, Vector3d.create(0, 0, 1));\r\n\r\n const dbToMercator = Transform.createMatrixPickupPutdown(matrix, projectCenter, mercatorOrigin);\r\n const mercatorToDb = dbToMercator.inverse();\r\n return mercatorToDb === undefined ? Transform.createIdentity() : mercatorToDb;\r\n }\r\n\r\n /** @alpha */\r\n protected yFractionFlip(fraction: number) {\r\n return this.rowZeroAtNorthPole ? (1.0 - fraction) : fraction;\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using a simple geographic projection by which longitude and latitude are mapped directly to X and Y.\r\n * This projection is commonly known as \"geographic\", \"equirectangular\", \"equidistant cylindrical\", or \"plate carrée\".\r\n * @beta\r\n */\r\nexport class GeographicTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 2, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = false) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n return Math.PI * (this.yFractionFlip(yFraction) - .5);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction]]. */\r\n public latitudeToYFraction(latitude: number): number {\r\n return this.yFractionFlip(.5 + latitude / Math.PI);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class WebMercatorProjection {\r\n /**\r\n * Converts a Mercator angle, in the range -PI to PI, to a geodetic latitude\r\n * in the range -PI/2 to PI/2.\r\n *\r\n * @param {Number} mercatorAngle The angle to convert.\r\n * @returns {Number} The geodetic latitude in radians.\r\n */\r\n public static mercatorAngleToGeodeticLatitude(mercatorAngle: number) {\r\n return Angle.piOver2Radians - (2.0 * Math.atan(Math.exp(-mercatorAngle)));\r\n }\r\n\r\n public static maximumLatitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(Angle.piRadians);\r\n\r\n public static geodeticLatitudeToMercatorAngle(latitude: number) {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude)\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n else if (latitude < -WebMercatorProjection.maximumLatitude)\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n\r\n const sinLatitude = Math.sin(latitude);\r\n return 0.5 * Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude));\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using the [EPSG:3857](https://en.wikipedia.org/wiki/Web_Mercator_projection) projection.\r\n * This scheme is used by most [tiled web maps](https://en.wikipedia.org/wiki/Tiled_web_map), including Bing Maps and Google Maps.\r\n * @beta\r\n */\r\nexport class WebMercatorTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 1, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = true) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n const mercatorAngle = Angle.pi2Radians * (this.rowZeroAtNorthPole ? (.5 - yFraction) : (yFraction - .5));\r\n return WebMercatorProjection.mercatorAngleToGeodeticLatitude(mercatorAngle);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction. */\r\n public latitudeToYFraction(latitude: number): number {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude) {\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n } else if (latitude < -WebMercatorProjection.maximumLatitude) {\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n }\r\n const sinLatitude = Math.sin(latitude);\r\n return (0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Angle.piRadians)); // https://msdn.microsoft.com/en-us/library/b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,eAAe;gBACvC,uBAAuB,SAAI,EAAE,uBAAuB,SAAI,EAAE,kBAAkB,UAAO;IAItG,0DAA0D;IACnD,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAKrD,wDAAwD;IACjD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAUrD"}
|
|
@@ -140,6 +140,8 @@ export class MapTilingScheme {
|
|
|
140
140
|
/** @alpha */
|
|
141
141
|
ecefToPixelFraction(point, applyTerrain) {
|
|
142
142
|
const cartoGraphic = Cartographic.fromEcef(point);
|
|
143
|
+
if (!cartoGraphic)
|
|
144
|
+
return undefined;
|
|
143
145
|
return Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);
|
|
144
146
|
}
|
|
145
147
|
/** @alpha */
|
|
@@ -151,6 +153,8 @@ export class MapTilingScheme {
|
|
|
151
153
|
const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);
|
|
152
154
|
const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);
|
|
153
155
|
const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);
|
|
156
|
+
if (!mercatorOrigin || !mercatorX || !mercatorY)
|
|
157
|
+
return Transform.createIdentity();
|
|
154
158
|
const deltaX = Vector3d.createStartEnd(mercatorOrigin, mercatorX);
|
|
155
159
|
const deltaY = Vector3d.createStartEnd(mercatorOrigin, mercatorY);
|
|
156
160
|
const matrix = Matrix3d.createColumns(deltaX, deltaY, Vector3d.create(0, 0, 1));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapTilingScheme.js","sourceRoot":"","sources":["../../../../src/tile/map/MapTilingScheme.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ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AAyD;IAC3J,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { Angle, Matrix3d, Point2d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapCartoRectangle } from \"../internal\";\r\n\r\n/** A scheme for converting between two representations of the surface of the Earth: an ellipsoid and a rectangular [tiled map](https://en.wikipedia.org/wiki/Tiled_web_map).\r\n * Positions on the surface of the ellipsoid are expressed in [Cartographic]($common) coordinates.\r\n * Rectangular [[MapTile]]s are projected onto this ellipsoid by the tiling scheme. Tile coordinates are represented by [[QuadId]]s.\r\n *\r\n * The tiling scheme represents the (x,y) coordinates of its tiles as fractions in [0,1] along the X and Y axes.\r\n * An X fraction of 0 corresponds to the easternmost longitude and an X fraction of 1 to the westernmost longitude.\r\n * The scheme can choose to correlate a Y fraction of 0 with either the north or south pole, as specified by [[rowZeroAtNorthPole]].\r\n * Implementing a tiling scheme only requires implementing the abstract method [[yFractionToLatitude]] and its inverse, [[latitudeToYFraction]].\r\n * @public\r\n */\r\nexport abstract class MapTilingScheme {\r\n /** If true, the fractional Y coordinate 0 corresponds to the north pole and 1 to the south pole; otherwise,\r\n * 0 corresponds to the south pole and 1 to the north.\r\n */\r\n public readonly rowZeroAtNorthPole: boolean;\r\n /** The number of tiles in the X direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesX;\r\n /** The number of tiles in the Y direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesY;\r\n private readonly _scratchFraction = Point2d.createZero();\r\n private readonly _scratchPoint2d = Point2d.createZero();\r\n\r\n /** Convert a longitude in [-pi, pi] radisn to a fraction in [0, 1] along the X axis. */\r\n public longitudeToXFraction(longitude: number) {\r\n return longitude / Angle.pi2Radians + .5;\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the X axis into a longitude in [-pi, pi] radians. */\r\n public xFractionToLongitude(xFraction: number) {\r\n return Angle.pi2Radians * (xFraction - .5);\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the Y axis into a latitude in [-pi/2, pi/2] radians. */\r\n public abstract yFractionToLatitude(yFraction: number): number;\r\n\r\n /** Convert a latitude in [-pi/2, pi/2] radians into a fraction in [0, 1] along the Y axis. */\r\n public abstract latitudeToYFraction(latitude: number): number;\r\n\r\n protected constructor(numberOfLevelZeroTilesX: number, numberOfLevelZeroTilesY: number, rowZeroAtNorthPole: boolean) {\r\n this.rowZeroAtNorthPole = rowZeroAtNorthPole;\r\n this.numberOfLevelZeroTilesX = numberOfLevelZeroTilesX;\r\n this.numberOfLevelZeroTilesY = numberOfLevelZeroTilesY;\r\n }\r\n\r\n /** The total number of tiles in the X direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfXTilesAtLevel(level: number) {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesX << level;\r\n }\r\n\r\n /** The total number of tiles in the Y direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfYTilesAtLevel(level: number): number {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesY << level;\r\n }\r\n\r\n /** @alpha */\r\n public get rootLevel() {\r\n return this.numberOfLevelZeroTilesX > 1 || this.numberOfLevelZeroTilesY > 1 ? -1 : 0;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfXChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesX : 2;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfYChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesY : 2;\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], convert it to a fractional distance along the X axis. */\r\n public tileXToFraction(x: number, level: number): number {\r\n return x / this.getNumberOfXTilesAtLevel(level);\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], convert it to a fractional distance along the Y axis. */\r\n public tileYToFraction(y: number, level: number): number {\r\n return y / this.getNumberOfYTilesAtLevel(level);\r\n }\r\n\r\n /** Given a fractional distance along the X axis and a level of the quad tree, compute the X component of the corresponding [[QuadId]]. */\r\n public xFractionToTileX(xFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfXTilesAtLevel(level);\r\n return Math.min(Math.floor(xFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given a fractional distance along the Y axis and a level of the quad tree, compute the Y component of the corresponding [[QuadId]]. */\r\n public yFractionToTileY(yFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfYTilesAtLevel(level);\r\n return Math.min(Math.floor(yFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], compute its longitude in [-pi, pi] radians. */\r\n public tileXToLongitude(x: number, level: number) {\r\n return this.xFractionToLongitude(this.tileXToFraction(x, level));\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], compute its latitude in [-pi/2, pi/2] radians. */\r\n public tileYToLatitude(y: number, level: number) {\r\n return this.yFractionToLatitude(this.tileYToFraction(y, level));\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute its fractional coordinates in the XY plane. */\r\n public tileXYToFraction(x: number, y: number, level: number, result?: Point2d): Point2d {\r\n if (undefined === result)\r\n result = Point2d.createZero();\r\n\r\n result.x = this.tileXToFraction(x, level);\r\n result.y = this.tileYToFraction(y, level);\r\n\r\n return result;\r\n }\r\n\r\n /** Given the components of a [[QuadId]] and an elevation, compute the corresponding [Cartographic]($common) position.\r\n * @param x The X component of the QuadId.\r\n * @param y The Y component of the QuadId.\r\n * @param level The level component of the QuadId.\r\n * @param height The elevation above the ellipsoid.\r\n * @returns the corresponding cartographic position.\r\n */\r\n public tileXYToCartographic(x: number, y: number, level: number, result: Cartographic, height = 0): Cartographic {\r\n const pt = this.tileXYToFraction(x, y, level, this._scratchFraction);\r\n return this.fractionToCartographic(pt.x, pt.y, result, height);\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute the corresponding region of the Earth's surface. */\r\n public tileXYToRectangle(x: number, y: number, level: number, result?: MapCartoRectangle) {\r\n if (level < 0)\r\n return MapCartoRectangle.createMaximum();\r\n\r\n return MapCartoRectangle.fromRadians(\r\n this.tileXToLongitude(x, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? (y + 1) : y, level),\r\n this.tileXToLongitude(x + 1, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? y : (y + 1), level),\r\n result,\r\n );\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the north pole. */\r\n public tileBordersNorthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row, level) === 0.0 : this.tileYToFraction(row + 1, level) === 1.0;\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the south pole. */\r\n public tileBordersSouthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row + 1, level) === 1.0 : this.tileYToFraction(row, level) === 0.0;\r\n }\r\n\r\n /** Given a cartographic position, compute the corresponding position on the surface of the Earth as fractional distances along the\r\n * X and Y axes.\r\n */\r\n public cartographicToTileXY(carto: Cartographic, level: number, result?: Point2d): Point2d {\r\n const fraction = this.cartographicToFraction(carto.latitude, carto.longitude, this._scratchPoint2d);\r\n return Point2d.create(this.xFractionToTileX(fraction.x, level), this.yFractionToTileY(fraction.y, level), result);\r\n\r\n }\r\n\r\n /** Given fractional coordinates in the XY plane and an elevation, compute the corresponding cartographic position. */\r\n public fractionToCartographic(xFraction: number, yFraction: number, result: Cartographic, height = 0): Cartographic {\r\n result.longitude = this.xFractionToLongitude(xFraction);\r\n result.latitude = this.yFractionToLatitude(yFraction);\r\n result.height = height;\r\n return result;\r\n }\r\n\r\n /** Given a cartographic location on the surface of the Earth, convert it to fractional coordinates in the XY plane. */\r\n public cartographicToFraction(latitudeRadians: number, longitudeRadians: number, result: Point2d): Point2d {\r\n result.x = this.longitudeToXFraction(longitudeRadians);\r\n result.y = this.latitudeToYFraction(latitudeRadians);\r\n return result;\r\n }\r\n\r\n /** @alpha */\r\n private ecefToPixelFraction(point: Point3d, applyTerrain: boolean): Point3d {\r\n const cartoGraphic = Cartographic.fromEcef(point)!;\r\n return Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);\r\n }\r\n\r\n /** @alpha */\r\n public computeMercatorFractionToDb(ecefToDb: Transform, bimElevationOffset: number, iModel: IModelConnection, applyTerrain: boolean) {\r\n const dbToEcef = ecefToDb.inverse()!;\r\n\r\n const projectCenter = Point3d.create(iModel.projectExtents.center.x, iModel.projectExtents.center.y, bimElevationOffset);\r\n const projectEast = projectCenter.plusXYZ(1, 0, 0);\r\n const projectNorth = projectCenter.plusXYZ(0, 1, 0);\r\n\r\n const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);\r\n const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);\r\n const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);\r\n\r\n const deltaX = Vector3d.createStartEnd(mercatorOrigin, mercatorX);\r\n const deltaY = Vector3d.createStartEnd(mercatorOrigin, mercatorY);\r\n const matrix = Matrix3d.createColumns(deltaX, deltaY, Vector3d.create(0, 0, 1));\r\n\r\n const dbToMercator = Transform.createMatrixPickupPutdown(matrix, projectCenter, mercatorOrigin);\r\n const mercatorToDb = dbToMercator.inverse();\r\n return mercatorToDb === undefined ? Transform.createIdentity() : mercatorToDb;\r\n }\r\n\r\n /** @alpha */\r\n protected yFractionFlip(fraction: number) {\r\n return this.rowZeroAtNorthPole ? (1.0 - fraction) : fraction;\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using a simple geographic projection by which longitude and latitude are mapped directly to X and Y.\r\n * This projection is commonly known as \"geographic\", \"equirectangular\", \"equidistant cylindrical\", or \"plate carrée\".\r\n * @beta\r\n */\r\nexport class GeographicTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 2, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = false) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n return Math.PI * (this.yFractionFlip(yFraction) - .5);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction]]. */\r\n public latitudeToYFraction(latitude: number): number {\r\n return this.yFractionFlip(.5 + latitude / Math.PI);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class WebMercatorProjection {\r\n /**\r\n * Converts a Mercator angle, in the range -PI to PI, to a geodetic latitude\r\n * in the range -PI/2 to PI/2.\r\n *\r\n * @param {Number} mercatorAngle The angle to convert.\r\n * @returns {Number} The geodetic latitude in radians.\r\n */\r\n public static mercatorAngleToGeodeticLatitude(mercatorAngle: number) {\r\n return Angle.piOver2Radians - (2.0 * Math.atan(Math.exp(-mercatorAngle)));\r\n }\r\n\r\n public static maximumLatitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(Angle.piRadians);\r\n\r\n public static geodeticLatitudeToMercatorAngle(latitude: number) {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude)\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n else if (latitude < -WebMercatorProjection.maximumLatitude)\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n\r\n const sinLatitude = Math.sin(latitude);\r\n return 0.5 * Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude));\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using the [EPSG:3857](https://en.wikipedia.org/wiki/Web_Mercator_projection) projection.\r\n * This scheme is used by most [tiled web maps](https://en.wikipedia.org/wiki/Tiled_web_map), including Bing Maps and Google Maps.\r\n * @beta\r\n */\r\nexport class WebMercatorTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 1, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = true) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n const mercatorAngle = Angle.pi2Radians * (this.rowZeroAtNorthPole ? (.5 - yFraction) : (yFraction - .5));\r\n return WebMercatorProjection.mercatorAngleToGeodeticLatitude(mercatorAngle);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction. */\r\n public latitudeToYFraction(latitude: number): number {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude) {\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n } else if (latitude < -WebMercatorProjection.maximumLatitude) {\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n }\r\n const sinLatitude = Math.sin(latitude);\r\n return (0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Angle.piRadians)); // https://msdn.microsoft.com/en-us/library/bb259689.aspx\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MapTilingScheme.js","sourceRoot":"","sources":["../../../../src/tile/map/MapTilingScheme.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,oBA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SAAS,CAAC,CAAC,CAAC,CAAG,yDAAyD;IAC3J,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { Angle, Matrix3d, Point2d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { Cartographic } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapCartoRectangle } from \"../internal\";\r\n\r\n/** A scheme for converting between two representations of the surface of the Earth: an ellipsoid and a rectangular [tiled map](https://en.wikipedia.org/wiki/Tiled_web_map).\r\n * Positions on the surface of the ellipsoid are expressed in [Cartographic]($common) coordinates.\r\n * Rectangular [[MapTile]]s are projected onto this ellipsoid by the tiling scheme. Tile coordinates are represented by [[QuadId]]s.\r\n *\r\n * The tiling scheme represents the (x,y) coordinates of its tiles as fractions in [0,1] along the X and Y axes.\r\n * An X fraction of 0 corresponds to the easternmost longitude and an X fraction of 1 to the westernmost longitude.\r\n * The scheme can choose to correlate a Y fraction of 0 with either the north or south pole, as specified by [[rowZeroAtNorthPole]].\r\n * Implementing a tiling scheme only requires implementing the abstract method [[yFractionToLatitude]] and its inverse, [[latitudeToYFraction]].\r\n * @public\r\n */\r\nexport abstract class MapTilingScheme {\r\n /** If true, the fractional Y coordinate 0 corresponds to the north pole and 1 to the south pole; otherwise,\r\n * 0 corresponds to the south pole and 1 to the north.\r\n */\r\n public readonly rowZeroAtNorthPole: boolean;\r\n /** The number of tiles in the X direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesX;\r\n /** The number of tiles in the Y direction at level 0 of the quad tree. */\r\n public readonly numberOfLevelZeroTilesY;\r\n private readonly _scratchFraction = Point2d.createZero();\r\n private readonly _scratchPoint2d = Point2d.createZero();\r\n\r\n /** Convert a longitude in [-pi, pi] radisn to a fraction in [0, 1] along the X axis. */\r\n public longitudeToXFraction(longitude: number) {\r\n return longitude / Angle.pi2Radians + .5;\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the X axis into a longitude in [-pi, pi] radians. */\r\n public xFractionToLongitude(xFraction: number) {\r\n return Angle.pi2Radians * (xFraction - .5);\r\n }\r\n\r\n /** Convert a fraction in [0, 1] along the Y axis into a latitude in [-pi/2, pi/2] radians. */\r\n public abstract yFractionToLatitude(yFraction: number): number;\r\n\r\n /** Convert a latitude in [-pi/2, pi/2] radians into a fraction in [0, 1] along the Y axis. */\r\n public abstract latitudeToYFraction(latitude: number): number;\r\n\r\n protected constructor(numberOfLevelZeroTilesX: number, numberOfLevelZeroTilesY: number, rowZeroAtNorthPole: boolean) {\r\n this.rowZeroAtNorthPole = rowZeroAtNorthPole;\r\n this.numberOfLevelZeroTilesX = numberOfLevelZeroTilesX;\r\n this.numberOfLevelZeroTilesY = numberOfLevelZeroTilesY;\r\n }\r\n\r\n /** The total number of tiles in the X direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfXTilesAtLevel(level: number) {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesX << level;\r\n }\r\n\r\n /** The total number of tiles in the Y direction at the specified level of detail.\r\n * @param level The level of detail, with 0 corresponding to the root tile.\r\n */\r\n public getNumberOfYTilesAtLevel(level: number): number {\r\n return level < 0 ? 1 : this.numberOfLevelZeroTilesY << level;\r\n }\r\n\r\n /** @alpha */\r\n public get rootLevel() {\r\n return this.numberOfLevelZeroTilesX > 1 || this.numberOfLevelZeroTilesY > 1 ? -1 : 0;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfXChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesX : 2;\r\n }\r\n\r\n /** @alpha */\r\n public getNumberOfYChildrenAtLevel(level: number): number {\r\n return level === 0 ? this.numberOfLevelZeroTilesY : 2;\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], convert it to a fractional distance along the X axis. */\r\n public tileXToFraction(x: number, level: number): number {\r\n return x / this.getNumberOfXTilesAtLevel(level);\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], convert it to a fractional distance along the Y axis. */\r\n public tileYToFraction(y: number, level: number): number {\r\n return y / this.getNumberOfYTilesAtLevel(level);\r\n }\r\n\r\n /** Given a fractional distance along the X axis and a level of the quad tree, compute the X component of the corresponding [[QuadId]]. */\r\n public xFractionToTileX(xFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfXTilesAtLevel(level);\r\n return Math.min(Math.floor(xFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given a fractional distance along the Y axis and a level of the quad tree, compute the Y component of the corresponding [[QuadId]]. */\r\n public yFractionToTileY(yFraction: number, level: number): number {\r\n const nTiles = this.getNumberOfYTilesAtLevel(level);\r\n return Math.min(Math.floor(yFraction * nTiles), nTiles - 1);\r\n }\r\n\r\n /** Given the X component and level of a [[QuadId]], compute its longitude in [-pi, pi] radians. */\r\n public tileXToLongitude(x: number, level: number) {\r\n return this.xFractionToLongitude(this.tileXToFraction(x, level));\r\n }\r\n\r\n /** Given the Y component and level of a [[QuadId]], compute its latitude in [-pi/2, pi/2] radians. */\r\n public tileYToLatitude(y: number, level: number) {\r\n return this.yFractionToLatitude(this.tileYToFraction(y, level));\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute its fractional coordinates in the XY plane. */\r\n public tileXYToFraction(x: number, y: number, level: number, result?: Point2d): Point2d {\r\n if (undefined === result)\r\n result = Point2d.createZero();\r\n\r\n result.x = this.tileXToFraction(x, level);\r\n result.y = this.tileYToFraction(y, level);\r\n\r\n return result;\r\n }\r\n\r\n /** Given the components of a [[QuadId]] and an elevation, compute the corresponding [Cartographic]($common) position.\r\n * @param x The X component of the QuadId.\r\n * @param y The Y component of the QuadId.\r\n * @param level The level component of the QuadId.\r\n * @param height The elevation above the ellipsoid.\r\n * @returns the corresponding cartographic position.\r\n */\r\n public tileXYToCartographic(x: number, y: number, level: number, result: Cartographic, height = 0): Cartographic {\r\n const pt = this.tileXYToFraction(x, y, level, this._scratchFraction);\r\n return this.fractionToCartographic(pt.x, pt.y, result, height);\r\n }\r\n\r\n /** Given the components of a [[QuadId]], compute the corresponding region of the Earth's surface. */\r\n public tileXYToRectangle(x: number, y: number, level: number, result?: MapCartoRectangle) {\r\n if (level < 0)\r\n return MapCartoRectangle.createMaximum();\r\n\r\n return MapCartoRectangle.fromRadians(\r\n this.tileXToLongitude(x, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? (y + 1) : y, level),\r\n this.tileXToLongitude(x + 1, level),\r\n this.tileYToLatitude(this.rowZeroAtNorthPole ? y : (y + 1), level),\r\n result,\r\n );\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the north pole. */\r\n public tileBordersNorthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row, level) === 0.0 : this.tileYToFraction(row + 1, level) === 1.0;\r\n }\r\n\r\n /** Returns true if the tile at the specified X coordinate and level is adjacent to the south pole. */\r\n public tileBordersSouthPole(row: number, level: number) {\r\n return this.rowZeroAtNorthPole ? this.tileYToFraction(row + 1, level) === 1.0 : this.tileYToFraction(row, level) === 0.0;\r\n }\r\n\r\n /** Given a cartographic position, compute the corresponding position on the surface of the Earth as fractional distances along the\r\n * X and Y axes.\r\n */\r\n public cartographicToTileXY(carto: Cartographic, level: number, result?: Point2d): Point2d {\r\n const fraction = this.cartographicToFraction(carto.latitude, carto.longitude, this._scratchPoint2d);\r\n return Point2d.create(this.xFractionToTileX(fraction.x, level), this.yFractionToTileY(fraction.y, level), result);\r\n\r\n }\r\n\r\n /** Given fractional coordinates in the XY plane and an elevation, compute the corresponding cartographic position. */\r\n public fractionToCartographic(xFraction: number, yFraction: number, result: Cartographic, height = 0): Cartographic {\r\n result.longitude = this.xFractionToLongitude(xFraction);\r\n result.latitude = this.yFractionToLatitude(yFraction);\r\n result.height = height;\r\n return result;\r\n }\r\n\r\n /** Given a cartographic location on the surface of the Earth, convert it to fractional coordinates in the XY plane. */\r\n public cartographicToFraction(latitudeRadians: number, longitudeRadians: number, result: Point2d): Point2d {\r\n result.x = this.longitudeToXFraction(longitudeRadians);\r\n result.y = this.latitudeToYFraction(latitudeRadians);\r\n return result;\r\n }\r\n\r\n /** @alpha */\r\n private ecefToPixelFraction(point: Point3d, applyTerrain: boolean): Point3d | undefined {\r\n const cartoGraphic = Cartographic.fromEcef(point);\r\n if (!cartoGraphic)\r\n return undefined;\r\n return Point3d.create(this.longitudeToXFraction(cartoGraphic.longitude), this.latitudeToYFraction(cartoGraphic.latitude), applyTerrain ? cartoGraphic.height : 0);\r\n }\r\n\r\n /** @alpha */\r\n public computeMercatorFractionToDb(ecefToDb: Transform, bimElevationOffset: number, iModel: IModelConnection, applyTerrain: boolean) {\r\n const dbToEcef = ecefToDb.inverse()!;\r\n\r\n const projectCenter = Point3d.create(iModel.projectExtents.center.x, iModel.projectExtents.center.y, bimElevationOffset);\r\n const projectEast = projectCenter.plusXYZ(1, 0, 0);\r\n const projectNorth = projectCenter.plusXYZ(0, 1, 0);\r\n\r\n const mercatorOrigin = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectCenter), applyTerrain);\r\n const mercatorX = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectEast), applyTerrain);\r\n const mercatorY = this.ecefToPixelFraction(dbToEcef.multiplyPoint3d(projectNorth), applyTerrain);\r\n\r\n if (!mercatorOrigin || !mercatorX || !mercatorY)\r\n return Transform.createIdentity();\r\n\r\n const deltaX = Vector3d.createStartEnd(mercatorOrigin, mercatorX);\r\n const deltaY = Vector3d.createStartEnd(mercatorOrigin, mercatorY);\r\n const matrix = Matrix3d.createColumns(deltaX, deltaY, Vector3d.create(0, 0, 1));\r\n\r\n const dbToMercator = Transform.createMatrixPickupPutdown(matrix, projectCenter, mercatorOrigin);\r\n const mercatorToDb = dbToMercator.inverse();\r\n return mercatorToDb === undefined ? Transform.createIdentity() : mercatorToDb;\r\n }\r\n\r\n /** @alpha */\r\n protected yFractionFlip(fraction: number) {\r\n return this.rowZeroAtNorthPole ? (1.0 - fraction) : fraction;\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using a simple geographic projection by which longitude and latitude are mapped directly to X and Y.\r\n * This projection is commonly known as \"geographic\", \"equirectangular\", \"equidistant cylindrical\", or \"plate carrée\".\r\n * @beta\r\n */\r\nexport class GeographicTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 2, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = false) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n return Math.PI * (this.yFractionFlip(yFraction) - .5);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction]]. */\r\n public latitudeToYFraction(latitude: number): number {\r\n return this.yFractionFlip(.5 + latitude / Math.PI);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class WebMercatorProjection {\r\n /**\r\n * Converts a Mercator angle, in the range -PI to PI, to a geodetic latitude\r\n * in the range -PI/2 to PI/2.\r\n *\r\n * @param {Number} mercatorAngle The angle to convert.\r\n * @returns {Number} The geodetic latitude in radians.\r\n */\r\n public static mercatorAngleToGeodeticLatitude(mercatorAngle: number) {\r\n return Angle.piOver2Radians - (2.0 * Math.atan(Math.exp(-mercatorAngle)));\r\n }\r\n\r\n public static maximumLatitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(Angle.piRadians);\r\n\r\n public static geodeticLatitudeToMercatorAngle(latitude: number) {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude)\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n else if (latitude < -WebMercatorProjection.maximumLatitude)\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n\r\n const sinLatitude = Math.sin(latitude);\r\n return 0.5 * Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude));\r\n }\r\n}\r\n\r\n/** A [[MapTilingScheme]] using the [EPSG:3857](https://en.wikipedia.org/wiki/Web_Mercator_projection) projection.\r\n * This scheme is used by most [tiled web maps](https://en.wikipedia.org/wiki/Tiled_web_map), including Bing Maps and Google Maps.\r\n * @beta\r\n */\r\nexport class WebMercatorTilingScheme extends MapTilingScheme {\r\n public constructor(numberOfLevelZeroTilesX = 1, numberOfLevelZeroTilesY = 1, rowZeroAtNorthPole = true) {\r\n super(numberOfLevelZeroTilesX, numberOfLevelZeroTilesY, rowZeroAtNorthPole);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.yFractionToLatitude]]. */\r\n public yFractionToLatitude(yFraction: number): number {\r\n const mercatorAngle = Angle.pi2Radians * (this.rowZeroAtNorthPole ? (.5 - yFraction) : (yFraction - .5));\r\n return WebMercatorProjection.mercatorAngleToGeodeticLatitude(mercatorAngle);\r\n }\r\n\r\n /** Implements [[MapTilingScheme.latitudeToYFraction. */\r\n public latitudeToYFraction(latitude: number): number {\r\n // Clamp the latitude coordinate to the valid Mercator bounds.\r\n if (latitude > WebMercatorProjection.maximumLatitude) {\r\n latitude = WebMercatorProjection.maximumLatitude;\r\n } else if (latitude < -WebMercatorProjection.maximumLatitude) {\r\n latitude = -WebMercatorProjection.maximumLatitude;\r\n }\r\n const sinLatitude = Math.sin(latitude);\r\n return (0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Angle.piRadians)); // https://msdn.microsoft.com/en-us/library/bb259689.aspx\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-frontend",
|
|
3
|
-
"version": "4.10.0-dev.
|
|
3
|
+
"version": "4.10.0-dev.30",
|
|
4
4
|
"description": "iTwin.js frontend components",
|
|
5
5
|
"main": "lib/cjs/core-frontend.js",
|
|
6
6
|
"module": "lib/esm/core-frontend.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"url": "http://www.bentley.com"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/appui-abstract": "^4.10.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "^4.10.0-dev.
|
|
28
|
-
"@itwin/core-common": "^4.10.0-dev.
|
|
29
|
-
"@itwin/core-geometry": "^4.10.0-dev.
|
|
30
|
-
"@itwin/core-orbitgt": "^4.10.0-dev.
|
|
31
|
-
"@itwin/core-quantity": "^4.10.0-dev.
|
|
26
|
+
"@itwin/appui-abstract": "^4.10.0-dev.30",
|
|
27
|
+
"@itwin/core-bentley": "^4.10.0-dev.30",
|
|
28
|
+
"@itwin/core-common": "^4.10.0-dev.30",
|
|
29
|
+
"@itwin/core-geometry": "^4.10.0-dev.30",
|
|
30
|
+
"@itwin/core-orbitgt": "^4.10.0-dev.30",
|
|
31
|
+
"@itwin/core-quantity": "^4.10.0-dev.30"
|
|
32
32
|
},
|
|
33
33
|
"//devDependencies": [
|
|
34
34
|
"NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
|
|
@@ -36,33 +36,30 @@
|
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@itwin/eslint-plugin": "^4.0.2",
|
|
39
|
-
"@types/chai": "4.3.1",
|
|
40
39
|
"@types/chai-as-promised": "^7",
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
40
|
+
"@vitest/browser": "^2.1.0",
|
|
41
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
43
42
|
"babel-loader": "~8.2.5",
|
|
44
43
|
"babel-plugin-istanbul": "~6.1.1",
|
|
45
|
-
"chai": "^4.3.10",
|
|
46
|
-
"chai-as-promised": "^7.1.1",
|
|
47
44
|
"cpx2": "^3.0.0",
|
|
48
45
|
"eslint": "^8.56.0",
|
|
49
46
|
"glob": "^10.3.12",
|
|
50
|
-
"
|
|
51
|
-
"nyc": "^15.1.0",
|
|
47
|
+
"playwright": "~1.47.1",
|
|
52
48
|
"rimraf": "^3.0.2",
|
|
53
|
-
"sinon": "^17.0.2",
|
|
54
49
|
"source-map-loader": "^4.0.0",
|
|
55
50
|
"typescript": "~5.3.3",
|
|
56
51
|
"typemoq": "^2.1.0",
|
|
52
|
+
"vitest": "^2.1.0",
|
|
53
|
+
"vite-multiple-assets": "^1.3.1",
|
|
54
|
+
"vite-plugin-static-copy": "1.0.6",
|
|
57
55
|
"webpack": "^5.76.0",
|
|
58
|
-
"@itwin/appui-abstract": "4.10.0-dev.
|
|
59
|
-
"@itwin/
|
|
60
|
-
"@itwin/
|
|
61
|
-
"@itwin/core-common": "4.10.0-dev.
|
|
62
|
-
"@itwin/core-geometry": "4.10.0-dev.
|
|
63
|
-
"@itwin/core-
|
|
64
|
-
"@itwin/core-
|
|
65
|
-
"@itwin/certa": "4.10.0-dev.29"
|
|
56
|
+
"@itwin/appui-abstract": "4.10.0-dev.30",
|
|
57
|
+
"@itwin/build-tools": "4.10.0-dev.30",
|
|
58
|
+
"@itwin/core-bentley": "4.10.0-dev.30",
|
|
59
|
+
"@itwin/core-common": "4.10.0-dev.30",
|
|
60
|
+
"@itwin/core-geometry": "4.10.0-dev.30",
|
|
61
|
+
"@itwin/core-quantity": "4.10.0-dev.30",
|
|
62
|
+
"@itwin/core-orbitgt": "4.10.0-dev.30"
|
|
66
63
|
},
|
|
67
64
|
"//dependencies": [
|
|
68
65
|
"NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
|
|
@@ -76,12 +73,9 @@
|
|
|
76
73
|
"fuse.js": "^3.3.0",
|
|
77
74
|
"meshoptimizer": "~0.20.0",
|
|
78
75
|
"wms-capabilities": "0.4.0",
|
|
79
|
-
"@itwin/core-
|
|
80
|
-
"@itwin/core-
|
|
81
|
-
"@itwin/webgl-compatibility": "4.10.0-dev.
|
|
82
|
-
},
|
|
83
|
-
"nyc": {
|
|
84
|
-
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|
|
76
|
+
"@itwin/core-i18n": "4.10.0-dev.30",
|
|
77
|
+
"@itwin/core-telemetry": "4.10.0-dev.30",
|
|
78
|
+
"@itwin/webgl-compatibility": "4.10.0-dev.30"
|
|
85
79
|
},
|
|
86
80
|
"scripts": {
|
|
87
81
|
"build": "npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers",
|
|
@@ -98,9 +92,9 @@
|
|
|
98
92
|
"lint": "eslint -f visualstudio \"./src/**/*.ts\" 1>&2",
|
|
99
93
|
"lint-fix": "eslint --fix -f visualstudio \"./src/**/*.ts\" 1>&2",
|
|
100
94
|
"pseudolocalize": "betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO",
|
|
101
|
-
"test": "npm run
|
|
102
|
-
"cover": "npm
|
|
103
|
-
"test:debug": "
|
|
95
|
+
"test": "npm run webpackTestWorker && vitest --run",
|
|
96
|
+
"cover": "npm run webpackTestWorker && vitest --run --coverage",
|
|
97
|
+
"test:debug": "vitest --run",
|
|
104
98
|
"webpackTests": "webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker",
|
|
105
99
|
"webpackTestWorker": "webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \"./lib/test/test-worker.js\" ./lib/test",
|
|
106
100
|
"webpackWorkers": "webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"
|