mapbox-gl-draw-geodesic
Advanced tools
Comparing version 2.2.3 to 2.2.4
# Changelog | ||
## 2.2.4 | ||
- bundle mapbox-gl-draw 1.3.0 sources | ||
## 2.2.3 | ||
@@ -4,0 +8,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var arc = require('arc'); | ||
var spherical_js = require('geodesy-fn/src/spherical.js'); | ||
var geodesyFn = require('geodesy-fn'); | ||
var CommonSelectors = require('@mapbox/mapbox-gl-draw/src/lib/common_selectors.js'); | ||
@@ -136,6 +136,6 @@ var doubleClickZoom = require('@mapbox/mapbox-gl-draw/src/lib/double_click_zoom.js'); | ||
function distance(start, destination) { | ||
return spherical_js.distance(start, destination, DEFAULT_RADIUS); | ||
return geodesyFn.distance(start, destination, DEFAULT_RADIUS); | ||
} | ||
function destinationPoint(start, distance, bearing) { | ||
return spherical_js.destinationPoint(start, distance, bearing, DEFAULT_RADIUS); | ||
return geodesyFn.destinationPoint(start, distance, bearing, DEFAULT_RADIUS); | ||
} | ||
@@ -218,3 +218,3 @@ | ||
const endCoord = feature.getCoordinate(endCoordPath); | ||
const midCoord = spherical_js.midpoint(startCoord, endCoord); | ||
const midCoord = geodesyFn.midpoint(startCoord, endCoord); | ||
const geodesicGeojson = { | ||
@@ -385,3 +385,3 @@ ...geojson, | ||
const radius = distance(center, handle); | ||
const handleBearing = spherical_js.initialBearing(center, handle); | ||
const handleBearing = geodesyFn.initialBearing(center, handle); | ||
state.circle.properties[properties.CIRCLE_RADIUS] = radius; | ||
@@ -479,3 +479,3 @@ state.circle[properties.CIRCLE_HANDLE_BEARING] = handleBearing; | ||
const radius = distance(center, handle); | ||
const handleBearing = spherical_js.initialBearing(center, handle); | ||
const handleBearing = geodesyFn.initialBearing(center, handle); | ||
state.feature.properties[properties.CIRCLE_RADIUS] = radius; | ||
@@ -482,0 +482,0 @@ state.feature[properties.CIRCLE_HANDLE_BEARING] = handleBearing; |
@@ -5,3 +5,3 @@ import { modes as modes$1, geojsonTypes, meta, activeStates, cursors, events } from '@mapbox/mapbox-gl-draw/src/constants.js'; | ||
import arc from 'arc'; | ||
import { distance as distance$1, destinationPoint as destinationPoint$1, midpoint, initialBearing } from 'geodesy-fn/src/spherical.js'; | ||
import { distance as distance$1, destinationPoint as destinationPoint$1, midpoint, initialBearing } from 'geodesy-fn'; | ||
import * as CommonSelectors from '@mapbox/mapbox-gl-draw/src/lib/common_selectors.js'; | ||
@@ -8,0 +8,0 @@ import doubleClickZoom from '@mapbox/mapbox-gl-draw/src/lib/double_click_zoom.js'; |
@@ -499,8 +499,2 @@ (function (global, factory) { | ||
const DEFAULT_RADIUS$1 = 6371e3; | ||
/** | ||
* @param {GeoJSON.Position} position1 | ||
* @param {GeoJSON.Position} position2 | ||
* @returns {boolean} | ||
*/ | ||
function equals(position1, position2) { | ||
@@ -511,23 +505,8 @@ if (Math.abs(position1[0] - position2[0]) > Number.EPSILON) return false; | ||
} | ||
/** | ||
* @param {number} value | ||
* @returns {number} | ||
*/ | ||
function toRadians(value) { | ||
return value / 180 * Math.PI; | ||
} | ||
/** | ||
* @param {number} value | ||
* @returns {number} | ||
*/ | ||
function toDegrees(value) { | ||
return value / Math.PI * 180; | ||
} | ||
/** | ||
* @param {number} value | ||
* @returns {number} | ||
*/ | ||
function wrap360(value) { | ||
@@ -558,3 +537,2 @@ return (value + 360) % 360; | ||
// see mathforum.org/library/drmath/view/51879.html for derivation | ||
const R = radius; | ||
@@ -572,3 +550,2 @@ const φ1 = toRadians(start[1]), | ||
} | ||
/** | ||
@@ -588,6 +565,4 @@ * Returns the initial bearing from start point to destination point. | ||
if (equals(start, destination)) return NaN; // coincident points | ||
// tanθ = sinΔλ⋅cosφ2 / cosφ1⋅sinφ2 − sinφ1⋅cosφ2⋅cosΔλ | ||
// see mathforum.org/library/drmath/view/55417.html for derivation | ||
const φ1 = toRadians(start[1]); | ||
@@ -602,3 +577,2 @@ const φ2 = toRadians(destination[1]); | ||
} | ||
/** | ||
@@ -620,3 +594,2 @@ * Returns the midpoint between start point and destination point. | ||
// midpoint is sum of vectors to two points: mathforum.org/library/drmath/view/51822.html | ||
const φ1 = toRadians(start[1]); | ||
@@ -626,3 +599,2 @@ const λ1 = toRadians(start[0]); | ||
const Δλ = toRadians(destination[0] - start[0]); | ||
// get cartesian coordinates for the two points | ||
@@ -639,3 +611,2 @@ const A = { | ||
}; | ||
// vector to midpoint is sum of vectors to two points (no need to normalise) | ||
@@ -653,3 +624,2 @@ const C = { | ||
} | ||
/** | ||
@@ -674,3 +644,2 @@ * Returns the destination point from start point having travelled the given distance on the | ||
// see mathforum.org/library/drmath/view/52049.html for derivation | ||
const δ = distance / radius; // angular distance in radians | ||
@@ -677,0 +646,0 @@ const θ = toRadians(bearing); |
@@ -9,6 +9,2 @@ export default { | ||
], | ||
reporters: [ | ||
'default', | ||
'jest-simple-summary' | ||
], | ||
collectCoverage: true, | ||
@@ -15,0 +11,0 @@ collectCoverageFrom: [ |
{ | ||
"name": "mapbox-gl-draw-geodesic", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "Geodesic plugin for Mapbox GL Draw", | ||
@@ -33,4 +33,4 @@ "keywords": [ | ||
"arc": "^0.1.4", | ||
"geodesy-fn": "^1.0.1", | ||
"hat": "0.0.3" | ||
"geodesy-fn": "^1.1.0", | ||
"hat": "^0.0.3" | ||
}, | ||
@@ -43,10 +43,9 @@ "devDependencies": { | ||
"@mapbox/mapbox-gl-draw": "1.3.0", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-commonjs": "^25.0.4", | ||
"@rollup/plugin-node-resolve": "^15.2.1", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.5", | ||
"@rollup/plugin-node-resolve": "^15.2.2", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"jest-simple-summary": "^1.0.2", | ||
"rimraf": "^5.0.5", | ||
@@ -53,0 +52,0 @@ "rollup": "^3.29.4", |
@@ -32,3 +32,3 @@ # mapbox-gl-draw-geodesic | ||
``` | ||
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.2.3/dist/mapbox-gl-draw-geodesic.umd.min.js"></script> | ||
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.2.4/dist/mapbox-gl-draw-geodesic.umd.min.js"></script> | ||
``` | ||
@@ -35,0 +35,0 @@ |
@@ -24,7 +24,2 @@ import pkg from './package.json' assert { type: 'json' }; | ||
...Object.keys(pkg.dependencies), | ||
'@mapbox/mapbox-gl-draw/src/constants.js', | ||
'@mapbox/mapbox-gl-draw/src/lib/common_selectors.js', | ||
'@mapbox/mapbox-gl-draw/src/lib/double_click_zoom.js', | ||
'@mapbox/mapbox-gl-draw/src/lib/create_vertex.js', | ||
'geodesy-fn/src/spherical.js', | ||
] : []), | ||
@@ -35,3 +30,3 @@ 'fs', | ||
plugins: [ | ||
...(options.resolve ? [resolve()] : []), | ||
...(options.resolve ? [resolve()] : [resolve({ resolveOnly: [/^@mapbox\/mapbox-gl-draw\/src\/.*/] })]), | ||
commonjs(), | ||
@@ -38,0 +33,0 @@ babel({ babelHelpers: 'runtime' }), |
@@ -1,2 +0,2 @@ | ||
import { distance as geodesyDistance, destinationPoint as geodesyDestinationPoint } from 'geodesy-fn/src/spherical.js'; | ||
import { distance as geodesyDistance, destinationPoint as geodesyDestinationPoint } from 'geodesy-fn'; | ||
@@ -14,2 +14,2 @@ // radius used by mapbox-gl, see https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/lng_lat.js#L11 | ||
export { initialBearing, midpoint } from 'geodesy-fn/src/spherical.js'; | ||
export { initialBearing, midpoint } from 'geodesy-fn'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15
1105897
3218
Updatedgeodesy-fn@^1.1.0
Updatedhat@^0.0.3