mapshaper 0.6.96 → 0.6.97
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 +16 -1
- package/package.json +1 -1
- package/www/mapshaper-gui.js +48 -7
- package/www/mapshaper.js +16 -1
package/mapshaper.js
CHANGED
|
@@ -20455,8 +20455,23 @@ ${svg}
|
|
|
20455
20455
|
return layerObj;
|
|
20456
20456
|
}
|
|
20457
20457
|
|
|
20458
|
+
// Prevent unstyled rectangle layers from displaying with the SVG default
|
|
20459
|
+
// solid black fill.
|
|
20460
|
+
// lyr: a layer, assumed to contain a single rectangular polygon
|
|
20461
|
+
function adjustRectangleStyle(lyr) {
|
|
20462
|
+
var data = getLayerDataTable(lyr);
|
|
20463
|
+
var d = data.getRecords()[0];
|
|
20464
|
+
if (!d.fill && !d.stroke) {
|
|
20465
|
+
d.fill = "none";
|
|
20466
|
+
}
|
|
20467
|
+
}
|
|
20468
|
+
|
|
20458
20469
|
function exportLayerForSVG(lyr, dataset, opts) {
|
|
20459
20470
|
var layerObj = getEmptyLayerForSVG(lyr, opts);
|
|
20471
|
+
if (layerIsRectangle(lyr, dataset.arcs)) {
|
|
20472
|
+
lyr = copyLayer(lyr);
|
|
20473
|
+
adjustRectangleStyle(lyr);
|
|
20474
|
+
}
|
|
20460
20475
|
layerObj.children = exportSymbolsForSVG(lyr, dataset, opts);
|
|
20461
20476
|
return layerObj;
|
|
20462
20477
|
}
|
|
@@ -45672,7 +45687,7 @@ ${svg}
|
|
|
45672
45687
|
});
|
|
45673
45688
|
}
|
|
45674
45689
|
|
|
45675
|
-
var version = "0.6.
|
|
45690
|
+
var version = "0.6.97";
|
|
45676
45691
|
|
|
45677
45692
|
// Parse command line args into commands and run them
|
|
45678
45693
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -1089,6 +1089,21 @@
|
|
|
1089
1089
|
return _el;
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
+
async function showPrompt(msg, title) {
|
|
1093
|
+
var popup = showPopupAlert(msg, title);
|
|
1094
|
+
return new Promise(function(resolve) {
|
|
1095
|
+
popup.onCancel(function() {
|
|
1096
|
+
resolve(false);
|
|
1097
|
+
});
|
|
1098
|
+
popup.button('Yes', function() {
|
|
1099
|
+
resolve(true);
|
|
1100
|
+
});
|
|
1101
|
+
popup.button('No', function() {
|
|
1102
|
+
resolve(false);
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1092
1107
|
function showPopupAlert(msg, title, optsArg) {
|
|
1093
1108
|
var opts = optsArg || {};
|
|
1094
1109
|
var self = {}, html = '';
|
|
@@ -1764,6 +1779,17 @@
|
|
|
1764
1779
|
gui.model.updated({select: true});
|
|
1765
1780
|
}
|
|
1766
1781
|
|
|
1782
|
+
async function considerReprojecting(gui, dataset, opts) {
|
|
1783
|
+
var mapCRS = gui.map.getActiveLayerCRS();
|
|
1784
|
+
var dataCRS = internal.getDatasetCRS(dataset);
|
|
1785
|
+
if (!dataCRS || !mapCRS || internal.crsAreEqual(mapCRS, dataCRS)) return;
|
|
1786
|
+
var msg = `The input file ${dataset?.info?.input_files[0] || ''} has a different projection from the current selected layer. Would you like to reproject it to match?`;
|
|
1787
|
+
var reproject = await showPrompt(msg, 'Reproject file?');
|
|
1788
|
+
if (reproject) {
|
|
1789
|
+
internal.projectDataset(dataset, dataCRS, mapCRS, {densify: true});
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1767
1793
|
// @cb function(<FileList>)
|
|
1768
1794
|
function DropControl(gui, el, cb) {
|
|
1769
1795
|
var area = El(el);
|
|
@@ -1921,7 +1947,7 @@
|
|
|
1921
1947
|
try {
|
|
1922
1948
|
if (files.length > 0) {
|
|
1923
1949
|
queuedFiles = [];
|
|
1924
|
-
await importFiles(files);
|
|
1950
|
+
await importFiles(files, readImportOpts());
|
|
1925
1951
|
}
|
|
1926
1952
|
} catch(e) {
|
|
1927
1953
|
console.log(e);
|
|
@@ -2058,8 +2084,7 @@
|
|
|
2058
2084
|
return expanded;
|
|
2059
2085
|
}
|
|
2060
2086
|
|
|
2061
|
-
async function importFiles(fileData) {
|
|
2062
|
-
var importOpts = readImportOpts();
|
|
2087
|
+
async function importFiles(fileData, importOpts) {
|
|
2063
2088
|
var groups = groupFilesForImport(fileData, importOpts);
|
|
2064
2089
|
var optStr = GUI.formatCommandOptions(importOpts);
|
|
2065
2090
|
fileData = null;
|
|
@@ -2070,21 +2095,28 @@
|
|
|
2070
2095
|
}
|
|
2071
2096
|
if (group[internal.PACKAGE_EXT]) {
|
|
2072
2097
|
await importSessionData(group[internal.PACKAGE_EXT].content, gui);
|
|
2073
|
-
} else if (importDataset(group, importOpts)) {
|
|
2098
|
+
} else if (await importDataset(group, importOpts)) {
|
|
2074
2099
|
importCount++;
|
|
2075
2100
|
gui.session.fileImported(group.filename, optStr);
|
|
2076
2101
|
}
|
|
2077
2102
|
}
|
|
2078
2103
|
}
|
|
2079
2104
|
|
|
2080
|
-
function importDataset(group, importOpts) {
|
|
2105
|
+
async function importDataset(group, importOpts) {
|
|
2081
2106
|
var dataset = internal.importContent(group, importOpts);
|
|
2082
2107
|
if (datasetIsEmpty(dataset)) return false;
|
|
2083
2108
|
if (group.layername) {
|
|
2084
2109
|
dataset.layers.forEach(lyr => lyr.name = group.layername);
|
|
2085
2110
|
}
|
|
2111
|
+
// TODO: add popup here
|
|
2086
2112
|
// save import options for use by repair control, etc.
|
|
2087
2113
|
dataset.info.import_options = importOpts;
|
|
2114
|
+
try {
|
|
2115
|
+
await considerReprojecting(gui, dataset, importOpts);
|
|
2116
|
+
} catch(e) {
|
|
2117
|
+
gui.alert(e.message, 'Projection error');
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2088
2120
|
model.addDataset(dataset);
|
|
2089
2121
|
return true;
|
|
2090
2122
|
}
|
|
@@ -10192,7 +10224,9 @@
|
|
|
10192
10224
|
function updateTextNode(node, d) {
|
|
10193
10225
|
var a = d['text-anchor'];
|
|
10194
10226
|
if (a) node.setAttribute('text-anchor', a);
|
|
10195
|
-
|
|
10227
|
+
// dx data property is applied to svg x property
|
|
10228
|
+
// setMultilineAttribute(node, 'dx', d.dx || 0);
|
|
10229
|
+
setMultilineAttribute(node, 'x', d.dx || 0);
|
|
10196
10230
|
node.setAttribute('y', d.dy || 0);
|
|
10197
10231
|
}
|
|
10198
10232
|
|
|
@@ -12487,6 +12521,13 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12487
12521
|
if (_activeLyr.gui.dynamic_crs) {
|
|
12488
12522
|
return _activeLyr.gui.dynamic_crs;
|
|
12489
12523
|
}
|
|
12524
|
+
return this.getActiveLayerCRS();
|
|
12525
|
+
};
|
|
12526
|
+
|
|
12527
|
+
this.getActiveLayerCRS = function() {
|
|
12528
|
+
if (!_activeLyr || !_activeLyr.gui.geographic) {
|
|
12529
|
+
return null;
|
|
12530
|
+
}
|
|
12490
12531
|
var info = getDatasetCrsInfo(_activeLyr.gui.source.dataset);
|
|
12491
12532
|
return info.crs || null;
|
|
12492
12533
|
};
|
|
@@ -12982,7 +13023,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12982
13023
|
addCoords(e.lonlat_coordinates);
|
|
12983
13024
|
}
|
|
12984
13025
|
if (e.projected_coordinates) {
|
|
12985
|
-
addMenuLabel('
|
|
13026
|
+
addMenuLabel('x, y');
|
|
12986
13027
|
addCoords(e.projected_coordinates);
|
|
12987
13028
|
}
|
|
12988
13029
|
|
package/www/mapshaper.js
CHANGED
|
@@ -20455,8 +20455,23 @@ ${svg}
|
|
|
20455
20455
|
return layerObj;
|
|
20456
20456
|
}
|
|
20457
20457
|
|
|
20458
|
+
// Prevent unstyled rectangle layers from displaying with the SVG default
|
|
20459
|
+
// solid black fill.
|
|
20460
|
+
// lyr: a layer, assumed to contain a single rectangular polygon
|
|
20461
|
+
function adjustRectangleStyle(lyr) {
|
|
20462
|
+
var data = getLayerDataTable(lyr);
|
|
20463
|
+
var d = data.getRecords()[0];
|
|
20464
|
+
if (!d.fill && !d.stroke) {
|
|
20465
|
+
d.fill = "none";
|
|
20466
|
+
}
|
|
20467
|
+
}
|
|
20468
|
+
|
|
20458
20469
|
function exportLayerForSVG(lyr, dataset, opts) {
|
|
20459
20470
|
var layerObj = getEmptyLayerForSVG(lyr, opts);
|
|
20471
|
+
if (layerIsRectangle(lyr, dataset.arcs)) {
|
|
20472
|
+
lyr = copyLayer(lyr);
|
|
20473
|
+
adjustRectangleStyle(lyr);
|
|
20474
|
+
}
|
|
20460
20475
|
layerObj.children = exportSymbolsForSVG(lyr, dataset, opts);
|
|
20461
20476
|
return layerObj;
|
|
20462
20477
|
}
|
|
@@ -45672,7 +45687,7 @@ ${svg}
|
|
|
45672
45687
|
});
|
|
45673
45688
|
}
|
|
45674
45689
|
|
|
45675
|
-
var version = "0.6.
|
|
45690
|
+
var version = "0.6.97";
|
|
45676
45691
|
|
|
45677
45692
|
// Parse command line args into commands and run them
|
|
45678
45693
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|