mapshaper 0.7.54 → 0.7.55
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/README.md +2 -2
- package/mapshaper.js +20 -15
- package/package.json +1 -1
- package/www/index.html +1 -2
- package/www/mapshaper-gui.js +1 -1
- package/www/mapshaper.js +20 -15
- package/www/sponsor.html +0 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
Mapshaper is software for editing Shapefile, GeoJSON, [TopoJSON](https://github.com/mbostock/topojson/wiki), CSV and several other data formats, written in JavaScript.
|
|
5
|
+
Mapshaper is software for editing Shapefile, GeoJSON, [TopoJSON](https://github.com/mbostock/topojson/wiki), GeoTIFF, CSV and several other data formats, written in JavaScript.
|
|
6
6
|
|
|
7
7
|
Mapshaper supports essential map making tasks like simplifying shapes, editing attribute data, clipping, erasing, dissolving, filtering and more.
|
|
8
8
|
|
|
@@ -103,7 +103,7 @@ Mapshaper is free and open source. If it's useful to you or your organization, p
|
|
|
103
103
|
* [Ko-fi](https://ko-fi.com/mapshaper) — one-time or recurring contributions, no account required.
|
|
104
104
|
* [GitHub Sponsors](https://github.com/sponsors/mbloch) — recurring sponsorship.
|
|
105
105
|
|
|
106
|
-
You can also help by [reporting bugs](https://github.com/mbloch/mapshaper/issues)
|
|
106
|
+
You can also help by [reporting bugs or requesting features](https://github.com/mbloch/mapshaper/issues).
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
## License
|
package/mapshaper.js
CHANGED
|
@@ -34003,8 +34003,6 @@ ${svg}
|
|
|
34003
34003
|
}); });
|
|
34004
34004
|
}
|
|
34005
34005
|
|
|
34006
|
-
function buildHeader(t,r=0){let n,o=new Builder,i=0;t.columns&&(i=Header.createColumnsVector(o,t.columns.map(e=>{let t;return t=o.createString(e.name),Column.startColumn(o),Column.addName(o,t),Column.addType(o,e.type),Column.endColumn(o)})));let f=o.createString("L1");r&&(Crs.startCrs(o),Crs.addCode(o,r),n=Crs.endCrs(o)),Header.startHeader(o),n&&Header.addCrs(o,n),Header.addFeaturesCount(o,BigInt(t.featuresCount)),Header.addGeometryType(o,t.geometryType),Header.addIndexNodeSize(o,0),i&&Header.addColumns(o,i),Header.addName(o,f);let u=Header.endHeader(o);return o.finishSizePrefixed(u),o.asUint8Array()}
|
|
34007
|
-
|
|
34008
34006
|
// bytes: Uint8Array
|
|
34009
34007
|
function getHeaderMeta(bytes) {
|
|
34010
34008
|
if (!bytes.subarray(0, 3).every((v, i) => magicbytes[i] === v)) {
|
|
@@ -34012,7 +34010,11 @@ ${svg}
|
|
|
34012
34010
|
}
|
|
34013
34011
|
var bb = new ByteBuffer(bytes);
|
|
34014
34012
|
bb.setPosition(magicbytes.length + SIZE_PREFIX_LEN);
|
|
34015
|
-
|
|
34013
|
+
var header = Header.getRootAsHeader(bb);
|
|
34014
|
+
var meta = fromByteBuffer(bb);
|
|
34015
|
+
// The library's header-meta helper omits the FlatGeobuf dataset name.
|
|
34016
|
+
meta.name = header.name();
|
|
34017
|
+
return meta;
|
|
34016
34018
|
}
|
|
34017
34019
|
|
|
34018
34020
|
// bytes: Uint8Array
|
|
@@ -34086,7 +34088,7 @@ ${svg}
|
|
|
34086
34088
|
// source: a feature cursor, {length, getFeature(i)}. Features are pulled and
|
|
34087
34089
|
// encoded one at a time rather than as a collection, because the GeoJSON form
|
|
34088
34090
|
// of a layer is several times larger than the FlatGeobuf it encodes into.
|
|
34089
|
-
function serializeWithColumns(source, columns) {
|
|
34091
|
+
function serializeWithColumns(source, columns, name) {
|
|
34090
34092
|
if (source.length === 0) {
|
|
34091
34093
|
throw new Error('Could not infer geometry type for collection of features.');
|
|
34092
34094
|
}
|
|
@@ -34094,13 +34096,13 @@ ${svg}
|
|
|
34094
34096
|
// type, but that type isn't known until every feature has been seen. Assume
|
|
34095
34097
|
// the layer is homogeneous, which nearly all are, and encode again as
|
|
34096
34098
|
// Unknown in the rare case that it isn't.
|
|
34097
|
-
return encodeCollection(source, columns, null) ||
|
|
34098
|
-
encodeCollection(source, columns, GeometryType.Unknown);
|
|
34099
|
+
return encodeCollection(source, columns, name, null) ||
|
|
34100
|
+
encodeCollection(source, columns, name, GeometryType.Unknown);
|
|
34099
34101
|
}
|
|
34100
34102
|
|
|
34101
34103
|
// Returns null if forcedType is null and the features turn out to have more
|
|
34102
34104
|
// than one geometry type.
|
|
34103
|
-
function encodeCollection(source, columns, forcedType) {
|
|
34105
|
+
function encodeCollection(source, columns, name, forcedType) {
|
|
34104
34106
|
var headerMeta = null;
|
|
34105
34107
|
var sink = null;
|
|
34106
34108
|
// Null-geometry features encountered before the collection's geometry type is
|
|
@@ -34126,7 +34128,8 @@ ${svg}
|
|
|
34126
34128
|
}
|
|
34127
34129
|
var type = GeometryType[feature.geometry.type] || GeometryType.Unknown;
|
|
34128
34130
|
if (!headerMeta) {
|
|
34129
|
-
headerMeta = getEncodedHeaderMeta(
|
|
34131
|
+
headerMeta = getEncodedHeaderMeta(
|
|
34132
|
+
forcedType === null ? type : forcedType, columns, source.length, name);
|
|
34130
34133
|
sink = initSink(source, headerMeta, deferred);
|
|
34131
34134
|
} else if (forcedType === null && type != headerMeta.geometryType) {
|
|
34132
34135
|
return null;
|
|
@@ -34139,15 +34142,16 @@ ${svg}
|
|
|
34139
34142
|
}
|
|
34140
34143
|
if (!sink) {
|
|
34141
34144
|
// No feature had a geometry, so the collection has no geometry type.
|
|
34142
|
-
headerMeta = getEncodedHeaderMeta(
|
|
34143
|
-
columns, source.length);
|
|
34145
|
+
headerMeta = getEncodedHeaderMeta(
|
|
34146
|
+
forcedType === null ? GeometryType.Unknown : forcedType, columns, source.length, name);
|
|
34144
34147
|
sink = initSink(source, headerMeta, deferred);
|
|
34145
34148
|
}
|
|
34146
34149
|
return sink.toBytes();
|
|
34147
34150
|
}
|
|
34148
34151
|
|
|
34149
|
-
function getEncodedHeaderMeta(geometryType, columns, featuresCount) {
|
|
34152
|
+
function getEncodedHeaderMeta(geometryType, columns, featuresCount, name) {
|
|
34150
34153
|
return {
|
|
34154
|
+
name: name,
|
|
34151
34155
|
geometryType: geometryType,
|
|
34152
34156
|
columns: columns,
|
|
34153
34157
|
envelope: null,
|
|
@@ -34163,7 +34167,7 @@ ${svg}
|
|
|
34163
34167
|
function initSink(source, headerMeta, deferredFeatures) {
|
|
34164
34168
|
var sink = new ByteSink(magicbytes.length + estimateEncodedBytes(source));
|
|
34165
34169
|
sink.append(magicbytes);
|
|
34166
|
-
sink.append(
|
|
34170
|
+
sink.append(buildHeaderWithCRS(headerMeta, null));
|
|
34167
34171
|
for (var i = 0; i < deferredFeatures.length; i++) {
|
|
34168
34172
|
sink.append(deferredFeatures[i]);
|
|
34169
34173
|
}
|
|
@@ -34287,13 +34291,14 @@ ${svg}
|
|
|
34287
34291
|
}
|
|
34288
34292
|
var crsMeta = resolveOutputCRS(dataset);
|
|
34289
34293
|
return dataset.layers.map(function(lyr) {
|
|
34294
|
+
var name = lyr.name || 'layer';
|
|
34290
34295
|
var cursor = getFeatureCursor(lyr, dataset, opts, true);
|
|
34291
34296
|
if (cursor.length === 0) {
|
|
34292
34297
|
stop$1('FlatGeobuf export does not support empty layers');
|
|
34293
34298
|
}
|
|
34294
34299
|
var columns = getFlatGeobufColumns(lyr);
|
|
34295
|
-
var content = serializeWithColumns(cursor, columns);
|
|
34296
|
-
var filename =
|
|
34300
|
+
var content = serializeWithColumns(cursor, columns, name);
|
|
34301
|
+
var filename = name + '.' + extension;
|
|
34297
34302
|
if (crsMeta) {
|
|
34298
34303
|
content = rewriteHeaderWithCRS(content, crsMeta);
|
|
34299
34304
|
} else {
|
|
@@ -78965,7 +78970,7 @@ ${svg}
|
|
|
78965
78970
|
return name == 'rectangle' || name == 'rectangles' || name == 'filter' && opts.cleanup;
|
|
78966
78971
|
}
|
|
78967
78972
|
|
|
78968
|
-
var version = "0.7.
|
|
78973
|
+
var version = "0.7.55";
|
|
78969
78974
|
|
|
78970
78975
|
// Parse command line args into commands and run them
|
|
78971
78976
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -89,12 +89,11 @@
|
|
|
89
89
|
<a class="header-menu-item" href="/docs/" target="_blank" rel="noopener" role="menuitem">Docs</a>
|
|
90
90
|
<a class="header-menu-item" href="https://github.com/mbloch/mapshaper" target="_blank" rel="noopener" role="menuitem">GitHub</a>
|
|
91
91
|
<a class="header-menu-item" href="https://github.com/mbloch/mapshaper/issues/new" target="_blank" rel="noopener" role="menuitem">Report an issue</a>
|
|
92
|
-
<a class="header-menu-item" href="https://tally.so/r/44Njok" target="_blank" rel="noopener" role="menuitem">1-minute survey</a>
|
|
93
92
|
<a class="header-menu-item header-menu-sponsor" href="sponsor.html" target="_blank" rel="noopener" role="menuitem"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>Become a sponsor</a>
|
|
94
93
|
</div>
|
|
95
94
|
</div>
|
|
96
95
|
<div id="splash-buttons" class="page-header-buttons">
|
|
97
|
-
<a href="/docs/"><span id="wiki-btn" class="header-btn btn">Docs</span></a><span class="separator"></span><a href="https://github.com/mbloch/mapshaper"><span id="github-btn" class="header-btn btn">GitHub</span></a><span class="separator"></span><a href="
|
|
96
|
+
<a href="/docs/"><span id="wiki-btn" class="header-btn btn">Docs</span></a><span class="separator"></span><a href="https://github.com/mbloch/mapshaper"><span id="github-btn" class="header-btn btn">GitHub</span></a><span class="separator"></span><a href="sponsor.html"><span id="sponsor-btn" class="header-btn btn"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg> Become a sponsor</span></a>
|
|
98
97
|
</div>
|
|
99
98
|
</div>
|
|
100
99
|
|
package/www/mapshaper-gui.js
CHANGED
|
@@ -12009,7 +12009,7 @@
|
|
|
12009
12009
|
}
|
|
12010
12010
|
|
|
12011
12011
|
// Hamburger menu in the top-right of the header. After the user starts
|
|
12012
|
-
// editing, the splash bar (Docs / GitHub /
|
|
12012
|
+
// editing, the splash bar (Docs / GitHub / Sponsor) is hidden by
|
|
12013
12013
|
// gui.mjs; this menu is the post-edit replacement, exposing the same links
|
|
12014
12014
|
// from a single button so the editing controls don't have to share the row.
|
|
12015
12015
|
|
package/www/mapshaper.js
CHANGED
|
@@ -34003,8 +34003,6 @@ ${svg}
|
|
|
34003
34003
|
}); });
|
|
34004
34004
|
}
|
|
34005
34005
|
|
|
34006
|
-
function buildHeader(t,r=0){let n,o=new Builder,i=0;t.columns&&(i=Header.createColumnsVector(o,t.columns.map(e=>{let t;return t=o.createString(e.name),Column.startColumn(o),Column.addName(o,t),Column.addType(o,e.type),Column.endColumn(o)})));let f=o.createString("L1");r&&(Crs.startCrs(o),Crs.addCode(o,r),n=Crs.endCrs(o)),Header.startHeader(o),n&&Header.addCrs(o,n),Header.addFeaturesCount(o,BigInt(t.featuresCount)),Header.addGeometryType(o,t.geometryType),Header.addIndexNodeSize(o,0),i&&Header.addColumns(o,i),Header.addName(o,f);let u=Header.endHeader(o);return o.finishSizePrefixed(u),o.asUint8Array()}
|
|
34007
|
-
|
|
34008
34006
|
// bytes: Uint8Array
|
|
34009
34007
|
function getHeaderMeta(bytes) {
|
|
34010
34008
|
if (!bytes.subarray(0, 3).every((v, i) => magicbytes[i] === v)) {
|
|
@@ -34012,7 +34010,11 @@ ${svg}
|
|
|
34012
34010
|
}
|
|
34013
34011
|
var bb = new ByteBuffer(bytes);
|
|
34014
34012
|
bb.setPosition(magicbytes.length + SIZE_PREFIX_LEN);
|
|
34015
|
-
|
|
34013
|
+
var header = Header.getRootAsHeader(bb);
|
|
34014
|
+
var meta = fromByteBuffer(bb);
|
|
34015
|
+
// The library's header-meta helper omits the FlatGeobuf dataset name.
|
|
34016
|
+
meta.name = header.name();
|
|
34017
|
+
return meta;
|
|
34016
34018
|
}
|
|
34017
34019
|
|
|
34018
34020
|
// bytes: Uint8Array
|
|
@@ -34086,7 +34088,7 @@ ${svg}
|
|
|
34086
34088
|
// source: a feature cursor, {length, getFeature(i)}. Features are pulled and
|
|
34087
34089
|
// encoded one at a time rather than as a collection, because the GeoJSON form
|
|
34088
34090
|
// of a layer is several times larger than the FlatGeobuf it encodes into.
|
|
34089
|
-
function serializeWithColumns(source, columns) {
|
|
34091
|
+
function serializeWithColumns(source, columns, name) {
|
|
34090
34092
|
if (source.length === 0) {
|
|
34091
34093
|
throw new Error('Could not infer geometry type for collection of features.');
|
|
34092
34094
|
}
|
|
@@ -34094,13 +34096,13 @@ ${svg}
|
|
|
34094
34096
|
// type, but that type isn't known until every feature has been seen. Assume
|
|
34095
34097
|
// the layer is homogeneous, which nearly all are, and encode again as
|
|
34096
34098
|
// Unknown in the rare case that it isn't.
|
|
34097
|
-
return encodeCollection(source, columns, null) ||
|
|
34098
|
-
encodeCollection(source, columns, GeometryType.Unknown);
|
|
34099
|
+
return encodeCollection(source, columns, name, null) ||
|
|
34100
|
+
encodeCollection(source, columns, name, GeometryType.Unknown);
|
|
34099
34101
|
}
|
|
34100
34102
|
|
|
34101
34103
|
// Returns null if forcedType is null and the features turn out to have more
|
|
34102
34104
|
// than one geometry type.
|
|
34103
|
-
function encodeCollection(source, columns, forcedType) {
|
|
34105
|
+
function encodeCollection(source, columns, name, forcedType) {
|
|
34104
34106
|
var headerMeta = null;
|
|
34105
34107
|
var sink = null;
|
|
34106
34108
|
// Null-geometry features encountered before the collection's geometry type is
|
|
@@ -34126,7 +34128,8 @@ ${svg}
|
|
|
34126
34128
|
}
|
|
34127
34129
|
var type = GeometryType[feature.geometry.type] || GeometryType.Unknown;
|
|
34128
34130
|
if (!headerMeta) {
|
|
34129
|
-
headerMeta = getEncodedHeaderMeta(
|
|
34131
|
+
headerMeta = getEncodedHeaderMeta(
|
|
34132
|
+
forcedType === null ? type : forcedType, columns, source.length, name);
|
|
34130
34133
|
sink = initSink(source, headerMeta, deferred);
|
|
34131
34134
|
} else if (forcedType === null && type != headerMeta.geometryType) {
|
|
34132
34135
|
return null;
|
|
@@ -34139,15 +34142,16 @@ ${svg}
|
|
|
34139
34142
|
}
|
|
34140
34143
|
if (!sink) {
|
|
34141
34144
|
// No feature had a geometry, so the collection has no geometry type.
|
|
34142
|
-
headerMeta = getEncodedHeaderMeta(
|
|
34143
|
-
columns, source.length);
|
|
34145
|
+
headerMeta = getEncodedHeaderMeta(
|
|
34146
|
+
forcedType === null ? GeometryType.Unknown : forcedType, columns, source.length, name);
|
|
34144
34147
|
sink = initSink(source, headerMeta, deferred);
|
|
34145
34148
|
}
|
|
34146
34149
|
return sink.toBytes();
|
|
34147
34150
|
}
|
|
34148
34151
|
|
|
34149
|
-
function getEncodedHeaderMeta(geometryType, columns, featuresCount) {
|
|
34152
|
+
function getEncodedHeaderMeta(geometryType, columns, featuresCount, name) {
|
|
34150
34153
|
return {
|
|
34154
|
+
name: name,
|
|
34151
34155
|
geometryType: geometryType,
|
|
34152
34156
|
columns: columns,
|
|
34153
34157
|
envelope: null,
|
|
@@ -34163,7 +34167,7 @@ ${svg}
|
|
|
34163
34167
|
function initSink(source, headerMeta, deferredFeatures) {
|
|
34164
34168
|
var sink = new ByteSink(magicbytes.length + estimateEncodedBytes(source));
|
|
34165
34169
|
sink.append(magicbytes);
|
|
34166
|
-
sink.append(
|
|
34170
|
+
sink.append(buildHeaderWithCRS(headerMeta, null));
|
|
34167
34171
|
for (var i = 0; i < deferredFeatures.length; i++) {
|
|
34168
34172
|
sink.append(deferredFeatures[i]);
|
|
34169
34173
|
}
|
|
@@ -34287,13 +34291,14 @@ ${svg}
|
|
|
34287
34291
|
}
|
|
34288
34292
|
var crsMeta = resolveOutputCRS(dataset);
|
|
34289
34293
|
return dataset.layers.map(function(lyr) {
|
|
34294
|
+
var name = lyr.name || 'layer';
|
|
34290
34295
|
var cursor = getFeatureCursor(lyr, dataset, opts, true);
|
|
34291
34296
|
if (cursor.length === 0) {
|
|
34292
34297
|
stop$1('FlatGeobuf export does not support empty layers');
|
|
34293
34298
|
}
|
|
34294
34299
|
var columns = getFlatGeobufColumns(lyr);
|
|
34295
|
-
var content = serializeWithColumns(cursor, columns);
|
|
34296
|
-
var filename =
|
|
34300
|
+
var content = serializeWithColumns(cursor, columns, name);
|
|
34301
|
+
var filename = name + '.' + extension;
|
|
34297
34302
|
if (crsMeta) {
|
|
34298
34303
|
content = rewriteHeaderWithCRS(content, crsMeta);
|
|
34299
34304
|
} else {
|
|
@@ -78965,7 +78970,7 @@ ${svg}
|
|
|
78965
78970
|
return name == 'rectangle' || name == 'rectangles' || name == 'filter' && opts.cleanup;
|
|
78966
78971
|
}
|
|
78967
78972
|
|
|
78968
|
-
var version = "0.7.
|
|
78973
|
+
var version = "0.7.55";
|
|
78969
78974
|
|
|
78970
78975
|
// Parse command line args into commands and run them
|
|
78971
78976
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/www/sponsor.html
CHANGED
|
@@ -43,9 +43,6 @@
|
|
|
43
43
|
<li><a href="docs/whats-new.html">Learn more</a></li>
|
|
44
44
|
</ul>
|
|
45
45
|
|
|
46
|
-
<h2>Want to help shape the roadmap?</h2>
|
|
47
|
-
<p>Take a <a href="https://tally.so/r/44Njok">one-minute survey</a> and tell me what you'd like to see improved.
|
|
48
|
-
|
|
49
46
|
<p class="signature">— Matthew Bloch, maintainer</p>
|
|
50
47
|
|
|
51
48
|
<div class="footer-note">
|