mapshaper 0.6.76 → 0.6.78

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 CHANGED
@@ -1537,7 +1537,6 @@
1537
1537
  this.xmax = c;
1538
1538
  this.ymax = d;
1539
1539
  if (a > c || b > d) this.update();
1540
- // error("Bounds#setBounds() min/max reversed:", a, b, c, d);
1541
1540
  return this;
1542
1541
  };
1543
1542
 
@@ -4279,6 +4278,10 @@
4279
4278
  return data;
4280
4279
  }
4281
4280
 
4281
+ function layerHasAttributeData(lyr) {
4282
+ return lyr.data && lyr.data.getFields().length > 0;
4283
+ }
4284
+
4282
4285
  function layerHasNonNullData(lyr) {
4283
4286
  return lyr.data && getFirstNonEmptyRecord(lyr.data.getRecords()) ? true : false;
4284
4287
  }
@@ -4552,6 +4555,7 @@
4552
4555
  __proto__: null,
4553
4556
  insertFieldValues: insertFieldValues,
4554
4557
  getLayerDataTable: getLayerDataTable,
4558
+ layerHasAttributeData: layerHasAttributeData,
4555
4559
  layerHasNonNullData: layerHasNonNullData,
4556
4560
  layerHasGeometry: layerHasGeometry,
4557
4561
  layerIsGeometric: layerIsGeometric,
@@ -5123,10 +5127,12 @@
5123
5127
  if (!P && info.prj) {
5124
5128
  P = parseCrsString(translatePrj(info.prj));
5125
5129
  }
5126
- if (!P && probablyDecimalDegreeBounds(getDatasetBounds(dataset))) {
5127
- // use wgs84 for probable latlong datasets with unknown datums
5128
- str = 'wgs84';
5129
- P = parseCrsString(str);
5130
+ if (!P) {
5131
+ if (probablyDecimalDegreeBounds(getDatasetBounds(dataset))) {
5132
+ // use wgs84 for probable latlong datasets with unknown datums
5133
+ str = 'wgs84';
5134
+ P = parseCrsString(str);
5135
+ }
5130
5136
  }
5131
5137
  return {
5132
5138
  crs: P || null,
@@ -7202,6 +7208,12 @@
7202
7208
  return bounds;
7203
7209
  }
7204
7210
 
7211
+ function datasetIsEmpty(dataset) {
7212
+ return dataset.layers.every(function(lyr) {
7213
+ return layerIsEmpty(lyr);
7214
+ });
7215
+ }
7216
+
7205
7217
  function datasetHasGeometry(dataset) {
7206
7218
  return utils.some(dataset.layers, function(lyr) {
7207
7219
  return layerHasGeometry(lyr);
@@ -7315,6 +7327,7 @@
7315
7327
  copyDatasetForExport: copyDatasetForExport,
7316
7328
  copyDatasetForRenaming: copyDatasetForRenaming,
7317
7329
  getDatasetBounds: getDatasetBounds,
7330
+ datasetIsEmpty: datasetIsEmpty,
7318
7331
  datasetHasGeometry: datasetHasGeometry,
7319
7332
  datasetHasPaths: datasetHasPaths,
7320
7333
  cleanupArcs: cleanupArcs,
@@ -13449,7 +13462,7 @@
13449
13462
  // range = Math.min(w, h) + 1e-8,
13450
13463
  range = Math.max(w, h) + 1e-8,
13451
13464
  digits = 0;
13452
- while (range < 2000) {
13465
+ while (range < 2000 && digits < 1) {
13453
13466
  range *= 10;
13454
13467
  digits++;
13455
13468
  }
@@ -18017,11 +18030,10 @@
18017
18030
  opts = utils.extend({}, opts);
18018
18031
  opts.rfc7946 = !opts.gj2008; // use RFC 7946 as the default
18019
18032
  var extension = opts.extension || "json";
18020
- var layerGroups, warn;
18033
+ var layerGroups;
18021
18034
 
18022
18035
  if (opts.rfc7946) {
18023
- warn = getRFC7946Warnings(dataset);
18024
- if (warn) message(warn);
18036
+ warnIfNotWgs84(dataset);
18025
18037
  }
18026
18038
 
18027
18039
  if (opts.file) {
@@ -18112,14 +18124,12 @@
18112
18124
  return feat;
18113
18125
  }
18114
18126
 
18115
- function getRFC7946Warnings(dataset) {
18127
+ function warnIfNotWgs84(dataset) {
18116
18128
  var P = getDatasetCRS(dataset);
18117
- var str;
18118
- if (!P || !isLatLngCRS(P)) {
18119
- str = 'RFC 7946 warning: non-WGS84 GeoJSON output.';
18120
- if (P) str += ' Tip: use "-proj wgs84" to convert.';
18121
- }
18122
- return str;
18129
+ if (P && isLatLngCRS(P) || datasetIsEmpty(dataset)) return;
18130
+ var str = 'RFC 7946 warning: non-WGS84 GeoJSON output.';
18131
+ if (P) str += ' Tip: use "-proj wgs84" to convert.';
18132
+ message(str);
18123
18133
  }
18124
18134
 
18125
18135
  function getDatasetBbox(dataset, rfc7946) {
@@ -18389,7 +18399,7 @@
18389
18399
  'default': GeoJSON,
18390
18400
  exportGeoJSON: exportGeoJSON,
18391
18401
  exportLayerAsGeoJSON: exportLayerAsGeoJSON,
18392
- getRFC7946Warnings: getRFC7946Warnings,
18402
+ warnIfNotWgs84: warnIfNotWgs84,
18393
18403
  getDatasetBbox: getDatasetBbox,
18394
18404
  exportDatasetAsGeoJSON: exportDatasetAsGeoJSON,
18395
18405
  preserveOriginalCRS: preserveOriginalCRS,
@@ -29352,7 +29362,7 @@ ${svg}
29352
29362
  // * In TopoJSON input, it makes sense to think of the last object/layer
29353
29363
  // as the topmost one -- it corresponds to the painter's algorithm and
29354
29364
  // the way that objects are ordered in SVG.
29355
- var lyr = targ.layers[targ.layers.length - 1];
29365
+ var lyr = targ?.layers[targ.layers.length - 1];
29356
29366
  return targ ? {layer: lyr, dataset: targ.dataset} : null;
29357
29367
  };
29358
29368
 
@@ -45136,7 +45146,7 @@ ${svg}
45136
45146
  opts.target, getFormattedLayerList(job.catalog)));
45137
45147
  }
45138
45148
  if (!commandAcceptsEmptyTarget(name)) {
45139
- throw new UserError("No data is available");
45149
+ stop("No data is available");
45140
45150
  }
45141
45151
  }
45142
45152
 
@@ -45522,7 +45532,7 @@ ${svg}
45522
45532
  });
