mapshaper 0.6.113 → 0.6.115
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 +2851 -355
- package/package.json +4 -2
- package/www/geopackage.js +4362 -0
- package/www/index.html +2 -2
- package/www/mapshaper-gui.js +81 -33
- package/www/mapshaper.js +2851 -355
- package/www/modules.js +0 -1
- package/www/sql-wasm.wasm +0 -0
package/www/index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<title>mapshaper</title>
|
|
5
|
-
<meta name="Description" content="A tool for topologically aware shape simplification. Reads and writes Shapefile, GeoJSON and
|
|
5
|
+
<meta name="Description" content="A tool for topologically aware shape simplification. Reads and writes Shapefile, GeoJSON, TopoJSON, KML, GeoPackage and FlatGeobuf formats.">
|
|
6
6
|
<meta charset="UTF-8">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
@@ -279,7 +279,7 @@ a smoother appearance.</div></div></div></div>
|
|
|
279
279
|
<span><input type="checkbox" class="advanced-import-options">with advanced options</span>
|
|
280
280
|
<div class="mini-drop-area">
|
|
281
281
|
<div class="subtitle">Drop, paste or <span class="add-btn inline-btn btn"><span class="label-text">select</span></span> files to import.</div>
|
|
282
|
-
<div class="subtitle">Shapefile, GeoJSON, TopoJSON, KML and CSV formats are supported. Files can be zipped or gzipped.</div>
|
|
282
|
+
<div class="subtitle">Shapefile, GeoJSON, TopoJSON, GeoPackage, FlatGeobuf, KML and CSV formats are supported. Files can be zipped or gzipped.</div>
|
|
283
283
|
</div>
|
|
284
284
|
</div>
|
|
285
285
|
<div class="queued-file-section">
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -462,6 +462,16 @@
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
async function loadScript(src) {
|
|
466
|
+
return new Promise((resolve, reject) => {
|
|
467
|
+
const script = document.createElement('script');
|
|
468
|
+
script.src = src;
|
|
469
|
+
script.onload = () => resolve(script);
|
|
470
|
+
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
471
|
+
document.head.appendChild(script);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
465
475
|
var tagOrIdSelectorRE = /^#?[\w-]+$/;
|
|
466
476
|
|
|
467
477
|
El.__select = function(selector, root) {
|
|
@@ -1934,6 +1944,18 @@
|
|
|
1934
1944
|
}
|
|
1935
1945
|
}
|
|
1936
1946
|
|
|
1947
|
+
var geopackagePromise = null;
|
|
1948
|
+
|
|
1949
|
+
async function loadGeopackageLib() {
|
|
1950
|
+
if (!window.modules || !window.modules['@ngageoint/geopackage']) {
|
|
1951
|
+
if (!geopackagePromise) {
|
|
1952
|
+
geopackagePromise = loadScript('geopackage.js');
|
|
1953
|
+
}
|
|
1954
|
+
await geopackagePromise;
|
|
1955
|
+
geopackagePromise = null;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1937
1959
|
// @cb function(<FileList>)
|
|
1938
1960
|
function DropControl(gui, el, cb) {
|
|
1939
1961
|
var area = El(el);
|
|
@@ -2305,7 +2327,15 @@
|
|
|
2305
2327
|
}
|
|
2306
2328
|
|
|
2307
2329
|
async function importDataset(group, importOpts) {
|
|
2308
|
-
var dataset
|
|
2330
|
+
var dataset;
|
|
2331
|
+
if (group.gpkg) {
|
|
2332
|
+
await loadGeopackageLib();
|
|
2333
|
+
}
|
|
2334
|
+
if (group.gpkg || group.fgb) {
|
|
2335
|
+
dataset = await internal.importContentAsync(group, importOpts);
|
|
2336
|
+
} else {
|
|
2337
|
+
dataset = internal.importContent(group, importOpts);
|
|
2338
|
+
}
|
|
2309
2339
|
if (datasetIsEmpty(dataset)) return false;
|
|
2310
2340
|
if (group.layername) {
|
|
2311
2341
|
dataset.layers.forEach(lyr => lyr.name = group.layername);
|
|
@@ -2492,6 +2522,8 @@
|
|
|
2492
2522
|
}
|
|
2493
2523
|
}
|
|
2494
2524
|
|
|
2525
|
+
// Group multiple files belonging to the same dataset together
|
|
2526
|
+
// (applies to Shapefiles)
|
|
2495
2527
|
function groupFilesForImport(data, importOpts) {
|
|
2496
2528
|
var names = importOpts.name ? [importOpts.name] : null;
|
|
2497
2529
|
if (initialImport && opts.name) { // name from mapshaper-gui --name option
|
|
@@ -4551,8 +4583,16 @@
|
|
|
4551
4583
|
async function exportMenuSelection(targets) {
|
|
4552
4584
|
// note: command line "target" option gets ignored
|
|
4553
4585
|
var opts = getExportOpts();
|
|
4586
|
+
if (opts.format == 'geopackage') {
|
|
4587
|
+
await loadGeopackageLib();
|
|
4588
|
+
}
|
|
4554
4589
|
opts.active_layer = gui.model.getActiveLayer().layer; // kludge to support restoring active layer in gui
|
|
4555
|
-
|
|
4590
|
+
try {
|
|
4591
|
+
var files = await internal.exportTargetLayers(model, targets, opts);
|
|
4592
|
+
} catch(e) {
|
|
4593
|
+
console.error(e);
|
|
4594
|
+
throw e;
|
|
4595
|
+
}
|
|
4556
4596
|
gui.session.layersExported(getTargetLayerIds(), getExportOptsAsString());
|
|
4557
4597
|
if (files.length == 1 && checkboxOn(clipboardCheckbox)) {
|
|
4558
4598
|
await saveFileContentToClipboard(files[0].content);
|
|
@@ -4674,7 +4714,7 @@
|
|
|
4674
4714
|
|
|
4675
4715
|
function getExportFormats() {
|
|
4676
4716
|
// return ['shapefile', 'geojson', 'topojson', 'json', 'dsv', 'kml', 'svg', internal.PACKAGE_EXT];
|
|
4677
|
-
return ['shapefile', 'json', 'geojson', 'dsv', 'topojson', 'kml', internal.PACKAGE_EXT, 'svg'];
|
|
4717
|
+
return ['shapefile', 'json', 'geojson', 'dsv', 'topojson', 'flatgeobuf', 'geopackage', 'kml', internal.PACKAGE_EXT, 'svg'];
|
|
4678
4718
|
}
|
|
4679
4719
|
|
|
4680
4720
|
function initFormatMenu() {
|
|
@@ -5330,7 +5370,7 @@
|
|
|
5330
5370
|
if (!lyr.data) {
|
|
5331
5371
|
missing.push('.dbf');
|
|
5332
5372
|
}
|
|
5333
|
-
if (!dataset.info.
|
|
5373
|
+
if (!dataset.info.wkt1 && !dataset.info.crs) {
|
|
5334
5374
|
missing.push('.prj');
|
|
5335
5375
|
}
|
|
5336
5376
|
}
|
|
@@ -6239,6 +6279,8 @@
|
|
|
6239
6279
|
throw new NonFatalError(formatLogArgs(arguments));
|
|
6240
6280
|
};
|
|
6241
6281
|
|
|
6282
|
+
var onceMessages = [];
|
|
6283
|
+
|
|
6242
6284
|
setLoggingForCLI();
|
|
6243
6285
|
|
|
6244
6286
|
function getLoggingSetter() {
|
|
@@ -6300,6 +6342,13 @@
|
|
|
6300
6342
|
_warn.apply(null, messageArgs(arguments));
|
|
6301
6343
|
}
|
|
6302
6344
|
|
|
6345
|
+
function warnOnce() {
|
|
6346
|
+
var str = formatLogArgs(arguments);
|
|
6347
|
+
if (onceMessages.includes(str)) return;
|
|
6348
|
+
onceMessages.push(str);
|
|
6349
|
+
_warn.apply(null, messageArgs(arguments));
|
|
6350
|
+
}
|
|
6351
|
+
|
|
6303
6352
|
// A way for the GUI to replace the CLI logging functions
|
|
6304
6353
|
function setLoggingFunctions(message, error, stop, warn) {
|
|
6305
6354
|
_message = message;
|
|
@@ -13587,12 +13636,12 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
13587
13636
|
layers: []
|
|
13588
13637
|
};
|
|
13589
13638
|
|
|
13590
|
-
function loadScript(url, cb) {
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
}
|
|
13639
|
+
// function loadScript(url, cb) {
|
|
13640
|
+
// var script = document.createElement('script');
|
|
13641
|
+
// script.onload = cb;
|
|
13642
|
+
// script.src = url;
|
|
13643
|
+
// document.head.appendChild(script);
|
|
13644
|
+
// }
|
|
13596
13645
|
|
|
13597
13646
|
function loadStylesheet(url) {
|
|
13598
13647
|
var el = document.createElement('link');
|
|
@@ -13900,34 +13949,33 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
13900
13949
|
return bbox2;
|
|
13901
13950
|
}
|
|
13902
13951
|
|
|
13903
|
-
function initMap() {
|
|
13952
|
+
async function initMap() {
|
|
13904
13953
|
// var accessToken = (window.location.hostname == 'localhost' ?
|
|
13905
13954
|
// params.localhost_key : params.production_key) || params.key;
|
|
13906
13955
|
if (!enabled() || map || loading) return;
|
|
13907
13956
|
loading = true;
|
|
13908
13957
|
loadStylesheet(params.css);
|
|
13909
|
-
loadScript(params.js
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
});
|
|
13958
|
+
await loadScript(params.js);
|
|
13959
|
+
map = new window.mapboxgl.Map({
|
|
13960
|
+
logoPosition: 'bottom-left',
|
|
13961
|
+
container: mapEl.node(),
|
|
13962
|
+
// style: activeStyle.url,
|
|
13963
|
+
style: EMPTY_STYLE, // initializing with empty style to support custom styles
|
|
13964
|
+
bounds: getLonLatBounds(),
|
|
13965
|
+
doubleClickZoom: false,
|
|
13966
|
+
dragPan: false,
|
|
13967
|
+
dragRotate: false,
|
|
13968
|
+
scrollZoom: false,
|
|
13969
|
+
interactive: false,
|
|
13970
|
+
keyboard: false,
|
|
13971
|
+
maxPitch: 0,
|
|
13972
|
+
projection: 'mercator', // prevent globe view when zoomed out
|
|
13973
|
+
renderWorldCopies: true // false // false prevents panning off the map
|
|
13974
|
+
});
|
|
13975
|
+
setStyle(activeStyle);
|
|
13976
|
+
map.on('load', function() {
|
|
13977
|
+
loading = false;
|
|
13978
|
+
refresh();
|
|
13931
13979
|
});
|
|
13932
13980
|
}
|
|
13933
13981
|
|