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/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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.15",
|
|
4
4
|
"description": "A tool for editing vector datasets for mapping and GIS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapefile",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"geographiclib-geodesic": "^2.2.0",
|
|
66
66
|
"geokdbush": "^1.1.0",
|
|
67
67
|
"geotiff": "^3.0.5",
|
|
68
|
+
"geotiff-geokeys-to-proj4": "^2024.4.13",
|
|
68
69
|
"hyparquet": "^1.25.6",
|
|
69
70
|
"hyparquet-compressors": "^1.1.1",
|
|
70
71
|
"hyparquet-writer": "^0.14.0",
|