mapshaper 0.6.84 → 0.6.86
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/mapshaper.js +50 -12
- package/package.json +1 -1
- package/www/images/thumb-satellite.jpg +0 -0
- package/www/mapshaper-gui.js +7 -5
- package/www/mapshaper.js +50 -12
- package/www/page.css +2 -2
package/mapshaper.js
CHANGED
|
@@ -25429,8 +25429,11 @@ ${svg}
|
|
|
25429
25429
|
.option('no-replace', noReplaceOpt);
|
|
25430
25430
|
|
|
25431
25431
|
parser.command('rectangles')
|
|
25432
|
-
.describe('create a rectangle
|
|
25432
|
+
.describe('create a rectangle for each feature in a layer')
|
|
25433
25433
|
.option('offset', offsetOpt)
|
|
25434
|
+
.option('bbox', {
|
|
25435
|
+
describe: 'Use an expression to generate a rectangle for each feature'
|
|
25436
|
+
})
|
|
25434
25437
|
.option('aspect-ratio', aspectRatioOpt)
|
|
25435
25438
|
.option('name', nameOpt)
|
|
25436
25439
|
.option('target', targetOpt)
|
|
@@ -38806,18 +38809,20 @@ ${svg}
|
|
|
38806
38809
|
|
|
38807
38810
|
// Create rectangles around each feature in a layer
|
|
38808
38811
|
cmd.rectangles = function(targetLyr, targetDataset, opts) {
|
|
38809
|
-
if (!layerHasGeometry(targetLyr)) {
|
|
38810
|
-
stop("Layer is missing geometric shapes");
|
|
38811
|
-
}
|
|
38812
38812
|
var crsInfo = getDatasetCrsInfo(targetDataset);
|
|
38813
38813
|
var records = targetLyr.data ? targetLyr.data.getRecords() : null;
|
|
38814
|
-
var geometries
|
|
38815
|
-
|
|
38816
|
-
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38820
|
-
|
|
38814
|
+
var geometries;
|
|
38815
|
+
|
|
38816
|
+
if (opts.bbox) {
|
|
38817
|
+
geometries = bboxExpressionToGeometries(opts.bbox, targetLyr, targetDataset);
|
|
38818
|
+
|
|
38819
|
+
} else {
|
|
38820
|
+
if (!layerHasGeometry(targetLyr)) {
|
|
38821
|
+
stop("Layer is missing geometric shapes");
|
|
38822
|
+
}
|
|
38823
|
+
geometries = shapesToBoxGeometries(targetLyr, targetDataset, opts);
|
|
38824
|
+
}
|
|
38825
|
+
|
|
38821
38826
|
var geojson = {
|
|
38822
38827
|
type: 'FeatureCollection',
|
|
38823
38828
|
features: geometries.map(function(geom, i) {
|
|
@@ -38839,6 +38844,39 @@ ${svg}
|
|
|
38839
38844
|
return outputLayers;
|
|
38840
38845
|
};
|
|
38841
38846
|
|
|
38847
|
+
function shapesToBoxGeometries(lyr, dataset, opts) {
|
|
38848
|
+
var crsInfo = getDatasetCrsInfo(dataset);
|
|
38849
|
+
return lyr.shapes.map(function(shp) {
|
|
38850
|
+
var bounds = lyr.geometry_type == 'point' ?
|
|
38851
|
+
getPointFeatureBounds(shp) : dataset.arcs.getMultiShapeBounds(shp);
|
|
38852
|
+
bounds = applyRectangleOptions(bounds, crsInfo.crs, opts);
|
|
38853
|
+
if (!bounds) return null;
|
|
38854
|
+
return bboxToPolygon(bounds.toArray(), opts);
|
|
38855
|
+
});
|
|
38856
|
+
}
|
|
38857
|
+
|
|
38858
|
+
function bboxExpressionToGeometries(exp, lyr, dataset, opts) {
|
|
38859
|
+
var compiled = compileFeatureExpression(exp, lyr, dataset.arcs, {});
|
|
38860
|
+
var n = getFeatureCount(lyr);
|
|
38861
|
+
var result;
|
|
38862
|
+
var geometries = [];
|
|
38863
|
+
for (var i=0; i<n; i++) {
|
|
38864
|
+
result = compiled(i);
|
|
38865
|
+
if (!looksLikeBbox(result)) {
|
|
38866
|
+
stop('Invalid bbox value (expected a GeoJSON-type bbox):', result);
|
|
38867
|
+
}
|
|
38868
|
+
geometries.push(bboxToPolygon(result));
|
|
38869
|
+
}
|
|
38870
|
+
return geometries;
|
|
38871
|
+
}
|
|
38872
|
+
|
|
38873
|
+
function looksLikeBbox(o) {
|
|
38874
|
+
if (!o || o.length != 4) return false;
|
|
38875
|
+
if (o.some(isNaN)) return false;
|
|
38876
|
+
if (o[0] <= o[2] == false || o[1] <= o[3] == false) return false;
|
|
38877
|
+
return true;
|
|
38878
|
+
}
|
|
38879
|
+
|
|
38842
38880
|
// Create rectangles around one or more target layers
|
|
38843
38881
|
//
|
|
38844
38882
|
cmd.rectangle2 = function(target, opts) {
|
|
@@ -45536,7 +45574,7 @@ ${svg}
|
|
|
45536
45574
|
});
|
|
45537
45575
|
}
|
|
45538
45576
|
|
|
45539
|
-
var version = "0.6.
|
|
45577
|
+
var version = "0.6.86";
|
|
45540
45578
|
|
|
45541
45579
|
// Parse command line args into commands and run them
|
|
45542
45580
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
|
Binary file
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -2428,7 +2428,7 @@
|
|
|
2428
2428
|
function error() {
|
|
2429
2429
|
var msg = GUI.formatMessageArgs(arguments);
|
|
2430
2430
|
console.error(msg);
|
|
2431
|
-
gui.alert('An
|
|
2431
|
+
gui.alert('An unknown error occured');
|
|
2432
2432
|
throw new Error(msg);
|
|
2433
2433
|
}
|
|
2434
2434
|
|
|
@@ -8817,7 +8817,9 @@
|
|
|
8817
8817
|
}
|
|
8818
8818
|
});
|
|
8819
8819
|
element.addEventListener('contextmenu', function(e) {
|
|
8820
|
-
|
|
8820
|
+
if (!e.ctrlKey) {
|
|
8821
|
+
_self.dispatchEvent('contextmenu', procMouseEvent(e));
|
|
8822
|
+
}
|
|
8821
8823
|
});
|
|
8822
8824
|
|
|
8823
8825
|
this.enable = function() {
|
|
@@ -10404,12 +10406,12 @@
|
|
|
10404
10406
|
} else {
|
|
10405
10407
|
deleteLastVertex(target);
|
|
10406
10408
|
}
|
|
10407
|
-
if (getLastArcLength(target) < 2) {
|
|
10408
|
-
gui.undo.undo(); // remove the path
|
|
10409
|
-
}
|
|
10410
10409
|
if (e.shapes) {
|
|
10411
10410
|
replaceDrawnShapes(e.shapes);
|
|
10412
10411
|
}
|
|
10412
|
+
if (getLastArcLength(target) < 2) {
|
|
10413
|
+
gui.undo.undo(); // remove the path
|
|
10414
|
+
}
|
|
10413
10415
|
});
|
|
10414
10416
|
|
|
10415
10417
|
function turnOn() {
|
package/www/mapshaper.js
CHANGED
|
@@ -25429,8 +25429,11 @@ ${svg}
|
|
|
25429
25429
|
.option('no-replace', noReplaceOpt);
|
|
25430
25430
|
|
|
25431
25431
|
parser.command('rectangles')
|
|
25432
|
-
.describe('create a rectangle
|
|
25432
|
+
.describe('create a rectangle for each feature in a layer')
|
|
25433
25433
|
.option('offset', offsetOpt)
|
|
25434
|
+
.option('bbox', {
|
|
25435
|
+
describe: 'Use an expression to generate a rectangle for each feature'
|
|
25436
|
+
})
|
|
25434
25437
|
.option('aspect-ratio', aspectRatioOpt)
|
|
25435
25438
|
.option('name', nameOpt)
|
|
25436
25439
|
.option('target', targetOpt)
|
|
@@ -38806,18 +38809,20 @@ ${svg}
|
|
|
38806
38809
|
|
|
38807
38810
|
// Create rectangles around each feature in a layer
|
|
38808
38811
|
cmd.rectangles = function(targetLyr, targetDataset, opts) {
|
|
38809
|
-
if (!layerHasGeometry(targetLyr)) {
|
|
38810
|
-
stop("Layer is missing geometric shapes");
|
|
38811
|
-
}
|
|
38812
38812
|
var crsInfo = getDatasetCrsInfo(targetDataset);
|
|
38813
38813
|
var records = targetLyr.data ? targetLyr.data.getRecords() : null;
|
|
38814
|
-
var geometries
|
|
38815
|
-
|
|
38816
|
-
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38820
|
-
|
|
38814
|
+
var geometries;
|
|
38815
|
+
|
|
38816
|
+
if (opts.bbox) {
|
|
38817
|
+
geometries = bboxExpressionToGeometries(opts.bbox, targetLyr, targetDataset);
|
|
38818
|
+
|
|
38819
|
+
} else {
|
|
38820
|
+
if (!layerHasGeometry(targetLyr)) {
|
|
38821
|
+
stop("Layer is missing geometric shapes");
|
|
38822
|
+
}
|
|
38823
|
+
geometries = shapesToBoxGeometries(targetLyr, targetDataset, opts);
|
|
38824
|
+
}
|
|
38825
|
+
|
|
38821
38826
|
var geojson = {
|
|
38822
38827
|
type: 'FeatureCollection',
|
|
38823
38828
|
features: geometries.map(function(geom, i) {
|
|
@@ -38839,6 +38844,39 @@ ${svg}
|
|
|
38839
38844
|
return outputLayers;
|
|
38840
38845
|
};
|
|
38841
38846
|
|
|
38847
|
+
function shapesToBoxGeometries(lyr, dataset, opts) {
|
|
38848
|
+
var crsInfo = getDatasetCrsInfo(dataset);
|
|
38849
|
+
return lyr.shapes.map(function(shp) {
|
|
38850
|
+
var bounds = lyr.geometry_type == 'point' ?
|
|
38851
|
+
getPointFeatureBounds(shp) : dataset.arcs.getMultiShapeBounds(shp);
|
|
38852
|
+
bounds = applyRectangleOptions(bounds, crsInfo.crs, opts);
|
|
38853
|
+
if (!bounds) return null;
|
|
38854
|
+
return bboxToPolygon(bounds.toArray(), opts);
|
|
38855
|
+
});
|
|
38856
|
+
}
|
|
38857
|
+
|
|
38858
|
+
function bboxExpressionToGeometries(exp, lyr, dataset, opts) {
|
|
38859
|
+
var compiled = compileFeatureExpression(exp, lyr, dataset.arcs, {});
|
|
38860
|
+
var n = getFeatureCount(lyr);
|
|
38861
|
+
var result;
|
|
38862
|
+
var geometries = [];
|
|
38863
|
+
for (var i=0; i<n; i++) {
|
|
38864
|
+
result = compiled(i);
|
|
38865
|
+
if (!looksLikeBbox(result)) {
|
|
38866
|
+
stop('Invalid bbox value (expected a GeoJSON-type bbox):', result);
|
|
38867
|
+
}
|
|
38868
|
+
geometries.push(bboxToPolygon(result));
|
|
38869
|
+
}
|
|
38870
|
+
return geometries;
|
|
38871
|
+
}
|
|
38872
|
+
|
|
38873
|
+
function looksLikeBbox(o) {
|
|
38874
|
+
if (!o || o.length != 4) return false;
|
|
38875
|
+
if (o.some(isNaN)) return false;
|
|
38876
|
+
if (o[0] <= o[2] == false || o[1] <= o[3] == false) return false;
|
|
38877
|
+
return true;
|
|
38878
|
+
}
|
|
38879
|
+
|
|
38842
38880
|
// Create rectangles around one or more target layers
|
|
38843
38881
|
//
|
|
38844
38882
|
cmd.rectangle2 = function(target, opts) {
|
|
@@ -45536,7 +45574,7 @@ ${svg}
|
|
|
45536
45574
|
});
|
|
45537
45575
|
}
|
|
45538
45576
|
|
|
45539
|
-
var version = "0.6.
|
|
45577
|
+
var version = "0.6.86";
|
|
45540
45578
|
|
|
45541
45579
|
// Parse command line args into commands and run them
|
|
45542
45580
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/www/page.css
CHANGED