45523
45533
  }
45524
45534
 
45525
- var version = "0.6.76";
45535
+ var version = "0.6.78";
45526
45536
 
45527
45537
  // Parse command line args into commands and run them
45528
45538
  // 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.6.76",
3
+ "version": "0.6.78",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/index.html CHANGED
@@ -76,7 +76,7 @@
76
76
  <input type="text" value="label" class="clicktext" />
77
77
  </div></div>
78
78
  <div id="mode-buttons" class="page-header-buttons">
79
- <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>
79
+ <span class="console-btn header-btn btn">Console</span><span class="basemap-btn header-btn btn">Basemap</span><span class="separator"></span><span class="separator"></span><span class="simplify-btn header-btn btn">Simplify</span><span class="separator"></span><span class="export-btn header-btn btn">Export</span>
80
80
  </div>
81
81
  <div id="splash-buttons" class="page-header-buttons">
82
82
  <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>
@@ -98,11 +98,14 @@
98
98
  <div class="pin-all pinnable">
99
99
  <img class="eye-btn black-eye" src="images/eye.png">
100
100
  <img class="eye-btn green-eye" src="images/eye2.png">
101
- </div>
101
+ </div>
102
102
  <div class="layer-list"></div>
103
103
  <!-- <h4>Sources</h4> -->
104
- <h4>Source files</h4>
105
- <div class="file-list"></div>
104
+ <div class="no-layer-note">No data has been added</div>
105
+ <div class="source-file-section">
106
+ <h4>Source files</h4>
107
+ <div class="file-list"></div>
108
+ </div>
106
109
  <div>
107
110
  <div id="add-file-btn" class="dialog-btn btn">Add files</div>
108
111
  <div id="add-empty-btn" class="dialog-btn btn">Add empty layer</div>
@@ -143,14 +146,13 @@
143
146
  <div class="info-box">
144
147
  <div class="close2-btn"></div>
145
148
  <h3>Export options</h3>
146
- <div style="height:3px"></div>
147
149
  <div class=export-layers>
148
150
  <h4 class="menu-title">Layers</h4>
149
151
  <div class="export-layer-list option-menu"></div>
150
152
  </div>
151
153
  <div class="export-zip-option option-menu">
152
154
 
153
- <div style="height:10px"></div>
155
+ <div style="height:6px"></div>
154
156
 
