mapshaper 0.5.101 → 0.5.104

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 CHANGED
@@ -1,3 +1,12 @@
1
+ v0.5.104
2
+ * Improvements to the basemap feature.
3
+
4
+ v0.5.103
5
+ * Bug fixes
6
+
7
+ v0.5.102
8
+ * Fix for bug in -v/--version command.
9
+
1
10
  v0.5.101
2
11
  * Update dependency.
3
12
 
package/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.5.96";
3
+ var VERSION = "0.5.104";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -1191,24 +1191,37 @@
1191
1191
 
1192
1192
  var LOGGING = false;
1193
1193
  var STDOUT = false; // use stdout for status messages
1194
-
1195
- // These three functions can be reset by GUI using setLoggingFunctions();
1196
- var _error = function() {
1197
- var msg = utils.toArray(arguments).join(' ');
1198
- throw new Error(msg);
1199
- };
1200
-
1201
- var _stop = function() {
1202
- throw new UserError(formatLogArgs(arguments));
1203
- };
1194
+ var _error, _stop, _message;
1204
1195
 
1205
1196
  var _interrupt = function() {
1206
1197
  throw new NonFatalError(formatLogArgs(arguments));
1207
1198
  };
1208
1199
 
1209
- var _message = function() {
1210
- logArgs(arguments);
1211
- };
1200
+ setLoggingForCLI();
1201
+
1202
+ function getLoggingSetter() {
1203
+ var e = _error, s = _stop, m = _message;
1204
+ return function() {
1205
+ setLoggingFunctions(m, e, s);
1206
+ };
1207
+ }
1208
+
1209
+ function setLoggingForCLI() {
1210
+ function stop() {
1211
+ throw new UserError(formatLogArgs(arguments));
1212
+ }
1213
+
1214
+ function error() {
1215
+ var msg = utils.toArray(arguments).join(' ');
1216
+ throw new Error(msg);
1217
+ }
1218
+
1219
+ function message() {
1220
+ logArgs(arguments);
1221
+ }
1222
+
1223
+ setLoggingFunctions(message, error, stop);
1224
+ }
1212
1225
 
1213
1226
  function enableLogging() {
1214
1227
  LOGGING = true;
@@ -1357,6 +1370,8 @@
1357
1370
 
1358
1371
  var Logging = /*#__PURE__*/Object.freeze({
1359
1372
  __proto__: null,
1373
+ getLoggingSetter: getLoggingSetter,
1374
+ setLoggingForCLI: setLoggingForCLI,
1360
1375
  enableLogging: enableLogging,
1361
1376
  loggingEnabled: loggingEnabled,
1362
1377
  error: error,
@@ -4782,7 +4797,7 @@
4782
4797
  var info = dataset.info || {},
4783
4798
  P = info.crs;
4784
4799
  if (!P && info.prj) {
4785
- P = parsePrj(info.prj);
4800
+ P = getCRS(translatePrj(info.prj));
4786
4801
  }
4787
4802
  if (!P && probablyDecimalDegreeBounds(getDatasetBounds(dataset))) {
4788
4803
  // use wgs84 for probable latlong datasets with unknown datums
@@ -33173,7 +33188,6 @@ ${svg}
33173
33188
  return coords;
33174
33189
  }
33175
33190
 
33176
-
33177
33191
  function appendArr(dest, src) {
33178
33192
  for (var i=0; i<src.length; i++) dest.push(src[i]);
33179
33193
  }
@@ -33213,20 +33227,46 @@ ${svg}
33213
33227
  }
33214
33228
  }
33215
33229
 
33216
- function getDefaultDensifyInterval(arcs, proj) {
33217
- var xy = getAvgSegment2(arcs),
33218
- bb = arcs.getBounds(),
33219
- a = proj(bb.centerX(), bb.centerY()),
33220
- b = proj(bb.centerX() + xy[0], bb.centerY() + xy[1]),
33230
+ // Use the median of intervals computed by projecting segments.
33231
+ // We're probing a number of points, because @proj might only be valid in
33232
+ // a sub-region of the dataset bbox (e.g. +proj=tpers)
33233
+ function findDensifyInterval(bounds, xy, proj) {
33234
+ var steps = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
33235
+ var points = [];
33236
+ for (var i=0; i<steps.length; i++) {
33237
+ for (var j=0; j<steps.length; j++) {
33238
+ points.push([steps[i], steps[j]]);
33239
+ }
33240
+ }
33241
+ var intervals = points.map(function(pos) {
33242
+ var x = bounds.xmin + bounds.width() * pos[0];
33243
+ var y = bounds.ymin + bounds.height() * pos[1];
33244
+ var a = proj(x, y);
33245
+ var b = proj(x + xy[0], y + xy[1]);
33246
+ return a && b ? geom.distance2D(a[0], a[1], b[0], b[1]) : Infinity;
33247
+ }).filter(function(int) {return int < Infinity;});
33248
+ return intervals.length > 0 ? utils.findMedian(intervals) : Infinity;
33249
+ }
33250
+
33251
+ // Kludgy way to get a useful interval for densifying a bounding box.
33252
+ // Uses a fraction of average bbox side length)
33253
+ // TODO: improve
33254
+ function findDensifyInterval2(bb, proj) {
33255
+ var a = proj(bb.centerX(), bb.centerY()),
33221
33256
  c = proj(bb.centerX(), bb.ymin), // right center
33222
33257
  d = proj(bb.xmax, bb.centerY()); // bottom center
33223
- // interval A: based on average segment length
33224
- var intervalA = a && b ? geom.distance2D(a[0], a[1], b[0], b[1]) : Infinity;
33225
- // interval B: a fraction of avg bbox side length
33226
- // (added this for bbox densification)
33227
- var intervalB = c && d ? (geom.distance2D(a[0], a[1], c[0], c[1]) +
33258
+ var interval = a && c && d ? (geom.distance2D(a[0], a[1], c[0], c[1]) +
33228
33259
  geom.distance2D(a[0], a[1], d[0], d[1])) / 5000 : Infinity;
33229
- var interval = Math.min(intervalA, intervalB);
33260
+ return interval;
33261
+ }
33262
+
33263
+ // Returns an interval in projected units
33264
+ function getDefaultDensifyInterval(arcs, proj) {
33265
+ var xy = getAvgSegment2(arcs),
33266
+ bb = arcs.getBounds(),
33267
+ intervalA = findDensifyInterval(bb, xy, proj),
33268
+ intervalB = findDensifyInterval2(bb, proj),
33269
+ interval = Math.min(intervalA, intervalB);
33230
33270
  if (interval == Infinity) {
33231
33271
  error('Densification error');
33232
33272
  }
@@ -34857,8 +34897,6 @@ ${svg}
34857
34897
  return table + sepLine;
34858
34898
  }
34859
34899
 
34860
-
34861
-
34862
34900
  function maxChars(arr) {
34863
34901
  return arr.reduce(function(memo, str) {
34864
34902
  var w = stringDisplayWidth(str);
@@ -34899,6 +34937,12 @@ ${svg}
34899
34937
  } else {
34900
34938
  str = String(val);
34901
34939
  }
34940
+
34941
+ if (typeof str != 'string') {
34942
+ // e.g. JSON.stringify converts functions to undefined
34943
+ str = '[' + (typeof val) + ']';
34944
+ }
34945
+
34902
34946
  return str;
34903
34947
  }
34904
34948
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.5.101",
3
+ "version": "0.5.104",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
Binary file
Binary file