mapshaper 0.7.14 → 0.7.15
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 +121 -8
- package/package.json +2 -1
- package/www/geotiff.js +4 -0
- package/www/index.html +2 -2
- package/www/mapshaper-gui.js +14 -6
- package/www/mapshaper.js +121 -8
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 topology-aware tool for editing and converting geospatial
|
|
5
|
+
<meta name="Description" content="A topology-aware tool for editing and converting geospatial data. Works with Shapefile, GeoJSON, TopoJSON, GeoPackage, FlatGeobuf, GeoParquet, GeoTIFF, KML and CSV — in the browser or on the command line.">
|
|
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">
|
|
@@ -307,7 +307,7 @@ a smoother appearance.</div></div></div></div>
|
|
|
307
307
|
<span><input type="checkbox" class="advanced-import-options">with advanced options</span>
|
|
308
308
|
<div class="mini-drop-area">
|
|
309
309
|
<div class="subtitle">Drop, paste or <span class="add-btn inline-btn btn"><span class="label-text">select</span></span> files to import.</div>
|
|
310
|
-
<div class="subtitle">Shapefile, GeoJSON, TopoJSON, GeoPackage, FlatGeobuf, GeoParquet, KML and
|
|
310
|
+
<div class="subtitle">Shapefile, GeoJSON, TopoJSON, GeoPackage, FlatGeobuf, GeoParquet, GeoTIFF, KML, CSV and more are supported. Files can be zipped or gzipped.</div>
|
|
311
311
|
</div>
|
|
312
312
|
</div>
|
|
313
313
|
<div class="queued-file-section">
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -9401,8 +9401,8 @@
|
|
|
9401
9401
|
} else if (kc == 40) {
|
|
9402
9402
|
forward();
|
|
9403
9403
|
} else if (kc == 32 && (!typing || (inputText === '' && typingInConsole))) {
|
|
9404
|
-
// space bar toggles the
|
|
9405
|
-
gui.
|
|
9404
|
+
// space bar toggles the console tab if nothing has been typed
|
|
9405
|
+
gui.toggleSidebarPanel('console');
|
|
9406
9406
|
} else if (!typing && e.target != input.node() && !metaKey(e)) {
|
|
9407
9407
|
// typing returns focus, unless a meta key is down (to allow Cmd-C copy)
|
|
9408
9408
|
// or user is typing in a different input area somewhere
|
|
@@ -9419,9 +9419,9 @@
|
|
|
9419
9419
|
|
|
9420
9420
|
// various shortcuts (while not typing in an input field or editable el)
|
|
9421
9421
|
} else if (!typing) {
|
|
9422
|
-
if (kc == 32) { // space bar toggles the
|
|
9422
|
+
if (kc == 32) { // space bar toggles the console tab
|
|
9423
9423
|
capture = true;
|
|
9424
|
-
gui.
|
|
9424
|
+
gui.toggleSidebarPanel('console');
|
|
9425
9425
|
// } else if (kc == 73) { // letter i opens inspector
|
|
9426
9426
|
// gui.dispatchEvent('interaction_toggle');
|
|
9427
9427
|
} else if (kc == 72) { // letter h resets map extent
|
|
@@ -10788,17 +10788,25 @@
|
|
|
10788
10788
|
headerBtn.on('click', function() {
|
|
10789
10789
|
toggle();
|
|
10790
10790
|
}).on('keydown', function(e) {
|
|
10791
|
-
if (e.key == 'Enter'
|
|
10791
|
+
if (e.key == 'Enter') {
|
|
10792
10792
|
e.preventDefault();
|
|
10793
10793
|
e.stopPropagation();
|
|
10794
10794
|
toggle();
|
|
10795
|
+
} else if (e.key == ' ') {
|
|
10796
|
+
e.preventDefault();
|
|
10797
|
+
e.stopPropagation();
|
|
10798
|
+
gui.toggleSidebarPanel('console');
|
|
10795
10799
|
}
|
|
10796
10800
|
});
|
|
10797
10801
|
tab.on('click', toggle).on('keydown', function(e) {
|
|
10798
|
-
if (e.key == 'Enter'
|
|
10802
|
+
if (e.key == 'Enter') {
|
|
10799
10803
|
e.preventDefault();
|
|
10800
10804
|
e.stopPropagation();
|
|
10801
10805
|
toggle();
|
|
10806
|
+
} else if (e.key == ' ') {
|
|
10807
|
+
e.preventDefault();
|
|
10808
|
+
e.stopPropagation();
|
|
10809
|
+
gui.toggleSidebarPanel('console');
|
|
10802
10810
|
}
|
|
10803
10811
|
});
|
|
10804
10812
|
|
package/www/mapshaper.js
CHANGED
|
@@ -35693,6 +35693,7 @@ ${svg}
|
|
|
35693
35693
|
}
|
|
35694
35694
|
|
|
35695
35695
|
var geotiffPromise = null;
|
|
35696
|
+
var geoKeysToProj4Promise = null;
|
|
35696
35697
|
var dynamicImportModule = Function('id', 'return import(id)');
|
|
35697
35698
|
var DEFAULT_MAX_IMPORT_PIXELS = 16e6;
|
|
35698
35699
|
|
|
@@ -35734,6 +35735,18 @@ ${svg}
|
|
|
35734
35735
|
return mod.default && !mod.fromArrayBuffer ? mod.default : mod;
|
|
35735
35736
|
}
|
|
35736
35737
|
|
|
35738
|
+
async function loadGeoKeysToProj4Lib() {
|
|
35739
|
+
var mod;
|
|
35740
|
+
if (runningInBrowser()) {
|
|
35741
|
+
return require$1('geotiff-geokeys-to-proj4');
|
|
35742
|
+
}
|
|
35743
|
+
if (!geoKeysToProj4Promise) {
|
|
35744
|
+
geoKeysToProj4Promise = dynamicImportModule('geotiff-geokeys-to-proj4');
|
|
35745
|
+
}
|
|
35746
|
+
mod = await geoKeysToProj4Promise;
|
|
35747
|
+
return mod.default || mod;
|
|
35748
|
+
}
|
|
35749
|
+
|
|
35737
35750
|
async function openGeoTIFF(source, geotiff) {
|
|
35738
35751
|
if (!source) {
|
|
35739
35752
|
stop$1('Missing GeoTIFF source data');
|
|
@@ -36040,23 +36053,123 @@ ${svg}
|
|
|
36040
36053
|
}
|
|
36041
36054
|
|
|
36042
36055
|
async function importGeoTIFFCrs(dataset, image) {
|
|
36043
|
-
var
|
|
36056
|
+
var crsInfo = await getGeoTIFFCrsInfo(image);
|
|
36057
|
+
var crsString = crsInfo.crsString;
|
|
36044
36058
|
if (!crsString) {
|
|
36045
|
-
warnOnce(
|
|
36059
|
+
warnOnce(getGeoTIFFCrsWarning(crsInfo));
|
|
36046
36060
|
return;
|
|
36047
36061
|
}
|
|
36048
|
-
await initProjLibrary({crs: crsString});
|
|
36049
36062
|
try {
|
|
36063
|
+
await initProjLibrary({crs: crsString});
|
|
36050
36064
|
setDatasetCrsInfo(dataset, getCrsInfo(crsString));
|
|
36051
36065
|
} catch(e) {
|
|
36052
|
-
dataset.info =
|
|
36066
|
+
dataset.info = dataset.info || {};
|
|
36067
|
+
warnOnce(getGeoTIFFCrsWarning(crsInfo, e.message || e));
|
|
36053
36068
|
}
|
|
36054
36069
|
}
|
|
36055
36070
|
|
|
36056
|
-
function
|
|
36071
|
+
async function getGeoTIFFCrsInfo(image) {
|
|
36057
36072
|
var keys = image.getGeoKeys && image.getGeoKeys() || {};
|
|
36058
|
-
var code = keys.ProjectedCSTypeGeoKey
|
|
36059
|
-
|
|
36073
|
+
var code = keys.ProjectedCSTypeGeoKey;
|
|
36074
|
+
var customProjection;
|
|
36075
|
+
if (isGeoTIFFAuthorityCode(code)) {
|
|
36076
|
+
return {crsString: 'EPSG:' + code};
|
|
36077
|
+
}
|
|
36078
|
+
customProjection = await getGeoTIFFCustomProjection(keys);
|
|
36079
|
+
if (customProjection.crsString) return customProjection;
|
|
36080
|
+
code = keys.GeographicTypeGeoKey;
|
|
36081
|
+
if (isGeoTIFFAuthorityCode(code)) return {crsString: 'EPSG:' + code};
|
|
36082
|
+
return {crsString: null, warning: customProjection.warning};
|
|
36083
|
+
}
|
|
36084
|
+
|
|
36085
|
+
function getGeoTIFFCrsWarning(crsInfo, detail) {
|
|
36086
|
+
if (detail || crsInfo && crsInfo.warning) {
|
|
36087
|
+
logGeoTIFFCrsWarningDetails(detail, crsInfo && crsInfo.warning);
|
|
36088
|
+
}
|
|
36089
|
+
return 'The GeoTIFF does not contain usable CRS data';
|
|
36090
|
+
}
|
|
36091
|
+
|
|
36092
|
+
function isGeoTIFFAuthorityCode(code) {
|
|
36093
|
+
return code > 0 && code != 32767;
|
|
36094
|
+
}
|
|
36095
|
+
|
|
36096
|
+
async function getGeoTIFFCustomProjection(keys) {
|
|
36097
|
+
var converted = await getGeoTIFFProj4FromGeoKeys(keys);
|
|
36098
|
+
if (converted.crsString) return converted;
|
|
36099
|
+
if (keys.ProjectedCSTypeGeoKey != 32767 && keys.ProjectionGeoKey != 32767) return converted;
|
|
36100
|
+
if (keys.ProjCoordTransGeoKey == 11) {
|
|
36101
|
+
return {
|
|
36102
|
+
crsString: getGeoTIFFAlbersProjection(keys),
|
|
36103
|
+
warning: converted.warning
|
|
36104
|
+
};
|
|
36105
|
+
}
|
|
36106
|
+
return converted;
|
|
36107
|
+
}
|
|
36108
|
+
|
|
36109
|
+
async function getGeoTIFFProj4FromGeoKeys(keys) {
|
|
36110
|
+
var geokeysToProj4, result;
|
|
36111
|
+
try {
|
|
36112
|
+
geokeysToProj4 = await loadGeoKeysToProj4Lib();
|
|
36113
|
+
result = geokeysToProj4.toProj4(keys);
|
|
36114
|
+
} catch(e) {
|
|
36115
|
+
return {crsString: null, warning: {type: 'GeoKey converter error', error: e.message || e}};
|
|
36116
|
+
}
|
|
36117
|
+
if (result && result.proj4) {
|
|
36118
|
+
return {crsString: normalizeGeoTIFFProj4(result.proj4)};
|
|
36119
|
+
}
|
|
36120
|
+
return {crsString: null, warning: result && result.errors || null};
|
|
36121
|
+
}
|
|
36122
|
+
|
|
36123
|
+
function normalizeGeoTIFFProj4(str) {
|
|
36124
|
+
return String(str).replace(/\s\+axis=[^ ]+/g, '').trim();
|
|
36125
|
+
}
|
|
36126
|
+
|
|
36127
|
+
function logGeoTIFFCrsWarningDetails(parseError, converterDetails) {
|
|
36128
|
+
if (typeof console == 'undefined' || !console.warn) return;
|
|
36129
|
+
console.warn('Unable to import GeoTIFF CRS metadata', {
|
|
36130
|
+
parseError: parseError || null,
|
|
36131
|
+
converterDetails: converterDetails || null
|
|
36132
|
+
});
|
|
36133
|
+
}
|
|
36134
|
+
|
|
36135
|
+
function getGeoTIFFAlbersProjection(keys) {
|
|
36136
|
+
var units = getGeoTIFFLinearUnits(keys);
|
|
36137
|
+
var ellipsoid = getGeoTIFFEllipsoid(keys);
|
|
36138
|
+
if (!units || !ellipsoid ||
|
|
36139
|
+
!isFinite(keys.ProjStdParallel1GeoKey) || !isFinite(keys.ProjStdParallel2GeoKey) ||
|
|
36140
|
+
!isFinite(keys.ProjNatOriginLatGeoKey) || !isFinite(keys.ProjNatOriginLongGeoKey)) {
|
|
36141
|
+
return null;
|
|
36142
|
+
}
|
|
36143
|
+
return [
|
|
36144
|
+
'+proj=aea',
|
|
36145
|
+
'+lat_1=' + keys.ProjStdParallel1GeoKey,
|
|
36146
|
+
'+lat_2=' + keys.ProjStdParallel2GeoKey,
|
|
36147
|
+
'+lat_0=' + keys.ProjNatOriginLatGeoKey,
|
|
36148
|
+
'+lon_0=' + keys.ProjNatOriginLongGeoKey,
|
|
36149
|
+
'+x_0=' + (keys.ProjFalseEastingGeoKey || 0),
|
|
36150
|
+
'+y_0=' + (keys.ProjFalseNorthingGeoKey || 0),
|
|
36151
|
+
ellipsoid,
|
|
36152
|
+
units
|
|
36153
|
+
].join(' ');
|
|
36154
|
+
}
|
|
36155
|
+
|
|
36156
|
+
function getGeoTIFFLinearUnits(keys) {
|
|
36157
|
+
var code = keys.ProjLinearUnitsGeoKey;
|
|
36158
|
+
if (!code || code == 9001) return '+units=m';
|
|
36159
|
+
if (code == 9002) return '+units=ft';
|
|
36160
|
+
if (code == 9003) return '+to_meter=0.3048006096012192';
|
|
36161
|
+
return null;
|
|
36162
|
+
}
|
|
36163
|
+
|
|
36164
|
+
function getGeoTIFFEllipsoid(keys) {
|
|
36165
|
+
if (keys.GeographicTypeGeoKey == 4326) return '+datum=WGS84';
|
|
36166
|
+
if (isFinite(keys.GeogSemiMajorAxisGeoKey) && isFinite(keys.GeogInvFlatteningGeoKey)) {
|
|
36167
|
+
return '+a=' + keys.GeogSemiMajorAxisGeoKey + ' +rf=' + keys.GeogInvFlatteningGeoKey;
|
|
36168
|
+
}
|
|
36169
|
+
if (isFinite(keys.GeogSemiMajorAxisGeoKey) && isFinite(keys.GeogSemiMinorAxisGeoKey)) {
|
|
36170
|
+
return '+a=' + keys.GeogSemiMajorAxisGeoKey + ' +b=' + keys.GeogSemiMinorAxisGeoKey;
|
|
36171
|
+
}
|
|
36172
|
+
return null;
|
|
36060
36173
|
}
|
|
36061
36174
|
|
|
36062
36175
|
async function importImageRaster(input, optsArg) {
|
|
@@ -57269,7 +57382,7 @@ ${svg}
|
|
|
57269
57382
|
});
|
|
57270
57383
|
}
|
|
57271
57384
|
|
|
57272
|
-
var version = "0.7.
|
|
57385
|
+
var version = "0.7.15";
|
|
57273
57386
|
|
|
57274
57387
|
// Parse command line args into commands and run them
|
|
57275
57388
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|