mapshaper 0.7.17 → 0.7.19
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 +110 -28
- package/package.json +2 -2
- package/www/index.html +3 -3
- package/www/mapshaper-gui.js +2650 -1301
- package/www/mapshaper.js +110 -28
- package/www/page.css +250 -8
package/mapshaper.js
CHANGED
|
@@ -18650,14 +18650,14 @@
|
|
|
18650
18650
|
var labelPositionFields = ['label-pos', 'dx', 'dy', 'text-anchor'];
|
|
18651
18651
|
|
|
18652
18652
|
var labelPositionStyles = {
|
|
18653
|
-
n: {dx: 0, dy: '-0.
|
|
18654
|
-
s: {dx: 0, dy: '1.
|
|
18655
|
-
e: {dx: '0.
|
|
18656
|
-
w: {dx: '-0.
|
|
18657
|
-
ne: {dx: '0.
|
|
18658
|
-
se: {dx: '0.
|
|
18659
|
-
nw: {dx: '-0.
|
|
18660
|
-
sw: {dx: '-0.
|
|
18653
|
+
n: {dx: 0, dy: '-0.5em', 'text-anchor': 'middle'},
|
|
18654
|
+
s: {dx: 0, dy: '1.1em', 'text-anchor': 'middle'},
|
|
18655
|
+
e: {dx: '0.45em', dy: '0.23em', 'text-anchor': 'start'},
|
|
18656
|
+
w: {dx: '-0.45em', dy: '0.23em', 'text-anchor': 'end'},
|
|
18657
|
+
ne: {dx: '0.4em', dy: '-0.15em', 'text-anchor': 'start'},
|
|
18658
|
+
se: {dx: '0.4em', dy: '0.7em', 'text-anchor': 'start'},
|
|
18659
|
+
nw: {dx: '-0.4em', dy: '-0.15em', 'text-anchor': 'end'},
|
|
18660
|
+
sw: {dx: '-0.4em', dy: '0.7em', 'text-anchor': 'end'},
|
|
18661
18661
|
c: {dx: 0, dy: '0.25em', 'text-anchor': 'middle'}
|
|
18662
18662
|
};
|
|
18663
18663
|
|
|
@@ -19880,7 +19880,7 @@
|
|
|
19880
19880
|
function exportSVG(dataset, opts) {
|
|
19881
19881
|
var namespace = 'xmlns="http://www.w3.org/2000/svg"';
|
|
19882
19882
|
var defs = [];
|
|
19883
|
-
var frame, svg, layers, metadataJSON;
|
|
19883
|
+
var frame, svg, layers, metadataJSON, files, svgFile;
|
|
19884
19884
|
var style = '';
|
|
19885
19885
|
|
|
19886
19886
|
// kludge for map keys
|
|
@@ -19901,6 +19901,8 @@
|
|
|
19901
19901
|
// use invert_y: 0 setting for screen coordinates and geojson polygon generation
|
|
19902
19902
|
// use 1px default margin so typical strokes don't get cut off on the sides
|
|
19903
19903
|
opts = Object.assign({invert_y: true, margin: "1"}, opts);
|
|
19904
|
+
opts.svg_image_files = [];
|
|
19905
|
+
opts.svg_file_base = getSvgFileBase(dataset, opts);
|
|
19904
19906
|
frame = getFrameData(dataset, opts);
|
|
19905
19907
|
fitDatasetToFrame(dataset, frame);
|
|
19906
19908
|
setCoordinatePrecision(dataset, opts.precision || 0.01);
|
|
@@ -19953,10 +19955,17 @@
|
|
|
19953
19955
|
${svg}
|
|
19954
19956
|
</svg>`;
|
|
19955
19957
|
svg = utils.format(template, frame.width, frame.height, 0, 0, frame.width, frame.height);
|
|
19956
|
-
|
|
19958
|
+
svgFile = {
|
|
19957
19959
|
content: svg,
|
|
19958
19960
|
filename: opts.file || getOutputFileBase(dataset) + '.svg'
|
|
19959
|
-
}
|
|
19961
|
+
};
|
|
19962
|
+
files = [svgFile].concat(opts.svg_image_files);
|
|
19963
|
+
return files;
|
|
19964
|
+
}
|
|
19965
|
+
|
|
19966
|
+
function getSvgFileBase(dataset, opts) {
|
|
19967
|
+
var file = opts.file || getOutputFileBase(dataset) + '.svg';
|
|
19968
|
+
return file.replace(/\.svg$/i, '');
|
|
19960
19969
|
}
|
|
19961
19970
|
|
|
19962
19971
|
function getMetadataBlock(metadataJSON, viewBox) {
|
|
@@ -20047,7 +20056,9 @@ ${svg}
|
|
|
20047
20056
|
layerObj.children = [];
|
|
20048
20057
|
return layerObj;
|
|
20049
20058
|
}
|
|
20050
|
-
href =
|
|
20059
|
+
href = opts.linked_images ?
|
|
20060
|
+
exportLinkedRasterPreview(rendered.preview, opts) :
|
|
20061
|
+
encodeRasterPreview(rendered.preview, opts);
|
|
20051
20062
|
layerObj.children = [{
|
|
20052
20063
|
tag: 'image',
|
|
20053
20064
|
properties: {
|
|
@@ -20121,6 +20132,30 @@ ${svg}
|
|
|
20121
20132
|
return 'data:image/' + format + ';base64,' + data;
|
|
20122
20133
|
}
|
|
20123
20134
|
|
|
20135
|
+
function exportLinkedRasterPreview(preview, opts) {
|
|
20136
|
+
var format = getSvgRasterFormat(preview, opts);
|
|
20137
|
+
var data = format == 'png' ? encodePng(preview) : encodeJpeg(preview, opts);
|
|
20138
|
+
var ext = format == 'jpeg' ? 'jpg' : format;
|
|
20139
|
+
var filename = opts.svg_file_base + '-image-' + (opts.svg_image_files.length + 1) + '.' + ext;
|
|
20140
|
+
opts.svg_image_files.push({
|
|
20141
|
+
filename: filename,
|
|
20142
|
+
content: base64ToBytes(data)
|
|
20143
|
+
});
|
|
20144
|
+
return filename;
|
|
20145
|
+
}
|
|
20146
|
+
|
|
20147
|
+
function base64ToBytes(str) {
|
|
20148
|
+
if (typeof Buffer != 'undefined') {
|
|
20149
|
+
return Buffer.from(str, 'base64');
|
|
20150
|
+
}
|
|
20151
|
+
var bin = atob(str);
|
|
20152
|
+
var bytes = new Uint8Array(bin.length);
|
|
20153
|
+
for (var i = 0; i < bin.length; i++) {
|
|
20154
|
+
bytes[i] = bin.charCodeAt(i);
|
|
20155
|
+
}
|
|
20156
|
+
return bytes;
|
|
20157
|
+
}
|
|
20158
|
+
|
|
20124
20159
|
function getSvgRasterFormat(preview, opts) {
|
|
20125
20160
|
var fmt = opts.svg_raster_format || opts.raster_format || null;
|
|
20126
20161
|
if (fmt) return fmt == 'jpg' ? 'jpeg' : fmt;
|
|
@@ -20136,11 +20171,11 @@ ${svg}
|
|
|
20136
20171
|
}
|
|
20137
20172
|
|
|
20138
20173
|
function encodeJpeg(preview, opts) {
|
|
20174
|
+
var quality = getJpegQuality(opts);
|
|
20139
20175
|
if (runningInBrowser() && typeof document != 'undefined') {
|
|
20140
|
-
return encodeWithCanvas(preview, 'image/jpeg',
|
|
20176
|
+
return encodeWithCanvas(preview, 'image/jpeg', quality / 100);
|
|
20141
20177
|
}
|
|
20142
20178
|
var jpeg = require$1('jpeg-js');
|
|
20143
|
-
var quality = Math.round((opts.svg_raster_quality || 0.85) * 100);
|
|
20144
20179
|
return Buffer.from(jpeg.encode({
|
|
20145
20180
|
data: Buffer.from(preview.pixels),
|
|
20146
20181
|
width: preview.width,
|
|
@@ -20148,6 +20183,14 @@ ${svg}
|
|
|
20148
20183
|
}, quality).data).toString('base64');
|
|
20149
20184
|
}
|
|
20150
20185
|
|
|
20186
|
+
function getJpegQuality(opts) {
|
|
20187
|
+
var quality = opts.jpeg_quality == null ? 85 : opts.jpeg_quality;
|
|
20188
|
+
if ((quality >= 1 && quality <= 100) === false) {
|
|
20189
|
+
stop$1('jpeg-quality= option should be a number from 1 to 100');
|
|
20190
|
+
}
|
|
20191
|
+
return Math.round(quality);
|
|
20192
|
+
}
|
|
20193
|
+
|
|
20151
20194
|
function encodePng(preview) {
|
|
20152
20195
|
if (runningInBrowser() && typeof document != 'undefined') {
|
|
20153
20196
|
return encodeWithCanvas(preview, 'image/png');
|
|
@@ -29002,6 +29045,10 @@ ${svg}
|
|
|
29002
29045
|
if ('topojson_precision' in o && o.topojson_precision > 0 === false) {
|
|
29003
29046
|
error('topojson-precision= option should be a positive number');
|
|
29004
29047
|
}
|
|
29048
|
+
|
|
29049
|
+
if ('jpeg_quality' in o && (o.jpeg_quality >= 1 && o.jpeg_quality <= 100) === false) {
|
|
29050
|
+
error('jpeg-quality= option should be a number from 1 to 100');
|
|
29051
|
+
}
|
|
29005
29052
|
}
|
|
29006
29053
|
|
|
29007
29054
|
var assignmentRxp = /^([a-z0-9_+-]+)=(?!=)(.*)$/i; // exclude ==
|
|
@@ -30408,6 +30455,14 @@ ${svg}
|
|
|
30408
30455
|
describe: '[SVG] raster pixels per SVG pixel (default is 1)',
|
|
30409
30456
|
type: 'number'
|
|
30410
30457
|
})
|
|
30458
|
+
.option('linked-images', {
|
|
30459
|
+
describe: '[SVG] link raster images as external files',
|
|
30460
|
+
type: 'flag'
|
|
30461
|
+
})
|
|
30462
|
+
.option('jpeg-quality', {
|
|
30463
|
+
describe: '[SVG] JPEG quality for raster images, 1-100 (default is 85)',
|
|
30464
|
+
type: 'number'
|
|
30465
|
+
})
|
|
30411
30466
|
.option('fit-extent', {
|
|
30412
30467
|
describe: '[SVG] layer to use for the map extent'
|
|
30413
30468
|
})
|
|
@@ -31432,6 +31487,10 @@ ${svg}
|
|
|
31432
31487
|
.option('nodata-color', {
|
|
31433
31488
|
describe: '[raster] color for uncovered pixels after reprojection'
|
|
31434
31489
|
})
|
|
31490
|
+
.option('background', {
|
|
31491
|
+
describe: '[raster] alias for nodata-color',
|
|
31492
|
+
alias_to: 'nodata-color'
|
|
31493
|
+
})
|
|
31435
31494
|
.option('resampling', {
|
|
31436
31495
|
describe: '[raster] nearest or bilinear (default is bilinear)'
|
|
31437
31496
|
})
|
|
@@ -31667,6 +31726,10 @@ ${svg}
|
|
|
31667
31726
|
type: 'flag'
|
|
31668
31727
|
})
|
|
31669
31728
|
.option('where', whereOpt)
|
|
31729
|
+
.option('ids', {
|
|
31730
|
+
describe: 'comma-sep. list of feature ids to style',
|
|
31731
|
+
type: 'numbers'
|
|
31732
|
+
})
|
|
31670
31733
|
.option('class', {
|
|
31671
31734
|
describe: 'name of CSS class or classes (space-separated)'
|
|
31672
31735
|
})
|
|
@@ -44077,7 +44140,17 @@ ${svg}
|
|
|
44077
44140
|
return utils.pickOne(schemes) || 'Tableau20';
|
|
44078
44141
|
}
|
|
44079
44142
|
|
|
44080
|
-
function
|
|
44143
|
+
function randomRotateArr(arr) {
|
|
44144
|
+
var n = Math.floor(Math.random() * arr.length);
|
|
44145
|
+
return arr.slice(-n).concat(arr.slice(0, -n));
|
|
44146
|
+
}
|
|
44147
|
+
|
|
44148
|
+
function getRandomizedCategoricalColorScheme(n) {
|
|
44149
|
+
var name = pickRandomCategoricalScheme(n);
|
|
44150
|
+
return getCategoricalColorScheme(name, n, true);
|
|
44151
|
+
}
|
|
44152
|
+
|
|
44153
|
+
function getCategoricalColorScheme(name, n, randomized) {
|
|
44081
44154
|
var colors;
|
|
44082
44155
|
initSchemes();
|
|
44083
44156
|
name = standardName(name);
|
|
@@ -44092,7 +44165,11 @@ ${svg}
|
|
|
44092
44165
|
// stop(name, 'does not contain', n, 'colors');
|
|
44093
44166
|
message('Color scheme has', colors.length, 'colors. Using duplication to match', n, 'categories.');
|
|
44094
44167
|
colors = wrapColors(colors, n);
|
|
44095
|
-
}
|
|
44168
|
+
}
|
|
44169
|
+
if (randomized) {
|
|
44170
|
+
colors = randomRotateArr(colors);
|
|
44171
|
+
}
|
|
44172
|
+
if (n < colors.length) {
|
|
44096
44173
|
colors = colors.slice(0, n);
|
|
44097
44174
|
}
|
|
44098
44175
|
return colors;
|
|
@@ -44183,7 +44260,7 @@ ${svg}
|
|
|
44183
44260
|
|
|
44184
44261
|
if (colorArg == 'random') {
|
|
44185
44262
|
if (categorical) {
|
|
44186
|
-
|
|
44263
|
+
return getRandomizedCategoricalColorScheme(n);
|
|
44187
44264
|
} else {
|
|
44188
44265
|
colorScheme = pickRandomColorScheme('sequential');
|
|
44189
44266
|
}
|
|
@@ -51092,7 +51169,7 @@ ${svg}
|
|
|
51092
51169
|
bbox = opts.output_bbox || opts.outputBbox || getProjectedMeshBBox(mesh);
|
|
51093
51170
|
if (!bbox) stop$1('Unable to project raster layer');
|
|
51094
51171
|
outSize = getOutputGridSize(grid, bbox, opts);
|
|
51095
|
-
outGrid = createProjectedRasterGrid(grid, bbox, outSize.width, outSize.height, opts);
|
|
51172
|
+
outGrid = createProjectedRasterGrid(grid, raster, bbox, outSize.width, outSize.height, opts);
|
|
51096
51173
|
timeStart(timing, 'rasterize');
|
|
51097
51174
|
rasterizeProjectedMesh(grid, outGrid, mesh, getRasterProjectionSampleMethod(raster, opts));
|
|
51098
51175
|
timeEnd(timing, 'rasterize');
|
|
@@ -51361,13 +51438,13 @@ ${svg}
|
|
|
51361
51438
|
return xmin < Infinity && xmax > xmin && ymax > ymin ? [xmin, ymin, xmax, ymax] : null;
|
|
51362
51439
|
}
|
|
51363
51440
|
|
|
51364
|
-
function createProjectedRasterGrid(grid, bbox, widthArg, heightArg, opts) {
|
|
51441
|
+
function createProjectedRasterGrid(grid, raster, bbox, widthArg, heightArg, opts) {
|
|
51365
51442
|
var width = widthArg || grid.width;
|
|
51366
51443
|
var height = heightArg || grid.height;
|
|
51367
|
-
var bands = getOutputBandCount(grid, opts);
|
|
51444
|
+
var bands = getOutputBandCount(grid, raster, opts);
|
|
51368
51445
|
var samples = new grid.samples.constructor(width * height * bands);
|
|
51369
51446
|
var coverage = new Uint8Array(width * height);
|
|
51370
|
-
fillProjectedRasterSamples(samples, bands, grid, opts || {});
|
|
51447
|
+
fillProjectedRasterSamples(samples, bands, grid, raster, opts || {});
|
|
51371
51448
|
return Object.assign({}, grid, {
|
|
51372
51449
|
width: width,
|
|
51373
51450
|
height: height,
|
|
@@ -51404,13 +51481,13 @@ ${svg}
|
|
|
51404
51481
|
return {width: width, height: height};
|
|
51405
51482
|
}
|
|
51406
51483
|
|
|
51407
|
-
function getOutputBandCount(grid, opts) {
|
|
51408
|
-
var color = getNoDataColor(opts);
|
|
51484
|
+
function getOutputBandCount(grid, raster, opts) {
|
|
51485
|
+
var color = getNoDataColor(raster, opts);
|
|
51409
51486
|
return color && color.a === 0 && grid.bands > 1 && grid.bands < 4 ? 4 : grid.bands;
|
|
51410
51487
|
}
|
|
51411
51488
|
|
|
51412
|
-
function fillProjectedRasterSamples(samples, bands, grid, opts) {
|
|
51413
|
-
var color = getNoDataColor(opts);
|
|
51489
|
+
function fillProjectedRasterSamples(samples, bands, grid, raster, opts) {
|
|
51490
|
+
var color = getNoDataColor(raster, opts);
|
|
51414
51491
|
var noData = grid.nodata;
|
|
51415
51492
|
if (color) {
|
|
51416
51493
|
fillProjectedRasterColor(samples, bands, color);
|
|
@@ -51420,10 +51497,12 @@ ${svg}
|
|
|
51420
51497
|
samples.fill(noData);
|
|
51421
51498
|
}
|
|
51422
51499
|
|
|
51423
|
-
function getNoDataColor(opts) {
|
|
51500
|
+
function getNoDataColor(raster, opts) {
|
|
51424
51501
|
var arg = opts.nodata_color || opts.nodataColor;
|
|
51425
51502
|
var color;
|
|
51426
|
-
if (arg == null || arg === '')
|
|
51503
|
+
if (arg == null || arg === '') {
|
|
51504
|
+
return rasterAppearsCategorical(raster) ? null : {r: 255, g: 255, b: 255, a: 1};
|
|
51505
|
+
}
|
|
51427
51506
|
if (String(arg).toLowerCase() == 'transparent') {
|
|
51428
51507
|
return {r: 0, g: 0, b: 0, a: 0};
|
|
51429
51508
|
}
|
|
@@ -56697,6 +56776,9 @@ ${svg}
|
|
|
56697
56776
|
if (opts.where) {
|
|
56698
56777
|
filterFn = compileFeatureExpression(opts.where, lyr, dataset.arcs);
|
|
56699
56778
|
}
|
|
56779
|
+
if (opts.ids) {
|
|
56780
|
+
filterFn = combineFilters(filterFn, getIdFilter(opts.ids));
|
|
56781
|
+
}
|
|
56700
56782
|
if (opts.clear) {
|
|
56701
56783
|
lyr.data.getFields().filter(isSupportedSvgStyleProperty).forEach(lyr.data.deleteField, lyr.data);
|
|
56702
56784
|
}
|
|
@@ -58248,7 +58330,7 @@ ${svg}
|
|
|
58248
58330
|
});
|
|
58249
58331
|
}
|
|
58250
58332
|
|
|
58251
|
-
var version = "0.7.
|
|
58333
|
+
var version = "0.7.19";
|
|
58252
58334
|
|
|
58253
58335
|
// Parse command line args into commands and run them
|
|
58254
58336
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapshaper",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "A tool for editing
|
|
3
|
+
"version": "0.7.19",
|
|
4
|
+
"description": "A tool for editing geospatial data for mapping and GIS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapefile",
|
|
7
7
|
"topojson",
|
package/www/index.html
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</svg>
|
|
49
49
|
|
|
50
50
|
<svg id="text-tool-icon" xmlns="http://www.w3.org/2000/svg" width="15" height="22" viewBox="0 0 15 22">
|
|
51
|
-
<path d="M13.4125,6.1758c-.0735,0-.1704.0087-.3023.0225-.35.0418-1.1581.0841-1.6018.0841H3.4416c-.4199,0-1.2035-.0418-1.5848-.0845-.1272-.0133-.2242-.022-.2977-.022-.5733,0-.5733.5104-.5733.678v3.8421h.9614c.8167,0,1.1245-.4428,1.2361-.7083.43-1.0372.9151-1.2196,1.775-1.2196h.
|
|
51
|
+
<path d="M13.4125,6.1758c-.0735,0-.1704.0087-.3023.0225-.35.0418-1.1581.0841-1.6018.0841H3.4416c-.4199,0-1.2035-.0418-1.5848-.0845-.1272-.0133-.2242-.022-.2977-.022-.5733,0-.5733.5104-.5733.678v3.8421h.9614c.8167,0,1.1245-.4428,1.2361-.7083.43-1.0372.9151-1.2196,1.775-1.2196h.6348v9.7486c0,.3918-.0528.4281-.463.7111l-.0919.0634c-.4874.3427-.6362.5765-.6362,1.0014v1.1346h6.1463v-1.1346c0-.4222-.1617-.6753-.6992-1.0441-.435-.3023-.4708-.3266-.4708-.7318v-9.7486h.6353c.8439,0,1.3253.1833,1.7754,1.2205.1851.4428.6307.7074,1.1925.7074h1.0042v-3.8421c0-.1677,0-.678-.5733-.678Z"/>
|
|
52
52
|
</svg>
|
|
53
53
|
|
|
54
54
|
<!-- adjusted height -->
|
|
@@ -375,8 +375,8 @@ encoding=big5</span>. Click to see all options.</div></div></div>
|
|
|
375
375
|
</div>
|
|
376
376
|
<div class="mshp-main-map main-area map-area">
|
|
377
377
|
<div class="intersection-display">
|
|
378
|
-
<span class="intersection-count">0 line intersections</span
|
|
379
|
-
<
|
|
378
|
+
<span class="intersection-count">0 line intersections</span>
|
|
379
|
+
<span class="repair-btn text-btn colored-text">repair</span>
|
|
380
380
|
</div>
|
|
381
381
|
<div class="basemap-overlay-buttons basemap-buttons"></div>
|
|
382
382
|
<div class="map-layers"></div>
|