mapshaper 0.5.98 → 0.5.101
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/CHANGELOG.md +9 -0
- package/mapshaper.js +54 -11
- package/package.json +2 -1
- package/www/images/thumb-map.jpg +0 -0
- package/www/images/thumb-satellite.jpg +0 -0
- package/www/index.html +15 -1
- package/www/mapshaper-gui.js +780 -385
- package/www/mapshaper.js +54 -11
- package/www/page.css +89 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
v0.5.101
|
|
2
|
+
* Update dependency.
|
|
3
|
+
|
|
4
|
+
v0.5.100
|
|
5
|
+
* Added support for using the basemap feature with datasets in a wide variety of projections.
|
|
6
|
+
|
|
7
|
+
v0.5.99
|
|
8
|
+
* Added support for viewing data against a Mapbox basemap (enabled on the mapshaper.org site).
|
|
9
|
+
|
|
1
10
|
v0.5.98
|
|
2
11
|
* Better handling of null data by the -classify command.
|
|
3
12
|
|
package/mapshaper.js
CHANGED
|
@@ -1771,6 +1771,8 @@
|
|
|
1771
1771
|
// avoid re-allocating memory
|
|
1772
1772
|
var xx2 = new Float64Array(data.xx.buffer, 0, n-1);
|
|
1773
1773
|
var yy2 = new Float64Array(data.yy.buffer, 0, n-1);
|
|
1774
|
+
var zz2 = arcs.isFlat() ? null : new Float64Array(data.zz.buffer, 0, n-1);
|
|
1775
|
+
var z = arcs.getRetainedInterval();
|
|
1774
1776
|
var count = 0;
|
|
1775
1777
|
var found = false;
|
|
1776
1778
|
for (var j=0; j<nn.length; j++) {
|
|
@@ -1784,24 +1786,31 @@
|
|
|
1784
1786
|
utils.copyElements(data.yy, 0, yy2, 0, i);
|
|
1785
1787
|
utils.copyElements(data.xx, i+1, xx2, i, n-i-1);
|
|
1786
1788
|
utils.copyElements(data.yy, i+1, yy2, i, n-i-1);
|
|
1787
|
-
|
|
1789
|
+
if (zz2) {
|
|
1790
|
+
utils.copyElements(data.zz, 0, zz2, 0, i);
|
|
1791
|
+
utils.copyElements(data.zz, i+1, zz2, i, n-i-1);
|
|
1792
|
+
}
|
|
1793
|
+
arcs.updateVertexData(nn, xx2, yy2, zz2);
|
|
1794
|
+
arcs.setRetainedInterval(z);
|
|
1788
1795
|
}
|
|
1789
1796
|
|
|
1790
1797
|
function insertVertex(arcs, i, p) {
|
|
1791
|
-
// TODO: add extra bytes to the buffers, to reduce new memory allocation
|
|
1792
1798
|
var data = arcs.getVertexData();
|
|
1793
1799
|
var nn = data.nn;
|
|
1794
1800
|
var n = data.xx.length;
|
|
1795
1801
|
var count = 0;
|
|
1796
1802
|
var found = false;
|
|
1797
|
-
var xx2, yy2;
|
|
1803
|
+
var xx2, yy2, zz2;
|
|
1798
1804
|
// avoid re-allocating memory on each insertion
|
|
1799
1805
|
if (data.xx.buffer.byteLength >= data.xx.length * 8 + 8) {
|
|
1800
1806
|
xx2 = new Float64Array(data.xx.buffer, 0, n+1);
|
|
1801
1807
|
yy2 = new Float64Array(data.yy.buffer, 0, n+1);
|
|
1802
1808
|
} else {
|
|
1803
|
-
xx2 = new Float64Array(new ArrayBuffer((n +
|
|
1804
|
-
yy2 = new Float64Array(new ArrayBuffer((n +
|
|
1809
|
+
xx2 = new Float64Array(new ArrayBuffer((n + 50) * 8), 0, n+1);
|
|
1810
|
+
yy2 = new Float64Array(new ArrayBuffer((n + 50) * 8), 0, n+1);
|
|
1811
|
+
}
|
|
1812
|
+
if (!arcs.isFlat()) {
|
|
1813
|
+
zz2 = new Float64Array(new ArrayBuffer((n + 1) * 8), 0, n+1);
|
|
1805
1814
|
}
|
|
1806
1815
|
for (var j=0; j<nn.length; j++) {
|
|
1807
1816
|
count += nn[j];
|
|
@@ -1816,7 +1825,12 @@
|
|
|
1816
1825
|
utils.copyElements(data.yy, i, yy2, i+1, n-i);
|
|
1817
1826
|
xx2[i] = p[0];
|
|
1818
1827
|
yy2[i] = p[1];
|
|
1819
|
-
|
|
1828
|
+
if (zz2) {
|
|
1829
|
+
zz2[i] = Infinity;
|
|
1830
|
+
utils.copyElements(data.zz, 0, zz2, 0, i);
|
|
1831
|
+
utils.copyElements(data.zz, i, zz2, i+1, n-i);
|
|
1832
|
+
}
|
|
1833
|
+
arcs.updateVertexData(nn, xx2, yy2, zz2);
|
|
1820
1834
|
}
|
|
1821
1835
|
|
|
1822
1836
|
var ArcUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -4663,8 +4677,8 @@
|
|
|
4663
4677
|
if (isLatLngCRS(P)) {
|
|
4664
4678
|
return xy.concat();
|
|
4665
4679
|
}
|
|
4666
|
-
proj =
|
|
4667
|
-
return proj(xy);
|
|
4680
|
+
proj = getProjTransform(P, getCRS('wgs84'));
|
|
4681
|
+
return proj(xy[0], xy[1]);
|
|
4668
4682
|
}
|
|
4669
4683
|
|
|
4670
4684
|
function getProjInfo(dataset) {
|
|
@@ -4806,10 +4820,30 @@
|
|
|
4806
4820
|
return !isLatLngCRS(P);
|
|
4807
4821
|
}
|
|
4808
4822
|
|
|
4823
|
+
function isInvertibleCRS(P) {
|
|
4824
|
+
if (!P || !P.inv) return false;
|
|
4825
|
+
return true;
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4809
4828
|
function isLatLngCRS(P) {
|
|
4810
4829
|
return P && P.is_latlong || false;
|
|
4811
4830
|
}
|
|
4812
4831
|
|
|
4832
|
+
function isWGS84(P) {
|
|
4833
|
+
if (!isLatLngCRS(P)) return false;
|
|
4834
|
+
var proj4 = crsToProj4(P);
|
|
4835
|
+
return proj4.toLowerCase().includes('84');
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4838
|
+
function isWebMercator(P) {
|
|
4839
|
+
if (!P) return false;
|
|
4840
|
+
var str = crsToProj4(P);
|
|
4841
|
+
// e.g. +proj=merc +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +wktext +a=6378137 +b=6378137 +nadgrids=@null
|
|
4842
|
+
// e.g. +proj=merc +a=6378137 +b=6378137
|
|
4843
|
+
// TODO: support https://proj.org/operations/projections/webmerc.html
|
|
4844
|
+
return str.includes('+proj=merc') && str.includes('+a=6378137') && str.includes('+b=6378137');
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4813
4847
|
function isLatLngDataset(dataset) {
|
|
4814
4848
|
return isLatLngCRS(getDatasetCRS(dataset));
|
|
4815
4849
|
}
|
|
@@ -4863,7 +4897,10 @@
|
|
|
4863
4897
|
requireDatasetsHaveCompatibleCRS: requireDatasetsHaveCompatibleCRS,
|
|
4864
4898
|
getScaleFactorAtXY: getScaleFactorAtXY,
|
|
4865
4899
|
isProjectedCRS: isProjectedCRS,
|
|
4900
|
+
isInvertibleCRS: isInvertibleCRS,
|
|
4866
4901
|
isLatLngCRS: isLatLngCRS,
|
|
4902
|
+
isWGS84: isWGS84,
|
|
4903
|
+
isWebMercator: isWebMercator,
|
|
4867
4904
|
isLatLngDataset: isLatLngDataset,
|
|
4868
4905
|
printProjections: printProjections,
|
|
4869
4906
|
translatePrj: translatePrj,
|
|
@@ -8357,8 +8394,8 @@
|
|
|
8357
8394
|
}
|
|
8358
8395
|
|
|
8359
8396
|
function getBoundsPrecisionForDisplay(bbox) {
|
|
8360
|
-
var w = bbox[2] - bbox[0],
|
|
8361
|
-
h = bbox[3] - bbox[1],
|
|
8397
|
+
var w = Math.abs(bbox[2] - bbox[0]),
|
|
8398
|
+
h = Math.abs(bbox[3] - bbox[1]),
|
|
8362
8399
|
range = Math.min(w, h) + 1e-8,
|
|
8363
8400
|
digits = 0;
|
|
8364
8401
|
while (range < 2000) {
|
|
@@ -29177,6 +29214,9 @@ ${svg}
|
|
|
29177
29214
|
} else if (dataType === null) {
|
|
29178
29215
|
// data field is empty
|
|
29179
29216
|
return null; // kludge
|
|
29217
|
+
} else if (dataType === undefined) {
|
|
29218
|
+
// no data field was given
|
|
29219
|
+
stop('Expected a data field to classify or the non-adjacent option');
|
|
29180
29220
|
} else {
|
|
29181
29221
|
stop('Unable to determine which classification method to use.');
|
|
29182
29222
|
}
|
|
@@ -34107,7 +34147,7 @@ ${svg}
|
|
|
34107
34147
|
isCentered = ['tmerc', 'etmerc'].includes(str);
|
|
34108
34148
|
proj4 = '+proj=' + str;
|
|
34109
34149
|
if (isConic2SP || isCentered) {
|
|
34110
|
-
bbox = getBBox(dataset);
|
|
34150
|
+
bbox = getBBox(dataset); // TODO: support projected datasets
|
|
34111
34151
|
decimals = getBoundsPrecisionForDisplay(bbox);
|
|
34112
34152
|
params = isCentered ? getCenterParams(bbox, decimals) : getConicParams(bbox, decimals);
|
|
34113
34153
|
proj4 += ' ' + params;
|
|
@@ -34312,14 +34352,17 @@ ${svg}
|
|
|
34312
34352
|
// old simplification data will not be optimal after reprojection;
|
|
34313
34353
|
// re-using for now to avoid error in web ui
|
|
34314
34354
|
zz = data.zz,
|
|
34355
|
+
z = arcs.getRetainedInterval(),
|
|
34315
34356
|
p;
|
|
34316
34357
|
|
|
34317
34358
|
for (var i=0, n=xx.length; i<n; i++) {
|
|
34318
34359
|
p = proj(xx[i], yy[i]);
|
|
34360
|
+
if (!p) error('Unprojectable point:', xx[i], yy[i]);
|
|
34319
34361
|
xx[i] = p[0];
|
|
34320
34362
|
yy[i] = p[1];
|
|
34321
34363
|
}
|
|
34322
34364
|
arcs.updateVertexData(data.nn, xx, yy, zz);
|
|
34365
|
+
arcs.setRetainedInterval(z);
|
|
34323
34366
|
}
|
|
34324
34367
|
|
|
34325
34368
|
function projectArcs2(arcs, proj) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.101",
|
|
4
4
|
"description": "A tool for editing vector datasets for mapping and GIS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapefile",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"/bin/**",
|
|
37
37
|
"/www/**",
|
|
38
|
+
"!/www/basemap.js",
|
|
38
39
|
"!/www/nacis/",
|
|
39
40
|
"/mapshaper.js",
|
|
40
41
|
"!.DS_Store"
|
|
Binary file
|
|
Binary file
|
package/www/index.html
CHANGED
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
<input type="text" value="label" class="clicktext" />
|
|
74
74
|
</div></div>
|
|
75
75
|
<div id="mode-buttons" class="page-header-buttons">
|
|
76
|
-
<span class="simplify-btn header-btn btn">Simplify</span><span class="separator"></span><span class="console-btn header-btn btn">Console</span><span class="separator"></span><span class="export-btn header-btn btn">Export</span>
|
|
76
|
+
<span class="basemap-btn header-btn btn">Basemap</span><span class="separator"></span><span class="simplify-btn header-btn btn">Simplify</span><span class="separator"></span><span class="console-btn header-btn btn">Console</span><span class="separator"></span><span class="export-btn header-btn btn">Export</span>
|
|
77
77
|
</div>
|
|
78
78
|
<div id="splash-buttons" class="page-header-buttons">
|
|
79
79
|
<a href="https://github.com/mbloch/mapshaper/wiki"><span id="wiki-btn" class="header-btn btn">Wiki</span></a><span class="separator"></span><a href="https://github.com/mbloch/mapshaper"><span id="github-btn" class="header-btn btn">GitHub</span></a>
|
|
@@ -148,6 +148,18 @@
|
|
|
148
148
|
</div>
|
|
149
149
|
</div>
|
|
150
150
|
|
|
151
|
+
<div class="basemap-options main-area popup-dialog">
|
|
152
|
+
<div class="info-box">
|
|
153
|
+
<h3>Basemap options</h3>
|
|
154
|
+
<p class="basemap-note">Your data will be displayed using the Mercator projection.</p>
|
|
155
|
+
<p class="basemap-warning"></p>
|
|
156
|
+
<div class="basemap-styles"></div>
|
|
157
|
+
<div>
|
|
158
|
+
<div class="close-btn btn dialog-btn">Close</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
|
|
151
163
|
<div class="simplify-options main-area popup-dialog">
|
|
152
164
|
<div class="info-box">
|
|
153
165
|
<h3>Simplification menu</h3>
|
|
@@ -280,6 +292,7 @@ interface. Examples: "no-topology"
|
|
|
280
292
|
<div class="repair-btn text-btn colored-text">Repair</div>
|
|
281
293
|
</div>
|
|
282
294
|
<div class="map-layers"></div>
|
|
295
|
+
<div class="basemap-container"><div class="basemap"></div></div>
|
|
283
296
|
</div>
|
|
284
297
|
</div>
|
|
285
298
|
|
|
@@ -287,6 +300,7 @@ interface. Examples: "no-topology"
|
|
|
287
300
|
<div class="drop-area"></div>
|
|
288
301
|
</div>
|
|
289
302
|
|
|
303
|
+
<script src="basemap.js" type="text/javascript"></script>
|
|
290
304
|
<script src="zip.js" type="text/javascript"></script>
|
|
291
305
|
<script src="modules.js" type="text/javascript"></script>
|
|
292
306
|
<script src="mapshaper.js" type="text/javascript"></script>
|