Socket
Socket
Sign inDemoInstall

json-odm

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-odm - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

bin/json.odm.js

4

bin/json.odm.min.js

@@ -1,2 +0,2 @@

"use strict";function JsonOdm(){var t=this;this.sources={},this.selectedSource={},this.addSource=function(e,n,o){"object"==typeof n&&("undefined"==typeof t.sources[e]&&(t.sources[e]=n),o&&(t.selectedSource=n))},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 n=Object.prototype.toString.call(t);n=n.substring(8,n.length-1).toLowerCase();for(var o=0;o<e.length;o++){var r=e[o].toLowerCase();if("array"==r&&this.isArray(t))return!0;if(r==n)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"),n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=n.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;o>s;s++)t.call(r,n[s])&&u.push(n[s]);return u}}(),jsonOdm.Util.prototype.branch=function(t,e){function n(){if(arguments&&arguments.length&&this){var t=this[arguments[0]];return t?n.apply(t,Array.prototype.slice.call(arguments,1)):t}return this}return n.apply(t,e)},jsonOdm.Util.prototype.projectElement=function(t,e,n){var o={};for(var r in t)t.hasOwnProperty(r)&&(1==t[r]?o[r]=e[r]:"function"==typeof t[r]?o[r]=t[r](n||e):t[r]instanceof jsonOdm.Query?(o[r]=t[r].$$commandQueue[t[r].$$commandQueue.length-1](e),t[r].$$accumulation!==!1&&(o[r]=t[r].$$accumulation)):"object"==typeof t[r]&&(o[r]=this.projectElement(t[r],e[r],n||e)));return 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,e){this.type="FeatureCollection",this.features=t||[],e&&(this.bbox=e)},jsonOdm.Geo.Feature=function(t,e,n,o){this.geometry=t||{},e&&(this.properties=e),n&&(this.bbox=n),o&&(this.id=o)},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 n,o;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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]==t.coordinates[0]&&e.coordinates[n][1]==t.coordinates[1])return!0;return!1}if("MultiLineString"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;e.coordinates[n]&&o<e.coordinates[n].length;o++)if(e.coordinates[n][o][0]==t.coordinates[0]&&e.coordinates[n][o][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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates,e.coordinates[n]?e.coordinates[n][0]:null))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Point.within(t,e.geometries[n]))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 n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++){for(i=!1,n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]==t.coordinates[o][0]&&e.coordinates[n][1]==t.coordinates[o][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,n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[n])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates?e.coordinates[0]:null))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++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates[n]?e.coordinates[n][0]:null)){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPoint.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n],e))return!1;return!0},jsonOdm.Geo.MultiPoint.intersects=function(t,e){var n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]==t.coordinates[o][0]&&e.coordinates[n][1]==t.coordinates[o][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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[n]))return!0;return!1}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates?e.coordinates[0]:null))return!0;return!1}if("MultiPolygon"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates[n]?e.coordinates[n][0]:null))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPoint.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(jsonOdm.Geo.pointWithinBounds(t.coordinates[n],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 n,o;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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates,e.coordinates[n]))return!0;return!1}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n][0])&&o+1==t.coordinates.length-1)return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.LineString.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n],e))return!1;return!0},jsonOdm.Geo.LineString.intersects=function(t,e){var n,o;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(n=0;n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n],t.coordinates[n+1]],e.coordinates))return!0;return!1}if("MultiLineString"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n]))return!0;return!1}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[0]))return!0;return!1}if("MultiPolygon"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.LineString.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n],t.coordinates[n+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 n,o,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(n=0;t.coordinates&&n<t.coordinates.length;n++)if(!jsonOdm.Geo.lineStringWithinLineString(t.coordinates[n],e.coordinates))return!1;return!0}if("MultiLineString"==e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++){for(i=!1,n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates[o],e.coordinates[n])){i=!0;break}if(!i)return!1}return!0}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates[n].length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][o],t.coordinates[n][o+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]&&r<t.coordinates[o].length-1;r++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n][0])&&r+1==t.coordinates[o].length-1){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiLineString.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n].length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n][o],e))return!1;return!0},jsonOdm.Geo.MultiLineString.intersects=function(t,e){var n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++)for(r=0;t.coordinates[o]&&r<t.coordinates[o].length-1;r++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n]))return!0;return!1}if("Polygon"==e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates[n].length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n][o],t.coordinates[n][o+1]],e.coordinates[0]))return!0;return!1}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]&&r<t.coordinates[o].length-1;r++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiLineString.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n].length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n][o],t.coordinates[n][o+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 n,o;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(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates[0]&&o<t.coordinates[0].length-1;o++){var r=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][o],t.coordinates[0][o+1]],e.coordinates[n][0]);if(!r)break;if(r&&o+1==t.coordinates[0].length-1)return!0}return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Polygon.within(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates[0]&&n<t.coordinates[0].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[0][n],e))return!1;return!0},jsonOdm.Geo.Polygon.intersects=function(t,e){var n,o;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(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[0]))return!0;return!1}if("MultiPolygon"==e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)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[n][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Polygon.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[0][n],t.coordinates[0][n+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 n,o,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(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][0][o],t.coordinates[n][0][o+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][0]&&r<t.coordinates[n][0].length-1;r++){var s=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][0][r],t.coordinates[n][0][r+1]],e.coordinates[o][0]);if(!s)break;if(s&&r+1==t.coordinates[n][0].length-1){i=!0;break}}if(!i)return!1}return!0}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPolygon.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n][0][o],e))return!1;return!0},jsonOdm.Geo.MultiPolygon.intersects=function(t,e){var n,o,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(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][0]&&r<t.coordinates[n][0].length-1;r++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n][0][r],e.coordinates[o][0]))return!0;return!1}if("GeometryCollection"==e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPolygon.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n][0][o],t.coordinates[n][0][o+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 n=0;n<t.geometries.length;n++){if(!jsonOdm.Geo[t.geometries[n].type]||!jsonOdm.Geo[t.geometries[n].type].within)return!1;if(!jsonOdm.Geo[t.geometries[n].type].within(t.geometries[n],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 n=0;n<t.geometries.length;n++)if(jsonOdm.Geo[t.geometries[n].type]&&jsonOdm.Geo[t.geometries[n].type].intersects&&jsonOdm.Geo[t.geometries[n].type].intersects(t.geometries[n],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 n,o=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(n=(e[r][0]-e[r+1][0])*((t[1]-e[r+1][1])/(e[r][1]-e[r+1][1]))+e[r+1][0],n==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;n>t[0]&&o++}}return o%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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsEdge=function(t,e,n){n="undefined"==typeof n?!0:n;var o=[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]*o[1]-o[0]*i[1]==0)return n&&t[0][1]+(e[0][0]-t[0][0])/o[0]*o[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])/(o[1]*i[0]-o[0]*i[1]),c=t[0][0]+u*o[0],d=t[0][1]+u*o[1];return n?c>=r[0]&&c<=r[2]&&d>=r[1]&&d<=r[3]&&c>=s[0]&&c<=s[2]&&d>=s[1]&&d<=s[3]:c>r[0]&&c<r[2]&&d>r[1]&&d<r[3]&&c>s[0]&&c<s[2]&&d>s[1]&&d<s[3]},jsonOdm.Geo.pointWithinLineString=function(t,e){if(!(jsonOdm.util.isArray(t)&&jsonOdm.util.isArray(e)&&e.length>=2))return!1;for(var n=0;n<e.length-1;n++)if((t[0]>=e[n][0]&&t[0]<=e[n+1][0]&&e[n][0]<=e[n+1][0]||t[0]<=e[n][0]&&t[0]>=e[n+1][0]&&e[n][0]>=e[n+1][0])&&(t[1]>=e[n][1]&&t[1]<=e[n+1][1]&&e[n][1]<=e[n+1][1]||t[1]<=e[n][1]&&t[1]>=e[n+1][1]&&e[n][1]>=e[n+1][1])&&(e[n][0]==t[0]&&e[n][1]==t[1]||e[n+1][0]==t[0]&&e[n+1][1]==t[1]||e[n][1]-e[n+1][1]!=0&&(e[n][0]-e[n+1][0])*((t[1]-e[n+1][1])/(e[n][1]-e[n+1][1]))+e[n+1][0]==t[0]||e[n][0]-e[n+1][0]!=0&&(e[n][1]-e[n+1][1])*((t[0]-e[n+1][0])/(e[n][0]-e[n+1][0]))+e[n+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 n,o;for(n=0;t&&n<t.length;n++){var r=!1;for(o=0;e&&o<e.length;o++)if(t[n][0]==e[o][0]&&t[n][1]==e[o][1]){if(n+1==t.length)return!0;if(!(e[o+1]&&t[n+1][0]==e[o+1][0]&&t[n+1][1]==e[o+1][1]||t[n+1][0]==e[o][0]&&t[n+1][1]==e[o][1]||o>0&&t[n+1][0]==e[o-1][0]&&t[n+1][1]==e[o-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,n,o,r){"string"==typeof o&&(r=r||o);var i=o;"string"==typeof o&&jsonOdm.selectedSource&&jsonOdm.selectedSource[o]&&(i=jsonOdm.selectedSource[o]);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 c=0;u.length&&c<u.length;c++){for(var d=null,a=0;a<i.length;a++)if(u[c]==i[a][n]){d=i[a];break}null!=d&&(t[s][r]||(t[s][r]=[]),t[s][r].push(d))}}},t.$hasOne=function(e,n,o,r){"string"==typeof o&&(r=r||o);var i=o;"string"==typeof o&&jsonOdm.selectedSource&&jsonOdm.selectedSource[o]&&(i=jsonOdm.selectedSource[o]);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 c=null,d=0;d<i.length;d++)if(u==i[d][n]){c=i[d];break}null!=c&&(t[s][r]=c)}}},t.$query=function(){return new jsonOdm.Query(t)})};e(t)},jsonOdm.Query=function(t){this.$$commandQueue=[],this.$$aggregationBeforeCollectQueue=[],this.$$aggregationResultQueue=[],this.$$collection=t||[],this.$$accumulation=!1},jsonOdm.Query.prototype.$delete=function(){if(this.$$commandQueue.length<1)return this;for(var t=0;t<this.$$collection.length;){for(var e=!0,n=0;n<this.$$commandQueue.length&&(e=e&&this.$$commandQueue[n](this.$$collection[t]));n++);e?this.$$collection.splice(t,1):t++}return this},jsonOdm.Query.prototype.$result=function(t,e){if(this.$$commandQueue.length<1&&this.$$aggregationBeforeCollectQueue<1)return this.$$collection;t="undefined"==typeof t?0:t,e="undefined"==typeof e?this.$$collection.length:e;var n,o,r,i=new jsonOdm.Collection;for(o=0;o<this.$$collection.length;o++){var s=!0;for(r=0;r<this.$$commandQueue.length;r++){var u=this.$$commandQueue[r](this.$$collection[o]);if(!(s=s&&null!==u&&u!==!1&&"undefined"!=typeof u))break}if(s){if(t>0){t--;continue}if(0>=e)return i;for(n=this.$$collection[o],r=0;r<this.$$aggregationBeforeCollectQueue.length;r++)n=this.$$aggregationBeforeCollectQueue[r](o,n);i.push(n),e--}}for(o=0;o<this.$$aggregationResultQueue.length;o++)i=this.$$aggregationResultQueue[o](i);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(t,e,n){return"function"==typeof t&&(t=[t]),"function"==typeof e&&(e=[e]),"function"==typeof n&&(n=[n]),jsonOdm.util.isArray(t)&&(this.$$commandQueue=this.$$commandQueue.concat(t)),jsonOdm.util.isArray(e)&&(this.$$aggregationBeforeCollectQueue=this.$$aggregationBeforeCollectQueue.concat(e)),jsonOdm.util.isArray(n)&&(this.$$aggregationResultQueue=this.$$aggregationResultQueue.concat(n)),this},jsonOdm.Query.prototype.$group=function(){var t=arguments,e=!1,n=[];return arguments.length>1&&!jsonOdm.util.isArray(arguments[arguments.length-1])&&!jsonOdm.util.is(arguments[arguments.length-1],"string")&&"object"==typeof arguments[arguments.length-1]&&(e=arguments[arguments.length-1],t=Array.prototype.slice.call(arguments,0,arguments.length-1)),this.$aggregateCollection(function(t,e){var n={};return function(o){for(var r,i={},s=!1,u=n,c=0;c<t.length;c++){var d=jsonOdm.util.isArray(t[c])?t[c]:[t[c]];r=jsonOdm.util.branch(o,d),c<t.length-1&&("undefined"==typeof u[""+r]&&(s=!0,u[""+r]={}),u=u[""+r]);for(var a=i,l=0;l<d.length-1;l++)"undefined"==typeof a[d[l]]&&(a[d[l]]={}),a=a[d[l]];a[d[d.length-1]]=r}return u[""+r]||(u[""+r]={accumulationObject:i,subResultSet:[]},e.push(u[""+r])),u[""+r].subResultSet.push(o),!0}}(t,n),null,function(t,e){function n(t){for(var e in t)t.hasOwnProperty(e)&&(t[e]instanceof jsonOdm.Query&&(t[e].$$accumulation=!1),"object"==typeof t[e]&&n(t[e]))}return function(){for(var o=new jsonOdm.Collection,r=0;r<t.length;r++)if(e===!1)o.push(t[r].accumulationObject);else{n(e);for(var i={},s=0;s<t[r].subResultSet.length;s++)i=jsonOdm.util.projectElement(e,t[r].subResultSet[s]);for(s in t[r].accumulationObject)t[r].accumulationObject.hasOwnProperty(s)&&(i[s]=t[r].accumulationObject[s]);o.push(i)}return o}}(n,e))},jsonOdm.Query.prototype.$project=function(t){return this.$aggregateCollection(null,function(e,n){return jsonOdm.util.projectElement(t,n)})},jsonOdm.Query.prototype.$testCollection=function(t,e){var n=this.$$commandQueue.pop(),o=function(){return function(o){if(!(n instanceof jsonOdm.Collection||"function"==typeof n||"undefined"==typeof n)||"function"!=typeof e)return!1;var r="undefined"==typeof n?o:n instanceof jsonOdm.Collection?n:n(o);return!!e(r,t)}}();return this.$$commandQueue.push(o),this},jsonOdm.Query.prototype.$queryOperator=function(t,e){var n=function(t,n){return function(o){if("function"!=typeof n)return!1;for(var r=[],i=0;i<t.length;i++)if(t[i]instanceof jsonOdm.Query)for(var s=0;s<t[i].$$commandQueue.length;s++)r.push(t[i].$$commandQueue[s](o));else r.push(t[i]);return e(r)}}(t,e),o=new jsonOdm.Query(this.$$collection);return o.$$commandQueue.push(n),o},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(n){return n=null!==e?e(n):n,"function"==typeof t?t(n):n}}(t,this.$$commandQueue.length?this.$$commandQueue[this.$$commandQueue.length-1]:null);return this.$$commandQueue.push(e),this},jsonOdm.Query.stringFiledModifyer=["charAt","charCodeAt","concat","fromCharCode","indexOf","lastIndexOf","localeCompare","match","replace","search","slice","split","substr","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","valueOf"];for(var i=0;i<jsonOdm.Query.stringFiledModifyer.length;i++)jsonOdm.Query.prototype["$"+jsonOdm.Query.stringFiledModifyer[i]]=function(t){return function(){return this.$modifyField(function(t,e){return function(n){return"string"==typeof n&&String.prototype.hasOwnProperty(e)?String.prototype[e].apply(n,t):n}}(arguments,t))}}(jsonOdm.Query.stringFiledModifyer[i]);jsonOdm.Query.prototype.$accumulator=function(t,e){t="string"==typeof t?[t]:t;var n=new jsonOdm.Query(this.$$collection),o=function(t,e,n,o){return function(r){var i=null!==t?jsonOdm.util.branch(r,t):t;return n.$$accumulation=e(i,n.$$accumulation,r),o.$$accumulation=n.$$accumulation,i}}(t,e,n,this);return n.$$commandQueue.push(o),n},jsonOdm.Query.prototype.$sum=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=0),t+e})},jsonOdm.Query.prototype.$avg=function(t){var e,n;return this.$accumulator(t,function(t,o){return o===!1&&(e=0,n=0),n+=t,e++,n/e})},jsonOdm.Query.prototype.$max=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=t),Math.max(t,e)})},jsonOdm.Query.prototype.$min=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=t),Math.min(t,e)})},jsonOdm.Query.prototype.$count=function(){return this.$accumulator(null,function(t,e){return e===!1&&(e=0),++e})},jsonOdm.Query.prototype.$push=function(){var t=new jsonOdm.Query(this.$$collection),e=function(t,e){return function(n){return t.$$accumulation=t.$$accumulation===!1?[]:t.$$accumulation,t.$$accumulation.push(n),e.$$accumulation=t.$$accumulation,!0}}(t,this);return t.$$commandQueue.push(e),t},jsonOdm.Query.prototype.$add=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e+=t[n];return e})},jsonOdm.Query.prototype.$subtract=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e-=t[n];return e})},jsonOdm.Query.prototype.$multiply=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e*=t[n];return e})},jsonOdm.Query.prototype.$divide=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e/=t[n];return e})},jsonOdm.Query.prototype.$modulo=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e%=t[n];return e})},jsonOdm.Query.prototype.$eq=function(){return this.$testCollection(arguments,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0;return!1})},jsonOdm.Query.prototype.$in=function(t){return this.$testCollection(t,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0;return!1
})},jsonOdm.Query.prototype.$ne=function(){return this.$testCollection(arguments,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!1;return!0})},jsonOdm.Query.prototype.$nin=function(t){return this.$testCollection(t,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===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,n,o=/(^| )-([^ ]+)( |$)/g,r=/"([^"]+)"/g,i=[],s=[];null!==(e=o.exec(t));)i.push(e[2]);for(t=t.replace(o,"");null!==(n=r.exec(t));)s.push(n[1]);t=t.replace(r,"");var u=t.split(" ");return this.$testCollection([i,s,u],function(t,e){for(var n=0;n<e[0].length;n++)if(t.indexOf(e[0][n])>-1)return!1;for(n=0;n<e[1].length;n++)if(t.indexOf(e[1][n])<0)return!1;for(n=0;n<e[2].length;n++)if(t.indexOf(e[2][n])>-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.$queryOperator(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.$queryOperator(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.$queryOperator(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.$queryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(t[e])return!1;return!0})};
"use strict";function JsonOdm(){var t=this;this.sources={},this.selectedSource={},this.addSource=function(e,n,o){"object"==typeof n&&("undefined"==typeof t.sources[e]&&(t.sources[e]=n),o&&(t.selectedSource=n))},this.selectSource=function(e){"undefined"!=typeof t.sources[e]&&(t.selectedSource=t.sources[e])}}function createQueryStringModifier(t){return function(){return this.$modifyField(function(t,e){return function(n){return"string"==typeof n&&String.prototype.hasOwnProperty(e)?String.prototype[e].apply(n,t):n}}(arguments,t))}}var root="undefined"!=typeof window?window:global,jsonOdm=new JsonOdm;if(root.jsonOdm||(root.jsonOdm=jsonOdm),"undefined"!=typeof module&&module.exports&&(module.exports=jsonOdm),"undefined"==typeof jsonOdm)var jsonOdm=new JsonOdm;if(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 n=Object.prototype.toString.call(t);n=n.substring(8,n.length-1).toLowerCase();for(var o=0;o<e.length;o++){var r=e[o].toLowerCase();if("array"==r&&this.isArray(t))return!0;if(r===n)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"),n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=n.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;o>s;s++)t.call(r,n[s])&&u.push(n[s]);return u}}(),jsonOdm.Util.prototype.branch=function(t,e){function n(){if(arguments&&arguments.length&&this){var t=this[arguments[0]];return t?n.apply(t,Array.prototype.slice.call(arguments,1)):t}return this}return n.apply(t,e)},jsonOdm.Util.prototype.projectElement=function(t,e,n){var o={};for(var r in t)t.hasOwnProperty(r)&&(1==t[r]?o[r]=e[r]:"function"==typeof t[r]?o[r]=t[r](n||e):t[r]instanceof jsonOdm.Query?(o[r]=t[r].$$commandQueue[t[r].$$commandQueue.length-1](e),t[r].$$accumulation!==!1&&(o[r]=t[r].$$accumulation)):"object"==typeof t[r]&&(o[r]=this.projectElement(t[r],e[r],n||e)));return o},jsonOdm.util=new jsonOdm.Util,"undefined"==typeof jsonOdm)var jsonOdm=new JsonOdm;if(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,n,o){this.geometry=t||{},e&&(this.properties=e),n&&(this.bbox=n),o&&(this.id=o)},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 n,o;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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]===t.coordinates[0]&&e.coordinates[n][1]===t.coordinates[1])return!0;return!1}if("MultiLineString"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;e.coordinates[n]&&o<e.coordinates[n].length;o++)if(e.coordinates[n][o][0]===t.coordinates[0]&&e.coordinates[n][o][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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates,e.coordinates[n]?e.coordinates[n][0]:null))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Point.within(t,e.geometries[n]))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 n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++){for(i=!1,n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]===t.coordinates[o][0]&&e.coordinates[n][1]===t.coordinates[o][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,n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[n])){i=!0;break}if(!i)return!1}return!0}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates?e.coordinates[0]:null))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++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates[n]?e.coordinates[n][0]:null)){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPoint.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n],e))return!1;return!0},jsonOdm.Geo.MultiPoint.intersects=function(t,e){var n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(e.coordinates[n][0]===t.coordinates[o][0]&&e.coordinates[n][1]===t.coordinates[o][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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinLineString(t.coordinates[r],e.coordinates[n]))return!0;return!1}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n],e.coordinates?e.coordinates[0]:null))return!0;return!1}if("MultiPolygon"===e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[o],e.coordinates[n]?e.coordinates[n][0]:null))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPoint.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(jsonOdm.Geo.pointWithinBounds(t.coordinates[n],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 n,o;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(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates,e.coordinates[n]))return!0;return!1}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n][0])&&o+1===t.coordinates.length-1)return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.LineString.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n],e))return!1;return!0},jsonOdm.Geo.LineString.intersects=function(t,e){var n,o;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(n=0;n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[n],t.coordinates[n+1]],e.coordinates))return!0;return!1}if("MultiLineString"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n]))return!0;return!1}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n],t.coordinates[n+1]],e.coordinates[0]))return!0;return!1}if("MultiPolygon"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates.length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o],t.coordinates[o+1]],e.coordinates[n][0]))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.LineString.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates&&n<t.coordinates.length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n],t.coordinates[n+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 n,o,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(n=0;t.coordinates&&n<t.coordinates.length;n++)if(!jsonOdm.Geo.lineStringWithinLineString(t.coordinates[n],e.coordinates))return!1;return!0}if("MultiLineString"===e.type){for(o=0;t.coordinates&&o<t.coordinates.length;o++){for(i=!1,n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.lineStringWithinLineString(t.coordinates[o],e.coordinates[n])){i=!0;break}if(!i)return!1}return!0}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates[n].length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][o],t.coordinates[n][o+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]&&r<t.coordinates[o].length-1;r++)if(jsonOdm.Geo.edgeWithinPolygon([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n][0])&&r+1===t.coordinates[o].length-1){i=!0;break}if(!i)return!1}return!0}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiLineString.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n].length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n][o],e))return!1;return!0},jsonOdm.Geo.MultiLineString.intersects=function(t,e){var n,o,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(o=0;t.coordinates&&o<t.coordinates.length;o++)for(r=0;t.coordinates[o]&&r<t.coordinates[o].length-1;r++)for(n=0;e.coordinates&&n<e.coordinates.length;n++)if(jsonOdm.Geo.edgeIntersectsLineString([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n]))return!0;return!1}if("Polygon"===e.type){for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;t.coordinates&&o<t.coordinates[n].length-1;o++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[n][o],t.coordinates[n][o+1]],e.coordinates[0]))return!0;return!1}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]&&r<t.coordinates[o].length-1;r++)if(jsonOdm.Geo.edgeIntersectsPolygon([t.coordinates[o][r],t.coordinates[o][r+1]],e.coordinates[n][0]))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiLineString.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n].length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n][o],t.coordinates[n][o+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 n,o;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(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][n],t.coordinates[0][n+1]],e.coordinates[0]))return!1;return!0}if("MultiPolygon"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)for(o=0;t.coordinates[0]&&o<t.coordinates[0].length-1;o++){var r=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[0][o],t.coordinates[0][o+1]],e.coordinates[n][0]);if(!r)break;if(r&&o+1===t.coordinates[0].length-1)return!0}return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Polygon.within(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates[0]&&n<t.coordinates[0].length;n++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[0][n],e))return!1;return!0},jsonOdm.Geo.Polygon.intersects=function(t,e){var n,o;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(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[0]))return!0;return!1}if("MultiPolygon"===e.type){for(n=0;e.coordinates&&n<e.coordinates.length;n++)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[n][0]))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.Polygon.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;t.coordinates[0]&&n<t.coordinates[0].length-1;n++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[0][n],t.coordinates[0][n+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 n,o,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(n=0;t.coordinates&&n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length-1;o++)if(!jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][0][o],t.coordinates[n][0][o+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][0]&&r<t.coordinates[n][0].length-1;r++){var s=jsonOdm.Geo.edgeWithinPolygon([t.coordinates[n][0][r],t.coordinates[n][0][r+1]],e.coordinates[o][0]);if(!s)break;if(s&&r+1===t.coordinates[n][0].length-1){i=!0;break}}if(!i)return!1}return!0}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPolygon.within(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length;o++)if(!jsonOdm.Geo.pointWithinBounds(t.coordinates[n][0][o],e))return!1;return!0},jsonOdm.Geo.MultiPolygon.intersects=function(t,e){var n,o,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(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][0]&&r<t.coordinates[n][0].length-1;r++)if(jsonOdm.Geo.pointWithinPolygon(t.coordinates[n][0][r],e.coordinates[o][0]))return!0;return!1}if("GeometryCollection"===e.type&&jsonOdm.util.isArray(e.geometries)){for(n=0;n<e.geometries.length;n++)if(jsonOdm.Geo.MultiPolygon.intersects(t,e.geometries[n]))return!0;return!1}for(n=0;n<t.coordinates.length;n++)for(o=0;o<t.coordinates[n][0].length-1;o++)if(jsonOdm.Geo.edgeIntersectsBounds([t.coordinates[n][0][o],t.coordinates[n][0][o+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 n=0;n<t.geometries.length;n++){if(!jsonOdm.Geo[t.geometries[n].type]||!jsonOdm.Geo[t.geometries[n].type].within)return!1;if(!jsonOdm.Geo[t.geometries[n].type].within(t.geometries[n],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 n=0;n<t.geometries.length;n++)if(jsonOdm.Geo[t.geometries[n].type]&&jsonOdm.Geo[t.geometries[n].type].intersects&&jsonOdm.Geo[t.geometries[n].type].intersects(t.geometries[n],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 n,o=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(n=(e[r][0]-e[r+1][0])*((t[1]-e[r+1][1])/(e[r][1]-e[r+1][1]))+e[r+1][0],n===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;n>t[0]&&o++}}return o%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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+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 n=0;n<e.length-1;n++)if(jsonOdm.Geo.edgeIntersectsEdge(t,[e[n],e[n+1]]))return!0;return!1},jsonOdm.Geo.edgeIntersectsEdge=function(t,e,n){n="undefined"==typeof n?!0:n;var o=[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]*o[1]-o[0]*i[1]===0)return n&&t[0][1]+(e[0][0]-t[0][0])/o[0]*o[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])/(o[1]*i[0]-o[0]*i[1]),d=t[0][0]+u*o[0],c=t[0][1]+u*o[1];return n?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 n=0;n<e.length-1;n++)if((t[0]>=e[n][0]&&t[0]<=e[n+1][0]&&e[n][0]<=e[n+1][0]||t[0]<=e[n][0]&&t[0]>=e[n+1][0]&&e[n][0]>=e[n+1][0])&&(t[1]>=e[n][1]&&t[1]<=e[n+1][1]&&e[n][1]<=e[n+1][1]||t[1]<=e[n][1]&&t[1]>=e[n+1][1]&&e[n][1]>=e[n+1][1])&&(e[n][0]===t[0]&&e[n][1]===t[1]||e[n+1][0]===t[0]&&e[n+1][1]===t[1]||e[n][1]-e[n+1][1]!=0&&(e[n][0]-e[n+1][0])*((t[1]-e[n+1][1])/(e[n][1]-e[n+1][1]))+e[n+1][0]===t[0]||e[n][0]-e[n+1][0]!=0&&(e[n][1]-e[n+1][1])*((t[0]-e[n+1][0])/(e[n][0]-e[n+1][0]))+e[n+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 n,o;for(n=0;t&&n<t.length;n++){var r=!1;for(o=0;e&&o<e.length;o++)if(t[n][0]===e[o][0]&&t[n][1]===e[o][1]){if(n+1===t.length)return!0;if(!(e[o+1]&&t[n+1][0]===e[o+1][0]&&t[n+1][1]===e[o+1][1]||t[n+1][0]===e[o][0]&&t[n+1][1]===e[o][1]||o>0&&t[n+1][0]===e[o-1][0]&&t[n+1][1]===e[o-1][1]))return!1;r=!0}if(!r)return!1}return!0},"undefined"==typeof jsonOdm)var jsonOdm=new JsonOdm;if(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,n,o,r){"string"==typeof o&&(r=r||o);var i=o;"string"==typeof o&&jsonOdm.selectedSource&&jsonOdm.selectedSource[o]&&(i=jsonOdm.selectedSource[o]);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,a=0;a<i.length;a++)if(u[d]==i[a][n]){c=i[a];break}null!=c&&(t[s][r]||(t[s][r]=[]),t[s][r].push(c))}}},t.$hasOne=function(e,n,o,r){"string"==typeof o&&(r=r||o);var i=o;"string"==typeof o&&jsonOdm.selectedSource&&jsonOdm.selectedSource[o]&&(i=jsonOdm.selectedSource[o]);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][n]){d=i[c];break}null!=d&&(t[s][r]=d)}}},t.$query=function(){return new jsonOdm.Query(t)})};e(t)},"undefined"==typeof jsonOdm)var jsonOdm=new JsonOdm;jsonOdm.Query=function(t){this.$$commandQueue=[],this.$$aggregationBeforeCollectQueue=[],this.$$aggregationResultQueue=[],this.$$collection=t||[],this.$$accumulation=!1},jsonOdm.Query.prototype.$delete=function(){if(this.$$commandQueue.length<1)return this;for(var t=0;t<this.$$collection.length;){for(var e=!0,n=0;n<this.$$commandQueue.length&&(e=e&&this.$$commandQueue[n](this.$$collection[t]));n++);e?this.$$collection.splice(t,1):t++}return this},jsonOdm.Query.prototype.$result=function(t,e){if(this.$$commandQueue.length<1&&this.$$aggregationBeforeCollectQueue<1)return this.$$collection;t="undefined"==typeof t?0:t,e="undefined"==typeof e?this.$$collection.length:e;var n,o,r,i=new jsonOdm.Collection;for(o=0;o<this.$$collection.length;o++){var s=!0;for(r=0;r<this.$$commandQueue.length;r++){var u=this.$$commandQueue[r](this.$$collection[o]);if(!(s=s&&null!==u&&u!==!1&&"undefined"!=typeof u))break}if(s){if(t>0){t--;continue}if(0>=e)return i;for(n=this.$$collection[o],r=0;r<this.$$aggregationBeforeCollectQueue.length;r++)n=this.$$aggregationBeforeCollectQueue[r](o,n);i.push(n),e--}}for(o=0;o<this.$$aggregationResultQueue.length;o++)i=this.$$aggregationResultQueue[o](i);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(t,e,n){return"function"==typeof t&&(t=[t]),"function"==typeof e&&(e=[e]),"function"==typeof n&&(n=[n]),jsonOdm.util.isArray(t)&&(this.$$commandQueue=this.$$commandQueue.concat(t)),jsonOdm.util.isArray(e)&&(this.$$aggregationBeforeCollectQueue=this.$$aggregationBeforeCollectQueue.concat(e)),jsonOdm.util.isArray(n)&&(this.$$aggregationResultQueue=this.$$aggregationResultQueue.concat(n)),this},jsonOdm.Query.prototype.$group=function(){var t=arguments,e=!1,n=[];return arguments.length>1&&!jsonOdm.util.isArray(arguments[arguments.length-1])&&!jsonOdm.util.is(arguments[arguments.length-1],"string")&&"object"==typeof arguments[arguments.length-1]&&(e=arguments[arguments.length-1],t=Array.prototype.slice.call(arguments,0,arguments.length-1)),this.$aggregateCollection(function(t,e){var n={};return function(o){for(var r,i={},s=n,u=0;u<t.length;u++){var d=jsonOdm.util.isArray(t[u])?t[u]:[t[u]];r=jsonOdm.util.branch(o,d),u<t.length-1&&("undefined"==typeof s[""+r]&&(s[""+r]={}),s=s[""+r]);for(var c=i,a=0;a<d.length-1;a++)"undefined"==typeof c[d[a]]&&(c[d[a]]={}),c=c[d[a]];c[d[d.length-1]]=r}return s[""+r]||(s[""+r]={accumulationObject:i,subResultSet:[]},e.push(s[""+r])),s[""+r].subResultSet.push(o),!0}}(t,n),null,function(t,e){function n(t){for(var e in t)t.hasOwnProperty(e)&&(t[e]instanceof jsonOdm.Query&&(t[e].$$accumulation=!1),"object"==typeof t[e]&&n(t[e]))}return function(){for(var o=new jsonOdm.Collection,r=0;r<t.length;r++)if(e===!1)o.push(t[r].accumulationObject);else{n(e);for(var i={},s=0;s<t[r].subResultSet.length;s++)i=jsonOdm.util.projectElement(e,t[r].subResultSet[s]);for(s in t[r].accumulationObject)t[r].accumulationObject.hasOwnProperty(s)&&(i[s]=t[r].accumulationObject[s]);o.push(i)}return o}}(n,e))},jsonOdm.Query.prototype.$project=function(t){return this.$aggregateCollection(null,function(e,n){return jsonOdm.util.projectElement(t,n)})},jsonOdm.Query.prototype.$testCollection=function(t,e){var n=this.$$commandQueue.pop(),o=function(){return function(o){if(!(n instanceof jsonOdm.Collection||"function"==typeof n||"undefined"==typeof n)||"function"!=typeof e)return!1;var r="undefined"==typeof n?o:n instanceof jsonOdm.Collection?n:n(o);return!!e(r,t)}}();return this.$$commandQueue.push(o),this},jsonOdm.Query.prototype.$queryOperator=function(t,e){var n=function(t,e){return function(n){if("function"!=typeof e)return!1;for(var o=[],r=0;r<t.length;r++)if(t[r]instanceof jsonOdm.Query)for(var i=0;i<t[r].$$commandQueue.length;i++)o.push(t[r].$$commandQueue[i](n));else o.push(t[r]);return e(o)}}(t,e),o=new jsonOdm.Query(this.$$collection);return o.$$commandQueue.push(n),o},jsonOdm.Query.prototype.$branch=function(t){if("undefined"==typeof t)return this;var e=function(t){return function(e){return jsonOdm.util.branch(e,t)}}(arguments),n=new jsonOdm.Query(this.$$collection);return n.$$commandQueue.push(e),n},jsonOdm.Query.prototype.$modifyField=function(t){var e=function(t,e){return function(n){return n=null!==e?e(n):n,"function"==typeof t?t(n):n}}(t,this.$$commandQueue.length?this.$$commandQueue[this.$$commandQueue.length-1]:null);return this.$$commandQueue.push(e),this},jsonOdm.Query.stringFiledModifyer=["charAt","charCodeAt","concat","fromCharCode","indexOf","lastIndexOf","localeCompare","match","replace","search","slice","split","substr","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","valueOf"];for(var i=0;i<jsonOdm.Query.stringFiledModifyer.length;i++)jsonOdm.Query.prototype["$"+jsonOdm.Query.stringFiledModifyer[i]]=createQueryStringModifier(jsonOdm.Query.stringFiledModifyer[i]);jsonOdm.Query.prototype.$accumulator=function(t,e){t="string"==typeof t?[t]:t;var n=new jsonOdm.Query(this.$$collection),o=function(t,e,n,o){return function(r){var i=null!==t?jsonOdm.util.branch(r,t):t;return n.$$accumulation=e(i,n.$$accumulation,r),o.$$accumulation=n.$$accumulation,i}}(t,e,n,this);return n.$$commandQueue.push(o),n},jsonOdm.Query.prototype.$sum=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=0),t+e})},jsonOdm.Query.prototype.$avg=function(t){var e,n;return this.$accumulator(t,function(t,o){return o===!1&&(e=0,n=0),n+=t,e++,n/e})},jsonOdm.Query.prototype.$max=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=t),Math.max(t,e)})},jsonOdm.Query.prototype.$min=function(t){return this.$accumulator(t,function(t,e){return e===!1&&(e=t),Math.min(t,e)})},jsonOdm.Query.prototype.$count=function(){return this.$accumulator(null,function(t,e){return e===!1&&(e=0),++e})},jsonOdm.Query.prototype.$push=function(){var t=new jsonOdm.Query(this.$$collection),e=function(t,e){return function(n){return t.$$accumulation=t.$$accumulation===!1?[]:t.$$accumulation,t.$$accumulation.push(n),e.$$accumulation=t.$$accumulation,!0}}(t,this);return t.$$commandQueue.push(e),t},jsonOdm.Query.prototype.$add=function(){return this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e+=t[n];return e})},jsonOdm.Query.prototype.$subtract=function(t){return"undefined"==typeof t?this:this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e-=t[n];return e})},jsonOdm.Query.prototype.$multiply=function(t){return"undefined"==typeof t?this:this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e*=t[n];return e})},jsonOdm.Query.prototype.$divide=function(t){return"undefined"==typeof t?this:this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e/=t[n];
return e})},jsonOdm.Query.prototype.$modulo=function(t){return"undefined"==typeof t?this:this.$queryOperator(arguments,function(t){for(var e=t.length>0?t[0]:0,n=1;n<t.length;n++)e%=t[n];return e})},jsonOdm.Query.prototype.$eq=function(t){return"undefined"==typeof t?this:this.$testCollection(arguments,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0;return!1})},jsonOdm.Query.prototype.$in=function(t){return"undefined"==typeof t&&(t=[]),this.$testCollection(t,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0;return!1})},jsonOdm.Query.prototype.$ne=function(t){return"undefined"==typeof t?this:this.$testCollection(arguments,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!1;return!0})},jsonOdm.Query.prototype.$nin=function(t){return"undefined"==typeof t&&(t=[]),this.$testCollection(t,function(t,e){for(var n=0;n<e.length;n++)if(e[n]===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(t){return"undefined"==typeof t?this.$testCollection([t],function(){return!1}):this.$testCollection(arguments,function(t,e){return jsonOdm.util.is(t,e)})},jsonOdm.Query.prototype.$mod=function(t,e){return"undefined"==typeof t||"undefined"==typeof e?this: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,n,o=/(^| )-([^ ]+)( |$)/g,r=/"([^"]+)"/g,i=[],s=[];null!==(e=o.exec(t));)i.push(e[2]);for(t=t.replace(o,"");null!==(n=r.exec(t));)s.push(n[1]);t=t.replace(r,"");var u=t.split(" ");return this.$testCollection([i,s,u],function(t,e){for(var n=0;n<e[0].length;n++)if(t.indexOf(e[0][n])>-1)return!1;for(n=0;n<e[1].length;n++)if(t.indexOf(e[1][n])<0)return!1;for(n=0;n<e[2].length;n++)if(t.indexOf(e[2][n])>-1)return!0;return!!e[1].length})},jsonOdm.Query.prototype.$where=function(t){return 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.$queryOperator(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.$queryOperator(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.$queryOperator(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.$queryOperator(arguments,function(t){for(var e=0;e<t.length;e++)if(t[e])return!1;return!0})};

@@ -25,4 +25,4 @@ "use strict";

.task('default', ['test-minified','doc'] ,function () {})
.task('build',['test-non-minified'], function() {
return gulp.src(['./src/odm.js', './src/util.js', './src/geo.js', './src/collection.js', './src/query.js'])
.task('build',['build-non-minified','test-non-minified'], function() {
return gulp.src(['./bin/json.odm.js'])
.pipe(filesize())

@@ -35,2 +35,10 @@ .pipe(concat('json.odm.min.js'))

})
.task('build-non-minified', function() {
return gulp.src(['./src/odm.js', './src/util.js', './src/geo.js', './src/collection.js', './src/query.js'])
.pipe(filesize())
.pipe(concat('json.odm.js'))
.pipe(filesize())
.pipe(gulp.dest('./bin/')
);
})
.task('test-non-minified', function () {

@@ -63,3 +71,3 @@ return gulp.src(testNonMinifiedFiles)

description:"A light weight but fast object document mapper for JavaScript objects.",
version:"0.2.0"
version:"0.2.1"
}, "jsonOdm"))

@@ -66,0 +74,0 @@ .pipe(jsdoc.generator('./doc',

@@ -10,3 +10,2 @@ // Karma configuration

// frameworks to use

@@ -16,3 +15,2 @@ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter

// list of files / patterns to load in the browser

@@ -26,8 +24,2 @@ files: [

// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser

@@ -45,7 +37,7 @@ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor

coverageReporter: {
dir: 'doc/coverage/',
dir: './',
reporters: [
// reporters not supporting the `file` property
{ type: 'html', subdir: 'report-html' },
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' }
{ type: 'html', subdir: 'doc/coverage/report-html' },
{ type: 'lcovonly',subdir: '/', file: 'lcov.info' }
]

@@ -52,0 +44,0 @@ },

{
"name": "json-odm",
"version": "0.2.0",
"version": "0.2.1",
"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. >> IF YOU LIKE IT, PLEASE GIVE IT A STAR ON GITHUB <<",

@@ -31,3 +31,4 @@ "main": " ./bin/json.odm.min.js",

"build": "gulp build",
"test": "gulp"
"test": "gulp",
"report-win":"set CODECLIMATE_REPO_TOKEN=0d92b7367dd924d8fb4592952f58f375f5ac387610689da3aa3ff5ef20726e41; codeclimate-test-reporter < bin/coverage/lcov.info"
},

@@ -34,0 +35,0 @@ "repository": {

[![Build Status](https://travis-ci.org/konsultaner/jsonOdm.svg?branch=master)](https://travis-ci.org/konsultaner/jsonOdm)
[![Code Climate](https://codeclimate.com/github/konsultaner/jsonOdm/badges/gpa.svg)](https://codeclimate.com/github/konsultaner/jsonOdm)
[![npm](https://img.shields.io/npm/dm/json-odm.svg)](https://www.npmjs.com/package/json-odm)

@@ -69,3 +70,3 @@ [![npm](https://img.shields.io/npm/v/json-odm.svg)](https://www.npmjs.com/package/json-odm)

------
This is only a basic example. Find more in the [docs](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.1/index.html), i.e. how to use [$geoWithin](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.1/jsonOdm.Query.html#$geoWithin)
This is only a basic example. Find a lot more in the [docs](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.2/index.html), i.e. how to use [$geoWithin](https://rawgit.com/konsultaner/jsonOdm/master/doc/jsonOdm/0.1/jsonOdm.Query.html#$geoWithin)
```html

@@ -72,0 +73,0 @@ <!-- add minified version from https://github.com/konsultaner/jsonOdm/tree/master/bin to the html head -->

"use strict";
// for code climate recognition
if (typeof jsonOdm === "undefined") {
var jsonOdm = new JsonOdm();
}
/**

@@ -4,0 +9,0 @@ * The Collection class holding the date from the selected data source

"use strict";
// for code climate recognition
if (typeof jsonOdm === "undefined") {
var jsonOdm = new JsonOdm();
}
/**

@@ -128,3 +133,5 @@ * The object to provide geographical data and methods. <br>

this.coordinates = position;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -140,32 +147,44 @@

var i, j;
if (!point.coordinates) return false;
if (geometry.type == "Point") return geometry.coordinates[0] == point.coordinates[0] && geometry.coordinates[1] == point.coordinates[1];
if (geometry.type == "MultiPoint" || geometry.type == "LineString") {
if (!point.coordinates) {
return false;
}
if (geometry.type === "Point") {
return geometry.coordinates[0] === point.coordinates[0] && geometry.coordinates[1] === point.coordinates[1];
}
if (geometry.type === "MultiPoint" || geometry.type === "LineString") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
if (geometry.coordinates[i][0] == point.coordinates[0] && geometry.coordinates[i][1] == point.coordinates[1]) return true;
if (geometry.coordinates[i][0] === point.coordinates[0] && geometry.coordinates[i][1] === point.coordinates[1]) {
return true;
}
}
return false;
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; geometry.coordinates[i] && j < geometry.coordinates[i].length; j++)
if (geometry.coordinates[i][j][0] == point.coordinates[0] && geometry.coordinates[i][j][1] == point.coordinates[1]) return true;
if (geometry.coordinates[i][j][0] === point.coordinates[0] && geometry.coordinates[i][j][1] === point.coordinates[1]) {
return true;
}
}
return false;
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
// we assume that polygon wholes do not intersect the outer polygon
return jsonOdm.Geo.pointWithinPolygon(point.coordinates, geometry.coordinates ? geometry.coordinates[0] : null)
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
// we assume that polygon wholes do not intersect the outer polygon
if (jsonOdm.Geo.pointWithinPolygon(point.coordinates, geometry.coordinates[i] ? geometry.coordinates[i][0] : null)) return true;
if (jsonOdm.Geo.pointWithinPolygon(point.coordinates, geometry.coordinates[i] ? geometry.coordinates[i][0] : null)) {
return true;
}
}
return false;
}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.Point.within(point, geometry.geometries[i])) return true;
if (jsonOdm.Geo.Point.within(point, geometry.geometries[i])) {
return true;
}
}

@@ -202,3 +221,5 @@ return false;

this.coordinates = positions;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -214,9 +235,13 @@

var i, j, k, found;
if (!multiPoint.coordinates || !jsonOdm.util.isArray(multiPoint.coordinates)) return false;
if (geometry.type == "Point") return multiPoint.coordinates.length == 1 && multiPoint.coordinates[0][0] == geometry.coordinates[0] && multiPoint.coordinates[0][1] == geometry.coordinates[1];
if (geometry.type == "MultiPoint") {
if (!multiPoint.coordinates || !jsonOdm.util.isArray(multiPoint.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return multiPoint.coordinates.length === 1 && multiPoint.coordinates[0][0] === geometry.coordinates[0] && multiPoint.coordinates[0][1] === geometry.coordinates[1];
}
if (geometry.type === "MultiPoint") {
for (j = 0; multiPoint.coordinates && j < multiPoint.coordinates.length; j++) {
found = false;
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
if (geometry.coordinates[i][0] == multiPoint.coordinates[j][0] && geometry.coordinates[i][1] == multiPoint.coordinates[j][1]) {
if (geometry.coordinates[i][0] === multiPoint.coordinates[j][0] && geometry.coordinates[i][1] === multiPoint.coordinates[j][1]) {
found = true;

@@ -226,13 +251,17 @@ break;

}
if (!found) return false;
if (!found) {
return false;
}
}
return true;
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
for (k = 0; multiPoint.coordinates && k < multiPoint.coordinates.length; k++) {
if (!jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates)) return false;
if (!jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates)) {
return false;
}
}
return true;
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (k = 0; multiPoint.coordinates && k < multiPoint.coordinates.length; k++) {

@@ -250,10 +279,12 @@ found = false;

}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; multiPoint.coordinates && i < multiPoint.coordinates.length; i++) {
// we assume that polygon wholes do not intersect the outer polygon
if (!jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[i], geometry.coordinates ? geometry.coordinates[0] : null)) return false;
if (!jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[i], geometry.coordinates ? geometry.coordinates[0] : null)) {
return false;
}
}
return true;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (j = 0; multiPoint.coordinates && j < multiPoint.coordinates.length; j++) {

@@ -268,10 +299,14 @@ found = false;

}
if (!found) return false;
if (!found) {
return false;
}
}
return true;
}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiPoint.within(multiPoint, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiPoint.within(multiPoint, geometry.geometries[i])) {
return true;
}
}

@@ -282,3 +317,5 @@ return false;

for (i = 0; i < multiPoint.coordinates.length; i++) {
if (!jsonOdm.Geo.pointWithinBounds(multiPoint.coordinates[i], geometry)) return false;
if (!jsonOdm.Geo.pointWithinBounds(multiPoint.coordinates[i], geometry)) {
return false;
}
}

@@ -296,10 +333,14 @@ return true;

var i, j, k;
if (!multiPoint.coordinates || !jsonOdm.util.isArray(multiPoint.coordinates)) return false;
if (geometry.type == "Point") {
if (!multiPoint.coordinates || !jsonOdm.util.isArray(multiPoint.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return jsonOdm.Geo.Point.intersects(geometry, multiPoint);
}
if (geometry.type == "MultiPoint") {
if (geometry.type === "MultiPoint") {
for (j = 0; multiPoint.coordinates && j < multiPoint.coordinates.length; j++) {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
if (geometry.coordinates[i][0] == multiPoint.coordinates[j][0] && geometry.coordinates[i][1] == multiPoint.coordinates[j][1]) return true;
if (geometry.coordinates[i][0] === multiPoint.coordinates[j][0] && geometry.coordinates[i][1] === multiPoint.coordinates[j][1]) {
return true;
}
}

@@ -309,12 +350,16 @@ }

}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
for (k = 0; multiPoint.coordinates && k < multiPoint.coordinates.length; k++) {
if (jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates)) return true;
if (jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates)) {
return true;
}
}
return false;
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (k = 0; multiPoint.coordinates && k < multiPoint.coordinates.length; k++) {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
if (jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates[i])) return true;
if (jsonOdm.Geo.pointWithinLineString(multiPoint.coordinates[k], geometry.coordinates[i])) {
return true;
}
}

@@ -324,13 +369,17 @@ }

}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; multiPoint.coordinates && i < multiPoint.coordinates.length; i++) {
if (jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[i], geometry.coordinates ? geometry.coordinates[0] : null)) return true;
if (jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[i], geometry.coordinates ? geometry.coordinates[0] : null)) {
return true;
}
}
return false;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (j = 0; multiPoint.coordinates && j < multiPoint.coordinates.length; j++) {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
// we assume that polygon wholes do not intersect the outer polygon
if (jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[j], geometry.coordinates[i] ? geometry.coordinates[i][0] : null)) return true;
if (jsonOdm.Geo.pointWithinPolygon(multiPoint.coordinates[j], geometry.coordinates[i] ? geometry.coordinates[i][0] : null)) {
return true;
}
}

@@ -340,5 +389,7 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiPoint.intersects(multiPoint, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiPoint.intersects(multiPoint, geometry.geometries[i])) {
return true;
}
}

@@ -349,3 +400,5 @@ return false;

for (i = 0; i < multiPoint.coordinates.length; i++) {
if (jsonOdm.Geo.pointWithinBounds(multiPoint.coordinates[i], geometry)) return true;
if (jsonOdm.Geo.pointWithinBounds(multiPoint.coordinates[i], geometry)) {
return true;
}
}

@@ -368,3 +421,5 @@ return false;

this.coordinates = positions;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -380,9 +435,13 @@

var i, j;
if (!lineString.coordinates || !jsonOdm.util.isArray(lineString.coordinates)) return false;
if (geometry.type == "Point" || geometry.type == "MultiPoint") return false;
if (!lineString.coordinates || !jsonOdm.util.isArray(lineString.coordinates)) {
return false;
}
if (geometry.type === "Point" || geometry.type === "MultiPoint") {
return false;
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
return jsonOdm.Geo.lineStringWithinLineString(lineString.coordinates, geometry.coordinates);
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {

@@ -395,12 +454,14 @@ if (jsonOdm.Geo.lineStringWithinLineString(lineString.coordinates, geometry.coordinates[i])) {

}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; lineString.coordinates && i < lineString.coordinates.length - 1; i++) {
if (!jsonOdm.Geo.edgeWithinPolygon([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry.coordinates[0]))return false;
if (!jsonOdm.Geo.edgeWithinPolygon([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry.coordinates[0])) {
return false;
}
}
return true;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; lineString.coordinates && j < lineString.coordinates.length - 1; j++) {
if (jsonOdm.Geo.edgeWithinPolygon([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i][0]) && j + 1 == lineString.coordinates.length - 1) {
if (jsonOdm.Geo.edgeWithinPolygon([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i][0]) && j + 1 === lineString.coordinates.length - 1) {
return true;

@@ -412,6 +473,8 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.LineString.within(lineString, geometry.geometries[i])) return true;
if (jsonOdm.Geo.LineString.within(lineString, geometry.geometries[i])) {
return true;
}
}

@@ -438,11 +501,13 @@ return false;

var i, j;
if (!lineString.coordinates || !jsonOdm.util.isArray(lineString.coordinates)) return false;
if (geometry.type == "Point") {
if (!lineString.coordinates || !jsonOdm.util.isArray(lineString.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return jsonOdm.Geo.Point.intersects(geometry, lineString);
}
if (geometry.type == "MultiPoint") {
if (geometry.type === "MultiPoint") {
return jsonOdm.Geo.MultiPoint.intersects(geometry, lineString);
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
for (i = 0; i < lineString.coordinates.length - 1; i++) {

@@ -453,6 +518,8 @@ if (jsonOdm.Geo.edgeIntersectsLineString([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry.coordinates)) return true;

}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; j < lineString.coordinates.length - 1; j++) {
if (jsonOdm.Geo.edgeIntersectsLineString([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i])) return true;
if (jsonOdm.Geo.edgeIntersectsLineString([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i])) {
return true;
}
}

@@ -462,12 +529,16 @@ }

}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; lineString.coordinates && i < lineString.coordinates.length - 1; i++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry.coordinates[0]))return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry.coordinates[0])){
return true;
}
}
return false;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; lineString.coordinates && j < lineString.coordinates.length - 1; j++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i][0])) return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([lineString.coordinates[j], lineString.coordinates[j + 1]], geometry.coordinates[i][0])) {
return true;
}
}

@@ -477,6 +548,8 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.LineString.intersects(lineString, geometry.geometries[i])) return true;
if (jsonOdm.Geo.LineString.intersects(lineString, geometry.geometries[i])) {
return true;
}
}

@@ -487,3 +560,5 @@ return false;

for (i = 0; lineString.coordinates && i < lineString.coordinates.length - 1; i++) {
if (jsonOdm.Geo.edgeIntersectsBounds([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry))return true;
if (jsonOdm.Geo.edgeIntersectsBounds([lineString.coordinates[i], lineString.coordinates[i + 1]], geometry)) {
return true;
}
}

@@ -507,3 +582,5 @@ return false;

this.coordinates = positions;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -519,12 +596,18 @@

var i, j, k, found;
if (!multiLineString.coordinates || !jsonOdm.util.isArray(multiLineString.coordinates)) return false;
if (geometry.type == "Point" || geometry.type == "MultiPoint") return false;
if (!multiLineString.coordinates || !jsonOdm.util.isArray(multiLineString.coordinates)) {
return false;
}
if (geometry.type === "Point" || geometry.type === "MultiPoint") {
return false;
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
for (i = 0; multiLineString.coordinates && i < multiLineString.coordinates.length; i++) {
if (!jsonOdm.Geo.lineStringWithinLineString(multiLineString.coordinates[i], geometry.coordinates)) return false;
if (!jsonOdm.Geo.lineStringWithinLineString(multiLineString.coordinates[i], geometry.coordinates)) {
return false;
}
}
return true;
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates.length; j++) {

@@ -538,10 +621,14 @@ found = false;

}
if (!found) return false;
if (!found) {
return false;
}
}
return true;
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; multiLineString.coordinates && i < multiLineString.coordinates.length; i++) {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates[i].length - 1; j++) {
if (!jsonOdm.Geo.edgeWithinPolygon([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry.coordinates[0])) return false;
if (!jsonOdm.Geo.edgeWithinPolygon([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry.coordinates[0])) {
return false;
}
}

@@ -551,3 +638,3 @@ }

}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates.length; j++) {

@@ -557,3 +644,3 @@ found = false;

for (k = 0; multiLineString.coordinates[j] && k < multiLineString.coordinates[j].length - 1; k++) {
if (jsonOdm.Geo.edgeWithinPolygon([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i][0]) && k + 1 == multiLineString.coordinates[j].length - 1) {
if (jsonOdm.Geo.edgeWithinPolygon([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i][0]) && k + 1 === multiLineString.coordinates[j].length - 1) {
found = true;

@@ -570,6 +657,8 @@ break;

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiLineString.within(multiLineString, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiLineString.within(multiLineString, geometry.geometries[i])) {
return true;
}
}

@@ -597,17 +686,21 @@ return false;

var i, j, k;
if (!multiLineString.coordinates || !jsonOdm.util.isArray(multiLineString.coordinates)) return false;
if (geometry.type == "Point") {
if (!multiLineString.coordinates || !jsonOdm.util.isArray(multiLineString.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return jsonOdm.Geo.Point.intersects(geometry, multiLineString);
}
if (geometry.type == "MultiPoint") {
if (geometry.type === "MultiPoint") {
return jsonOdm.Geo.MultiPoint.intersects(geometry, multiLineString);
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
return jsonOdm.Geo.LineString.intersects(geometry, multiLineString);
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates.length; j++) {
for (k = 0; multiLineString.coordinates[j] && k < multiLineString.coordinates[j].length - 1; k++) {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
if (jsonOdm.Geo.edgeIntersectsLineString([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i])) return true;
if (jsonOdm.Geo.edgeIntersectsLineString([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i])) {
return true;
}
}

@@ -618,6 +711,8 @@ }

}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; multiLineString.coordinates && i < multiLineString.coordinates.length; i++) {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates[i].length - 1; j++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry.coordinates[0])) return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry.coordinates[0])) {
return true;
}
}

@@ -627,7 +722,9 @@ }

}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (j = 0; multiLineString.coordinates && j < multiLineString.coordinates.length; j++) {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (k = 0; multiLineString.coordinates[j] && k < multiLineString.coordinates[j].length - 1; k++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i][0])) return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([multiLineString.coordinates[j][k], multiLineString.coordinates[j][k + 1]], geometry.coordinates[i][0])) {
return true;
}
}

@@ -638,6 +735,8 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiLineString.intersects(multiLineString, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiLineString.intersects(multiLineString, geometry.geometries[i])) {
return true;
}
}

@@ -649,3 +748,5 @@ return false;

for (j = 0; j < multiLineString.coordinates[i].length - 1; j++) {
if (jsonOdm.Geo.edgeIntersectsBounds([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry)) return true;
if (jsonOdm.Geo.edgeIntersectsBounds([multiLineString.coordinates[i][j], multiLineString.coordinates[i][j + 1]], geometry)) {
return true;
}
}

@@ -673,3 +774,5 @@ }

this.coordinates = positions;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -685,17 +788,25 @@

var i, j;
if (!polygon.coordinates || !jsonOdm.util.isArray(polygon.coordinates)) return false;
if (geometry.type == "Point" || geometry.type == "MultiPoint" || geometry.type == "LineString" || geometry.type == "MultiLineString") return false;
if (!polygon.coordinates || !jsonOdm.util.isArray(polygon.coordinates)) {
return false;
}
if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString" || geometry.type === "MultiLineString") {
return false;
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; polygon.coordinates[0] && i < polygon.coordinates[0].length - 1; i++) {
if (!jsonOdm.Geo.edgeWithinPolygon([polygon.coordinates[0][i], polygon.coordinates[0][i + 1]], geometry.coordinates[0])) return false;
if (!jsonOdm.Geo.edgeWithinPolygon([polygon.coordinates[0][i], polygon.coordinates[0][i + 1]], geometry.coordinates[0])) {
return false;
}
}
return true;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; polygon.coordinates[0] && j < polygon.coordinates[0].length - 1; j++) {
var inside = jsonOdm.Geo.edgeWithinPolygon([polygon.coordinates[0][j], polygon.coordinates[0][j + 1]], geometry.coordinates[i][0]);
if (!inside) break;
if (inside && j + 1 == polygon.coordinates[0].length - 1) {
if (!inside) {
break;
}
if (inside && j + 1 === polygon.coordinates[0].length - 1) {
return true;

@@ -707,6 +818,8 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.Polygon.within(polygon, geometry.geometries[i])) return true;
if (jsonOdm.Geo.Polygon.within(polygon, geometry.geometries[i])) {
return true;
}
}

@@ -732,26 +845,32 @@ return false;

var i, j;
if (!polygon.coordinates || !jsonOdm.util.isArray(polygon.coordinates)) return false;
if (geometry.type == "Point") {
if (!polygon.coordinates || !jsonOdm.util.isArray(polygon.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return jsonOdm.Geo.Point.intersects(geometry, polygon);
}
if (geometry.type == "MultiPoint") {
if (geometry.type === "MultiPoint") {
return jsonOdm.Geo.MultiPoint.intersects(geometry, polygon);
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
return jsonOdm.Geo.LineString.intersects(geometry, polygon);
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
return jsonOdm.Geo.MultiLineString.intersects(geometry, polygon);
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; polygon.coordinates[0] && i < polygon.coordinates[0].length - 1; i++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([polygon.coordinates[0][i], polygon.coordinates[0][i + 1]], geometry.coordinates[0])) return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([polygon.coordinates[0][i], polygon.coordinates[0][i + 1]], geometry.coordinates[0])) {
return true;
}
}
return false;
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; geometry.coordinates && i < geometry.coordinates.length; i++) {
for (j = 0; polygon.coordinates[0] && j < polygon.coordinates[0].length - 1; j++) {
if (jsonOdm.Geo.edgeIntersectsPolygon([polygon.coordinates[0][j], polygon.coordinates[0][j + 1]], geometry.coordinates[i][0])) return true;
if (jsonOdm.Geo.edgeIntersectsPolygon([polygon.coordinates[0][j], polygon.coordinates[0][j + 1]], geometry.coordinates[i][0])) {
return true;
}
}

@@ -761,6 +880,8 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
// maybe order it by complexity to get a better best case scenario
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.Polygon.intersects(polygon, geometry.geometries[i])) return true;
if (jsonOdm.Geo.Polygon.intersects(polygon, geometry.geometries[i])) {
return true;
}
}

@@ -798,3 +919,5 @@ return false;

this.coordinates = positions;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -810,9 +933,15 @@

var i, j, k, found;
if (!multiPolygon.coordinates || !jsonOdm.util.isArray(multiPolygon.coordinates)) return false;
if (geometry.type == "Point" || geometry.type == "MultiPoint" || geometry.type == "LineString" || geometry.type == "MultiLineString") return false;
if (!multiPolygon.coordinates || !jsonOdm.util.isArray(multiPolygon.coordinates)) {
return false;
}
if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString" || geometry.type === "MultiLineString") {
return false;
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
for (i = 0; multiPolygon.coordinates && i < multiPolygon.coordinates.length; i++) {
for (j = 0; j < multiPolygon.coordinates[i][0].length - 1; j++) {
if (!jsonOdm.Geo.edgeWithinPolygon([multiPolygon.coordinates[i][0][j], multiPolygon.coordinates[i][0][j + 1]], geometry.coordinates[0])) return false;
if (!jsonOdm.Geo.edgeWithinPolygon([multiPolygon.coordinates[i][0][j], multiPolygon.coordinates[i][0][j + 1]], geometry.coordinates[0])) {
return false;
}
}

@@ -822,3 +951,3 @@ }

}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; multiPolygon.coordinates && i < multiPolygon.coordinates.length; i++) {

@@ -830,3 +959,3 @@ found = false;

if (!inside) break;
if (inside && k + 1 == multiPolygon.coordinates[i][0].length - 1) {
if (inside && k + 1 === multiPolygon.coordinates[i][0].length - 1) {
found = true;

@@ -837,9 +966,13 @@ break;

}
if (!found) return false;
if (!found) {
return false;
}
}
return true;
}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiPolygon.within(multiPolygon, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiPolygon.within(multiPolygon, geometry.geometries[i])) {
return true;
}
}

@@ -867,24 +1000,28 @@ return false;

var i, j, k;
if (!multiPolygon.coordinates || !jsonOdm.util.isArray(multiPolygon.coordinates)) return false;
if (geometry.type == "Point") {
if (!multiPolygon.coordinates || !jsonOdm.util.isArray(multiPolygon.coordinates)) {
return false;
}
if (geometry.type === "Point") {
return jsonOdm.Geo.Point.intersects(geometry, multiPolygon);
}
if (geometry.type == "MultiPoint") {
if (geometry.type === "MultiPoint") {
return jsonOdm.Geo.MultiPoint.intersects(geometry, multiPolygon);
}
if (geometry.type == "LineString") {
if (geometry.type === "LineString") {
return jsonOdm.Geo.LineString.intersects(geometry, multiPolygon);
}
if (geometry.type == "MultiLineString") {
if (geometry.type === "MultiLineString") {
return jsonOdm.Geo.MultiLineString.intersects(geometry, multiPolygon);
}
if (geometry.type == "Polygon") {
if (geometry.type === "Polygon") {
return jsonOdm.Geo.Polygon.intersects(geometry, multiPolygon);
}
if (geometry.type == "MultiPolygon") {
if (geometry.type === "MultiPolygon") {
for (i = 0; multiPolygon.coordinates && i < multiPolygon.coordinates.length; i++) {
for (j = 0; geometry.coordinates && j < geometry.coordinates.length; j++) {
for (k = 0; multiPolygon.coordinates[i][0] && k < multiPolygon.coordinates[i][0].length - 1; k++) {
if (jsonOdm.Geo.pointWithinPolygon(multiPolygon.coordinates[i][0][k], geometry.coordinates[j][0])) return true;
if (jsonOdm.Geo.pointWithinPolygon(multiPolygon.coordinates[i][0][k], geometry.coordinates[j][0])) {
return true;
}
}

@@ -895,5 +1032,7 @@ }

}
if (geometry.type == "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
if (geometry.type === "GeometryCollection" && jsonOdm.util.isArray(geometry.geometries)) {
for (i = 0; i < geometry.geometries.length; i++) {
if (jsonOdm.Geo.MultiPolygon.intersects(multiPolygon, geometry.geometries[i])) return true;
if (jsonOdm.Geo.MultiPolygon.intersects(multiPolygon, geometry.geometries[i])) {
return true;
}
}

@@ -928,3 +1067,5 @@ return false;

this.geometries = geometries;
if (boundaryBox) this.bbox = boundaryBox;
if (boundaryBox) {
this.bbox = boundaryBox;
}
};

@@ -939,3 +1080,5 @@

jsonOdm.Geo.GeometryCollection.within = function (geometryCollection, geometry) {
if (!jsonOdm.util.isArray(geometryCollection.geometries) || !geometryCollection.geometries.length || !geometry.type) return false;
if (!jsonOdm.util.isArray(geometryCollection.geometries) || !geometryCollection.geometries.length || !geometry.type) {
return false;
}
for (var i = 0; i < geometryCollection.geometries.length; i++) {

@@ -946,3 +1089,5 @@ if (jsonOdm.Geo[geometryCollection.geometries[i].type] && jsonOdm.Geo[geometryCollection.geometries[i].type].within) {

}
} else return false;
} else {
return false;
}
}

@@ -959,3 +1104,5 @@ return true;

jsonOdm.Geo.GeometryCollection.intersects = function (geometryCollection, geometry) {
if (!jsonOdm.util.isArray(geometryCollection.geometries) || !geometryCollection.geometries.length || !geometry.type) return false;
if (!jsonOdm.util.isArray(geometryCollection.geometries) || !geometryCollection.geometries.length || !geometry.type) {
return false;
}
for (var i = 0; i < geometryCollection.geometries.length; i++) {

@@ -978,3 +1125,5 @@ if (jsonOdm.Geo[geometryCollection.geometries[i].type] && jsonOdm.Geo[geometryCollection.geometries[i].type].intersects) {

jsonOdm.Geo.pointWithinPolygon = function (point, polygon) {
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(polygon) && polygon.length > 2)) return false;
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(polygon) && polygon.length > 2)) {
return false;
}

@@ -984,7 +1133,11 @@ var intersection = 0, foundX;

// close the polygon
if (!(polygon[0][0] == polygon[polygon.length - 1][0] && polygon[0][1] == polygon[polygon.length - 1][1])) polygon = polygon.concat([polygon[0]]);
if (!(polygon[0][0] === polygon[polygon.length - 1][0] && polygon[0][1] === polygon[polygon.length - 1][1])) {
polygon = polygon.concat([polygon[0]]);
}
// do not enter the last point because the calculation also reads the i+1th index
for (var i = 0; i < polygon.length - 1; i++) {
if (polygon[i][0] == point[0] && polygon[i][1] == point[1]) return true; // vertex equals the given point
if (polygon[i][0] === point[0] && polygon[i][1] === point[1]) {
return true;
} // vertex equals the given point
if (

@@ -999,7 +1152,9 @@ polygon[i][0] < point[0] && polygon[i + 1][0] < point[0] || // the vector is only in section 1 or 4 of the coordinate system normalized to the point, so it does not intersect the positive x-axis

// on the edge
if (foundX == point[0] && point[1] <= Math.max(polygon[i][1], polygon[i + 1][1]) && point[1] >= Math.min(polygon[i][1], polygon[i + 1][1]))return true;
if (foundX === point[0] && point[1] <= Math.max(polygon[i][1], polygon[i + 1][1]) && point[1] >= Math.min(polygon[i][1], polygon[i + 1][1])) {
return true;
}
// the vector intersects the positive x-axis of the coordinate system normalized to the point
if (foundX > point[0])intersection++;
}
return intersection % 2 == 1; // the normalized x-axis needs to be intersected by a odd amount of intersections
return intersection % 2 === 1; // the normalized x-axis needs to be intersected by a odd amount of intersections
};

@@ -1014,7 +1169,13 @@

jsonOdm.Geo.edgeWithinPolygon = function (edge, polygon) {
if (!(jsonOdm.util.isArray(edge) && edge.length == 2 && jsonOdm.util.isArray(polygon) && polygon.length >= 2)) return false;
if (!(jsonOdm.util.isArray(edge) && edge.length === 2 && jsonOdm.util.isArray(polygon) && polygon.length >= 2)) {
return false;
}
// close the polygon
if (!(polygon[0][0] == polygon[polygon.length - 1][0] && polygon[0][1] == polygon[polygon.length - 1][1])) polygon = polygon.concat([polygon[0]]);
if (!jsonOdm.Geo.pointWithinPolygon(edge[0], polygon) || !jsonOdm.Geo.pointWithinPolygon(edge[1], polygon)) return false;
if (!(polygon[0][0] === polygon[polygon.length - 1][0] && polygon[0][1] === polygon[polygon.length - 1][1])) {
polygon = polygon.concat([polygon[0]]);
}
if (!jsonOdm.Geo.pointWithinPolygon(edge[0], polygon) || !jsonOdm.Geo.pointWithinPolygon(edge[1], polygon)) {
return false;
}

@@ -1037,7 +1198,13 @@ for (var i = 0; i < polygon.length - 1; i++) {

jsonOdm.Geo.edgeIntersectsPolygon = function (edge, polygon) {
if (!(jsonOdm.util.isArray(edge) && edge.length == 2 && jsonOdm.util.isArray(polygon) && polygon.length >= 2)) return false;
if (!(jsonOdm.util.isArray(edge) && edge.length === 2 && jsonOdm.util.isArray(polygon) && polygon.length >= 2)) {
return false;
}
// close the polygon
if (!(polygon[0][0] == polygon[polygon.length - 1][0] && polygon[0][1] == polygon[polygon.length - 1][1])) polygon = polygon.concat([polygon[0]]);
if (jsonOdm.Geo.pointWithinPolygon(edge[0], polygon) || jsonOdm.Geo.pointWithinPolygon(edge[1], polygon)) return true;
if (!(polygon[0][0] === polygon[polygon.length - 1][0] && polygon[0][1] === polygon[polygon.length - 1][1])) {
polygon = polygon.concat([polygon[0]]);
}
if (jsonOdm.Geo.pointWithinPolygon(edge[0], polygon) || jsonOdm.Geo.pointWithinPolygon(edge[1], polygon)) {
return true;
}

@@ -1060,3 +1227,5 @@ for (var i = 0; i < polygon.length - 1; i++) {

jsonOdm.Geo.edgeIntersectsLineString = function (edge, lineString) {
if (!(jsonOdm.util.isArray(edge) && edge.length == 2 && jsonOdm.util.isArray(lineString))) return false;
if (!(jsonOdm.util.isArray(edge) && edge.length === 2 && jsonOdm.util.isArray(lineString))) {
return false;
}
for (var i = 0; i < lineString.length - 1; i++) {

@@ -1078,3 +1247,3 @@ if (jsonOdm.Geo.edgeIntersectsEdge(edge, [lineString[i], lineString[i + 1]])) {

jsonOdm.Geo.edgeIntersectsEdge = function (edge1, edge2, allowOnEdge) {
allowOnEdge = typeof allowOnEdge == "undefined" ? true : allowOnEdge;
allowOnEdge = typeof allowOnEdge === "undefined" ? true : allowOnEdge;
var directionVector1 = [edge1[1][0] - edge1[0][0], edge1[1][1] - edge1[0][1]],

@@ -1094,4 +1263,4 @@ bounds1 = [Math.min(edge1[0][0], edge1[1][0]), Math.min(edge1[0][1], edge1[1][1]), Math.max(edge1[0][0], edge1[1][0]), Math.max(edge1[0][1], edge1[1][1])],

if ((directionVector2[0] * directionVector1[1] - directionVector1[0] * directionVector2[1]) == 0) {
return allowOnEdge && edge1[0][1] + (((edge2[0][0] - edge1[0][0]) / (directionVector1[0])) * (directionVector1[1])) == edge2[0][1];
if ((directionVector2[0] * directionVector1[1] - directionVector1[0] * directionVector2[1]) === 0) {
return allowOnEdge && edge1[0][1] + (((edge2[0][0] - edge1[0][0]) / (directionVector1[0])) * (directionVector1[1])) === edge2[0][1];
}

@@ -1116,3 +1285,5 @@

jsonOdm.Geo.pointWithinLineString = function (point, lineString) {
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(lineString) && lineString.length >= 2)) return false;
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(lineString) && lineString.length >= 2)) {
return false;
}
for (var i = 0; i < lineString.length - 1; i++) {

@@ -1132,8 +1303,10 @@ if (

if (
(lineString[i] [0] == point[0] && lineString[i] [1] == point[1]) ||
(lineString[i + 1][0] == point[0] && lineString[i + 1][1] == point[1]) ||
(lineString[i] [0] === point[0] && lineString[i] [1] === point[1]) ||
(lineString[i + 1][0] === point[0] && lineString[i + 1][1] === point[1]) ||
((lineString[i][1] - lineString[i + 1][1]) != 0 && ((lineString[i][0] - lineString[i + 1][0]) * ((point[1] - lineString[i + 1][1]) / (lineString[i][1] - lineString[i + 1][1])) + lineString[i + 1][0] == point[0])) ||
((lineString[i][0] - lineString[i + 1][0]) != 0 && ((lineString[i][1] - lineString[i + 1][1]) * ((point[0] - lineString[i + 1][0]) / (lineString[i][0] - lineString[i + 1][0])) + lineString[i + 1][1] == point[1]))
) return true;
((lineString[i][1] - lineString[i + 1][1]) != 0 && ((lineString[i][0] - lineString[i + 1][0]) * ((point[1] - lineString[i + 1][1]) / (lineString[i][1] - lineString[i + 1][1])) + lineString[i + 1][0] === point[0])) ||
((lineString[i][0] - lineString[i + 1][0]) != 0 && ((lineString[i][1] - lineString[i + 1][1]) * ((point[0] - lineString[i + 1][0]) / (lineString[i][0] - lineString[i + 1][0])) + lineString[i + 1][1] === point[1]))
) {
return true;
}
}

@@ -1151,3 +1324,5 @@ }

jsonOdm.Geo.pointWithinBounds = function (point, bounds) {
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(bounds) && bounds.length == 4)) return false;
if (!(jsonOdm.util.isArray(point) && jsonOdm.util.isArray(bounds) && bounds.length === 4)) {
return false;
}
return point[0] >= bounds[0] && point[1] >= bounds[1] && point[0] <= bounds[2] && point[1] <= bounds[3];

@@ -1163,3 +1338,5 @@ };

jsonOdm.Geo.edgeIntersectsBounds = function (edge, bounds) {
if (!(jsonOdm.util.isArray(edge) && jsonOdm.util.isArray(bounds) && bounds.length == 4)) return false;
if (!(jsonOdm.util.isArray(edge) && jsonOdm.util.isArray(bounds) && bounds.length === 4)) {
return false;
}
return jsonOdm.Geo.edgeIntersectsPolygon(edge, [[bounds[0], bounds[1]], [bounds[2], bounds[1]], [bounds[2], bounds[3]], [bounds[0], bounds[3]]]);

@@ -1175,3 +1352,5 @@ };

jsonOdm.Geo.lineStringWithinLineString = function (lineString, inLineString) {
if (!(jsonOdm.util.isArray(lineString) && jsonOdm.util.isArray(inLineString))) return false;
if (!(jsonOdm.util.isArray(lineString) && jsonOdm.util.isArray(inLineString))) {
return false;
}
var i, j;

@@ -1181,4 +1360,4 @@ for (i = 0; lineString && i < lineString.length; i++) {

for (j = 0; inLineString && j < inLineString.length; j++) {
if (lineString[i][0] == inLineString[j][0] && lineString[i][1] == inLineString[j][1]) {
if (i + 1 == lineString.length) {
if (lineString[i][0] === inLineString[j][0] && lineString[i][1] === inLineString[j][1]) {
if (i + 1 === lineString.length) {
return true; // we have successfully found the last matching line point

@@ -1190,7 +1369,7 @@ }

// next is not the next one
(inLineString[j + 1] && lineString[i + 1][0] == inLineString[j + 1][0] && lineString[i + 1][1] == inLineString[j + 1][1]) ||
(inLineString[j + 1] && lineString[i + 1][0] === inLineString[j + 1][0] && lineString[i + 1][1] === inLineString[j + 1][1]) ||
// next is not the same one
(lineString[i + 1][0] == inLineString[j][0] && lineString[i + 1][1] == inLineString[j][1]) ||
(lineString[i + 1][0] === inLineString[j][0] && lineString[i + 1][1] === inLineString[j][1]) ||
// next is not the previous one
(j > 0 && lineString[i + 1][0] == inLineString[j - 1][0] && lineString[i + 1][1] == inLineString[j - 1][1])
(j > 0 && lineString[i + 1][0] === inLineString[j - 1][0] && lineString[i + 1][1] === inLineString[j - 1][1])
)

@@ -1201,5 +1380,7 @@ ) return false;

}
if (!found) return false;
if (!found) {
return false;
}
}
return true;
};

@@ -43,3 +43,3 @@ "use strict";

*/
function JsonOdm () {
function JsonOdm() {
var self = this;

@@ -56,4 +56,8 @@ this.sources = {};

if (typeof source == "object") {
if (typeof self.sources[sourceId] == "undefined") self.sources[sourceId] = source;
if(selectSource) self.selectedSource = source;
if (typeof self.sources[sourceId] === "undefined") {
self.sources[sourceId] = source;
}
if (selectSource) {
self.selectedSource = source;
}
}

@@ -66,11 +70,15 @@ };

this.selectSource = function (sourceId) {
if(typeof self.sources[sourceId] != "undefined") self.selectedSource = self.sources[sourceId];
if (typeof self.sources[sourceId] !== "undefined") {
self.selectedSource = self.sources[sourceId];
}
};
}
var root = typeof window != "undefined" ? window : global;
var odm = new JsonOdm();
if(!root.jsonOdm) root.jsonOdm = odm;
if (typeof module !== 'undefined' && module.exports) {
module.exports = odm;
}
var root = typeof window !== "undefined" ? window : global;
var jsonOdm = new JsonOdm();
if (!root.jsonOdm) {
root.jsonOdm = jsonOdm;
}
if (typeof module !== "undefined" && module.exports) {
module.exports = jsonOdm;
}
"use strict";
// for code climate recognition
if (typeof jsonOdm === "undefined") {
var jsonOdm = new JsonOdm();
}
/** @namespace jsonOdm.Query */

@@ -45,3 +50,3 @@

}
for (var i = 0; i < this.$$collection.length;) {
for (var i = 0; i < this.$$collection.length; ) {
var validCollection = true;

@@ -169,3 +174,3 @@ for (var j = 0; j < this.$$commandQueue.length; j++) {

* Groups all elements of a collection by a given grouping schema
* @param {...jsonOdm.Query} by
* @param {...jsonOdm.Query}
* @return {jsonOdm.Query}

@@ -190,11 +195,11 @@ * @example

* // [
* // {"salaryRate":3300,"salaryGroup":{"name":"Developer"},"missingDays":22,"holidayDays":144,"averageMissingDays":11,"averageHolidayDays":72,$count:2},
* // {"salaryRate":2800,"salaryGroup":{"name":"Tester"} ,"missingDays":10,"holidayDays":66 ,"averageMissingDays":5, "averageHolidayDays":33,$count:2},
* // {"salaryRate":4800,"salaryGroup":{"name":"Boss"} ,"missingDays":12,"holidayDays":33 ,"averageMissingDays":12,"averageHolidayDays":33,$count:1}
* // {"salaryRate":3300,"salaryGroup":{"name":"Developer"},"missingDays":22,"holidayDays":144,"averageMissingDays":11,"averageHolidayDays":72,"count":2},
* // {"salaryRate":2800,"salaryGroup":{"name":"Tester"} ,"missingDays":10,"holidayDays":66 ,"averageMissingDays":5, "averageHolidayDays":33,"count":2},
* // {"salaryRate":4800,"salaryGroup":{"name":"Boss"} ,"missingDays":12,"holidayDays":33 ,"averageMissingDays":12,"averageHolidayDays":33,"count":1}
* // ]
*/
jsonOdm.Query.prototype.$group = function (by) {
var orderBy = arguments;
var accumulationProjection = false;
var aggregationResult = [];
jsonOdm.Query.prototype.$group = function () {
var orderByFields = arguments;
var accumulationProjectionDefinition = false;
var aggregationResultBuffer = [];
// last argument might be a projection

@@ -205,4 +210,4 @@ if (

) {
accumulationProjection = arguments[arguments.length - 1];
orderBy = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
accumulationProjectionDefinition = arguments[arguments.length - 1];
orderByFields = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
}

@@ -215,3 +220,2 @@ return this.$aggregateCollection(

var accumulationObject = {},
newValueVariation = false,
currentValueVariation = valueVariations,

@@ -225,3 +229,2 @@ value;

if (typeof currentValueVariation["" + value] === "undefined") {
newValueVariation = true;
currentValueVariation["" + value] = {};

@@ -252,3 +255,3 @@ }

};
})(orderBy, aggregationResult),
})(orderByFields, aggregationResultBuffer),
null,

@@ -291,3 +294,3 @@ (function (aggregationResult, accumulationProjection) {

};
})(aggregationResult, accumulationProjection));
})(aggregationResultBuffer, accumulationProjectionDefinition));
};

@@ -353,5 +356,5 @@

jsonOdm.Query.prototype.$queryOperator = function (queries, operator) {
var $testCollection = (function (queries, oprator) {
var $testCollection = (function (queries, currentOprator) {
return function (collection) {
if (typeof oprator !== "function") {
if (typeof currentOprator !== "function") {
return false;

@@ -370,3 +373,3 @@ }

}
return operator(commandResults);
return currentOprator(commandResults);
};

@@ -384,2 +387,5 @@ })(queries, operator);

jsonOdm.Query.prototype.$branch = function (node) {
if( typeof node === "undefined" ) {
return this;
}
var $branch = (function (nodes) {

@@ -405,3 +411,3 @@ /**

jsonOdm.Query.prototype.$modifyField = function (modifier) {
var $modifier = (function (modifier, lastCommand) {
var $modifier = (function (currentModifier, lastCommand) {
/**

@@ -413,3 +419,3 @@ * @param {*} The collection to go down

collection = lastCommand !== null ? lastCommand(collection) : collection;
return typeof modifier === "function" ? modifier(collection) : collection;
return typeof currentModifier === "function" ? currentModifier(collection) : collection;
};

@@ -433,13 +439,14 @@ })(modifier, this.$$commandQueue.length ? this.$$commandQueue[this.$$commandQueue.length - 1] : null);

jsonOdm.Query.stringFiledModifyer = ["charAt", "charCodeAt", "concat", "fromCharCode", "indexOf", "lastIndexOf", "localeCompare", "match", "replace", "search", "slice", "split", "substr", "substring", "toLocaleLowerCase", "toLocaleUpperCase", "toLowerCase", "toUpperCase", "trim", "valueOf"];
for (var i = 0; i < jsonOdm.Query.stringFiledModifyer.length; i++) {
jsonOdm.Query.prototype["$" + jsonOdm.Query.stringFiledModifyer[i]] = (function (modifyer) {
return function () {
return this.$modifyField((function (args, modifyer) {
return function (value) {
return typeof value === "string" && String.prototype.hasOwnProperty(modifyer) ? String.prototype[modifyer].apply(value, args) : value;
};
})(arguments, modifyer));
function createQueryStringModifier(modifyer) {
return function () {
return this.$modifyField((function (args, modifyer) {
return function (value) {
return typeof value === "string" && String.prototype.hasOwnProperty(modifyer) ? String.prototype[modifyer].apply(value, args) : value;
};
})(jsonOdm.Query.stringFiledModifyer[i]);
})(arguments, modifyer));
};
}
for (var i = 0; i < jsonOdm.Query.stringFiledModifyer.length; i++) {
jsonOdm.Query.prototype["$" + jsonOdm.Query.stringFiledModifyer[i]] = createQueryStringModifier(jsonOdm.Query.stringFiledModifyer[i]);
}

@@ -629,4 +636,3 @@ // ACCUMULATION FUNCTIONS

* Performs an arithmetic subtraction on two or more field values
* @param {jsonOdm.Query|Number} branch1
* @param {...jsonOdm.Query|...Number} branch2
* @param {...jsonOdm.Query|...Number} branch
* @return jsonOdm.Query

@@ -644,3 +650,6 @@ * @example

*/
jsonOdm.Query.prototype.$subtract = function (branch1, branch2) {
jsonOdm.Query.prototype.$subtract = function (branch) {
if( typeof branch === "undefined" ) {
return this;
}
return this.$queryOperator(arguments, function (queryResults) {

@@ -657,4 +666,3 @@ var result = queryResults.length > 0 ? queryResults[0] : 0;

* Performs an arithmetic multiplication on two or more field values
* @param {jsonOdm.Query|Number} branch1
* @param {...jsonOdm.Query|...Number} branch2
* @param {...jsonOdm.Query|...Number} branch
* @return jsonOdm.Query

@@ -672,3 +680,6 @@ * @example

*/
jsonOdm.Query.prototype.$multiply = function (branch1, branch2) {
jsonOdm.Query.prototype.$multiply = function (branch) {
if( typeof branch === "undefined" ) {
return this;
}
return this.$queryOperator(arguments, function (queryResults) {

@@ -685,4 +696,3 @@ var result = queryResults.length > 0 ? queryResults[0] : 0;

* Performs an arithmetic divition on two or more field values
* @param {jsonOdm.Query|Number} branch1
* @param {...jsonOdm.Query|...Number} branch2
* @param {...jsonOdm.Query|...Number} branch
* @return jsonOdm.Query

@@ -700,3 +710,6 @@ * @example

*/
jsonOdm.Query.prototype.$divide = function (branch1, branch2) {
jsonOdm.Query.prototype.$divide = function (branch) {
if( typeof branch === "undefined" ) {
return this;
}
return this.$queryOperator(arguments, function (queryResults) {

@@ -713,3 +726,3 @@ var result = queryResults.length > 0 ? queryResults[0] : 0;

* Performs an arithmetic modulo on two or more field values
* @param {jsonOdm.Query|Number} branch1
* @param {jsonOdm.Query|Number} branch
* @param {...jsonOdm.Query|...Number} module

@@ -728,3 +741,6 @@ * @return jsonOdm.Query

*/
jsonOdm.Query.prototype.$modulo = function (branch1, module) {
jsonOdm.Query.prototype.$modulo = function (branch, module) {
if( typeof branch === "undefined" ) {
return this;
}
return this.$queryOperator(arguments, function (queryResults) {

@@ -746,2 +762,5 @@ var result = queryResults.length > 0 ? queryResults[0] : 0;

jsonOdm.Query.prototype.$eq = function (comparable) {
if( typeof comparable === "undefined" ) {
return this;
}
return this.$testCollection(arguments, function (collectionValue, possibleValues) {

@@ -764,2 +783,5 @@ for (var i = 0; i < possibleValues.length; i++) {

jsonOdm.Query.prototype.$in = function (comparable) {
if( typeof comparable === "undefined" ) {
comparable = [];
}
return this.$testCollection(comparable, function (collectionValue, possibleValues) {

@@ -782,2 +804,5 @@ for (var i = 0; i < possibleValues.length; i++) {

jsonOdm.Query.prototype.$ne = function (comparable) {
if( typeof comparable === "undefined" ) {
return this
}
return this.$testCollection(arguments, function (collectionValue, possibleValues) {

@@ -800,2 +825,5 @@ for (var i = 0; i < possibleValues.length; i++) {

jsonOdm.Query.prototype.$nin = function (comparable) {
if( typeof comparable === "undefined" ) {
comparable = [];
}
return this.$testCollection(comparable, function (collectionValue, possibleValues) {

@@ -865,3 +893,3 @@ for (var i = 0; i < possibleValues.length; i++) {

return this.$testCollection(null, function (collectionValue) {
return typeof collectionValue === 'undefined' || collectionValue === null;
return typeof collectionValue === "undefined" || collectionValue === null;
});

@@ -876,3 +904,3 @@ };

return this.$testCollection(null, function (collectionValue) {
return typeof collectionValue != 'undefined';
return typeof collectionValue !== "undefined";
});

@@ -894,2 +922,8 @@ };

jsonOdm.Query.prototype.$type = function (type) {
if(typeof type === "undefined" ) {
return this.$testCollection([type], function () {
return false;
});
}
return this.$testCollection(arguments, function (collectionValue, possibleTypes) {

@@ -911,2 +945,5 @@ return jsonOdm.util.is(collectionValue, possibleTypes);

jsonOdm.Query.prototype.$mod = function (divisor, remainder) {
if( typeof divisor === "undefined" || typeof remainder === "undefined" ){
return this;
}
return this.$testCollection(arguments, function (collectionValue, args) {

@@ -1183,2 +1220,2 @@ return collectionValue % args[0] === args[1];

});
};
};
"use strict";
// for code climate recognition
if (typeof jsonOdm === "undefined") {
var jsonOdm = new JsonOdm();
}
/**

@@ -17,4 +22,4 @@ * The Utility Class that provides some useful methods used throughout the ODM

*/
jsonOdm.Util.prototype.isArray = function(arrayObject){
if(!Array.isArray) {
jsonOdm.Util.prototype.isArray = function (arrayObject) {
if (!Array.isArray) {
return Object.prototype.toString.call(arrayObject) === "[object Array]";

@@ -32,13 +37,13 @@ }

*/
jsonOdm.Util.prototype.is = function(object,type){
jsonOdm.Util.prototype.is = function (object, type) {
type = (typeof type == "string") ? [type] : type;
var objectType = Object.prototype.toString.call(object);
objectType = objectType.substring(8,objectType.length-1).toLowerCase();
for(var i = 0; i < type.length; i++) {
objectType = objectType.substring(8, objectType.length - 1).toLowerCase();
for (var i = 0; i < type.length; i++) {
var lowerType = type[i].toLowerCase();
if ("array" == lowerType && this.isArray(object)) return true;
// all object types, i.e. "[object ArrayBuffer]"
if(lowerType == objectType) return true;
if (lowerType === objectType) return true;
// number string object
if (typeof object == lowerType) return true;
if (typeof object === lowerType) return true;
}

@@ -54,39 +59,39 @@ return false;

*/
jsonOdm.Util.prototype.objectKeys = Object.keys || (function() {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
jsonOdm.Util.prototype.objectKeys = Object.keys || (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function(obj) {
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
throw new TypeError('Object.keys called on non-object');
}
return function (obj) {
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
throw new TypeError('Object.keys called on non-object');
}
var result = [], prop, i;
var result = [], prop, i;
for (prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
for (prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
}
if (hasDontEnumBug) {
for (i = 0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) {
result.push(dontEnums[i]);
if (hasDontEnumBug) {
for (i = 0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) {
result.push(dontEnums[i]);
}
}
}
}
return result;
};
}());
return result;
};
}());

@@ -99,12 +104,13 @@ /** Query an object with a function

*/
jsonOdm.Util.prototype.branch = function(object,path){
jsonOdm.Util.prototype.branch = function (object, path) {
function goDown() {
if(arguments && arguments.length && this){
if (arguments && arguments.length && this) {
var subCollection = this[arguments[0]];
if(!subCollection) return subCollection;
return goDown.apply(subCollection,Array.prototype.slice.call( arguments, 1 ));
if (!subCollection) return subCollection;
return goDown.apply(subCollection, Array.prototype.slice.call(arguments, 1));
}
return this
}
return goDown.apply(object,path);
return goDown.apply(object, path);
};

@@ -130,15 +136,17 @@

*/
jsonOdm.Util.prototype.projectElement = function(projection,element,parentElement){
var projectionResult = {},i;
for(var key in projection){
if(!projection.hasOwnProperty(key)) continue;
if(projection[key] == 1){
jsonOdm.Util.prototype.projectElement = function (projection, element, parentElement) {
var projectionResult = {}, i;
for (var key in projection) {
if (!projection.hasOwnProperty(key)) {
continue;
}
if (projection[key] == 1) {
projectionResult[key] = element[key]; // might be undefined or raises an error
}else if(typeof projection[key] === 'function'){
} else if (typeof projection[key] === 'function') {
projectionResult[key] = projection[key](parentElement || element);
}else if(projection[key] instanceof jsonOdm.Query){
projectionResult[key] = projection[key].$$commandQueue[projection[key].$$commandQueue.length-1](element);
if(projection[key].$$accumulation !== false) projectionResult[key] = projection[key].$$accumulation;
}else if(typeof projection[key] === 'object'){
projectionResult[key] = this.projectElement(projection[key],element[key],parentElement || element);
} else if (projection[key] instanceof jsonOdm.Query) {
projectionResult[key] = projection[key].$$commandQueue[projection[key].$$commandQueue.length - 1](element);
if (projection[key].$$accumulation !== false) projectionResult[key] = projection[key].$$accumulation;
} else if (typeof projection[key] === 'object') {
projectionResult[key] = this.projectElement(projection[key], element[key], parentElement || element);
}

@@ -145,0 +153,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc