forked from Esri/terraformer-arcgis-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terraformer-arcgis-parser.min.js
1 lines (1 loc) · 2.74 KB
/
terraformer-arcgis-parser.min.js
1
!function(a,b){if("object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b(require("terraformer"))),"object"==typeof a.navigator){if(!a.Terraformer)throw new Error("Terraformer.ArcGIS requires the core Terraformer library. https://github.com/esri/Terraformer");a.Terraformer.ArcGIS=b(a.Terraformer)}}(this,function(a){function b(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function c(a){var b,c=0,d=0,e=a.length,f=a[d];for(d;e-1>d;d++)b=a[d+1],c+=(b[0]-f[0])*(b[1]+f[1]),f=b;return c>=0}function d(a){var b=[],d=a.slice(0),e=d.shift().slice(0);c(e)||e.reverse(),b.push(e);for(var f=0;f<d.length;f++){var g=d[f].slice(0);c(g)&&g.reverse(),b.push(g)}return b}function e(a){for(var b=[],c=0;c<a.length;c++)for(var e=d(a[c]),f=e.length-1;f>=0;f--){var g=e[f].slice(0);b.push(g)}return b}function f(b,c){var d=a.Tools.arrayIntersectsArray(b,c),e=a.Tools.coordinatesContainPoint(b,c[0]);return!d&&e?!0:!1}function g(a){for(var b=[],d=[],e=0;e<a.length;e++){var g=a[e].slice(0);if(c(g)){var h=[g];b.push(h)}else d.push(g)}for(;d.length;){for(var i=d.pop(),j=!1,k=b.length-1;k>=0;k--){var l=b[k][0];if(f(l,i)){b[k].push(i),j=!0;break}}j||b.push([i.reverse()])}return 1===b.length?{type:"Polygon",coordinates:b[0]}:{type:"MultiPolygon",coordinates:b}}function h(c){var d={};c.x&&c.y&&(d.type="Point",d.coordinates=[c.x,c.y]),c.points&&(d.type="MultiPoint",d.coordinates=c.points.slice(0)),c.paths&&(1===c.paths.length?(d.type="LineString",d.coordinates=c.paths[0].slice(0)):(d.type="MultiLineString",d.coordinates=c.paths.slice(0))),c.rings&&(d=g(c.rings.slice(0))),(c.geometry||c.attributes)&&(d.type="Feature",d.geometry=c.geometry?h(c.geometry):{},d.properties=b(c.attributes)||{});var e=c.geometry?c.geometry.spatialReference:c.spatialReference;return e&&102100===e.wkid&&(d=a.toGeographic(d)),new a.Primitive(d)}function i(c,f){var g;g=f?f:c&&c.crs===a.MercatorCRS?{wkid:102100}:{wkid:4326};var h,j={};switch(c.type){case"Point":j.x=c.coordinates[0],j.y=c.coordinates[1],j.spatialReference=g;break;case"MultiPoint":j.points=c.coordinates.slice(0),j.spatialReference=g;break;case"LineString":j.paths=[c.coordinates.slice(0)],j.spatialReference=g;break;case"MultiLineString":j.paths=c.coordinates.slice(0),j.spatialReference=g;break;case"Polygon":j.rings=d(c.coordinates.slice(0)),j.spatialReference=g;break;case"MultiPolygon":j.rings=e(c.coordinates.slice(0)),j.spatialReference=g;break;case"Feature":c.geometry&&(j.geometry=i(c.geometry)),c.properties&&(j.attributes=b(c.properties));break;case"FeatureCollection":for(j=[],h=0;h<c.features.length;h++)j.push(i(c.features[h]));break;case"GeometryCollection":for(j=[],h=0;h<c.geometries.length;h++)j.push(i(c.geometries[h]))}return j}var j={};return j.parse=h,j.convert=i,j.toGeoJSON=h,j.fromGeoJSON=i,j});