155
157
  </div>
156
158
  <h4>File format</h4>
@@ -166,7 +168,6 @@
166
168
  the -o command. Examples: bbox no-quantization
167
169
  precision=0.001. Click to see all options.</div></div></div></a>
168
170
 
169
-
170
171
  <!-- <div class="option-menu">
171
172
  <input id="ofile-name" class="text-input" type="text" placeholder="output file name" />
172
173
  </div> -->
@@ -246,55 +247,41 @@ a smoother appearance.</div></div></div></div>
246
247
  </div> <!-- .info-box -->
247
248
  </div> <!-- simplify-options -->
248
249
 
249
- <div id="splash-screen" class="main-area">
250
- <div>
251
- <h3 id="splash-screen-blurb">Mapshaper is an editor for map data</h3>
252
- </div>
253
- <div id="drop-areas" class="drop-area-wrapper main-area">
254
-
255
- <div class="file-catalog catalog-area">
256
- </div>
257
- <div class="file-catalog-spacer spacer"></div>
258
-
259
- <div id="import-drop" class="drop-area">
260
- <h4>Drop or paste files here or <span class="inline-btn btn" id="file-selection-btn"><span class="label-text">select</span></span> from a folder</h4>
261
- <div class="subtitle">Shapefile, GeoJSON, TopoJSON, KML and CSV files are supported</div>
262
- <div class="subtitle">Files can be gzipped or in a zip archive</div>
263
- </div>
264
- <div class="spacer"></div>
265
- <div id="import-quick-drop" class="drop-area">
266
- <h4>Quick import</h4>
267
- <div class="subtitle">Drop or paste files here to import with default settings</div>
268
- </div>
269
- </div>
270
- </div>
271
-
272
250
  <div id="import-options" class="main-area popup-dialog">
273
251
  <div class="info-box">
274
- <h3 class="list-header">Files</h3>
275
-
276
- <div class="dropped-file-list"></div>
277
-
278
- <div class="option-menu">
279
-
280
- <div id="path-import-options">
281
- <h4>Options</h4>
252
+ <div class="cancel-btn close2-btn"></div>
253
+ <h3 class="list-header">Import files</h3>
254
+ <div class="import-instructions">
255
+ <span><input type="checkbox" class="advanced-import-options" />with advanced options</span>
256
+ <div class="mini-drop-area">
257
+ <div class="subtitle">Drop, paste or <span class="add-btn inline-btn btn"><span class="label-text">select</span></span> files to import.</div>
258
+ <div class="subtitle">Shapefile, GeoJSON, TopoJSON, KML and CSV formats are supported. Files can be zipped or gzipped.</div>
259
+ </div>
282
260
  </div>
261
+ <div class="queued-file-section">
262
+ <!-- <h4>Files</h4> -->
263
+ <div class="dropped-file-list"></div>
264
+
265
+ <div class="option-menu">
283
266
 
284
- <div><input type="text" class="text-input advanced-options" placeholder="command line import options" />
285
- <a href="https://github.com/mbloch/mapshaper/wiki/Command-Reference#-i-input" target="_mapshaper_import_docs">
286
- <div class="tip-button">?<div class="tip-anchor">
287
- <div class="tip">Enter options from the command line
267
+ <div id="path-import-options">
268
+ <!-- <h4>Options</h4> -->
269
+ </div>
270
+
271
+ <div style="margin-top: 10px"><input type="text" class="text-input advanced-options" placeholder="import options" />
272
+ <a href="https://github.com/mbloch/mapshaper/wiki/Command-Reference#-i-input" target="_mapshaper_import_docs">
273
+ <div class="tip-button">?<div class="tip-anchor">
274
+ <div class="tip">Enter options from the command line
288
275
  interface. Examples: <span id="import-option-examples">snap no-topology
289
276
  encoding=big5</span>. Click to see all options.</div></div></div></div>
290
- </a>
277
+ </a>
291
278
 
292
- </div>
279
+ </div>
280
+
281
+ <!-- <div class="cancel-btn btn dialog-btn">Cancel</div>
282
+ <div class="add-btn btn dialog-btn">Select</div> -->
283
+ <div class="submit-btn btn dialog-btn default-btn disabled">Submit</div>
293
284
 
294
- <div id="import-buttons">
295
- <div class="cancel-btn btn dialog-btn">Cancel</div>
296
- <div class="add-btn btn dialog-btn">Select</div>
297
- <div class="submit-btn btn dialog-btn default-btn">Import</div>
298
285
  </div>
299
286
 
300
287
  </div> <!-- .info-box -->