geojson-equality.min.js 4.8 KB

1
  1. !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.GeojsonEquality=e()}}(function(){return function e(t,r,o){function n(c,u){if(!r[c]){if(!t[c]){var p="function"==typeof require&&require;if(!u&&p)return p(c,!0);if(i)return i(c,!0);var s=new Error("Cannot find module '"+c+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[c]={exports:{}};t[c][0].call(a.exports,function(e){var r=t[c][1][e];return n(r?r:e)},a,a.exports,e,t,r,o)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<o.length;c++)n(o[c]);return n}({1:[function(e,t){function r(e){return e.coordinates.map(function(t){return{type:e.type.replace("Multi",""),coordinates:t}})}function o(e,t){return e.hasOwnProperty("coordinates")?e.coordinates.length===t.coordinates.length:e.length===t.length}function n(e,t){return i(e,t,{strict:!0})}var i=e("deep-equal"),c=function(e){this.precision=e&&e.precision?e.precision:17,this.direction=e&&e.direction?e.direction:!1,this.pseudoNode=e&&e.pseudoNode?e.pseudoNode:!1,this.objectComparator=e&&e.objectComparator?e.objectComparator:n};c.prototype.compare=function(e,t){if(e.type!==t.type||!o(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates,0,!1);case"Polygon":return this.comparePolygon(e,t);case"Feature":return this.compareFeature(e,t);default:if(0===e.type.indexOf("Multi")){var n=this,i=r(e),c=r(t);return i.every(function(e){return this.some(function(t){return n.compare(e,t)})},c)}}return!1},c.prototype.compareCoord=function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r].toFixed(this.precision)!==t[r].toFixed(this.precision))return!1;return!0},c.prototype.compareLine=function(e,t,r,n){if(!o(e,t))return!1;var i=this.pseudoNode?e:this.removePseudo(e),c=this.pseudoNode?t:this.removePseudo(t);if(!n||this.compareCoord(i[0],c[0])||(c=this.fixStartIndex(c,i))){var u=this.compareCoord(i[r],c[r]);return this.direction||u?this.comparePath(i,c):this.compareCoord(i[r],c[c.length-(1+r)])?this.comparePath(i.slice().reverse(),c):!1}},c.prototype.fixStartIndex=function(e,t){for(var r,o=-1,n=0;n<e.length;n++)if(this.compareCoord(e[n],t[0])){o=n;break}return o>=0&&(r=[].concat(e.slice(o,e.length),e.slice(1,o+1))),r},c.prototype.comparePath=function(e,t){var r=this;return e.every(function(e,t){return r.compareCoord(e,this[t])},t)},c.prototype.comparePolygon=function(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){var r=e.coordinates.slice(1,e.coordinates.length),o=t.coordinates.slice(1,t.coordinates.length),n=this;return r.every(function(e){return this.some(function(t){return n.compareLine(e,t,1,!0)})},o)}return!1},c.prototype.compareFeature=function(e,t){return e.id===t.id&&this.objectComparator(e.properties,t.properties)&&this.compareBBox(e,t)?this.compare(e.geometry,t.geometry):!1},c.prototype.compareBBox=function(e,t){return!e.bbox&&!t.bbox||e.bbox&&t.bbox&&this.compareCoord(e.bbox,t.bbox)?!0:!1},c.prototype.removePseudo=function(e){return e},t.exports=c},{"deep-equal":2}],2:[function(e,t){function r(e){return null===e||void 0===e}function o(e){return e&&"object"==typeof e&&"number"==typeof e.length?"function"!=typeof e.copy||"function"!=typeof e.slice?!1:e.length>0&&"number"!=typeof e[0]?!1:!0:!1}function n(e,t,n){var s,a;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(u(e))return u(t)?(e=i.call(e),t=i.call(t),p(e,t,n)):!1;if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}try{var f=c(e),l=c(t)}catch(d){return!1}if(f.length!=l.length)return!1;for(f.sort(),l.sort(),s=f.length-1;s>=0;s--)if(f[s]!=l[s])return!1;for(s=f.length-1;s>=0;s--)if(a=f[s],!p(e[a],t[a],n))return!1;return typeof e==typeof t}var i=Array.prototype.slice,c=e("./lib/keys.js"),u=e("./lib/is_arguments.js"),p=t.exports=function(e,t,r){return r||(r={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():"object"!=typeof e&&"object"!=typeof t?r.strict?e===t:e==t:n(e,t,r)}},{"./lib/is_arguments.js":3,"./lib/keys.js":4}],3:[function(e,t,r){function o(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function n(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();r=t.exports=i?o:n,r.supported=o,r.unsupported=n},{}],4:[function(e,t,r){function o(e){var t=[];for(var r in e)t.push(r);return t}r=t.exports="function"==typeof Object.keys?Object.keys:o,r.shim=o},{}]},{},[1])(1)});