mapshaper 0.5.74 → 0.5.75
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/CHANGELOG.md +3 -0
- package/mapshaper.js +41 -2
- package/package.json +1 -1
- package/www/index.html +2 -2
- package/www/mapshaper-gui.js +2472 -5776
- package/www/mapshaper.js +41 -2
- package/www/page.css +1 -1
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.5.
|
|
3
|
+
var VERSION = "0.5.74";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -34176,6 +34176,32 @@ ${svg}
|
|
|
34176
34176
|
return d;
|
|
34177
34177
|
}
|
|
34178
34178
|
|
|
34179
|
+
function findNearestVertices(p, shp, arcs) {
|
|
34180
|
+
var p2 = findNearestVertex(p[0], p[1], shp, arcs);
|
|
34181
|
+
return findVertexIds(p2.x, p2.y, arcs);
|
|
34182
|
+
}
|
|
34183
|
+
|
|
34184
|
+
// p: point to snap
|
|
34185
|
+
// ids: ids of nearby vertices, possibly including an arc endpoint
|
|
34186
|
+
function snapPointToArcEndpoint(p, ids, arcs) {
|
|
34187
|
+
var p2, p3, dx, dy;
|
|
34188
|
+
ids.forEach(function(idx) {
|
|
34189
|
+
if (vertexIsArcStart(idx, arcs)) {
|
|
34190
|
+
p2 = getVertexCoords(idx + 1, arcs);
|
|
34191
|
+
} else if (vertexIsArcEnd(idx, arcs)) {
|
|
34192
|
+
p2 = getVertexCoords(idx - 1, arcs);
|
|
34193
|
+
}
|
|
34194
|
+
});
|
|
34195
|
+
if (!p2) return;
|
|
34196
|
+
dx = p2[0] - p[0];
|
|
34197
|
+
dy = p2[1] - p[1];
|
|
34198
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
34199
|
+
p[1] = p2[1]; // snap y coord
|
|
34200
|
+
} else {
|
|
34201
|
+
p[0] = p2[0];
|
|
34202
|
+
}
|
|
34203
|
+
}
|
|
34204
|
+
|
|
34179
34205
|
// Find ids of vertices with identical coordinates to x,y in an ArcCollection
|
|
34180
34206
|
// Caveat: does not exclude vertices that are not visible at the
|
|
34181
34207
|
// current level of simplification.
|
|
@@ -34238,6 +34264,18 @@ ${svg}
|
|
|
34238
34264
|
return minLen < Infinity ? {x: minX, y: minY} : null;
|
|
34239
34265
|
}
|
|
34240
34266
|
|
|
34267
|
+
var VertexUtils = /*#__PURE__*/Object.freeze({
|
|
34268
|
+
__proto__: null,
|
|
34269
|
+
findNearestVertices: findNearestVertices,
|
|
34270
|
+
snapPointToArcEndpoint: snapPointToArcEndpoint,
|
|
34271
|
+
findVertexIds: findVertexIds,
|
|
34272
|
+
getVertexCoords: getVertexCoords,
|
|
34273
|
+
vertexIsArcEnd: vertexIsArcEnd,
|
|
34274
|
+
vertexIsArcStart: vertexIsArcStart,
|
|
34275
|
+
setVertexCoords: setVertexCoords,
|
|
34276
|
+
findNearestVertex: findNearestVertex
|
|
34277
|
+
});
|
|
34278
|
+
|
|
34241
34279
|
// Returns x,y coordinates of the point that is at the midpoint of each polyline feature
|
|
34242
34280
|
// Uses 2d cartesian geometry
|
|
34243
34281
|
// TODO: optionally use spherical geometry
|
|
@@ -39097,7 +39135,8 @@ ${svg}
|
|
|
39097
39135
|
TopojsonImport,
|
|
39098
39136
|
Topology,
|
|
39099
39137
|
Units,
|
|
39100
|
-
SvgHatch
|
|
39138
|
+
SvgHatch,
|
|
39139
|
+
VertexUtils
|
|
39101
39140
|
);
|
|
39102
39141
|
|
|
39103
39142
|
// The entry point for the core mapshaper module
|
package/www/page.css
CHANGED