Comparing version 0.1.1 to 0.1.2
@@ -1,1 +0,1 @@ | ||
"use strict";function JsonOdm(){var t=this;this.sources={},this.selectedSource={},this.addSource=function(o,e,n){"object"==typeof e&&("undefined"==typeof t.sources[o]&&(t.sources[o]=e),n&&(t.selectedSource=e))},this.selectSource=function(o){"undefined"!=typeof t.sources[o]&&(t.selectedSource=t.sources[o])}}var root="undefined"!=typeof window?window:global,odm=new JsonOdm;root.jsonOdm||(root.jsonOdm=odm),"undefined"!=typeof module&&module.exports&&(module.exports=odm),jsonOdm.Util=function(){},jsonOdm.Util.prototype.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},jsonOdm.Util.prototype.is=function(t,o){o="string"==typeof o?[o]:o;var e=Object.prototype.toString.call(t);e=e.substring(8,e.length-1).toLowerCase();for(var n=0;n<o.length;n++){var r=o[n].toLowerCase();if("array"==r&&this.isArray(t))return!0;if(r==e)return!0;if(typeof t==r)return!0}return!1},jsonOdm.Util.prototype.objectKeys=Object.keys||function(){var t=Object.prototype.hasOwnProperty,o=!{toString:null}.propertyIsEnumerable("toString"),e=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=e.length;return function(r){if("object"!=typeof r&&("function"!=typeof r||null===r))throw new TypeError("Object.keys called on non-object");var i,s,d=[];for(i in r)t.call(r,i)&&d.push(i);if(o)for(s=0;n>s;s++)t.call(r,e[s])&&d.push(e[s]);return d}}(),jsonOdm.Util.prototype.branch=function(t,o){function e(){if(arguments&&arguments.length&&this){var t=this[arguments[0]];return t?e.apply(t,Array.prototype.slice.call(arguments,1)):t}return this}return e.apply(t,o)},jsonOdm.util=new jsonOdm.Util,jsonOdm.Geo=function(){},jsonOdm.Geo.detectAsGeometry=function(t){if(!t.type)if(jsonOdm.util.isArray(t)&&2==t.length&&!jsonOdm.util.isArray(t[0]))t=new jsonOdm.Geo.Point(t);else if(jsonOdm.util.isArray(t)&&4==t.length&&!jsonOdm.util.isArray(t[0]))t=new jsonOdm.Geo.BoundaryBox(t);else if(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&2==t[0].length&&!jsonOdm.util.isArray(t[0][0]))t=new jsonOdm.Geo.LineString(t);else if(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&t[0].length>=1&&jsonOdm.util.isArray(t[0][0])&&2==t[0][0].length&&!jsonOdm.util.isArray(t[0][0][0]))t=new jsonOdm.Geo.Polygon(t);else{if(!(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&t[0].length>=1&&jsonOdm.util.isArray(t[0][0])&&t[0][0].length>=1&&jsonOdm.util.isArray(t[0][0][0])&&2==t[0][0][0].length)||jsonOdm.util.isArray(t[0][0][0][0]))return!1;t=new jsonOdm.Geo.MultiPolygon(t)}return t},jsonOdm.Geo.FeatureCollection=function(t,o){this.type="FeatureCollection",this.features=t||[],o&&(this.bbox=o)},jsonOdm.Geo.Feature=function(t,o,e,n){this.geometry=t||{},o&&(this.properties=o),e&&(this.bbox=e),n&&(this.id=n)},jsonOdm.Geo.BoundaryBox=function(t){var o=Object.create(Array.prototype);return o=Array.apply(o)||o,jsonOdm.util.isArray(t)?(o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=t[3]):(o[0]=0,o[1]=0,o[2]=0,o[3]=0),o},jsonOdm.Geo.BoundaryBox.within=function(t,o){return jsonOdm.util.isArray(t)&&4==t.length?jsonOdm.Geo.Polygon.within(new jsonOdm.Geo.Polygon([[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],[t[0],t[1]]]]),o):!1},jsonOdm.Geo.Point=function(t,o){this.type="Point",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.Point.within=function(t,o){var e,n;if(!t.coordinates)return!1;if("Point"==o.type)return o.coordinates[0]==t.coordinates[0]&&o.coordinates[1]==t.coordinates[1];if("MultiPoint"==o.type||"LineString"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(o.coordinates[e][0]==t.coordinates[0]&&o.coordinates[e][1]==t.coordinates[1])return!0;return!1}if("MultiLineString"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;o.coordinates[e]&&n<o.coordinates[e].length;n++)if(o.coordinates[e][n][0]==t.coordinates[0]&&o.coordinates[e][n][1]==t.coordinates[1])return!0;return!1}if("Polygon"==o.type)return jsonOdm.Geo.pointWithinPolygon(t.coordinates,o.coordinates?o.coordinates[0]:null);if("MultiPolygon"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates,o.coordinates[e]?o.coordinates[e][0]:null))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.Point.within(t,o.geometries[e]))return!0;return!1}return jsonOdm.Geo.pointWithinBounds(t.coordinates,o)},jsonOdm.Geo.Point.intersects=jsonOdm.Geo.Point.within,jsonOdm.Geo.MultiPoint=function(t,o){this.type="MultiPoint",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.MultiPoint.within=function(t,o){var e,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return 1==t.coordinates.length&&t.coordinates[0][0]==o.coordinates[0]&&t.coordinates[0][1]==o.coordinates[1];if("MultiPoint"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,e=0;o.coordinates&&e<o.coordinates.length;e++)if(o.coordinates[e][0]==t.coordinates[n][0]&&o.coordinates[e][1]==t.coordinates[n][1]){i=!0;break}if(!i)return!1}return!0}if("LineString"==o.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)if(!jsonOdm.Geo.pointWithinLineString(t.coordinates[r],o.coordinates))return!1;return!0}if("MultiLineString"==o.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++){for(i=!1,e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],o.coordinates[e])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)if(!jsonOdm.Geo.pointWithinPolygon(t.coordinates[e],o.coordinates?o.coordinates[0]:null))return!1;return!0}if("MultiPolygon"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],o.coordinates[e]?o.coordinates[e][0]:null)){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiPoint.within(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[e],o))return!1;return!0},jsonOdm.Geo.MultiPoint.intersects=function(t,o){var e,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return jsonOdm.Geo.Point.intersects(o,t);if("MultiPoint"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(o.coordinates[e][0]==t.coordinates[n][0]&&o.coordinates[e][1]==t.coordinates[n][1])return!0;return!1}if("LineString"==o.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],o.coordinates))return!0;return!1}if("MultiLineString"==o.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],o.coordinates[e]))return!0;return!1}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[e],o.coordinates?o.coordinates[0]:null))return!0;return!1}if("MultiPolygon"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],o.coordinates[e]?o.coordinates[e][0]:null))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiPoint.intersects(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)if(jsonOdm.Geo.pointWithinBounds(t.coordinates[e],o))return!0;return!1},jsonOdm.Geo.LineString=function(t,o){this.type="LineString",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.LineString.within=function(t,o){var e,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type||"MultiPoint"==o.type)return!1;if("LineString"==o.type)return jsonOdm.Geo.lineStringWithinLineString(t.coordinates,o.coordinates);if("MultiLineString"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates,o.coordinates[e]))return!0;return!1}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length-1;e++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[e],t.coordinates[e+1]],o.coordinates[0]))return!1;return!0}if("MultiPolygon"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n],t.coordinates[n+1]],o.coordinates[e][0])&&n+1==t.coordinates.length-1)return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.LineString.within(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[e],o))return!1;return!0},jsonOdm.Geo.LineString.intersects=function(t,o){var e,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return jsonOdm.Geo.Point.intersects(o,t);if("MultiPoint"==o.type)return jsonOdm.Geo.MultiPoint.intersects(o,t);if("LineString"==o.type){for(e=0;e<t.coordinates.length-1;e++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[e],t.coordinates[e+1]],o.coordinates))return!0;return!1}if("MultiLineString"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n],t.coordinates[n+1]],o.coordinates[e]))return!0;return!1}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length-1;e++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[e],t.coordinates[e+1]],o.coordinates[0]))return!0;return!1}if("MultiPolygon"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n],t.coordinates[n+1]],o.coordinates[e][0]))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.LineString.intersects(t,o.geometries[e]))return!0;return!1}for(e=0;t.coordinates&&e<t.coordinates.length-1;e++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[e],t.coordinates[e+1]],o))return!0;return!1},jsonOdm.Geo.MultiLineString=function(t,o){this.type="MultiLineString",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.MultiLineString.within=function(t,o){var e,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type||"MultiPoint"==o.type)return!1;if("LineString"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)if(!jsonOdm.Geo.lineStringWithinLineString(t.coordinates[e],o.coordinates))return!1;return!0}if("MultiLineString"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates[n],o.coordinates[e])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)for(n=0;t.coordinates&&n<t.coordinates[e].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[e][n],t.coordinates[e][n+1]],o.coordinates[0]))return!1;return!0}if("MultiPolygon"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,e=0;o.coordinates&&e<o.coordinates.length;e++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][r],t.coordinates[n][r+1]],o.coordinates[e][0])&&r+1==t.coordinates[n].length-1){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiLineString.within(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)for(n=0;n<t.coordinates[e].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[e][n],o))return!1;return!0},jsonOdm.Geo.MultiLineString.intersects=function(t,o){var e,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return jsonOdm.Geo.Point.intersects(o,t);if("MultiPoint"==o.type)return jsonOdm.Geo.MultiPoint.intersects(o,t);if("LineString"==o.type)return jsonOdm.Geo.LineString.intersects(o,t);if("MultiLineString"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)for(e=0;o.coordinates&&e<o.coordinates.length;e++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n][r],t.coordinates[n][r+1]],o.coordinates[e]))return!0;return!1}if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)for(n=0;t.coordinates&&n<t.coordinates[e].length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[e][n],t.coordinates[e][n+1]],o.coordinates[0]))return!0;return!1}if("MultiPolygon"==o.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n][r],t.coordinates[n][r+1]],o.coordinates[e][0]))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiLineString.intersects(t,o.geometries[e]))return!0;return!1}for(e=0;t.coordinates&&e<t.coordinates.length;e++)for(n=0;n<t.coordinates[e].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[e][n],t.coordinates[e][n+1]],o))return!0;return!1},jsonOdm.Geo.Polygon=function(t,o){this.type="Polygon",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.Polygon.within=function(t,o){var e,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type||"MultiPoint"==o.type||"LineString"==o.type||"MultiLineString"==o.type)return!1;if("Polygon"==o.type){for(e=0;t.coordinates[0]&&e<t.coordinates[0].length-1;e++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][e],t.coordinates[0][e+1]],o.coordinates[0]))return!1;return!0}if("MultiPolygon"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++){var r=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],o.coordinates[e][0]);if(!r)break;if(r&&n+1==t.coordinates[0].length-1)return!0}return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.Polygon.within(t,o.geometries[e]))return!0;return!1}for(e=0;t.coordinates[0]&&e<t.coordinates[0].length;e++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[0][e],o))return!1;return!0},jsonOdm.Geo.Polygon.intersects=function(t,o){var e,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return jsonOdm.Geo.Point.intersects(o,t);if("MultiPoint"==o.type)return jsonOdm.Geo.MultiPoint.intersects(o,t);if("LineString"==o.type)return jsonOdm.Geo.LineString.intersects(o,t);if("MultiLineString"==o.type)return jsonOdm.Geo.MultiLineString.intersects(o,t);if("Polygon"==o.type){for(e=0;t.coordinates[0]&&e<t.coordinates[0].length-1;e++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[0][e],t.coordinates[0][e+1]],o.coordinates[0]))return!0;return!1}if("MultiPolygon"==o.type){for(e=0;o.coordinates&&e<o.coordinates.length;e++)for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],o.coordinates[e][0]))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.Polygon.intersects(t,o.geometries[e]))return!0;return!1}for(e=0;t.coordinates[0]&&e<t.coordinates[0].length-1;e++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[0][e],t.coordinates[0][e+1]],o))return!0;return!1},jsonOdm.Geo.MultiPolygon=function(t,o){this.type="MultiPolygon",this.coordinates=t,o&&(this.bbox=o)},jsonOdm.Geo.MultiPolygon.within=function(t,o){var e,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type||"MultiPoint"==o.type||"LineString"==o.type||"MultiLineString"==o.type)return!1;if("Polygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)for(n=0;n<t.coordinates[e][0].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[e][0][n],t.coordinates[e][0][n+1]],o.coordinates[0]))return!1;return!0}if("MultiPolygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++){for(i=!1,n=0;o.coordinates&&n<o.coordinates.length;n++)for(r=0;t.coordinates[e][0]&&r<t.coordinates[e][0].length-1;r++){var s=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[e][0][r],t.coordinates[e][0][r+1]],o.coordinates[n][0]);if(!s)break;if(s&&r+1==t.coordinates[e][0].length-1){i=!0;break}}if(!i)return!1}return!0}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiPolygon.within(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)for(n=0;n<t.coordinates[e][0].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[e][0][n],o))return!1;return!0},jsonOdm.Geo.MultiPolygon.intersects=function(t,o){var e,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==o.type)return jsonOdm.Geo.Point.intersects(o,t);if("MultiPoint"==o.type)return jsonOdm.Geo.MultiPoint.intersects(o,t);if("LineString"==o.type)return jsonOdm.Geo.LineString.intersects(o,t);if("MultiLineString"==o.type)return jsonOdm.Geo.MultiLineString.intersects(o,t);if("Polygon"==o.type)return jsonOdm.Geo.Polygon.intersects(o,t);if("MultiPolygon"==o.type){for(e=0;t.coordinates&&e<t.coordinates.length;e++)for(n=0;o.coordinates&&n<o.coordinates.length;n++)for(r=0;t.coordinates[e][0]&&r<t.coordinates[e][0].length-1;r++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[e][0][r],o.coordinates[n][0]))return!0;return!1}if("GeometryCollection"==o.type&&jsonOdm.util.isArray(o.geometries)){for(e=0;e<o.geometries.length;e++)if(jsonOdm.Geo.MultiPolygon.intersects(t,o.geometries[e]))return!0;return!1}for(e=0;e<t.coordinates.length;e++)for(n=0;n<t.coordinates[e][0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[e][0][n],t.coordinates[e][0][n+1]],o))return!0;return!1},jsonOdm.Geo.GeometryCollection=function(t,o){this.type="GeometryCollection",this.geometries=t,o&&(this.bbox=o)},jsonOdm.Geo.GeometryCollection.within=function(t,o){if(!jsonOdm.util.isArray(t.geometries)||!t.geometries.length||!o.type)return!1;for(var e=0;e<t.geometries.length;e++){if(!jsonOdm.Geo[t.geometries[e].type]||!jsonOdm.Geo[t.geometries[e].type].within)return!1;if(!jsonOdm.Geo[t.geometries[e].type].within(t.geometries[e],o))return!1}return!0},jsonOdm.Geo.GeometryCollection.intersects=function(t,o){if(!jsonOdm.util.isArray(t.geometries)||!t.geometries.length||!o.type)return!1;for(var e=0;e<t.geometries.length;e++)if(jsonOdm.Geo[t.geometries[e].type]&&jsonOdm.Geo[t.geometries[e].type].intersects&&jsonOdm.Geo[t.geometries[e].type].intersects(t.geometries[e],o))return!0;return!1},jsonOdm.Geo.pointWithinPolygon=function(t,o){if(!(jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(o)&&o.length>2))return!1;var e,n=0;(o[0][0]!=o[o.length-1][0]||o[0][1]!=o[o.length-1][1])&&(o=o.concat([o[0]]));for(var r=0;r<o.length-1;r++){if(o[r][0]==t[0]&&o[r][1]==t[1])return!0;if(!(o[r][0]<t[0]&&o[r+1][0]<t[0]||o[r][1]<t[1]&&o[r+1][1]<t[1]||o[r][1]>t[1]&&o[r+1][1]>t[1])){if(e=(o[r][0]-o[r+1][0])*((t[1]-o[r+1][1])/(o[r][1]-o[r+1][1]))+o[r+1][0],e==t[0]&&t[1]<=Math.max(o[r][1],o[r+1][1])&&t[1]>=Math.min(o[r][1],o[r+1][1]))return!0;e>t[0]&&n++}}return n%2==1},jsonOdm.Geo.edgeWithinPolygon=function(t,o){if(!(jsonOdm.util.isArray(t)&&2==t.length&&jsonOdm.util.isArray(o)&&o.length>=2))return!1;if((o[0][0]!=o[o.length-1][0]||o[0][1]!=o[o.length-1][1])&&(o=o.concat([o[0]])),!jsonOdm.Geo.pointWithinPolygon(t[0],o)||!jsonOdm.Geo.pointWithinPolygon(t[1],o))return!1;for(var e=0;e<o.length-1;e++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[o[e],o[e+1]],!1))return!1;return!0},jsonOdm.Geo.edgeIntersectsPolygon=function(t,o){if(!(jsonOdm.util.isArray(t)&&2==t.length&&jsonOdm.util.isArray(o)&&o.length>=2))return!1;if((o[0][0]!=o[o.length-1][0]||o[0][1]!=o[o.length-1][1])&&(o=o.concat([o[0]])),jsonOdm.Geo.pointWithinPolygon(t[0],o)||jsonOdm.Geo.pointWithinPolygon(t[1],o))return!0;for(var e=0;e<o.length-1;e++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[o[e],o[e+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsLineString=function(t,o){if(!jsonOdm.util.isArray(t)||2!=t.length||!jsonOdm.util.isArray(o))return!1;for(var e=0;e<o.length-1;e++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[o[e],o[e+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsEdge=function(t,o,e){e="undefined"==typeof e?!0:e;var n=[t[1][0]-t[0][0],t[1][1]-t[0][1]],r=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])],i=[o[1][0]-o[0][0],o[1][1]-o[0][1]],s=[Math.min(o[0][0],o[1][0]),Math.min(o[0][1],o[1][1]),Math.max(o[0][0],o[1][0]),Math.max(o[0][1],o[1][1])];if(r[0]>s[0]&&r[0]>s[2]||r[1]>s[1]&&r[1]>s[3]||s[0]>r[0]&&s[0]>r[2]||s[1]>r[1]&&s[1]>r[3])return!1;if(i[0]*n[1]-n[0]*i[1]==0)return e&&t[0][1]+(o[0][0]-t[0][0])/n[0]*n[1]==o[0][1];var d=(o[0][1]*i[0]+t[0][0]*i[1]-o[0][0]*i[1]-t[0][1]*i[0])/(n[1]*i[0]-n[0]*i[1]),u=t[0][0]+d*n[0],c=t[0][1]+d*n[1];return e?u>=r[0]&&u<=r[2]&&c>=r[1]&&c<=r[3]&&u>=s[0]&&u<=s[2]&&c>=s[1]&&c<=s[3]:u>r[0]&&u<r[2]&&c>r[1]&&c<r[3]&&u>s[0]&&u<s[2]&&c>s[1]&&c<s[3]},jsonOdm.Geo.pointWithinLineString=function(t,o){if(!(jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(o)&&o.length>=2))return!1;for(var e=0;e<o.length-1;e++)if((t[0]>=o[e][0]&&t[0]<=o[e+1][0]&&o[e][0]<=o[e+1][0]||t[0]<=o[e][0]&&t[0]>=o[e+1][0]&&o[e][0]>=o[e+1][0])&&(t[1]>=o[e][1]&&t[1]<=o[e+1][1]&&o[e][1]<=o[e+1][1]||t[1]<=o[e][1]&&t[1]>=o[e+1][1]&&o[e][1]>=o[e+1][1])&&(o[e][0]==t[0]&&o[e][1]==t[1]||o[e+1][0]==t[0]&&o[e+1][1]==t[1]||o[e][1]-o[e+1][1]!=0&&(o[e][0]-o[e+1][0])*((t[1]-o[e+1][1])/(o[e][1]-o[e+1][1]))+o[e+1][0]==t[0]||o[e][0]-o[e+1][0]!=0&&(o[e][1]-o[e+1][1])*((t[0]-o[e+1][0])/(o[e][0]-o[e+1][0]))+o[e+1][1]==t[1]))return!0;return!1},jsonOdm.Geo.pointWithinBounds=function(t,o){return jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(o)&&4==o.length?t[0]>=o[0]&&t[1]>=o[1]&&t[0]<=o[2]&&t[1]<=o[3]:!1},jsonOdm.Geo.edgeIntersectsBounds=function(t,o){return jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(o)&&4==o.length?jsonOdm.Geo.edgeIntersectsPolygon(t,[[o[0],o[1]],[o[2],o[1]],[o[2],o[3]],[o[0],o[3]]]):!1},jsonOdm.Geo.lineStringWithinLineString=function(t,o){if(!jsonOdm.util.isArray(t)||!jsonOdm.util.isArray(o))return!1;var e,n;for(e=0;t&&e<t.length;e++){var r=!1;for(n=0;o&&n<o.length;n++)if(t[e][0]==o[n][0]&&t[e][1]==o[n][1]){if(e+1==t.length)return!0;if(!(o[n+1]&&t[e+1][0]==o[n+1][0]&&t[e+1][1]==o[n+1][1]||t[e+1][0]==o[n][0]&&t[e+1][1]==o[n][1]||n>0&&t[e+1][0]==o[n-1][0]&&t[e+1][1]==o[n-1][1]))return!1;r=!0}if(!r)return!1}return!0},jsonOdm.Collection=function(t){var o=Object.create(Array.prototype);return o=Array.apply(o)||o,"undefined"!=typeof t&&jsonOdm.selectedSource&&jsonOdm.selectedSource[t]&&(o=o.concat(jsonOdm.selectedSource[t])),jsonOdm.Collection.decorate(o),o.$branch=function(){var t=jsonOdm.util.branch(o,arguments);return jsonOdm.Collection.decorate(t),t},o},jsonOdm.Collection.decorate=function(t){var o=function(t){jsonOdm.util.isArray(t)&&(t.$hasMany=function(o,e,n,r){"string"==typeof n&&(r=r||n);var i=n;"string"==typeof n&&jsonOdm.selectedSource&&jsonOdm.selectedSource[n]&&(i=jsonOdm.selectedSource[n]);for(var s=0;s<t.length;s++){var d=o;if(t[s].hasOwnProperty(o)&&(d=t[s][o]),"undefined"==typeof t[s][r])for(var u=0;d.length&&u<d.length;u++){for(var c=null,l=0;l<i.length;l++)if(d[u]==i[l][e]){c=i[l];break}null!=c&&(t[s][r]||(t[s][r]=[]),t[s][r].push(c))}}},t.$hasOne=function(o,e,n,r){"string"==typeof n&&(r=r||n);var i=n;"string"==typeof n&&jsonOdm.selectedSource&&jsonOdm.selectedSource[n]&&(i=jsonOdm.selectedSource[n]);for(var s=0;s<t.length;s++){var d;if(t[s].hasOwnProperty(o)&&(d=t[s][o]),"undefined"==typeof t[s][r]){for(var u=null,c=0;c<i.length;c++)if(d==i[c][e]){u=i[c];break}null!=u&&(t[s][r]=u)}}},t.$query=function(){return new jsonOdm.Query(t)})};o(t)},jsonOdm.Query=function(t){this.$$commandQueue=[],this.$$collection=t},jsonOdm.Query.prototype.$delete=function(){if(this.$$commandQueue.length<1)return this;for(var t=0;t<this.$$collection.length;){for(var o=!0,e=0;e<this.$$commandQueue.length&&(o=o&&this.$$commandQueue[e](this.$$collection[t]));e++);o?this.$$collection.splice(t,1):t++}return this},jsonOdm.Query.prototype.$all=function(t){if(this.$$commandQueue.length<1)return this.$$collection;for(var o=new jsonOdm.Collection,e=0;e<this.$$collection.length;e++){for(var n=!0,r=0;r<this.$$commandQueue.length&&(n=n&&this.$$commandQueue[r](this.$$collection[e]));r++);if(n){if(t)return this.$$collection[e];o.push(this.$$collection[e])}}return o},jsonOdm.Query.prototype.$first=function(){return this.$all(!0)},jsonOdm.Query.prototype.$testCollection=function(t,o){var e=this.$$commandQueue.pop(),n=function(){return function(n){if(!(e instanceof jsonOdm.Collection||"function"==typeof e||"undefined"==typeof e)||"function"!=typeof o)return!1;var r="undefined"==typeof e?n:e instanceof jsonOdm.Collection?e:e(n);return o(r,t)}}();return this.$$commandQueue.push(n),this},jsonOdm.Query.prototype.$binaryOperator=function(t,o){var e=function(t,e){return function(n){if("function"!=typeof e)return!1;for(var r=[],i=0;i<t.length;i++)for(var s=0;s<t[i].$$commandQueue.length;s++)r.push(t[i].$$commandQueue[s](n));return o(r)}}(t,o),n=new jsonOdm.Query(this.$$collection);return n.$$commandQueue.push(e),n},jsonOdm.Query.prototype.$branch=function(){var t=function(t){return function(o){return jsonOdm.util.branch(o,t)}}(arguments),o=new jsonOdm.Query(this.$$collection);return o.$$commandQueue.push(t),o},jsonOdm.Query.prototype.$eq=function(){return this.$testCollection(arguments,function(t,o){for(var e=0;e<o.length;e++)if(o[e]==t)return!0;return!1})},jsonOdm.Query.prototype.$in=function(t){return this.$testCollection(t,function(t,o){for(var e=0;e<o.length;e++)if(o[e]==t)return!0;return!1})},jsonOdm.Query.prototype.$ne=function(){return this.$testCollection(arguments,function(t,o){for(var e=0;e<o.length;e++)if(o[e]==t)return!1;return!0})},jsonOdm.Query.prototype.$nin=function(t){return this.$testCollection(t,function(t,o){for(var e=0;e<o.length;e++)if(o[e]==t)return!1;return!0})},jsonOdm.Query.prototype.$gt=function(t){return this.$testCollection(t,function(t,o){return t>o})},jsonOdm.Query.prototype.$gte=function(t){return this.$testCollection(t,function(t,o){return t>=o})},jsonOdm.Query.prototype.$lt=function(t){return this.$testCollection(t,function(t,o){return o>t})},jsonOdm.Query.prototype.$lte=function(t){return this.$testCollection(t,function(t,o){return o>=t})},jsonOdm.Query.prototype.$isNull=function(){return this.$testCollection(null,function(t){return"undefined"==typeof t||null===t})},jsonOdm.Query.prototype.$exists=function(){return this.$testCollection(null,function(t){return"undefined"!=typeof t})},jsonOdm.Query.prototype.$type=function(){return this.$testCollection(arguments,function(t,o){return jsonOdm.util.is(t,o)})},jsonOdm.Query.prototype.$mod=function(){return this.$testCollection(arguments,function(t,o){return t%o[0]==o[1]})},jsonOdm.Query.prototype.$regex=function(t,o){return"string"==typeof t&&(t="string"==typeof o?new RegExp(t,o):new RegExp(t)),this.$testCollection(t,function(t,o){return o.test(t)})},jsonOdm.Query.prototype.$text=function(t){for(var o,e,n=/(^| )-([^ ]+)( |$)/g,r=/"([^"]+)"/g,i=[],s=[];null!==(o=n.exec(t));)i.push(o[2]);for(t=t.replace(n,"");null!==(e=r.exec(t));)s.push(e[1]);t=t.replace(r,"");var d=t.split(" ");return this.$testCollection([i,s,d],function(t,o){for(var e=0;e<o[0].length;e++)if(t.indexOf(o[0][e])>-1)return!1;for(e=0;e<o[1].length;e++)if(t.indexOf(o[1][e])<0)return!1;for(e=0;e<o[2].length;e++)if(t.indexOf(o[2][e])>-1)return!0;return!!o[1].length})},jsonOdm.Query.prototype.$where=function(t){return"string"==typeof t&&(t=new Function(t)),this.$testCollection(t,function(t,o){return"function"!=typeof o?!1:o.apply(t)})},jsonOdm.Query.prototype.$geoWithin=function(t){return this.$testCollection(jsonOdm.Geo.detectAsGeometry(t),function(t,o){return jsonOdm.Geo[t.type]&&jsonOdm.Geo[t.type].within&&jsonOdm.Geo[t.type].within(t,o)})},jsonOdm.Query.prototype.$geoIntersects=function(t){return this.$testCollection(jsonOdm.Geo.detectAsGeometry(t),function(t,o){return jsonOdm.Geo[t.type]&&jsonOdm.Geo[t.type].intersects&&jsonOdm.Geo[t.type].intersects(t,o)})},jsonOdm.Query.prototype.$and=function(){return this.$binaryOperator(arguments,function(t){for(var o=0;o<t.length;o++)if(!t[o])return!1;return!0})},jsonOdm.Query.prototype.$nand=function(){return this.$binaryOperator(arguments,function(t){for(var o=0;o<t.length;o++)if(!t[o])return!0;return!1})},jsonOdm.Query.prototype.$not=jsonOdm.Query.prototype.$nand,jsonOdm.Query.prototype.$or=function(){return this.$binaryOperator(arguments,function(t){for(var o=0;o<t.length;o++)if(t[o])return!0;return!1})},jsonOdm.Query.prototype.$nor=function(){return this.$binaryOperator(arguments,function(t){for(var o=0;o<t.length;o++)if(t[o])return!1;return!0})}; | ||
"use strict";function JsonOdm(){var t=this;this.sources={},this.selectedSource={},this.addSource=function(e,o,n){"object"==typeof o&&("undefined"==typeof t.sources[e]&&(t.sources[e]=o),n&&(t.selectedSource=o))},this.selectSource=function(e){"undefined"!=typeof t.sources[e]&&(t.selectedSource=t.sources[e])}}var root="undefined"!=typeof window?window:global,odm=new JsonOdm;root.jsonOdm||(root.jsonOdm=odm),"undefined"!=typeof module&&module.exports&&(module.exports=odm),jsonOdm.Util=function(){},jsonOdm.Util.prototype.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},jsonOdm.Util.prototype.is=function(t,e){e="string"==typeof e?[e]:e;var o=Object.prototype.toString.call(t);o=o.substring(8,o.length-1).toLowerCase();for(var n=0;n<e.length;n++){var r=e[n].toLowerCase();if("array"==r&&this.isArray(t))return!0;if(r==o)return!0;if(typeof t==r)return!0}return!1},jsonOdm.Util.prototype.objectKeys=Object.keys||function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),o=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=o.length;return function(r){if("object"!=typeof r&&("function"!=typeof r||null===r))throw new TypeError("Object.keys called on non-object");var i,s,u=[];for(i in r)t.call(r,i)&&u.push(i);if(e)for(s=0;n>s;s++)t.call(r,o[s])&&u.push(o[s]);return u}}(),jsonOdm.Util.prototype.branch=function(t,e){function o(){if(arguments&&arguments.length&&this){var t=this[arguments[0]];return t?o.apply(t,Array.prototype.slice.call(arguments,1)):t}return this}return o.apply(t,e)},jsonOdm.Util.prototype.projectElement=function(t,e,o){var n,r={};for(var i in t)if(t.hasOwnProperty(i))if(1==t[i])r[i]=e[i];else if("function"==typeof t[i])r[i]=t[i](o||e);else if(t[i]instanceof jsonOdm.Query)for(n=0;n<t[i].$$commandQueue.length;n++)r[i]=t[i].$$commandQueue[n](0===n?e:r[i]);else"object"==typeof t[i]&&(r[i]=this.projectElement(t[i],e[i],o||e));return r},jsonOdm.util=new jsonOdm.Util,jsonOdm.Geo=function(){},jsonOdm.Geo.detectAsGeometry=function(t){if(!t.type)if(jsonOdm.util.isArray(t)&&2==t.length&&!jsonOdm.util.isArray(t[0]))t=new jsonOdm.Geo.Point(t);else if(jsonOdm.util.isArray(t)&&4==t.length&&!jsonOdm.util.isArray(t[0]))t=new jsonOdm.Geo.BoundaryBox(t);else if(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&2==t[0].length&&!jsonOdm.util.isArray(t[0][0]))t=new jsonOdm.Geo.LineString(t);else if(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&t[0].length>=1&&jsonOdm.util.isArray(t[0][0])&&2==t[0][0].length&&!jsonOdm.util.isArray(t[0][0][0]))t=new jsonOdm.Geo.Polygon(t);else{if(!(jsonOdm.util.isArray(t)&&t.length>=1&&jsonOdm.util.isArray(t[0])&&t[0].length>=1&&jsonOdm.util.isArray(t[0][0])&&t[0][0].length>=1&&jsonOdm.util.isArray(t[0][0][0])&&2==t[0][0][0].length)||jsonOdm.util.isArray(t[0][0][0][0]))return!1;t=new jsonOdm.Geo.MultiPolygon(t)}return t},jsonOdm.Geo.FeatureCollection=function(t,e){this.type="FeatureCollection",this.features=t||[],e&&(this.bbox=e)},jsonOdm.Geo.Feature=function(t,e,o,n){this.geometry=t||{},e&&(this.properties=e),o&&(this.bbox=o),n&&(this.id=n)},jsonOdm.Geo.BoundaryBox=function(t){var e=Object.create(Array.prototype);return e=Array.apply(e)||e,jsonOdm.util.isArray(t)?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]):(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e},jsonOdm.Geo.BoundaryBox.within=function(t,e){return jsonOdm.util.isArray(t)&&4==t.length?jsonOdm.Geo.Polygon.within(new jsonOdm.Geo.Polygon([[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],[t[0],t[1]]]]),e):!1},jsonOdm.Geo.Point=function(t,e){this.type="Point",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.Point.within=function(t,e){var o,n;if(!t.coordinates)return!1;if("Point"==e.type)return e.coordinates[0]==t.coordinates[0]&&e.coordinates[1]==t.coordinates[1];if("MultiPoint"==e.type||"LineString"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(e.coordinates[o][0]==t.coordinates[0]&&e.coordinates[o][1]==t.coordinates[1])return!0;return!1}if("MultiLineString"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;e.coordinates[o]&&n<e.coordinates[o].length;n++)if(e.coordinates[o][n][0]==t.coordinates[0]&&e.coordinates[o][n][1]==t.coordinates[1])return!0;return!1}if("Polygon"==e.type)return jsonOdm.Geo.pointWithinPolygon(t.coordinates,e.coordinates?e.coordinates[0]:null);if("MultiPolygon"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates,e.coordinates[o]?e.coordinates[o][0]:null))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.Point.within(t,e.geometries[o]))return!0;return!1}return jsonOdm.Geo.pointWithinBounds(t.coordinates,e)},jsonOdm.Geo.Point.intersects=jsonOdm.Geo.Point.within,jsonOdm.Geo.MultiPoint=function(t,e){this.type="MultiPoint",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.MultiPoint.within=function(t,e){var o,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return 1==t.coordinates.length&&t.coordinates[0][0]==e.coordinates[0]&&t.coordinates[0][1]==e.coordinates[1];if("MultiPoint"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,o=0;e.coordinates&&o<e.coordinates.length;o++)if(e.coordinates[o][0]==t.coordinates[n][0]&&e.coordinates[o][1]==t.coordinates[n][1]){i=!0;break}if(!i)return!1}return!0}if("LineString"==e.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)if(!jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates))return!1;return!0}if("MultiLineString"==e.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++){for(i=!1,o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[o])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)if(!jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates?e.coordinates[0]:null))return!1;return!0}if("MultiPolygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates[o]?e.coordinates[o][0]:null)){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiPoint.within(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[o],e))return!1;return!0},jsonOdm.Geo.MultiPoint.intersects=function(t,e){var o,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return jsonOdm.Geo.Point.intersects(e,t);if("MultiPoint"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(e.coordinates[o][0]==t.coordinates[n][0]&&e.coordinates[o][1]==t.coordinates[n][1])return!0;return!1}if("LineString"==e.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates))return!0;return!1}if("MultiLineString"==e.type){for(r=0;t.coordinates&&r<t.coordinates.length;r++)for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[o]))return!0;return!1}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates?e.coordinates[0]:null))return!0;return!1}if("MultiPolygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates[o]?e.coordinates[o][0]:null))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiPoint.intersects(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)if(jsonOdm.Geo.pointWithinBounds(t.coordinates[o],e))return!0;return!1},jsonOdm.Geo.LineString=function(t,e){this.type="LineString",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.LineString.within=function(t,e){var o,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type||"MultiPoint"==e.type)return!1;if("LineString"==e.type)return jsonOdm.Geo.lineStringWithinLineString(t.coordinates,e.coordinates);if("MultiLineString"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates,e.coordinates[o]))return!0;return!1}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[o][0])&&n+1==t.coordinates.length-1)return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.LineString.within(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[o],e))return!1;return!0},jsonOdm.Geo.LineString.intersects=function(t,e){var o,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return jsonOdm.Geo.Point.intersects(e,t);if("MultiPoint"==e.type)return jsonOdm.Geo.MultiPoint.intersects(e,t);if("LineString"==e.type){for(o=0;o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[o],t.coordinates[o+1]],e.coordinates))return!0;return!1}if("MultiLineString"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n],t.coordinates[n+1]],e.coordinates[o]))return!0;return!1}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[0]))return!0;return!1}if("MultiPolygon"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[o][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.LineString.intersects(t,e.geometries[o]))return!0;return!1}for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[o],t.coordinates[o+1]],e))return!0;return!1},jsonOdm.Geo.MultiLineString=function(t,e){this.type="MultiLineString",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.MultiLineString.within=function(t,e){var o,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type||"MultiPoint"==e.type)return!1;if("LineString"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)if(!jsonOdm.Geo.lineStringWithinLineString(t.coordinates[o],e.coordinates))return!1;return!0}if("MultiLineString"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates[n],e.coordinates[o])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;t.coordinates&&n<t.coordinates[o].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o][n],t.coordinates[o][n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++){for(i=!1,o=0;e.coordinates&&o<e.coordinates.length;o++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][r],t.coordinates[n][r+1]],e.coordinates[o][0])&&r+1==t.coordinates[n].length-1){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiLineString.within(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)for(n=0;n<t.coordinates[o].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[o][n],e))return!1;return!0},jsonOdm.Geo.MultiLineString.intersects=function(t,e){var o,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return jsonOdm.Geo.Point.intersects(e,t);if("MultiPoint"==e.type)return jsonOdm.Geo.MultiPoint.intersects(e,t);if("LineString"==e.type)return jsonOdm.Geo.LineString.intersects(e,t);if("MultiLineString"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)for(o=0;e.coordinates&&o<e.coordinates.length;o++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n][r],t.coordinates[n][r+1]],e.coordinates[o]))return!0;return!1}if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;t.coordinates&&n<t.coordinates[o].length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o][n],t.coordinates[o][n+1]],e.coordinates[0]))return!0;return!1}if("MultiPolygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(r=0;t.coordinates[n]&&r<t.coordinates[n].length-1;r++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n][r],t.coordinates[n][r+1]],e.coordinates[o][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiLineString.intersects(t,e.geometries[o]))return!0;return!1}for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;n<t.coordinates[o].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[o][n],t.coordinates[o][n+1]],e))return!0;return!1},jsonOdm.Geo.Polygon=function(t,e){this.type="Polygon",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.Polygon.within=function(t,e){var o,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type||"MultiPoint"==e.type||"LineString"==e.type||"MultiLineString"==e.type)return!1;if("Polygon"==e.type){for(o=0;t.coordinates[0]&&o<t.coordinates[0].length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][o],t.coordinates[0][o+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++){var r=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],e.coordinates[o][0]);if(!r)break;if(r&&n+1==t.coordinates[0].length-1)return!0}return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.Polygon.within(t,e.geometries[o]))return!0;return!1}for(o=0;t.coordinates[0]&&o<t.coordinates[0].length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[0][o],e))return!1;return!0},jsonOdm.Geo.Polygon.intersects=function(t,e){var o,n;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return jsonOdm.Geo.Point.intersects(e,t);if("MultiPoint"==e.type)return jsonOdm.Geo.MultiPoint.intersects(e,t);if("LineString"==e.type)return jsonOdm.Geo.LineString.intersects(e,t);if("MultiLineString"==e.type)return jsonOdm.Geo.MultiLineString.intersects(e,t);if("Polygon"==e.type){for(o=0;t.coordinates[0]&&o<t.coordinates[0].length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[0][o],t.coordinates[0][o+1]],e.coordinates[0]))return!0;return!1}if("MultiPolygon"==e.type){for(o=0;e.coordinates&&o<e.coordinates.length;o++)for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],e.coordinates[o][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.Polygon.intersects(t,e.geometries[o]))return!0;return!1}for(o=0;t.coordinates[0]&&o<t.coordinates[0].length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[0][o],t.coordinates[0][o+1]],e))return!0;return!1},jsonOdm.Geo.MultiPolygon=function(t,e){this.type="MultiPolygon",this.coordinates=t,e&&(this.bbox=e)},jsonOdm.Geo.MultiPolygon.within=function(t,e){var o,n,r,i;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type||"MultiPoint"==e.type||"LineString"==e.type||"MultiLineString"==e.type)return!1;if("Polygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;n<t.coordinates[o][0].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o][0][n],t.coordinates[o][0][n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++){for(i=!1,n=0;e.coordinates&&n<e.coordinates.length;n++)for(r=0;t.coordinates[o][0]&&r<t.coordinates[o][0].length-1;r++){var s=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o][0][r],t.coordinates[o][0][r+1]],e.coordinates[n][0]);if(!s)break;if(s&&r+1==t.coordinates[o][0].length-1){i=!0;break}}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiPolygon.within(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)for(n=0;n<t.coordinates[o][0].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[o][0][n],e))return!1;return!0},jsonOdm.Geo.MultiPolygon.intersects=function(t,e){var o,n,r;if(!t.coordinates||!jsonOdm.util.isArray(t.coordinates))return!1;if("Point"==e.type)return jsonOdm.Geo.Point.intersects(e,t);if("MultiPoint"==e.type)return jsonOdm.Geo.MultiPoint.intersects(e,t);if("LineString"==e.type)return jsonOdm.Geo.LineString.intersects(e,t);if("MultiLineString"==e.type)return jsonOdm.Geo.MultiLineString.intersects(e,t);if("Polygon"==e.type)return jsonOdm.Geo.Polygon.intersects(e,t);if("MultiPolygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(r=0;t.coordinates[o][0]&&r<t.coordinates[o][0].length-1;r++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o][0][r],e.coordinates[n][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(o=0;o<e.geometries.length;o++)if(jsonOdm.Geo.MultiPolygon.intersects(t,e.geometries[o]))return!0;return!1}for(o=0;o<t.coordinates.length;o++)for(n=0;n<t.coordinates[o][0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[o][0][n],t.coordinates[o][0][n+1]],e))return!0;return!1},jsonOdm.Geo.GeometryCollection=function(t,e){this.type="GeometryCollection",this.geometries=t,e&&(this.bbox=e)},jsonOdm.Geo.GeometryCollection.within=function(t,e){if(!jsonOdm.util.isArray(t.geometries)||!t.geometries.length||!e.type)return!1;for(var o=0;o<t.geometries.length;o++){if(!jsonOdm.Geo[t.geometries[o].type]||!jsonOdm.Geo[t.geometries[o].type].within)return!1;if(!jsonOdm.Geo[t.geometries[o].type].within(t.geometries[o],e))return!1}return!0},jsonOdm.Geo.GeometryCollection.intersects=function(t,e){if(!jsonOdm.util.isArray(t.geometries)||!t.geometries.length||!e.type)return!1;for(var o=0;o<t.geometries.length;o++)if(jsonOdm.Geo[t.geometries[o].type]&&jsonOdm.Geo[t.geometries[o].type].intersects&&jsonOdm.Geo[t.geometries[o].type].intersects(t.geometries[o],e))return!0;return!1},jsonOdm.Geo.pointWithinPolygon=function(t,e){if(!(jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(e)&&e.length>2))return!1;var o,n=0;(e[0][0]!=e[e.length-1][0]||e[0][1]!=e[e.length-1][1])&&(e=e.concat([e[0]]));for(var r=0;r<e.length-1;r++){if(e[r][0]==t[0]&&e[r][1]==t[1])return!0;if(!(e[r][0]<t[0]&&e[r+1][0]<t[0]||e[r][1]<t[1]&&e[r+1][1]<t[1]||e[r][1]>t[1]&&e[r+1][1]>t[1])){if(o=(e[r][0]-e[r+1][0])*((t[1]-e[r+1][1])/(e[r][1]-e[r+1][1]))+e[r+1][0],o==t[0]&&t[1]<=Math.max(e[r][1],e[r+1][1])&&t[1]>=Math.min(e[r][1],e[r+1][1]))return!0;o>t[0]&&n++}}return n%2==1},jsonOdm.Geo.edgeWithinPolygon=function(t,e){if(!(jsonOdm.util.isArray(t)&&2==t.length&&jsonOdm.util.isArray(e)&&e.length>=2))return!1;if((e[0][0]!=e[e.length-1][0]||e[0][1]!=e[e.length-1][1])&&(e=e.concat([e[0]])),!jsonOdm.Geo.pointWithinPolygon(t[0],e)||!jsonOdm.Geo.pointWithinPolygon(t[1],e))return!1;for(var o=0;o<e.length-1;o++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[o],e[o+1]],!1))return!1;return!0},jsonOdm.Geo.edgeIntersectsPolygon=function(t,e){if(!(jsonOdm.util.isArray(t)&&2==t.length&&jsonOdm.util.isArray(e)&&e.length>=2))return!1;if((e[0][0]!=e[e.length-1][0]||e[0][1]!=e[e.length-1][1])&&(e=e.concat([e[0]])),jsonOdm.Geo.pointWithinPolygon(t[0],e)||jsonOdm.Geo.pointWithinPolygon(t[1],e))return!0;for(var o=0;o<e.length-1;o++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[o],e[o+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsLineString=function(t,e){if(!jsonOdm.util.isArray(t)||2!=t.length||!jsonOdm.util.isArray(e))return!1;for(var o=0;o<e.length-1;o++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[o],e[o+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsEdge=function(t,e,o){o="undefined"==typeof o?!0:o;var n=[t[1][0]-t[0][0],t[1][1]-t[0][1]],r=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])],i=[e[1][0]-e[0][0],e[1][1]-e[0][1]],s=[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])];if(r[0]>s[0]&&r[0]>s[2]||r[1]>s[1]&&r[1]>s[3]||s[0]>r[0]&&s[0]>r[2]||s[1]>r[1]&&s[1]>r[3])return!1;if(i[0]*n[1]-n[0]*i[1]==0)return o&&t[0][1]+(e[0][0]-t[0][0])/n[0]*n[1]==e[0][1];var u=(e[0][1]*i[0]+t[0][0]*i[1]-e[0][0]*i[1]-t[0][1]*i[0])/(n[1]*i[0]-n[0]*i[1]),d=t[0][0]+u*n[0],c=t[0][1]+u*n[1];return o?d>=r[0]&&d<=r[2]&&c>=r[1]&&c<=r[3]&&d>=s[0]&&d<=s[2]&&c>=s[1]&&c<=s[3]:d>r[0]&&d<r[2]&&c>r[1]&&c<r[3]&&d>s[0]&&d<s[2]&&c>s[1]&&c<s[3]},jsonOdm.Geo.pointWithinLineString=function(t,e){if(!(jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(e)&&e.length>=2))return!1;for(var o=0;o<e.length-1;o++)if((t[0]>=e[o][0]&&t[0]<=e[o+1][0]&&e[o][0]<=e[o+1][0]||t[0]<=e[o][0]&&t[0]>=e[o+1][0]&&e[o][0]>=e[o+1][0])&&(t[1]>=e[o][1]&&t[1]<=e[o+1][1]&&e[o][1]<=e[o+1][1]||t[1]<=e[o][1]&&t[1]>=e[o+1][1]&&e[o][1]>=e[o+1][1])&&(e[o][0]==t[0]&&e[o][1]==t[1]||e[o+1][0]==t[0]&&e[o+1][1]==t[1]||e[o][1]-e[o+1][1]!=0&&(e[o][0]-e[o+1][0])*((t[1]-e[o+1][1])/(e[o][1]-e[o+1][1]))+e[o+1][0]==t[0]||e[o][0]-e[o+1][0]!=0&&(e[o][1]-e[o+1][1])*((t[0]-e[o+1][0])/(e[o][0]-e[o+1][0]))+e[o+1][1]==t[1]))return!0;return!1},jsonOdm.Geo.pointWithinBounds=function(t,e){return jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(e)&&4==e.length?t[0]>=e[0]&&t[1]>=e[1]&&t[0]<=e[2]&&t[1]<=e[3]:!1},jsonOdm.Geo.edgeIntersectsBounds=function(t,e){return jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(e)&&4==e.length?jsonOdm.Geo.edgeIntersectsPolygon(t,[[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]]):!1},jsonOdm.Geo.lineStringWithinLineString=function(t,e){if(!jsonOdm.util.isArray(t)||!jsonOdm.util.isArray(e))return!1;var o,n;for(o=0;t&&o<t.length;o++){var r=!1;for(n=0;e&&n<e.length;n++)if(t[o][0]==e[n][0]&&t[o][1]==e[n][1]){if(o+1==t.length)return!0;if(!(e[n+1]&&t[o+1][0]==e[n+1][0]&&t[o+1][1]==e[n+1][1]||t[o+1][0]==e[n][0]&&t[o+1][1]==e[n][1]||n>0&&t[o+1][0]==e[n-1][0]&&t[o+1][1]==e[n-1][1]))return!1;r=!0}if(!r)return!1}return!0},jsonOdm.Collection=function(t){var e=Object.create(Array.prototype);return e=Array.apply(e)||e,"undefined"!=typeof t&&jsonOdm.selectedSource&&jsonOdm.selectedSource[t]&&(e=e.concat(jsonOdm.selectedSource[t])),jsonOdm.Collection.decorate(e),e.$branch=function(){var t=jsonOdm.util.branch(e,arguments);return jsonOdm.Collection.decorate(t),t},e},jsonOdm.Collection.decorate=function(t){var e=function(t){jsonOdm.util.isArray(t)&&(t.$hasMany=function(e,o,n,r){"string"==typeof n&&(r=r||n);var i=n;"string"==typeof n&&jsonOdm.selectedSource&&jsonOdm.selectedSource[n]&&(i=jsonOdm.selectedSource[n]);for(var s=0;s<t.length;s++){var u=e;if(t[s].hasOwnProperty(e)&&(u=t[s][e]),"undefined"==typeof t[s][r])for(var d=0;u.length&&d<u.length;d++){for(var c=null,l=0;l<i.length;l++)if(u[d]==i[l][o]){c=i[l];break}null!=c&&(t[s][r]||(t[s][r]=[]),t[s][r].push(c))}}},t.$hasOne=function(e,o,n,r){"string"==typeof n&&(r=r||n);var i=n;"string"==typeof n&&jsonOdm.selectedSource&&jsonOdm.selectedSource[n]&&(i=jsonOdm.selectedSource[n]);for(var s=0;s<t.length;s++){var u;if(t[s].hasOwnProperty(e)&&(u=t[s][e]),"undefined"==typeof t[s][r]){for(var d=null,c=0;c<i.length;c++)if(u==i[c][o]){d=i[c];break}null!=d&&(t[s][r]=d)}}},t.$query=function(){return new jsonOdm.Query(t)})};e(t)},jsonOdm.Query=function(t){this.$$commandQueue=[],this.$$aggregationBeforeCollectQueue=[],this.$$aggregationResultQueue=[],this.$$collection=t},jsonOdm.Query.prototype.$delete=function(){if(this.$$commandQueue.length<1)return this;for(var t=0;t<this.$$collection.length;){for(var e=!0,o=0;o<this.$$commandQueue.length&&(e=e&&this.$$commandQueue[o](this.$$collection[t]));o++);e?this.$$collection.splice(t,1):t++}return this},jsonOdm.Query.prototype.$result=function(t,e){if(this.$$commandQueue.length<1)return this.$$collection;t="undefined"==typeof t?0:t,e="undefined"==typeof e?this.$$collection.length:e;var o,n,r,i=new jsonOdm.Collection;for(n=0;n<this.$$collection.length;n++){var s=!0;for(r=0;r<this.$$commandQueue.length&&(s=s&&this.$$commandQueue[r](this.$$collection[n]));r++);if(s){if(t>0){t--;continue}if(0>=e)return i;for(o=this.$$collection[n],r=0;r<this.$$aggregationBeforeCollectQueue.length;r++)o=this.$$aggregationBeforeCollectQueue[r](o);i.push(o),e--}}return i},jsonOdm.Query.prototype.$all=function(){return this.$result()},jsonOdm.Query.prototype.$first=function(){return this.$result(0,1)[0]},jsonOdm.Query.prototype.$aggregateCollection=function(){},jsonOdm.Query.prototype.$project=function(t){return this.$aggregateCollection(null,function(e,o){return jsonOdm.util.projectElement(t,o)})},jsonOdm.Query.prototype.$testCollection=function(t,e){var o=this.$$commandQueue.pop(),n=function(){return function(n){if(!(o instanceof jsonOdm.Collection||"function"==typeof o||"undefined"==typeof o)||"function"!=typeof e)return!1;var r="undefined"==typeof o?n:o instanceof jsonOdm.Collection?o:o(n);return!!e(r,t)}}();return this.$$commandQueue.push(n),this},jsonOdm.Query.prototype.$binaryOperator=function(t,e){var o=function(t,o){return function(n){if("function"!=typeof o)return!1;for(var r=[],i=0;i<t.length;i++)for(var s=0;s<t[i].$$commandQueue.length;s++)r.push(t[i].$$commandQueue[s](n));return!!e(r)}}(t,e),n=new jsonOdm.Query(this.$$collection);return n.$$commandQueue.push(o),n},jsonOdm.Query.prototype.$branch=function(){var t=function(t){return function(e){return jsonOdm.util.branch(e,t)}}(arguments),e=new jsonOdm.Query(this.$$collection);return e.$$commandQueue.push(t),e},jsonOdm.Query.prototype.$modifyField=function(t){var e=function(t,e){return function(o){return o=null!==e?e(o):o,"function"==typeof t?t(o):o}}(t,this.$$commandQueue.length?this.$$commandQueue[this.$$commandQueue.length-1]:null);return this.$$commandQueue.push(e),this},jsonOdm.Query.prototype.$substr=function(t,e){return this.$modifyField(function(t,e){return function(o){return"string"==typeof o?o.substr(t,e):o}}(t,e))},jsonOdm.Query.prototype.$eq=function(){return this.$testCollection(arguments,function(t,e){for(var o=0;o<e.length;o++)if(e[o]==t)return!0;return!1})},jsonOdm.Query.prototype.$in=function(t){return this.$testCollection(t,function(t,e){for(var o=0;o<e.length;o++)if(e[o]==t)return!0;return!1})},jsonOdm.Query.prototype.$ne=function(){return this.$testCollection(arguments,function(t,e){for(var o=0;o<e.length;o++)if(e[o]==t)return!1;return!0})},jsonOdm.Query.prototype.$nin=function(t){return this.$testCollection(t,function(t,e){for(var o=0;o<e.length;o++)if(e[o]==t)return!1;return!0})},jsonOdm.Query.prototype.$gt=function(t){return this.$testCollection(t,function(t,e){return t>e})},jsonOdm.Query.prototype.$gte=function(t){return this.$testCollection(t,function(t,e){return t>=e})},jsonOdm.Query.prototype.$lt=function(t){return this.$testCollection(t,function(t,e){return e>t})},jsonOdm.Query.prototype.$lte=function(t){return this.$testCollection(t,function(t,e){return e>=t})},jsonOdm.Query.prototype.$isNull=function(){return this.$testCollection(null,function(t){return"undefined"==typeof t||null===t})},jsonOdm.Query.prototype.$exists=function(){return this.$testCollection(null,function(t){return"undefined"!=typeof t})},jsonOdm.Query.prototype.$type=function(){return this.$testCollection(arguments,function(t,e){return jsonOdm.util.is(t,e)})},jsonOdm.Query.prototype.$mod=function(){return this.$testCollection(arguments,function(t,e){return t%e[0]==e[1]})},jsonOdm.Query.prototype.$regex=function(t,e){return"string"==typeof t&&(t="string"==typeof e?new RegExp(t,e):new RegExp(t)),this.$testCollection(t,function(t,e){return e.test(t)})},jsonOdm.Query.prototype.$text=function(t){for(var e,o,n=/(^| )-([^ ]+)( |$)/g,r=/"([^"]+)"/g,i=[],s=[];null!==(e=n.exec(t));)i.push(e[2]);for(t=t.replace(n,"");null!==(o=r.exec(t));)s.push(o[1]);t=t.replace(r,"");var u=t.split(" ");return this.$testCollection([i,s,u],function(t,e){for(var o=0;o<e[0].length;o++)if(t.indexOf(e[0][o])>-1)return!1;for(o=0;o<e[1].length;o++)if(t.indexOf(e[1][o])<0)return!1;for(o=0;o<e[2].length;o++)if(t.indexOf(e[2][o])>-1)return!0;return!!e[1].length})},jsonOdm.Query.prototype.$where=function(t){return"string"==typeof t&&(t=new Function(t)),this.$testCollection(t,function(t,e){return"function"!=typeof e?!1:e.apply(t)})},jsonOdm.Query.prototype.$geoWithin=function(t){return this.$testCollection(jsonOdm.Geo.detectAsGeometry(t),function(t,e){return jsonOdm.Geo[t.type]&&jsonOdm.Geo[t.type].within&&jsonOdm.Geo[t.type].within(t,e)})},jsonOdm.Query.prototype.$geoIntersects=function(t){return this.$testCollection(jsonOdm.Geo.detectAsGeometry(t),function(t,e){return jsonOdm.Geo[t.type]&&jsonOdm.Geo[t.type].intersects&&jsonOdm.Geo[t.type].intersects(t,e)})},jsonOdm.Query.prototype.$and=function(){return this.$binaryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(!t[e])return!1;return!0})},jsonOdm.Query.prototype.$nand=function(){return this.$binaryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(!t[e])return!0;return!1})},jsonOdm.Query.prototype.$not=jsonOdm.Query.prototype.$nand,jsonOdm.Query.prototype.$or=function(){return this.$binaryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(t[e])return!0;return!1})},jsonOdm.Query.prototype.$nor=function(){return this.$binaryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(t[e])return!1;return!0})}; |
@@ -26,3 +26,3 @@ "use strict"; | ||
description:"A light weight but fast object document mapper for JavaScript objects.", | ||
version:"0.1.1" | ||
version:"0.1.2" | ||
}, "jsonOdm")) | ||
@@ -29,0 +29,0 @@ .pipe(jsdoc.generator('./doc', |
{ | ||
"name": "json-odm", | ||
"version": "0.1.1", | ||
"description": "MaF) Object document mapper for JSON data that provides mongodb methods for querying and transformation as well as additional joining that is not provided by mongodb", | ||
"version": "0.1.2", | ||
"description": "Object document mapper for JSON data that provides mongodb methods for querying and transformation as well as additional joining that is not provided by mongodb", | ||
"main": " ./bin/json.odm.min.js", | ||
"bin": { | ||
"json-odm": "json.odm.min.js" | ||
"json-odm": "./bin/json.odm.min.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "directories": { |
@@ -1,2 +0,2 @@ | ||
JSON ODM v0.1.1 | ||
JSON ODM v0.1.2 | ||
======== | ||
@@ -30,3 +30,3 @@ by [Konsultaner](http://www.konsultaner.de), Richard Burkhardt | ||
- Array ($all,$elementMatch,$size) 0% // i may not implement the first two | ||
- Projection Operators ($,$elemMatch,$meta,$slice) 0% | ||
- Projection Operators ($,$elemMatch,$meta,$slice) 5% in experimental state | ||
- Support Promise/A+ sources for the odm.addSource | ||
@@ -36,20 +36,9 @@ - Full ~~CR~~U~~D~~ support | ||
Required NPM-Packages | ||
Install from NPM-Package | ||
--------------------- | ||
To build it from source use command ```gulp``` and after adding: | ||
```bash | ||
npm install --save-dev gulp | ||
npm install --save-dev gulp-concat | ||
npm install --save-dev gulp-filesize | ||
npm install --save-dev gulp-jsdoc | ||
npm install --save-dev gulp-uglify | ||
npm install --save-dev jsdoc3-bootstrap | ||
npm install json-odm | ||
``` | ||
To execute the benchmark use command ```gulp bench``` after adding: | ||
```bash | ||
npm install --save-dev gulp-bench | ||
``` | ||
Browser Support | ||
@@ -56,0 +45,0 @@ --------------- |
@@ -5,3 +5,2 @@ "use strict"; | ||
* The main class holding all sub classes and the data source | ||
* @version 0.0.1 | ||
* @author Richard Burkhardt - Konsultaner | ||
@@ -8,0 +7,0 @@ * |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2084872
9310
115