forked from caseycesari/GeoJSON.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeojson.min.js
3 lines (3 loc) · 1.86 KB
/
geojson.min.js
1
2
3
// geojson.js - v0.2.1
// (c) 2015 Casey Thomas, MIT License
!function(a){function b(a,b){var c=a||{};for(var d in b)b.hasOwnProperty(d)&&!c[d]&&(c[d]=b[d]);return c}function c(a,b){if(b.crs&&(a.crs={type:"name",properties:{name:b.crs}}),b.bbox&&(a.bbox=b.bbox),b.extraGlobal){a.properties={};for(var c in b.extraGlobal)a.properties[c]=b.extraGlobal[c]}}function d(a){a.geom={};for(var b in a)a.hasOwnProperty(b)&&-1!==j.indexOf(b)&&(a.geom[b]=a[b],delete a[b]);e(a.geom)}function e(a){for(var b in a)a.hasOwnProperty(b)&&("string"==typeof a[b]?k.push(a[b]):"object"==typeof a[b]&&(k.push(a[b][0]),k.push(a[b][1])));if(0===k.length)throw new Error("No geometry attributes specified")}function f(a,b,c){var d={type:"Feature"};return d.geometry=g(a,b),d.properties=c.call(a),d}function g(a,b){var c={};for(var d in b.geom){var e=b.geom[d];"string"==typeof e&&a.hasOwnProperty(e)?(c.type=d,c.coordinates=a[e]):Array.isArray(e)&&a.hasOwnProperty(e[0])&&a.hasOwnProperty(e[1])&&(c.type=d,c.coordinates=[a[e[1]],a[e[0]]])}return c}function h(a){var b;return a.exclude||a.include?a.include?b=function(b){a.include.forEach(function(a){b[a]=this[a]},this)}:a.exclude&&(b=function(b){for(var c in this)this.hasOwnProperty(c)&&-1===k.indexOf(c)&&-1===a.exclude.indexOf(c)&&(b[c]=this[c])}):b=function(a){for(var b in this)this.hasOwnProperty(b)&&-1===k.indexOf(b)&&(a[b]=this[b])},function(){var c={};return b.call(this,c),a.extra&&i(c,a.extra),c}}function i(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}a.version="0.2.0",a.defaults={},a.parse=function(a,e,g){var i,j={type:"FeatureCollection",features:[]},l=b(e,this.defaults);return k.length=0,d(l),i=h(l),a.forEach(function(a){j.features.push(f(a,l,i))}),c(j,l),g&&"function"==typeof g?void g(j):j};var j=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],k=[]}("object"==typeof module?module.exports:window.GeoJSON={});