GPolygon.prototype.Store=function(){if(this._EPoly){return}this._EPoly={};this._EPoly.Bounds=this.getBounds();this._EPoly.Lats=[];this._EPoly.Lngs=[];this._EPoly.Points=[];this._EPoly.Length=this.getVertexCount();for(var a=0;a<this._EPoly.Length;a++){var b=this.getVertex(a);this._EPoly.Lats[a]=b.lat();this._EPoly.Lngs[a]=b.lng();this._EPoly.Points[a]=b}};GPolygon.prototype.Contains=function(b){if(!this._EPoly){this.Store()}if(!this._EPoly.Bounds.containsLatLng(b)){return false}var c=0;var e=false;var a=b.lng();var f=b.lat();for(var d=0;d<this._EPoly.Length;d++){c++;if(c==this._EPoly.Length){c=0}if(((this._EPoly.Lats[d]<f)&&(this._EPoly.Lats[c]>=f))||((this._EPoly.Lats[c]<f)&&(this._EPoly.Lats[d]>=f))){if(this._EPoly.Lngs[d]+(f-this._EPoly.Lats[d])/(this._EPoly.Lats[c]-this._EPoly.Lats[d])*(this._EPoly.Lngs[c]-this._EPoly.Lngs[d])<a){e=!e}}}return e};GPolygon.prototype.Area=function(){if(!this._EPoly){this.Store()}if(this._EPoly.Area){return this._EPoly.Area}var m=0;var f=0;var k=this.getBounds();var e=k.getSouthWest().lng();var n=k.getSouthWest().lat();for(var g=0;g<this.getVertexCount();g++){f++;if(f==this.getVertexCount()){f=0}var d=this._EPoly.Points[g].distanceFrom(new GLatLng(this._EPoly.Lats[g],e));var c=this._EPoly.Points[f].distanceFrom(new GLatLng(this._EPoly.Lats[f],e));var l=this._EPoly.Points[g].distanceFrom(new GLatLng(n,this._EPoly.Lngs[g]));var h=this._EPoly.Points[f].distanceFrom(new GLatLng(n,this._EPoly.Lngs[f]));m+=d*h-c*l}this._EPoly.Area=Math.abs(m*0.5);return Math.abs(m*0.5)};GPolygon.prototype.Distance=function(){if(!this._EPoly){this.Store()}var b=0;for(var a=1;a<this.getVertexCount();a++){b+=this._EPoly.Points[a].distanceFrom(this.getVertex(a-1))}return b};GPolygon.prototype.Bounds=function(){return this.getBounds()};GPolygon.prototype.GetPointAtDistance=function(b){if(!this._EPoly){this.Store()}if(b==0){return this._EPoly.Points[0]}if(b<0){return null}var g=0;var c=0;for(var d=1;(d<this._EPoly.Length&&g<b);d++){c=g;g+=this._EPoly.Points[d].distanceFrom(this._EPoly.Points[d-1])}if(g<b){return null}var f=this._EPoly.Points[d-2];var e=this._EPoly.Points[d-1];var a=(b-c)/(g-c);return new GLatLng(f.lat()+(e.lat()-f.lat())*a,f.lng()+(e.lng()-f.lng())*a)};GPolygon.prototype.GetPointsAtDistance=function(a){if(!this._EPoly){this.Store()}var e=a;var h=[];if(a<=0){return h}var f=0;var c=0;for(var d=1;(d<this._EPoly.Length);d++){c=f;f+=this._EPoly.Points[d].distanceFrom(this.getVertex(d-1));while(f>e){var j=this._EPoly.Points[d-1];var g=this._EPoly.Points[d];var b=(e-c)/(f-c);h.push(new GLatLng(j.lat()+(g.lat()-j.lat())*b,j.lng()+(g.lng()-j.lng())*b));e+=a}}return h};GPolygon.prototype.GetIndexAtDistance=function(a){if(!this._EPoly){this.Store()}if(a==0){return this.getVertex(0)}if(a<0){return null}var d=0;var b=0;for(var c=1;(c<this._EPoly.Length&&d<a);c++){b=d;d+=this._EPoly.Points[c].distanceFrom(this._EPoly.Points[c-1])}if(d<a){return null}return c};GPolygon.prototype.Bearing=function(g,f){if(g==null){g=0;f=this.getVertexCount()-1}else{if(f==null){f=g+1}}if((g<0)||(g>=this.getVertexCount())||(f<0)||(f>=this.getVertexCount())){return}var h=this.getVertex(g);var i=this.getVertex(f);if(h.equals(i)){return 0}var c=h.latRadians();var e=h.lngRadians();var b=i.latRadians();var d=i.lngRadians();var a=-Math.atan2(Math.sin(e-d)*Math.cos(b),Math.cos(c)*Math.sin(b)-Math.sin(c)*Math.cos(b)*Math.cos(e-d));if(a<0){a+=Math.PI*2}a=a*180/Math.PI;return parseFloat(a.toFixed(1))};GPolyline.prototype.Store=GPolygon.prototype.Store;GPolyline.prototype.Contains=GPolygon.prototype.Contains;GPolyline.prototype.Area=GPolygon.prototype.Area;GPolyline.prototype.Distance=GPolygon.prototype.Distance;GPolyline.prototype.Bounds=GPolygon.prototype.Bounds;GPolyline.prototype.GetPointAtDistance=GPolygon.prototype.GetPointAtDistance;GPolyline.prototype.GetPointsAtDistance=GPolygon.prototype.GetPointsAtDistance;GPolyline.prototype.GetIndexAtDistance=GPolygon.prototype.GetIndexAtDistance;GPolyline.prototype.Bearing=GPolygon.prototype.Bearing;
