Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-gl-draw-geodesic

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl-draw-geodesic - npm Package Compare versions

Comparing version 2.2.4 to 2.2.5

4

CHANGELOG.md
# Changelog
## 2.2.5
- bundle mapbox-gl-draw 1.3.0 sources - fix resolveOnly
## 2.2.4

@@ -4,0 +8,0 @@

161

dist/mapbox-gl-draw-geodesic.cjs.js
'use strict';
var constants_js = require('@mapbox/mapbox-gl-draw/src/constants.js');
var createVertex = require('@mapbox/mapbox-gl-draw/src/lib/create_vertex.js');
var hat = require('hat');
var arc = require('arc');
var geodesyFn = require('geodesy-fn');
var CommonSelectors = require('@mapbox/mapbox-gl-draw/src/lib/common_selectors.js');
var doubleClickZoom = require('@mapbox/mapbox-gl-draw/src/lib/double_click_zoom.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
const cursors = {
ADD: 'add',
MOVE: 'move',
DRAG: 'drag',
POINTER: 'pointer',
NONE: 'none'
};
const geojsonTypes = {
FEATURE: 'Feature',
POLYGON: 'Polygon',
LINE_STRING: 'LineString',
POINT: 'Point',
FEATURE_COLLECTION: 'FeatureCollection',
MULTI_PREFIX: 'Multi',
MULTI_POINT: 'MultiPoint',
MULTI_LINE_STRING: 'MultiLineString',
MULTI_POLYGON: 'MultiPolygon'
};
const modes$1 = {
DRAW_LINE_STRING: 'draw_line_string',
DRAW_POLYGON: 'draw_polygon',
DRAW_POINT: 'draw_point',
SIMPLE_SELECT: 'simple_select',
DIRECT_SELECT: 'direct_select',
STATIC: 'static'
};
const events = {
CREATE: 'draw.create',
DELETE: 'draw.delete',
UPDATE: 'draw.update',
SELECTION_CHANGE: 'draw.selectionchange',
MODE_CHANGE: 'draw.modechange',
ACTIONABLE: 'draw.actionable',
RENDER: 'draw.render',
COMBINE_FEATURES: 'draw.combine',
UNCOMBINE_FEATURES: 'draw.uncombine'
};
const meta = {
FEATURE: 'feature',
MIDPOINT: 'midpoint',
VERTEX: 'vertex'
};
const activeStates = {
ACTIVE: 'true',
INACTIVE: 'false'
};
var CommonSelectors__namespace = /*#__PURE__*/_interopNamespaceDefault(CommonSelectors);
const modes = {
...constants_js.modes,
...modes$1,
DRAW_CIRCLE: 'draw_circle'

@@ -39,2 +63,29 @@ };

/**
* Returns GeoJSON for a Point representing the
* vertex of another feature.
*
* @param {string} parentId
* @param {Array<number>} coordinates
* @param {string} path - Dot-separated numbers indicating exactly
* where the point exists within its parent feature's coordinates.
* @param {boolean} selected
* @return {GeoJSON} Point
*/
function createVertex (parentId, coordinates, path, selected) {
return {
type: geojsonTypes.FEATURE,
properties: {
meta: meta.VERTEX,
parent: parentId,
coord_path: path,
active: selected ? activeStates.ACTIVE : activeStates.INACTIVE
},
geometry: {
type: geojsonTypes.POINT,
coordinates
}
};
}
function createCircle(center, radius) {

@@ -47,3 +98,3 @@ let properties$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

id: hat(),
type: constants_js.geojsonTypes.FEATURE,
type: geojsonTypes.FEATURE,
properties: {

@@ -55,3 +106,3 @@ [properties.CIRCLE_RADIUS]: radius,

geometry: {
type: constants_js.geojsonTypes.POLYGON,
type: geojsonTypes.POLYGON,
coordinates: [[center, center, center, center]] // valid polygon needs 3 vertices

@@ -63,3 +114,3 @@ }

function isCircleByTypeAndProperties(type, properties$1) {
return type === constants_js.geojsonTypes.POLYGON && typeof properties$1[properties.CIRCLE_RADIUS] === 'number' && properties$1[properties.CIRCLE_RADIUS] > 0;
return type === geojsonTypes.POLYGON && typeof properties$1[properties.CIRCLE_RADIUS] === 'number' && properties$1[properties.CIRCLE_RADIUS] > 0;
}

@@ -122,3 +173,3 @@ function isCircle(geojson) {

const geodesicCoordinates = geodesicSegments.map(geodesicSegment => {
if (geodesicSegment.geometry.type === constants_js.geojsonTypes.MULTI_LINE_STRING) {
if (geodesicSegment.geometry.type === geojsonTypes.MULTI_LINE_STRING) {
const prevWorldOffset = worldOffset;

@@ -169,3 +220,3 @@ const nextWorldOffset = worldOffset + (geodesicSegment.geometry.coordinates[0][0][0] > geodesicSegment.geometry.coordinates[1][0][0] ? 1 : -1);

function getMidpointEndCoordPath(feature, path) {
if (feature.type === constants_js.geojsonTypes.POLYGON || feature.type === constants_js.geojsonTypes.MULTI_POLYGON) {
if (feature.type === geojsonTypes.POLYGON || feature.type === geojsonTypes.MULTI_POLYGON) {
try {

@@ -191,6 +242,6 @@ feature.getCoordinate(path);

const feature = options.ctx.store.get(featureId);
if (type === constants_js.geojsonTypes.POINT) {
if (type === geojsonTypes.POINT) {
if (isCircleFeature(feature)) {
return []; // hide circle points, they are displayed in processCircle instead
} else if (properties$1.meta === constants_js.meta.MIDPOINT) {
} else if (properties$1.meta === meta.MIDPOINT) {
return processMidpoint(); // calculate geodesic midpoint

@@ -200,5 +251,5 @@ } else {

}
} else if (type === constants_js.geojsonTypes.LINE_STRING) {
} else if (type === geojsonTypes.LINE_STRING) {
return processLine(); // calculate geodesic line
} else if (type === constants_js.geojsonTypes.POLYGON) {
} else if (type === geojsonTypes.POLYGON) {
if (isCircleFeature(feature)) {

@@ -209,3 +260,3 @@ return processCircle(); // calculate geodesic circle

}
} else /* istanbul ignore else */if (type.indexOf(constants_js.geojsonTypes.MULTI_PREFIX) === 0) {
} else /* istanbul ignore else */if (type.indexOf(geojsonTypes.MULTI_PREFIX) === 0) {
return processMultiGeometry();

@@ -279,3 +330,3 @@ }

// circle handles
if (properties$1.active === constants_js.activeStates.ACTIVE) {
if (properties$1.active === activeStates.ACTIVE) {
const handle = destinationPoint(center, radius, handleBearing);

@@ -292,6 +343,6 @@ const points = [center, handle];

function processMultiGeometry() {
const subType = type.replace(constants_js.geojsonTypes.MULTI_PREFIX, '');
const subType = type.replace(geojsonTypes.MULTI_PREFIX, '');
const geodesicFeatures = coordinates.map(subCoordinates => {
const subFeature = {
type: constants_js.geojsonTypes.FEATURE,
type: geojsonTypes.FEATURE,
properties: properties$1,

@@ -351,2 +402,28 @@ geometry: {

function isEscapeKey(e) {
return e.keyCode === 27;
}
function isEnterKey(e) {
return e.keyCode === 13;
}
var doubleClickZoom = {
enable(ctx) {
setTimeout(() => {
// First check we've got a map and some context.
if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return;
// Now check initial state wasn't false (we leave it disabled if so)
if (!ctx._ctx.store.getInitialConfigValue('doubleClickZoom')) return;
ctx.map.doubleClickZoom.enable();
}, 0);
},
disable(ctx) {
setTimeout(() => {
if (!ctx.map || !ctx.map.doubleClickZoom) return;
// Always disable here, as it's necessary in some cases.
ctx.map.doubleClickZoom.disable();
}, 0);
}
};
const dragPan = {

@@ -377,3 +454,3 @@ enable(ctx) {

this.updateUIClasses({
mouse: constants_js.cursors.ADD
mouse: cursors.ADD
});

@@ -402,3 +479,3 @@ this.setActionableState(); // default actionable state is false for all actions

DrawCircleGeodesic.onMouseUp = DrawCircleGeodesic.onTouchEnd = function (state, e) {
this.map.fire(constants_js.events.CREATE, {
this.map.fire(events.CREATE, {
features: [state.circle.toGeoJSON()]

@@ -411,3 +488,3 @@ });

DrawCircleGeodesic.onKeyUp = function (state, e) {
if (CommonSelectors__namespace.isEscapeKey(e)) {
if (isEscapeKey(e)) {
if (state.circle) {

@@ -419,3 +496,3 @@ this.deleteFeature([state.circle.id], {

this.changeMode(modes.SIMPLE_SELECT);
} else if (CommonSelectors__namespace.isEnterKey(e)) {
} else if (isEnterKey(e)) {
this.changeMode(modes.SIMPLE_SELECT, {

@@ -428,3 +505,3 @@ featureIds: [state.circle.id]

this.updateUIClasses({
mouse: constants_js.cursors.NONE
mouse: cursors.NONE
});

@@ -438,3 +515,3 @@ doubleClickZoom.enable(this);

const isActivePolygon = geojson.properties.id === state.circle.id;
geojson.properties.active = isActivePolygon ? constants_js.activeStates.ACTIVE : constants_js.activeStates.INACTIVE;
geojson.properties.active = isActivePolygon ? activeStates.ACTIVE : activeStates.INACTIVE;
}

@@ -441,0 +518,0 @@ const displayGeodesic = geojson => {

@@ -1,9 +0,52 @@

import { modes as modes$1, geojsonTypes, meta, activeStates, cursors, events } from '@mapbox/mapbox-gl-draw/src/constants.js';
import createVertex from '@mapbox/mapbox-gl-draw/src/lib/create_vertex.js';
import hat from 'hat';
import arc from 'arc';
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';
import doubleClickZoom from '@mapbox/mapbox-gl-draw/src/lib/double_click_zoom.js';
const cursors = {
ADD: 'add',
MOVE: 'move',
DRAG: 'drag',
POINTER: 'pointer',
NONE: 'none'
};
const geojsonTypes = {
FEATURE: 'Feature',
POLYGON: 'Polygon',
LINE_STRING: 'LineString',
POINT: 'Point',
FEATURE_COLLECTION: 'FeatureCollection',
MULTI_PREFIX: 'Multi',
MULTI_POINT: 'MultiPoint',
MULTI_LINE_STRING: 'MultiLineString',
MULTI_POLYGON: 'MultiPolygon'
};
const modes$1 = {
DRAW_LINE_STRING: 'draw_line_string',
DRAW_POLYGON: 'draw_polygon',
DRAW_POINT: 'draw_point',
SIMPLE_SELECT: 'simple_select',
DIRECT_SELECT: 'direct_select',
STATIC: 'static'
};
const events = {
CREATE: 'draw.create',
DELETE: 'draw.delete',
UPDATE: 'draw.update',
SELECTION_CHANGE: 'draw.selectionchange',
MODE_CHANGE: 'draw.modechange',
ACTIONABLE: 'draw.actionable',
RENDER: 'draw.render',
COMBINE_FEATURES: 'draw.combine',
UNCOMBINE_FEATURES: 'draw.uncombine'
};
const meta = {
FEATURE: 'feature',
MIDPOINT: 'midpoint',
VERTEX: 'vertex'
};
const activeStates = {
ACTIVE: 'true',
INACTIVE: 'false'
};
const modes = {

@@ -18,2 +61,29 @@ ...modes$1,

/**
* Returns GeoJSON for a Point representing the
* vertex of another feature.
*
* @param {string} parentId
* @param {Array<number>} coordinates
* @param {string} path - Dot-separated numbers indicating exactly
* where the point exists within its parent feature's coordinates.
* @param {boolean} selected
* @return {GeoJSON} Point
*/
function createVertex (parentId, coordinates, path, selected) {
return {
type: geojsonTypes.FEATURE,
properties: {
meta: meta.VERTEX,
parent: parentId,
coord_path: path,
active: selected ? activeStates.ACTIVE : activeStates.INACTIVE
},
geometry: {
type: geojsonTypes.POINT,
coordinates
}
};
}
function createCircle(center, radius) {

@@ -320,2 +390,28 @@ let properties$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

function isEscapeKey(e) {
return e.keyCode === 27;
}
function isEnterKey(e) {
return e.keyCode === 13;
}
var doubleClickZoom = {
enable(ctx) {
setTimeout(() => {
// First check we've got a map and some context.
if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return;
// Now check initial state wasn't false (we leave it disabled if so)
if (!ctx._ctx.store.getInitialConfigValue('doubleClickZoom')) return;
ctx.map.doubleClickZoom.enable();
}, 0);
},
disable(ctx) {
setTimeout(() => {
if (!ctx.map || !ctx.map.doubleClickZoom) return;
// Always disable here, as it's necessary in some cases.
ctx.map.doubleClickZoom.disable();
}, 0);
}
};
const dragPan = {

@@ -378,3 +474,3 @@ enable(ctx) {

DrawCircleGeodesic.onKeyUp = function (state, e) {
if (CommonSelectors.isEscapeKey(e)) {
if (isEscapeKey(e)) {
if (state.circle) {

@@ -386,3 +482,3 @@ this.deleteFeature([state.circle.id], {

this.changeMode(modes.SIMPLE_SELECT);
} else if (CommonSelectors.isEnterKey(e)) {
} else if (isEnterKey(e)) {
this.changeMode(modes.SIMPLE_SELECT, {

@@ -389,0 +485,0 @@ featureIds: [state.circle.id]

{
"name": "mapbox-gl-draw-geodesic",
"version": "2.2.4",
"version": "2.2.5",
"description": "Geodesic plugin for Mapbox GL Draw",

@@ -5,0 +5,0 @@ "keywords": [

@@ -32,3 +32,3 @@ # mapbox-gl-draw-geodesic

```
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.2.4/dist/mapbox-gl-draw-geodesic.umd.min.js"></script>
<script src="https://unpkg.com/mapbox-gl-draw-geodesic@2.2.5/dist/mapbox-gl-draw-geodesic.umd.min.js"></script>
```

@@ -35,0 +35,0 @@

@@ -25,7 +25,5 @@ import pkg from './package.json' assert { type: 'json' };

] : []),
'fs',
'path',
],
plugins: [
...(options.resolve ? [resolve()] : [resolve({ resolveOnly: [/^@mapbox\/mapbox-gl-draw\/src\/.*/] })]),
...(options.resolve ? [resolve()] : [resolve({ resolveOnly: ['@mapbox/mapbox-gl-draw'] })]),
commonjs(),

@@ -32,0 +30,0 @@ babel({ babelHelpers: 'runtime' }),

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc