mapshaper 0.6.33 → 0.6.34
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 +36 -6
- package/package.json +1 -1
- package/www/mapshaper.js +36 -6
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.34";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -18213,6 +18213,7 @@
|
|
|
18213
18213
|
dy: 'measure',
|
|
18214
18214
|
fill: 'color',
|
|
18215
18215
|
'fill-pattern': 'pattern',
|
|
18216
|
+
'fill-effect': null, // todo: validate effect names
|
|
18216
18217
|
'font-family': null,
|
|
18217
18218
|
'font-size': null,
|
|
18218
18219
|
'font-style': null,
|
|
@@ -18261,7 +18262,7 @@
|
|
|
18261
18262
|
var commonProperties = 'css,class,opacity,stroke,stroke-width,stroke-dasharray,stroke-opacity,fill-opacity,vector-effect'.split(',');
|
|
18262
18263
|
|
|
18263
18264
|
var propertiesBySymbolType = {
|
|
18264
|
-
polygon: utils.arrayToIndex(commonProperties.concat('fill', 'fill-pattern')),
|
|
18265
|
+
polygon: utils.arrayToIndex(commonProperties.concat('fill', 'fill-pattern', 'fill-effect')),
|
|
18265
18266
|
polyline: utils.arrayToIndex(commonProperties.concat('stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit')),
|
|
18266
18267
|
point: utils.arrayToIndex(commonProperties.concat('fill', 'r')),
|
|
18267
18268
|
label: utils.arrayToIndex(commonProperties.concat(
|
|
@@ -19146,6 +19147,9 @@
|
|
|
19146
19147
|
if (obj.tag == 'path' && obj.properties['fill-pattern']) {
|
|
19147
19148
|
convertFillPattern(obj.properties, defs);
|
|
19148
19149
|
}
|
|
19150
|
+
if (obj.tag == 'path' && obj.properties['fill-effect'] == 'sphere') {
|
|
19151
|
+
convertSphereEffect(obj.properties, defs);
|
|
19152
|
+
}
|
|
19149
19153
|
if (obj.tag == 'image') {
|
|
19150
19154
|
if (/\.svg/.test(obj.properties.href || '')) {
|
|
19151
19155
|
convertSvgImage(obj, defs);
|
|
@@ -19156,6 +19160,25 @@
|
|
|
19156
19160
|
}
|
|
19157
19161
|
}
|
|
19158
19162
|
|
|
19163
|
+
function convertSphereEffect(obj, defs) {
|
|
19164
|
+
var id = 'mapshaper_sphere_effect';
|
|
19165
|
+
var href = `url(#${ id })`;
|
|
19166
|
+
var svg =
|
|
19167
|
+
`<radialGradient id="${id}" cx="0.5" cy="0.5" r=".56" fx="0.4" fy="0.35">
|
|
19168
|
+
<stop offset=".35" stop-opacity="0"/>
|
|
19169
|
+
<stop offset=".65" stop-opacity="0.1" />
|
|
19170
|
+
<stop offset=".85" stop-opacity="0.45" />
|
|
19171
|
+
<stop offset=".95" stop-opacity="1" />
|
|
19172
|
+
</radialGradient>` ;
|
|
19173
|
+
if (!utils.find(defs, function(o) { return o.id == id; })) {
|
|
19174
|
+
defs.push({svg, id, href});
|
|
19175
|
+
}
|
|
19176
|
+
obj.fill = href;
|
|
19177
|
+
if ('opacity' in obj === false && 'fill-opacity' in obj === false) {
|
|
19178
|
+
obj['fill-opacity'] = 0.35;
|
|
19179
|
+
}
|
|
19180
|
+
}
|
|
19181
|
+
|
|
19159
19182
|
function convertSvgImage(obj, defs) {
|
|
19160
19183
|
// Same-origin policy prevents embedding images in the web UI
|
|
19161
19184
|
var href = obj.properties.href;
|
|
@@ -23917,7 +23940,9 @@ ${svg}
|
|
|
23917
23940
|
.option('polygon', {
|
|
23918
23941
|
describe: 'create a polygon to match the outline of the graticule',
|
|
23919
23942
|
type: 'flag'
|
|
23920
|
-
})
|
|
23943
|
+
})
|
|
23944
|
+
.option('name', nameOpt);
|
|
23945
|
+
|
|
23921
23946
|
|
|
23922
23947
|
parser.command('grid')
|
|
23923
23948
|
.describe('create a grid of square or hexagonal polygons')
|
|
@@ -24447,6 +24472,9 @@ ${svg}
|
|
|
24447
24472
|
.option('fill-pattern', {
|
|
24448
24473
|
describe: 'pattern fill, ex: "hatches 2px grey 2px blue"'
|
|
24449
24474
|
})
|
|
24475
|
+
.option('fill-effect', {
|
|
24476
|
+
describe: 'use "sphere" on a circle for a 3d globe effect'
|
|
24477
|
+
})
|
|
24450
24478
|
.option('fill-opacity', {
|
|
24451
24479
|
describe: 'fill opacity'
|
|
24452
24480
|
})
|
|
@@ -37929,7 +37957,8 @@ ${svg}
|
|
|
37929
37957
|
return {
|
|
37930
37958
|
gnom: 60,
|
|
37931
37959
|
laea: 179,
|
|
37932
|
-
ortho: 89.9, //
|
|
37960
|
+
//ortho: 89.9, // projection errors betwen lat +/-35 to 55
|
|
37961
|
+
ortho: 89.85, // TODO: investigate
|
|
37933
37962
|
stere: 142,
|
|
37934
37963
|
sterea: 142,
|
|
37935
37964
|
ups: 10.5 // TODO: should be 6.5 deg at north pole
|
|
@@ -38308,7 +38337,7 @@ ${svg}
|
|
|
38308
38337
|
});
|
|
38309
38338
|
|
|
38310
38339
|
cmd.graticule = function(dataset, opts) {
|
|
38311
|
-
var name = opts.polygon
|
|
38340
|
+
var name = opts.name || opts.polygon && 'polygon' || 'graticule';
|
|
38312
38341
|
var graticule, destInfo;
|
|
38313
38342
|
if (dataset && !isLatLngDataset(dataset)) {
|
|
38314
38343
|
// project graticule to match dataset
|
|
@@ -38374,7 +38403,7 @@ ${svg}
|
|
|
38374
38403
|
//
|
|
38375
38404
|
function createGraticule(P, outlined, opts) {
|
|
38376
38405
|
var interval = opts.interval || 10;
|
|
38377
|
-
if (![5,10,15,30,45].includes(interval)) stop('Invalid interval:', interval);
|
|
38406
|
+
if (![5,10,15,20,30,45].includes(interval)) stop('Invalid interval:', interval);
|
|
38378
38407
|
P.lam0 * 180 / Math.PI;
|
|
38379
38408
|
var precision = interval > 10 ? 1 : 0.5; // degrees between each vertex
|
|
38380
38409
|
var xstep = interval;
|
|
@@ -40962,6 +40991,7 @@ ${svg}
|
|
|
40962
40991
|
}
|
|
40963
40992
|
commandStr = runGlobalExpression(opts.expression, targets);
|
|
40964
40993
|
if (commandStr) {
|
|
40994
|
+
message(`command: [${commandStr}]`);
|
|
40965
40995
|
commands = parseCommands(commandStr);
|
|
40966
40996
|
runParsedCommands(commands, job, cb);
|
|
40967
40997
|
} else {
|
package/package.json
CHANGED
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.34";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -18213,6 +18213,7 @@
|
|
|
18213
18213
|
dy: 'measure',
|
|
18214
18214
|
fill: 'color',
|
|
18215
18215
|
'fill-pattern': 'pattern',
|
|
18216
|
+
'fill-effect': null, // todo: validate effect names
|
|
18216
18217
|
'font-family': null,
|
|
18217
18218
|
'font-size': null,
|
|
18218
18219
|
'font-style': null,
|
|
@@ -18261,7 +18262,7 @@
|
|
|
18261
18262
|
var commonProperties = 'css,class,opacity,stroke,stroke-width,stroke-dasharray,stroke-opacity,fill-opacity,vector-effect'.split(',');
|
|
18262
18263
|
|
|
18263
18264
|
var propertiesBySymbolType = {
|
|
18264
|
-
polygon: utils.arrayToIndex(commonProperties.concat('fill', 'fill-pattern')),
|
|
18265
|
+
polygon: utils.arrayToIndex(commonProperties.concat('fill', 'fill-pattern', 'fill-effect')),
|
|
18265
18266
|
polyline: utils.arrayToIndex(commonProperties.concat('stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit')),
|
|
18266
18267
|
point: utils.arrayToIndex(commonProperties.concat('fill', 'r')),
|
|
18267
18268
|
label: utils.arrayToIndex(commonProperties.concat(
|
|
@@ -19146,6 +19147,9 @@
|
|
|
19146
19147
|
if (obj.tag == 'path' && obj.properties['fill-pattern']) {
|
|
19147
19148
|
convertFillPattern(obj.properties, defs);
|
|
19148
19149
|
}
|
|
19150
|
+
if (obj.tag == 'path' && obj.properties['fill-effect'] == 'sphere') {
|
|
19151
|
+
convertSphereEffect(obj.properties, defs);
|
|
19152
|
+
}
|
|
19149
19153
|
if (obj.tag == 'image') {
|
|
19150
19154
|
if (/\.svg/.test(obj.properties.href || '')) {
|
|
19151
19155
|
convertSvgImage(obj, defs);
|
|
@@ -19156,6 +19160,25 @@
|
|
|
19156
19160
|
}
|
|
19157
19161
|
}
|
|
19158
19162
|
|
|
19163
|
+
function convertSphereEffect(obj, defs) {
|
|
19164
|
+
var id = 'mapshaper_sphere_effect';
|
|
19165
|
+
var href = `url(#${ id })`;
|
|
19166
|
+
var svg =
|
|
19167
|
+
`<radialGradient id="${id}" cx="0.5" cy="0.5" r=".56" fx="0.4" fy="0.35">
|
|
19168
|
+
<stop offset=".35" stop-opacity="0"/>
|
|
19169
|
+
<stop offset=".65" stop-opacity="0.1" />
|
|
19170
|
+
<stop offset=".85" stop-opacity="0.45" />
|
|
19171
|
+
<stop offset=".95" stop-opacity="1" />
|
|
19172
|
+
</radialGradient>` ;
|
|
19173
|
+
if (!utils.find(defs, function(o) { return o.id == id; })) {
|
|
19174
|
+
defs.push({svg, id, href});
|
|
19175
|
+
}
|
|
19176
|
+
obj.fill = href;
|
|
19177
|
+
if ('opacity' in obj === false && 'fill-opacity' in obj === false) {
|
|
19178
|
+
obj['fill-opacity'] = 0.35;
|
|
19179
|
+
}
|
|
19180
|
+
}
|
|
19181
|
+
|
|
19159
19182
|
function convertSvgImage(obj, defs) {
|
|
19160
19183
|
// Same-origin policy prevents embedding images in the web UI
|
|
19161
19184
|
var href = obj.properties.href;
|
|
@@ -23917,7 +23940,9 @@ ${svg}
|
|
|
23917
23940
|
.option('polygon', {
|
|
23918
23941
|
describe: 'create a polygon to match the outline of the graticule',
|
|
23919
23942
|
type: 'flag'
|
|
23920
|
-
})
|
|
23943
|
+
})
|
|
23944
|
+
.option('name', nameOpt);
|
|
23945
|
+
|
|
23921
23946
|
|
|
23922
23947
|
parser.command('grid')
|
|
23923
23948
|
.describe('create a grid of square or hexagonal polygons')
|
|
@@ -24447,6 +24472,9 @@ ${svg}
|
|
|
24447
24472
|
.option('fill-pattern', {
|
|
24448
24473
|
describe: 'pattern fill, ex: "hatches 2px grey 2px blue"'
|
|
24449
24474
|
})
|
|
24475
|
+
.option('fill-effect', {
|
|
24476
|
+
describe: 'use "sphere" on a circle for a 3d globe effect'
|
|
24477
|
+
})
|
|
24450
24478
|
.option('fill-opacity', {
|
|
24451
24479
|
describe: 'fill opacity'
|
|
24452
24480
|
})
|
|
@@ -37929,7 +37957,8 @@ ${svg}
|
|
|
37929
37957
|
return {
|
|
37930
37958
|
gnom: 60,
|
|
37931
37959
|
laea: 179,
|
|
37932
|
-
ortho: 89.9, //
|
|
37960
|
+
//ortho: 89.9, // projection errors betwen lat +/-35 to 55
|
|
37961
|
+
ortho: 89.85, // TODO: investigate
|
|
37933
37962
|
stere: 142,
|
|
37934
37963
|
sterea: 142,
|
|
37935
37964
|
ups: 10.5 // TODO: should be 6.5 deg at north pole
|
|
@@ -38308,7 +38337,7 @@ ${svg}
|
|
|
38308
38337
|
});
|
|
38309
38338
|
|
|
38310
38339
|
cmd.graticule = function(dataset, opts) {
|
|
38311
|
-
var name = opts.polygon
|
|
38340
|
+
var name = opts.name || opts.polygon && 'polygon' || 'graticule';
|
|
38312
38341
|
var graticule, destInfo;
|
|
38313
38342
|
if (dataset && !isLatLngDataset(dataset)) {
|
|
38314
38343
|
// project graticule to match dataset
|
|
@@ -38374,7 +38403,7 @@ ${svg}
|
|
|
38374
38403
|
//
|
|
38375
38404
|
function createGraticule(P, outlined, opts) {
|
|
38376
38405
|
var interval = opts.interval || 10;
|
|
38377
|
-
if (![5,10,15,30,45].includes(interval)) stop('Invalid interval:', interval);
|
|
38406
|
+
if (![5,10,15,20,30,45].includes(interval)) stop('Invalid interval:', interval);
|
|
38378
38407
|
P.lam0 * 180 / Math.PI;
|
|
38379
38408
|
var precision = interval > 10 ? 1 : 0.5; // degrees between each vertex
|
|
38380
38409
|
var xstep = interval;
|
|
@@ -40962,6 +40991,7 @@ ${svg}
|
|
|
40962
40991
|
}
|
|
40963
40992
|
commandStr = runGlobalExpression(opts.expression, targets);
|
|
40964
40993
|
if (commandStr) {
|
|
40994
|
+
message(`command: [${commandStr}]`);
|
|
40965
40995
|
commands = parseCommands(commandStr);
|
|
40966
40996
|
runParsedCommands(commands, job, cb);
|
|
40967
40997
|
} else {
|