@math.gl/web-mercator 4.0.0-beta.1 → 4.0.1
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/dist/assert.d.ts +0 -1
- package/dist/assert.js +6 -4
- package/dist/fit-bounds.d.ts +3 -4
- package/dist/fit-bounds.js +56 -41
- package/dist/fly-to-viewport.d.ts +2 -3
- package/dist/fly-to-viewport.js +74 -97
- package/dist/get-bounds.d.ts +1 -2
- package/dist/get-bounds.js +44 -37
- package/dist/index.cjs +19 -57
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +9 -10
- package/dist/index.js +2 -1
- package/dist/math-utils.d.ts +0 -1
- package/dist/math-utils.js +12 -12
- package/dist/normalize-viewport-props.d.ts +1 -2
- package/dist/normalize-viewport-props.js +35 -49
- package/dist/web-mercator-utils.d.ts +2 -3
- package/dist/web-mercator-utils.js +273 -154
- package/dist/web-mercator-viewport.d.ts +3 -4
- package/dist/web-mercator-viewport.js +265 -256
- package/package.json +4 -7
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js.map +0 -1
- package/dist/fit-bounds.d.ts.map +0 -1
- package/dist/fit-bounds.js.map +0 -1
- package/dist/fly-to-viewport.d.ts.map +0 -1
- package/dist/fly-to-viewport.js.map +0 -1
- package/dist/get-bounds.d.ts.map +0 -1
- package/dist/get-bounds.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/math-utils.d.ts.map +0 -1
- package/dist/math-utils.js.map +0 -1
- package/dist/normalize-viewport-props.d.ts.map +0 -1
- package/dist/normalize-viewport-props.js.map +0 -1
- package/dist/web-mercator-utils.d.ts.map +0 -1
- package/dist/web-mercator-utils.js.map +0 -1
- package/dist/web-mercator-viewport.d.ts.map +0 -1
- package/dist/web-mercator-viewport.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.js", "math-utils.js", "web-mercator-utils.js", "assert.js", "fit-bounds.js", "get-bounds.js", "web-mercator-viewport.js", "normalize-viewport-props.js", "fly-to-viewport.js"],
|
|
4
|
+
"sourcesContent": ["// Classic web-mercator-project\nexport { WebMercatorViewport } from \"./web-mercator-viewport.js\";\nexport { getBounds } from \"./get-bounds.js\";\nexport { fitBounds } from \"./fit-bounds.js\";\nexport { normalizeViewportProps } from \"./normalize-viewport-props.js\";\nexport { flyToViewport, getFlyToDuration } from \"./fly-to-viewport.js\";\nexport { MAX_LATITUDE, lngLatToWorld, worldToLngLat, worldToPixels, pixelsToWorld, zoomToScale, scaleToZoom, altitudeToFovy, fovyToAltitude, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionMatrix, getProjectionParameters } from \"./web-mercator-utils.js\";\n/** @deprecated default export */\nexport { WebMercatorViewport as default } from \"./web-mercator-viewport.js\";\n", "import { vec4 } from '@math.gl/core';\n// Helper, avoids low-precision 32 bit matrices from gl-matrix mat4.create()\nexport function createMat4() {\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n}\n// Transforms a vec4 with a projection matrix\nexport function transformVector(matrix, vector) {\n const result = vec4.transformMat4([], vector, matrix);\n vec4.scale(result, result, 1 / result[3]);\n return result;\n}\nexport function mod(value, divisor) {\n const modulus = value % divisor;\n return modulus < 0 ? divisor + modulus : modulus;\n}\nexport function lerp(start, end, step) {\n return step * end + (1 - step) * start;\n}\nexport function clamp(x, min, max) {\n return x < min ? min : x > max ? max : x;\n}\nfunction ieLog2(x) {\n return Math.log(x) * Math.LOG2E;\n}\n// Handle missing log2 in IE 11\nexport const log2 = Math.log2 || ieLog2;\n", "// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE\nimport { createMat4, transformVector, clamp, log2 } from \"./math-utils.js\";\nimport { mat4, vec2, vec3 } from '@math.gl/core';\nimport { assert } from \"./assert.js\";\n// CONSTANTS\nconst PI = Math.PI;\nconst PI_4 = PI / 4;\nconst DEGREES_TO_RADIANS = PI / 180;\nconst RADIANS_TO_DEGREES = 180 / PI;\nconst TILE_SIZE = 512;\n// Average circumference (40075 km equatorial, 40007 km meridional)\nconst EARTH_CIRCUMFERENCE = 40.03e6;\n// Latitude that makes a square world, 2 * atan(E ** PI) - PI / 2\nexport const MAX_LATITUDE = 85.051129;\n// Mapbox default altitude\nexport const DEFAULT_ALTITUDE = 1.5;\n/** Logarithimic zoom to linear scale **/\nexport function zoomToScale(zoom) {\n return Math.pow(2, zoom);\n}\n/** Linear scale to logarithimic zoom **/\nexport function scaleToZoom(scale) {\n return log2(scale);\n}\n/**\n * Project [lng,lat] on sphere onto [x,y] on 512*512 Mercator Zoom 0 tile.\n * Performs the nonlinear part of the web mercator projection.\n * Remaining projection is done with 4x4 matrices which also handles\n * perspective.\n *\n * @param lngLat - [lng, lat] coordinates\n * Specifies a point on the sphere to project onto the map.\n * @return [x,y] coordinates.\n */\nexport function lngLatToWorld(lngLat) {\n const [lng, lat] = lngLat;\n assert(Number.isFinite(lng));\n assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, 'invalid latitude');\n const lambda2 = lng * DEGREES_TO_RADIANS;\n const phi2 = lat * DEGREES_TO_RADIANS;\n const x = (TILE_SIZE * (lambda2 + PI)) / (2 * PI);\n const y = (TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5)))) / (2 * PI);\n return [x, y];\n}\n/**\n * Unproject world point [x,y] on map onto {lat, lon} on sphere\n *\n * @param xy - array with [x,y] members\n * representing point on projected map plane\n * @return - array with [x,y] of point on sphere.\n * Has toArray method if you need a GeoJSON Array.\n * Per cartographic tradition, lat and lon are specified as degrees.\n */\nexport function worldToLngLat(xy) {\n const [x, y] = xy;\n const lambda2 = (x / TILE_SIZE) * (2 * PI) - PI;\n const phi2 = 2 * (Math.atan(Math.exp((y / TILE_SIZE) * (2 * PI) - PI)) - PI_4);\n return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];\n}\n/**\n * Returns the zoom level that gives a 1 meter pixel at a certain latitude\n * 1 = C*cos(y)/2^z/TILE_SIZE = C*cos(y)/2^(z+9)\n */\nexport function getMeterZoom(options) {\n const { latitude } = options;\n assert(Number.isFinite(latitude));\n const latCosine = Math.cos(latitude * DEGREES_TO_RADIANS);\n return scaleToZoom(EARTH_CIRCUMFERENCE * latCosine) - 9;\n}\n/**\n * Calculate the conversion from meter to common units at a given latitude\n * This is a cheaper version of `getDistanceScales`\n * @param latitude center latitude in degrees\n * @returns common units per meter\n */\nexport function unitsPerMeter(latitude) {\n const latCosine = Math.cos(latitude * DEGREES_TO_RADIANS);\n return TILE_SIZE / EARTH_CIRCUMFERENCE / latCosine;\n}\n/**\n * Calculate distance scales in meters around current lat/lon, both for\n * degrees and pixels.\n * In mercator projection mode, the distance scales vary significantly\n * with latitude.\n */\nexport function getDistanceScales(options) {\n const { latitude, longitude, highPrecision = false } = options;\n assert(Number.isFinite(latitude) && Number.isFinite(longitude));\n const worldSize = TILE_SIZE;\n const latCosine = Math.cos(latitude * DEGREES_TO_RADIANS);\n /**\n * Number of pixels occupied by one degree longitude around current lat/lon:\n unitsPerDegreeX = d(lngLatToWorld([lng, lat])[0])/d(lng)\n = scale * TILE_SIZE * DEGREES_TO_RADIANS / (2 * PI)\n unitsPerDegreeY = d(lngLatToWorld([lng, lat])[1])/d(lat)\n = -scale * TILE_SIZE * DEGREES_TO_RADIANS / cos(lat * DEGREES_TO_RADIANS) / (2 * PI)\n */\n const unitsPerDegreeX = worldSize / 360;\n const unitsPerDegreeY = unitsPerDegreeX / latCosine;\n /**\n * Number of pixels occupied by one meter around current lat/lon:\n */\n const altUnitsPerMeter = worldSize / EARTH_CIRCUMFERENCE / latCosine;\n /**\n * LngLat: longitude -> east and latitude -> north (bottom left)\n * UTM meter offset: x -> east and y -> north (bottom left)\n * World space: x -> east and y -> south (top left)\n *\n * Y needs to be flipped when converting delta degree/meter to delta pixels\n */\n const result = {\n unitsPerMeter: [altUnitsPerMeter, altUnitsPerMeter, altUnitsPerMeter],\n metersPerUnit: [1 / altUnitsPerMeter, 1 / altUnitsPerMeter, 1 / altUnitsPerMeter],\n unitsPerDegree: [unitsPerDegreeX, unitsPerDegreeY, altUnitsPerMeter],\n degreesPerUnit: [1 / unitsPerDegreeX, 1 / unitsPerDegreeY, 1 / altUnitsPerMeter]\n };\n /**\n * Taylor series 2nd order for 1/latCosine\n f'(a) * (x - a)\n = d(1/cos(lat * DEGREES_TO_RADIANS))/d(lat) * dLat\n = DEGREES_TO_RADIANS * tan(lat * DEGREES_TO_RADIANS) / cos(lat * DEGREES_TO_RADIANS) * dLat\n */\n if (highPrecision) {\n const latCosine2 = (DEGREES_TO_RADIANS * Math.tan(latitude * DEGREES_TO_RADIANS)) / latCosine;\n const unitsPerDegreeY2 = (unitsPerDegreeX * latCosine2) / 2;\n const altUnitsPerDegree2 = (worldSize / EARTH_CIRCUMFERENCE) * latCosine2;\n const altUnitsPerMeter2 = (altUnitsPerDegree2 / unitsPerDegreeY) * altUnitsPerMeter;\n result.unitsPerDegree2 = [0, unitsPerDegreeY2, altUnitsPerDegree2];\n result.unitsPerMeter2 = [altUnitsPerMeter2, 0, altUnitsPerMeter2];\n }\n // Main results, used for converting meters to latlng deltas and scaling offsets\n return result;\n}\n/**\n * Offset a lng/lat position by meterOffset (northing, easting)\n */\nexport function addMetersToLngLat(lngLatZ, xyz) {\n const [longitude, latitude, z0] = lngLatZ;\n const [x, y, z] = xyz;\n const { unitsPerMeter, unitsPerMeter2 } = getDistanceScales({\n longitude,\n latitude,\n highPrecision: true\n });\n const worldspace = lngLatToWorld(lngLatZ);\n worldspace[0] += x * (unitsPerMeter[0] + unitsPerMeter2[0] * y);\n worldspace[1] += y * (unitsPerMeter[1] + unitsPerMeter2[1] * y);\n const newLngLat = worldToLngLat(worldspace);\n const newZ = (z0 || 0) + (z || 0);\n return Number.isFinite(z0) || Number.isFinite(z) ? [newLngLat[0], newLngLat[1], newZ] : newLngLat;\n}\n/**\n *\n * view and projection matrix creation is intentionally kept compatible with\n * mapbox-gl's implementation to ensure that seamless interoperation\n * with mapbox and react-map-gl. See: https://github.com/mapbox/mapbox-gl-js\n */\nexport function getViewMatrix(options) {\n const { \n // Viewport props\n height, pitch, bearing, altitude, \n // Pre-calculated parameters\n scale, center } = options;\n // VIEW MATRIX: PROJECTS MERCATOR WORLD COORDINATES\n // Note that mercator world coordinates typically need to be flipped\n //\n // Note: As usual, matrix operation orders should be read in reverse\n // since vectors will be multiplied from the right during transformation\n const vm = createMat4();\n // Move camera to altitude (along the pitch & bearing direction)\n mat4.translate(vm, vm, [0, 0, -altitude]);\n // Rotate by bearing, and then by pitch (which tilts the view)\n mat4.rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);\n mat4.rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);\n const relativeScale = scale / height;\n mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);\n if (center) {\n mat4.translate(vm, vm, vec3.negate([], center));\n }\n return vm;\n}\n/**\n * Calculates mapbox compatible projection matrix from parameters\n *\n * @param options.width Width of \"viewport\" or window\n * @param options.height Height of \"viewport\" or window\n * @param options.scale Scale at the current zoom\n * @param options.center Offset of the target, vec3 in world space\n * @param options.offset Offset of the focal point, vec2 in screen space\n * @param options.pitch Camera angle in degrees (0 is straight down)\n * @param options.fovy field of view in degrees\n * @param options.altitude if provided, field of view is calculated using `altitudeToFovy()`\n * @param options.nearZMultiplier control z buffer\n * @param options.farZMultiplier control z buffer\n * @returns project parameters object\n */\nexport function getProjectionParameters(options) {\n const { width, height, altitude, pitch = 0, offset, center, scale, nearZMultiplier = 1, farZMultiplier = 1 } = options;\n let { fovy = altitudeToFovy(DEFAULT_ALTITUDE) } = options;\n // For back-compatibility allow field of view to be\n // derived from altitude\n if (altitude !== undefined) {\n fovy = altitudeToFovy(altitude);\n }\n const fovRadians = fovy * DEGREES_TO_RADIANS;\n const pitchRadians = pitch * DEGREES_TO_RADIANS;\n // Distance from camera to the target\n const focalDistance = fovyToAltitude(fovy);\n let cameraToSeaLevelDistance = focalDistance;\n if (center) {\n cameraToSeaLevelDistance += (center[2] * scale) / Math.cos(pitchRadians) / height;\n }\n const fovAboveCenter = fovRadians * (0.5 + (offset ? offset[1] : 0) / height);\n // Find the distance from the center point to the center top\n // in focal distance units using law of sines.\n const topHalfSurfaceDistance = (Math.sin(fovAboveCenter) * cameraToSeaLevelDistance) /\n Math.sin(clamp(Math.PI / 2 - pitchRadians - fovAboveCenter, 0.01, Math.PI - 0.01));\n // Calculate z distance of the farthest fragment that should be rendered.\n const furthestDistance = Math.sin(pitchRadians) * topHalfSurfaceDistance + cameraToSeaLevelDistance;\n // Matches mapbox limit\n const horizonDistance = cameraToSeaLevelDistance * 10;\n // Calculate z value of the farthest fragment that should be rendered.\n const farZ = Math.min(furthestDistance * farZMultiplier, horizonDistance);\n return {\n fov: fovRadians,\n aspect: width / height,\n focalDistance,\n near: nearZMultiplier,\n far: farZ\n };\n}\n/**\n * CALCULATE PROJECTION MATRIX: PROJECTS FROM CAMERA (VIEW) SPACE TO CLIPSPACE\n *\n * To match mapbox's z buffer:\n * - \\<= 0.28: nearZMultiplier: 0.1, farZmultiplier: 1\n * - \\>= 0.29: nearZMultiplier: 1 / height, farZMultiplier: 1.01\n *\n * @param options Viewport options\n * @param options.width Width of \"viewport\" or window\n * @param options.height Height of \"viewport\" or window\n * @param options.scale Scale at the current zoom\n * @param options.center Offset of the target, vec3 in world space\n * @param options.offset Offset of the focal point, vec2 in screen space\n * @param options.pitch Camera angle in degrees (0 is straight down)\n * @param options.fovy field of view in degrees\n * @param options.altitude if provided, field of view is calculated using `altitudeToFovy()`\n * @param options.nearZMultiplier control z buffer\n * @param options.farZMultiplier control z buffer\n * @returns 4x4 projection matrix\n */\nexport function getProjectionMatrix(options) {\n const { fov, aspect, near, far } = getProjectionParameters(options);\n const projectionMatrix = mat4.perspective([], fov, // fov in radians\n aspect, // aspect ratio\n near, // near plane\n far // far plane\n );\n return projectionMatrix;\n}\n/**\n *\n * Convert an altitude to field of view such that the\n * focal distance is equal to the altitude\n *\n * @param altitude - altitude of camera in screen units\n * @return fovy field of view in degrees\n */\nexport function altitudeToFovy(altitude) {\n return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES;\n}\n/**\n *\n * Convert an field of view such that the\n * focal distance is equal to the altitude\n *\n * @param fovy - field of view in degrees\n * @return altitude altitude of camera in screen units\n */\nexport function fovyToAltitude(fovy) {\n return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS);\n}\n// Project flat coordinates to pixels on screen.\nexport function worldToPixels(xyz, pixelProjectionMatrix) {\n const [x, y, z = 0] = xyz;\n assert(Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z));\n return transformVector(pixelProjectionMatrix, [x, y, z, 1]);\n}\n/**\n * Unproject pixels on screen to flat coordinates.\n *\n * @param xyz - pixel coordinate on screen.\n * @param pixelUnprojectionMatrix - unprojection matrix 4x4\n * @param targetZ - if pixel coordinate does not have a 3rd component (depth),\n * targetZ is used as the elevation plane to unproject onto\n * @return [x, y, Z] flat coordinates on 512*512 Mercator Zoom 0 tile.\n */\nexport function pixelsToWorld(xyz, pixelUnprojectionMatrix, targetZ = 0) {\n const [x, y, z] = xyz;\n assert(Number.isFinite(x) && Number.isFinite(y), 'invalid pixel coordinate');\n if (Number.isFinite(z)) {\n // Has depth component\n const coord = transformVector(pixelUnprojectionMatrix, [x, y, z, 1]);\n return coord;\n }\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that line with z=0\n const coord0 = transformVector(pixelUnprojectionMatrix, [x, y, 0, 1]);\n const coord1 = transformVector(pixelUnprojectionMatrix, [x, y, 1, 1]);\n const z0 = coord0[2];\n const z1 = coord1[2];\n const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);\n return vec2.lerp([], coord0, coord1, t);\n}\n", "// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\nexport function assert(condition, message) {\n if (!condition) {\n throw new Error(message || '@math.gl/web-mercator: assertion failed.');\n }\n}\n", "import { assert } from \"./assert.js\";\nimport { log2, clamp } from \"./math-utils.js\";\nimport { MAX_LATITUDE, lngLatToWorld, worldToLngLat } from \"./web-mercator-utils.js\";\n/**\n * Returns map settings {latitude, longitude, zoom}\n * that will contain the provided corners within the provided width.\n *\n * > _Note: Only supports non-perspective mode._\n *\n * @param options fit bounds parameters\n * @returns - latitude, longitude and zoom\n */\nexport function fitBounds(options) {\n const { width, height, bounds, minExtent = 0, // 0.01 would be about 1000 meters (degree is ~110KM)\n maxZoom = 24, // ~x4,000,000 => About 10 meter extents\n offset = [0, 0] } = options;\n const [[west, south], [east, north]] = bounds;\n const padding = getPaddingObject(options.padding);\n const nw = lngLatToWorld([west, clamp(north, -MAX_LATITUDE, MAX_LATITUDE)]);\n const se = lngLatToWorld([east, clamp(south, -MAX_LATITUDE, MAX_LATITUDE)]);\n // width/height on the Web Mercator plane\n const size = [\n Math.max(Math.abs(se[0] - nw[0]), minExtent),\n Math.max(Math.abs(se[1] - nw[1]), minExtent)\n ];\n const targetSize = [\n width - padding.left - padding.right - Math.abs(offset[0]) * 2,\n height - padding.top - padding.bottom - Math.abs(offset[1]) * 2\n ];\n assert(targetSize[0] > 0 && targetSize[1] > 0);\n // scale = screen pixels per unit on the Web Mercator plane\n const scaleX = targetSize[0] / size[0];\n const scaleY = targetSize[1] / size[1];\n // Find how much we need to shift the center\n const offsetX = (padding.right - padding.left) / 2 / scaleX;\n const offsetY = (padding.top - padding.bottom) / 2 / scaleY;\n const center = [(se[0] + nw[0]) / 2 + offsetX, (se[1] + nw[1]) / 2 + offsetY];\n const centerLngLat = worldToLngLat(center);\n const zoom = Math.min(maxZoom, log2(Math.abs(Math.min(scaleX, scaleY))));\n assert(Number.isFinite(zoom));\n return {\n longitude: centerLngLat[0],\n latitude: centerLngLat[1],\n zoom\n };\n}\n// Helpers\nfunction getPaddingObject(padding = 0) {\n if (typeof padding === 'number') {\n return {\n top: padding,\n bottom: padding,\n left: padding,\n right: padding\n };\n }\n // Make sure all the required properties are set\n assert(Number.isFinite(padding.top) &&\n Number.isFinite(padding.bottom) &&\n Number.isFinite(padding.left) &&\n Number.isFinite(padding.right));\n return padding;\n}\n", "/* eslint-disable camelcase */\nimport { vec2 } from '@math.gl/core';\nimport { worldToLngLat } from \"./web-mercator-utils.js\";\nimport { transformVector } from \"./math-utils.js\";\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n/*\n * Returns the quad at the intersection of the frustum and the given z plane\n * @param {WebMercatorViewport} viewport\n * @param {Number} z - elevation in meters\n */\nexport function getBounds(viewport, z = 0) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { width, height, unproject } = viewport;\n const unprojectOps = { targetZ: z };\n const bottomLeft = unproject([0, height], unprojectOps);\n const bottomRight = unproject([width, height], unprojectOps);\n let topLeft;\n let topRight;\n const halfFov = viewport.fovy\n ? 0.5 * viewport.fovy * DEGREES_TO_RADIANS\n : Math.atan(0.5 / viewport.altitude);\n const angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS;\n // The top plane is parallel to the ground if halfFov == angleToGround\n if (halfFov > angleToGround - 0.01) {\n // intersect with the far plane\n topLeft = unprojectOnFarPlane(viewport, 0, z);\n topRight = unprojectOnFarPlane(viewport, width, z);\n }\n else {\n // intersect with the top plane\n topLeft = unproject([0, 0], unprojectOps);\n topRight = unproject([width, 0], unprojectOps);\n }\n return [bottomLeft, bottomRight, topRight, topLeft];\n}\n/*\n * Find a point on the far clipping plane of the viewport\n * @param {WebMercatorViewport} viewport\n * @param {Number} x - projected x in screen space\n * @param {Number} targetZ - the elevation of the point in meters\n */\nfunction unprojectOnFarPlane(viewport, x, targetZ) {\n const { pixelUnprojectionMatrix } = viewport;\n const coord0 = transformVector(pixelUnprojectionMatrix, [x, 0, 1, 1]);\n const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);\n const z = targetZ * viewport.distanceScales.unitsPerMeter[2];\n const t = (z - coord0[2]) / (coord1[2] - coord0[2]);\n const coord = vec2.lerp([], coord0, coord1, t);\n const result = worldToLngLat(coord);\n result.push(targetZ);\n return result;\n}\n", "// View and Projection Matrix calculations for mapbox-js style map view properties\nimport { createMat4 } from \"./math-utils.js\";\nimport { zoomToScale, pixelsToWorld, lngLatToWorld, worldToLngLat, worldToPixels, altitudeToFovy, fovyToAltitude, DEFAULT_ALTITUDE, getProjectionMatrix, getDistanceScales, getViewMatrix } from \"./web-mercator-utils.js\";\nimport { fitBounds } from \"./fit-bounds.js\";\nimport { getBounds } from \"./get-bounds.js\";\nimport { mat4, vec2, vec3 } from '@math.gl/core';\n/**\n * The WebMercatorViewport class creates\n * - view/projection matrices\n * - \"uniform values\" (for shaders) from mercator params\n *\n * Note: Instances are immutable in the sense that they only have accessors.\n * A new viewport instance should be created if any parameters have changed.\n */\nexport class WebMercatorViewport {\n /**\n * @classdesc\n * Creates view/projection matrices from mercator params\n * Note: The Viewport is immutable in the sense that it only has accessors.\n * A new viewport instance should be created if any parameters have changed.\n */\n // eslint-disable-next-line max-statements\n constructor(props = { width: 1, height: 1 }) {\n /** Two viewports are equal if width and height are identical, and if\n * their view and projection matrices are (approximately) equal.\n */\n this.equals = (viewport) => {\n if (!(viewport instanceof WebMercatorViewport)) {\n return false;\n }\n return (viewport.width === this.width &&\n viewport.height === this.height &&\n mat4.equals(viewport.projectionMatrix, this.projectionMatrix) &&\n mat4.equals(viewport.viewMatrix, this.viewMatrix));\n };\n /**\n * Projects xyz (possibly latitude and longitude) to pixel coordinates in window\n * using viewport projection parameters\n * - [longitude, latitude] to [x, y]\n * - [longitude, latitude, Z] => [x, y, z]\n * Note: By default, returns top-left coordinates for canvas/SVG type render\n *\n * @param lngLatZ - [lng, lat] or [lng, lat, Z]\n * @param options - options\n * @param options.topLeft=true - Whether projected coords are top left\n * @return - screen coordinates [x, y] or [x, y, z], z as pixel depth\n */\n this.project = (lngLatZ, options = {}) => {\n const { topLeft = true } = options;\n const worldPosition = this.projectPosition(lngLatZ);\n const coord = worldToPixels(worldPosition, this.pixelProjectionMatrix);\n const [x, y] = coord;\n const y2 = topLeft ? y : this.height - y;\n return lngLatZ.length === 2 ? [x, y2] : [x, y2, coord[2]];\n };\n /**\n * Unproject pixel coordinates on screen onto world coordinates, possibly `[lon, lat]` on map.\n *\n * - [x, y] => [lng, lat]\n * - [x, y, z] => [lng, lat, Z]\n *\n * @param xyz - screen coordinates, z as pixel depth\n * @param options - options\n * @param options.topLeft=true - Whether projected coords are top left\n * @param options.targetZ=0 - If pixel depth is unknown, targetZ is used as\n * the elevation plane to unproject onto\n * @return - [lng, lat, Z] or [X, Y, Z]\n */\n this.unproject = (xyz, options = {}) => {\n const { topLeft = true, targetZ = undefined } = options;\n const [x, y, z] = xyz;\n const y2 = topLeft ? y : this.height - y;\n const targetZWorld = targetZ && targetZ * this.distanceScales.unitsPerMeter[2];\n const coord = pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix, targetZWorld);\n const [X, Y, Z] = this.unprojectPosition(coord);\n if (Number.isFinite(z)) {\n return [X, Y, Z];\n }\n return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];\n };\n // NON_LINEAR PROJECTION HOOKS\n // Used for web meractor projection\n this.projectPosition = (xyz) => {\n const [X, Y] = lngLatToWorld(xyz);\n const Z = (xyz[2] || 0) * this.distanceScales.unitsPerMeter[2];\n return [X, Y, Z];\n };\n this.unprojectPosition = (xyz) => {\n const [X, Y] = worldToLngLat(xyz);\n const Z = (xyz[2] || 0) * this.distanceScales.metersPerUnit[2];\n return [X, Y, Z];\n };\n let { \n // Map state\n width, height, altitude = null, fovy = null } = props;\n const { latitude = 0, longitude = 0, zoom = 0, pitch = 0, bearing = 0, position = null, nearZMultiplier = 0.02, farZMultiplier = 1.01 } = props;\n // Silently allow apps to send in 0,0 to facilitate isomorphic render etc\n width = width || 1;\n height = height || 1;\n // `fovy` & `altitude` are independent parameters, one for the\n // projection and the latter for the view matrix. In the past,\n // the `fovy` was always derived from the `altitude`\n if (fovy === null && altitude === null) {\n altitude = DEFAULT_ALTITUDE;\n fovy = altitudeToFovy(altitude);\n }\n else if (fovy === null) {\n fovy = altitudeToFovy(altitude);\n }\n else if (altitude === null) {\n altitude = fovyToAltitude(fovy);\n }\n const scale = zoomToScale(zoom);\n // Altitude - prevent division by 0\n // TODO - just throw an Error instead?\n altitude = Math.max(0.75, altitude);\n const distanceScales = getDistanceScales({ longitude, latitude });\n const center = lngLatToWorld([longitude, latitude]);\n center.push(0);\n if (position) {\n vec3.add(center, center, vec3.mul([], position, distanceScales.unitsPerMeter));\n }\n this.projectionMatrix = getProjectionMatrix({\n width,\n height,\n scale,\n center,\n pitch,\n fovy,\n nearZMultiplier,\n farZMultiplier\n });\n this.viewMatrix = getViewMatrix({\n height,\n scale,\n center,\n pitch,\n bearing,\n altitude\n });\n // Save parameters\n this.width = width;\n this.height = height;\n this.scale = scale;\n this.latitude = latitude;\n this.longitude = longitude;\n this.zoom = zoom;\n this.pitch = pitch;\n this.bearing = bearing;\n this.altitude = altitude;\n this.fovy = fovy;\n this.center = center;\n this.meterOffset = position || [0, 0, 0];\n this.distanceScales = distanceScales;\n this._initMatrices();\n Object.freeze(this);\n }\n _initMatrices() {\n const { width, height, projectionMatrix, viewMatrix } = this;\n // Note: As usual, matrix operations should be applied in \"reverse\" order\n // since vectors will be multiplied in from the right during transformation\n const vpm = createMat4();\n mat4.multiply(vpm, vpm, projectionMatrix);\n mat4.multiply(vpm, vpm, viewMatrix);\n this.viewProjectionMatrix = vpm;\n // Calculate matrices and scales needed for projection\n /**\n * Builds matrices that converts preprojected lngLats to screen pixels\n * and vice versa.\n * Note: Currently returns bottom-left coordinates!\n * Note: Starts with the GL projection matrix and adds steps to the\n * scale and translate that matrix onto the window.\n * Note: WebGL controls clip space to screen projection with gl.viewport\n * and does not need this step.\n */\n const m = createMat4();\n // matrix for conversion from location to screen coordinates\n mat4.scale(m, m, [width / 2, -height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n mat4.multiply(m, m, vpm);\n const mInverse = mat4.invert(createMat4(), m);\n if (!mInverse) {\n throw new Error('Pixel project matrix not invertible');\n }\n this.pixelProjectionMatrix = m;\n this.pixelUnprojectionMatrix = mInverse;\n }\n /**\n * Project [lng,lat] on sphere onto [x,y] on 512*512 Mercator Zoom 0 tile.\n * Performs the nonlinear part of the web mercator projection.\n * Remaining projection is done with 4x4 matrices which also handles\n * perspective.\n *\n * @param lngLat - [lng, lat] coordinates\n * Specifies a point on the sphere to project onto the map.\n * @return [x,y] coordinates.\n */\n projectFlat(lngLat) {\n return lngLatToWorld(lngLat);\n }\n /**\n * Unproject world point [x,y] on map onto {lat, lon} on sphere\n *\n * @param xy - array with [x,y] members\n * representing point on projected map plane\n * @return - array with [lat,lon] of point on sphere.\n * Has toArray method if you need a GeoJSON Array.\n * Per cartographic tradition, lat and lon are specified as degrees.\n */\n unprojectFlat(xy) {\n return worldToLngLat(xy);\n }\n /**\n * Get the map center that place a given [lng, lat] coordinate at screen point [x, y]\n * @param opt\n * @param opt.lngLat - [lng,lat] coordinates\n * Specifies a point on the sphere.\n * @param opt.pos - [x,y] coordinates\n * Specifies a point on the screen.\n * @return [lng,lat] new map center.\n */\n getMapCenterByLngLatPosition({ lngLat, pos }) {\n const fromLocation = pixelsToWorld(pos, this.pixelUnprojectionMatrix);\n const toLocation = lngLatToWorld(lngLat);\n const translate = vec2.add([], toLocation, vec2.negate([], fromLocation));\n const newCenter = vec2.add([], this.center, translate);\n return worldToLngLat(newCenter);\n }\n /**\n * Returns a new viewport that fit around the given rectangle.\n * Only supports non-perspective mode.\n * @param bounds - [[lon, lat], [lon, lat]]\n * @param [options]\n * @param [options.padding] - The amount of padding in pixels to add to the given bounds.\n * @param [options.offset] - The center of the given bounds relative to the map's center,\n * [x, y] measured in pixels.\n * @returns {WebMercatorViewport}\n */\n fitBounds(bounds, options = {}) {\n const { width, height } = this;\n const { longitude, latitude, zoom } = fitBounds(Object.assign({ width, height, bounds }, options));\n return new WebMercatorViewport({ width, height, longitude, latitude, zoom });\n }\n /**\n * Returns the bounding box of the viewport.\n * @param [options]\n * @param [options.z] - The altitude at which the bounds should be calculated.\n * @returns {Array} bounds - [[lon, lat], [lon, lat]]\n */\n getBounds(options) {\n const corners = this.getBoundingRegion(options);\n const west = Math.min(...corners.map((p) => p[0]));\n const east = Math.max(...corners.map((p) => p[0]));\n const south = Math.min(...corners.map((p) => p[1]));\n const north = Math.max(...corners.map((p) => p[1]));\n return [\n [west, south],\n [east, north]\n ];\n }\n /**\n * Returns the bounding box of the viewport.\n * @param [options]\n * @param [options.z] - The altitude at which the bounds should be calculated.\n * @returns {Array} an array of 4 points that define the visible region\n */\n getBoundingRegion(options = {}) {\n return getBounds(this, options.z || 0);\n }\n // DEPRECATED\n /** @deprecated Legacy method name */\n getLocationAtPoint({ lngLat, pos }) {\n return this.getMapCenterByLngLatPosition({ lngLat, pos });\n }\n}\n", "import { worldToLngLat } from \"./web-mercator-utils.js\";\nimport { mod, log2 } from \"./math-utils.js\";\n// defined by mapbox-gl\nconst TILE_SIZE = 512;\n/**\n * Apply mathematical constraints to viewport props\n * @param props\n */\n// eslint-disable-next-line complexity\nexport function normalizeViewportProps(props) {\n const { width, height, pitch = 0 } = props;\n let { longitude, latitude, zoom, bearing = 0 } = props;\n // Normalize degrees\n if (longitude < -180 || longitude > 180) {\n longitude = mod(longitude + 180, 360) - 180;\n }\n if (bearing < -180 || bearing > 180) {\n bearing = mod(bearing + 180, 360) - 180;\n }\n // Constrain zoom and shift center at low zoom levels\n const minZoom = log2(height / TILE_SIZE);\n if (zoom <= minZoom) {\n zoom = minZoom;\n latitude = 0;\n }\n else {\n // Eliminate white space above and below the map\n const halfHeightPixels = height / 2 / Math.pow(2, zoom);\n const minLatitude = worldToLngLat([0, halfHeightPixels])[1];\n if (latitude < minLatitude) {\n latitude = minLatitude;\n }\n else {\n const maxLatitude = worldToLngLat([0, TILE_SIZE - halfHeightPixels])[1];\n if (latitude > maxLatitude) {\n latitude = maxLatitude;\n }\n }\n }\n return { width, height, longitude, latitude, zoom, pitch, bearing };\n}\n", "import { lerp } from \"./math-utils.js\";\nimport { scaleToZoom, zoomToScale, lngLatToWorld, worldToLngLat } from \"./web-mercator-utils.js\";\nimport { vec2 } from '@math.gl/core';\nconst EPSILON = 0.01;\nconst VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'];\nconst DEFAULT_OPTS = {\n curve: 1.414,\n speed: 1.2\n // screenSpeed and maxDuration are used only if specified\n};\n/**\n * mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.\n * It implements \u201CSmooth and efficient zooming and panning.\u201D algorithm by\n * \"Jarke J. van Wijk and Wim A.A. Nuij\"\n */\nexport function flyToViewport(startProps, endProps, t, options) {\n // Equations from above paper are referred where needed.\n const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);\n // If change in center is too small, do linear interpolaiton.\n if (u1 < EPSILON) {\n const viewport = {};\n for (const key of VIEWPORT_TRANSITION_PROPS) {\n const startValue = startProps[key];\n const endValue = endProps[key];\n // @ts-ignore-error properties are populated dynamically\n viewport[key] = lerp(startValue, endValue, t);\n }\n // @ts-expect-error properties are populated dynamically\n return viewport;\n }\n const s = t * S;\n const w = Math.cosh(r0) / Math.cosh(r0 + rho * s);\n const u = (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;\n const scaleIncrement = 1 / w; // Using w method for scaling.\n const newZoom = startZoom + scaleToZoom(scaleIncrement);\n const newCenterWorld = vec2.scale([], uDelta, u);\n vec2.add(newCenterWorld, newCenterWorld, startCenterXY);\n const newCenter = worldToLngLat(newCenterWorld);\n return {\n longitude: newCenter[0],\n latitude: newCenter[1],\n zoom: newZoom\n };\n}\n// returns transition duration in milliseconds\nexport function getFlyToDuration(startProps, endProps, options) {\n const opts = { ...DEFAULT_OPTS, ...options };\n const { screenSpeed, speed, maxDuration } = opts;\n const { S, rho } = getFlyToTransitionParams(startProps, endProps, opts);\n const length = 1000 * S;\n let duration;\n if (Number.isFinite(screenSpeed)) {\n duration = length / (screenSpeed / rho);\n }\n else {\n duration = length / speed;\n }\n return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;\n}\n// Private Methods\n// Calculate all parameters that are static for given startProps and endProps\nfunction getFlyToTransitionParams(startProps, endProps, opts) {\n opts = Object.assign({}, DEFAULT_OPTS, opts);\n const rho = opts.curve;\n const startZoom = startProps.zoom;\n const startCenter = [startProps.longitude, startProps.latitude];\n const startScale = zoomToScale(startZoom);\n const endZoom = endProps.zoom;\n const endCenter = [endProps.longitude, endProps.latitude];\n const scale = zoomToScale(endZoom - startZoom);\n const startCenterXY = lngLatToWorld(startCenter);\n const endCenterXY = lngLatToWorld(endCenter);\n const uDelta = vec2.sub([], endCenterXY, startCenterXY);\n const w0 = Math.max(startProps.width, startProps.height);\n const w1 = w0 / scale;\n const u1 = vec2.length(uDelta) * startScale;\n // u0 is treated as '0' in Eq (9).\n // If u1 is too small, will generate invalid number\n const _u1 = Math.max(u1, EPSILON);\n // Implement Equation (9) from above algorithm.\n const rho2 = rho * rho;\n const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);\n const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);\n const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);\n const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);\n const S = (r1 - r0) / rho;\n return { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0, r1 };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AK,MAAM,IAAI,GAAG;AAC5E;",
|
|
6
|
+
"names": ["import_core", "unitsPerMeter", "unitsPerMeter2", "import_core", "DEGREES_TO_RADIANS", "import_core", "TILE_SIZE", "import_core"]
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { WebMercatorViewport } from
|
|
2
|
-
export { getBounds } from
|
|
3
|
-
export { fitBounds } from
|
|
4
|
-
export { normalizeViewportProps } from
|
|
5
|
-
export { flyToViewport, getFlyToDuration } from
|
|
6
|
-
export { MAX_LATITUDE, lngLatToWorld, worldToLngLat, worldToPixels, pixelsToWorld, zoomToScale, scaleToZoom, altitudeToFovy, fovyToAltitude, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionMatrix, getProjectionParameters } from
|
|
1
|
+
export { WebMercatorViewport } from "./web-mercator-viewport.js";
|
|
2
|
+
export { getBounds } from "./get-bounds.js";
|
|
3
|
+
export { fitBounds } from "./fit-bounds.js";
|
|
4
|
+
export { normalizeViewportProps } from "./normalize-viewport-props.js";
|
|
5
|
+
export { flyToViewport, getFlyToDuration } from "./fly-to-viewport.js";
|
|
6
|
+
export { MAX_LATITUDE, lngLatToWorld, worldToLngLat, worldToPixels, pixelsToWorld, zoomToScale, scaleToZoom, altitudeToFovy, fovyToAltitude, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionMatrix, getProjectionParameters } from "./web-mercator-utils.js";
|
|
7
7
|
/** Types */
|
|
8
|
-
export type { FitBoundsOptions } from
|
|
9
|
-
export type { DistanceScales } from
|
|
8
|
+
export type { FitBoundsOptions } from "./fit-bounds.js";
|
|
9
|
+
export type { DistanceScales } from "./web-mercator-utils.js";
|
|
10
10
|
/** @deprecated default export */
|
|
11
|
-
export { WebMercatorViewport as default } from
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
11
|
+
export { WebMercatorViewport as default } from "./web-mercator-viewport.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// Classic web-mercator-project
|
|
1
2
|
export { WebMercatorViewport } from "./web-mercator-viewport.js";
|
|
2
3
|
export { getBounds } from "./get-bounds.js";
|
|
3
4
|
export { fitBounds } from "./fit-bounds.js";
|
|
4
5
|
export { normalizeViewportProps } from "./normalize-viewport-props.js";
|
|
5
6
|
export { flyToViewport, getFlyToDuration } from "./fly-to-viewport.js";
|
|
6
7
|
export { MAX_LATITUDE, lngLatToWorld, worldToLngLat, worldToPixels, pixelsToWorld, zoomToScale, scaleToZoom, altitudeToFovy, fovyToAltitude, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionMatrix, getProjectionParameters } from "./web-mercator-utils.js";
|
|
8
|
+
/** @deprecated default export */
|
|
7
9
|
export { WebMercatorViewport as default } from "./web-mercator-viewport.js";
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/math-utils.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export declare function mod(value: number, divisor: number): number;
|
|
|
4
4
|
export declare function lerp(start: number, end: number, step: number): number;
|
|
5
5
|
export declare function clamp(x: number, min: number, max: number): number;
|
|
6
6
|
export declare const log2: (x: number) => number;
|
|
7
|
-
//# sourceMappingURL=math-utils.d.ts.map
|
package/dist/math-utils.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { vec4 } from '@math.gl/core';
|
|
2
|
+
// Helper, avoids low-precision 32 bit matrices from gl-matrix mat4.create()
|
|
2
3
|
export function createMat4() {
|
|
3
|
-
|
|
4
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
4
5
|
}
|
|
6
|
+
// Transforms a vec4 with a projection matrix
|
|
5
7
|
export function transformVector(matrix, vector) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const result = vec4.transformMat4([], vector, matrix);
|
|
9
|
+
vec4.scale(result, result, 1 / result[3]);
|
|
10
|
+
return result;
|
|
9
11
|
}
|
|
10
12
|
export function mod(value, divisor) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const modulus = value % divisor;
|
|
14
|
+
return modulus < 0 ? divisor + modulus : modulus;
|
|
13
15
|
}
|
|
14
16
|
export function lerp(start, end, step) {
|
|
15
|
-
|
|
17
|
+
return step * end + (1 - step) * start;
|
|
16
18
|
}
|
|
17
19
|
export function clamp(x, min, max) {
|
|
18
|
-
|
|
20
|
+
return x < min ? min : x > max ? max : x;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
22
|
function ieLog2(x) {
|
|
22
|
-
|
|
23
|
+
return Math.log(x) * Math.LOG2E;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
// Handle missing log2 in IE 11
|
|
25
26
|
export const log2 = Math.log2 || ieLog2;
|
|
26
|
-
//# sourceMappingURL=math-utils.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Description of viewport */
|
|
2
|
-
export
|
|
2
|
+
export type ViewportProps = {
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
longitude: number;
|
|
@@ -13,4 +13,3 @@ export declare type ViewportProps = {
|
|
|
13
13
|
* @param props
|
|
14
14
|
*/
|
|
15
15
|
export declare function normalizeViewportProps(props: ViewportProps): ViewportProps;
|
|
16
|
-
//# sourceMappingURL=normalize-viewport-props.d.ts.map
|
|
@@ -1,55 +1,41 @@
|
|
|
1
1
|
import { worldToLngLat } from "./web-mercator-utils.js";
|
|
2
2
|
import { mod, log2 } from "./math-utils.js";
|
|
3
|
+
// defined by mapbox-gl
|
|
3
4
|
const TILE_SIZE = 512;
|
|
5
|
+
/**
|
|
6
|
+
* Apply mathematical constraints to viewport props
|
|
7
|
+
* @param props
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line complexity
|
|
4
10
|
export function normalizeViewportProps(props) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
longitude,
|
|
12
|
-
latitude,
|
|
13
|
-
zoom,
|
|
14
|
-
bearing = 0
|
|
15
|
-
} = props;
|
|
16
|
-
|
|
17
|
-
if (longitude < -180 || longitude > 180) {
|
|
18
|
-
longitude = mod(longitude + 180, 360) - 180;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (bearing < -180 || bearing > 180) {
|
|
22
|
-
bearing = mod(bearing + 180, 360) - 180;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const minZoom = log2(height / TILE_SIZE);
|
|
26
|
-
|
|
27
|
-
if (zoom <= minZoom) {
|
|
28
|
-
zoom = minZoom;
|
|
29
|
-
latitude = 0;
|
|
30
|
-
} else {
|
|
31
|
-
const halfHeightPixels = height / 2 / Math.pow(2, zoom);
|
|
32
|
-
const minLatitude = worldToLngLat([0, halfHeightPixels])[1];
|
|
33
|
-
|
|
34
|
-
if (latitude < minLatitude) {
|
|
35
|
-
latitude = minLatitude;
|
|
36
|
-
} else {
|
|
37
|
-
const maxLatitude = worldToLngLat([0, TILE_SIZE - halfHeightPixels])[1];
|
|
38
|
-
|
|
39
|
-
if (latitude > maxLatitude) {
|
|
40
|
-
latitude = maxLatitude;
|
|
41
|
-
}
|
|
11
|
+
const { width, height, pitch = 0 } = props;
|
|
12
|
+
let { longitude, latitude, zoom, bearing = 0 } = props;
|
|
13
|
+
// Normalize degrees
|
|
14
|
+
if (longitude < -180 || longitude > 180) {
|
|
15
|
+
longitude = mod(longitude + 180, 360) - 180;
|
|
42
16
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
height
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
if (bearing < -180 || bearing > 180) {
|
|
18
|
+
bearing = mod(bearing + 180, 360) - 180;
|
|
19
|
+
}
|
|
20
|
+
// Constrain zoom and shift center at low zoom levels
|
|
21
|
+
const minZoom = log2(height / TILE_SIZE);
|
|
22
|
+
if (zoom <= minZoom) {
|
|
23
|
+
zoom = minZoom;
|
|
24
|
+
latitude = 0;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Eliminate white space above and below the map
|
|
28
|
+
const halfHeightPixels = height / 2 / Math.pow(2, zoom);
|
|
29
|
+
const minLatitude = worldToLngLat([0, halfHeightPixels])[1];
|
|
30
|
+
if (latitude < minLatitude) {
|
|
31
|
+
latitude = minLatitude;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const maxLatitude = worldToLngLat([0, TILE_SIZE - halfHeightPixels])[1];
|
|
35
|
+
if (latitude > maxLatitude) {
|
|
36
|
+
latitude = maxLatitude;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { width, height, longitude, latitude, zoom, pitch, bearing };
|
|
54
41
|
}
|
|
55
|
-
//# sourceMappingURL=normalize-viewport-props.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const MAX_LATITUDE = 85.051129;
|
|
2
2
|
export declare const DEFAULT_ALTITUDE = 1.5;
|
|
3
|
-
export
|
|
3
|
+
export type DistanceScales = {
|
|
4
4
|
unitsPerMeter: number[];
|
|
5
5
|
metersPerUnit: number[];
|
|
6
6
|
unitsPerMeter2?: number[];
|
|
@@ -18,7 +18,7 @@ export declare type DistanceScales = {
|
|
|
18
18
|
* @param near near clipping plane
|
|
19
19
|
* @param far far clipping plane
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
type ProjectionParameters = {
|
|
22
22
|
fov: number;
|
|
23
23
|
aspect: number;
|
|
24
24
|
focalDistance: number;
|
|
@@ -189,4 +189,3 @@ export declare function worldToPixels(xyz: number[], pixelProjectionMatrix: numb
|
|
|
189
189
|
*/
|
|
190
190
|
export declare function pixelsToWorld(xyz: number[], pixelUnprojectionMatrix: number[], targetZ?: number): number[];
|
|
191
191
|
export {};
|
|
192
|
-
//# sourceMappingURL=web-mercator-utils.d.ts.map
|