@math.gl/web-mercator 3.6.0-alpha.1 → 3.6.0-alpha.4
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/es5/fit-bounds.js +37 -31
- package/dist/es5/fit-bounds.js.map +1 -1
- package/dist/es5/fly-to-viewport.js +98 -75
- package/dist/es5/fly-to-viewport.js.map +1 -1
- package/dist/es5/get-bounds.js +25 -26
- package/dist/es5/get-bounds.js.map +1 -1
- package/dist/es5/index.js +31 -23
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/math-utils.js +8 -3
- package/dist/es5/math-utils.js.map +1 -1
- package/dist/es5/normalize-viewport-props.js +21 -23
- package/dist/es5/normalize-viewport-props.js.map +1 -1
- package/dist/es5/web-mercator-utils.js +118 -92
- package/dist/es5/web-mercator-utils.js.map +1 -1
- package/dist/es5/web-mercator-viewport.js +239 -178
- package/dist/es5/web-mercator-viewport.js.map +1 -1
- package/dist/esm/fit-bounds.js +6 -13
- package/dist/esm/fit-bounds.js.map +1 -1
- package/dist/esm/fly-to-viewport.js.map +1 -1
- package/dist/esm/get-bounds.js +1 -1
- package/dist/esm/get-bounds.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math-utils.js +3 -0
- package/dist/esm/math-utils.js.map +1 -1
- package/dist/esm/normalize-viewport-props.js.map +1 -1
- package/dist/esm/web-mercator-utils.js +2 -1
- package/dist/esm/web-mercator-utils.js.map +1 -1
- package/dist/esm/web-mercator-viewport.js +1 -1
- package/dist/esm/web-mercator-viewport.js.map +1 -1
- package/dist/fit-bounds.d.ts +3 -2
- package/dist/fit-bounds.d.ts.map +1 -1
- package/dist/fit-bounds.js +6 -13
- package/dist/fly-to-viewport.d.ts +6 -6
- package/dist/fly-to-viewport.d.ts.map +1 -1
- package/dist/get-bounds.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/math-utils.d.ts +2 -1
- package/dist/math-utils.d.ts.map +1 -1
- package/dist/math-utils.js +3 -0
- package/dist/normalize-viewport-props.d.ts +1 -2
- package/dist/normalize-viewport-props.d.ts.map +1 -1
- package/dist/web-mercator-utils.d.ts +4 -3
- package/dist/web-mercator-utils.d.ts.map +1 -1
- package/dist/web-mercator-utils.js +3 -2
- package/dist/web-mercator-viewport.d.ts +4 -5
- package/dist/web-mercator-viewport.d.ts.map +1 -1
- package/dist/web-mercator-viewport.js +1 -2
- package/package.json +3 -3
- package/src/fit-bounds.ts +8 -16
- package/src/fly-to-viewport.ts +26 -11
- package/src/get-bounds.ts +4 -4
- package/src/index.ts +5 -0
- package/src/math-utils.ts +6 -2
- package/src/normalize-viewport-props.ts +1 -1
- package/src/web-mercator-utils.ts +9 -8
- package/src/web-mercator-viewport.ts +8 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/web-mercator-utils.ts"],"names":["PI","Math","PI_4","DEGREES_TO_RADIANS","RADIANS_TO_DEGREES","TILE_SIZE","EARTH_CIRCUMFERENCE","DEFAULT_ALTITUDE","zoomToScale","zoom","pow","scaleToZoom","scale","lngLatToWorld","lngLat","lng","lat","Number","isFinite","lambda2","phi2","x","y","log","tan","worldToLngLat","xy","atan","exp","getMeterZoom","options","latitude","latCosine","cos","getDistanceScales","longitude","highPrecision","worldSize","unitsPerDegreeX","unitsPerDegreeY","altUnitsPerMeter","result","unitsPerMeter","metersPerUnit","unitsPerDegree","degreesPerUnit","latCosine2","unitsPerDegreeY2","altUnitsPerDegree2","altUnitsPerMeter2","unitsPerDegree2","unitsPerMeter2","addMetersToLngLat","lngLatZ","xyz","z0","z","worldspace","newLngLat","newZ","getViewMatrix","height","pitch","bearing","altitude","center","vm","mat4","translate","rotateX","rotateZ","relativeScale","vec3","negate","getProjectionParameters","width","nearZMultiplier","farZMultiplier","fovy","altitudeToFovy","undefined","halfFov","focalDistance","fovyToAltitude","pitchRadians","topHalfSurfaceDistance","sin","min","max","farZ","fov","aspect","near","far","getProjectionMatrix","projectionMatrix","perspective","worldToPixels","pixelProjectionMatrix","pixelsToWorld","pixelUnprojectionMatrix","targetZ","coord","coord0","coord1","z1","t","vec2","lerp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAGA,MAAMA,EAAE,GAAGC,IAAI,CAACD,EAAhB;AACA,MAAME,IAAI,GAAGF,EAAE,GAAG,CAAlB;AACA,MAAMG,kBAAkB,GAAGH,EAAE,GAAG,GAAhC;AACA,MAAMI,kBAAkB,GAAG,MAAMJ,EAAjC;AACA,MAAMK,SAAS,GAAG,GAAlB;AAEA,MAAMC,mBAAmB,GAAG,OAA5B;AAGO,MAAMC,gBAAgB,GAAG,GAAzB;;;AA8BA,SAASC,WAAT,CAAqBC,IAArB,EAA2C;AAChD,SAAOR,IAAI,CAACS,GAAL,CAAS,CAAT,EAAYD,IAAZ,CAAP;AACD;;AAGM,SAASE,WAAT,CAAqBC,KAArB,EAA4C;AACjD,SAAO,qBAAKA,KAAL,CAAP;AACD;;AAYM,SAASC,aAAT,CAAuBC,MAAvB,EAAmD;AACxD,QAAM,CAACC,GAAD,EAAMC,GAAN,IAAaF,MAAnB;AACA,uBAAOG,MAAM,CAACC,QAAP,CAAgBH,GAAhB,CAAP;AACA,uBAAOE,MAAM,CAACC,QAAP,CAAgBF,GAAhB,KAAwBA,GAAG,IAAI,CAAC,EAAhC,IAAsCA,GAAG,IAAI,EAApD,EAAwD,kBAAxD;AAEA,QAAMG,OAAO,GAAGJ,GAAG,GAAGZ,kBAAtB;AACA,QAAMiB,IAAI,GAAGJ,GAAG,GAAGb,kBAAnB;AACA,QAAMkB,CAAC,GAAIhB,SAAS,IAAIc,OAAO,GAAGnB,EAAd,CAAV,IAAgC,IAAIA,EAApC,CAAV;AACA,QAAMsB,CAAC,GAAIjB,SAAS,IAAIL,EAAE,GAAGC,IAAI,CAACsB,GAAL,CAAStB,I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,OAAO,IAAI,CAAZ,IAAiB9C,EAAlB,KAAyBkD,EAAE,GAAGlD,EAA9B,CAA1B;AACA,SAAOoD,IAAI,CAACC,IAAL,CAAU,EAAV,EAAcL,MAAd,EAAsBC,MAAtB,EAA8BE,CAA9B,CAAP;AACD","sourcesContent":["// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE\n\nimport {createMat4, transformVector, log2} from './math-utils';\n\nimport * as mat4 from 'gl-matrix/mat4';\nimport * as vec2 from 'gl-matrix/vec2';\nimport * as vec3 from 'gl-matrix/vec3';\nimport assert from './assert';\n\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\n// Mapbox default altitude\nexport const DEFAULT_ALTITUDE = 1.5;\n\nexport type DistanceScales = {\n unitsPerMeter: number[];\n metersPerUnit: number[];\n unitsPerMeter2?: number[];\n unitsPerDegree: number[];\n degreesPerUnit: number[];\n unitsPerDegree2?: number[];\n};\n\n/**\n * PROJECTION MATRIX PARAMETERS\n *\n * TODO how to document mebers\n * @param fov in radians. fov is variable, depends on pitch and altitude\n * @param aspect width/height\n * @param focalDistance distance at which visual scale factor is 1\n * @param near near clipping plane\n * @param far far clipping plane\n */\ntype ProjectionParameters = {\n fov: number;\n aspect: number;\n focalDistance: number;\n near: number;\n far: number;\n};\n\n/** Logarithimic zoom to linear scale **/\nexport function zoomToScale(zoom: number): number {\n return Math.pow(2, zoom);\n}\n\n/** Linear scale to logarithimic zoom **/\nexport function scaleToZoom(scale: number): number {\n return log2(scale);\n}\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: number[]): number[] {\n const [lng, lat] = lngLat;\n assert(Number.isFinite(lng));\n assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, 'invalid latitude');\n\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/**\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: number[]): number[] {\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/**\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: {latitude: number}): number {\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/**\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 latitude: number;\n longitude: number;\n highPrecision?: boolean;\n}): DistanceScales {\n const {latitude, longitude, highPrecision = false} = options;\n assert(Number.isFinite(latitude) && Number.isFinite(longitude));\n\n const worldSize = TILE_SIZE;\n const latCosine = Math.cos(latitude * DEGREES_TO_RADIANS);\n\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 /**\n * Number of pixels occupied by one meter around current lat/lon:\n */\n const altUnitsPerMeter = worldSize / EARTH_CIRCUMFERENCE / latCosine;\n\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: DistanceScales = {\n unitsPerMeter: [altUnitsPerMeter, altUnitsPerMeter, altUnitsPerMeter],\n metersPerUnit: [1 / altUnitsPerMeter, 1 / altUnitsPerMeter, 1 / altUnitsPerMeter],\n\n unitsPerDegree: [unitsPerDegreeX, unitsPerDegreeY, altUnitsPerMeter],\n degreesPerUnit: [1 / unitsPerDegreeX, 1 / unitsPerDegreeY, 1 / altUnitsPerMeter]\n };\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\n result.unitsPerDegree2 = [0, unitsPerDegreeY2, altUnitsPerDegree2];\n result.unitsPerMeter2 = [altUnitsPerMeter2, 0, altUnitsPerMeter2];\n }\n\n // Main results, used for converting meters to latlng deltas and scaling offsets\n return result;\n}\n\n/**\n * Offset a lng/lat position by meterOffset (northing, easting)\n */\nexport function addMetersToLngLat(lngLatZ: number[], xyz: number[]): number[] {\n const [longitude, latitude, z0] = lngLatZ;\n const [x, y, z] = xyz;\n\n const {unitsPerMeter, unitsPerMeter2} = getDistanceScales({\n longitude,\n latitude,\n highPrecision: true\n });\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\n // @ts-ignore\n const newLngLat = worldToLngLat(worldspace);\n const newZ = (z0 || 0) + (z || 0);\n\n return Number.isFinite(z0) || Number.isFinite(z) ? [newLngLat[0], newLngLat[1], newZ] : newLngLat;\n}\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 // Viewport props\n height: number;\n pitch: number;\n bearing: number;\n altitude: number;\n // Pre-calculated parameters\n scale: number;\n center: number[];\n}): number[] {\n const {\n // Viewport props\n height,\n pitch,\n bearing,\n altitude,\n // Pre-calculated parameters\n scale,\n center = null\n } = 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\n // Move camera to altitude (along the pitch & bearing direction)\n mat4.translate(vm, vm, [0, 0, -altitude]);\n\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\n const relativeScale = scale / height;\n mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);\n\n if (center) {\n mat4.translate(vm, vm, vec3.negate([], center));\n }\n\n return vm;\n}\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.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 width: number;\n height: number;\n fovy?: number;\n altitude?: number;\n pitch?: number;\n nearZMultiplier?: number;\n farZMultiplier?: number;\n}): ProjectionParameters {\n const {width, height, altitude, pitch = 0, nearZMultiplier = 1, farZMultiplier = 1} = options;\n let {fovy = altitudeToFovy(DEFAULT_ALTITUDE)} = options;\n\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 halfFov = 0.5 * fovy * DEGREES_TO_RADIANS;\n const focalDistance = fovyToAltitude(fovy);\n\n // Find the distance from the center point to the center top\n // in focal distance units using law of sines.\n const pitchRadians = pitch * DEGREES_TO_RADIANS;\n const topHalfSurfaceDistance =\n (Math.sin(halfFov) * focalDistance) /\n Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01));\n\n // Calculate z value of the farthest fragment that should be rendered.\n const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance;\n\n return {\n fov: 2 * halfFov,\n aspect: width / height,\n focalDistance,\n near: nearZMultiplier,\n far: farZ * farZMultiplier\n };\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.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 width: number;\n height: number;\n pitch: number;\n fovy?: number;\n altitude?: number;\n nearZMultiplier: number;\n farZMultiplier: number;\n}): number[] {\n const {fov, aspect, near, far} = getProjectionParameters(options);\n\n const projectionMatrix = mat4.perspective(\n [],\n fov, // fov in radians\n aspect, // aspect ratio\n near, // near plane\n far // far plane\n );\n\n return projectionMatrix;\n}\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: number): number {\n return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES;\n}\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: number): number {\n return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS);\n}\n\n/**\n * Project flat coordinates to pixels on screen.\n *\n * @param xyz - flat coordinate on 512*512 Mercator Zoom 0 tile\n * @param pixelProjectionMatrix - projection matrix 4x4\n * @return [x, y, depth] pixel coordinate on screen.\n */\nexport function worldToPixels(xyz: number[], pixelProjectionMatrix: number[]): number[];\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\n return transformVector(pixelProjectionMatrix, [x, y, z, 1]);\n}\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(\n xyz: number[],\n pixelUnprojectionMatrix: number[],\n targetZ: number = 0\n): number[] {\n const [x, y, z] = xyz;\n assert(Number.isFinite(x) && Number.isFinite(y), 'invalid pixel coordinate');\n\n if (Number.isFinite(z)) {\n // Has depth component\n const coord = transformVector(pixelUnprojectionMatrix, [x, y, z, 1]);\n return coord;\n }\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\n const z0 = coord0[2];\n const z1 = coord1[2];\n\n const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);\n return vec2.lerp([], coord0, coord1, t);\n}\n"],"file":"web-mercator-utils.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/web-mercator-utils.ts"],"names":["PI","Math","PI_4","DEGREES_TO_RADIANS","RADIANS_TO_DEGREES","TILE_SIZE","EARTH_CIRCUMFERENCE","MAX_LATITUDE","DEFAULT_ALTITUDE","zoomToScale","zoom","pow","scaleToZoom","scale","lngLatToWorld","lngLat","lng","lat","Number","isFinite","lambda2","phi2","x","y","log","tan","worldToLngLat","xy","atan","exp","getMeterZoom","options","latitude","latCosine","cos","getDistanceScales","longitude","highPrecision","worldSize","unitsPerDegreeX","unitsPerDegreeY","altUnitsPerMeter","result","unitsPerMeter","metersPerUnit","unitsPerDegree","degreesPerUnit","latCosine2","unitsPerDegreeY2","altUnitsPerDegree2","altUnitsPerMeter2","unitsPerDegree2","unitsPerMeter2","addMetersToLngLat","lngLatZ","xyz","z0","z","worldspace","newLngLat","newZ","getViewMatrix","height","pitch","bearing","altitude","center","vm","mat4","translate","rotateX","rotateZ","relativeScale","vec3","negate","getProjectionParameters","width","nearZMultiplier","farZMultiplier","fovy","altitudeToFovy","undefined","halfFov","focalDistance","fovyToAltitude","pitchRadians","topHalfSurfaceDistance","sin","min","max","farZ","fov","aspect","near","far","getProjectionMatrix","projectionMatrix","perspective","worldToPixels","pixelProjectionMatrix","pixelsToWorld","pixelUnprojectionMatrix","targetZ","coord","coord0","coord1","z1","t","vec2","lerp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAGA,IAAMA,EAAE,GAAGC,IAAI,CAACD,EAAhB;AACA,IAAME,IAAI,GAAGF,EAAE,GAAG,CAAlB;AACA,IAAMG,kBAAkB,GAAGH,EAAE,GAAG,GAAhC;AACA,IAAMI,kBAAkB,GAAG,MAAMJ,EAAjC;AACA,IAAMK,SAAS,GAAG,GAAlB;AAEA,IAAMC,mBAAmB,GAAG,OAA5B;AAEO,IAAMC,YAAY,GAAG,SAArB;;AAGA,IAAMC,gBAAgB,GAAG,GAAzB;;;AA8BA,SAASC,WAAT,CAAqBC,IAArB,EAA2C;AAChD,SAAOT,IAAI,CAACU,GAAL,CAAS,CAAT,EAAYD,IAAZ,CAAP;AACD;;AAGM,SAASE,WAAT,CAAqBC,KAArB,EAA4C;AACjD,SAAO,qBAAKA,KAAL,CAAP;AACD;;AAYM,SAASC,aAAT,CAAuBC,MAAvB,EAA2D;AAChE,6CAAmBA,MAAnB;AAAA,MAAOC,GAAP;AAAA,MAAYC,GAAZ;;AACA,uBAAOC,MAAM,CAACC,QAAP,CAAgBH,GAAhB,CAAP;AACA,uBAAOE,MAAM,CAACC,QAAP,CAAgBF,GAAhB,KAAwBA,GAAG,IAAI,CAAC,EAAhC,IAAsCA,GAAG,IAAI,EAApD,EAAwD,kBAAxD;AAEA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BAFK,EAIK;AAAA,MADVC,OACU,uEADQ,CACR;;AACV,2CAAkB/C,GAAlB;AAAA,MAAOjC,CAAP;AAAA,MAAUC,CAAV;AAAA,MAAakC,CAAb;;AACA,uBAAOvC,MAAM,CAACC,QAAP,CAAgBG,CAAhB,KAAsBJ,MAAM,CAACC,QAAP,CAAgBI,CAAhB,CAA7B,EAAiD,0BAAjD;;AAEA,MAAIL,MAAM,CAACC,QAAP,CAAgBsC,CAAhB,CAAJ,EAAwB;AAEtB,QAAM8C,KAAK,GAAG,gCAAgBF,uBAAhB,EAAyC,CAAC/E,CAAD,EAAIC,CAAJ,EAAOkC,CAAP,EAAU,CAAV,CAAzC,CAAd;AACA,WAAO8C,KAAP;AACD;;AAID,MAAMC,MAAM,GAAG,gCAAgBH,uBAAhB,EAAyC,CAAC/E,CAAD,EAAIC,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAzC,CAAf;AACA,MAAMkF,MAAM,GAAG,gCAAgBJ,uBAAhB,EAAyC,CAAC/E,CAAD,EAAIC,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAzC,CAAf;AAEA,MAAMiC,EAAE,GAAGgD,MAAM,CAAC,CAAD,CAAjB;AACA,MAAME,EAAE,GAAGD,MAAM,CAAC,CAAD,CAAjB;AAEA,MAAME,CAAC,GAAGnD,EAAE,KAAKkD,EAAP,GAAY,CAAZ,GAAgB,CAAC,CAACJ,OAAO,IAAI,CAAZ,IAAiB9C,EAAlB,KAAyBkD,EAAE,GAAGlD,EAA9B,CAA1B;AACA,SAAOoD,IAAI,CAACC,IAAL,CAAU,EAAV,EAA0BL,MAA1B,EAAkCC,MAAlC,EAA0CE,CAA1C,CAAP;AACD","sourcesContent":["// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE\n\nimport {createMat4, transformVector, log2} from './math-utils';\n\nimport * as mat4 from 'gl-matrix/mat4';\nimport * as vec2 from 'gl-matrix/vec2';\nimport * as vec3 from 'gl-matrix/vec3';\nimport assert from './assert';\n\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\n// Mapbox default altitude\nexport const DEFAULT_ALTITUDE = 1.5;\n\nexport type DistanceScales = {\n unitsPerMeter: number[];\n metersPerUnit: number[];\n unitsPerMeter2?: number[];\n unitsPerDegree: number[];\n degreesPerUnit: number[];\n unitsPerDegree2?: number[];\n};\n\n/**\n * PROJECTION MATRIX PARAMETERS\n *\n * TODO how to document mebers\n * @param fov in radians. fov is variable, depends on pitch and altitude\n * @param aspect width/height\n * @param focalDistance distance at which visual scale factor is 1\n * @param near near clipping plane\n * @param far far clipping plane\n */\ntype ProjectionParameters = {\n fov: number;\n aspect: number;\n focalDistance: number;\n near: number;\n far: number;\n};\n\n/** Logarithimic zoom to linear scale **/\nexport function zoomToScale(zoom: number): number {\n return Math.pow(2, zoom);\n}\n\n/** Linear scale to logarithimic zoom **/\nexport function scaleToZoom(scale: number): number {\n return log2(scale);\n}\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: number[]): [number, number] {\n const [lng, lat] = lngLat;\n assert(Number.isFinite(lng));\n assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, 'invalid latitude');\n\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/**\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: number[]): [number, number] {\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/**\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: {latitude: number}): number {\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/**\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 latitude: number;\n longitude: number;\n highPrecision?: boolean;\n}): DistanceScales {\n const {latitude, longitude, highPrecision = false} = options;\n assert(Number.isFinite(latitude) && Number.isFinite(longitude));\n\n const worldSize = TILE_SIZE;\n const latCosine = Math.cos(latitude * DEGREES_TO_RADIANS);\n\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 /**\n * Number of pixels occupied by one meter around current lat/lon:\n */\n const altUnitsPerMeter = worldSize / EARTH_CIRCUMFERENCE / latCosine;\n\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: DistanceScales = {\n unitsPerMeter: [altUnitsPerMeter, altUnitsPerMeter, altUnitsPerMeter],\n metersPerUnit: [1 / altUnitsPerMeter, 1 / altUnitsPerMeter, 1 / altUnitsPerMeter],\n\n unitsPerDegree: [unitsPerDegreeX, unitsPerDegreeY, altUnitsPerMeter],\n degreesPerUnit: [1 / unitsPerDegreeX, 1 / unitsPerDegreeY, 1 / altUnitsPerMeter]\n };\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\n result.unitsPerDegree2 = [0, unitsPerDegreeY2, altUnitsPerDegree2];\n result.unitsPerMeter2 = [altUnitsPerMeter2, 0, altUnitsPerMeter2];\n }\n\n // Main results, used for converting meters to latlng deltas and scaling offsets\n return result;\n}\n\n/**\n * Offset a lng/lat position by meterOffset (northing, easting)\n */\nexport function addMetersToLngLat(lngLatZ: number[], xyz: number[]): number[] {\n const [longitude, latitude, z0] = lngLatZ;\n const [x, y, z] = xyz;\n\n const {unitsPerMeter, unitsPerMeter2} = getDistanceScales({\n longitude,\n latitude,\n highPrecision: true\n });\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\n const newLngLat = worldToLngLat(worldspace);\n const newZ = (z0 || 0) + (z || 0);\n\n return Number.isFinite(z0) || Number.isFinite(z) ? [newLngLat[0], newLngLat[1], newZ] : newLngLat;\n}\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 // Viewport props\n height: number;\n pitch: number;\n bearing: number;\n altitude: number;\n // Pre-calculated parameters\n scale: number;\n center?: number[];\n}): number[] {\n const {\n // Viewport props\n height,\n pitch,\n bearing,\n altitude,\n // Pre-calculated parameters\n scale,\n center\n } = 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\n // Move camera to altitude (along the pitch & bearing direction)\n mat4.translate(vm, vm, [0, 0, -altitude]);\n\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\n const relativeScale = scale / height;\n mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);\n\n if (center) {\n mat4.translate(vm, vm, vec3.negate([], center));\n }\n\n return vm;\n}\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.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 width: number;\n height: number;\n fovy?: number;\n altitude?: number;\n pitch?: number;\n nearZMultiplier?: number;\n farZMultiplier?: number;\n}): ProjectionParameters {\n const {width, height, altitude, pitch = 0, nearZMultiplier = 1, farZMultiplier = 1} = options;\n let {fovy = altitudeToFovy(DEFAULT_ALTITUDE)} = options;\n\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 halfFov = 0.5 * fovy * DEGREES_TO_RADIANS;\n const focalDistance = fovyToAltitude(fovy);\n\n // Find the distance from the center point to the center top\n // in focal distance units using law of sines.\n const pitchRadians = pitch * DEGREES_TO_RADIANS;\n const topHalfSurfaceDistance =\n (Math.sin(halfFov) * focalDistance) /\n Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01));\n\n // Calculate z value of the farthest fragment that should be rendered.\n const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance;\n\n return {\n fov: 2 * halfFov,\n aspect: width / height,\n focalDistance,\n near: nearZMultiplier,\n far: farZ * farZMultiplier\n };\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.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 width: number;\n height: number;\n pitch: number;\n fovy?: number;\n altitude?: number;\n nearZMultiplier: number;\n farZMultiplier: number;\n}): number[] {\n const {fov, aspect, near, far} = getProjectionParameters(options);\n\n const projectionMatrix = mat4.perspective(\n [] as number[],\n fov, // fov in radians\n aspect, // aspect ratio\n near, // near plane\n far // far plane\n );\n\n return projectionMatrix;\n}\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: number): number {\n return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES;\n}\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: number): number {\n return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS);\n}\n\n/**\n * Project flat coordinates to pixels on screen.\n *\n * @param xyz - flat coordinate on 512*512 Mercator Zoom 0 tile\n * @param pixelProjectionMatrix - projection matrix 4x4\n * @return [x, y, depth] pixel coordinate on screen.\n */\nexport function worldToPixels(xyz: number[], pixelProjectionMatrix: number[]): number[];\n\n// Project flat coordinates to pixels on screen.\nexport function worldToPixels(xyz: number[], pixelProjectionMatrix: number[]): number[] {\n const [x, y, z = 0] = xyz;\n assert(Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z));\n\n return transformVector(pixelProjectionMatrix, [x, y, z, 1]);\n}\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(\n xyz: number[],\n pixelUnprojectionMatrix: number[],\n targetZ: number = 0\n): number[] {\n const [x, y, z] = xyz;\n assert(Number.isFinite(x) && Number.isFinite(y), 'invalid pixel coordinate');\n\n if (Number.isFinite(z)) {\n // Has depth component\n const coord = transformVector(pixelUnprojectionMatrix, [x, y, z, 1]);\n return coord;\n }\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\n const z0 = coord0[2];\n const z1 = coord1[2];\n\n const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);\n return vec2.lerp([] as number[], coord0, coord1, t);\n}\n"],"file":"web-mercator-utils.js"}
|
|
@@ -2,18 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.default = void 0;
|
|
9
11
|
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
10
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
21
|
|
|
12
22
|
var _mathUtils = require("./math-utils");
|
|
13
23
|
|
|
14
24
|
var _webMercatorUtils = require("./web-mercator-utils");
|
|
15
25
|
|
|
16
|
-
var
|
|
26
|
+
var _fitBounds3 = _interopRequireDefault(require("./fit-bounds"));
|
|
17
27
|
|
|
18
28
|
var _getBounds = _interopRequireDefault(require("./get-bounds"));
|
|
19
29
|
|
|
@@ -23,15 +33,17 @@ var vec2 = _interopRequireWildcard(require("gl-matrix/vec2"));
|
|
|
23
33
|
|
|
24
34
|
var vec3 = _interopRequireWildcard(require("gl-matrix/vec3"));
|
|
25
35
|
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
37
|
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
var WebMercatorViewport = function () {
|
|
41
|
+
function WebMercatorViewport() {
|
|
42
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
43
|
+
width: 1,
|
|
44
|
+
height: 1
|
|
45
|
+
};
|
|
46
|
+
(0, _classCallCheck2.default)(this, WebMercatorViewport);
|
|
35
47
|
(0, _defineProperty2.default)(this, "latitude", void 0);
|
|
36
48
|
(0, _defineProperty2.default)(this, "longitude", void 0);
|
|
37
49
|
(0, _defineProperty2.default)(this, "zoom", void 0);
|
|
@@ -50,22 +62,28 @@ class WebMercatorViewport {
|
|
|
50
62
|
(0, _defineProperty2.default)(this, "viewProjectionMatrix", void 0);
|
|
51
63
|
(0, _defineProperty2.default)(this, "pixelProjectionMatrix", void 0);
|
|
52
64
|
(0, _defineProperty2.default)(this, "pixelUnprojectionMatrix", void 0);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
var width = props.width,
|
|
66
|
+
height = props.height,
|
|
67
|
+
_props$altitude = props.altitude,
|
|
68
|
+
altitude = _props$altitude === void 0 ? null : _props$altitude,
|
|
69
|
+
_props$fovy = props.fovy,
|
|
70
|
+
fovy = _props$fovy === void 0 ? null : _props$fovy;
|
|
71
|
+
var _props$latitude = props.latitude,
|
|
72
|
+
latitude = _props$latitude === void 0 ? 0 : _props$latitude,
|
|
73
|
+
_props$longitude = props.longitude,
|
|
74
|
+
longitude = _props$longitude === void 0 ? 0 : _props$longitude,
|
|
75
|
+
_props$zoom = props.zoom,
|
|
76
|
+
zoom = _props$zoom === void 0 ? 0 : _props$zoom,
|
|
77
|
+
_props$pitch = props.pitch,
|
|
78
|
+
pitch = _props$pitch === void 0 ? 0 : _props$pitch,
|
|
79
|
+
_props$bearing = props.bearing,
|
|
80
|
+
bearing = _props$bearing === void 0 ? 0 : _props$bearing,
|
|
81
|
+
_props$position = props.position,
|
|
82
|
+
position = _props$position === void 0 ? null : _props$position,
|
|
83
|
+
_props$nearZMultiplie = props.nearZMultiplier,
|
|
84
|
+
nearZMultiplier = _props$nearZMultiplie === void 0 ? 0.02 : _props$nearZMultiplie,
|
|
85
|
+
_props$farZMultiplier = props.farZMultiplier,
|
|
86
|
+
farZMultiplier = _props$farZMultiplier === void 0 ? 1.01 : _props$farZMultiplier;
|
|
69
87
|
width = width || 1;
|
|
70
88
|
height = height || 1;
|
|
71
89
|
|
|
@@ -78,34 +96,34 @@ class WebMercatorViewport {
|
|
|
78
96
|
altitude = (0, _webMercatorUtils.fovyToAltitude)(fovy);
|
|
79
97
|
}
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
var scale = (0, _webMercatorUtils.zoomToScale)(zoom);
|
|
82
100
|
altitude = Math.max(0.75, altitude);
|
|
83
|
-
|
|
84
|
-
longitude,
|
|
85
|
-
latitude
|
|
101
|
+
var distanceScales = (0, _webMercatorUtils.getDistanceScales)({
|
|
102
|
+
longitude: longitude,
|
|
103
|
+
latitude: latitude
|
|
86
104
|
});
|
|
87
|
-
|
|
88
|
-
center
|
|
105
|
+
var center = (0, _webMercatorUtils.lngLatToWorld)([longitude, latitude]);
|
|
106
|
+
center.push(0);
|
|
89
107
|
|
|
90
108
|
if (position) {
|
|
91
109
|
vec3.add(center, center, vec3.mul([], position, distanceScales.unitsPerMeter));
|
|
92
110
|
}
|
|
93
111
|
|
|
94
112
|
this.projectionMatrix = (0, _webMercatorUtils.getProjectionMatrix)({
|
|
95
|
-
width,
|
|
96
|
-
height,
|
|
97
|
-
pitch,
|
|
98
|
-
fovy,
|
|
99
|
-
nearZMultiplier,
|
|
100
|
-
farZMultiplier
|
|
113
|
+
width: width,
|
|
114
|
+
height: height,
|
|
115
|
+
pitch: pitch,
|
|
116
|
+
fovy: fovy,
|
|
117
|
+
nearZMultiplier: nearZMultiplier,
|
|
118
|
+
farZMultiplier: farZMultiplier
|
|
101
119
|
});
|
|
102
120
|
this.viewMatrix = (0, _webMercatorUtils.getViewMatrix)({
|
|
103
|
-
height,
|
|
104
|
-
scale,
|
|
105
|
-
center,
|
|
106
|
-
pitch,
|
|
107
|
-
bearing,
|
|
108
|
-
altitude
|
|
121
|
+
height: height,
|
|
122
|
+
scale: scale,
|
|
123
|
+
center: center,
|
|
124
|
+
pitch: pitch,
|
|
125
|
+
bearing: bearing,
|
|
126
|
+
altitude: altitude
|
|
109
127
|
});
|
|
110
128
|
this.width = width;
|
|
111
129
|
this.height = height;
|
|
@@ -131,146 +149,189 @@ class WebMercatorViewport {
|
|
|
131
149
|
Object.freeze(this);
|
|
132
150
|
}
|
|
133
151
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
(0, _createClass2.default)(WebMercatorViewport, [{
|
|
153
|
+
key: "_initMatrices",
|
|
154
|
+
value: function _initMatrices() {
|
|
155
|
+
var width = this.width,
|
|
156
|
+
height = this.height,
|
|
157
|
+
projectionMatrix = this.projectionMatrix,
|
|
158
|
+
viewMatrix = this.viewMatrix;
|
|
159
|
+
var vpm = (0, _mathUtils.createMat4)();
|
|
160
|
+
mat4.multiply(vpm, vpm, projectionMatrix);
|
|
161
|
+
mat4.multiply(vpm, vpm, viewMatrix);
|
|
162
|
+
this.viewProjectionMatrix = vpm;
|
|
163
|
+
var m = (0, _mathUtils.createMat4)();
|
|
164
|
+
mat4.scale(m, m, [width / 2, -height / 2, 1]);
|
|
165
|
+
mat4.translate(m, m, [1, -1, 0]);
|
|
166
|
+
mat4.multiply(m, m, vpm);
|
|
167
|
+
var mInverse = mat4.invert((0, _mathUtils.createMat4)(), m);
|
|
168
|
+
|
|
169
|
+
if (!mInverse) {
|
|
170
|
+
throw new Error('Pixel project matrix not invertible');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.pixelProjectionMatrix = m;
|
|
174
|
+
this.pixelUnprojectionMatrix = mInverse;
|
|
153
175
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return
|
|
176
|
+
}, {
|
|
177
|
+
key: "equals",
|
|
178
|
+
value: function equals(viewport) {
|
|
179
|
+
if (!(viewport instanceof WebMercatorViewport)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return viewport.width === this.width && viewport.height === this.height && mat4.equals(viewport.projectionMatrix, this.projectionMatrix) && mat4.equals(viewport.viewMatrix, this.viewMatrix);
|
|
162
184
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
}, {
|
|
186
|
+
key: "project",
|
|
187
|
+
value: function project(lngLatZ) {
|
|
188
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
189
|
+
var _options$topLeft = options.topLeft,
|
|
190
|
+
topLeft = _options$topLeft === void 0 ? true : _options$topLeft;
|
|
191
|
+
var worldPosition = this.projectPosition(lngLatZ);
|
|
192
|
+
var coord = (0, _webMercatorUtils.worldToPixels)(worldPosition, this.pixelProjectionMatrix);
|
|
193
|
+
|
|
194
|
+
var _coord = (0, _slicedToArray2.default)(coord, 2),
|
|
195
|
+
x = _coord[0],
|
|
196
|
+
y = _coord[1];
|
|
197
|
+
|
|
198
|
+
var y2 = topLeft ? y : this.height - y;
|
|
199
|
+
return lngLatZ.length === 2 ? [x, y2] : [x, y2, coord[2]];
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "unproject",
|
|
203
|
+
value: function unproject(xyz) {
|
|
204
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
205
|
+
var _options$topLeft2 = options.topLeft,
|
|
206
|
+
topLeft = _options$topLeft2 === void 0 ? true : _options$topLeft2,
|
|
207
|
+
_options$targetZ = options.targetZ,
|
|
208
|
+
targetZ = _options$targetZ === void 0 ? undefined : _options$targetZ;
|
|
209
|
+
|
|
210
|
+
var _xyz = (0, _slicedToArray2.default)(xyz, 3),
|
|
211
|
+
x = _xyz[0],
|
|
212
|
+
y = _xyz[1],
|
|
213
|
+
z = _xyz[2];
|
|
214
|
+
|
|
215
|
+
var y2 = topLeft ? y : this.height - y;
|
|
216
|
+
var targetZWorld = targetZ && targetZ * this.distanceScales.unitsPerMeter[2];
|
|
217
|
+
var coord = (0, _webMercatorUtils.pixelsToWorld)([x, y2, z], this.pixelUnprojectionMatrix, targetZWorld);
|
|
218
|
+
|
|
219
|
+
var _this$unprojectPositi = this.unprojectPosition(coord),
|
|
220
|
+
_this$unprojectPositi2 = (0, _slicedToArray2.default)(_this$unprojectPositi, 3),
|
|
221
|
+
X = _this$unprojectPositi2[0],
|
|
222
|
+
Y = _this$unprojectPositi2[1],
|
|
223
|
+
Z = _this$unprojectPositi2[2];
|
|
224
|
+
|
|
225
|
+
if (Number.isFinite(z)) {
|
|
226
|
+
return [X, Y, Z];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "projectPosition",
|
|
233
|
+
value: function projectPosition(xyz) {
|
|
234
|
+
var _lngLatToWorld = (0, _webMercatorUtils.lngLatToWorld)(xyz),
|
|
235
|
+
_lngLatToWorld2 = (0, _slicedToArray2.default)(_lngLatToWorld, 2),
|
|
236
|
+
X = _lngLatToWorld2[0],
|
|
237
|
+
Y = _lngLatToWorld2[1];
|
|
238
|
+
|
|
239
|
+
var Z = (xyz[2] || 0) * this.distanceScales.unitsPerMeter[2];
|
|
190
240
|
return [X, Y, Z];
|
|
191
241
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
242
|
+
}, {
|
|
243
|
+
key: "unprojectPosition",
|
|
244
|
+
value: function unprojectPosition(xyz) {
|
|
245
|
+
var _worldToLngLat = (0, _webMercatorUtils.worldToLngLat)(xyz),
|
|
246
|
+
_worldToLngLat2 = (0, _slicedToArray2.default)(_worldToLngLat, 2),
|
|
247
|
+
X = _worldToLngLat2[0],
|
|
248
|
+
Y = _worldToLngLat2[1];
|
|
249
|
+
|
|
250
|
+
var Z = (xyz[2] || 0) * this.distanceScales.metersPerUnit[2];
|
|
251
|
+
return [X, Y, Z];
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "projectFlat",
|
|
255
|
+
value: function projectFlat(lngLat) {
|
|
256
|
+
return (0, _webMercatorUtils.lngLatToWorld)(lngLat);
|
|
257
|
+
}
|
|
258
|
+
}, {
|
|
259
|
+
key: "unprojectFlat",
|
|
260
|
+
value: function unprojectFlat(xy) {
|
|
261
|
+
return (0, _webMercatorUtils.worldToLngLat)(xy);
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
key: "getMapCenterByLngLatPosition",
|
|
265
|
+
value: function getMapCenterByLngLatPosition(_ref) {
|
|
266
|
+
var lngLat = _ref.lngLat,
|
|
267
|
+
pos = _ref.pos;
|
|
268
|
+
var fromLocation = (0, _webMercatorUtils.pixelsToWorld)(pos, this.pixelUnprojectionMatrix);
|
|
269
|
+
var toLocation = (0, _webMercatorUtils.lngLatToWorld)(lngLat);
|
|
270
|
+
var translate = vec2.add([], toLocation, vec2.negate([], fromLocation));
|
|
271
|
+
var newCenter = vec2.add([], this.center, translate);
|
|
272
|
+
return (0, _webMercatorUtils.worldToLngLat)(newCenter);
|
|
273
|
+
}
|
|
274
|
+
}, {
|
|
275
|
+
key: "fitBounds",
|
|
276
|
+
value: function fitBounds(bounds) {
|
|
277
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
278
|
+
var width = this.width,
|
|
279
|
+
height = this.height;
|
|
280
|
+
|
|
281
|
+
var _fitBounds2 = (0, _fitBounds3.default)(Object.assign({
|
|
282
|
+
width: width,
|
|
283
|
+
height: height,
|
|
284
|
+
bounds: bounds
|
|
285
|
+
}, options)),
|
|
286
|
+
longitude = _fitBounds2.longitude,
|
|
287
|
+
latitude = _fitBounds2.latitude,
|
|
288
|
+
zoom = _fitBounds2.zoom;
|
|
289
|
+
|
|
290
|
+
return new WebMercatorViewport({
|
|
291
|
+
width: width,
|
|
292
|
+
height: height,
|
|
293
|
+
longitude: longitude,
|
|
294
|
+
latitude: latitude,
|
|
295
|
+
zoom: zoom
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
key: "getBounds",
|
|
300
|
+
value: function getBounds(options) {
|
|
301
|
+
var corners = this.getBoundingRegion(options);
|
|
302
|
+
var west = Math.min.apply(Math, (0, _toConsumableArray2.default)(corners.map(function (p) {
|
|
303
|
+
return p[0];
|
|
304
|
+
})));
|
|
305
|
+
var east = Math.max.apply(Math, (0, _toConsumableArray2.default)(corners.map(function (p) {
|
|
306
|
+
return p[0];
|
|
307
|
+
})));
|
|
308
|
+
var south = Math.min.apply(Math, (0, _toConsumableArray2.default)(corners.map(function (p) {
|
|
309
|
+
return p[1];
|
|
310
|
+
})));
|
|
311
|
+
var north = Math.max.apply(Math, (0, _toConsumableArray2.default)(corners.map(function (p) {
|
|
312
|
+
return p[1];
|
|
313
|
+
})));
|
|
314
|
+
return [[west, south], [east, north]];
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
key: "getBoundingRegion",
|
|
318
|
+
value: function getBoundingRegion() {
|
|
319
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
320
|
+
return (0, _getBounds.default)(this, options.z || 0);
|
|
321
|
+
}
|
|
322
|
+
}, {
|
|
323
|
+
key: "getLocationAtPoint",
|
|
324
|
+
value: function getLocationAtPoint(_ref2) {
|
|
325
|
+
var lngLat = _ref2.lngLat,
|
|
326
|
+
pos = _ref2.pos;
|
|
327
|
+
return this.getMapCenterByLngLatPosition({
|
|
328
|
+
lngLat: lngLat,
|
|
329
|
+
pos: pos
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}]);
|
|
333
|
+
return WebMercatorViewport;
|
|
334
|
+
}();
|
|
274
335
|
|
|
275
336
|
exports.default = WebMercatorViewport;
|
|
276
337
|
//# sourceMappingURL=web-mercator-viewport.js.map
|