mapshaper 0.5.109 → 0.5.110
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 +5 -0
- package/mapshaper.js +237 -194
- package/package.json +4 -2
- package/www/mapshaper-gui.js +32 -56
- package/www/mapshaper.js +237 -194
- package/www/modules.js +5 -1
package/www/modules.js
CHANGED
|
@@ -5343,7 +5343,11 @@ function handleQs(url, query) {
|
|
|
5343
5343
|
}
|
|
5344
5344
|
exports["default"] = handleQs;
|
|
5345
5345
|
|
|
5346
|
-
},{"qs":25}],"
|
|
5346
|
+
},{"qs":25}],"@tmcw/togeojson":[function(require,module,exports){
|
|
5347
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).toGeoJSON={})}(this,(function(e){"use strict";function t(e){return e&&e.normalize&&e.normalize(),e&&e.textContent||""}function n(e,t){const n=e.getElementsByTagName(t);return n.length?n[0]:null}function o(e){const o={};if(e){const s=n(e,"line");if(s){const e=t(n(s,"color")),r=parseFloat(t(n(s,"opacity"))),i=parseFloat(t(n(s,"width")));e&&(o.stroke=e),isNaN(r)||(o["stroke-opacity"]=r),isNaN(i)||(o["stroke-width"]=96*i/25.4)}}return o}function s(e){let n=[];if(null!==e)for(let o=0;o<e.childNodes.length;o++){const r=e.childNodes[o];if(1!==r.nodeType)continue;const i=["heart","gpxtpx:hr","hr"].includes(r.nodeName)?"heart":r.nodeName;if("gpxtpx:TrackPointExtension"===i)n=n.concat(s(r));else{const e=t(r);n.push([i,isNaN(e)?e:parseFloat(e)])}}return n}function r(e,o){const s={};let r,i;for(i=0;i<o.length;i++)r=n(e,o[i]),r&&(s[o[i]]=t(r));return s}function i(e){const n=r(e,["name","cmt","desc","type","time","keywords"]),o=e.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3","*");for(let s=0;s<o.length;s++){const r=o[s];r.parentNode.parentNode===e&&(n[r.tagName.replace(":","_")]=t(r))}const s=e.getElementsByTagName("link");s.length&&(n.links=[]);for(let e=0;e<s.length;e++)n.links.push(Object.assign({href:s[e].getAttribute("href")},r(s[e],["text","type"])));return n}function l(e){const o=[parseFloat(e.getAttribute("lon")),parseFloat(e.getAttribute("lat"))],r=n(e,"ele"),i=n(e,"time");if(r){const e=parseFloat(t(r));isNaN(e)||o.push(e)}return{coordinates:o,time:i?t(i):null,extendedValues:s(n(e,"extensions"))}}function a(e){const t=c(e,"rtept");if(t)return{type:"Feature",properties:Object.assign(i(e),o(n(e,"extensions")),{_gpxType:"rte"}),geometry:{type:"LineString",coordinates:t.line}}}function c(e,t){const n=e.getElementsByTagName(t);if(n.length<2)return;const o=[],s=[],r={};for(let e=0;e<n.length;e++){const t=l(n[e]);o.push(t.coordinates),t.time&&s.push(t.time);for(let o=0;o<t.extendedValues.length;o++){const[s,i]=t.extendedValues[o],l="heart"===s?s:s.replace("gpxtpx:","")+"s";r[l]||(r[l]=Array(n.length).fill(null)),r[l][e]=i}}return{line:o,times:s,extendedValues:r}}function g(e){const t=e.getElementsByTagName("trkseg"),s=[],r=[],l=[];for(let e=0;e<t.length;e++){const n=c(t[e],"trkpt");n&&(l.push(n),n.times&&n.times.length&&r.push(n.times))}if(0===l.length)return;const a=l.length>1,g=Object.assign(i(e),o(n(e,"extensions")),{_gpxType:"trk"},r.length?{coordinateProperties:{times:a?r:r[0]}}:{});for(let e=0;e<l.length;e++){const t=l[e];s.push(t.line);for(const[n,o]of Object.entries(t.extendedValues)){g.coordinateProperties||(g.coordinateProperties={});const t=g.coordinateProperties;a?(t[n]||(t[n]=l.map((e=>new Array(e.line.length).fill(null)))),t[n][e]=o):t[n]=o}}return{type:"Feature",properties:g,geometry:a?{type:"MultiLineString",coordinates:s}:{type:"LineString",coordinates:s[0]}}}function*u(e){const t=e.getElementsByTagName("trk"),n=e.getElementsByTagName("rte"),o=e.getElementsByTagName("wpt");for(let e=0;e<t.length;e++){const n=g(t[e]);n&&(yield n)}for(let e=0;e<n.length;e++){const t=a(n[e]);t&&(yield t)}for(let e=0;e<o.length;e++)yield(s=o[e],{type:"Feature",properties:Object.assign(i(s),r(s,["sym"])),geometry:{type:"Point",coordinates:l(s).coordinates}});var s}const p=[["heartRate","heartRates"],["Cadence","cadences"],["Speed","speeds"],["Watts","watts"]],m=[["TotalTimeSeconds","totalTimeSeconds"],["DistanceMeters","distanceMeters"],["MaximumSpeed","maxSpeed"],["AverageHeartRateBpm","avgHeartRate"],["MaximumHeartRateBpm","maxHeartRate"],["AvgSpeed","avgSpeed"],["AvgWatts","avgWatts"],["MaxWatts","maxWatts"]];function d(e,o){const s=[];for(const[r,i]of o){let o=n(e,r);if(!o){const t=e.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/ActivityExtension/v2",r);t.length&&(o=t[0])}const l=parseFloat(t(o));isNaN(l)||s.push([i,l])}return s}function f(e){const o=t(n(e,"LongitudeDegrees")),s=t(n(e,"LatitudeDegrees"));if(!o.length||!s.length)return null;const r=[parseFloat(o),parseFloat(s)],i=n(e,"AltitudeMeters"),l=n(e,"HeartRateBpm"),a=n(e,"Time");let c;return i&&(c=parseFloat(t(i)),isNaN(c)||r.push(c)),{coordinates:r,time:a?t(a):null,heartRate:l?parseFloat(t(l)):null,extensions:d(e,p)}}function h(e,t){const n=e.getElementsByTagName(t),o=[],s=[],r=[];if(n.length<2)return null;const i={extendedProperties:{}};for(let e=0;e<n.length;e++){const t=f(n[e]);if(null!==t){o.push(t.coordinates),t.time&&s.push(t.time),t.heartRate&&r.push(t.heartRate);for(const[o,s]of t.extensions)i.extendedProperties[o]||(i.extendedProperties[o]=Array(n.length).fill(null)),i.extendedProperties[o][e]=s}}return Object.assign(i,{line:o,times:s,heartRates:r})}function y(e){const o=e.getElementsByTagName("Track"),s=[],r=[],i=[],l=[];let a;const c=function(e){const t={};for(const[n,o]of e)t[n]=o;return t}(d(e,m)),g=n(e,"Name");g&&(c.name=t(g));for(let e=0;e<o.length;e++)a=h(o[e],"Trackpoint"),a&&(s.push(a.line),a.times.length&&r.push(a.times),a.heartRates.length&&i.push(a.heartRates),l.push(a.extendedProperties));for(let e=0;e<l.length;e++){const t=l[e];for(const n in t)1===o.length?c[n]=a.extendedProperties[n]:(c[n]||(c[n]=s.map((e=>Array(e.length).fill(null)))),c[n][e]=t[n])}if(0!==s.length)return(r.length||i.length)&&(c.coordinateProperties=Object.assign(r.length?{times:1===s.length?r[0]:r}:{},i.length?{heart:1===s.length?i[0]:i}:{})),{type:"Feature",properties:c,geometry:{type:1===s.length?"LineString":"MultiLineString",coordinates:1===s.length?s[0]:s}}}function*N(e){const t=e.getElementsByTagName("Lap");for(let e=0;e<t.length;e++){const n=y(t[e]);n&&(yield n)}const n=e.getElementsByTagName("Courses");for(let e=0;e<n.length;e++){const t=y(n[e]);t&&(yield t)}}const x=/\s*/g,T=/^\s*|\s*$/g,b=/\s+/;function S(e){if(!e||!e.length)return 0;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function k(e){return e.replace(x,"").split(",").map(parseFloat)}function E(e){return e.replace(T,"").split(b).map(k)}function A(e){if(void 0!==e.xml)return e.xml;if(e.tagName){let t=e.tagName;for(let n=0;n<e.attributes.length;n++)t+=e.attributes[n].name+e.attributes[n].value;for(let n=0;n<e.childNodes.length;n++)t+=A(e.childNodes[n]);return t}return"#text"===e.nodeName?(e.nodeValue||e.value||"").trim():"#cdata-section"===e.nodeName?e.nodeValue:""}const B=["Polygon","LineString","Point","Track","gx:Track"];function P(e,o,s){let r=t(n(o,"color"))||"";const i="stroke"==s||"fill"===s?s:s+"-color";"#"===r.substr(0,1)&&(r=r.substr(1)),6===r.length||3===r.length?e[i]=r:8===r.length&&(e[s+"-opacity"]=parseInt(r.substr(0,2),16)/255,e[i]="#"+r.substr(6,2)+r.substr(4,2)+r.substr(2,2))}function F(e,o,s,r){const i=parseFloat(t(n(o,s)));isNaN(i)||(e[r]=i)}function v(e){let n=e.getElementsByTagName("coord");const o=[],s=[];0===n.length&&(n=e.getElementsByTagName("gx:coord"));for(let e=0;e<n.length;e++)o.push(t(n[e]).split(" ").map(parseFloat));const r=e.getElementsByTagName("when");for(let e=0;e<r.length;e++)s.push(t(r[e]));return{coords:o,times:s}}function L(e){let o,s,r,i,l;const a=[],c=[];if(n(e,"MultiGeometry"))return L(n(e,"MultiGeometry"));if(n(e,"MultiTrack"))return L(n(e,"MultiTrack"));if(n(e,"gx:MultiTrack"))return L(n(e,"gx:MultiTrack"));for(r=0;r<B.length;r++)if(s=e.getElementsByTagName(B[r]),s)for(i=0;i<s.length;i++)if(o=s[i],"Point"===B[r])a.push({type:"Point",coordinates:k(t(n(o,"coordinates")))});else if("LineString"===B[r])a.push({type:"LineString",coordinates:E(t(n(o,"coordinates")))});else if("Polygon"===B[r]){const e=o.getElementsByTagName("LinearRing"),s=[];for(l=0;l<e.length;l++)s.push(E(t(n(e[l],"coordinates"))));a.push({type:"Polygon",coordinates:s})}else if("Track"===B[r]||"gx:Track"===B[r]){const e=v(o);a.push({type:"LineString",coordinates:e.coords}),e.times.length&&c.push(e.times)}return{geoms:a,coordTimes:c}}function M(e,o,s,r){const i=L(e);let l;const a={},c=t(n(e,"name")),g=t(n(e,"address"));let u=t(n(e,"styleUrl"));const p=t(n(e,"description")),m=n(e,"TimeSpan"),d=n(e,"TimeStamp"),f=n(e,"ExtendedData");let h=n(e,"IconStyle"),y=n(e,"LabelStyle"),N=n(e,"LineStyle"),x=n(e,"PolyStyle");const T=n(e,"visibility");if(c&&(a.name=c),g&&(a.address=g),u){"#"!==u[0]&&(u="#"+u),a.styleUrl=u,o[u]&&(a.styleHash=o[u]),s[u]&&(a.styleMapHash=s[u],a.styleHash=o[s[u].normal]);const e=r[a.styleHash];e&&(h||(h=n(e,"IconStyle")),y||(y=n(e,"LabelStyle")),N||(N=n(e,"LineStyle")),x||(x=n(e,"PolyStyle")))}if(p&&(a.description=p),m){const e=t(n(m,"begin")),o=t(n(m,"end"));a.timespan={begin:e,end:o}}if(d&&(a.timestamp=t(n(d,"when"))),h){P(a,h,"icon"),F(a,h,"scale","icon-scale"),F(a,h,"heading","icon-heading");const e=n(h,"hotSpot");if(e){const t=parseFloat(e.getAttribute("x")),n=parseFloat(e.getAttribute("y"));isNaN(t)||isNaN(n)||(a["icon-offset"]=[t,n])}const o=n(h,"Icon");if(o){const e=t(n(o,"href"));e&&(a.icon=e)}}if(y&&(P(a,y,"label"),F(a,y,"scale","label-scale")),N&&(P(a,N,"stroke"),F(a,N,"width","stroke-width")),x){P(a,x,"fill");const e=t(n(x,"fill")),o=t(n(x,"outline"));e&&(a["fill-opacity"]="1"===e?a["fill-opacity"]||1:0),o&&(a["stroke-opacity"]="1"===o?a["stroke-opacity"]||1:0)}if(f){const e=f.getElementsByTagName("Data"),o=f.getElementsByTagName("SimpleData");for(l=0;l<e.length;l++)a[e[l].getAttribute("name")]=t(n(e[l],"value"));for(l=0;l<o.length;l++)a[o[l].getAttribute("name")]=t(o[l])}T&&(a.visibility=t(T)),i.coordTimes.length&&(a.coordinateProperties={times:1===i.coordTimes.length?i.coordTimes[0]:i.coordTimes});const b={type:"Feature",geometry:0===i.geoms.length?null:1===i.geoms.length?i.geoms[0]:{type:"GeometryCollection",geometries:i.geoms},properties:a};return e.getAttribute("id")&&(b.id=e.getAttribute("id")),b}function*w(e){const o={},s={},r={},i=e.getElementsByTagName("Placemark"),l=e.getElementsByTagName("Style"),a=e.getElementsByTagName("StyleMap");for(let e=0;e<l.length;e++){const t=l[e],n=S(A(t)).toString(16);let r=t.getAttribute("id");r||"CascadingStyle"!==t.parentNode.tagName.replace("gx:","")||(r=t.parentNode.getAttribute("kml:id")||t.parentNode.getAttribute("id")),o["#"+r]=n,s[n]=t}for(let e=0;e<a.length;e++){o["#"+a[e].getAttribute("id")]=S(A(a[e])).toString(16);const s=a[e].getElementsByTagName("Pair"),i={};for(let e=0;e<s.length;e++)i[t(n(s[e],"key"))]=t(n(s[e],"styleUrl"));r["#"+a[e].getAttribute("id")]=i}for(let e=0;e<i.length;e++){const t=M(i[e],o,r,s);t&&(yield t)}}e.gpx=function(e){return{type:"FeatureCollection",features:Array.from(u(e))}},e.gpxGen=u,e.kml=function(e){return{type:"FeatureCollection",features:Array.from(w(e))}},e.kmlGen=w,e.tcx=function(e){return{type:"FeatureCollection",features:Array.from(N(e))}},e.tcxGen=N,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
5348
|
+
|
|
5349
|
+
|
|
5350
|
+
},{}],"buffer":[function(require,module,exports){
|
|
5347
5351
|
(function (Buffer){(function (){
|
|
5348
5352
|
/*!
|
|
5349
5353
|
* The buffer module from node.js, for the browser.
|