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/www/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
- arcs.updateVertexData(nn, xx2, yy2, null);
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 + 20) * 8), 0, n+1);
1804
- yy2 = new Float64Array(new ArrayBuffer((n + 20) * 8), 0, n+1);
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
- arcs.updateVertexData(nn, xx2, yy2, null);
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 = getProjInfo(P, getCRS('wgs84'));
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/www/page.css CHANGED
@@ -107,14 +107,19 @@ body {
107
107
  height: 29px;
108
108
  }
109
109
 
110
+ .basemap-on .coordinate-info {
111
+ left: 100px;
112
+ }
113
+
110
114
  .coordinate-info {
111
115
  z-index: 1;
112
116
  position: absolute;
113
- bottom: 6px;
114
- left: 6px;
117
+ bottom: 7px;
118
+ left: 7px;
115
119
  padding: 2px 5px 2px 5px;
116
120
  font-size: 11px;
117
121
  pointer-events: none;
122
+ background: rgba(255,255,255,0.4);
118
123
  }
119
124
 
120
125
  .mapshaper-logo {
@@ -977,8 +982,88 @@ img.close-btn:hover,
977
982
  height: 100%;
978
983
  }
979
984
 
985
+ .basemap-options {
986
+ pointer-events: none;
987
+ }
988
+
989
+ .basemap-options .info-box {
990
+ width: min-content;
991
+ pointer-events: initial;
992
+ }
993
+
994
+ .basemap-container {
995
+ z-index: -1;
996
+ position: absolute;
997
+ top: 0;
998
+ left: 0;
999
+ right: 0;
1000
+ bottom: 0;
1001
+ }
1002
+
1003
+ .basemap {
1004
+ display: none;
1005
+ position: relative;
1006
+ height: 100%;
1007
+ }
1008
+
1009
+ .info-box p {
1010
+ line-height: 1.2;
1011
+ font-size: 90%;
1012
+ }
1013
+
1014
+ .basemap-styles {
1015
+ white-space: nowrap;
1016
+ }
1017
+
1018
+ .basemap-warning {
1019
+ color: #cc0000;
1020
+ }
1021
+
1022
+ .basemap-prompt {
1023
+ width: 100%;
1024
+ text-align: center;
1025
+ z-index: -2;
1026
+ bottom: 8px;
1027
+ font-size: 22px;
1028
+ color: #aaa;
1029
+ position: absolute;
1030
+ }
1031
+
1032
+ .basemap-styles > div {
1033
+ display: inline-block;
1034
+ margin-bottom: 8px;
1035
+ }
1036
+
1037
+ .basemap-styles > div:nth-child(even) {
1038
+ position: relative;
1039
+ left: 6px;
1040
+ margin-left: 2px;
1041
+ }
1042
+
1043
+ .basemap-style-btn img {
1044
+ display: block;
1045
+ left: -3px;
1046
+ position: relative;
1047
+ border: 3px solid transparent;
1048
+ width: 120px;
1049
+ height: 90px;
1050
+ }
1051
+
1052
+ div.basemap-style-btn.active img {
1053
+ border: 3px solid #e8ba52;
1054
+ }
1055
+
1056
+ .basemap-style-btn:hover img {
1057
+ cursor: pointer;
1058
+ border: 3px solid #ead683;
1059
+ }
1060
+
1061
+ .mapbox-improve-map {
1062
+ display: none;
1063
+ }
1064
+
980
1065
  .mshp-main-map {
981
- background-color: #fff;
1066
+ /* background-color: #fff; */
982
1067
  }
983
1068
 
984
1069
  .map-layers.symbol-hit {
@@ -1067,7 +1152,7 @@ img.close-btn:hover,
1067
1152
  clear: right;
1068
1153
  white-space: nowrap;
1069
1154
  display: inline-block;
1070
- padding: 2px 7px 4px 7px;
1155
+ padding: 3px 7px 5px 7px;
1071
1156
  line-height: 11px;
1072
1157
  cursor: pointer;
1073
1158
  }