melting-pot/js/osmtogeojson.js

1 line
29 KiB
JavaScript
Raw Normal View History

2022-06-20 11:54:11 +02:00
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.osmtogeojson=e()}}(function(){return function e(n,t,r){function o(i,s){if(!t[i]){if(!n[i]){var l="function"==typeof require&&require;if(!s&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[i]={exports:{}};n[i][0].call(c.exports,function(e){var t=n[i][1][e];return o(t?t:e)},c,c.exports,e,n,t,r)}return t[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,n,t){var r=e("./lodash.custom.js"),o=e("geojson-rewind"),a={};e("osm-polygon-features").forEach(function(e){if("all"===e.polygon)a[e.key]=!0;else{var n="whitelist"===e.polygon?"included_values":"excluded_values",t={};e.values.forEach(function(e){t[e]=!0}),a[e.key]={},a[e.key][n]=t}});var i={};i=function(e,n){function t(e){function n(e){var n=r.clone(e);n.lat=e.center.lat,n.lon=e.center.lon,n.__is_center_placeholder=!0,i.push(n)}function t(e){function n(e,n,r){var o={type:"node",id:"_"+t.type+"/"+t.id+"bounds"+r,lat:e,lon:n};t.nodes.push(o.id),i.push(o)}var t=r.clone(e);t.nodes=[],n(t.bounds.minlat,t.bounds.minlon,1),n(t.bounds.maxlat,t.bounds.minlon,2),n(t.bounds.maxlat,t.bounds.maxlon,3),n(t.bounds.minlat,t.bounds.maxlon,4),t.nodes.push(t.nodes[0]),t.__is_bounds_placeholder=!0,l.push(t)}function o(e){function n(e,n,t){var r={type:"node",id:t,lat:e,lon:n,__is_uninteresting:!0};i.push(r)}r.isArray(e.nodes)||(e.nodes=e.geometry.map(function(e){return null!==e?"_anonymous@"+e.lat+"/"+e.lon:"_anonymous@unknown_location"})),e.geometry.forEach(function(t,r){t&&n(t.lat,t.lon,e.nodes[r])})}function a(e){function n(e,n,t){var r={type:"node",id:t,lat:e,lon:n};i.push(r)}function t(e,n){function t(e,n){var t={type:"node",id:"_anonymous@"+e+"/"+n,lat:e,lon:n,__is_uninteresting:!0};r.nodes.push(t.id),i.push(t)}if(!l.some(function(e){return"way"==e.type&&e.id==n})){var r={type:"way",id:n,nodes:[]};e.forEach(function(e){e?t(e.lat,e.lon):r.nodes.push(void 0)}),l.push(r)}}e.members.forEach(function(e,r){"node"==e.type?e.lat&&n(e.lat,e.lon,e.ref):"way"==e.type&&e.geometry&&(e.ref="_fullGeom"+e.ref,t(e.geometry,e.ref))})}for(var i=new Array,l=new Array,u=new Array,c=0;c<e.elements.length;c++)switch(e.elements[c].type){case"node":var f=e.elements[c];i.push(f);break;case"way":var p=r.clone(e.elements[c]);p.nodes=r.clone(p.nodes),l.push(p),p.center&&n(p),p.geometry?o(p):p.bounds&&t(p);break;case"relation":var y=r.clone(e.elements[c]);y.members=r.clone(y.members),u.push(y);var g=y.members&&y.members.some(function(e){return"node"==e.type&&e.lat||"way"==e.type&&e.geometry&&e.geometry.length>0});y.center&&n(y),g?a(y):y.bounds&&t(y)}return s(i,l,u)}function i(e){function n(e,n,t){e.hasAttribute(t)&&(n[t]=e.getAttribute(t))}function t(e,t){var o=r.clone(e);n(t,o,"lat"),n(t,o,"lon"),o.__is_center_placeholder=!0,l.push(o)}function o(e,n){function t(e,n,t){var r={type:"node",id:"_"+o.type+"/"+o.id+"bounds"+t,lat:e,lon:n};o.nodes.push(r.id),l.push(r)}var o=r.clone(e);o.nodes=[],t(n.getAttribute("minlat"),n.getAttribute("minlon"),1),t(n.getAttribute("maxlat"),n.getAttribute("minlon"),2),t(n.getAttribute("maxlat"),n.getAttribute("maxlon"),3),t(n.getAttribute("minlat"),n.getAttribute("maxlon"),4),o.nodes.push(o.nodes[0]),o.__is_bounds_placeholder=!0,u.push(o)}function a(e,n){function t(e,n,t){var r={type:"node",id:t,lat:e,lon:n,__is_uninteresting:!0};return l.push(r),r.id}r.isArray(e.nodes)||(e.nodes=[],r.each(n,function(n,t){e.nodes.push("_anonymous@"+n.getAttribute("lat")+"/"+n.getAttribute("lon"))})),r.each(n,function(n,r){n.getAttribute("lat")&&t(n.getAttribute("lat"),n.getAttribute("lon"),e.nodes[r])})}function i(e,n){function t(e,n,t){var r={type:"node",id:t,lat:e,lon:n};l.push(r)}function o(e,n){function t(e,n){var t={type:"node",id:"_anonymous@"+e+"/"+n,lat:e,lon:n,__is_uninteresting:!0};o.nodes.push(t.id),l