{"size": 4340, "ext": "js", "max_stars_repo_path": "public-build/lib/openlayers/OpenLayers-2.13.1/lib/OpenLayers/Geometry/Collection.js", "max_stars_repo_name": "nickbenes/GeoSense", "max_stars_repo_stars_event_min_datetime": "2015-03-17T18:31:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-22T02:57:45.000Z", "max_issues_repo_path": "public-build/lib/openlayers/OpenLayers-2.13.1/lib/OpenLayers/Geometry/Collection.js", "max_issues_repo_name": "nickbenes/GeoSense", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public-build/lib/openlayers/OpenLayers-2.13.1/lib/OpenLayers/Geometry/Collection.js", "max_forks_repo_name": "nickbenes/GeoSense", "max_forks_repo_forks_event_min_datetime": "2019-06-28T13:16:49.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-08T11:59:43.000Z"}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 723.3333333333, "max_line_length": 4087, "alphanum_fraction": 0.7384792627}
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
 * full list of contributors). Published under the 2-clause BSD license.
 * See license.txt in the OpenLayers distribution or repository for the
 * full text of the license. */

OpenLayers.Geometry.Collection=OpenLayers.Class(OpenLayers.Geometry,{components:null,componentTypes:null,initialize:function(e){OpenLayers.Geometry.prototype.initialize.apply(this,arguments),this.components=[],e!=null&&this.addComponents(e)},destroy:function(){this.components.length=0,this.components=null,OpenLayers.Geometry.prototype.destroy.apply(this,arguments)},clone:function(){var geometry=eval("new "+this.CLASS_NAME+"()");for(var i=0,len=this.components.length;i<len;i++)geometry.addComponent(this.components[i].clone());return OpenLayers.Util.applyDefaults(geometry,this),geometry},getComponentsString:function(){var e=[];for(var t=0,n=this.components.length;t<n;t++)e.push(this.components[t].toShortString());return e.join(",")},calculateBounds:function(){this.bounds=null;var e=new OpenLayers.Bounds,t=this.components;if(t)for(var n=0,r=t.length;n<r;n++)e.extend(t[n].getBounds());e.left!=null&&e.bottom!=null&&e.right!=null&&e.top!=null&&this.setBounds(e)},addComponents:function(e){OpenLayers.Util.isArray(e)||(e=[e]);for(var t=0,n=e.length;t<n;t++)this.addComponent(e[t])},addComponent:function(e,t){var n=!1;if(e)if(this.componentTypes==null||OpenLayers.Util.indexOf(this.componentTypes,e.CLASS_NAME)>-1){if(t!=null&&t<this.components.length){var r=this.components.slice(0,t),i=this.components.slice(t,this.components.length);r.push(e),this.components=r.concat(i)}else this.components.push(e);e.parent=this,this.clearBounds(),n=!0}return n},removeComponents:function(e){var t=!1;OpenLayers.Util.isArray(e)||(e=[e]);for(var n=e.length-1;n>=0;--n)t=this.removeComponent(e[n])||t;return t},removeComponent:function(e){return OpenLayers.Util.removeItem(this.components,e),this.clearBounds(),!0},getLength:function(){var e=0;for(var t=0,n=this.components.length;t<n;t++)e+=this.components[t].getLength();return e},getArea:function(){var e=0;for(var t=0,n=this.components.length;t<n;t++)e+=this.components[t].getArea();return e},getGeodesicArea:function(e){var t=0;for(var n=0,r=this.components.length;n<r;n++)t+=this.components[n].getGeodesicArea(e);return t},getCentroid:function(e){if(!e)return this.components.length&&this.components[0].getCentroid();var t=this.components.length;if(!t)return!1;var n=[],r=[],i=0,s=Number.MAX_VALUE,o;for(var u=0;u<t;++u){o=this.components[u];var a=o.getArea(),f=o.getCentroid(!0);if(isNaN(a)||isNaN(f.x)||isNaN(f.y))continue;n.push(a),i+=a,s=a<s&&a>0?a:s,r.push(f)}t=n.length;if(i===0){for(var u=0;u<t;++u)n[u]=1;i=n.length}else{for(var u=0;u<t;++u)n[u]/=s;i/=s}var l=0,c=0,f,a;for(var u=0;u<t;++u)f=r[u],a=n[u],l+=f.x*a,c+=f.y*a;return new OpenLayers.Geometry.Point(l/i,c/i)},getGeodesicLength:function(e){var t=0;for(var n=0,r=this.components.length;n<r;n++)t+=this.components[n].getGeodesicLength(e);return t},move:function(e,t){for(var n=0,r=this.components.length;n<r;n++)this.components[n].move(e,t)},rotate:function(e,t){for(var n=0,r=this.components.length;n<r;++n)this.components[n].rotate(e,t)},resize:function(e,t,n){for(var r=0;r<this.components.length;++r)this.components[r].resize(e,t,n);return this},distanceTo:function(e,t){var n=!t||t.edge!==!1,r=n&&t&&t.details,i,s,o,u=Number.POSITIVE_INFINITY;for(var a=0,f=this.components.length;a<f;++a){i=this.components[a].distanceTo(e,t),o=r?i.distance:i;if(o<u){u=o,s=i;if(u==0)break}}return s},equals:function(e){var t=!0;if(!e||!e.CLASS_NAME||this.CLASS_NAME!=e.CLASS_NAME)t=!1;else if(!OpenLayers.Util.isArray(e.components)||e.components.length!=this.components.length)t=!1;else for(var n=0,r=this.components.length;n<r;++n)if(!this.components[n].equals(e.components[n])){t=!1;break}return t},transform:function(e,t){if(e&&t){for(var n=0,r=this.components.length;n<r;n++){var i=this.components[n];i.transform(e,t)}this.bounds=null}return this},intersects:function(e){var t=!1;for(var n=0,r=this.components.length;n<r;++n){t=e.intersects(this.components[n]);if(t)break}return t},getVertices:function(e){var t=[];for(var n=0,r=this.components.length;n<r;++n)Array.prototype.push.apply(t,this.components[n].getVertices(e));return t},CLASS_NAME:"OpenLayers.Geometry.Collection"});