!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.turf=e()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;omindist){steps.push(t);laststep=step}}return steps};Spline.prototype.vector=function(t){var p1=this.pos(t+10);var p2=this.pos(t-10);return{angle:180*Math.atan2(p1.y-p2.y,p1.x-p2.x)/3.14,speed:Math.sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y)+(p2.z-p1.z)*(p2.z-p1.z))}};Spline.prototype.drawControlPoints=function(ctx,color){ctx.fillStyle=color||"#f60";ctx.strokeStyle="#fff";ctx.lineWidth=2;for(var i=0;ithis.duration)t=this.duration-1;var t2=t/this.duration;if(t2>=1)return this.points[this.length-1];var n=Math.floor((this.points.length-1)*t2);var t1=(this.length-1)*t2-n;return bezier(t1,this.points[n],this.controls[n][1],this.controls[n+1][0],this.points[n+1])};Spline.prototype.draw=function(ctx,color){ctx.strokeStyle=color||"#7e5e38";ctx.lineWidth=14;ctx.beginPath();var pos;for(var i=0;i2){var polyCoordinates=[];_.each(c,function(coord){polyCoordinates.push([coord.x,coord.y])});var poly=t.polygon([polyCoordinates]);poly.properties={};poly.properties[z]=c.level;fc.features.push(poly)}});if(donuts){var donutPolys=t.donuts(fc);var zGroups=[];_.each(donutPolys.features,function(ring){var found=false;_.each(zGroups,function(group){if(group.z===ring.properties[z]){found=true;group.rings.push(ring)}});if(!found){zGroups.push({z:ring.properties[z],rings:[ring]})}});donutPolys.features=[];_.each(zGroups,function(group){donutPolys.features.push(t.merge(t.featurecollection(group.rings)))});done(null,donutPolys);return donutPolys}else{done(null,fc);return fc}};exports.Conrec=Conrec;var EPSILON=1e-10;function pointsEqual(a,b){var x=a.x-b.x,y=a.y-b.y;return x*x+y*y=jlb;j--){for(var i=ilb;i<=iub-1;i++){var temp1,temp2;temp1=Math.min(d[i][j],d[i][j+1]);temp2=Math.min(d[i+1][j],d[i+1][j+1]);dmin=Math.min(temp1,temp2);temp1=Math.max(d[i][j],d[i][j+1]);temp2=Math.max(d[i+1][j],d[i+1][j+1]);dmax=Math.max(temp1,temp2);if(dmax>=z[0]&&dmin<=z[nc-1]){for(var k=0;k=dmin&&z[k]<=dmax){for(var m=4;m>=0;m--){if(m>0){h[m]=d[i+im[m-1]][j+jm[m-1]]-z[k];xh[m]=x[i+im[m-1]];yh[m]=y[j+jm[m-1]]}else{h[0]=.25*(h[1]+h[2]+h[3]+h[4]);xh[0]=.5*(x[i]+x[i+1]);yh[0]=.5*(y[j]+y[j+1])}if(h[m]>EPSILON){sh[m]=1}else if(h[m]<-EPSILON){sh[m]=-1}else sh[m]=0}for(m=1;m<=4;m++){m1=m;m2=0;if(m!=4){m3=m+1}else{m3=1}case_value=castab[sh[m1]+1][sh[m2]+1][sh[m3]+1];if(case_value!=0){switch(case_value){case 1:x1=xh[m1];y1=yh[m1];x2=xh[m2];y2=yh[m2];break;case 2:x1=xh[m2];y1=yh[m2];x2=xh[m3];y2=yh[m3];break;case 3:x1=xh[m3];y1=yh[m3];x2=xh[m1];y2=yh[m1];break;case 4:x1=xh[m1];y1=yh[m1];x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 5:x1=xh[m2];y1=yh[m2];x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 6:x1=xh[m3];y1=yh[m3];x2=xsect(m1,m2);y2=ysect(m1,m2);break;case 7:x1=xsect(m1,m2);y1=ysect(m1,m2);x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 8:x1=xsect(m2,m3);y1=ysect(m2,m3);x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 9:x1=xsect(m3,m1);y1=ysect(m3,m1);x2=xsect(m1,m2);y2=ysect(m1,m2);break;default:break}drawContour(x1,y1,x2,y2,z[k],k)}}}}}}}}},{"./donuts":17,"./extent":21,"./featurecollection":22,"./grid":25,"./inside":26,"./merge":36,"./planepoint":41,"./polygon":43,"./square":51,"./tin":54,async:59,lodash:66}],13:[function(_dereq_,module,exports){var t={};t.tin=_dereq_("./tin");t.merge=_dereq_("./merge");t.buffer=_dereq_("./buffer");module.exports=function(points,done){var tinPolys=t.tin(points,null),mergePolys;done=done||function(){};if(tinPolys instanceof Error){done(tinPolys);return tinPolys}mergePolys=t.merge(tinPolys);if(mergePolys instanceof Error){done(mergePolys)}else{done(null,mergePolys)}return mergePolys}},{"./buffer":7,"./merge":36,"./tin":54}],14:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={}}var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(1)}});poly.properties[outField]=values.length});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66}],15:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),ss=_dereq_("simple-statistics");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,inField,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={}}var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.standard_deviation(values)});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66,"simple-statistics":67}],16:[function(_dereq_,module,exports){module.exports=function(point1,point2,units,done){var toRad=function(degree){return degree*Math.PI/180};var coordinates1=point1.geometry.coordinates;var coordinates2=point2.geometry.coordinates;var dLat=toRad(coordinates2[0]-coordinates1[0]);var dLon=toRad(coordinates2[1]-coordinates1[1]);var lat1=toRad(coordinates1[1]);var lat2=toRad(coordinates2[1]);var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.sin(dLon/2)*Math.sin(dLon/2)*Math.cos(lat1)*Math.cos(lat2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var R=0;done=done||function(){};switch(units){case"miles":R=3960;break;case"kilometers":R=6373;break;case"degrees":R=57.2957795;break;case"radians":R=1;break}var distance=R*c;done(null,distance);return distance}},{}],17:[function(_dereq_,module,exports){var _=_dereq_("lodash");var t={};t.featurecollection=_dereq_("./featurecollection");t.erase=_dereq_("./erase");t.point=_dereq_("./point");t.inside=_dereq_("./inside");t.union=_dereq_("./union");module.exports=function(fc,done){done=done||function(){};donuts=t.featurecollection([]);_.each(fc.features,function(poly1){_.each(fc.features,function(poly2){if(_.isEqual(poly1,poly2)){}else{var isContained=contained(poly1,poly2);if(isContained&&!_.isEqual(poly1.properties,poly2.properties)){var erased=t.erase(poly1,poly2);if(!_.some(donuts.features,erased)){poly1=erased}}if(isContained&&_.isEqual(poly1.properties,poly2.properties)){var unioned=t.union(poly1,poly2);if(!_.some(donuts.features,unioned)){poly1=unioned}}}});donuts.features.push(poly1)});done(null,donuts);return donuts};function contained(poly1,poly2){var sampleVertex=t.point(poly2.geometry.coordinates[0][0][0],poly2.geometry.coordinates[0][0][1]);return t.inside(sampleVertex,poly1)}},{"./erase":19,"./featurecollection":22,"./inside":26,"./point":42,"./union":56,lodash:66}],18:[function(_dereq_,module,exports){var t={};var extent=_dereq_("./extent"),bboxPolygon=_dereq_("./bboxPolygon");t.bboxPolygon=bboxPolygon;t.extent=extent;module.exports=function(features,done){var poly=t.bboxPolygon(t.extent(features));done=done||function(){};if(poly instanceof Error){done(poly)}else{done(null,poly)}return poly}},{"./bboxPolygon":5,"./extent":21}],19:[function(_dereq_,module,exports){var jsts=_dereq_("jsts"),_=_dereq_("lodash");var t={};t.featurecollection=_dereq_("./featurecollection");module.exports=function(poly1,poly2,done){poly1=correctRings(poly1);poly2=correctRings(poly2);var reader=new jsts.io.GeoJSONReader;var a=reader.read(JSON.stringify(poly1.geometry));var b=reader.read(JSON.stringify(poly2.geometry));var erased=a.difference(b);var parser=new jsts.io.GeoJSONParser;erased=parser.write(erased);var newPoly=_.cloneDeep(poly1);newPoly.geometry=erased;done=done||function(){};done(null,newPoly);return newPoly};function correctRings(poly){_.each(poly.geometry.coordinates,function(ring){var isWrapped=_.isEqual(ring[0],ring.slice(-1)[0]);if(!isWrapped){ring.push(ring[0])}});return poly}},{"./featurecollection":22,jsts:63,lodash:66}],20:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),featurecollection=_dereq_("./featurecollection"),point=_dereq_("./point");t.featurecollection=featurecollection;t.point=point;module.exports=function(features,done){var coordinates=[];done=done||function(){};if(features.type==="FeatureCollection"){for(var i in features.features){switch(features.features[i].geometry.type){case"Point":coordinates.push([features.features[i].geometry.coordinates]);break;case"LineString":coordinates.push(features.features[i].geometry.coordinates);break;case"Polygon":coordinates.push(features.features[i].geometry.coordinates);coordinates.push(_.flatten(coordinates,true));break;case"MultiPoint":coordinates.push(features.features[i].geometry.coordinates);break;case"MultiLineString":coordinates.push(features.features[i].geometry.coordinates);coordinates.push(_.flatten(coordinates,true));break;case"MultiPolygon":coordinates.push(features.features[i].geometry.coordinates);coordinates.push(_.flatten(coordinates,true));coordinates.push(_.flatten(coordinates,true));break}if(!features.features[i].geometry&&features.features[i].properties){throw new Error("Unknown Geometry Type")}}coordinates=_.flatten(coordinates,true)}else{var geometry;if(features.type==="Feature"){geometry=features.geometry}else{geometry=features}switch(geometry.type){case"Point":coordinates=[geometry.coordinates];break;case"LineString":coordinates=geometry.coordinates;break;case"Polygon":coordinates=geometry.coordinates;coordinates=_.flatten(coordinates,true);break;case"MultiPoint":coordinates=geometry.coordinates;break;case"MultiLineString":coordinates=geometry.coordinates;coordinates=_.flatten(coordinates,true);break;case"MultiPolygon":coordinates=geometry.coordinates;coordinates=_.flatten(coordinates,true);coordinates=_.flatten(coordinates,true);break}if(!geometry){throw new Error("No Geometry Found")}}var fc=t.featurecollection([]);_.each(coordinates,function(c){fc.features.push(t.point(c[0],c[1]))});done(null,fc);return fc}},{"./featurecollection":22,"./point":42,lodash:66}],21:[function(_dereq_,module,exports){_=_dereq_("lodash");module.exports=function(layer,done){var xmin=Infinity,ymin=Infinity,xmax=-Infinity,ymax=-Infinity;done=done||function(){};if(layer.type==="FeatureCollection"){for(var i in layer.features){var coordinates;switch(layer.features[i].geometry.type){case"Point":coordinates=[layer.features[i].geometry.coordinates];break;case"LineString":coordinates=layer.features[i].geometry.coordinates;break;case"Polygon":coordinates=layer.features[i].geometry.coordinates;coordinates=_.flatten(coordinates,true);break;case"MultiPoint":coordinates=layer.features[i].geometry.coordinates;break;case"MultiLineString":coordinates=layer.features[i].geometry.coordinates;coordinates=_.flatten(coordinates,true);break;case"MultiPolygon":coordinates=layer.features[i].geometry.coordinates;coordinates=_.flatten(coordinates,true);coordinates=_.flatten(coordinates,true);break}if(!layer.features[i].geometry&&layer.features[i].properties){throw new Error("Unknown Geometry Type")}for(var n in coordinates){if(xmin>coordinates[n][0]){xmin=coordinates[n][0]}if(ymin>coordinates[n][1]){ymin=coordinates[n][1]}if(xmaxcoordinates[n][0]){xmin=coordinates[n][0]}if(ymin>coordinates[n][1]){ymin=coordinates[n][1]}if(xmaxy!=yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi;if(intersect)isInside=!isInside}done(null,isInside);return isInside}},{}],27:[function(_dereq_,module,exports){var jsts=_dereq_("jsts");var t={};t.featurecollection=_dereq_("./featurecollection");module.exports=function(polys1,polys2,done){var reader=new jsts.io.GeoJSONReader;var a=reader.read(JSON.stringify(polys1.features[0].geometry));var b=reader.read(JSON.stringify(polys2.features[0].geometry));var intersection=a.intersection(b);var parser=new jsts.io.GeoJSONParser;done=done||function(){};intersection=parser.write(intersection);intersection=t.featurecollection([intersection]);done(null,intersection);return intersection}},{"./featurecollection":22,jsts:63}],28:[function(_dereq_,module,exports){module.exports=function(ring){var sum=0;var i=1;var len=ring.length;var prev,cur;while(i0}},{}],29:[function(_dereq_,module,exports){var _=_dereq_("lodash"),async=_dereq_("async");var t={};t.tin=_dereq_("./tin");t.inside=_dereq_("./inside");t.grid=_dereq_("./grid");t.extent=_dereq_("./extent");t.planepoint=_dereq_("./planepoint");t.featurecollection=_dereq_("./featurecollection");t.polygon=_dereq_("./polygon");t.square=_dereq_("./square");t.donuts=_dereq_("./donuts");t.merge=_dereq_("./merge");t.size=_dereq_("./size");t.point=_dereq_("./point");module.exports=function(points,z,resolution,breaks,done){var addEdgesResult=addEdges(points,z,resolution);done=done||function(){};if(addEdgesResult instanceof Error){done(addEdgesResult);return addEdgesResult}var tinResult=t.tin(points,z),extentBBox=t.extent(points),squareBBox=t.square(extentBBox),gridResult=t.grid(squareBBox,resolution),data=[];_(gridResult.features).each(function(pt){_(tinResult.features).each(function(triangle){if(t.inside(pt,triangle)){pt.properties={};pt.properties[z]=t.planepoint(pt,triangle)}});if(!pt.properties){pt.properties={};pt.properties[z]=-100}});var depth=Math.sqrt(gridResult.features.length);for(var x=0;x2){var polyCoordinates=[];_.each(c,function(coord){polyCoordinates.push([coord.x,coord.y])});var poly=t.polygon([polyCoordinates]);poly.properties={};poly.properties[z]=c.level;fc.features.push(poly)}});var donutPolys=t.donuts(fc);var zGroups=[];_.each(donutPolys.features,function(ring){var found=false;_.each(zGroups,function(group){if(group.z===ring.properties[z]){found=true;group.rings.push(ring)}});if(!found){zGroups.push({z:ring.properties[z],rings:[ring]})}});donutPolys.features=[];_.each(zGroups,function(group){_.each(group.rings,function(ring){});donutPolys.features.push(t.merge(t.featurecollection(group.rings)))});done(null,donutPolys);return donutPolys};function addEdges(points,z,resolution){var extentBBox=t.extent(points),squareBBox,sizeResult;if(extentBBox instanceof Error){return extentBBox}squareBBox=t.square(extentBBox);if(squareBBox instanceof Error){return squareBBox}sizeBBox=t.size(squareBBox,.35);if(sizeBBox instanceof Error){return sizeBBox}var edgeDistance=sizeBBox[2]-sizeBBox[0];var extendDistance=edgeDistance/resolution;var xmin=sizeBBox[0];var ymin=sizeBBox[1];var xmax=sizeBBox[2];var ymax=sizeBBox[3];var left=[[xmin,ymin],[xmin,ymax]];for(var i=0;i<=resolution;i++){var pt=t.point(xmin,ymin+extendDistance*i);pt.properties={};pt.properties[z]=-100;points.features.push(pt)}var bottom=[[xmin,ymin],[xmax,ymin]];for(var i=0;i<=resolution;i++){var pt=t.point(xmin+extendDistance*i,ymin);pt.properties={};pt.properties[z]=-100;points.features.push(pt)}var right=[[xmax,ymin],[xmax,ymax]];for(var i=0;i<=resolution;i++){var pt=t.point(xmax,ymin+extendDistance*i);pt.properties={};pt.properties[z]=-100;points.features.push(pt)}var top=[[xmin,ymax],[xmax,ymax]];for(var i=0;i<=resolution;i++){var pt=t.point(xmin+extendDistance*i,ymax);pt.properties={};pt.properties[z]=-100;points.features.push(pt)}return points}exports.Conrec=Conrec;var EPSILON=1e-10;function pointsEqual(a,b){var x=a.x-b.x,y=a.y-b.y;return x*x+y*y=jlb;j--){for(var i=ilb;i<=iub-1;i++){var temp1,temp2;temp1=Math.min(d[i][j],d[i][j+1]);temp2=Math.min(d[i+1][j],d[i+1][j+1]);dmin=Math.min(temp1,temp2);temp1=Math.max(d[i][j],d[i][j+1]);temp2=Math.max(d[i+1][j],d[i+1][j+1]);dmax=Math.max(temp1,temp2);if(dmax>=z[0]&&dmin<=z[nc-1]){for(var k=0;k=dmin&&z[k]<=dmax){for(var m=4;m>=0;m--){if(m>0){h[m]=d[i+im[m-1]][j+jm[m-1]]-z[k];xh[m]=x[i+im[m-1]];yh[m]=y[j+jm[m-1]]}else{h[0]=.25*(h[1]+h[2]+h[3]+h[4]);xh[0]=.5*(x[i]+x[i+1]);yh[0]=.5*(y[j]+y[j+1])}if(h[m]>EPSILON){sh[m]=1}else if(h[m]<-EPSILON){sh[m]=-1}else sh[m]=0}for(m=1;m<=4;m++){m1=m;m2=0;if(m!=4){m3=m+1}else{m3=1}case_value=castab[sh[m1]+1][sh[m2]+1][sh[m3]+1];if(case_value!=0){switch(case_value){case 1:x1=xh[m1];y1=yh[m1];x2=xh[m2];y2=yh[m2];break;case 2:x1=xh[m2];y1=yh[m2];x2=xh[m3];y2=yh[m3];break;case 3:x1=xh[m3];y1=yh[m3];x2=xh[m1];y2=yh[m1];break;case 4:x1=xh[m1];y1=yh[m1];x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 5:x1=xh[m2];y1=yh[m2];x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 6:x1=xh[m3];y1=yh[m3];x2=xsect(m1,m2);y2=ysect(m1,m2);break;case 7:x1=xsect(m1,m2);y1=ysect(m1,m2);x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 8:x1=xsect(m2,m3);y1=ysect(m2,m3);x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 9:x1=xsect(m3,m1);y1=ysect(m3,m1);x2=xsect(m1,m2);y2=ysect(m1,m2);break;default:break}drawContour(x1,y1,x2,y2,z[k],k)}}}}}}}}},{"./donuts":17,"./extent":21,"./featurecollection":22,"./grid":25,"./inside":26,"./merge":36,"./planepoint":41,"./point":42,"./polygon":43,"./size":50,"./square":51,"./tin":54,async:59,lodash:66}],30:[function(_dereq_,module,exports){var _=_dereq_("lodash"),async=_dereq_("async");var t={};t.tin=_dereq_("./tin");t.inside=_dereq_("./inside");t.grid=_dereq_("./grid");t.extent=_dereq_("./extent");t.planepoint=_dereq_("./planepoint");t.featurecollection=_dereq_("./featurecollection");t.linestring=_dereq_("./linestring");t.square=_dereq_("./square");module.exports=function(points,z,resolution,breaks,done){var tinResult=t.tin(points,z),extentBBox=t.extent(points),squareBBox=t.square(extentBBox),gridResult=t.grid(squareBBox,resolution),data=[];done=done||function(){};_(gridResult.features).each(function(pt){_(tinResult.features).each(function(triangle){if(t.inside(pt,triangle)){pt.properties={};pt.properties[z]=t.planepoint(pt,triangle)}})});var depth=Math.sqrt(gridResult.features.length);for(var x=0;x2){var polyCoordinates=[];_.each(c,function(coord){polyCoordinates.push([coord.x,coord.y])});var poly=t.linestring(polyCoordinates);poly.properties={};poly.properties[z]=c.level;fc.features.push(poly)}});done(null,fc);return fc};exports.Conrec=Conrec;var EPSILON=1e-10;function pointsEqual(a,b){var x=a.x-b.x,y=a.y-b.y;return x*x+y*y=jlb;j--){for(var i=ilb;i<=iub-1;i++){var temp1,temp2;temp1=Math.min(d[i][j],d[i][j+1]);temp2=Math.min(d[i+1][j],d[i+1][j+1]);dmin=Math.min(temp1,temp2);temp1=Math.max(d[i][j],d[i][j+1]);temp2=Math.max(d[i+1][j],d[i+1][j+1]);dmax=Math.max(temp1,temp2);if(dmax>=z[0]&&dmin<=z[nc-1]){for(var k=0;k=dmin&&z[k]<=dmax){for(var m=4;m>=0;m--){if(m>0){h[m]=d[i+im[m-1]][j+jm[m-1]]-z[k];xh[m]=x[i+im[m-1]];yh[m]=y[j+jm[m-1]]}else{h[0]=.25*(h[1]+h[2]+h[3]+h[4]);xh[0]=.5*(x[i]+x[i+1]);yh[0]=.5*(y[j]+y[j+1])}if(h[m]>EPSILON){sh[m]=1}else if(h[m]<-EPSILON){sh[m]=-1}else sh[m]=0}for(m=1;m<=4;m++){m1=m;m2=0;if(m!=4){m3=m+1}else{m3=1}case_value=castab[sh[m1]+1][sh[m2]+1][sh[m3]+1];if(case_value!=0){switch(case_value){case 1:x1=xh[m1];y1=yh[m1];x2=xh[m2];y2=yh[m2];break;case 2:x1=xh[m2];y1=yh[m2];x2=xh[m3];y2=yh[m3];break;case 3:x1=xh[m3];y1=yh[m3];x2=xh[m1];y2=yh[m1];break;case 4:x1=xh[m1];y1=yh[m1];x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 5:x1=xh[m2];y1=yh[m2];x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 6:x1=xh[m3];y1=yh[m3];x2=xsect(m1,m2);y2=ysect(m1,m2);break;case 7:x1=xsect(m1,m2);y1=ysect(m1,m2);x2=xsect(m2,m3);y2=ysect(m2,m3);break;case 8:x1=xsect(m2,m3);y1=ysect(m2,m3);x2=xsect(m3,m1);y2=ysect(m3,m1);break;case 9:x1=xsect(m3,m1);y1=ysect(m3,m1);x2=xsect(m1,m2);y2=ysect(m1,m2);break;default:break}drawContour(x1,y1,x2,y2,z[k],k)}}}}}}}}},{"./extent":21,"./featurecollection":22,"./grid":25,"./inside":26,"./linestring":32,"./planepoint":41,"./square":51,"./tin":54,async:59,lodash:66}],31:[function(_dereq_,module,exports){var ss=_dereq_("simple-statistics"),_=_dereq_("lodash");module.exports=function(fc,field,num,done){var vals=[];var breaks=[];done=done||function(){};_.each(fc.features,function(feature){if(!(feature.properties[field]===undefined)){vals.push(feature.properties[field])}});breaks=ss.jenks(vals,num);done(null,breaks);return breaks}},{lodash:66,"simple-statistics":67}],32:[function(_dereq_,module,exports){module.exports=function(coordinates,properties){if(coordinates===null)throw new Error("No coordinates passed");var linestring={type:"Feature",geometry:{type:"LineString",coordinates:coordinates},properties:properties};return linestring}},{}],33:[function(_dereq_,module,exports){var path=_dereq_("path"),fs=_dereq_("fs"),layer;module.exports=function(file,done){fs.readFile(file,function(err,res){if(err)done(err);layer=JSON.parse(res);done(null,layer)})}},{fs:60,path:62}],34:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),ss=_dereq_("simple-statistics");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,inField,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={}}var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.max(values)});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66,"simple-statistics":67}],35:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),ss=_dereq_("simple-statistics");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,inField,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={}}var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.median(values)});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66,"simple-statistics":67}],36:[function(_dereq_,module,exports){var _=_dereq_("lodash");var t={};t.union=_dereq_("./union");module.exports=function(polygons,done){var merged=_.cloneDeep(polygons.features[0]),features=polygons.features;done=done||function(){};for(var i=0,len=features.length;i=translations[i][0]&&feature.properties[inField]<=translations[i][1]){reclassedFeature=_.clone(feature,true);reclassedFeature.properties[outField]=translations[i][2]}}reclassed.features.push(reclassedFeature)});done(null,reclassed);return reclassed}},{"./featurecollection":22}],46:[function(_dereq_,module,exports){var t={};var featurecollection=_dereq_("./featurecollection");t.featurecollection=featurecollection;module.exports=function(collection,key,val,done){var newFC=t.featurecollection([]);done=done||function(){};for(var i=0;i=verticalDistance){squareBbox[0]=bbox[0];squareBbox[2]=bbox[2];verticalMidpoint=t.midpoint(lowLeft,topLeft);squareBbox[1]=verticalMidpoint.geometry.coordinates[1]-(bbox[2]-bbox[0])/2;squareBbox[3]=verticalMidpoint.geometry.coordinates[1]+(bbox[2]-bbox[0])/2}else{squareBbox[1]=bbox[1];squareBbox[3]=bbox[3];horizontalMidpoint=t.midpoint(lowLeft,lowRight);squareBbox[0]=horizontalMidpoint.geometry.coordinates[0]-(bbox[3]-bbox[1])/2;squareBbox[2]=horizontalMidpoint.geometry.coordinates[0]+(bbox[3]-bbox[1])/2}done(null,squareBbox);return squareBbox}},{"../lib/distance":16,"../lib/midpoint":37,"../lib/point":42}],52:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),ss=_dereq_("simple-statistics");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,inField,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={}}var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.sum(values)});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66,"simple-statistics":67}],53:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash");t.inside=_dereq_("./inside");module.exports=function(points,polygons,field,outField,done){done=done||function(){};_.each(points.features,function(pt){if(!pt.properties){pt.properties={}}_.each(polygons.features,function(poly){if(!pt.properties[outField]){if(t.inside(pt,poly)){pt.properties[outField]=poly.properties[field]}else{pt.properties[outField]=null}}})});done(null,points);return points}},{"./inside":26,lodash:66}],54:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),polygon=_dereq_("./polygon"),nearest=_dereq_("./nearest"),point=_dereq_("./point");t.polygon=polygon;t.nearest=nearest;t.point=point;module.exports=function(points,z,done){var vertices=[];_(points.features).each(function(p){vertices.push({x:p.geometry.coordinates[0],y:p.geometry.coordinates[1]})});var triangulated=triangulate(vertices);var triangles={type:"FeatureCollection",features:[]};done=done||function(){};_(triangulated).each(function(triangle){var coords=[[[triangle.a.x,triangle.a.y],[triangle.b.x,triangle.b.y],[triangle.c.x,triangle.c.y]]];var poly=t.polygon(coords,{a:null,b:null,c:null});triangles.features.push(poly)});if(z){_.each(triangles.features,function(tri){var coordinateNumber=1;_.each(tri.geometry.coordinates[0],function(c){var closest=t.nearest(t.point(c[0],c[1]),points);if(coordinateNumber===1){tri.properties.a=closest.properties[z]}else if(coordinateNumber===2){tri.properties.b=closest.properties[z]}else if(coordinateNumber===3){tri.properties.c=closest.properties[z]}coordinateNumber++})})}_.each(triangles.features,function(tri){tri=correctRings(tri)});done(null,triangles);return triangles};function correctRings(poly){_.each(poly.geometry.coordinates,function(ring){var isWrapped=_.isEqual(ring[0],ring.slice(-1)[0]);if(!isWrapped){ring.push(ring[0])}});return poly}function Triangle(a,b,c){this.a=a;this.b=b;this.c=c;var A=b.x-a.x,B=b.y-a.y,C=c.x-a.x,D=c.y-a.y,E=A*(a.x+b.x)+B*(a.y+b.y),F=C*(a.x+c.x)+D*(a.y+c.y),G=2*(A*(c.y-b.y)-B*(c.x-b.x)),minx,miny,dx,dy;if(Math.abs(G)<1e-6){minx=Math.min(a.x,b.x,c.x);miny=Math.min(a.y,b.y,c.y);dx=(Math.max(a.x,b.x,c.x)-minx)*.5;dy=(Math.max(a.y,b.y,c.y)-miny)*.5;this.x=minx+dx;this.y=miny+dy;this.r=dx*dx+dy*dy}else{this.x=(D*E-B*F)/G;this.y=(A*F-C*E)/G;dx=this.x-a.x;dy=this.y-a.y;this.r=dx*dx+dy*dy}}Triangle.prototype.draw=function(ctx){ctx.beginPath();ctx.moveTo(this.a.x,this.a.y);ctx.lineTo(this.b.x,this.b.y);ctx.lineTo(this.c.x,this.c.y);ctx.closePath();ctx.stroke()};function byX(a,b){return b.x-a.x}function dedup(edges){var j=edges.length,a,b,i,m,n;outer:while(j){b=edges[--j];a=edges[--j];i=j;while(i){n=edges[--i];m=edges[--i];if(a===m&&b===n||a===n&&b===m){edges.splice(j,2);edges.splice(i,2);j-=2;continue outer}}}}function triangulate(vertices){if(vertices.length<3)return[];vertices.sort(byX);var i=vertices.length-1,xmin=vertices[i].x,xmax=vertices[0].x,ymin=vertices[i].y,ymax=ymin;while(i--){if(vertices[i].yymax)ymax=vertices[i].y}var dx=xmax-xmin,dy=ymax-ymin,dmax=dx>dy?dx:dy,xmid=(xmax+xmin)*.5,ymid=(ymax+ymin)*.5,open=[new Triangle({x:xmid-20*dmax,y:ymid-dmax,__sentinel:true},{x:xmid,y:ymid+20*dmax,__sentinel:true},{x:xmid+20*dmax,y:ymid-dmax,__sentinel:true})],closed=[],edges=[],j,a,b;i=vertices.length;while(i--){edges.length=0;j=open.length;while(j--){dx=vertices[i].x-open[j].x;if(dx>0&&dx*dx>open[j].r){closed.push(open[j]);open.splice(j,1);continue}dy=vertices[i].y-open[j].y;if(dx*dx+dy*dy>open[j].r)continue;edges.push(open[j].a,open[j].b,open[j].b,open[j].c,open[j].c,open[j].a);open.splice(j,1)}dedup(edges);j=edges.length;while(j){b=edges[--j];a=edges[--j];open.push(new Triangle(a,b,vertices[i]))}}Array.prototype.push.apply(closed,open);i=closed.length;while(i--)if(closed[i].a.__sentinel||closed[i].b.__sentinel||closed[i].c.__sentinel)closed.splice(i,1);return closed}},{"./nearest":40,"./point":42,"./polygon":43,lodash:66}],55:[function(_dereq_,module,exports){var topojson=_dereq_("topojson");module.exports=function(geojson,done){var topology=topojson.topology({geojson:geojson});done=done||function(){};done(null,topology);return topology}},{topojson:68}],56:[function(_dereq_,module,exports){var jsts=_dereq_("jsts");var t={};t.featurecollection=_dereq_("./featurecollection");module.exports=function(poly1,poly2,done){var reader=new jsts.io.GeoJSONReader;var a=reader.read(JSON.stringify(poly1.geometry));var b=reader.read(JSON.stringify(poly2.geometry));var union=a.union(b);var parser=new jsts.io.GeoJSONParser;done=done||function(){};union=parser.write(union);union={type:"Feature",geometry:union,properties:poly1.properties};done(null,union);return union}},{"./featurecollection":22,jsts:63}],57:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash"),ss=_dereq_("simple-statistics");t.inside=_dereq_("./inside");module.exports=function(polyFC,ptFC,inField,outField,done){done=done||function(){};_.each(polyFC.features,function(poly){if(!poly.properties){poly.properties={} }var values=[];_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.variance(values)});done(null,polyFC);return polyFC}},{"./inside":26,lodash:66,"simple-statistics":67}],58:[function(_dereq_,module,exports){var t={};var _=_dereq_("lodash");t.inside=_dereq_("./inside");t.featurecollection=_dereq_("./featurecollection");module.exports=function(ptFC,polyFC,done){var pointsWithin=t.featurecollection([]);done=done||function(){};_.each(polyFC.features,function(poly){_.each(ptFC.features,function(pt){if(t.inside(pt,poly)){pointsWithin.features.push(pt)}})});done(null,pointsWithin);return pointsWithin}},{"./featurecollection":22,"./inside":26,lodash:66}],59:[function(_dereq_,module,exports){(function(process){(function(){var async={};var root,previous_async;root=this;if(root!=null){previous_async=root.async}async.noConflict=function(){root.async=previous_async;return async};function only_once(fn){var called=false;return function(){if(called)throw new Error("Callback was already called.");called=true;fn.apply(root,arguments)}}var _each=function(arr,iterator){if(arr.forEach){return arr.forEach(iterator)}for(var i=0;i=arr.length){callback(null)}}}))})};async.forEach=async.each;async.eachSeries=function(arr,iterator,callback){callback=callback||function(){};if(!arr.length){return callback()}var completed=0;var iterate=function(){iterator(arr[completed],function(err){if(err){callback(err);callback=function(){}}else{completed+=1;if(completed>=arr.length){callback(null)}else{iterate()}}})};iterate()};async.forEachSeries=async.eachSeries;async.eachLimit=function(arr,limit,iterator,callback){var fn=_eachLimit(limit);fn.apply(null,[arr,iterator,callback])};async.forEachLimit=async.eachLimit;var _eachLimit=function(limit){return function(arr,iterator,callback){callback=callback||function(){};if(!arr.length||limit<=0){return callback()}var completed=0;var started=0;var running=0;(function replenish(){if(completed>=arr.length){return callback()}while(running=arr.length){callback()}else{replenish()}}})}})()}};var doParallel=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.each].concat(args))}};var doParallelLimit=function(limit,fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[_eachLimit(limit)].concat(args))}};var doSeries=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.eachSeries].concat(args))}};var _asyncMap=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x}});eachfn(arr,function(x,callback){iterator(x.value,function(err,v){results[x.index]=v;callback(err)})},function(err){callback(err,results)})};async.map=doParallel(_asyncMap);async.mapSeries=doSeries(_asyncMap);async.mapLimit=function(arr,limit,iterator,callback){return _mapLimit(limit)(arr,iterator,callback)};var _mapLimit=function(limit){return doParallelLimit(limit,_asyncMap)};async.reduce=function(arr,memo,iterator,callback){async.eachSeries(arr,function(x,callback){iterator(memo,x,function(err,v){memo=v;callback(err)})},function(err){callback(err,memo)})};async.inject=async.reduce;async.foldl=async.reduce;async.reduceRight=function(arr,memo,iterator,callback){var reversed=_map(arr,function(x){return x}).reverse();async.reduce(reversed,memo,iterator,callback)};async.foldr=async.reduceRight;var _filter=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x}});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(v){results.push(x)}callback()})},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index}),function(x){return x.value}))})};async.filter=doParallel(_filter);async.filterSeries=doSeries(_filter);async.select=async.filter;async.selectSeries=async.filterSeries;var _reject=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x}});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(!v){results.push(x)}callback()})},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index}),function(x){return x.value}))})};async.reject=doParallel(_reject);async.rejectSeries=doSeries(_reject);var _detect=function(eachfn,arr,iterator,main_callback){eachfn(arr,function(x,callback){iterator(x,function(result){if(result){main_callback(x);main_callback=function(){}}else{callback()}})},function(err){main_callback()})};async.detect=doParallel(_detect);async.detectSeries=doSeries(_detect);async.some=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(v){main_callback(true);main_callback=function(){}}callback()})},function(err){main_callback(false)})};async.any=async.some;async.every=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(!v){main_callback(false);main_callback=function(){}}callback()})},function(err){main_callback(true)})};async.all=async.every;async.sortBy=function(arr,iterator,callback){async.map(arr,function(x,callback){iterator(x,function(err,criteria){if(err){callback(err)}else{callback(null,{value:x,criteria:criteria})}})},function(err,results){if(err){return callback(err)}else{var fn=function(left,right){var a=left.criteria,b=right.criteria;return ab?1:0};callback(null,_map(results.sort(fn),function(x){return x.value}))}})};async.auto=function(tasks,callback){callback=callback||function(){};var keys=_keys(tasks);if(!keys.length){return callback(null)}var results={};var listeners=[];var addListener=function(fn){listeners.unshift(fn)};var removeListener=function(fn){for(var i=0;i2){var args=Array.prototype.slice.call(arguments,2);return go.apply(this,args)}else{return go}};async.applyEach=doParallel(_applyEach);async.applyEachSeries=doSeries(_applyEach);async.forever=function(fn,callback){function next(err){if(err){if(callback){return callback(err)}throw err}fn(next)}next()};if(typeof define!=="undefined"&&define.amd){define([],function(){return async})}else if(typeof module!=="undefined"&&module.exports){module.exports=async}else{root.async=async}})()}).call(this,_dereq_("m:\\development\\github repositories\\turf\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js"))},{"m:\\development\\github repositories\\turf\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js":61}],60:[function(_dereq_,module,exports){},{}],61:[function(_dereq_,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}if(canPost){var queue=[];window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],62:[function(_dereq_,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;ihiPt.y){hiPt=p;hiIndex=i}}iPrev=hiIndex;do{iPrev=iPrev-1;if(iPrev<0){iPrev=nPts}}while(ring[iPrev].equals2D(hiPt)&&iPrev!==hiIndex);iNext=hiIndex;do{iNext=(iNext+1)%nPts}while(ring[iNext].equals2D(hiPt)&&iNext!==hiIndex);prev=ring[iPrev];next=ring[iNext];if(prev.equals2D(hiPt)||next.equals2D(hiPt)||prev.equals2D(next)){return false}disc=jsts.algorithm.CGAlgorithms.computeOrientation(prev,hiPt,next);isCCW=false;if(disc===0){isCCW=prev.x>next.x}else{isCCW=disc>0}return isCCW};jsts.algorithm.CGAlgorithms.computeOrientation=function(p1,p2,q){return jsts.algorithm.CGAlgorithms.orientationIndex(p1,p2,q)};jsts.algorithm.CGAlgorithms.distancePointLine=function(p,A,B){if(!(A instanceof jsts.geom.Coordinate)){jsts.algorithm.CGAlgorithms.distancePointLine2.apply(this,arguments)}if(A.x===B.x&&A.y===B.y){return p.distance(A)}var r,s;r=((p.x-A.x)*(B.x-A.x)+(p.y-A.y)*(B.y-A.y))/((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));if(r<=0){return p.distance(A)}if(r>=1){return p.distance(B)}s=((A.y-p.y)*(B.x-A.x)-(A.x-p.x)*(B.y-A.y))/((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));return Math.abs(s)*Math.sqrt((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y))};jsts.algorithm.CGAlgorithms.distancePointLinePerpendicular=function(p,A,B){var s=((A.y-p.y)*(B.x-A.x)-(A.x-p.x)*(B.y-A.y))/((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));return Math.abs(s)*Math.sqrt((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y)) };jsts.algorithm.CGAlgorithms.distancePointLine2=function(p,line){var minDistance,i,il,dist;if(line.length===0){throw new jsts.error.IllegalArgumentError("Line array must contain at least one vertex")}minDistance=p.distance(line[0]);for(i=0,il=line.length-1;i1||s<0||s>1){return Math.min(jsts.algorithm.CGAlgorithms.distancePointLine(A,C,D),Math.min(jsts.algorithm.CGAlgorithms.distancePointLine(B,C,D),Math.min(jsts.algorithm.CGAlgorithms.distancePointLine(C,A,B),jsts.algorithm.CGAlgorithms.distancePointLine(D,A,B))))}return 0};jsts.algorithm.CGAlgorithms.signedArea=function(ring){if(ring.length<3){return 0}var sum,i,il,bx,by,cx,cy;sum=0;for(i=0,il=ring.length-1;i0};jsts.algorithm.Angle.isObtuse=function(p0,p1,p2){var dx0,dy0,dx1,dy1,dotprod;dx0=p0.x-p1.x;dy0=p0.y-p1.y;dx1=p2.x-p1.x;dy1=p2.y-p1.y;dotprod=dx0*dx1+dy0*dy1;return dotprod<0};jsts.algorithm.Angle.angleBetween=function(tip1,tail,tip2){var a1,a2;a1=jsts.algorithm.Angle.angle(tail,tip1);a2=jsts.algorithm.Angle.angle(tail,tip2);return jsts.algorithm.Angle.diff(a1,a2)};jsts.algorithm.Angle.angleBetweenOriented=function(tip1,tail,tip2){var a1,a2,angDel;a1=jsts.algorithm.Angle.angle(tail,tip1);a2=jsts.algorithm.Angle.angle(tail,tip2);angDel=a2-a1;if(angDel<=-Math.PI){return angDel+jsts.algorithm.Angle.PI_TIMES_2}if(angDel>Math.PI){return angDel-jsts.algorithm.Angle.PI_TIMES_2}return angDel};jsts.algorithm.Angle.interiorAngle=function(p0,p1,p2){var anglePrev,angleNext;anglePrev=jsts.algorithm.Angle.angle(p1,p0);angleNext=jsts.algorithm.Angle.angle(p1,p2);return Math.abs(angleNext-anglePrev)};jsts.algorithm.Angle.getTurn=function(ang1,ang2){var crossproduct=Math.sin(ang2-ang1);if(crossproduct>0){return jsts.algorithm.Angle.COUNTERCLOCKWISE}if(crossproduct<0){return jsts.algorithm.Angle.CLOCKWISE}return jsts.algorithm.Angle.NONE};jsts.algorithm.Angle.normalize=function(angle){while(angle>Math.PI){angle-=jsts.algorithm.Angle.PI_TIMES_2}while(angle<=-Math.PI){angle+=jsts.algorithm.Angle.PI_TIMES_2}return angle};jsts.algorithm.Angle.normalizePositive=function(angle){if(angle<0){while(angle<0){angle+=jsts.algorithm.Angle.PI_TIMES_2}if(angle>=jsts.algorithm.Angle.PI_TIMES_2){angle=0}}else{while(angle>=jsts.algorithm.Angle.PI_TIMES_2){angle-=jsts.algorithm.Angle.PI_TIMES_2}if(angle<0){angle=0}}return angle};jsts.algorithm.Angle.diff=function(ang1,ang2){var delAngle;if(ang1Math.PI){delAngle=2*Math.PI-delAngle}return delAngle};jsts.geom.GeometryComponentFilter=function(){};jsts.geom.GeometryComponentFilter.prototype.filter=function(geom){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.util.LinearComponentExtracter=function(lines,isForcedToLineString){this.lines=lines;this.isForcedToLineString=isForcedToLineString};jsts.geom.util.LinearComponentExtracter.prototype=new jsts.geom.GeometryComponentFilter;jsts.geom.util.LinearComponentExtracter.prototype.lines=null;jsts.geom.util.LinearComponentExtracter.prototype.isForcedToLineString=false;jsts.geom.util.LinearComponentExtracter.getLines=function(geoms,lines){if(arguments.length==1){return jsts.geom.util.LinearComponentExtracter.getLines5.apply(this,arguments)}else if(arguments.length==2&&typeof lines==="boolean"){return jsts.geom.util.LinearComponentExtracter.getLines6.apply(this,arguments)}else if(arguments.length==2&&geoms instanceof jsts.geom.Geometry){return jsts.geom.util.LinearComponentExtracter.getLines3.apply(this,arguments)}else if(arguments.length==3&&geoms instanceof jsts.geom.Geometry){return jsts.geom.util.LinearComponentExtracter.getLines4.apply(this,arguments)}else if(arguments.length==3){return jsts.geom.util.LinearComponentExtracter.getLines2.apply(this,arguments)}for(var i=0;idistance){return false}return DistanceOp.isWithinDistance(this,geom,distance)};jsts.geom.Geometry.prototype.isRectangle=function(){return false};jsts.geom.Geometry.prototype.getArea=function(){return 0};jsts.geom.Geometry.prototype.getLength=function(){return 0};jsts.geom.Geometry.prototype.getCentroid=function(){if(this.isEmpty()){return null}var cent;var centPt=null;var dim=this.getDimension();if(dim===0){cent=new jsts.algorithm.CentroidPoint;cent.add(this);centPt=cent.getCentroid()}else if(dim===1){cent=new jsts.algorithm.CentroidLine;cent.add(this);centPt=cent.getCentroid()}else{cent=new jsts.algorithm.CentroidArea;cent.add(this);centPt=cent.getCentroid()}return this.createPointFromInternalCoord(centPt,this)};jsts.geom.Geometry.prototype.getInteriorPoint=function(){var intPt;var interiorPt=null;var dim=this.getDimension();if(dim===0){intPt=new jsts.algorithm.InteriorPointPoint(this);interiorPt=intPt.getInteriorPoint()}else if(dim===1){intPt=new jsts.algorithm.InteriorPointLine(this);interiorPt=intPt.getInteriorPoint()}else{intPt=new jsts.algorithm.InteriorPointArea(this);interiorPt=intPt.getInteriorPoint()}return this.createPointFromInternalCoord(interiorPt,this)};jsts.geom.Geometry.prototype.getDimension=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.getBoundary=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.getBoundaryDimension=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.getEnvelope=function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())};jsts.geom.Geometry.prototype.getEnvelopeInternal=function(){if(this.envelope===null){this.envelope=this.computeEnvelopeInternal()}return this.envelope};jsts.geom.Geometry.prototype.disjoint=function(g){return!this.intersects(g)};jsts.geom.Geometry.prototype.touches=function(g){if(!this.getEnvelopeInternal().intersects(g.getEnvelopeInternal())){return false}return this.relate(g).isTouches(this.getDimension(),g.getDimension())};jsts.geom.Geometry.prototype.intersects=function(g){if(!this.getEnvelopeInternal().intersects(g.getEnvelopeInternal())){return false}if(this.isRectangle()){return RectangleIntersects.intersects(this,g)}if(g.isRectangle()){return RectangleIntersects.intersects(g,this)}return this.relate(g).isIntersects()};jsts.geom.Geometry.prototype.crosses=function(g){if(!this.getEnvelopeInternal().intersects(g.getEnvelopeInternal())){return false}return this.relate(g).isCrosses(this.getDimension(),g.getDimension())};jsts.geom.Geometry.prototype.within=function(g){return g.contains(this)};jsts.geom.Geometry.prototype.contains=function(g){if(!this.getEnvelopeInternal().contains(g.getEnvelopeInternal())){return false}if(this.isRectangle()){return RectangleContains.contains(this,g)}return this.relate(g).isContains()};jsts.geom.Geometry.prototype.overlaps=function(g){if(!this.getEnvelopeInternal().intersects(g.getEnvelopeInternal())){return false}return this.relate(g).isOverlaps(this.getDimension(),g.getDimension())};jsts.geom.Geometry.prototype.covers=function(g){if(!this.getEnvelopeInternal().covers(g.getEnvelopeInternal())){return false}if(this.isRectangle()){return true}return this.relate(g).isCovers()};jsts.geom.Geometry.prototype.coveredBy=function(g){return g.covers(this)};jsts.geom.Geometry.prototype.relate=function(g,intersectionPattern){if(arguments.length===1){return this.relate2.apply(this,arguments)}return this.relate2(g).matches(intersectionPattern)};jsts.geom.Geometry.prototype.relate2=function(g){this.checkNotGeometryCollection(this);this.checkNotGeometryCollection(g);return jsts.operation.relate.RelateOp.relate(this,g)};jsts.geom.Geometry.prototype.equalsTopo=function(g){if(!this.getEnvelopeInternal().equals(g.getEnvelopeInternal())){return false}return this.relate(g).isEquals(this.getDimension(),g.getDimension())};jsts.geom.Geometry.prototype.equals=function(o){if(o instanceof jsts.geom.Geometry||o instanceof jsts.geom.LinearRing||o instanceof jsts.geom.Polygon||o instanceof jsts.geom.GeometryCollection||o instanceof jsts.geom.MultiPoint||o instanceof jsts.geom.MultiLineString||o instanceof jsts.geom.MultiPolygon){return this.equalsExact(o)}return false};jsts.geom.Geometry.prototype.buffer=function(distance,quadrantSegments,endCapStyle){var params=new jsts.operation.buffer.BufferParameters(quadrantSegments,endCapStyle);return jsts.operation.buffer.BufferOp.bufferOp2(this,distance,params)};jsts.geom.Geometry.prototype.convexHull=function(){return new jsts.algorithm.ConvexHull(this).getConvexHull()};jsts.geom.Geometry.prototype.intersection=function(other){if(this.isEmpty()){return this.getFactory().createGeometryCollection(null)}if(other.isEmpty()){return this.getFactory().createGeometryCollection(null)}if(this.isGeometryCollection(this)){var g2=other}this.checkNotGeometryCollection(this);this.checkNotGeometryCollection(other);return jsts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(this,other,jsts.operation.overlay.OverlayOp.INTERSECTION)};jsts.geom.Geometry.prototype.union=function(other){if(arguments.length===0){return jsts.operation.union.UnaryUnionOp.union(this)}if(this.isEmpty()){return other.clone()}if(other.isEmpty()){return this.clone()}this.checkNotGeometryCollection(this);this.checkNotGeometryCollection(other);return jsts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(this,other,jsts.operation.overlay.OverlayOp.UNION)};jsts.geom.Geometry.prototype.difference=function(other){if(this.isEmpty()){return this.getFactory().createGeometryCollection(null)}if(other.isEmpty()){return this.clone()}this.checkNotGeometryCollection(this);this.checkNotGeometryCollection(other);return jsts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(this,other,jsts.operation.overlay.OverlayOp.DIFFERENCE)};jsts.geom.Geometry.prototype.symDifference=function(other){if(this.isEmpty()){return other.clone()}if(other.isEmpty()){return this.clone()}this.checkNotGeometryCollection(this);this.checkNotGeometryCollection(other);return jsts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(this,other,jsts.operation.overlay.OverlayOp.SYMDIFFERENCE)};jsts.geom.Geometry.prototype.equalsExact=function(other,tolerance){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.equalsNorm=function(g){if(g===null||g===undefined)return false;return this.norm().equalsExact(g.norm())};jsts.geom.Geometry.prototype.apply=function(filter){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.clone=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.normalize=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.norm=function(){var copy=this.clone();copy.normalize();return copy};jsts.geom.Geometry.prototype.compareTo=function(o){var other=o;if(this.getClassSortIndex()!==other.getClassSortIndex()){return this.getClassSortIndex()-other.getClassSortIndex()}if(this.isEmpty()&&other.isEmpty()){return 0}if(this.isEmpty()){return-1}if(other.isEmpty()){return 1}return this.compareToSameClass(o)};jsts.geom.Geometry.prototype.isEquivalentClass=function(other){if(this instanceof jsts.geom.Point&&other instanceof jsts.geom.Point){return true}else if(this instanceof jsts.geom.LineString&&other instanceof jsts.geom.LineString|other instanceof jsts.geom.LinearRing){return true}else if(this instanceof jsts.geom.LinearRing&&other instanceof jsts.geom.LineString|other instanceof jsts.geom.LinearRing){return true}else if(this instanceof jsts.geom.Polygon&&other instanceof jsts.geom.Polygon){return true}else if(this instanceof jsts.geom.MultiPoint&&other instanceof jsts.geom.MultiPoint){return true}else if(this instanceof jsts.geom.MultiLineString&&other instanceof jsts.geom.MultiLineString){return true}else if(this instanceof jsts.geom.MultiPolygon&&other instanceof jsts.geom.MultiPolygon){return true}else if(this instanceof jsts.geom.GeometryCollection&&other instanceof jsts.geom.GeometryCollection){return true}return false};jsts.geom.Geometry.prototype.checkNotGeometryCollection=function(g){if(g.isGeometryCollectionBase()){throw new jsts.error.IllegalArgumentError("This method does not support GeometryCollection")}};jsts.geom.Geometry.prototype.isGeometryCollection=function(){return this instanceof jsts.geom.GeometryCollection};jsts.geom.Geometry.prototype.isGeometryCollectionBase=function(){return this.CLASS_NAME==="jsts.geom.GeometryCollection"};jsts.geom.Geometry.prototype.computeEnvelopeInternal=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.compareToSameClass=function(o){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.compare=function(a,b){var i=a.iterator();var j=b.iterator();while(i.hasNext()&&j.hasNext()){var aElement=i.next();var bElement=j.next();var comparison=aElement.compareTo(bElement);if(comparison!==0){return comparison}}if(i.hasNext()){return 1}if(j.hasNext()){return-1}return 0};jsts.geom.Geometry.prototype.equal=function(a,b,tolerance){if(tolerance===undefined||tolerance===null||tolerance===0){return a.equals(b)}return a.distance(b)<=tolerance};jsts.geom.Geometry.prototype.getClassSortIndex=function(){var sortedClasses=[jsts.geom.Point,jsts.geom.MultiPoint,jsts.geom.LineString,jsts.geom.LinearRing,jsts.geom.MultiLineString,jsts.geom.Polygon,jsts.geom.MultiPolygon,jsts.geom.GeometryCollection];for(var i=0;iother.x){return 1}if(this.yother.y){return 1}return 0};jsts.geom.Coordinate.prototype.toString=function(){return"("+this.x+", "+this.y+")"}})();jsts.geom.Envelope=function(){jsts.geom.Envelope.prototype.init.apply(this,arguments)};jsts.geom.Envelope.prototype.minx=null;jsts.geom.Envelope.prototype.maxx=null;jsts.geom.Envelope.prototype.miny=null;jsts.geom.Envelope.prototype.maxy=null;jsts.geom.Envelope.prototype.init=function(){if(typeof arguments[0]==="number"&&arguments.length===4){this.initFromValues(arguments[0],arguments[1],arguments[2],arguments[3])}else if(arguments[0]instanceof jsts.geom.Coordinate&&arguments.length===1){this.initFromCoordinate(arguments[0])}else if(arguments[0]instanceof jsts.geom.Coordinate&&arguments.length===2){this.initFromCoordinates(arguments[0],arguments[1])}else if(arguments[0]instanceof jsts.geom.Envelope&&arguments.length===1){this.initFromEnvelope(arguments[0])}else{this.setToNull()}};jsts.geom.Envelope.prototype.initFromValues=function(x1,x2,y1,y2){if(x1this.maxx){this.maxx=x}if(ythis.maxy){this.maxy=y}}};jsts.geom.Envelope.prototype.expandToIncludeEnvelope=function(other){if(other.isNull()){return}if(this.isNull()){this.minx=other.getMinX();this.maxx=other.getMaxX();this.miny=other.getMinY();this.maxy=other.getMaxY()}else{if(other.minxthis.maxx){this.maxx=other.maxx}if(other.minythis.maxy){this.maxy=other.maxy}}};jsts.geom.Envelope.prototype.expandBy=function(){if(arguments.length===1){this.expandByDistance(arguments[0])}else{this.expandByDistances(arguments[0],arguments[1])}};jsts.geom.Envelope.prototype.expandByDistance=function(distance){this.expandByDistances(distance,distance)};jsts.geom.Envelope.prototype.expandByDistances=function(deltaX,deltaY){if(this.isNull()){return}this.minx-=deltaX;this.maxx+=deltaX;this.miny-=deltaY;this.maxy+=deltaY;if(this.minx>this.maxx||this.miny>this.maxy){this.setToNull()}};jsts.geom.Envelope.prototype.translate=function(transX,transY){if(this.isNull()){return}this.init(this.minx+transX,this.maxx+transX,this.miny+transY,this.maxy+transY)};jsts.geom.Envelope.prototype.centre=function(){if(this.isNull()){return null}return new jsts.geom.Coordinate((this.minx+this.maxx)/2,(this.miny+this.maxy)/2)};jsts.geom.Envelope.prototype.intersection=function(env){if(this.isNull()||env.isNull()||!this.intersects(env)){return new jsts.geom.Envelope}var intMinX=this.minx>env.minx?this.minx:env.minx;var intMinY=this.miny>env.miny?this.miny:env.miny;var intMaxX=this.maxxthis.maxx||other.maxxthis.maxy||other.maxythis.maxx||xthis.maxy||y=this.minx&&x<=this.maxx&&y>=this.miny&&y<=this.maxy};jsts.geom.Envelope.prototype.coversCoordinate=function(p){return this.coversValues(p.x,p.y)};jsts.geom.Envelope.prototype.coversEnvelope=function(other){if(this.isNull()||other.isNull()){return false}return other.minx>=this.minx&&other.maxx<=this.maxx&&other.miny>=this.miny&&other.maxy<=this.maxy};jsts.geom.Envelope.prototype.distance=function(env){if(this.intersects(env)){return 0}var dx=0;if(this.maxxenv.maxx){dx=this.minx-env.maxx}var dy=0;if(this.maxyenv.maxy){dy=this.miny-env.maxy}if(dx===0){return dy}if(dy===0){return dx}return Math.sqrt(dx*dx+dy*dy)};jsts.geom.Envelope.prototype.equals=function(other){if(this.isNull()){return other.isNull()}return this.maxx===other.maxx&&this.maxy===other.maxy&&this.minx===other.minx&&this.miny===other.miny};jsts.geom.Envelope.prototype.toString=function(){return"Env["+this.minx+" : "+this.maxx+", "+this.miny+" : "+this.maxy+"]"};jsts.geom.Envelope.intersects=function(p1,p2,q){if(arguments.length===4){return jsts.geom.Envelope.intersectsEnvelope(arguments[0],arguments[1],arguments[2],arguments[3])}var xc1=p1.xp2.x?p1.x:p2.x;var yc1=p1.yp2.y?p1.y:p2.y;if(q.x>=xc1&&q.x<=xc2&&(q.y>=yc1&&q.y<=yc2)){return true}return false};jsts.geom.Envelope.intersectsEnvelope=function(p1,p2,q1,q2){var minq=Math.min(q1.x,q2.x);var maxq=Math.max(q1.x,q2.x);var minp=Math.min(p1.x,p2.x);var maxp=Math.max(p1.x,p2.x);if(minp>maxq){return false}if(maxpmaxq){return false}if(maxp1)return this.combine2.apply(this,arguments);var combiner=new jsts.geom.util.GeometryCombiner(geoms);return combiner.combine()};jsts.geom.util.GeometryCombiner.combine2=function(){var arrayList=new javascript.util.ArrayList;Array.prototype.slice.call(arguments).forEach(function(a){arrayList.add(a)});var combiner=new jsts.geom.util.GeometryCombiner(arrayList);return combiner.combine()};jsts.geom.util.GeometryCombiner.prototype.geomFactory=null;jsts.geom.util.GeometryCombiner.prototype.skipEmpty=false;jsts.geom.util.GeometryCombiner.prototype.inputGeoms;jsts.geom.util.GeometryCombiner.extractFactory=function(geoms){if(geoms.isEmpty())return null;return geoms.iterator().next().getFactory()};jsts.geom.util.GeometryCombiner.prototype.combine=function(){var elems=new javascript.util.ArrayList,i;for(i=this.inputGeoms.iterator();i.hasNext();){var g=i.next();this.extractElements(g,elems)}if(elems.size()===0){if(this.geomFactory!==null){return this.geomFactory.createGeometryCollection(null)}return null}return this.geomFactory.buildGeometry(elems)};jsts.geom.util.GeometryCombiner.prototype.extractElements=function(geom,elems){if(geom===null){return}for(var i=0;isegmentIndex)return 1;if(this.distdist)return 1;return 0};jsts.geomgraph.EdgeIntersection.prototype.isEndPoint=function(maxSegmentIndex){if(this.segmentIndex===0&&this.dist===0)return true;if(this.segmentIndex===maxSegmentIndex)return true;return false};jsts.geomgraph.EdgeIntersection.prototype.toString=function(){return""+this.segmentIndex+this.dist};(function(){var EdgeIntersection=jsts.geomgraph.EdgeIntersection;var TreeMap=javascript.util.TreeMap;jsts.geomgraph.EdgeIntersectionList=function(edge){this.nodeMap=new TreeMap;this.edge=edge};jsts.geomgraph.EdgeIntersectionList.prototype.nodeMap=null;jsts.geomgraph.EdgeIntersectionList.prototype.edge=null;jsts.geomgraph.EdgeIntersectionList.prototype.isIntersection=function(pt){for(var it=this.iterator();it.hasNext();){var ei=it.next();if(ei.coord.equals(pt)){return true}}return false};jsts.geomgraph.EdgeIntersectionList.prototype.add=function(intPt,segmentIndex,dist){var eiNew=new EdgeIntersection(intPt,segmentIndex,dist);var ei=this.nodeMap.get(eiNew);if(ei!==null){return ei}this.nodeMap.put(eiNew,eiNew);return eiNew};jsts.geomgraph.EdgeIntersectionList.prototype.iterator=function(){return this.nodeMap.values().iterator()};jsts.geomgraph.EdgeIntersectionList.prototype.addEndpoints=function(){var maxSegIndex=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0);this.add(this.edge.pts[maxSegIndex],maxSegIndex,0)};jsts.geomgraph.EdgeIntersectionList.prototype.addSplitEdges=function(edgeList){this.addEndpoints();var it=this.iterator();var eiPrev=it.next();while(it.hasNext()){var ei=it.next();var newEdge=this.createSplitEdge(eiPrev,ei);edgeList.add(newEdge);eiPrev=ei}};jsts.geomgraph.EdgeIntersectionList.prototype.createSplitEdge=function(ei0,ei1){var npts=ei1.segmentIndex-ei0.segmentIndex+2;var lastSegStartPt=this.edge.pts[ei1.segmentIndex];var useIntPt1=ei1.dist>0||!ei1.coord.equals2D(lastSegStartPt);if(!useIntPt1){npts--}var pts=[];var ipt=0;pts[ipt++]=new jsts.geom.Coordinate(ei0.coord);for(var i=ei0.segmentIndex+1;i<=ei1.segmentIndex;i++){pts[ipt++]=this.edge.pts[i]}if(useIntPt1)pts[ipt]=ei1.coord;return new jsts.geomgraph.Edge(pts,new jsts.geomgraph.Label(this.edge.label))}})();(function(){var AssertionFailedException=function(message){this.message=message};AssertionFailedException.prototype=new Error;AssertionFailedException.prototype.name="AssertionFailedException";jsts.util.AssertionFailedException=AssertionFailedException})();(function(){var AssertionFailedException=jsts.util.AssertionFailedException;jsts.util.Assert=function(){};jsts.util.Assert.isTrue=function(assertion,message){if(!assertion){if(message===null){throw new AssertionFailedException}else{throw new AssertionFailedException(message)}}};jsts.util.Assert.equals=function(expectedValue,actualValue,message){if(!actualValue.equals(expectedValue)){throw new AssertionFailedException("Expected "+expectedValue+" but encountered "+actualValue+(message!=null?": "+message:""))}};jsts.util.Assert.shouldNeverReachHere=function(message){throw new AssertionFailedException("Should never reach here"+(message!=null?": "+message:""))}})();(function(){var Location=jsts.geom.Location;var Assert=jsts.util.Assert;var ArrayList=javascript.util.ArrayList;jsts.operation.relate.RelateComputer=function(arg){this.li=new jsts.algorithm.RobustLineIntersector;this.ptLocator=new jsts.algorithm.PointLocator;this.nodes=new jsts.geomgraph.NodeMap(new jsts.operation.relate.RelateNodeFactory);this.isolatedEdges=new ArrayList;this.arg=arg};jsts.operation.relate.RelateComputer.prototype.li=null;jsts.operation.relate.RelateComputer.prototype.ptLocator=null;jsts.operation.relate.RelateComputer.prototype.arg=null;jsts.operation.relate.RelateComputer.prototype.nodes=null;jsts.operation.relate.RelateComputer.prototype.im=null;jsts.operation.relate.RelateComputer.prototype.isolatedEdges=null;jsts.operation.relate.RelateComputer.prototype.invalidPoint=null;jsts.operation.relate.RelateComputer.prototype.computeIM=function(){var im=new jsts.geom.IntersectionMatrix;im.set(Location.EXTERIOR,Location.EXTERIOR,2);if(!this.arg[0].getGeometry().getEnvelopeInternal().intersects(this.arg[1].getGeometry().getEnvelopeInternal())){this.computeDisjointIM(im);return im}this.arg[0].computeSelfNodes(this.li,false);this.arg[1].computeSelfNodes(this.li,false);var intersector=this.arg[0].computeEdgeIntersections(this.arg[1],this.li,false);this.computeIntersectionNodes(0);this.computeIntersectionNodes(1);this.copyNodesAndLabels(0);this.copyNodesAndLabels(1);this.labelIsolatedNodes();this.computeProperIntersectionIM(intersector,im);var eeBuilder=new jsts.operation.relate.EdgeEndBuilder;var ee0=eeBuilder.computeEdgeEnds(this.arg[0].getEdgeIterator());this.insertEdgeEnds(ee0);var ee1=eeBuilder.computeEdgeEnds(this.arg[1].getEdgeIterator());this.insertEdgeEnds(ee1);this.labelNodeEdges();this.labelIsolatedEdges(0,1);this.labelIsolatedEdges(1,0);this.updateIM(im);return im};jsts.operation.relate.RelateComputer.prototype.insertEdgeEnds=function(ee){for(var i=ee.iterator();i.hasNext();){var e=i.next();this.nodes.add(e)}};jsts.operation.relate.RelateComputer.prototype.computeProperIntersectionIM=function(intersector,im){var dimA=this.arg[0].getGeometry().getDimension();var dimB=this.arg[1].getGeometry().getDimension();var hasProper=intersector.hasProperIntersection();var hasProperInterior=intersector.hasProperInteriorIntersection();if(dimA===2&&dimB===2){if(hasProper)im.setAtLeast("212101212")}else if(dimA===2&&dimB===1){if(hasProper)im.setAtLeast("FFF0FFFF2");if(hasProperInterior)im.setAtLeast("1FFFFF1FF")}else if(dimA===1&&dimB===2){if(hasProper)im.setAtLeast("F0FFFFFF2");if(hasProperInterior)im.setAtLeast("1F1FFFFFF")}else if(dimA===1&&dimB===1){if(hasProperInterior)im.setAtLeast("0FFFFFFFF")}};jsts.operation.relate.RelateComputer.prototype.copyNodesAndLabels=function(argIndex){for(var i=this.arg[argIndex].getNodeIterator();i.hasNext();){var graphNode=i.next();var newNode=this.nodes.addNode(graphNode.getCoordinate());newNode.setLabel(argIndex,graphNode.getLabel().getLocation(argIndex))}};jsts.operation.relate.RelateComputer.prototype.computeIntersectionNodes=function(argIndex){for(var i=this.arg[argIndex].getEdgeIterator();i.hasNext();){var e=i.next();var eLoc=e.getLabel().getLocation(argIndex);for(var eiIt=e.getEdgeIntersectionList().iterator();eiIt.hasNext();){var ei=eiIt.next();var n=this.nodes.addNode(ei.coord);if(eLoc===Location.BOUNDARY)n.setLabelBoundary(argIndex);else{if(n.getLabel().isNull(argIndex))n.setLabel(argIndex,Location.INTERIOR)}}}};jsts.operation.relate.RelateComputer.prototype.labelIntersectionNodes=function(argIndex){for(var i=this.arg[argIndex].getEdgeIterator();i.hasNext();){var e=i.next();var eLoc=e.getLabel().getLocation(argIndex);for(var eiIt=e.getEdgeIntersectionList().iterator();eiIt.hasNext();){var ei=eiIt.next();var n=this.nodes.find(ei.coord);if(n.getLabel().isNull(argIndex)){if(eLoc===Location.BOUNDARY)n.setLabelBoundary(argIndex);else n.setLabel(argIndex,Location.INTERIOR)}}}};jsts.operation.relate.RelateComputer.prototype.computeDisjointIM=function(im){var ga=this.arg[0].getGeometry();if(!ga.isEmpty()){im.set(Location.INTERIOR,Location.EXTERIOR,ga.getDimension());im.set(Location.BOUNDARY,Location.EXTERIOR,ga.getBoundaryDimension())}var gb=this.arg[1].getGeometry();if(!gb.isEmpty()){im.set(Location.EXTERIOR,Location.INTERIOR,gb.getDimension());im.set(Location.EXTERIOR,Location.BOUNDARY,gb.getBoundaryDimension())}};jsts.operation.relate.RelateComputer.prototype.labelNodeEdges=function(){for(var ni=this.nodes.iterator();ni.hasNext();){var node=ni.next();node.getEdges().computeLabelling(this.arg)}};jsts.operation.relate.RelateComputer.prototype.updateIM=function(im){for(var ei=this.isolatedEdges.iterator();ei.hasNext();){var e=ei.next();e.updateIM(im)}for(var ni=this.nodes.iterator();ni.hasNext();){var node=ni.next();node.updateIM(im);node.updateIMFromEdges(im)}};jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdges=function(thisIndex,targetIndex){for(var ei=this.arg[thisIndex].getEdgeIterator();ei.hasNext();){var e=ei.next();if(e.isIsolated()){this.labelIsolatedEdge(e,targetIndex,this.arg[targetIndex].getGeometry());this.isolatedEdges.add(e)}}};jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdge=function(e,targetIndex,target){if(target.getDimension()>0){var loc=this.ptLocator.locate(e.getCoordinate(),target);e.getLabel().setAllLocations(targetIndex,loc)}else{e.getLabel().setAllLocations(targetIndex,Location.EXTERIOR)}};jsts.operation.relate.RelateComputer.prototype.labelIsolatedNodes=function(){for(var ni=this.nodes.iterator();ni.hasNext();){var n=ni.next();var label=n.getLabel();Assert.isTrue(label.getGeometryCount()>0,"node with empty label found");if(n.isIsolated()){if(label.isNull(0))this.labelIsolatedNode(n,0);else this.labelIsolatedNode(n,1)}}};jsts.operation.relate.RelateComputer.prototype.labelIsolatedNode=function(n,targetIndex){var loc=this.ptLocator.locate(n.getCoordinate(),this.arg[targetIndex].getGeometry());n.getLabel().setAllLocations(targetIndex,loc)}})();(function(){var Assert=jsts.util.Assert;jsts.geomgraph.GraphComponent=function(label){this.label=label};jsts.geomgraph.GraphComponent.prototype.label=null;jsts.geomgraph.GraphComponent.prototype._isInResult=false;jsts.geomgraph.GraphComponent.prototype._isCovered=false;jsts.geomgraph.GraphComponent.prototype._isCoveredSet=false;jsts.geomgraph.GraphComponent.prototype._isVisited=false;jsts.geomgraph.GraphComponent.prototype.getLabel=function(){return this.label};jsts.geomgraph.GraphComponent.prototype.setLabel=function(label){if(arguments.length===2){this.setLabel2.apply(this,arguments);return}this.label=label};jsts.geomgraph.GraphComponent.prototype.setInResult=function(isInResult){this._isInResult=isInResult};jsts.geomgraph.GraphComponent.prototype.isInResult=function(){return this._isInResult};jsts.geomgraph.GraphComponent.prototype.setCovered=function(isCovered){this._isCovered=isCovered;this._isCoveredSet=true};jsts.geomgraph.GraphComponent.prototype.isCovered=function(){return this._isCovered};jsts.geomgraph.GraphComponent.prototype.isCoveredSet=function(){return this._isCoveredSet};jsts.geomgraph.GraphComponent.prototype.isVisited=function(){return this._isVisited};jsts.geomgraph.GraphComponent.prototype.setVisited=function(isVisited){this._isVisited=isVisited};jsts.geomgraph.GraphComponent.prototype.getCoordinate=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.GraphComponent.prototype.computeIM=function(im){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.GraphComponent.prototype.isIsolated=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.GraphComponent.prototype.updateIM=function(im){Assert.isTrue(this.label.getGeometryCount()>=2,"found partial label");this.computeIM(im)}})();jsts.geomgraph.Node=function(coord,edges){this.coord=coord;this.edges=edges;this.label=new jsts.geomgraph.Label(0,jsts.geom.Location.NONE)};jsts.geomgraph.Node.prototype=new jsts.geomgraph.GraphComponent;jsts.geomgraph.Node.prototype.coord=null;jsts.geomgraph.Node.prototype.edges=null;jsts.geomgraph.Node.prototype.isIsolated=function(){return this.label.getGeometryCount()==1};jsts.geomgraph.Node.prototype.setLabel2=function(argIndex,onLocation){if(this.label===null){this.label=new jsts.geomgraph.Label(argIndex,onLocation)}else this.label.setLocation(argIndex,onLocation)};jsts.geomgraph.Node.prototype.setLabelBoundary=function(argIndex){var loc=jsts.geom.Location.NONE;if(this.label!==null)loc=this.label.getLocation(argIndex);var newLoc;switch(loc){case jsts.geom.Location.BOUNDARY:newLoc=jsts.geom.Location.INTERIOR;break;case jsts.geom.Location.INTERIOR:newLoc=jsts.geom.Location.BOUNDARY;break;default:newLoc=jsts.geom.Location.BOUNDARY;break}this.label.setLocation(argIndex,newLoc)};jsts.geomgraph.Node.prototype.add=function(e){this.edges.insert(e);e.setNode(this)};jsts.geomgraph.Node.prototype.getCoordinate=function(){return this.coord};jsts.geomgraph.Node.prototype.getEdges=function(){return this.edges};jsts.geomgraph.Node.prototype.isIncidentEdgeInResult=function(){for(var it=this.getEdges().getEdges().iterator();it.hasNext();){var de=it.next();if(de.getEdge().isInResult())return true}return false};jsts.geom.Dimension=function(){};jsts.geom.Dimension.P=0;jsts.geom.Dimension.L=1;jsts.geom.Dimension.A=2;jsts.geom.Dimension.FALSE=-1;jsts.geom.Dimension.TRUE=-2;jsts.geom.Dimension.DONTCARE=-3;jsts.geom.Dimension.toDimensionSymbol=function(dimensionValue){switch(dimensionValue){case jsts.geom.Dimension.FALSE:return"F";case jsts.geom.Dimension.TRUE:return"T";case jsts.geom.Dimension.DONTCARE:return"*";case jsts.geom.Dimension.P:return"0";case jsts.geom.Dimension.L:return"1";case jsts.geom.Dimension.A:return"2"}throw new jsts.IllegalArgumentError("Unknown dimension value: "+dimensionValue)};jsts.geom.Dimension.toDimensionValue=function(dimensionSymbol){switch(dimensionSymbol.toUpperCase()){case"F":return jsts.geom.Dimension.FALSE;case"T":return jsts.geom.Dimension.TRUE;case"*":return jsts.geom.Dimension.DONTCARE;case"0":return jsts.geom.Dimension.P;case"1":return jsts.geom.Dimension.L;case"2":return jsts.geom.Dimension.A}throw new jsts.error.IllegalArgumentError("Unknown dimension symbol: "+dimensionSymbol)};(function(){var Dimension=jsts.geom.Dimension;jsts.geom.LineString=function(points,factory){this.factory=factory;this.points=points||[]};jsts.geom.LineString.prototype=new jsts.geom.Geometry;jsts.geom.LineString.constructor=jsts.geom.LineString;jsts.geom.LineString.prototype.points=null;jsts.geom.LineString.prototype.getCoordinates=function(){return this.points};jsts.geom.LineString.prototype.getCoordinateSequence=function(){return this.points};jsts.geom.LineString.prototype.getCoordinateN=function(n){return this.points[n]};jsts.geom.LineString.prototype.getCoordinate=function(){if(this.isEmpty()){return null}return this.getCoordinateN(0)};jsts.geom.LineString.prototype.getDimension=function(){return 1};jsts.geom.LineString.prototype.getBoundaryDimension=function(){if(this.isClosed()){return Dimension.FALSE}return 0};jsts.geom.LineString.prototype.isEmpty=function(){return this.points.length===0};jsts.geom.LineString.prototype.getNumPoints=function(){return this.points.length};jsts.geom.LineString.prototype.getPointN=function(n){return this.getFactory().createPoint(this.points[n])};jsts.geom.LineString.prototype.getStartPoint=function(){if(this.isEmpty()){return null}return this.getPointN(0)};jsts.geom.LineString.prototype.getEndPoint=function(){if(this.isEmpty()){return null}return this.getPointN(this.getNumPoints()-1)};jsts.geom.LineString.prototype.isClosed=function(){if(this.isEmpty()){return false}return this.getCoordinateN(0).equals2D(this.getCoordinateN(this.points.length-1))};jsts.geom.LineString.prototype.isRing=function(){return this.isClosed()&&this.isSimple()};jsts.geom.LineString.prototype.getGeometryType=function(){return"LineString"};jsts.geom.LineString.prototype.getLength=function(){return jsts.algorithm.CGAlgorithms.computeLength(this.points)};jsts.geom.LineString.prototype.getBoundary=function(){return new jsts.operation.BoundaryOp(this).getBoundary()};jsts.geom.LineString.prototype.computeEnvelopeInternal=function(){if(this.isEmpty()){return new jsts.geom.Envelope}var env=new jsts.geom.Envelope;this.points.forEach(function(component){env.expandToInclude(component)});return env};jsts.geom.LineString.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}if(this.points.length!==other.points.length){return false}if(this.isEmpty()&&other.isEmpty()){return true}return this.points.reduce(function(equal,point,i){return equal&&jsts.geom.Geometry.prototype.equal(point,other.points[i],tolerance)})};jsts.geom.LineString.prototype.isEquivalentClass=function(other){return other instanceof jsts.geom.LineString};jsts.geom.LineString.prototype.compareToSameClass=function(o){var line=o;var i=0,il=this.points.length;var j=0,jl=line.points.length;while(i0){this.points.reverse()}return}}};jsts.geom.LineString.prototype.CLASS_NAME="jsts.geom.LineString"})();(function(){jsts.geom.Polygon=function(shell,holes,factory){this.shell=shell||factory.createLinearRing(null);this.holes=holes||[];this.factory=factory};jsts.geom.Polygon.prototype=new jsts.geom.Geometry;jsts.geom.Polygon.constructor=jsts.geom.Polygon;jsts.geom.Polygon.prototype.getCoordinate=function(){return this.shell.getCoordinate()};jsts.geom.Polygon.prototype.getCoordinates=function(){if(this.isEmpty()){return[]}var coordinates=[];var k=-1;var shellCoordinates=this.shell.getCoordinates();for(var x=0;x0){cent.x=this.cg3.x/3/this.areasum2;cent.y=this.cg3.y/3/this.areasum2}else if(this.totalLength>0){cent.x=this.lineCentSum.x/this.totalLength;cent.y=this.lineCentSum.y/this.totalLength}else if(this.ptCount>0){cent.x=this.ptCentSum.x/this.ptCount; cent.y=this.ptCentSum.y/this.ptCount}else{return null}return cent};jsts.algorithm.Centroid.prototype.setBasePoint=function(basePt){if(this.areaBasePt===null){this.areaBasePt=basePt}};jsts.algorithm.Centroid.prototype.addPolygon=function(poly){this.addShell(poly.getExteriorRing().getCoordinates());for(var i=0;i0){this.setBasePoint(pts[0])}var isPositiveArea=!jsts.algorithm.CGAlgorithms.isCCW(pts);for(var i=0;i0){this.addPoint(pts[0])}};jsts.algorithm.Centroid.prototype.addPoint=function(pt){this.ptCount+=1;this.ptCentSum.x+=pt.x;this.ptCentSum.y+=pt.y};(function(){var EdgeRing=function(factory){this.deList=new javascript.util.ArrayList;this.factory=factory};EdgeRing.findEdgeRingContaining=function(testEr,shellList){var testRing=testEr.getRing();var testEnv=testRing.getEnvelopeInternal();var testPt=testRing.getCoordinateN(0);var minShell=null;var minEnv=null;for(var it=shellList.iterator();it.hasNext();){var tryShell=it.next();var tryRing=tryShell.getRing();var tryEnv=tryRing.getEnvelopeInternal();if(minShell!=null)minEnv=minShell.getRing().getEnvelopeInternal();var isContained=false;if(tryEnv.equals(testEnv))continue;testPt=jsts.geom.CoordinateArrays.ptNotInList(testRing.getCoordinates(),tryRing.getCoordinates());if(tryEnv.contains(testEnv)&&jsts.algorithm.CGAlgorithms.isPointInRing(testPt,tryRing.getCoordinates()))isContained=true;if(isContained){if(minShell==null||minEnv.contains(tryEnv)){minShell=tryShell}}}return minShell};EdgeRing.ptNotInList=function(testPts,pts){for(var i=0;i=0;i--){coordList.add(coords[i],false)}}};jsts.operation.polygonize.EdgeRing=EdgeRing})();(function(){var GraphComponent=function(){};GraphComponent.setVisited=function(i,visited){while(i.hasNext()){var comp=i.next();comp.setVisited(visited)}};GraphComponent.setMarked=function(i,marked){while(i.hasNext()){var comp=i.next();comp.setMarked(marked)}};GraphComponent.getComponentWithVisitedState=function(i,visitedState){while(i.hasNext()){var comp=i.next();if(comp.isVisited()==visitedState)return comp}return null};GraphComponent.prototype._isMarked=false;GraphComponent.prototype._isVisited=false;GraphComponent.prototype.data;GraphComponent.prototype.isVisited=function(){return this._isVisited};GraphComponent.prototype.setVisited=function(isVisited){this._isVisited=isVisited};GraphComponent.prototype.isMarked=function(){return this._isMarked};GraphComponent.prototype.setMarked=function(isMarked){this._isMarked=isMarked};GraphComponent.prototype.setContext=function(data){this.data=data};GraphComponent.prototype.getContext=function(){return data};GraphComponent.prototype.setData=function(data){this.data=data};GraphComponent.prototype.getData=function(){return data};GraphComponent.prototype.isRemoved=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.planargraph.GraphComponent=GraphComponent})();(function(){var GraphComponent=jsts.planargraph.GraphComponent;var Edge=function(de0,de1){if(de0===undefined){return}this.setDirectedEdges(de0,de1)};Edge.prototype=new GraphComponent;Edge.prototype.dirEdge=null;Edge.prototype.setDirectedEdges=function(de0,de1){this.dirEdge=[de0,de1];de0.setEdge(this);de1.setEdge(this);de0.setSym(de1);de1.setSym(de0);de0.getFromNode().addOutEdge(de0);de1.getFromNode().addOutEdge(de1)};Edge.prototype.getDirEdge=function(i){if(i instanceof jsts.planargraph.Node){this.getDirEdge2(i)}return this.dirEdge[i]};Edge.prototype.getDirEdge2=function(fromNode){if(this.dirEdge[0].getFromNode()==fromNode)return this.dirEdge[0];if(this.dirEdge[1].getFromNode()==fromNode)return this.dirEdge[1];return null};Edge.prototype.getOppositeNode=function(node){if(this.dirEdge[0].getFromNode()==node)return this.dirEdge[0].getToNode();if(this.dirEdge[1].getFromNode()==node)return this.dirEdge[1].getToNode();return null};Edge.prototype.remove=function(){this.dirEdge=null};Edge.prototype.isRemoved=function(){return dirEdge==null};jsts.planargraph.Edge=Edge})();jsts.operation.polygonize.PolygonizeEdge=function(line){this.line=line};jsts.operation.polygonize.PolygonizeEdge.prototype=new jsts.planargraph.Edge;jsts.operation.polygonize.PolygonizeEdge.prototype.line=null;jsts.operation.polygonize.PolygonizeEdge.prototype.getLine=function(){return this.line};(function(){var ArrayList=javascript.util.ArrayList;var GraphComponent=jsts.planargraph.GraphComponent;var DirectedEdge=function(from,to,directionPt,edgeDirection){if(from===undefined){return}this.from=from;this.to=to;this.edgeDirection=edgeDirection;this.p0=from.getCoordinate();this.p1=directionPt;var dx=this.p1.x-this.p0.x;var dy=this.p1.y-this.p0.y;this.quadrant=jsts.geomgraph.Quadrant.quadrant(dx,dy);this.angle=Math.atan2(dy,dx)};DirectedEdge.prototype=new GraphComponent;DirectedEdge.toEdges=function(dirEdges){var edges=new ArrayList;for(var i=dirEdges.iterator();i.hasNext();){edges.add(i.next().parentEdge)}return edges};DirectedEdge.prototype.parentEdge=null;DirectedEdge.prototype.from=null;DirectedEdge.prototype.to=null;DirectedEdge.prototype.p0=null;DirectedEdge.prototype.p1=null;DirectedEdge.prototype.sym=null;DirectedEdge.prototype.edgeDirection=null;DirectedEdge.prototype.quadrant=null;DirectedEdge.prototype.angle=null;DirectedEdge.prototype.getEdge=function(){return this.parentEdge};DirectedEdge.prototype.setEdge=function(parentEdge){this.parentEdge=parentEdge};DirectedEdge.prototype.getQuadrant=function(){return this.quadrant};DirectedEdge.prototype.getDirectionPt=function(){return this.p1};DirectedEdge.prototype.getEdgeDirection=function(){return this.edgeDirection};DirectedEdge.prototype.getFromNode=function(){return this.from};DirectedEdge.prototype.getToNode=function(){return this.to};DirectedEdge.prototype.getCoordinate=function(){return this.from.getCoordinate()};DirectedEdge.prototype.getAngle=function(){return this.angle};DirectedEdge.prototype.getSym=function(){return this.sym};DirectedEdge.prototype.setSym=function(sym){this.sym=sym};DirectedEdge.prototype.remove=function(){this.sym=null;this.parentEdge=null};DirectedEdge.prototype.isRemoved=function(){return this.parentEdge==null};DirectedEdge.prototype.compareTo=function(obj){var de=obj;return this.compareDirection(de)};DirectedEdge.prototype.compareDirection=function(e){if(this.quadrant>e.quadrant)return 1;if(this.quadrant1){if(intNodes==null)intNodes=new ArrayList;intNodes.add(node)}de=de.getNext();Assert.isTrue(de!=null,"found null DE in ring");Assert.isTrue(de==startDE||!de.isInRing(),"found DE already in ring")}while(de!=startDE);return intNodes};PolygonizeGraph.prototype.getEdgeRings=function(){this.computeNextCWEdges();PolygonizeGraph.label(this.dirEdges,-1);var maximalRings=PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);this.convertMaximalToMinimalEdgeRings(maximalRings);var edgeRingList=new ArrayList;for(var i=this.dirEdges.iterator();i.hasNext();){var de=i.next();if(de.isMarked())continue;if(de.isInRing())continue;var er=this.findEdgeRing(de);edgeRingList.add(er)}return edgeRingList};PolygonizeGraph.findLabeledEdgeRings=function(dirEdges){var edgeRingStarts=new ArrayList;var currLabel=1;for(var i=dirEdges.iterator();i.hasNext();){var de=i.next();if(de.isMarked())continue;if(de.getLabel()>=0)continue;edgeRingStarts.add(de);var edges=PolygonizeGraph.findDirEdgesInRing(de);PolygonizeGraph.label(edges,currLabel);currLabel++}return edgeRingStarts};PolygonizeGraph.prototype.deleteCutEdges=function(){this.computeNextCWEdges();PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);var cutLines=new ArrayList;for(var i=this.dirEdges.iterator();i.hasNext();){var de=i.next();if(de.isMarked())continue;var sym=de.getSym();if(de.getLabel()==sym.getLabel()){de.setMarked(true);sym.setMarked(true);var e=de.getEdge();cutLines.add(e.getLine())}}return cutLines};PolygonizeGraph.label=function(dirEdges,label){for(var i=dirEdges.iterator();i.hasNext();){var de=i.next();de.setLabel(label)}};PolygonizeGraph.computeNextCWEdges=function(node){var deStar=node.getOutEdges();var startDE=null;var prevDE=null;for(var i=deStar.getEdges().iterator();i.hasNext();){var outDE=i.next();if(outDE.isMarked())continue;if(startDE==null)startDE=outDE;if(prevDE!=null){var sym=prevDE.getSym();sym.setNext(outDE)}prevDE=outDE}if(prevDE!=null){var sym=prevDE.getSym();sym.setNext(startDE)}};PolygonizeGraph.computeNextCCWEdges=function(node,label){var deStar=node.getOutEdges();var firstOutDE=null;var prevInDE=null;var edges=deStar.getEdges();for(var i=edges.size()-1;i>=0;i--){var de=edges.get(i);var sym=de.getSym();var outDE=null;if(de.getLabel()==label)outDE=de;var inDE=null;if(sym.getLabel()==label)inDE=sym;if(outDE==null&&inDE==null)continue;if(inDE!=null){prevInDE=inDE}if(outDE!=null){if(prevInDE!=null){prevInDE.setNext(outDE);prevInDE=null}if(firstOutDE==null)firstOutDE=outDE}}if(prevInDE!=null){Assert.isTrue(firstOutDE!=null);prevInDE.setNext(firstOutDE)}};PolygonizeGraph.findDirEdgesInRing=function(startDE){var de=startDE;var edges=new ArrayList;do{edges.add(de);de=de.getNext();Assert.isTrue(de!=null,"found null DE in ring");Assert.isTrue(de==startDE||!de.isInRing(),"found DE already in ring")}while(de!=startDE);return edges};PolygonizeGraph.prototype.findEdgeRing=function(startDE){var de=startDE;var er=new EdgeRing(this.factory);do{er.add(de);de.setRing(er);de=de.getNext();Assert.isTrue(de!=null,"found null DE in ring");Assert.isTrue(de==startDE||!de.isInRing(),"found DE already in ring")}while(de!=startDE);return er};PolygonizeGraph.prototype.deleteDangles=function(){var nodesToRemove=this.findNodesOfDegree(1);var dangleLines=new HashSet;var nodeStack=new Stack;for(var i=nodesToRemove.iterator();i.hasNext();){nodeStack.push(i.next())}while(!nodeStack.isEmpty()){var node=nodeStack.pop();PolygonizeGraph.deleteAllEdges(node);var nodeOutEdges=node.getOutEdges().getEdges();for(var i=nodeOutEdges.iterator();i.hasNext();){var de=i.next();de.setMarked(true);var sym=de.getSym();if(sym!=null)sym.setMarked(true);var e=de.getEdge();dangleLines.add(e.getLine());var toNode=de.getToNode();if(PolygonizeGraph.getDegreeNonDeleted(toNode)==1)nodeStack.push(toNode)}}return dangleLines};PolygonizeGraph.prototype.computeDepthParity=function(){while(true){var de=null;if(de==null)return;this.computeDepthParity(de)}};PolygonizeGraph.prototype.computeDepthParity=function(de){};jsts.operation.polygonize.PolygonizeGraph=PolygonizeGraph})();jsts.index.strtree.Interval=function(){var other;if(arguments.length===1){other=arguments[0];return jsts.index.strtree.Interval(other.min,other.max)}else if(arguments.length===2){jsts.util.Assert.isTrue(this.min<=this.max);this.min=arguments[0];this.max=arguments[1]}};jsts.index.strtree.Interval.prototype.min=null;jsts.index.strtree.Interval.prototype.max=null;jsts.index.strtree.Interval.prototype.getCentre=function(){return(this.min+this.max)/2};jsts.index.strtree.Interval.prototype.expandToInclude=function(other){this.max=Math.max(this.max,other.max);this.min=Math.min(this.min,other.min);return this};jsts.index.strtree.Interval.prototype.intersects=function(other){return!(other.min>this.max||other.max1;if(isCollection){if(geom0 instanceof jsts.geom.Polygon){return this.createMultiPolygon(geomList.toArray())}else if(geom0 instanceof jsts.geom.LineString){return this.createMultiLineString(geomList.toArray())}else if(geom0 instanceof jsts.geom.Point){return this.createMultiPoint(geomList.toArray())}jsts.util.Assert.shouldNeverReachHere("Unhandled class: "+geom0)}return geom0};jsts.geom.GeometryFactory.prototype.createGeometryCollection=function(geometries){return new jsts.geom.GeometryCollection(geometries,this)};jsts.geom.GeometryFactory.prototype.toGeometry=function(envelope){if(envelope.isNull()){return this.createPoint(null)}if(envelope.getMinX()===envelope.getMaxX()&&envelope.getMinY()===envelope.getMaxY()){return this.createPoint(new jsts.geom.Coordinate(envelope.getMinX(),envelope.getMinY()))}if(envelope.getMinX()===envelope.getMaxX()||envelope.getMinY()===envelope.getMaxY()){return this.createLineString([new jsts.geom.Coordinate(envelope.getMinX(),envelope.getMinY()),new jsts.geom.Coordinate(envelope.getMaxX(),envelope.getMaxY())])}return this.createPolygon(this.createLinearRing([new jsts.geom.Coordinate(envelope.getMinX(),envelope.getMinY()),new jsts.geom.Coordinate(envelope.getMinX(),envelope.getMaxY()),new jsts.geom.Coordinate(envelope.getMaxX(),envelope.getMaxY()),new jsts.geom.Coordinate(envelope.getMaxX(),envelope.getMinY()),new jsts.geom.Coordinate(envelope.getMinX(),envelope.getMinY())]),null)};jsts.geomgraph.NodeFactory=function(){};jsts.geomgraph.NodeFactory.prototype.createNode=function(coord){return new jsts.geomgraph.Node(coord,null)};(function(){jsts.geomgraph.Position=function(){};jsts.geomgraph.Position.ON=0;jsts.geomgraph.Position.LEFT=1;jsts.geomgraph.Position.RIGHT=2;jsts.geomgraph.Position.opposite=function(position){if(position===jsts.geomgraph.Position.LEFT){return jsts.geomgraph.Position.RIGHT}if(position===jsts.geomgraph.Position.RIGHT){return jsts.geomgraph.Position.LEFT}return position}})();jsts.geomgraph.TopologyLocation=function(){this.location=[];if(arguments.length===3){var on=arguments[0];var left=arguments[1];var right=arguments[2];this.init(3);this.location[jsts.geomgraph.Position.ON]=on;this.location[jsts.geomgraph.Position.LEFT]=left;this.location[jsts.geomgraph.Position.RIGHT]=right}else if(arguments[0]instanceof jsts.geomgraph.TopologyLocation){var gl=arguments[0];this.init(gl.location.length);if(gl!=null){for(var i=0;i1};jsts.geomgraph.TopologyLocation.prototype.isLine=function(){return this.location.length===1};jsts.geomgraph.TopologyLocation.prototype.flip=function(){if(this.location.length<=1)return;var temp=this.location[jsts.geomgraph.Position.LEFT];this.location[jsts.geomgraph.Position.LEFT]=this.location[jsts.geomgraph.Position.RIGHT];this.location[jsts.geomgraph.Position.RIGHT]=temp};jsts.geomgraph.TopologyLocation.prototype.setAllLocations=function(locValue){for(var i=0;ithis.location.length){var newLoc=[];newLoc[jsts.geomgraph.Position.ON]=this.location[jsts.geomgraph.Position.ON];newLoc[jsts.geomgraph.Position.LEFT]=jsts.geom.Location.NONE;newLoc[jsts.geomgraph.Position.RIGHT]=jsts.geom.Location.NONE;this.location=newLoc}for(var i=0;ithis.maxNodeDegree)this.maxNodeDegree=degree;de=this.getNext(de)}while(de!==this.startDe);this.maxNodeDegree*=2};jsts.geomgraph.EdgeRing.prototype.setInResult=function(){var de=this.startDe;do{de.getEdge().setInResult(true);de=de.getNext()}while(de!=this.startDe)};jsts.geomgraph.EdgeRing.prototype.mergeLabel=function(deLabel){this.mergeLabel2(deLabel,0);this.mergeLabel2(deLabel,1)};jsts.geomgraph.EdgeRing.prototype.mergeLabel2=function(deLabel,geomIndex){var loc=deLabel.getLocation(geomIndex,jsts.geomgraph.Position.RIGHT);if(loc==jsts.geom.Location.NONE)return;if(this.label.getLocation(geomIndex)===jsts.geom.Location.NONE){this.label.setLocation(geomIndex,loc);return}};jsts.geomgraph.EdgeRing.prototype.addPoints=function(edge,isForward,isFirstEdge){var edgePts=edge.getCoordinates();if(isForward){var startIndex=1;if(isFirstEdge)startIndex=0;for(var i=startIndex;i=0;i--){this.pts.push(edgePts[i])}}};jsts.geomgraph.EdgeRing.prototype.containsPoint=function(p){var shell=this.getLinearRing();var env=shell.getEnvelopeInternal();if(!env.contains(p))return false;if(!jsts.algorithm.CGAlgorithms.isPointInRing(p,shell.getCoordinates()))return false;for(var i=0;i1,"Node capacity must be greater than 1");this.nodeCapacity=nodeCapacity};jsts.index.strtree.AbstractSTRtree.IntersectsOp=function(){};jsts.index.strtree.AbstractSTRtree.IntersectsOp.prototype.intersects=function(aBounds,bBounds){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractSTRtree.prototype.root=null;jsts.index.strtree.AbstractSTRtree.prototype.built=false;jsts.index.strtree.AbstractSTRtree.prototype.itemBoundables=null;jsts.index.strtree.AbstractSTRtree.prototype.nodeCapacity=null;jsts.index.strtree.AbstractSTRtree.prototype.build=function(){jsts.util.Assert.isTrue(!this.built);this.root=this.itemBoundables.length===0?this.createNode(0):this.createHigherLevels(this.itemBoundables,-1);this.built=true};jsts.index.strtree.AbstractSTRtree.prototype.createNode=function(level){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractSTRtree.prototype.createParentBoundables=function(childBoundables,newLevel){jsts.util.Assert.isTrue(!(childBoundables.length===0));var parentBoundables=[];parentBoundables.push(this.createNode(newLevel));var sortedChildBoundables=[];for(var i=0;ib?1:amaxChildDepth)maxChildDepth=childDepth}}return maxChildDepth+1};jsts.index.strtree.AbstractSTRtree.prototype.insert=function(bounds,item){jsts.util.Assert.isTrue(!this.built,"Cannot insert items into an STR packed R-tree after it has been built.");this.itemBoundables.push(new jsts.index.strtree.ItemBoundable(bounds,item))};jsts.index.strtree.AbstractSTRtree.prototype.query=function(searchBounds){if(arguments.length>1){this.query2.apply(this,arguments)}if(!this.built){this.build()}var matches=[];if(this.itemBoundables.length===0){jsts.util.Assert.isTrue(this.root.getBounds()===null);return matches}if(this.getIntersectsOp().intersects(this.root.getBounds(),searchBounds)){this.query3(searchBounds,this.root,matches)}return matches};jsts.index.strtree.AbstractSTRtree.prototype.query2=function(searchBounds,visitor){if(arguments.length>2){this.query3.apply(this,arguments)}if(!this.built){this.build()}if(this.itemBoundables.length===0){jsts.util.Assert.isTrue(this.root.getBounds()===null)}if(this.getIntersectsOp().intersects(this.root.getBounds(),searchBounds)){this.query4(searchBounds,this.root,visitor)}};jsts.index.strtree.AbstractSTRtree.prototype.query3=function(searchBounds,node,matches){if(!(arguments[2]instanceof Array)){this.query4.apply(this,arguments)}var childBoundables=node.getChildBoundables();for(var i=0;i1){this.boundablesAtLevel2.apply(this,arguments);return}var boundables=[];this.boundablesAtLevel2(level,this.root,boundables);return boundables};jsts.index.strtree.AbstractSTRtree.prototype.boundablesAtLevel2=function(level,top,boundables){jsts.util.Assert.isTrue(level>-2);if(top.getLevel()===level){boundables.add(top);return}var childBoundables=node.getChildBoundables();for(var i=0;i0);var parentBoundables=[];for(var i=0;i0){var bndPair=priQ.pop();var currentDistance=bndPair.getDistance();if(currentDistance>=distanceLowerBound)break;if(bndPair.isLeaves()){distanceLowerBound=currentDistance;minPair=bndPair}else{bndPair.expandToQueue(priQ,distanceLowerBound)}}return[minPair.getBoundable(0).getItem(),minPair.getBoundable(1).getItem()]};jsts.noding.SegmentString=function(){};jsts.noding.SegmentString.prototype.getData=jsts.abstractFunc;jsts.noding.SegmentString.prototype.setData=jsts.abstractFunc;jsts.noding.SegmentString.prototype.size=jsts.abstractFunc;jsts.noding.SegmentString.prototype.getCoordinate=jsts.abstractFunc;jsts.noding.SegmentString.prototype.getCoordinates=jsts.abstractFunc;jsts.noding.SegmentString.prototype.isClosed=jsts.abstractFunc;jsts.noding.NodableSegmentString=function(){};jsts.noding.NodableSegmentString.prototype=new jsts.noding.SegmentString;jsts.noding.NodableSegmentString.prototype.addIntersection=jsts.abstractFunc;jsts.noding.NodedSegmentString=function(pts,data){this.nodeList=new jsts.noding.SegmentNodeList(this);this.pts=pts;this.data=data};jsts.noding.NodedSegmentString.prototype=new jsts.noding.NodableSegmentString;jsts.noding.NodedSegmentString.constructor=jsts.noding.NodedSegmentString;jsts.noding.NodedSegmentString.getNodedSubstrings=function(segStrings){if(arguments.length===2){jsts.noding.NodedSegmentString.getNodedSubstrings2.apply(this,arguments);return}var resultEdgelist=new javascript.util.ArrayList;jsts.noding.NodedSegmentString.getNodedSubstrings2(segStrings,resultEdgelist);return resultEdgelist};jsts.noding.NodedSegmentString.getNodedSubstrings2=function(segStrings,resultEdgelist){for(var i=segStrings.iterator();i.hasNext();){var ss=i.next();ss.getNodeList().addSplitEdges(resultEdgelist)}};jsts.noding.NodedSegmentString.prototype.nodeList=null;jsts.noding.NodedSegmentString.prototype.pts=null;jsts.noding.NodedSegmentString.prototype.data=null;jsts.noding.NodedSegmentString.prototype.getData=function(){return this.data};jsts.noding.NodedSegmentString.prototype.setData=function(data){this.data=data};jsts.noding.NodedSegmentString.prototype.getNodeList=function(){return this.nodeList};jsts.noding.NodedSegmentString.prototype.size=function(){return this.pts.length};jsts.noding.NodedSegmentString.prototype.getCoordinate=function(i){return this.pts[i]};jsts.noding.NodedSegmentString.prototype.getCoordinates=function(){return this.pts};jsts.noding.NodedSegmentString.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])};jsts.noding.NodedSegmentString.prototype.getSegmentOctant=function(index){if(index===this.pts.length-1)return-1;return this.safeOctant(this.getCoordinate(index),this.getCoordinate(index+1))};jsts.noding.NodedSegmentString.prototype.safeOctant=function(p0,p1){if(p0.equals2D(p1))return 0;return jsts.noding.Octant.octant(p0,p1)};jsts.noding.NodedSegmentString.prototype.addIntersections=function(li,segmentIndex,geomIndex){for(var i=0;i=pts.length-1){return pts.length-1}var chainQuad=jsts.geomgraph.Quadrant.quadrant(pts[safeStart],pts[safeStart+1]);var last=start+1;while(last0&&factor<1){return this.project(p)}var dist0=this.p0.distance(p);var dist1=this.p1.distance(p);if(dist0queryChain.getId()){queryChain.computeOverlaps(testChain,overlapAction);this.nOverlaps++}if(this.segInt.isDone())return}}};jsts.noding.MCIndexNoder.prototype.add=function(segStr){var segChains=MonotoneChainBuilder.getChains(segStr.getCoordinates(),segStr);for(var i=0;i1&&snapPts[0].equals2D(snapPts[snapPts.length-1])){distinctPtCount=snapPts.length-1}i=0;for(i;i=0){srcCoords.add(index+1,new jsts.geom.Coordinate(snapPt),false)}}};LineStringSnapper.prototype.findSegmentIndexToSnap=function(snapPt,srcCoords){var minDist=Number.MAX_VALUE,snapIndex=-1,i=0,dist;for(i;i0&&seqSize<4&&!this.preserveType)return this.factory.createLineString(seq);return this.factory.createLinearRing(seq)};GeometryTransformer.prototype.transformLineString=function(geom,parent){return this.factory.createLineString(this.transformCoordinates(geom.getCoordinateSequence(),geom))};GeometryTransformer.prototype.transformMultiLineString=function(geom,parent){var transGeomList=new ArrayList;for(var i=0;isnapTolerance)snapTolerance=fixedSnapTol}return snapTolerance};GeometrySnapper.computeSizeBasedSnapTolerance=function(g){var env=g.getEnvelopeInternal();var minDimension=Math.min(env.getHeight(),env.getWidth());var snapTol=minDimension*GeometrySnapper.SNAP_PRECISION_FACTOR;return snapTol};GeometrySnapper.computeOverlaySnapTolerance2=function(g0,g1){return Math.min(this.computeOverlaySnapTolerance(g0),this.computeOverlaySnapTolerance(g1))};GeometrySnapper.snap=function(g0,g1,snapTolerance){var snapGeom=[];var snapper0=new GeometrySnapper(g0);snapGeom[0]=snapper0.snapTo(g1,snapTolerance);var snapper1=new GeometrySnapper(g1);snapGeom[1]=snapper1.snapTo(snapGeom[0],snapTolerance);return snapGeom};GeometrySnapper.snapToSelf=function(g0,snapTolerance,cleanResult){var snapper0=new GeometrySnapper(g0);return snapper0.snapToSelf(snapTolerance,cleanResult)};GeometrySnapper.prototype.srcGeom=null;GeometrySnapper.prototype.snapTo=function(snapGeom,snapTolerance){var snapPts=this.extractTargetCoordinates(snapGeom); var snapTrans=new SnapTransformer(snapTolerance,snapPts);return snapTrans.transform(this.srcGeom)};GeometrySnapper.prototype.snapToSelf=function(snapTolerance,cleanResult){var snapPts=this.extractTargetCoordinates(srcGeom);var snapTrans=new SnapTransformer(snapTolerance,snapPts,true);var snappedGeom=snapTrans.transform(srcGeom);var result=snappedGeom;if(cleanResult&&result instanceof Polygonal){result=snappedGeom.buffer(0)}return result};GeometrySnapper.prototype.extractTargetCoordinates=function(g){var ptSet=new TreeSet;var pts=g.getCoordinates();for(var i=0;i0||this.isIn)return jsts.geom.Location.INTERIOR;return jsts.geom.Location.EXTERIOR};jsts.algorithm.PointLocator.prototype.computeLocation=function(p,geom){if(geom instanceof jsts.geom.Point||geom instanceof jsts.geom.LineString||geom instanceof jsts.geom.Polygon){this.updateLocationInfo(this.locate(p,geom))}else if(geom instanceof jsts.geom.MultiLineString){var ml=geom;for(var i=0;idy){dist=dx}else{dist=dy}}else{var pdx=Math.abs(p.x-p0.x);var pdy=Math.abs(p.y-p0.y);if(dx>dy){dist=pdx}else{dist=pdy}if(dist===0&&!p.equals(p0)){dist=Math.max(pdx,pdy)}}if(dist===0&&!p.equals(p0)){throw new jsts.error.IllegalArgumentError("Bad distance calculation")}return dist};jsts.algorithm.LineIntersector.nonRobustComputeEdgeDistance=function(p,p1,p2){var dx=p.x-p1.x;var dy=p.y-p1.y;var dist=Math.sqrt(dx*dx+dy*dy);if(!(dist===0&&!p.equals(p1))){throw new jsts.error.IllegalArgumentError("Invalid distance calculation")}return dist};jsts.algorithm.LineIntersector.prototype.result=null;jsts.algorithm.LineIntersector.prototype.inputLines=null;jsts.algorithm.LineIntersector.prototype.intPt=null;jsts.algorithm.LineIntersector.prototype.intLineIndex=null;jsts.algorithm.LineIntersector.prototype._isProper=null;jsts.algorithm.LineIntersector.prototype.pa=null;jsts.algorithm.LineIntersector.prototype.pb=null;jsts.algorithm.LineIntersector.prototype.precisionModel=null;jsts.algorithm.LineIntersector.prototype.computeIntersection=function(p,p1,p2){throw new jsts.error.AbstractMethodInvocationError};jsts.algorithm.LineIntersector.prototype.isCollinear=function(){return this.result===jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION};jsts.algorithm.LineIntersector.prototype.computeIntersection=function(p1,p2,p3,p4){this.inputLines[0][0]=p1;this.inputLines[0][1]=p2;this.inputLines[1][0]=p3;this.inputLines[1][1]=p4;this.result=this.computeIntersect(p1,p2,p3,p4)};jsts.algorithm.LineIntersector.prototype.computeIntersect=function(p1,p2,q1,q2){throw new jsts.error.AbstractMethodInvocationError};jsts.algorithm.LineIntersector.prototype.isEndPoint=function(){return this.hasIntersection()&&!this._isProper};jsts.algorithm.LineIntersector.prototype.hasIntersection=function(){return this.result!==jsts.algorithm.LineIntersector.NO_INTERSECTION};jsts.algorithm.LineIntersector.prototype.getIntersectionNum=function(){return this.result};jsts.algorithm.LineIntersector.prototype.getIntersection=function(intIndex){return this.intPt[intIndex]};jsts.algorithm.LineIntersector.prototype.computeIntLineIndex=function(){if(this.intLineIndex===null){this.intLineIndex=[[],[]];this.computeIntLineIndex(0);this.computeIntLineIndex(1)}};jsts.algorithm.LineIntersector.prototype.isIntersection=function(pt){var i;for(i=0;idist1){this.intLineIndex[segmentIndex][0]=0;this.intLineIndex[segmentIndex][1]=1}else{this.intLineIndex[segmentIndex][0]=1;this.intLineIndex[segmentIndex][1]=0}};jsts.algorithm.LineIntersector.prototype.getEdgeDistance=function(segmentIndex,intIndex){var dist=jsts.algorithm.LineIntersector.computeEdgeDistance(this.intPt[intIndex],this.inputLines[segmentIndex][0],this.inputLines[segmentIndex][1]);return dist};jsts.algorithm.RobustLineIntersector=function(){jsts.algorithm.RobustLineIntersector.prototype.constructor.call(this)};jsts.algorithm.RobustLineIntersector.prototype=new jsts.algorithm.LineIntersector;jsts.algorithm.RobustLineIntersector.prototype.computeIntersection=function(p,p1,p2){if(arguments.length===4){jsts.algorithm.LineIntersector.prototype.computeIntersection.apply(this,arguments);return}this._isProper=false;if(jsts.geom.Envelope.intersects(p1,p2,p)){if(jsts.algorithm.CGAlgorithms.orientationIndex(p1,p2,p)===0&&jsts.algorithm.CGAlgorithms.orientationIndex(p2,p1,p)===0){this._isProper=true;if(p.equals(p1)||p.equals(p2)){this._isProper=false}this.result=jsts.algorithm.LineIntersector.POINT_INTERSECTION;return}}this.result=jsts.algorithm.LineIntersector.NO_INTERSECTION};jsts.algorithm.RobustLineIntersector.prototype.computeIntersect=function(p1,p2,q1,q2){this._isProper=false;if(!jsts.geom.Envelope.intersects(p1,p2,q1,q2)){return jsts.algorithm.LineIntersector.NO_INTERSECTION}var Pq1=jsts.algorithm.CGAlgorithms.orientationIndex(p1,p2,q1);var Pq2=jsts.algorithm.CGAlgorithms.orientationIndex(p1,p2,q2);if(Pq1>0&&Pq2>0||Pq1<0&&Pq2<0){return jsts.algorithm.LineIntersector.NO_INTERSECTION}var Qp1=jsts.algorithm.CGAlgorithms.orientationIndex(q1,q2,p1);var Qp2=jsts.algorithm.CGAlgorithms.orientationIndex(q1,q2,p2);if(Qp1>0&&Qp2>0||Qp1<0&&Qp2<0){return jsts.algorithm.LineIntersector.NO_INTERSECTION}var collinear=Pq1===0&&Pq2===0&&Qp1===0&&Qp2===0;if(collinear){return this.computeCollinearIntersection(p1,p2,q1,q2)}if(Pq1===0||Pq2===0||Qp1===0||Qp2===0){this._isProper=false;if(p1.equals2D(q1)||p1.equals2D(q2)){this.intPt[0]=p1}else if(p2.equals2D(q1)||p2.equals2D(q2)){this.intPt[0]=p2}else if(Pq1===0){this.intPt[0]=new jsts.geom.Coordinate(q1)}else if(Pq2===0){this.intPt[0]=new jsts.geom.Coordinate(q2)}else if(Qp1===0){this.intPt[0]=new jsts.geom.Coordinate(p1)}else if(Qp2===0){this.intPt[0]=new jsts.geom.Coordinate(p2)}}else{this._isProper=true;this.intPt[0]=this.intersection(p1,p2,q1,q2)}return jsts.algorithm.LineIntersector.POINT_INTERSECTION};jsts.algorithm.RobustLineIntersector.prototype.computeCollinearIntersection=function(p1,p2,q1,q2){var p1q1p2=jsts.geom.Envelope.intersects(p1,p2,q1);var p1q2p2=jsts.geom.Envelope.intersects(p1,p2,q2);var q1p1q2=jsts.geom.Envelope.intersects(q1,q2,p1);var q1p2q2=jsts.geom.Envelope.intersects(q1,q2,p2);if(p1q1p2&&p1q2p2){this.intPt[0]=q1;this.intPt[1]=q2;return jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}if(q1p1q2&&q1p2q2){this.intPt[0]=p1;this.intPt[1]=p2;return jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}if(p1q1p2&&q1p1q2){this.intPt[0]=q1;this.intPt[1]=p1;return q1.equals(p1)&&!p1q2p2&&!q1p2q2?jsts.algorithm.LineIntersector.POINT_INTERSECTION:jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}if(p1q1p2&&q1p2q2){this.intPt[0]=q1;this.intPt[1]=p2;return q1.equals(p2)&&!p1q2p2&&!q1p1q2?jsts.algorithm.LineIntersector.POINT_INTERSECTION:jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}if(p1q2p2&&q1p1q2){this.intPt[0]=q2;this.intPt[1]=p1;return q2.equals(p1)&&!p1q1p2&&!q1p2q2?jsts.algorithm.LineIntersector.POINT_INTERSECTION:jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}if(p1q2p2&&q1p2q2){this.intPt[0]=q2;this.intPt[1]=p2;return q2.equals(p2)&&!p1q1p2&&!q1p1q2?jsts.algorithm.LineIntersector.POINT_INTERSECTION:jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION}return jsts.algorithm.LineIntersector.NO_INTERSECTION};jsts.algorithm.RobustLineIntersector.prototype.intersection=function(p1,p2,q1,q2){var intPt=this.intersectionWithNormalization(p1,p2,q1,q2);if(!this.isInSegmentEnvelopes(intPt)){intPt=jsts.algorithm.CentralEndpointIntersector.getIntersection(p1,p2,q1,q2)}if(this.precisionModel!==null){this.precisionModel.makePrecise(intPt)}return intPt};jsts.algorithm.RobustLineIntersector.prototype.intersectionWithNormalization=function(p1,p2,q1,q2){var n1=new jsts.geom.Coordinate(p1);var n2=new jsts.geom.Coordinate(p2);var n3=new jsts.geom.Coordinate(q1);var n4=new jsts.geom.Coordinate(q2);var normPt=new jsts.geom.Coordinate;this.normalizeToEnvCentre(n1,n2,n3,n4,normPt);var intPt=this.safeHCoordinateIntersection(n1,n2,n3,n4);intPt.x+=normPt.x;intPt.y+=normPt.y;return intPt};jsts.algorithm.RobustLineIntersector.prototype.safeHCoordinateIntersection=function(p1,p2,q1,q2){var intPt=null;try{intPt=jsts.algorithm.HCoordinate.intersection(p1,p2,q1,q2)}catch(e){if(e instanceof jsts.error.NotRepresentableError){intPt=jsts.algorithm.CentralEndpointIntersector.getIntersection(p1,p2,q1,q2)}else{throw e}}return intPt};jsts.algorithm.RobustLineIntersector.prototype.normalizeToMinimum=function(n1,n2,n3,n4,normPt){normPt.x=this.smallestInAbsValue(n1.x,n2.x,n3.x,n4.x);normPt.y=this.smallestInAbsValue(n1.y,n2.y,n3.y,n4.y);n1.x-=normPt.x;n1.y-=normPt.y;n2.x-=normPt.x;n2.y-=normPt.y;n3.x-=normPt.x;n3.y-=normPt.y;n4.x-=normPt.x;n4.y-=normPt.y};jsts.algorithm.RobustLineIntersector.prototype.normalizeToEnvCentre=function(n00,n01,n10,n11,normPt){var minX0=n00.xn01.x?n00.x:n01.x;var maxY0=n00.y>n01.y?n00.y:n01.y;var minX1=n10.xn11.x?n10.x:n11.x;var maxY1=n10.y>n11.y?n10.y:n11.y;var intMinX=minX0>minX1?minX0:minX1;var intMaxX=maxX0minY1?minY0:minY1;var intMaxY=maxY0=segStr.size()-2)return true;return false};jsts.noding.InteriorIntersectionFinder.prototype.isDone=function(){if(this.findAllIntersections)return false;return this.interiorIntersection!=null}})();(function(){var RobustLineIntersector=jsts.algorithm.RobustLineIntersector;var InteriorIntersectionFinder=jsts.noding.InteriorIntersectionFinder;var MCIndexNoder=jsts.noding.MCIndexNoder;jsts.noding.FastNodingValidator=function(segStrings){this.li=new RobustLineIntersector;this.segStrings=segStrings};jsts.noding.FastNodingValidator.prototype.li=null;jsts.noding.FastNodingValidator.prototype.segStrings=null;jsts.noding.FastNodingValidator.prototype.findAllIntersections=false;jsts.noding.FastNodingValidator.prototype.segInt=null;jsts.noding.FastNodingValidator.prototype._isValid=true;jsts.noding.FastNodingValidator.prototype.setFindAllIntersections=function(findAllIntersections){this.findAllIntersections=findAllIntersections};jsts.noding.FastNodingValidator.prototype.getIntersections=function(){return segInt.getIntersections()};jsts.noding.FastNodingValidator.prototype.isValid=function(){this.execute();return this._isValid};jsts.noding.FastNodingValidator.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var intSegs=this.segInt.getIntersectionSegments();return"found non-noded intersection between "+jsts.io.WKTWriter.toLineString(intSegs[0],intSegs[1])+" and "+jsts.io.WKTWriter.toLineString(intSegs[2],intSegs[3])};jsts.noding.FastNodingValidator.prototype.checkValid=function(){this.execute();if(!this._isValid)throw new jsts.error.TopologyError(this.getErrorMessage(),this.segInt.getInteriorIntersection())};jsts.noding.FastNodingValidator.prototype.execute=function(){if(this.segInt!=null)return;this.checkInteriorIntersections()};jsts.noding.FastNodingValidator.prototype.checkInteriorIntersections=function(){this._isValid=true;this.segInt=new InteriorIntersectionFinder(this.li);this.segInt.setFindAllIntersections(this.findAllIntersections);var noder=new MCIndexNoder;noder.setSegmentIntersector(this.segInt);noder.computeNodes(this.segStrings);if(this.segInt.hasIntersection()){this._isValid=false;return}}})();(function(){jsts.noding.BasicSegmentString=function(pts,data){this.pts=pts;this.data=data};jsts.noding.BasicSegmentString.prototype=new jsts.noding.SegmentString;jsts.noding.BasicSegmentString.prototype.pts=null;jsts.noding.BasicSegmentString.prototype.data=null;jsts.noding.BasicSegmentString.prototype.getData=function(){return this.data};jsts.noding.BasicSegmentString.prototype.setData=function(data){this.data=data};jsts.noding.BasicSegmentString.prototype.size=function(){return this.pts.length};jsts.noding.BasicSegmentString.prototype.getCoordinate=function(i){return this.pts[i]};jsts.noding.BasicSegmentString.prototype.getCoordinates=function(){return this.pts};jsts.noding.BasicSegmentString.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])};jsts.noding.BasicSegmentString.prototype.getSegmentOctant=function(index){if(index==this.pts.length-1)return-1;return jsts.noding.Octant.octant(this.getCoordinate(index),this.getCoordinate(index+1))}})();(function(){var FastNodingValidator=jsts.noding.FastNodingValidator;var BasicSegmentString=jsts.noding.BasicSegmentString;var ArrayList=javascript.util.ArrayList;jsts.geomgraph.EdgeNodingValidator=function(edges){this.nv=new FastNodingValidator(jsts.geomgraph.EdgeNodingValidator.toSegmentStrings(edges))};jsts.geomgraph.EdgeNodingValidator.checkValid=function(edges){var validator=new jsts.geomgraph.EdgeNodingValidator(edges);validator.checkValid()};jsts.geomgraph.EdgeNodingValidator.toSegmentStrings=function(edges){var segStrings=new ArrayList;for(var i=edges.iterator();i.hasNext();){var e=i.next();segStrings.add(new BasicSegmentString(e.getCoordinates(),e))}return segStrings};jsts.geomgraph.EdgeNodingValidator.prototype.nv=null;jsts.geomgraph.EdgeNodingValidator.prototype.checkValid=function(){this.nv.checkValid()}})();jsts.operation.GeometryGraphOperation=function(g0,g1,boundaryNodeRule){this.li=new jsts.algorithm.RobustLineIntersector;this.arg=[];if(g0===undefined){return}if(g1===undefined){this.setComputationPrecision(g0.getPrecisionModel());this.arg[0]=new jsts.geomgraph.GeometryGraph(0,g0);return}boundaryNodeRule=boundaryNodeRule||jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;if(g0.getPrecisionModel().compareTo(g1.getPrecisionModel())>=0)this.setComputationPrecision(g0.getPrecisionModel());else this.setComputationPrecision(g1.getPrecisionModel());this.arg[0]=new jsts.geomgraph.GeometryGraph(0,g0,boundaryNodeRule);this.arg[1]=new jsts.geomgraph.GeometryGraph(1,g1,boundaryNodeRule)};jsts.operation.GeometryGraphOperation.prototype.li=null;jsts.operation.GeometryGraphOperation.prototype.resultPrecisionModel=null;jsts.operation.GeometryGraphOperation.prototype.arg=null;jsts.operation.GeometryGraphOperation.prototype.getArgGeometry=function(i){return arg[i].getGeometry()};jsts.operation.GeometryGraphOperation.prototype.setComputationPrecision=function(pm){this.resultPrecisionModel=pm;this.li.setPrecisionModel(this.resultPrecisionModel)};jsts.operation.overlay.OverlayNodeFactory=function(){};jsts.operation.overlay.OverlayNodeFactory.prototype=new jsts.geomgraph.NodeFactory;jsts.operation.overlay.OverlayNodeFactory.constructor=jsts.operation.overlay.OverlayNodeFactory;jsts.operation.overlay.OverlayNodeFactory.prototype.createNode=function(coord){return new jsts.geomgraph.Node(coord,new jsts.geomgraph.DirectedEdgeStar)};jsts.operation.overlay.PolygonBuilder=function(geometryFactory){this.shellList=[];this.geometryFactory=geometryFactory};jsts.operation.overlay.PolygonBuilder.prototype.geometryFactory=null;jsts.operation.overlay.PolygonBuilder.prototype.shellList=null;jsts.operation.overlay.PolygonBuilder.prototype.add=function(graph){if(arguments.length===2){this.add2.apply(this,arguments);return}this.add2(graph.getEdgeEnds(),graph.getNodes())};jsts.operation.overlay.PolygonBuilder.prototype.add2=function(dirEdges,nodes){jsts.geomgraph.PlanarGraph.linkResultDirectedEdges(nodes);var maxEdgeRings=this.buildMaximalEdgeRings(dirEdges);var freeHoleList=[];var edgeRings=this.buildMinimalEdgeRings(maxEdgeRings,this.shellList,freeHoleList);this.sortShellsAndHoles(edgeRings,this.shellList,freeHoleList);this.placeFreeHoles(this.shellList,freeHoleList)};jsts.operation.overlay.PolygonBuilder.prototype.getPolygons=function(){var resultPolyList=this.computePolygons(this.shellList);return resultPolyList};jsts.operation.overlay.PolygonBuilder.prototype.buildMaximalEdgeRings=function(dirEdges){var maxEdgeRings=[];for(var it=dirEdges.iterator();it.hasNext();){var de=it.next();if(de.isInResult()&&de.getLabel().isArea()){if(de.getEdgeRing()==null){var er=new jsts.operation.overlay.MaximalEdgeRing(de,this.geometryFactory);maxEdgeRings.push(er);er.setInResult()}}}return maxEdgeRings};jsts.operation.overlay.PolygonBuilder.prototype.buildMinimalEdgeRings=function(maxEdgeRings,shellList,freeHoleList){var edgeRings=[];for(var i=0;i2){er.linkDirectedEdgesForMinimalEdgeRings();var minEdgeRings=er.buildMinimalRings();var shell=this.findShell(minEdgeRings);if(shell!==null){this.placePolygonHoles(shell,minEdgeRings);shellList.push(shell)}else{freeHoleList=freeHoleList.concat(minEdgeRings)}}else{edgeRings.push(er)}}return edgeRings};jsts.operation.overlay.PolygonBuilder.prototype.findShell=function(minEdgeRings){var shellCount=0;var shell=null;for(var i=0;i=0;i--){var nextOut=this.resultAreaEdgeList.get(i);var nextIn=nextOut.getSym();if(firstOut===null&&nextOut.getEdgeRing()===er)firstOut=nextOut;switch(state){case this.SCANNING_FOR_INCOMING:if(nextIn.getEdgeRing()!=er)continue;incoming=nextIn;state=this.LINKING_TO_OUTGOING;break;case this.LINKING_TO_OUTGOING:if(nextOut.getEdgeRing()!==er)continue;incoming.setNextMin(nextOut);state=this.SCANNING_FOR_INCOMING;break}}if(state===this.LINKING_TO_OUTGOING){Assert.isTrue(firstOut!==null,"found null for first outgoing dirEdge");Assert.isTrue(firstOut.getEdgeRing()===er,"unable to link last incoming dirEdge");incoming.setNextMin(firstOut)}};jsts.geomgraph.DirectedEdgeStar.prototype.linkAllDirectedEdges=function(){this.getEdges();var prevOut=null;var firstIn=null;for(var i=this.edgeList.size()-1;i>=0;i--){var nextOut=this.edgeList.get(i);var nextIn=nextOut.getSym();if(firstIn===null)firstIn=nextIn;if(prevOut!==null)nextIn.setNext(prevOut);prevOut=nextOut}firstIn.setNext(prevOut)};jsts.geomgraph.DirectedEdgeStar.prototype.findCoveredLineEdges=function(){var startLoc=Location.NONE;for(var it=this.iterator();it.hasNext();){var nextOut=it.next();var nextIn=nextOut.getSym();if(!nextOut.isLineEdge()){if(nextOut.isInResult()){startLoc=Location.INTERIOR;break}if(nextIn.isInResult()){startLoc=Location.EXTERIOR;break}}}if(startLoc===Location.NONE)return;var currLoc=startLoc;for(var it=this.iterator();it.hasNext();){var nextOut=it.next();var nextIn=nextOut.getSym();if(nextOut.isLineEdge()){nextOut.getEdge().setCovered(currLoc===Location.INTERIOR)}else{if(nextOut.isInResult())currLoc=Location.EXTERIOR;if(nextIn.isInResult())currLoc=Location.INTERIOR}}};jsts.geomgraph.DirectedEdgeStar.prototype.computeDepths=function(de){if(arguments.length===2){this.computeDepths2.apply(this,arguments);return}var edgeIndex=this.findIndex(de);var label=de.getLabel();var startDepth=de.getDepth(Position.LEFT);var targetLastDepth=de.getDepth(Position.RIGHT);var nextDepth=this.computeDepths2(edgeIndex+1,this.edgeList.size(),startDepth);var lastDepth=this.computeDepths2(0,edgeIndex,nextDepth);if(lastDepth!=targetLastDepth)throw new jsts.error.TopologyError("depth mismatch at "+de.getCoordinate())};jsts.geomgraph.DirectedEdgeStar.prototype.computeDepths2=function(startIndex,endIndex,startDepth){var currDepth=startDepth;for(var i=startIndex;i0){return this.pts[0]}else{return null}}return this.pts[i]};jsts.geomgraph.Edge.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])};jsts.geomgraph.Edge.prototype.setIsolated=function(isIsolated){this._isIsolated=isIsolated };jsts.geomgraph.Edge.prototype.isIsolated=function(){return this._isIsolated};jsts.geomgraph.Edge.prototype.addIntersections=function(li,segmentIndex,geomIndex){for(var i=0;i=0){if(dy>=0){if(adx>=ady)return 0;else return 1}else{if(adx>=ady)return 7;else return 6}}else{if(dy>=0){if(adx>=ady)return 3;else return 2}else{if(adx>=ady)return 4;else return 5}}};jsts.noding.Octant.octant2=function(p0,p1){var dx=p1.x-p0.x;var dy=p1.y-p0.y;if(dx===0&&dy===0)throw new jsts.error.IllegalArgumentError("Cannot compute the octant for two identical points "+p0);return jsts.noding.Octant.octant(dx,dy)};jsts.operation.union.UnionInteracting=function(g0,g1){this.g0=g0;this.g1=g1;this.geomFactory=g0.getFactory();this.interacts0=[];this.interacts1=[]};jsts.operation.union.UnionInteracting.union=function(g0,g1){var uue=new jsts.operation.union.UnionInteracting(g0,g1);return uue.union()};jsts.operation.union.UnionInteracting.prototype.geomFactory=null;jsts.operation.union.UnionInteracting.prototype.g0=null;jsts.operation.union.UnionInteracting.prototype.g1=null;jsts.operation.union.UnionInteracting.prototype.interacts0=null;jsts.operation.union.UnionInteracting.prototype.interacts1=null;jsts.operation.union.UnionInteracting.prototype.union=function(){this.computeInteracting();var int0=this.extractElements(this.g0,this.interacts0,true);var int1=this.extractElements(this.g1,this.interacts1,true);if(int0.isEmpty()||int1.isEmpty()){}var union=in0.union(int1);var disjoint0=this.extractElements(this.g0,this.interacts0,false);var disjoint1=this.extractElements(this.g1,this.interacts1,false);var overallUnion=jsts.geom.util.GeometryCombiner.combine(union,disjoint0,disjoint1);return overallUnion};jsts.operation.union.UnionInteracting.prototype.bufferUnion=function(g0,g1){var factory=g0.getFactory();var gColl=factory.createGeometryCollection([g0,g1]);var unionAll=gColl.buffer(0);return unionAll};jsts.operation.union.UnionInteracting.prototype.computeInteracting=function(elem0){if(!elem0){for(var i=0,l=this.g0.getNumGeometries();i0;return isInCircle};jsts.triangulate.quadedge.TrianglePredicate.isInCircleNormalized=function(a,b,c,p){var adx,ady,bdx,bdy,cdx,cdy,abdet,bcdet,cadet,alift,blift,clift,disc;adx=a.x-p.x;ady=a.y-p.y;bdx=b.x-p.x;bdy=b.y-p.y;cdx=c.x-p.x;cdy=c.y-p.y;abdet=adx*bdy-bdx*ady;bcdet=bdx*cdy-cdx*bdy;cadet=cdx*ady-adx*cdy;alift=adx*adx+ady*ady;blift=bdx*bdx+bdy*bdy;clift=cdx*cdx+cdy*cdy;disc=alift*bcdet+blift*cadet+clift*abdet;return disc>0};jsts.triangulate.quadedge.TrianglePredicate.triArea=function(a,b,c){return(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x)};jsts.triangulate.quadedge.TrianglePredicate.isInCircleRobust=function(a,b,c,p){return jsts.triangulate.quadedge.TrianglePredicate.isInCircleNormalized(a,b,c,p)};jsts.triangulate.quadedge.TrianglePredicate.isInCircleDDSlow=function(a,b,c,p){var px,py,ax,ay,bx,by,cx,cy,aTerm,bTerm,cTerm,pTerm,sum,isInCircle;px=jsts.math.DD.valueOf(p.x);py=jsts.math.DD.valueOf(p.y);ax=jsts.math.DD.valueOf(a.x);ay=jsts.math.DD.valueOf(a.y);bx=jsts.math.DD.valueOf(b.x);by=jsts.math.DD.valueOf(b.y);cx=jsts.math.DD.valueOf(c.x);cy=jsts.math.DD.valueOf(c.y);aTerm=ax.multiply(ax).add(ay.multiply(ay)).multiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDSlow(bx,by,cx,cy,px,py));bTerm=bx.multiply(bx).add(by.multiply(by)).multiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDSlow(ax,ay,cx,cy,px,py));cTerm=cx.multiply(cx).add(cy.multiply(cy)).multiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDSlow(ax,ay,bx,by,px,py));pTerm=px.multiply(px).add(py.multiply(py)).multiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDSlow(ax,ay,bx,by,cx,cy));sum=aTerm.subtract(bTerm).add(cTerm).subtract(pTerm);isInCircle=sum.doubleValue()>0;return isInCircle};jsts.triangulate.quadedge.TrianglePredicate.triAreaDDSlow=function(ax,ay,bx,by,cx,cy){return bx.subtract(ax).multiply(cy.subtract(ay)).subtract(by.subtract(ay).multiply(cx.subtract(ax)))};jsts.triangulate.quadedge.TrianglePredicate.isInCircleDDFast=function(a,b,c,p){var aTerm,bTerm,cTerm,pTerm,sum,isInCircle;aTerm=jsts.math.DD.sqr(a.x).selfAdd(jsts.math.DD.sqr(a.y)).selfMultiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDFast(b,c,p));bTerm=jsts.math.DD.sqr(b.x).selfAdd(jsts.math.DD.sqr(b.y)).selfMultiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDFast(a,c,p));cTerm=jsts.math.DD.sqr(c.x).selfAdd(jsts.math.DD.sqr(c.y)).selfMultiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDFast(a,b,p));pTerm=jsts.math.DD.sqr(p.x).selfAdd(jsts.math.DD.sqr(p.y)).selfMultiply(jsts.triangulate.quadedge.TrianglePredicate.triAreaDDFast(a,b,c));sum=aTerm.selfSubtract(bTerm).selfAdd(cTerm).selfSubtract(pTerm);isInCircle=sum.doubleValue()>0;return isInCircle};jsts.triangulate.quadedge.TrianglePredicate.triAreaDDFast=function(a,b,c){var t1,t2;t1=jsts.math.DD.valueOf(b.x).selfSubtract(a.x).selfMultiply(jsts.math.DD.valueOf(c.y).selfSubtract(a.y));t2=jsts.math.DD.valueOf(b.y).selSubtract(a.y).selfMultiply(jsts.math.DD.valueOf(c.x).selfSubtract(a.x));return t1.selfSubtract(t2)};jsts.triangulate.quadedge.TrianglePredicate.isInCircleDDNormalized=function(a,b,c,p){var adx,ady,bdx,bdy,cdx,cdy,abdet,bcdet,cadet,alift,blift,clift,sum,isInCircle;adx=jsts.math.DD.valueOf(a.x).selfSubtract(p.x);ady=jsts.math.DD.valueOf(a.y).selfSubtract(p.y);bdx=jsts.math.DD.valueOf(b.x).selfSubtract(p.x);bdx=jsts.math.DD.valueOf(b.y).selfSubtract(p.y);cdx=jsts.math.DD.valueOf(c.x).selfSubtract(p.x);cdx=jsts.math.DD.valueOf(c.y).selfSubtract(p.y);abdet=adx.multiply(bdy).selfSubtract(bdx.multiply(ady));bcdet=bdx.multiply(cdy).selfSubtract(cdx.multiply(bdy));cadet=cdx.multiply(ady).selfSubtract(adx.multiply(cdy));alift=adx.multiply(adx).selfAdd(ady.multiply(ady));blift=bdx.multiply(bdx).selfAdd(bdy.multiply(bdy));clift=cdx.multiply(cdx).selfAdd(cdy.multiply(cdy));sum=alift.selfMultiply(bcdet).selfAdd(blift.selfMultiply(cadet)).selfAdd(clift.selfMultiply(abdet));isInCircle=sum.doubleValue()>0;return isInCircle};jsts.triangulate.quadedge.TrianglePredicate.isInCircleCC=function(a,b,c,p){var cc,ccRadius,pRadiusDiff;cc=jsts.geom.Triangle.circumcentre(a,b,c);ccRadius=a.distance(cc);pRadiusDiff=p.distance(cc)-ccRadius;return pRadiusDiff<=0};jsts.operation.union.PointGeometryUnion=function(pointGeom,otherGeom){this.pointGeom=pointGeom;this.otherGeom=otherGeom;this.geomFact=otherGeom.getFactory()};jsts.operation.union.PointGeometryUnion.union=function(pointGeom,otherGeom){var unioner=new jsts.operation.union.PointGeometryUnion(pointGeom,otherGeom);return unioner.union()};jsts.operation.union.PointGeometryUnion.prototype.pointGeom=null;jsts.operation.union.PointGeometryUnion.prototype.otherGeom=null;jsts.operation.union.PointGeometryUnion.prototype.geomFact=null;jsts.operation.union.PointGeometryUnion.prototype.union=function(){var locator=new jsts.algorithm.PointLocator;var exteriorCoords=[];for(var i=0,l=this.pointGeom.getNumGeometries();i0&&y2<=0||y2>0&&y1<=0){xInt=jsts.algorithm.RobustDeterminant.signOfDet2x2(x1,y1,x2,y2)/(y2-y1);if(0max){this.min=max;this.max=min}};Interval.prototype.getMin=function(){return this.min};Interval.prototype.getMax=function(){return this.max};Interval.prototype.getWidth=function(){return this.max-this.min};Interval.prototype.expandToInclude=function(interval){if(interval.max>this.max){this.max=interval.max}if(interval.minmax||this.max=this.min&&max<=this.max};Interval.prototype.containsPoint=function(p){return p>=this.min&&p<=this.max};jsts.index.bintree.Interval=Interval})();jsts.index.DoubleBits=function(){};jsts.index.DoubleBits.powerOf2=function(exp){return Math.pow(2,exp)};jsts.index.DoubleBits.exponent=function(d){return jsts.index.DoubleBits.CVTFWD(64,d)-1023};jsts.index.DoubleBits.CVTFWD=function(NumW,Qty){var Sign,Expo,Mant,Bin,nb01="";var Inf={32:{d:127,c:128,b:0,a:0},64:{d:32752,c:0,b:0,a:0}};var ExW={32:8,64:11}[NumW],MtW=NumW-ExW-1;if(!Bin){Sign=Qty<0||1/Qty<0;if(!isFinite(Qty)){Bin=Inf[NumW];if(Sign){Bin.d+=1<=2){Expo++;Mant/=2}while(Mant<1&&Expo>0){Expo--;Mant*=2}if(Expo<=0){Mant/=2;nb01="Zero or Denormal"}if(NumW===32&&Expo>254){nb01="Too big for Single";Bin={d:Sign?255:127,c:128,b:0,a:0};Expo=Math.pow(2,ExW)-1;Mant=0}}return Expo};(function(){var DoubleBits=jsts.index.DoubleBits;var Interval=jsts.index.bintree.Interval;var Key=function(interval){this.pt=0;this.level=0;this.computeKey(interval)};Key.computeLevel=function(interval){var dx=interval.getWidth(),level;level=DoubleBits.exponent(dx)+1;return level};Key.prototype.getPoint=function(){return this.pt};Key.prototype.getLevel=function(){return this.level};Key.prototype.getInterval=function(){return this.interval};Key.prototype.computeKey=function(itemInterval){this.level=Key.computeLevel(itemInterval);this.interval=new Interval;this.computeInterval(this.level,itemInterval);while(!this.interval.contains(itemInterval)){this.level+=1;this.computeInterval(this.level,itemInterval)}};Key.prototype.computeInterval=function(level,itemInterval){var size=DoubleBits.powerOf2(level);this.pt=Math.floor(itemInterval.getMin()/size)*size;this.interval.init(this.pt,this.pt+size)};jsts.index.bintree.Key=Key})();jsts.operation.buffer.SubgraphDepthLocater=function(subgraphs){this.subgraphs=[];this.seg=new jsts.geom.LineSegment;this.subgraphs=subgraphs};jsts.operation.buffer.SubgraphDepthLocater.prototype.subgraphs=null;jsts.operation.buffer.SubgraphDepthLocater.prototype.seg=null;jsts.operation.buffer.SubgraphDepthLocater.prototype.getDepth=function(p){var stabbedSegments=this.findStabbedSegments(p);if(stabbedSegments.length===0)return 0;stabbedSegments.sort();var ds=stabbedSegments[0];return ds.leftDepth};jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments=function(stabbingRayLeftPt){if(arguments.length===3){this.findStabbedSegments2.apply(this,arguments);return}var stabbedSegments=[];for(var i=0;ienv.getMaxY())continue;this.findStabbedSegments2(stabbingRayLeftPt,bsg.getDirectedEdges(),stabbedSegments)}return stabbedSegments};jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments2=function(stabbingRayLeftPt,dirEdges,stabbedSegments){if(arguments[1]instanceof jsts.geomgraph.DirectedEdge){this.findStabbedSegments3(stabbingRayLeftPt,dirEdges,stabbedSegments);return}for(var i=dirEdges.iterator();i.hasNext();){var de=i.next();if(!de.isForward())continue;this.findStabbedSegments3(stabbingRayLeftPt,de,stabbedSegments)}};jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments3=function(stabbingRayLeftPt,dirEdge,stabbedSegments){var pts=dirEdge.getEdge().getCoordinates();for(var i=0;ithis.seg.p1.y)this.seg.reverse();var maxx=Math.max(this.seg.p0.x,this.seg.p1.x);if(maxxthis.seg.p1.y)continue;if(jsts.algorithm.CGAlgorithms.computeOrientation(this.seg.p0,this.seg.p1,stabbingRayLeftPt)===jsts.algorithm.CGAlgorithms.RIGHT)continue;var depth=dirEdge.getDepth(jsts.geomgraph.Position.LEFT);if(!this.seg.p0.equals(pts[i]))depth=dirEdge.getDepth(jsts.geomgraph.Position.RIGHT);var ds=new jsts.operation.buffer.SubgraphDepthLocater.DepthSegment(this.seg,depth);stabbedSegments.push(ds)}};jsts.operation.buffer.SubgraphDepthLocater.DepthSegment=function(seg,depth){this.upwardSeg=new jsts.geom.LineSegment(seg);this.leftDepth=depth};jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.upwardSeg=null;jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.leftDepth=null;jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.compareTo=function(obj){var other=obj;var orientIndex=this.upwardSeg.orientationIndex(other.upwardSeg);if(orientIndex===0)orientIndex=-1*other.upwardSeg.orientationIndex(upwardSeg);if(orientIndex!==0)return orientIndex;return this.compareX(this.upwardSeg,other.upwardSeg)};jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.compareX=function(seg0,seg1){var compare0=seg0.p0.compareTo(seg1.p0);if(compare0!==0)return compare0;return seg0.p1.compareTo(seg1.p1)};jsts.noding.snapround.HotPixel=function(pt,scaleFactor,li){this.corner=[];this.originalPt=pt;this.pt=pt;this.scaleFactor=scaleFactor;this.li=li;if(this.scaleFactor!==1){this.pt=new jsts.geom.Coordinate(this.scale(pt.x),this.scale(pt.y));this.p0Scaled=new jsts.geom.Coordinate;this.p1Scaled=new jsts.geom.Coordinate}this.initCorners(this.pt)};jsts.noding.snapround.HotPixel.prototype.li=null;jsts.noding.snapround.HotPixel.prototype.pt=null;jsts.noding.snapround.HotPixel.prototype.originalPt=null;jsts.noding.snapround.HotPixel.prototype.ptScaled=null;jsts.noding.snapround.HotPixel.prototype.p0Scaled=null;jsts.noding.snapround.HotPixel.prototype.p1Scaled=null;jsts.noding.snapround.HotPixel.prototype.scaleFactor=undefined;jsts.noding.snapround.HotPixel.prototype.minx=undefined;jsts.noding.snapround.HotPixel.prototype.maxx=undefined;jsts.noding.snapround.HotPixel.prototype.miny=undefined; jsts.noding.snapround.HotPixel.prototype.maxy=undefined;jsts.noding.snapround.HotPixel.prototype.corner=null;jsts.noding.snapround.HotPixel.prototype.safeEnv=null;jsts.noding.snapround.HotPixel.prototype.getCoordinate=function(){return this.originalPt};jsts.noding.snapround.HotPixel.SAFE_ENV_EXPANSION_FACTOR=.75;jsts.noding.snapround.HotPixel.prototype.getSafeEnvelope=function(){if(this.safeEnv===null){var safeTolerance=jsts.noding.snapround.HotPixel.SAFE_ENV_EXPANSION_FACTOR/this.scaleFactor;this.safeEnv=new jsts.geom.Envelope(this.originalPt.x-safeTolerance,this.originalPt.x+safeTolerance,this.originalPt.y-safeTolerance,this.originalPt.y+safeTolerance)}return this.safeEnv};jsts.noding.snapround.HotPixel.prototype.initCorners=function(pt){var tolerance=.5;this.minx=pt.x-tolerance;this.maxx=pt.x+tolerance;this.miny=pt.y-tolerance;this.maxy=pt.y+tolerance;this.corner[0]=new jsts.geom.Coordinate(this.maxx,this.maxy);this.corner[1]=new jsts.geom.Coordinate(this.minx,this.maxy);this.corner[2]=new jsts.geom.Coordinate(this.minx,this.miny);this.corner[3]=new jsts.geom.Coordinate(this.maxx,this.miny)};jsts.noding.snapround.HotPixel.prototype.scale=function(val){return Math.round(val*this.scaleFactor)};jsts.noding.snapround.HotPixel.prototype.intersects=function(p0,p1){if(this.scaleFactor===1)return this.intersectsScaled(p0,p1);this.copyScaled(p0,this.p0Scaled);this.copyScaled(p1,this.p1Scaled);return this.intersectsScaled(this.p0Scaled,this.p1Scaled)};jsts.noding.snapround.HotPixel.prototype.copyScaled=function(p,pScaled){pScaled.x=this.scale(p.x);pScaled.y=this.scale(p.y)};jsts.noding.snapround.HotPixel.prototype.intersectsScaled=function(p0,p1){var segMinx=Math.min(p0.x,p1.x);var segMaxx=Math.max(p0.x,p1.x);var segMiny=Math.min(p0.y,p1.y);var segMaxy=Math.max(p0.y,p1.y);var isOutsidePixelEnv=this.maxxsegMaxx||this.maxysegMaxy;if(isOutsidePixelEnv)return false;var intersects=this.intersectsToleranceSquare(p0,p1);jsts.util.Assert.isTrue(!(isOutsidePixelEnv&&intersects),"Found bad envelope test");return intersects};jsts.noding.snapround.HotPixel.prototype.intersectsToleranceSquare=function(p0,p1){var intersectsLeft=false;var intersectsBottom=false;this.li.computeIntersection(p0,p1,this.corner[0],this.corner[1]);if(this.li.isProper())return true;this.li.computeIntersection(p0,p1,this.corner[1],this.corner[2]);if(this.li.isProper())return true;if(this.li.hasIntersection())intersectsLeft=true;this.li.computeIntersection(p0,p1,this.corner[2],this.corner[3]);if(this.li.isProper())return true;if(this.li.hasIntersection())intersectsBottom=true;this.li.computeIntersection(p0,p1,this.corner[3],this.corner[0]);if(this.li.isProper())return true;if(intersectsLeft&&intersectsBottom)return true;if(p0.equals(this.pt))return true;if(p1.equals(this.pt))return true;return false};jsts.noding.snapround.HotPixel.prototype.intersectsPixelClosure=function(p0,p1){this.li.computeIntersection(p0,p1,this.corner[0],this.corner[1]);if(this.li.hasIntersection())return true;this.li.computeIntersection(p0,p1,this.corner[1],this.corner[2]);if(this.li.hasIntersection())return true;this.li.computeIntersection(p0,p1,this.corner[2],this.corner[3]);if(this.li.hasIntersection())return true;this.li.computeIntersection(p0,p1,this.corner[3],this.corner[0]);if(this.li.hasIntersection())return true;return false};jsts.noding.snapround.HotPixel.prototype.addSnappedNode=function(segStr,segIndex){var p0=segStr.getCoordinate(segIndex);var p1=segStr.getCoordinate(segIndex+1);if(this.intersects(p0,p1)){segStr.addIntersection(this.getCoordinate(),segIndex);return true}return false};jsts.operation.buffer.BufferInputLineSimplifier=function(inputLine){this.inputLine=inputLine};jsts.operation.buffer.BufferInputLineSimplifier.simplify=function(inputLine,distanceTol){var simp=new jsts.operation.buffer.BufferInputLineSimplifier(inputLine);return simp.simplify(distanceTol)};jsts.operation.buffer.BufferInputLineSimplifier.INIT=0;jsts.operation.buffer.BufferInputLineSimplifier.DELETE=1;jsts.operation.buffer.BufferInputLineSimplifier.KEEP=1;jsts.operation.buffer.BufferInputLineSimplifier.prototype.inputLine=null;jsts.operation.buffer.BufferInputLineSimplifier.prototype.distanceTol=null;jsts.operation.buffer.BufferInputLineSimplifier.prototype.isDeleted=null;jsts.operation.buffer.BufferInputLineSimplifier.prototype.angleOrientation=jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE;jsts.operation.buffer.BufferInputLineSimplifier.prototype.simplify=function(distanceTol){this.distanceTol=Math.abs(distanceTol);if(distanceTol<0)this.angleOrientation=jsts.algorithm.CGAlgorithms.CLOCKWISE;this.isDeleted=[];this.isDeleted.length=this.inputLine.length;var isChanged=false;do{isChanged=this.deleteShallowConcavities()}while(isChanged);return this.collapseLine()};jsts.operation.buffer.BufferInputLineSimplifier.prototype.deleteShallowConcavities=function(){var index=1;var maxIndex=this.inputLine.length-1;var midIndex=this.findNextNonDeletedIndex(index);var lastIndex=this.findNextNonDeletedIndex(midIndex);var isChanged=false;while(lastIndexpe.xValue){return 1}if(this.eventTypepe.eventType){return 1}return 0};jsts.geom.CoordinateList=function(coord,allowRepeated){javascript.util.ArrayList.apply(this,arguments);allowRepeated=allowRepeated===undefined?true:allowRepeated;if(coord!==undefined){this.add(coord,allowRepeated)}};jsts.geom.CoordinateList.prototype=new javascript.util.ArrayList;jsts.geom.CoordinateList.prototype.add=function(){if(arguments.length>1){return this.addCoordinates.apply(this,arguments)}else{return javascript.util.ArrayList.prototype.add.apply(this,arguments)}};jsts.geom.CoordinateList.prototype.addCoordinates=function(coord,allowRepeated,direction){if(coord instanceof jsts.geom.Coordinate){return this.addCoordinate.apply(this,arguments)}else if(typeof coord==="number"){return this.insertCoordinate.apply(this,arguments)}direction=direction||true;if(direction){for(var i=0;i=0;i--){this.addCoordinate(coord[i],allowRepeated)}}return true};jsts.geom.CoordinateList.prototype.addCoordinate=function(coord,allowRepeated){if(!allowRepeated){if(this.size()>=1){var last=this.get(this.size()-1);if(last.equals2D(coord))return}}this.add(coord)};jsts.geom.CoordinateList.prototype.insertCoordinate=function(index,coord,allowRepeated){if(!allowRepeated){var before=index>0?index-1:-1;if(before!==-1&&this.get(before).equals2D(coord)){return}var after=index0){this.addCoordinate(new jsts.geom.Coordinate(this.get(0)),false)}};jsts.geom.CoordinateList.prototype.toArray=function(){var i,il,arr;i=0,il=this.size(),arr=[];for(i;i=8&&this.bufParams.getJoinStyle()===jsts.operation.buffer.BufferParameters.JOIN_ROUND){this.closingSegLengthFactor=jsts.operation.buffer.OffsetSegmentGenerator.MAX_CLOSING_SEG_LEN_FACTOR}this.init(distance)};jsts.operation.buffer.OffsetSegmentGenerator.OFFSET_SEGMENT_SEPARATION_FACTOR=.001;jsts.operation.buffer.OffsetSegmentGenerator.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001;jsts.operation.buffer.OffsetSegmentGenerator.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6;jsts.operation.buffer.OffsetSegmentGenerator.MAX_CLOSING_SEG_LEN_FACTOR=80;jsts.operation.buffer.OffsetSegmentGenerator.prototype.maxCurveSegmentError=0;jsts.operation.buffer.OffsetSegmentGenerator.prototype.filletAngleQuantum=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.closingSegLengthFactor=1;jsts.operation.buffer.OffsetSegmentGenerator.prototype.segList=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.distance=0;jsts.operation.buffer.OffsetSegmentGenerator.prototype.precisionModel=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.bufParams=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.li=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.s0=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.s1=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.s2=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.seg0=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.seg1=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.offset0=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.offset1=null;jsts.operation.buffer.OffsetSegmentGenerator.prototype.side=0;jsts.operation.buffer.OffsetSegmentGenerator.prototype.hasNarrowConcaveAngle=false;jsts.operation.buffer.OffsetSegmentGenerator.prototype.hasNarrowConcaveAngle=function(){return this.hasNarrowConcaveAngle};jsts.operation.buffer.OffsetSegmentGenerator.prototype.init=function(distance){this.distance=distance;this.maxCurveSegmentError=this.distance*(1-Math.cos(this.filletAngleQuantum/2));this.segList=new jsts.operation.buffer.OffsetSegmentString;this.segList.setPrecisionModel(this.precisionModel);this.segList.setMinimumVertexDistance(this.distance*jsts.operation.buffer.OffsetSegmentGenerator.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.initSideSegments=function(s1,s2,side){this.s1=s1;this.s2=s2;this.side=side;this.seg1.setCoordinates(this.s1,this.s2);this.computeOffsetSegment(this.seg1,this.side,this.distance,this.offset1)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.getCoordinates=function(){return this.segList.getCoordinates()};jsts.operation.buffer.OffsetSegmentGenerator.prototype.closeRing=function(){this.segList.closeRing()};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addSegments=function(pt,isForward){this.segList.addPts(pt,isForward)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addFirstSegment=function(){this.segList.addPt(this.offset1.p0)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addLastSegment=function(){this.segList.addPt(this.offset1.p1)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addNextSegment=function(p,addStartPoint){this.s0=this.s1;this.s1=this.s2;this.s2=p;this.seg0.setCoordinates(this.s0,this.s1);this.computeOffsetSegment(this.seg0,this.side,this.distance,this.offset0);this.seg1.setCoordinates(this.s1,this.s2);this.computeOffsetSegment(this.seg1,this.side,this.distance,this.offset1);if(this.s1.equals(this.s2))return;var orientation=jsts.algorithm.CGAlgorithms.computeOrientation(this.s0,this.s1,this.s2);var outsideTurn=orientation===jsts.algorithm.CGAlgorithms.CLOCKWISE&&this.side===jsts.geomgraph.Position.LEFT||orientation===jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE&&this.side===jsts.geomgraph.Position.RIGHT;if(orientation==0){this.addCollinear(addStartPoint)}else if(outsideTurn){this.addOutsideTurn(orientation,addStartPoint)}else{this.addInsideTurn(orientation,addStartPoint)}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addCollinear=function(addStartPoint){this.li.computeIntersection(this.s0,this.s1,this.s1,this.s2);var numInt=this.li.getIntersectionNum();if(numInt>=2){if(this.bufParams.getJoinStyle()===jsts.operation.buffer.BufferParameters.JOIN_BEVEL||this.bufParams.getJoinStyle()===jsts.operation.buffer.BufferParameters.JOIN_MITRE){if(addStartPoint)this.segList.addPt(this.offset0.p1);this.segList.addPt(this.offset1.p0)}else{this.addFillet(this.s1,this.offset0.p1,this.offset1.p0,jsts.algorithm.CGAlgorithms.CLOCKWISE,this.distance)}}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addOutsideTurn=function(orientation,addStartPoint){if(this.offset0.p1.distance(this.offset1.p0)0){var mid0=new jsts.geom.Coordinate((this.closingSegLengthFactor*this.offset0.p1.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset0.p1.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(mid0);var mid1=new jsts.geom.Coordinate((this.closingSegLengthFactor*this.offset1.p0.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset1.p0.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(mid1)}else{this.segList.addPt(this.s1)}this.segList.addPt(this.offset1.p0)}}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.computeOffsetSegment=function(seg,side,distance,offset){var sideSign=side===jsts.geomgraph.Position.LEFT?1:-1;var dx=seg.p1.x-seg.p0.x;var dy=seg.p1.y-seg.p0.y;var len=Math.sqrt(dx*dx+dy*dy);var ux=sideSign*distance*dx/len;var uy=sideSign*distance*dy/len;offset.p0.x=seg.p0.x-uy;offset.p0.y=seg.p0.y+ux;offset.p1.x=seg.p1.x-uy;offset.p1.y=seg.p1.y+ux};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addLineEndCap=function(p0,p1){var seg=new jsts.geom.LineSegment(p0,p1);var offsetL=new jsts.geom.LineSegment;this.computeOffsetSegment(seg,jsts.geomgraph.Position.LEFT,this.distance,offsetL);var offsetR=new jsts.geom.LineSegment;this.computeOffsetSegment(seg,jsts.geomgraph.Position.RIGHT,this.distance,offsetR);var dx=p1.x-p0.x;var dy=p1.y-p0.y;var angle=Math.atan2(dy,dx);switch(this.bufParams.getEndCapStyle()){case jsts.operation.buffer.BufferParameters.CAP_ROUND:this.segList.addPt(offsetL.p1);this.addFillet(p1,angle+Math.PI/2,angle-Math.PI/2,jsts.algorithm.CGAlgorithms.CLOCKWISE,this.distance);this.segList.addPt(offsetR.p1);break;case jsts.operation.buffer.BufferParameters.CAP_FLAT:this.segList.addPt(offsetL.p1);this.segList.addPt(offsetR.p1);break;case jsts.operation.buffer.BufferParameters.CAP_SQUARE:var squareCapSideOffset=new jsts.geom.Coordinate;squareCapSideOffset.x=Math.abs(this.distance)*Math.cos(angle);squareCapSideOffset.y=Math.abs(this.distance)*Math.sin(angle);var squareCapLOffset=new jsts.geom.Coordinate(offsetL.p1.x+squareCapSideOffset.x,offsetL.p1.y+squareCapSideOffset.y);var squareCapROffset=new jsts.geom.Coordinate(offsetR.p1.x+squareCapSideOffset.x,offsetR.p1.y+squareCapSideOffset.y);this.segList.addPt(squareCapLOffset);this.segList.addPt(squareCapROffset);break}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addMitreJoin=function(p,offset0,offset1,distance){var isMitreWithinLimit=true;var intPt=null;try{intPt=jsts.algorithm.HCoordinate.intersection(offset0.p0,offset0.p1,offset1.p0,offset1.p1);var mitreRatio=distance<=0?1:intPt.distance(p)/Math.abs(distance);if(mitreRatio>this.bufParams.getMitreLimit())this.isMitreWithinLimit=false}catch(e){if(e instanceof jsts.error.NotRepresentableError){intPt=new jsts.geom.Coordinate(0,0);this.isMitreWithinLimit=false}}if(isMitreWithinLimit){this.segList.addPt(intPt)}else{this.addLimitedMitreJoin(offset0,offset1,distance,bufParams.getMitreLimit())}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addLimitedMitreJoin=function(offset0,offset1,distance,mitreLimit){var basePt=this.seg0.p1;var ang0=jsts.algorithm.Angle.angle(basePt,this.seg0.p0);var ang1=jsts.algorithm.Angle.angle(basePt,this.seg1.p1);var angDiff=jsts.algorithm.Angle.angleBetweenOriented(this.seg0.p0,basePt,this.seg1.p1);var angDiffHalf=angDiff/2;var midAng=jsts.algorithm.Angle.normalize(ang0+angDiffHalf);var mitreMidAng=jsts.algorithm.Angle.normalize(midAng+Math.PI);var mitreDist=mitreLimit*distance;var bevelDelta=mitreDist*Math.abs(Math.sin(angDiffHalf));var bevelHalfLen=distance-bevelDelta;var bevelMidX=basePt.x+mitreDist*Math.cos(mitreMidAng);var bevelMidY=basePt.y+mitreDist*Math.sin(mitreMidAng);var bevelMidPt=new jsts.geom.Coordinate(bevelMidX,bevelMidY);var mitreMidLine=new jsts.geom.LineSegment(basePt,bevelMidPt);var bevelEndLeft=mitreMidLine.pointAlongOffset(1,bevelHalfLen);var bevelEndRight=mitreMidLine.pointAlongOffset(1,-bevelHalfLen);if(this.side==jsts.geomgraph.Position.LEFT){this.segList.addPt(bevelEndLeft);this.segList.addPt(bevelEndRight)}else{this.segList.addPt(bevelEndRight);this.segList.addPt(bevelEndLeft)}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addBevelJoin=function(offset0,offset1){this.segList.addPt(offset0.p1);this.segList.addPt(offset1.p0)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addFillet=function(p,p0,p1,direction,radius){if(!(p1 instanceof jsts.geom.Coordinate)){this.addFillet2.apply(this,arguments);return}var dx0=p0.x-p.x;var dy0=p0.y-p.y;var startAngle=Math.atan2(dy0,dx0);var dx1=p1.x-p.x;var dy1=p1.y-p.y;var endAngle=Math.atan2(dy1,dx1);if(direction===jsts.algorithm.CGAlgorithms.CLOCKWISE){if(startAngle<=endAngle)startAngle+=2*Math.PI}else{if(startAngle>=endAngle)startAngle-=2*Math.PI}this.segList.addPt(p0);this.addFillet(p,startAngle,endAngle,direction,radius);this.segList.addPt(p1)};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addFillet2=function(p,startAngle,endAngle,direction,radius){var directionFactor=direction===jsts.algorithm.CGAlgorithms.CLOCKWISE?-1:1;var totalAngle=Math.abs(startAngle-endAngle);var nSegs=parseInt(totalAngle/this.filletAngleQuantum+.5);if(nSegs<1)return;var initAngle,currAngleInc;initAngle=0;currAngleInc=totalAngle/nSegs;var currAngle=initAngle;var pt=new jsts.geom.Coordinate;while(currAnglex2){return x1}return x2};jsts.geomgraph.index.MonotoneChainEdge.prototype.computeIntersects=function(mce,si){for(var i=0;i=iPrev)pPrev=eiPrev.coord;var label=new jsts.geomgraph.Label(edge.getLabel());label.flip();var e=new jsts.geomgraph.EdgeEnd(edge,eiCurr.coord,pPrev,label);l.add(e)};jsts.operation.relate.EdgeEndBuilder.prototype.createEdgeEndForNext=function(edge,l,eiCurr,eiNext){var iNext=eiCurr.segmentIndex+1;if(iNext>=edge.getNumPoints()&&eiNext===null)return;var pNext=edge.getCoordinate(iNext);if(eiNext!==null&&eiNext.segmentIndex===eiCurr.segmentIndex)pNext=eiNext.coord;var e=new jsts.geomgraph.EdgeEnd(edge,eiCurr.coord,pNext,new jsts.geomgraph.Label(edge.getLabel()));l.add(e)}})();(function(){jsts.io.GeoJSONParser=function(geometryFactory){this.geometryFactory=geometryFactory||new jsts.geom.GeometryFactory;this.geometryTypes=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"]};jsts.io.GeoJSONParser.prototype.read=function(json){var obj;if(typeof json==="string"){obj=JSON.parse(json)}else{obj=json}var type=obj.type;if(!this.parse[type]){throw new Error("Unknown GeoJSON type: "+obj.type)}if(this.geometryTypes.indexOf(type)!=-1){return this.parse[type].apply(this,[obj.coordinates])}else if(type==="GeometryCollection"){return this.parse[type].apply(this,[obj.geometries])}return this.parse[type].apply(this,[obj])};jsts.io.GeoJSONParser.prototype.parse={Feature:function(obj){var feature={};for(var key in obj){feature[key]=obj[key]}if(obj.geometry){var type=obj.geometry.type;if(!this.parse[type]){throw new Error("Unknown GeoJSON type: "+obj.type)}feature.geometry=this.read(obj.geometry)}if(obj.bbox){feature.bbox=this.parse.bbox.apply(this,[obj.bbox])}return feature},FeatureCollection:function(obj){var featureCollection={};if(obj.features){featureCollection.features=[];for(var i=0;i0){return jsts.triangulate.quadedge.Vertex.LEFT}if(sa<0){return jsts.triangulate.quadedge.Vertex.RIGHT}if(a.getX()*b.getX()<0||a.getY()*b.getY()<0){return jsts.triangulate.quadedge.Vertex.BEHIND}if(a.magn()0};jsts.triangulate.quadedge.Vertex.prototype.rightOf=function(e){return this.isCCW(e.dest(),e.orig())};jsts.triangulate.quadedge.Vertex.prototype.leftOf=function(e){return this.isCCW(e.orig(),e.dest())};jsts.triangulate.quadedge.Vertex.prototype.bisector=function(a,b){var dx,dy,l1,l2;dx=b.getX()-a.getX();dy=b.getY()-a.getY();l1=new jsts.algorithm.HCoordinate(a.getX()+dx/2,a.getY()+dy/2,1);l2=new jsts.algorithm.HCoordinate(a.getX()-dy+dx/2,a.getY()+dx+dy/2,1);return new jsts.algorithm.HCoordinate(l1,l2)};jsts.triangulate.quadedge.Vertex.prototype.distance=function(v1,v2){return v1.p.distance(v2.p)};jsts.triangulate.quadedge.Vertex.prototype.circumRadiusRatio=function(b,c){var x,radius,edgeLength,el;x=this.circleCenter(b,c);radius=this.distance(x,b);edgeLength=this.distance(this,b);el=this.distance(b,c);if(el=1){pt=ring.getCoordinateN(0)}this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.RING_NOT_CLOSED,pt)}};jsts.operation.valid.IsValidOp.prototype.checkTooFewPoints=function(graph){if(graph.hasTooFewPoints){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.TOO_FEW_POINTS,graph.getInvalidPoint());return}};jsts.operation.valid.IsValidOp.prototype.checkConsistentArea=function(graph){var cat=new jsts.operation.valid.ConsistentAreaTester(graph);var isValidArea=cat.isNodeConsistentArea();if(!isValidArea){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.SELF_INTERSECTION,cat.getInvalidPoint());return}if(cat.hasDuplicateRings()){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.DUPLICATE_RINGS,cat.getInvalidPoint())}};jsts.operation.valid.IsValidOp.prototype.checkNoSelfIntersectingRings=function(graph){for(var i=graph.getEdgeIterator();i.hasNext();){var e=i.next();this.checkNoSelfIntersectingRing(e.getEdgeIntersectionList());if(this.validErr!=null){return}}};jsts.operation.valid.IsValidOp.prototype.checkNoSelfIntersectingRing=function(eiList){var nodeSet=[];var isFirst=true;for(var i=eiList.iterator();i.hasNext();){var ei=i.next();if(isFirst){isFirst=false;continue}if(nodeSet.indexOf(ei.coord)>=0){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.RING_SELF_INTERSECTION,ei.coord);return}else{nodeSet.push(ei.coord)}}};jsts.operation.valid.IsValidOp.prototype.checkHolesInShell=function(p,graph){var shell=p.getExteriorRing();var pir=new jsts.algorithm.MCPointInRing(shell);for(var i=0;i0){if(x2>0){return-sign}else{return sign}}else{if(x2>0){return sign}else{return-sign}}}if(y1===0||x2===0){if(y2>0){if(x1>0){return sign}else{return-sign}}else{if(x1>0){return-sign}else{return sign}}}if(0y2){sign=-sign;swap=x1;x1=x2;x2=swap;swap=y1;y1=y2;y2=swap}}else{if(y1<=-y2){sign=-sign;x2=-x2;y2=-y2}else{swap=x1;x1=-x2;x2=swap;swap=y1;y1=-y2;y2=swap}}}else{if(0=y2){x1=-x1;y1=-y1;x2=-x2;y2=-y2}else{sign=-sign;swap=-x1;x1=-x2;x2=swap;swap=-y1;y1=-y2;y2=swap}}}if(0x2){return sign}}else{return sign}}else{if(0=x2){sign=-sign;x1=-x1;x2=-x2}else{return-sign}}}while(true){count=count+1;k=Math.floor(x2/x1);x2=x2-k*x1;y2=y2-k*y1;if(y2<0){return-sign}if(y2>y1){return sign}if(x1>x2+x2){if(y1y2+y2){return-sign}else{x2=x1-x2;y2=y1-y2;sign=-sign}}if(y2===0){if(x2===0){return 0}else{return-sign}}if(x2===0){return sign}k=Math.floor(x1/x2);x1=x1-k*x2;y1=y1-k*y2;if(y1<0){return sign}if(y1>y2){return-sign}if(x2>x1+x1){if(y2y1+y1){return sign}else{x1=x2-x1;y1=y2-y1;sign=-sign}}if(y1===0){if(x1===0){return 0}else{return sign}}if(x1===0){return-sign}}};jsts.algorithm.RobustDeterminant.orientationIndex=function(p1,p2,q){var dx1=p2.x-p1.x;var dy1=p2.y-p1.y;var dx2=q.x-p2.x;var dy2=q.y-p2.y;return jsts.algorithm.RobustDeterminant.signOfDet2x2(dx1,dy1,dx2,dy2)};jsts.index.quadtree.NodeBase=function(){this.subnode=new Array(4);this.subnode[0]=null;this.subnode[1]=null;this.subnode[2]=null;this.subnode[3]=null;this.items=[]};jsts.index.quadtree.NodeBase.prototype.getSubnodeIndex=function(env,centre){var subnodeIndex=-1;if(env.getMinX()>=centre.x){if(env.getMinY()>=centre.y){subnodeIndex=3}if(env.getMaxY()<=centre.y){subnodeIndex=1}}if(env.getMaxX()<=centre.x){if(env.getMinY()>=centre.y){subnodeIndex=2}if(env.getMaxY()<=centre.y){subnodeIndex=0}}return subnodeIndex};jsts.index.quadtree.NodeBase.prototype.getItems=function(){return this.items};jsts.index.quadtree.NodeBase.prototype.hasItems=function(){return this.items.length>0};jsts.index.quadtree.NodeBase.prototype.add=function(item){this.items.push(item)};jsts.index.quadtree.NodeBase.prototype.remove=function(itemEnv,item){if(!this.isSearchMatch(itemEnv)){return false}var found=false,i=0;for(i;i<4;i++){if(this.subnode[i]!==null){found=this.subnode[i].remove(itemEnv,item);if(found){if(this.subnode[i].isPrunable()){this.subnode[i]=null}break}}}if(found){return found}if(this.items.indexOf(item)!==-1){for(var i=this.items.length-1;i>=0;i--){if(this.items[i]===item){this.items.splice(i,1)}}found=true}return found};jsts.index.quadtree.NodeBase.prototype.isPrunable=function(){return!(this.hasChildren()||this.hasItems())};jsts.index.quadtree.NodeBase.prototype.hasChildren=function(){var i=0;for(i;i<4;i++){if(this.subnode[i]!==null){return true}}return false};jsts.index.quadtree.NodeBase.prototype.isEmpty=function(){var isEmpty=true;if(this.items.length>0){isEmpty=false}var i=0;for(i;i<4;i++){if(this.subnode[i]!==null){if(!this.subnode[i].isEmpty()){isEmpty=false}}}return isEmpty};jsts.index.quadtree.NodeBase.prototype.addAllItems=function(resultItems){resultItems=resultItems.concat(this.items);var i=0;for(i;i<4;i++){if(this.subnode[i]!==null){resultItems=this.subnode[i].addAllItems(resultItems)}}return resultItems};jsts.index.quadtree.NodeBase.prototype.addAllItemsFromOverlapping=function(searchEnv,resultItems){if(!this.isSearchMatch(searchEnv)){return}resultItems=resultItems.concat(this.items);var i=0;for(i;i<4;i++){if(this.subnode[i]!==null){resultItems=this.subnode[i].addAllItemsFromOverlapping(searchEnv,resultItems)}}};jsts.index.quadtree.NodeBase.prototype.visit=function(searchEnv,visitor){if(!this.isSearchMatch(searchEnv)){return}this.visitItems(searchEnv,visitor);var i=0;for(i;i<4;i++){if(this.subnode[i]!==null){this.subnode[i].visit(searchEnv,visitor)}}};jsts.index.quadtree.NodeBase.prototype.visitItems=function(env,visitor){var i=0,il=this.items.length;for(i;imaxSubDepth){maxSubDepth=sqd}}}return maxSubDepth+1};jsts.index.quadtree.NodeBase.prototype.size=function(){var subSize=0,i=0;for(i;i<4;i++){if(this.subnode[i]!==null){subSize+=this.subnode[i].size()}}return subSize+this.items.length};jsts.index.quadtree.NodeBase.prototype.getNodeCount=function(){var subSize=0,i=0;for(i;i<4;i++){if(this.subnode[i]!==null){subSize+=this.subnode[i].size()}}return subSize+1};jsts.index.quadtree.Node=function(env,level){jsts.index.quadtree.NodeBase.prototype.constructor.apply(this,arguments);this.env=env;this.level=level;this.centre=new jsts.geom.Coordinate;this.centre.x=(env.getMinX()+env.getMaxX())/2;this.centre.y=(env.getMinY()+env.getMaxY())/2};jsts.index.quadtree.Node.prototype=new jsts.index.quadtree.NodeBase;jsts.index.quadtree.Node.createNode=function(env){var key,node;key=new jsts.index.quadtree.Key(env);node=new jsts.index.quadtree.Node(key.getEnvelope(),key.getLevel());return node};jsts.index.quadtree.Node.createExpanded=function(node,addEnv){var expandEnv=new jsts.geom.Envelope(addEnv),largerNode;if(node!==null){expandEnv.expandToInclude(node.env)}largerNode=jsts.index.quadtree.Node.createNode(expandEnv);if(node!==null){largerNode.insertNode(node)}return largerNode};jsts.index.quadtree.Node.prototype.getEnvelope=function(){return this.env};jsts.index.quadtree.Node.prototype.isSearchMatch=function(searchEnv){return this.env.intersects(searchEnv)};jsts.index.quadtree.Node.prototype.getNode=function(searchEnv){var subnodeIndex=this.getSubnodeIndex(searchEnv,this.centre),node;if(subnodeIndex!==-1){node=this.getSubnode(subnodeIndex);return node.getNode(searchEnv)}else{return this}};jsts.index.quadtree.Node.prototype.find=function(searchEnv){var subnodeIndex=this.getSubnodeIndex(searchEnv,this.centre),node;if(subnodeIndex===-1){return this}if(this.subnode[subnodeIndex]!==null){node=this.subnode[subnodeIndex];return node.find(searchEnv)}return this};jsts.index.quadtree.Node.prototype.insertNode=function(node){var index=this.getSubnodeIndex(node.env,this.centre),childNode;if(node.level===this.level-1){this.subnode[index]=node}else{childNode=this.createSubnode(index);childNode.insertNode(node);this.subnode[index]=childNode}};jsts.index.quadtree.Node.prototype.getSubnode=function(index){if(this.subnode[index]===null){this.subnode[index]=this.createSubnode(index)}return this.subnode[index]};jsts.index.quadtree.Node.prototype.createSubnode=function(index){var minx=0,maxx=0,miny=0,maxy=0,sqEnv,node;switch(index){case 0:minx=this.env.getMinX();maxx=this.centre.x;miny=this.env.getMinY();maxy=this.centre.y;break;case 1:minx=this.centre.x;maxx=this.env.getMaxX();miny=this.env.getMinY();maxy=this.centre.y;break;case 2:minx=this.env.getMinX();maxx=this.centre.x;miny=this.centre.y;maxy=this.env.getMaxY();break;case 3:minx=this.centre.x;maxx=this.env.getMaxX();miny=this.centre.y;maxy=this.env.getMaxY();break}sqEnv=new jsts.geom.Envelope(minx,maxx,miny,maxy);node=new jsts.index.quadtree.Node(sqEnv,this.level-1);return node};(function(){jsts.triangulate.quadedge.QuadEdge=function(){this.rot=null;this.vertex=null;this.next=null;this.data=null};var QuadEdge=jsts.triangulate.quadedge.QuadEdge;jsts.triangulate.quadedge.QuadEdge.makeEdge=function(o,d){var q0,q1,q2,q3,base;q0=new QuadEdge;q1=new QuadEdge;q2=new QuadEdge;q3=new QuadEdge;q0.rot=q1;q1.rot=q2;q2.rot=q3;q3.rot=q0;q0.setNext(q0);q1.setNext(q3);q2.setNext(q2);q3.setNext(q1);base=q0;base.setOrig(o);base.setDest(d);return base};jsts.triangulate.quadedge.QuadEdge.connect=function(a,b){var e=QuadEdge.makeEdge(a.dest(),b.orig());QuadEdge.splice(e,a.lNext());QuadEdge.splice(e.sym(),b);return e};jsts.triangulate.quadedge.QuadEdge.splice=function(a,b){var alpha,beta,t1,t2,t3,t4;alpha=a.oNext().rot;beta=b.oNext().rot;t1=b.oNext();t2=a.oNext();t3=beta.oNext();t4=alpha.oNext();a.setNext(t1);b.setNext(t2);alpha.setNext(t3);beta.setNext(t4)};jsts.triangulate.quadedge.QuadEdge.swap=function(e){var a,b;a=e.oPrev();b=e.sym().oPrev();QuadEdge.splice(e,a);QuadEdge.splice(e.sym(),b);QuadEdge.splice(e,a.lNext());QuadEdge.splice(e.sym(),b.lNext());e.setOrig(a.dest());e.setDest(b.dest())};jsts.triangulate.quadedge.QuadEdge.prototype.getPrimary=function(){if(this.orig().getCoordinate().compareTo(this.dest().getCoordinate())<=0){return this}else{return this.sym()}};jsts.triangulate.quadedge.QuadEdge.prototype.setData=function(data){this.data=data};jsts.triangulate.quadedge.QuadEdge.prototype.getData=function(){return this.data};jsts.triangulate.quadedge.QuadEdge.prototype.delete_jsts=function(){this.rot=null};jsts.triangulate.quadedge.QuadEdge.prototype.isLive=function(){return this.rot!==null};jsts.triangulate.quadedge.QuadEdge.prototype.setNext=function(next){this.next=next};jsts.triangulate.quadedge.QuadEdge.prototype.invRot=function(){return this.rot.sym()};jsts.triangulate.quadedge.QuadEdge.prototype.sym=function(){return this.rot.rot};jsts.triangulate.quadedge.QuadEdge.prototype.oNext=function(){return this.next};jsts.triangulate.quadedge.QuadEdge.prototype.oPrev=function(){return this.rot.next.rot};jsts.triangulate.quadedge.QuadEdge.prototype.dNext=function(){return this.sym().oNext().sym()};jsts.triangulate.quadedge.QuadEdge.prototype.dPrev=function(){return this.invRot().oNext().invRot()};jsts.triangulate.quadedge.QuadEdge.prototype.lNext=function(){return this.invRot().oNext().rot};jsts.triangulate.quadedge.QuadEdge.prototype.lPrev=function(){return this.next.sym()};jsts.triangulate.quadedge.QuadEdge.prototype.rNext=function(){return this.rot.next.invRot()};jsts.triangulate.quadedge.QuadEdge.prototype.rPrev=function(){return this.sym().oNext()};jsts.triangulate.quadedge.QuadEdge.prototype.setOrig=function(o){this.vertex=o};jsts.triangulate.quadedge.QuadEdge.prototype.setDest=function(d){this.sym().setOrig(d)};jsts.triangulate.quadedge.QuadEdge.prototype.orig=function(){return this.vertex};jsts.triangulate.quadedge.QuadEdge.prototype.dest=function(){return this.sym().orig()};jsts.triangulate.quadedge.QuadEdge.prototype.getLength=function(){return this.orig().getCoordinate().distance(dest().getCoordinate())};jsts.triangulate.quadedge.QuadEdge.prototype.equalsNonOriented=function(qe){if(this.equalsOriented(qe)){return true}if(this.equalsOriented(qe.sym())){return true}return false};jsts.triangulate.quadedge.QuadEdge.prototype.equalsOriented=function(qe){if(this.orig().getCoordinate().equals2D(qe.orig().getCoordinate())&&this.dest().getCoordinate().equals2D(qe.dest().getCoordinate())){return true}return false};jsts.triangulate.quadedge.QuadEdge.prototype.toLineSegment=function(){return new jsts.geom.LineSegment(this.vertex.getCoordinate(),this.dest().getCoordinate())};jsts.triangulate.quadedge.QuadEdge.prototype.toString=function(){var p0,p1;p0=this.vertex.getCoordinate();p1=this.dest().getCoordinate();return jsts.io.WKTWriter.toLineString(p0,p1)}})();(function(){var Assert=jsts.util.Assert;jsts.geomgraph.EdgeEnd=function(edge,p0,p1,label){this.edge=edge;if(p0&&p1){this.init(p0,p1)}if(label){this.label=label||null}};jsts.geomgraph.EdgeEnd.prototype.edge=null;jsts.geomgraph.EdgeEnd.prototype.label=null;jsts.geomgraph.EdgeEnd.prototype.node=null;jsts.geomgraph.EdgeEnd.prototype.p0=null;jsts.geomgraph.EdgeEnd.prototype.p1=null;jsts.geomgraph.EdgeEnd.prototype.dx=null;jsts.geomgraph.EdgeEnd.prototype.dy=null;jsts.geomgraph.EdgeEnd.prototype.quadrant=null;jsts.geomgraph.EdgeEnd.prototype.init=function(p0,p1){this.p0=p0;this.p1=p1;this.dx=p1.x-p0.x;this.dy=p1.y-p0.y;this.quadrant=jsts.geomgraph.Quadrant.quadrant(this.dx,this.dy);Assert.isTrue(!(this.dx===0&&this.dy===0),"EdgeEnd with identical endpoints found")};jsts.geomgraph.EdgeEnd.prototype.getEdge=function(){return this.edge};jsts.geomgraph.EdgeEnd.prototype.getLabel=function(){return this.label};jsts.geomgraph.EdgeEnd.prototype.getCoordinate=function(){return this.p0};jsts.geomgraph.EdgeEnd.prototype.getDirectedCoordinate=function(){return this.p1};jsts.geomgraph.EdgeEnd.prototype.getQuadrant=function(){return this.quadrant};jsts.geomgraph.EdgeEnd.prototype.getDx=function(){return this.dx};jsts.geomgraph.EdgeEnd.prototype.getDy=function(){return this.dy};jsts.geomgraph.EdgeEnd.prototype.setNode=function(node){this.node=node};jsts.geomgraph.EdgeEnd.prototype.getNode=function(){return this.node};jsts.geomgraph.EdgeEnd.prototype.compareTo=function(e){return this.compareDirection(e)};jsts.geomgraph.EdgeEnd.prototype.compareDirection=function(e){if(this.dx===e.dx&&this.dy===e.dy)return 0;if(this.quadrant>e.quadrant)return 1;if(this.quadrant0&&this.minIndexthis.minCoord.y&&pNext.y>this.minCoord.y&&orientation===jsts.algorithm.CGAlgorithms.CLOCKWISE){usePrev=true}if(usePrev){this.minIndex=this.minIndex-1}};jsts.operation.buffer.RightmostEdgeFinder.prototype.checkForRightmostCoordinate=function(de){var coord=de.getEdge().getCoordinates();for(var i=0;ithis.minCoord.x){this.minDe=de;this.minIndex=i;this.minCoord=coord[i]}}};jsts.operation.buffer.RightmostEdgeFinder.prototype.getRightmostSide=function(de,index){var side=this.getRightmostSideOfSegment(de,index);if(side<0)side=this.getRightmostSideOfSegment(de,index-1);if(side<0){this.minCoord=null;this.checkForRightmostCoordinate(de)}return side};jsts.operation.buffer.RightmostEdgeFinder.prototype.getRightmostSideOfSegment=function(de,i){var e=de.getEdge();var coord=e.getCoordinates();if(i<0||i+1>=coord.length)return-1;if(coord[i].y==coord[i+1].y)return-1;var pos=jsts.geomgraph.Position.LEFT;if(coord[i].y0};jsts.triangulate.IncrementalDelaunayTriangulator.prototype.insertSites=function(vertices){var i=0,il=vertices.length,v;for(i;i0){cent.x=this.cg3.x/3/this.areasum2;cent.y=this.cg3.y/3/this.areasum2}else{cent.x=this.centSum.x/this.totalLength;cent.y=this.centSum.y/this.totalLength}return cent};jsts.algorithm.CentroidArea.prototype.setBasePoint=function(basePt){if(this.basePt==null)this.basePt=basePt};jsts.algorithm.CentroidArea.prototype.add3=function(poly){this.addShell(poly.getExteriorRing().getCoordinates());for(var i=0;ix2){return x1}return x2};jsts.geomgraph.index.SweepLineSegment.prototype.computeIntersections=function(ss,si){si.addIntersections(this.edge,this.ptIndex,ss.edge,ss.ptIndex)};jsts.index.quadtree.Root=function(){jsts.index.quadtree.NodeBase.prototype.constructor.apply(this,arguments);this.origin=new jsts.geom.Coordinate(0,0)};jsts.index.quadtree.Root.prototype=new jsts.index.quadtree.NodeBase;jsts.index.quadtree.Root.prototype.insert=function(itemEnv,item){var index=this.getSubnodeIndex(itemEnv,this.origin);if(index===-1){this.add(item);return}var node=this.subnode[index];if(node===null||!node.getEnvelope().contains(itemEnv)){var largerNode=jsts.index.quadtree.Node.createExpanded(node,itemEnv);this.subnode[index]=largerNode}this.insertContained(this.subnode[index],itemEnv,item)};jsts.index.quadtree.Root.prototype.insertContained=function(tree,itemEnv,item){var isZeroX,isZeroY,node;isZeroX=jsts.index.IntervalSize.isZeroWidth(itemEnv.getMinX(),itemEnv.getMaxX());isZeroY=jsts.index.IntervalSize.isZeroWidth(itemEnv.getMinY(),itemEnv.getMaxY());if(isZeroX||isZeroY){node=tree.find(itemEnv)}else{node=tree.getNode(itemEnv)}node.add(item)};jsts.index.quadtree.Root.prototype.isSearchMatch=function(searchEnv){return true};jsts.geomgraph.index.MonotoneChainIndexer=function(){};jsts.geomgraph.index.MonotoneChainIndexer.toIntArray=function(list){var array=[];for(var i=list.iterator();i.hasNext();){var element=i.next();array.push(element)}return array};jsts.geomgraph.index.MonotoneChainIndexer.prototype.getChainStartIndices=function(pts){var start=0;var startIndexList=new javascript.util.ArrayList;startIndexList.add(start);do{var last=this.findChainEnd(pts,start);startIndexList.add(last);start=last}while(start=list.length){return null}return list[index]};jsts.operation.union.CascadedPolygonUnion.prototype.reduceToGeometries=function(geomTree){var geoms=[];for(var i=0,l=geomTree.length;i=0;i--){segGen.addNextSegment(simp2[i],true)}segGen.addLastSegment();segGen.addLineEndCap(simp2[1],simp2[0]);segGen.closeRing()};jsts.operation.buffer.OffsetCurveBuilder.prototype.computeSingleSidedBufferCurve=function(inputPts,isRightSide,segGen){var distTol=jsts.operation.buffer.OffsetCurveBuilder.simplifyTolerance(this.distance);if(isRightSide){segGen.addSegments(inputPts,true);var simp2=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,-distTol);var n2=simp2.length-1;segGen.initSideSegments(simp2[n2],simp2[n2-1],jsts.geomgraph.Position.LEFT);segGen.addFirstSegment();for(var i=n2-2;i>=0;i--){segGen.addNextSegment(simp2[i],true)}}else{segGen.addSegments(inputPts,false);var simp1=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,distTol);var n1=simp1.length-1;segGen.initSideSegments(simp1[0],simp1[1],jsts.geomgraph.Position.LEFT);segGen.addFirstSegment();for(var i=2;i<=n1;i++){segGen.addNextSegment(simp1[i],true)}}segGen.addLastSegment();segGen.closeRing()};jsts.operation.buffer.OffsetCurveBuilder.prototype.computeOffsetCurve=function(inputPts,isRightSide,segGen){var distTol=jsts.operation.buffer.OffsetCurveBuilder.simplifyTolerance(this.distance);if(isRightSide){var simp2=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,-distTol);var n2=simp2.length-1;segGen.initSideSegments(simp2[n2],simp2[n2-1],jsts.geomgraph.Position.LEFT);segGen.addFirstSegment();for(var i=n2-2;i>=0;i--){segGen.addNextSegment(simp2[i],true)}}else{var simp1=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,distTol);var n1=simp1.length-1;segGen.initSideSegments(simp1[0],simp1[1],jsts.geomgraph.Position.LEFT);segGen.addFirstSegment();for(var i=2;i<=n1;i++){segGen.addNextSegment(simp1[i],true)}}segGen.addLastSegment()};jsts.operation.buffer.OffsetCurveBuilder.prototype.computeRingBufferCurve=function(inputPts,side,segGen){var distTol=jsts.operation.buffer.OffsetCurveBuilder.simplifyTolerance(this.distance);if(side===jsts.geomgraph.Position.RIGHT)distTol=-distTol;var simp=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,distTol);var n=simp.length-1;segGen.initSideSegments(simp[n-1],simp[0],side);for(var i=1;i<=n;i++){var addStartPoint=i!==1;segGen.addNextSegment(simp[i],addStartPoint)}segGen.closeRing()};(function(){var HotPixelSnapAction=function(hotPixel,parentEdge,vertexIndex){this.hotPixel=hotPixel;this.parentEdge=parentEdge;this.vertexIndex=vertexIndex};HotPixelSnapAction.prototype=new jsts.index.chain.MonotoneChainSelectAction;HotPixelSnapAction.constructor=HotPixelSnapAction;HotPixelSnapAction.prototype.hotPixel=null;HotPixelSnapAction.prototype.parentEdge=null;HotPixelSnapAction.prototype.vertexIndex=null;HotPixelSnapAction.prototype._isNodeAdded=false;HotPixelSnapAction.prototype.isNodeAdded=function(){return this._isNodeAdded};HotPixelSnapAction.prototype.select=function(mc,startIndex){var ss=mc.getContext();if(this.parentEdge!==null){if(ss===this.parentEdge&&startIndex===this.vertexIndex)return}this._isNodeAdded=this.hotPixel.addSnappedNode(ss,startIndex)};jsts.noding.snapround.MCIndexPointSnapper=function(index){this.index=index};jsts.noding.snapround.MCIndexPointSnapper.prototype.index=null;jsts.noding.snapround.MCIndexPointSnapper.prototype.snap=function(hotPixel,parentEdge,vertexIndex){if(arguments.length===1){this.snap2.apply(this,arguments);return}var pixelEnv=hotPixel.getSafeEnvelope();var hotPixelSnapAction=new HotPixelSnapAction(hotPixel,parentEdge,vertexIndex);this.index.query(pixelEnv,{visitItem:function(testChain){testChain.select(pixelEnv,hotPixelSnapAction)}});return hotPixelSnapAction.isNodeAdded()};jsts.noding.snapround.MCIndexPointSnapper.prototype.snap2=function(hotPixel){return this.snap(hotPixel,null,-1)}})();(function(){var NodeBase=function(){this.items=new javascript.util.ArrayList;this.subnode=[null,null]};NodeBase.getSubnodeIndex=function(interval,centre){var subnodeIndex=-1;if(interval.min>=centre){subnodeIndex=1}if(interval.max<=centre){subnodeIndex=0}return subnodeIndex};NodeBase.prototype.getItems=function(){return this.items};NodeBase.prototype.add=function(item){this.items.add(item)};NodeBase.prototype.addAllItems=function(items){items.addAll(this.items);var i=0,il=2;for(i;imaxSubDepth){maxSubDepth=sqd}}}return maxSubDepth+1};NodeBase.prototype.size=function(){var subSize=0,i=0,il=2;for(i;i=0){if(dy>=0)return jsts.geomgraph.Quadrant.NE;else return jsts.geomgraph.Quadrant.SE}else{if(dy>=0)return jsts.geomgraph.Quadrant.NW;else return jsts.geomgraph.Quadrant.SW}};jsts.geomgraph.Quadrant.quadrant2=function(p0,p1){if(p1.x===p0.x&&p1.y===p0.y)throw new jsts.error.IllegalArgumentError("Cannot compute the quadrant for two identical points "+p0);if(p1.x>=p0.x){if(p1.y>=p0.y)return jsts.geomgraph.Quadrant.NE;else return jsts.geomgraph.Quadrant.SE}else{if(p1.y>=p0.y)return jsts.geomgraph.Quadrant.NW;else return jsts.geomgraph.Quadrant.SW}};jsts.geomgraph.Quadrant.isOpposite=function(quad1,quad2){if(quad1===quad2)return false;var diff=(quad1-quad2+4)%4;if(diff===2)return true;return false};jsts.geomgraph.Quadrant.commonHalfPlane=function(quad1,quad2){if(quad1===quad2)return quad1;var diff=(quad1-quad2+4)%4;if(diff===2)return-1;var min=quad1quad2?quad1:quad2;if(min===0&&max===3)return 3;return min};jsts.geomgraph.Quadrant.isInHalfPlane=function(quad,halfPlane){if(halfPlane===jsts.geomgraph.Quadrant.SE){return quad===jsts.geomgraph.Quadrant.SE||quad===jsts.geomgraph.Quadrant.SW}return quad===halfPlane||quad===halfPlane+1};jsts.geomgraph.Quadrant.isNorthern=function(quad){return quad===jsts.geomgraph.Quadrant.NE||quad===jsts.geomgraph.Quadrant.NW};jsts.operation.valid.ConsistentAreaTester=function(geomGraph){this.geomGraph=geomGraph;this.li=new jsts.algorithm.RobustLineIntersector;this.nodeGraph=new jsts.operation.relate.RelateNodeGraph;this.invalidPoint=null};jsts.operation.valid.ConsistentAreaTester.prototype.getInvalidPoint=function(){return this.invalidPoint};jsts.operation.valid.ConsistentAreaTester.prototype.isNodeConsistentArea=function(){var intersector=this.geomGraph.computeSelfNodes(this.li,true);if(intersector.hasProperIntersection()){this.invalidPoint=intersector.getProperIntersectionPoint();return false}this.nodeGraph.build(this.geomGraph);return this.isNodeEdgeAreaLabelsConsistent()};jsts.operation.valid.ConsistentAreaTester.prototype.isNodeEdgeAreaLabelsConsistent=function(){for(var nodeIt=this.nodeGraph.getNodeIterator();nodeIt.hasNext();){var node=nodeIt.next();if(!node.getEdges().isAreaLabelsConsistent(this.geomGraph)){this.invalidPoint=node.getCoordinate().clone();return false}}return true};jsts.operation.valid.ConsistentAreaTester.prototype.hasDuplicateRings=function(){for(var nodeIt=this.nodeGraph.getNodeIterator();nodeIt.hasNext();){var node=nodeIt.next(); for(var i=node.getEdges().iterator();i.hasNext();){var eeb=i.next();if(eeb.getEdgeEnds().length>1){invalidPoint=eeb.getEdge().getCoordinate(0);return true}}}return false};jsts.operation.relate.RelateNode=function(coord,edges){jsts.geomgraph.Node.apply(this,arguments)};jsts.operation.relate.RelateNode.prototype=new jsts.geomgraph.Node;jsts.operation.relate.RelateNode.prototype.computeIM=function(im){im.setAtLeastIfValid(this.label.getLocation(0),this.label.getLocation(1),0)};jsts.operation.relate.RelateNode.prototype.updateIMFromEdges=function(im){this.edges.updateIM(im)};(function(){var Location=jsts.geom.Location;var Position=jsts.geomgraph.Position;var EdgeEnd=jsts.geomgraph.EdgeEnd;jsts.geomgraph.DirectedEdge=function(edge,isForward){EdgeEnd.call(this,edge);this.depth=[0,-999,-999];this._isForward=isForward;if(isForward){this.init(edge.getCoordinate(0),edge.getCoordinate(1))}else{var n=edge.getNumPoints()-1;this.init(edge.getCoordinate(n),edge.getCoordinate(n-1))}this.computeDirectedLabel()};jsts.geomgraph.DirectedEdge.prototype=new EdgeEnd;jsts.geomgraph.DirectedEdge.constructor=jsts.geomgraph.DirectedEdge;jsts.geomgraph.DirectedEdge.depthFactor=function(currLocation,nextLocation){if(currLocation===Location.EXTERIOR&&nextLocation===Location.INTERIOR)return 1;else if(currLocation===Location.INTERIOR&&nextLocation===Location.EXTERIOR)return-1;return 0};jsts.geomgraph.DirectedEdge.prototype._isForward=null;jsts.geomgraph.DirectedEdge.prototype._isInResult=false;jsts.geomgraph.DirectedEdge.prototype._isVisited=false;jsts.geomgraph.DirectedEdge.prototype.sym=null;jsts.geomgraph.DirectedEdge.prototype.next=null;jsts.geomgraph.DirectedEdge.prototype.nextMin=null;jsts.geomgraph.DirectedEdge.prototype.edgeRing=null;jsts.geomgraph.DirectedEdge.prototype.minEdgeRing=null;jsts.geomgraph.DirectedEdge.prototype.depth=null;jsts.geomgraph.DirectedEdge.prototype.getEdge=function(){return this.edge};jsts.geomgraph.DirectedEdge.prototype.setInResult=function(isInResult){this._isInResult=isInResult};jsts.geomgraph.DirectedEdge.prototype.isInResult=function(){return this._isInResult};jsts.geomgraph.DirectedEdge.prototype.isVisited=function(){return this._isVisited};jsts.geomgraph.DirectedEdge.prototype.setVisited=function(isVisited){this._isVisited=isVisited};jsts.geomgraph.DirectedEdge.prototype.setEdgeRing=function(edgeRing){this.edgeRing=edgeRing};jsts.geomgraph.DirectedEdge.prototype.getEdgeRing=function(){return this.edgeRing};jsts.geomgraph.DirectedEdge.prototype.setMinEdgeRing=function(minEdgeRing){this.minEdgeRing=minEdgeRing};jsts.geomgraph.DirectedEdge.prototype.getMinEdgeRing=function(){return this.minEdgeRing};jsts.geomgraph.DirectedEdge.prototype.getDepth=function(position){return this.depth[position]};jsts.geomgraph.DirectedEdge.prototype.setDepth=function(position,depthVal){if(this.depth[position]!==-999){if(this.depth[position]!==depthVal)throw new jsts.error.TopologyError("assigned depths do not match",this.getCoordinate())}this.depth[position]=depthVal};jsts.geomgraph.DirectedEdge.prototype.getDepthDelta=function(){var depthDelta=this.edge.getDepthDelta();if(!this._isForward)depthDelta=-depthDelta;return depthDelta};jsts.geomgraph.DirectedEdge.prototype.setVisitedEdge=function(isVisited){this.setVisited(isVisited);this.sym.setVisited(isVisited)};jsts.geomgraph.DirectedEdge.prototype.getSym=function(){return this.sym};jsts.geomgraph.DirectedEdge.prototype.isForward=function(){return this._isForward};jsts.geomgraph.DirectedEdge.prototype.setSym=function(de){this.sym=de};jsts.geomgraph.DirectedEdge.prototype.getNext=function(){return this.next};jsts.geomgraph.DirectedEdge.prototype.setNext=function(next){this.next=next};jsts.geomgraph.DirectedEdge.prototype.getNextMin=function(){return this.nextMin};jsts.geomgraph.DirectedEdge.prototype.setNextMin=function(nextMin){this.nextMin=nextMin};jsts.geomgraph.DirectedEdge.prototype.isLineEdge=function(){var isLine=this.label.isLine(0)||this.label.isLine(1);var isExteriorIfArea0=!this.label.isArea(0)||this.label.allPositionsEqual(0,Location.EXTERIOR);var isExteriorIfArea1=!this.label.isArea(1)||this.label.allPositionsEqual(1,Location.EXTERIOR);return isLine&&isExteriorIfArea0&&isExteriorIfArea1};jsts.geomgraph.DirectedEdge.prototype.isInteriorAreaEdge=function(){var isInteriorAreaEdge=true;for(var i=0;i<2;i++){if(!(this.label.isArea(i)&&this.label.getLocation(i,Position.LEFT)===Location.INTERIOR&&this.label.getLocation(i,Position.RIGHT)===Location.INTERIOR)){isInteriorAreaEdge=false}}return isInteriorAreaEdge};jsts.geomgraph.DirectedEdge.prototype.computeDirectedLabel=function(){this.label=new jsts.geomgraph.Label(this.edge.getLabel());if(!this._isForward)this.label.flip()};jsts.geomgraph.DirectedEdge.prototype.setEdgeDepths=function(position,depth){var depthDelta=this.getEdge().getDepthDelta();if(!this._isForward)depthDelta=-depthDelta;var directionFactor=1;if(position===Position.LEFT)directionFactor=-1;var oppositePos=Position.opposite(position);var delta=depthDelta*directionFactor;var oppositeDepth=depth+delta;this.setDepth(position,depth);this.setDepth(oppositePos,oppositeDepth)}})();jsts.operation.distance.DistanceOp=function(g0,g1,terminateDistance){this.ptLocator=new jsts.algorithm.PointLocator;this.geom=[];this.geom[0]=g0;this.geom[1]=g1;this.terminateDistance=terminateDistance};jsts.operation.distance.DistanceOp.prototype.geom=null;jsts.operation.distance.DistanceOp.prototype.terminateDistance=0;jsts.operation.distance.DistanceOp.prototype.ptLocator=null;jsts.operation.distance.DistanceOp.prototype.minDistanceLocation=null;jsts.operation.distance.DistanceOp.prototype.minDistance=Number.MAX_VALUE;jsts.operation.distance.DistanceOp.distance=function(g0,g1){var distOp=new jsts.operation.distance.DistanceOp(g0,g1,0);return distOp.distance()};jsts.operation.distance.DistanceOp.isWithinDistance=function(g0,g1,distance){var distOp=new jsts.operation.distance.DistanceOp(g0,g1,distance);return distOp.distance()<=distance};jsts.operation.distance.DistanceOp.nearestPoints=function(g0,g1){var distOp=new jsts.operation.distance.DistanceOp(g0,g1,0);return distOp.nearestPoints()};jsts.operation.distance.DistanceOp.prototype.distance=function(){if(this.geom[0]===null||this.geom[1]===null)throw new jsts.error.IllegalArgumentError("null geometries are not supported");if(this.geom[0].isEmpty()||this.geom[1].isEmpty())return 0;this.computeMinDistance();return this.minDistance};jsts.operation.distance.DistanceOp.prototype.nearestPoints=function(){this.computeMinDistance();var nearestPts=[this.minDistanceLocation[0].getCoordinate(),this.minDistanceLocation[1].getCoordinate()];return nearestPts};jsts.operation.distance.DistanceOp.prototype.nearestLocations=function(){this.computeMinDistance();return this.minDistanceLocation};jsts.operation.distance.DistanceOp.prototype.updateMinDistance=function(locGeom,flip){if(locGeom[0]===null)return;if(flip){this.minDistanceLocation[0]=locGeom[1];this.minDistanceLocation[1]=locGeom[0]}else{this.minDistanceLocation[0]=locGeom[0];this.minDistanceLocation[1]=locGeom[1]}};jsts.operation.distance.DistanceOp.prototype.computeMinDistance=function(){if(arguments.length>0){this.computeMinDistance2.apply(this,arguments);return}if(this.minDistanceLocation!==null)return;this.minDistanceLocation=[];this.computeContainmentDistance();if(this.minDistance<=this.terminateDistance)return;this.computeFacetDistance()};jsts.operation.distance.DistanceOp.prototype.computeContainmentDistance=function(){if(arguments.length===2){this.computeContainmentDistance2.apply(this,arguments);return}else if(arguments.length===3&&!arguments[0]instanceof jsts.operation.distance.GeometryLocation){this.computeContainmentDistance3.apply(this,arguments);return}else if(arguments.length===3){this.computeContainmentDistance4.apply(this,arguments);return}var locPtPoly=[];this.computeContainmentDistance2(0,locPtPoly);if(this.minDistance<=this.terminateDistance)return;this.computeContainmentDistance2(1,locPtPoly)};jsts.operation.distance.DistanceOp.prototype.computeContainmentDistance2=function(polyGeomIndex,locPtPoly){var locationsIndex=1-polyGeomIndex;var polys=jsts.geom.util.PolygonExtracter.getPolygons(this.geom[polyGeomIndex]);if(polys.length>0){var insideLocs=jsts.operation.distance.ConnectedElementLocationFilter.getLocations(this.geom[locationsIndex]);this.computeContainmentDistance3(insideLocs,polys,locPtPoly);if(this.minDistance<=this.terminateDistance){this.minDistanceLocation[locationsIndex]=locPtPoly[0];this.minDistanceLocation[polyGeomIndex]=locPtPoly[1];return}}};jsts.operation.distance.DistanceOp.prototype.computeContainmentDistance3=function(locs,polys,locPtPoly){for(var i=0;ithis.minDistance){return}var coord0=line0.getCoordinates();var coord1=line1.getCoordinates();for(var i=0;ithis.minDistance){return}var coord0=line.getCoordinates();var coord=pt.getCoordinate();for(var i=0;i0){return this.isNull2.apply(this,arguments)}for(var i=0;i<2;i++){for(var j=0;j<3;j++){if(this.depth[i][j]!==jsts.geomgraph.Depth.NULL_VALUE)return false}}return true};jsts.geomgraph.Depth.prototype.isNull2=function(geomIndex){if(arguments.length>1){return this.isNull3.apply(this,arguments)}return this.depth[geomIndex][1]==jsts.geomgraph.Depth.NULL_VALUE};jsts.geomgraph.Depth.prototype.isNull3=function(geomIndex,posIndex){return this.depth[geomIndex][posIndex]==jsts.geomgraph.Depth.NULL_VALUE};jsts.geomgraph.Depth.prototype.add=function(lbl){for(var i=0;i<2;i++){for(var j=1;j<3;j++){var loc=lbl.getLocation(i,j);if(loc===Location.EXTERIOR||loc===Location.INTERIOR){if(this.isNull(i,j)){this.depth[i][j]=jsts.geomgraph.Depth.depthAtLocation(loc)}else this.depth[i][j]+=jsts.geomgraph.Depth.depthAtLocation(loc)}}}};jsts.geomgraph.Depth.prototype.getDelta=function(geomIndex){return this.depth[geomIndex][Position.RIGHT]-this.depth[geomIndex][Position.LEFT]};jsts.geomgraph.Depth.prototype.normalize=function(){for(var i=0;i<2;i++){if(!this.isNull(i)){var minDepth=this.depth[i][1];if(this.depth[i][2]minDepth)newValue=1;this.depth[i][j]=newValue}}}};jsts.geomgraph.Depth.prototype.toString=function(){return"A: "+this.depth[0][1]+","+this.depth[0][2]+" B: "+this.depth[1][1]+","+this.depth[1][2]}})();jsts.algorithm.BoundaryNodeRule=function(){};jsts.algorithm.BoundaryNodeRule.prototype.isInBoundary=function(boundaryCount){throw new jsts.error.AbstractMethodInvocationError};jsts.algorithm.Mod2BoundaryNodeRule=function(){};jsts.algorithm.Mod2BoundaryNodeRule.prototype=new jsts.algorithm.BoundaryNodeRule;jsts.algorithm.Mod2BoundaryNodeRule.prototype.isInBoundary=function(boundaryCount){return boundaryCount%2===1};jsts.algorithm.BoundaryNodeRule.MOD2_BOUNDARY_RULE=new jsts.algorithm.Mod2BoundaryNodeRule;jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE=jsts.algorithm.BoundaryNodeRule.MOD2_BOUNDARY_RULE;jsts.operation.distance.GeometryLocation=function(component,segIndex,pt){this.component=component;this.segIndex=segIndex;this.pt=pt};jsts.operation.distance.GeometryLocation.INSIDE_AREA=-1;jsts.operation.distance.GeometryLocation.prototype.component=null;jsts.operation.distance.GeometryLocation.prototype.segIndex=null;jsts.operation.distance.GeometryLocation.prototype.pt=null;jsts.operation.distance.GeometryLocation.prototype.getGeometryComponent=function(){return this.component};jsts.operation.distance.GeometryLocation.prototype.getSegmentIndex=function(){return this.segIndex};jsts.operation.distance.GeometryLocation.prototype.getCoordinate=function(){return this.pt};jsts.operation.distance.GeometryLocation.prototype.isInsideArea=function(){return this.segIndex===jsts.operation.distance.GeometryLocation.INSIDE_AREA};jsts.geom.util.PointExtracter=function(pts){this.pts=pts};jsts.geom.util.PointExtracter.prototype=new jsts.geom.GeometryFilter;jsts.geom.util.PointExtracter.prototype.pts=null;jsts.geom.util.PointExtracter.getPoints=function(geom,list){if(list===undefined){list=[]}if(geom instanceof jsts.geom.Point){list.push(geom)}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.MultiLineString||geom instanceof jsts.geom.MultiPolygon){geom.apply(new jsts.geom.util.PointExtracter(list))}return list};jsts.geom.util.PointExtracter.prototype.filter=function(geom){if(geom instanceof jsts.geom.Point)this.pts.push(geom)};jsts.noding.ScaledNoder=function(noder,scaleFactor,offsetX,offsetY){this.offsetX=offsetX?offsetX:0;this.offsetY=offsetY?offsetY:0;this.noder=noder;this.scaleFactor=scaleFactor;this.isScaled=!this.isIntegerPrecision()};jsts.noding.ScaledNoder.prototype=new jsts.noding.Noder;jsts.noding.ScaledNoder.constructor=jsts.noding.ScaledNoder;jsts.noding.ScaledNoder.prototype.noder=null;jsts.noding.ScaledNoder.prototype.scaleFactor=undefined;jsts.noding.ScaledNoder.prototype.offsetX=undefined;jsts.noding.ScaledNoder.prototype.offsetY=undefined;jsts.noding.ScaledNoder.prototype.isScaled=false;jsts.noding.ScaledNoder.prototype.isIntegerPrecision=function(){return this.scaleFactor===1};jsts.noding.ScaledNoder.prototype.getNodedSubstrings=function(){var splitSS=this.noder.getNodedSubstrings();if(this.isScaled)this.rescale(splitSS);return splitSS};jsts.noding.ScaledNoder.prototype.computeNodes=function(inputSegStrings){var intSegStrings=inputSegStrings;if(this.isScaled)intSegStrings=this.scale(inputSegStrings);this.noder.computeNodes(intSegStrings)};jsts.noding.ScaledNoder.prototype.scale=function(segStrings){if(segStrings instanceof Array){return this.scale2(segStrings)}var transformed=new javascript.util.ArrayList;for(var i=segStrings.iterator();i.hasNext();){var ss=i.next();transformed.add(new jsts.noding.NodedSegmentString(this.scale(ss.getCoordinates()),ss.getData()))}return transformed};jsts.noding.ScaledNoder.prototype.scale2=function(pts){var roundPts=[];for(var i=0;iother.segmentIndex)return 1;if(this.coord.equals2D(other.coord))return 0;return jsts.noding.SegmentPointComparator.compare(this.segmentOctant,this.coord,other.coord)};(function(){jsts.io.GeoJSONWriter=function(){this.parser=new jsts.io.GeoJSONParser(this.geometryFactory)};jsts.io.GeoJSONWriter.prototype.write=function(geometry){var geoJson=this.parser.write(geometry);return geoJson}})();jsts.io.OpenLayersParser=function(geometryFactory){this.geometryFactory=geometryFactory||new jsts.geom.GeometryFactory};jsts.io.OpenLayersParser.prototype.read=function(geometry){if(geometry.CLASS_NAME==="OpenLayers.Geometry.Point"){return this.convertFromPoint(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.LineString"){return this.convertFromLineString(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.LinearRing"){return this.convertFromLinearRing(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.Polygon"){return this.convertFromPolygon(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.MultiPoint"){return this.convertFromMultiPoint(geometry) }else if(geometry.CLASS_NAME==="OpenLayers.Geometry.MultiLineString"){return this.convertFromMultiLineString(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.MultiPolygon"){return this.convertFromMultiPolygon(geometry)}else if(geometry.CLASS_NAME==="OpenLayers.Geometry.Collection"){return this.convertFromCollection(geometry)}};jsts.io.OpenLayersParser.prototype.convertFromPoint=function(point){return this.geometryFactory.createPoint(new jsts.geom.Coordinate(point.x,point.y))};jsts.io.OpenLayersParser.prototype.convertFromLineString=function(lineString){var i;var coordinates=[];for(i=0;i0){this.minExtent=delX}var delY=itemEnv.getHeight();if(delY0){this.minExtent=delY}};jsts.operation.relate.RelateNodeFactory=function(){};jsts.operation.relate.RelateNodeFactory.prototype=new jsts.geomgraph.NodeFactory;jsts.operation.relate.RelateNodeFactory.prototype.createNode=function(coord){return new jsts.operation.relate.RelateNode(coord,new jsts.operation.relate.EdgeEndBundleStar)};jsts.index.quadtree.Key=function(itemEnv){this.pt=new jsts.geom.Coordinate;this.level=0;this.env=null;this.computeKey(itemEnv)};jsts.index.quadtree.Key.computeQuadLevel=function(env){var dx,dy,dMax,level;dx=env.getWidth();dy=env.getHeight();dMax=dx>dy?dx:dy;level=jsts.index.DoubleBits.exponent(dMax)+1;return level};jsts.index.quadtree.Key.prototype.getPoint=function(){return this.pt};jsts.index.quadtree.Key.prototype.getLevel=function(){return this.level};jsts.index.quadtree.Key.prototype.getEnvelope=function(){return this.env};jsts.index.quadtree.Key.prototype.getCentre=function(){var x,y;x=(this.env.getMinX()+this.env.getMaxX())/2;y=(this.env.getMinY()+this.env.getMaxY())/2;return new jsts.geom.Coordinate(x,y)};jsts.index.quadtree.Key.prototype.computeKey=function(){if(arguments[0]instanceof jsts.geom.Envelope){this.computeKeyFromEnvelope(arguments[0])}else{this.computeKeyFromLevel(arguments[0],arguments[1])}};jsts.index.quadtree.Key.prototype.computeKeyFromEnvelope=function(env){this.level=jsts.index.quadtree.Key.computeQuadLevel(env);this.env=new jsts.geom.Envelope;this.computeKey(this.level,env);while(!this.env.contains(env)){this.level+=1;this.computeKey(this.level,env)}};jsts.index.quadtree.Key.prototype.computeKeyFromLevel=function(level,env){var quadSize=jsts.index.DoubleBits.powerOf2(level);this.pt.x=Math.floor(env.getMinX()/quadSize)*quadSize;this.pt.y=Math.floor(env.getMinY()/quadSize)*quadSize;this.env.init(this.pt.x,this.pt.x+quadSize,this.pt.y,this.pt.y+quadSize)};jsts.geom.CoordinateArrays=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.CoordinateArrays.removeRepeatedPoints=function(coord){var coordList;if(!this.hasRepeatedPoints(coord)){return coord}coordList=new jsts.geom.CoordinateList(coord,false);return coordList.toCoordinateArray()};jsts.geom.CoordinateArrays.hasRepeatedPoints=function(coord){var i;for(i=1;i0){minCoord=coordinates[i]}}return minCoord};jsts.geom.CoordinateArrays.scroll=function(coordinates,firstCoordinate){var i=jsts.geom.CoordinateArrays.indexOf(firstCoordinate,coordinates);if(i<0)return;var newCoordinates=coordinates.slice(i).concat(coordinates.slice(0,i));for(i=0;imaxx){minx=p2.x;maxx=p1.x}if(this.p.x>=minx&&this.p.x<=maxx){this.isPointOnSegment=true}return}if(p1.y>this.p.y&&p2.y<=this.p.y||p2.y>this.p.y&&p1.y<=this.p.y){var x1=p1.x-this.p.x;var y1=p1.y-this.p.y;var x2=p2.x-this.p.x;var y2=p2.y-this.p.y;var xIntSign=jsts.algorithm.RobustDeterminant.signOfDet2x2(x1,y1,x2,y2);if(xIntSign===0){this.isPointOnSegment=true;return}if(y20){this.crossingCount++}}};jsts.algorithm.RayCrossingCounter.prototype.isOnSegment=function(){return jsts.geom.isPointOnSegment};jsts.algorithm.RayCrossingCounter.prototype.getLocation=function(){if(this.isPointOnSegment)return jsts.geom.Location.BOUNDARY;if(this.crossingCount%2===1){return jsts.geom.Location.INTERIOR}return jsts.geom.Location.EXTERIOR};jsts.algorithm.RayCrossingCounter.prototype.isPointInPolygon=function(){return this.getLocation()!==jsts.geom.Location.EXTERIOR};jsts.operation.BoundaryOp=function(geom,bnRule){this.geom=geom;this.geomFact=geom.getFactory();this.bnRule=bnRule||jsts.algorithm.BoundaryNodeRule.MOD2_BOUNDARY_RULE};jsts.operation.BoundaryOp.prototype.geom=null;jsts.operation.BoundaryOp.prototype.geomFact=null;jsts.operation.BoundaryOp.prototype.bnRule=null;jsts.operation.BoundaryOp.prototype.getBoundary=function(){if(this.geom instanceof jsts.geom.LineString)return this.boundaryLineString(this.geom);if(this.geom instanceof jsts.geom.MultiLineString)return this.boundaryMultiLineString(this.geom);return this.geom.getBoundary()};jsts.operation.BoundaryOp.prototype.getEmptyMultiPoint=function(){return this.geomFact.createMultiPoint(null)};jsts.operation.BoundaryOp.prototype.boundaryMultiLineString=function(mLine){if(this.geom.isEmpty()){return this.getEmptyMultiPoint()}var bdyPts=this.computeBoundaryCoordinates(mLine);if(bdyPts.length==1){return this.geomFact.createPoint(bdyPts[0])}return this.geomFact.createMultiPoint(bdyPts)};jsts.operation.BoundaryOp.prototype.endpoints=null;jsts.operation.BoundaryOp.prototype.computeBoundaryCoordinates=function(mLine){var i,line,endpoint,bdyPts=[];this.endpoints=[];for(i=0;i0&&this.isErodedCompletely(hole,-this.distance))continue;this.addPolygonRing(holeCoord,offsetDistance,jsts.geomgraph.Position.opposite(offsetSide),jsts.geom.Location.INTERIOR,jsts.geom.Location.EXTERIOR)}};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addPolygonRing=function(coord,offsetDistance,side,cwLeftLoc,cwRightLoc){if(offsetDistance==0&&coord.length=jsts.geom.LinearRing.MINIMUM_VALID_SIZE&&jsts.algorithm.CGAlgorithms.isCCW(coord)){leftLoc=cwRightLoc;rightLoc=cwLeftLoc;side=jsts.geomgraph.Position.opposite(side)}var curve=this.curveBuilder.getRingCurve(coord,side,offsetDistance);this.addCurve(curve,leftLoc,rightLoc)};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.isErodedCompletely=function(ring,bufferDistance){var ringCoord=ring.getCoordinates();var minDiam=0;if(ringCoord.length<4)return bufferDistance<0;if(ringCoord.length==4)return this.isTriangleErodedCompletely(ringCoord,bufferDistance);var env=ring.getEnvelopeInternal();var envMinDimension=Math.min(env.getHeight(),env.getWidth());if(bufferDistance<0&&2*Math.abs(bufferDistance)>envMinDimension)return true;return false};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.isTriangleErodedCompletely=function(triangleCoord,bufferDistance){var tri=new jsts.geom.Triangle(triangleCoord[0],triangleCoord[1],triangleCoord[2]);var inCentre=tri.inCentre();var distToCentre=jsts.algorithm.CGAlgorithms.distancePointLine(inCentre,tri.p0,tri.p1);return distToCentre=1&&de.getDepth(jsts.geomgraph.Position.LEFT)<=0&&!de.isInteriorAreaEdge()){de.setInResult(true)}}};jsts.operation.buffer.BufferSubgraph.prototype.compareTo=function(o){var graph=o;if(this.rightMostCoord.xgraph.rightMostCoord.x){return 1}return 0};jsts.geom.util.GeometryExtracter=function(clz,comps){this.clz=clz;this.comps=comps};jsts.geom.util.GeometryExtracter.prototype=new jsts.geom.GeometryFilter;jsts.geom.util.GeometryExtracter.prototype.clz=null;jsts.geom.util.GeometryExtracter.prototype.comps=null;jsts.geom.util.GeometryExtracter.extract=function(geom,clz,list){list=list||new javascript.util.ArrayList;if(geom instanceof clz){list.add(geom)}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.MultiLineString||geom instanceof jsts.geom.MultiPolygon){geom.apply(new jsts.geom.util.GeometryExtracter(clz,list))}return list};jsts.geom.util.GeometryExtracter.prototype.filter=function(geom){if(this.clz===null||geom instanceof this.clz){this.comps.add(geom)}};(function(){var OverlayOp=jsts.operation.overlay.OverlayOp;var SnapOverlayOp=jsts.operation.overlay.snap.SnapOverlayOp;var SnapIfNeededOverlayOp=function(g1,g2){this.geom=[];this.geom[0]=g1;this.geom[1]=g2};SnapIfNeededOverlayOp.overlayOp=function(g0,g1,opCode){var op=new SnapIfNeededOverlayOp(g0,g1);return op.getResultGeometry(opCode)};SnapIfNeededOverlayOp.intersection=function(g0,g1){return overlayOp(g0,g1,OverlayOp.INTERSECTION)};SnapIfNeededOverlayOp.union=function(g0,g1){return overlayOp(g0,g1,OverlayOp.UNION)};SnapIfNeededOverlayOp.difference=function(g0,g1){return overlayOp(g0,g1,OverlayOp.DIFFERENCE)};SnapIfNeededOverlayOp.symDifference=function(g0,g1){return overlayOp(g0,g1,OverlayOp.SYMDIFFERENCE)};SnapIfNeededOverlayOp.prototype.geom=null;SnapIfNeededOverlayOp.prototype.getResultGeometry=function(opCode){var result=null;var isSuccess=false;var savedException=null;try{result=OverlayOp.overlayOp(this.geom[0],this.geom[1],opCode);var isValid=true;if(isValid)isSuccess=true}catch(ex){savedException=ex}if(!isSuccess){try{result=SnapOverlayOp.overlayOp(this.geom[0],this.geom[1],opCode)}catch(ex){throw savedException}}return result};jsts.operation.overlay.snap.SnapIfNeededOverlayOp=SnapIfNeededOverlayOp})();(function(){var GeometryExtracter=jsts.geom.util.GeometryExtracter;var CascadedPolygonUnion=jsts.operation.union.CascadedPolygonUnion;var PointGeometryUnion=jsts.operation.union.PointGeometryUnion;var OverlayOp=jsts.operation.overlay.OverlayOp;var SnapIfNeededOverlayOp=jsts.operation.overlay.snap.SnapIfNeededOverlayOp;var ArrayList=javascript.util.ArrayList;jsts.operation.union.UnaryUnionOp=function(geoms,geomFact){this.polygons=new ArrayList;this.lines=new ArrayList;this.points=new ArrayList;if(geomFact){this.geomFact=geomFact}this.extract(geoms)};jsts.operation.union.UnaryUnionOp.union=function(geoms,geomFact){var op=new jsts.operation.union.UnaryUnionOp(geoms,geomFact);return op.union()};jsts.operation.union.UnaryUnionOp.prototype.polygons=null;jsts.operation.union.UnaryUnionOp.prototype.lines=null;jsts.operation.union.UnaryUnionOp.prototype.points=null;jsts.operation.union.UnaryUnionOp.prototype.geomFact=null;jsts.operation.union.UnaryUnionOp.prototype.extract=function(geoms){if(geoms instanceof ArrayList){for(var i=geoms.iterator();i.hasNext();){var geom=i.next();this.extract(geom)}}else{if(this.geomFact===null){this.geomFact=geoms.getFactory()}GeometryExtracter.extract(geoms,jsts.geom.Polygon,this.polygons);GeometryExtracter.extract(geoms,jsts.geom.LineString,this.lines);GeometryExtracter.extract(geoms,jsts.geom.Point,this.points)}};jsts.operation.union.UnaryUnionOp.prototype.union=function(){if(this.geomFact===null){return null}var unionPoints=null;if(this.points.size()>0){var ptGeom=this.geomFact.buildGeometry(this.points);unionPoints=this.unionNoOpt(ptGeom)}var unionLines=null;if(this.lines.size()>0){var lineGeom=this.geomFact.buildGeometry(this.lines);unionLines=this.unionNoOpt(lineGeom)}var unionPolygons=null;if(this.polygons.size()>0){unionPolygons=CascadedPolygonUnion.union(this.polygons)}var unionLA=this.unionWithNull(unionLines,unionPolygons);var union=null;if(unionPoints===null){union=unionLA}else if(unionLA===null){union=unionPoints}else{union=PointGeometryUnion(unionPoints,unionLA)}if(union===null){return this.geomFact.createGeometryCollection(null)}return union};jsts.operation.union.UnaryUnionOp.prototype.unionWithNull=function(g0,g1){if(g0===null&&g1===null){return null}if(g1===null){return g0}if(g0===null){return g1}return g0.union(g1)};jsts.operation.union.UnaryUnionOp.prototype.unionNoOpt=function(g0){var empty=this.geomFact.createPoint(null);return SnapIfNeededOverlayOp.overlayOp(g0,empty,OverlayOp.UNION)}})();jsts.index.kdtree.KdNode=function(){this.left=null;this.right=null;this.count=1;if(arguments.length===2){this.initializeFromCoordinate.apply(this,arguments[0],arguments[1])}else if(arguments.length===3){this.initializeFromXY.apply(this,arguments[0],arguments[1],arguments[2])}};jsts.index.kdtree.KdNode.prototype.initializeFromXY=function(x,y,data){this.p=new jsts.geom.Coordinate(x,y);this.data=data};jsts.index.kdtree.KdNode.prototype.initializeFromCoordinate=function(p,data){this.p=p;this.data=data};jsts.index.kdtree.KdNode.prototype.getX=function(){return this.p.x};jsts.index.kdtree.KdNode.prototype.getY=function(){return this.p.y };jsts.index.kdtree.KdNode.prototype.getCoordinate=function(){return this.p};jsts.index.kdtree.KdNode.prototype.getData=function(){return this.data};jsts.index.kdtree.KdNode.prototype.getLeft=function(){return this.left};jsts.index.kdtree.KdNode.prototype.getRight=function(){return this.right};jsts.index.kdtree.KdNode.prototype.increment=function(){this.count+=1};jsts.index.kdtree.KdNode.prototype.getCount=function(){return this.count};jsts.index.kdtree.KdNode.prototype.isRepeated=function(){return count>1};jsts.index.kdtree.KdNode.prototype.setLeft=function(left){this.left=left};jsts.index.kdtree.KdNode.prototype.setRight=function(right){this.right=right};jsts.algorithm.InteriorPointPoint=function(geometry){this.minDistance=Number.MAX_VALUE;this.interiorPoint=null;this.centroid=geometry.getCentroid().getCoordinate();this.add(geometry)};jsts.algorithm.InteriorPointPoint.prototype.add=function(geometry){if(geometry instanceof jsts.geom.Point){this.addPoint(geometry.getCoordinate())}else if(geometry instanceof jsts.geom.GeometryCollection){for(var i=0;i0){this.minExtent=del}};jsts.index.bintree.Bintree=Bintree})();jsts.algorithm.InteriorPointArea=function(geometry){this.factory;this.interiorPoint=null;this.maxWidth=0;this.factory=geometry.getFactory();this.add(geometry)};jsts.algorithm.InteriorPointArea.avg=function(a,b){return(a+b)/2};jsts.algorithm.InteriorPointArea.prototype.getInteriorPoint=function(){return this.interiorPoint};jsts.algorithm.InteriorPointArea.prototype.add=function(geometry){if(geometry instanceof jsts.geom.Polygon){this.addPolygon(geometry)}else if(geometry instanceof jsts.geom.GeometryCollection){for(var i=0;ithis.maxWidth){this.interiorPoint=intPt;this.maxWidth=width}};jsts.algorithm.InteriorPointArea.prototype.widestGeometry=function(obj){if(obj instanceof jsts.geom.GeometryCollection){var gc=obj;if(gc.isEmpty()){return gc}var widestGeometry=gc.getGeometryN(0);for(var i=1;iwidestGeometry.getEnvelopeInternal().getWidth()){widestGeometry=gc.getGeometryN(i)}}return widestGeometry}else if(obj instanceof jsts.geom.Geometry){return obj}};jsts.algorithm.InteriorPointArea.prototype.horizontalBisector=function(geometry){var envelope=geometry.getEnvelopeInternal();var bisectY=jsts.algorithm.SafeBisectorFinder.getBisectorY(geometry);return this.factory.createLineString([new jsts.geom.Coordinate(envelope.getMinX(),bisectY),new jsts.geom.Coordinate(envelope.getMaxX(),bisectY)])};jsts.algorithm.InteriorPointArea.prototype.centre=function(envelope){return new jsts.geom.Coordinate(jsts.algorithm.InteriorPointArea.avg(envelope.getMinX(),envelope.getMaxX()),jsts.algorithm.InteriorPointArea.avg(envelope.getMinY(),envelope.getMaxY()))};jsts.algorithm.SafeBisectorFinder=function(poly){this.poly;this.centreY;this.hiY=Number.MAX_VALUE;this.loY=-Number.MAX_VALUE;this.poly=poly;this.hiY=poly.getEnvelopeInternal().getMaxY();this.loY=poly.getEnvelopeInternal().getMinY();this.centreY=jsts.algorithm.InteriorPointArea.avg(this.loY,this.hiY)};jsts.algorithm.SafeBisectorFinder.getBisectorY=function(poly){var finder=new jsts.algorithm.SafeBisectorFinder(poly);return finder.getBisectorY()};jsts.algorithm.SafeBisectorFinder.prototype.getBisectorY=function(){this.process(this.poly.getExteriorRing());for(var i=0;ithis.loY){this.loY=y}}else if(y>this.centreY){if(yx1)return 1;return 0};jsts.noding.SegmentPointComparator.compareValue=function(compareSign0,compareSign1){if(compareSign0<0)return-1;if(compareSign0>0)return 1;if(compareSign1<0)return-1;if(compareSign1>0)return 1;return 0};jsts.operation.relate.RelateOp=function(){jsts.operation.GeometryGraphOperation.apply(this,arguments);this._relate=new jsts.operation.relate.RelateComputer(this.arg)};jsts.operation.relate.RelateOp.prototype=new jsts.operation.GeometryGraphOperation;jsts.operation.relate.RelateOp.relate=function(a,b,boundaryNodeRule){var relOp=new jsts.operation.relate.RelateOp(a,b,boundaryNodeRule);var im=relOp.getIntersectionMatrix();return im};jsts.operation.relate.RelateOp.prototype._relate=null;jsts.operation.relate.RelateOp.prototype.getIntersectionMatrix=function(){return this._relate.computeIM()};jsts.index.chain.MonotoneChain=function(pts,start,end,context){this.pts=pts;this.start=start;this.end=end;this.context=context};jsts.index.chain.MonotoneChain.prototype.pts=null;jsts.index.chain.MonotoneChain.prototype.start=null;jsts.index.chain.MonotoneChain.prototype.end=null;jsts.index.chain.MonotoneChain.prototype.env=null;jsts.index.chain.MonotoneChain.prototype.context=null;jsts.index.chain.MonotoneChain.prototype.id=null;jsts.index.chain.MonotoneChain.prototype.setId=function(id){this.id=id};jsts.index.chain.MonotoneChain.prototype.getId=function(){return this.id};jsts.index.chain.MonotoneChain.prototype.getContext=function(){return this.context};jsts.index.chain.MonotoneChain.prototype.getEnvelope=function(){if(this.env==null){var p0=this.pts[this.start];var p1=this.pts[this.end];this.env=new jsts.geom.Envelope(p0,p1)}return this.env};jsts.index.chain.MonotoneChain.prototype.getStartIndex=function(){return this.start};jsts.index.chain.MonotoneChain.prototype.getEndIndex=function(){return this.end};jsts.index.chain.MonotoneChain.prototype.getLineSegment=function(index,ls){ls.p0=this.pts[index];ls.p1=this.pts[index+1]};jsts.index.chain.MonotoneChain.prototype.getCoordinates=function(){var coord=[];var index=0;for(var i=this.start;i<=this.end;i++){coord[index++]=this.pts[i]}return coord};jsts.index.chain.MonotoneChain.prototype.select=function(searchEnv,mcs){this.computeSelect2(searchEnv,this.start,this.end,mcs)};jsts.index.chain.MonotoneChain.prototype.computeSelect2=function(searchEnv,start0,end0,mcs){var p0=this.pts[start0];var p1=this.pts[end0];mcs.tempEnv1.init(p0,p1);if(end0-start0===1){mcs.select(this,start0);return}if(!searchEnv.intersects(mcs.tempEnv1))return;var mid=parseInt((start0+end0)/2);if(start0=0||actualDimensionValue===Dimension.TRUE)){return true}if(requiredDimensionSymbol==="F"&&actualDimensionValue===Dimension.FALSE){return true}if(requiredDimensionSymbol==="0"&&actualDimensionValue===Dimension.P){return true}if(requiredDimensionSymbol==="1"&&actualDimensionValue===Dimension.L){return true}if(requiredDimensionSymbol==="2"&&actualDimensionValue===Dimension.A){return true}return false};jsts.geom.IntersectionMatrix.matches2=function(actualDimensionSymbols,requiredDimensionSymbols){var m=new jsts.geom.IntersectionMatrix(actualDimensionSymbols);return m.matches(requiredDimensionSymbols)};jsts.geom.IntersectionMatrix.prototype.set=function(row,column,dimensionValue){if(typeof row==="string"){this.set2(row);return}this.matrix[row][column]=dimensionValue};jsts.geom.IntersectionMatrix.prototype.set2=function(dimensionSymbols){for(var i=0;i=0&&column>=0){this.setAtLeast(row,column,minimumDimensionValue)}};jsts.geom.IntersectionMatrix.prototype.setAtLeast2=function(minimumDimensionSymbols){var i;for(i=0;idimensionOfGeometryB){return this.isTouches(dimensionOfGeometryB,dimensionOfGeometryA)}if(dimensionOfGeometryA==Dimension.A&&dimensionOfGeometryB==Dimension.A||dimensionOfGeometryA==Dimension.L&&dimensionOfGeometryB==Dimension.L||dimensionOfGeometryA==Dimension.L&&dimensionOfGeometryB==Dimension.A||dimensionOfGeometryA==Dimension.P&&dimensionOfGeometryB==Dimension.A||dimensionOfGeometryA==Dimension.P&&dimensionOfGeometryB==Dimension.L){return this.matrix[Location.INTERIOR][Location.INTERIOR]===Dimension.FALSE&&(jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.BOUNDARY],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.INTERIOR],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.BOUNDARY],"T"))}return false};jsts.geom.IntersectionMatrix.prototype.isCrosses=function(dimensionOfGeometryA,dimensionOfGeometryB){if(dimensionOfGeometryA==Dimension.P&&dimensionOfGeometryB==Dimension.L||dimensionOfGeometryA==Dimension.P&&dimensionOfGeometryB==Dimension.A||dimensionOfGeometryA==Dimension.L&&dimensionOfGeometryB==Dimension.A){return jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.EXTERIOR],"T")}if(dimensionOfGeometryA==Dimension.L&&dimensionOfGeometryB==Dimension.P||dimensionOfGeometryA==Dimension.A&&dimensionOfGeometryB==Dimension.P||dimensionOfGeometryA==Dimension.A&&dimensionOfGeometryB==Dimension.L){return jsts.geom.IntersectionMatrix.matches(matrix[Location.INTERIOR][Location.INTERIOR],"T")&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.EXTERIOR][Location.INTERIOR],"T")}if(dimensionOfGeometryA===Dimension.L&&dimensionOfGeometryB===Dimension.L){return this.matrix[Location.INTERIOR][Location.INTERIOR]===0}return false};jsts.geom.IntersectionMatrix.prototype.isWithin=function(){return jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")&&this.matrix[Location.INTERIOR][Location.EXTERIOR]==Dimension.FALSE&&this.matrix[Location.BOUNDARY][Location.EXTERIOR]==Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isContains=function(){return jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")&&this.matrix[Location.EXTERIOR][Location.INTERIOR]==Dimension.FALSE&&this.matrix[Location.EXTERIOR][Location.BOUNDARY]==Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isCovers=function(){var hasPointInCommon=jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.BOUNDARY],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.INTERIOR],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.BOUNDARY],"T");return hasPointInCommon&&this.matrix[Location.EXTERIOR][Location.INTERIOR]==Dimension.FALSE&&this.matrix[Location.EXTERIOR][Location.BOUNDARY]==Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isCoveredBy=function(){var hasPointInCommon=jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.BOUNDARY],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.INTERIOR],"T")||jsts.geom.IntersectionMatrix.matches(this.matrix[Location.BOUNDARY][Location.BOUNDARY],"T");return hasPointInCommon&&this.matrix[Location.INTERIOR][Location.EXTERIOR]===Dimension.FALSE&&this.matrix[Location.BOUNDARY][Location.EXTERIOR]===Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isEquals=function(dimensionOfGeometryA,dimensionOfGeometryB){if(dimensionOfGeometryA!==dimensionOfGeometryB){return false}return jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")&&this.matrix[Location.EXTERIOR][Location.INTERIOR]===Dimension.FALSE&&this.matrix[Location.INTERIOR][Location.EXTERIOR]===Dimension.FALSE&&this.matrix[Location.EXTERIOR][Location.BOUNDARY]===Dimension.FALSE&&this.matrix[Location.BOUNDARY][Location.EXTERIOR]===Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isOverlaps=function(dimensionOfGeometryA,dimensionOfGeometryB){if(dimensionOfGeometryA==Dimension.P&&dimensionOfGeometryB===Dimension.P||dimensionOfGeometryA==Dimension.A&&dimensionOfGeometryB===Dimension.A){return jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.INTERIOR],"T")&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.EXTERIOR],"T")&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.EXTERIOR][Location.INTERIOR],"T")}if(dimensionOfGeometryA===Dimension.L&&dimensionOfGeometryB===Dimension.L){return this.matrix[Location.INTERIOR][Location.INTERIOR]==1&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.INTERIOR][Location.EXTERIOR],"T")&&jsts.geom.IntersectionMatrix.matches(this.matrix[Location.EXTERIOR][Location.INTERIOR],"T")}return false};jsts.geom.IntersectionMatrix.prototype.matches=function(requiredDimensionSymbols){if(requiredDimensionSymbols.length!=9){throw new jsts.error.IllegalArgumentException("Should be length 9: "+requiredDimensionSymbols)}for(var ai=0;ai<3;ai++){for(var bi=0;bi<3;bi++){if(!jsts.geom.IntersectionMatrix.matches(this.matrix[ai][bi],requiredDimensionSymbols.charAt(3*ai+bi))){return false}}}return true};jsts.geom.IntersectionMatrix.prototype.transpose=function(){var temp=matrix[1][0];this.matrix[1][0]=this.matrix[0][1]; this.matrix[0][1]=temp;temp=this.matrix[2][0];this.matrix[2][0]=this.matrix[0][2];this.matrix[0][2]=temp;temp=this.matrix[2][1];this.matrix[2][1]=this.matrix[1][2];this.matrix[1][2]=temp;return this};jsts.geom.IntersectionMatrix.prototype.toString=function(){var ai,bi,buf="";for(ai=0;ai<3;ai++){for(bi=0;bi<3;bi++){buf+=Dimension.toDimensionSymbol(this.matrix[ai][bi])}}return buf}})();jsts.triangulate.quadedge.LastFoundQuadEdgeLocator=function(subdiv){this.subdiv=subdiv;this.lastEdge=null;this.init()};jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.init=function(){this.lastEdge=this.findEdge()};jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.findEdge=function(){var edges=this.subdiv.getEdges();return edges[0]};jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.locate=function(v){if(!this.lastEdge.isLive()){this.init()}var e=this.subdiv.locateFromEdge(v,this.lastEdge);this.lastEdge=e;return e};jsts.noding.SegmentNodeList=function(edge){this.nodeMap=new javascript.util.TreeMap;this.edge=edge};jsts.noding.SegmentNodeList.prototype.nodeMap=null;jsts.noding.SegmentNodeList.prototype.iterator=function(){return this.nodeMap.values().iterator()};jsts.noding.SegmentNodeList.prototype.edge=null;jsts.noding.SegmentNodeList.prototype.getEdge=function(){return this.edge};jsts.noding.SegmentNodeList.prototype.add=function(intPt,segmentIndex){var eiNew=new jsts.noding.SegmentNode(this.edge,intPt,segmentIndex,this.edge.getSegmentOctant(segmentIndex));var ei=this.nodeMap.get(eiNew);if(ei!==null){jsts.util.Assert.isTrue(ei.coord.equals2D(intPt),"Found equal nodes with different coordinates");return ei}this.nodeMap.put(eiNew,eiNew);return eiNew};jsts.noding.SegmentNodeList.prototype.addEndpoints=function(){var maxSegIndex=this.edge.size()-1;this.add(this.edge.getCoordinate(0),0);this.add(this.edge.getCoordinate(maxSegIndex),maxSegIndex)};jsts.noding.SegmentNodeList.prototype.addCollapsedNodes=function(){var collapsedVertexIndexes=[];this.findCollapsesFromInsertedNodes(collapsedVertexIndexes);this.findCollapsesFromExistingVertices(collapsedVertexIndexes);for(var i=0;ideltaY){offset=deltaX*10}else{offset=deltaY*10}this.frameVertex[0]=new jsts.triangulate.quadedge.Vertex((env.getMaxX()+env.getMinX())/2,env.getMaxY()+offset);this.frameVertex[1]=new jsts.triangulate.quadedge.Vertex(env.getMinX()-offset,env.getMinY()-offset);this.frameVertex[2]=new jsts.triangulate.quadedge.Vertex(env.getMaxX()+offset,env.getMinY()-offset);this.frameEnv=new jsts.geom.Envelope(this.frameVertex[0].getCoordinate(),this.frameVertex[1].getCoordinate());this.frameEnv.expandToInclude(this.frameVertex[2].getCoordinate())};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.initSubdiv=function(){var ea,eb,ec;ea=this.makeEdge(this.frameVertex[0],this.frameVertex[1]);eb=this.makeEdge(this.frameVertex[1],this.frameVertex[2]);jsts.triangulate.quadedge.QuadEdge.splice(ea.sym(),eb);ec=this.makeEdge(this.frameVertex[2],this.frameVertex[0]);jsts.triangulate.quadedge.QuadEdge.splice(eb.sym(),ec);jsts.triangulate.quadedge.QuadEdge.splice(ec.sym(),ea);return ea};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getTolerance=function(){return this.tolerance};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getEnvelope=function(){return new jsts.geom.Envelope(this.frameEnv)};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getEdges=function(){if(arguments.length>0){return this.getEdgesByFactory(arguments[0])}else{return this.quadEdges}};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.setLocator=function(locator){this.locator=locator};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.makeEdge=function(o,d){var q=jsts.triangulate.quadedge.QuadEdge.makeEdge(o,d);this.quadEdges.push(q);return q};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.connect=function(a,b){var q=jsts.triangulate.quadedge.QuadEdge.connect(a,b);this.quadEdges.push(q);return q};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.delete_jsts=function(e){jsts.triangulate.quadedge.QuadEdge.splice(e,e.oPrev());jsts.triangulate.quadedge.QuadEdge.splice(e.sym(),e.sym().oPrev());var eSym,eRot,eRotSym;e.eSym=e.sym();eRot=e.rot;eRotSym=e.rot.sym();var idx=this.quadEdges.indexOf(e);if(idx!==-1){this.quadEdges.splice(idx,1)}idx=this.quadEdges.indexOf(eSym);if(idx!==-1){this.quadEdges.splice(idx,1)}idx=this.quadEdges.indexOf(eRot);if(idx!==-1){this.quadEdges.splice(idx,1)}idx=this.quadEdges.indexOf(eRotSym);if(idx!==-1){this.quadEdges.splice(idx,1)}e.delete_jsts();eSym.delete_jsts();eRot.delete_jsts();eRotSym.delete_jsts()};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.locateFromEdge=function(v,startEdge){var iter=0,maxIter=this.quadEdges.length,e;e=startEdge;while(true){iter++;if(iter>maxIter){throw new jsts.error.LocateFailureError(e.toLineSegment())}if(v.equals(e.orig())||v.equals(e.dest())){break}else if(v.rightOf(e)){e=e.sym()}else if(!v.rightOf(e.oNext())){e=e.oNext()}else if(!v.rightOf(e.dPrev())){e=e.dPrev()}else{break}}return e};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.locate=function(){if(arguments.length===1){if(arguments[0]instanceof jsts.triangulate.quadedge.Vertex){return this.locateByVertex(arguments[0])}else{return this.locateByCoordinate(arguments[0])}}else{return this.locateByCoordinates(arguments[0],arguments[1])}};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.locateByVertex=function(v){return this.locator.locate(v)};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.locateByCoordinate=function(p){return this.locator.locate(new jsts.triangulate.quadedge.Vertex(p))};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.locateByCoordinates=function(p0,p1){var e,base,locEdge;var e=this.locator.locate(new jsts.triangulate.quadedge.Vertex(p0));if(e===null){return null}base=e;if(e.dest().getCoordinate().equals2D(p0)){base=e.sym()}locEdge=base;do{if(locEdge.dest().getCoordinate().equals2D(p1)){return locEdge}locEdge=locEdge.oNext()}while(locEdge!=base);return null};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.insertSite=function(v){var e,base,startEdge;e=this.locate(v);if(v.equals(e.orig(),this.tolerance)||v.equals(e.dest(),this.tolerance)){return e}base=this.makeEdge(e.orig(),v);jsts.triangulate.quadedge.QuadEdge.splice(base,e);startEdge=base;do{base=this.connect(e,base.sym());e=base.oPrev()}while(e.lNext()!=startEdge);return startEdge};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.isFrameEdge=function(e){if(this.isFrameVertex(e.orig())||this.isFrameVertex(e.dest())){return true}return false};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.isFrameBorderEdge=function(e){var leftTri,rightTri,vLeftTriOther,vRightTriOther;leftTri=new Array(3);this.getTriangleEdges(e,leftTri);rightTri=new Array(3);this.getTriangleEdges(e.sym(),rightTri);vLeftTriOther=e.lNext().dest();if(this.isFrameVertex(vLeftTriOther)){return true}vRightTriOther=e.sym().lNext().dest();if(this.isFrameVertex(vRightTriOther)){return true}return false};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.isFrameVertex=function(v){if(v.equals(this.frameVertex[0])){return true}if(v.equals(this.frameVertex[1])){return true}if(v.equals(this.frameVertex[2])){return true}return false};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.isOnEdge=function(e,p){this.seg.setCoordinates(e.orig().getCoordinate(),e.dest().getCoordinate());var dist=this.seg.distance(p);return dist0){edge=edgeStack.pop();if(visitedEdges.indexOf(edge)===-1){priQE=edge.getPrimary();if(includeFrame||!this.isFrameEdge(priQE)){edges.push(priQE)}edgeStack.push(edge.oNext());edgeStack.push(edge.sym().oNext());visitedEdges.push(edge);visitedEdges.push(edge.sym())}}return edges};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.visitTriangles=function(triVisitor,includeFrame){this.visitedKey++;var edgeStack,visitedEdges,edge,triEdges;edgeStack=[];edgeStack.push(this.startingEdge);visitedEdges=[];while(edgeStack.length>0){edge=edgeStack.pop();if(visitedEdges.indexOf(edge)===-1){triEdges=this.fetchTriangleToVisit(edge,edgeStack,includeFrame,visitedEdges);if(triEdges!==null)triVisitor.visit(triEdges)}}};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.fetchTriangleToVisit=function(edge,edgeStack,includeFrame,visitedEdges){var curr,edgeCount,isFrame,sym;curr=edge;edgeCount=0;isFrame=false;do{this.triEdges[edgeCount]=curr;if(this.isFrameEdge(curr)){isFrame=true}sym=curr.sym();if(visitedEdges.indexOf(sym)===-1){edgeStack.push(sym)}visitedEdges.push(curr);edgeCount++;curr=curr.lNext()}while(curr!==edge);if(isFrame&&!includeFrame){return null}return this.triEdges};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getTriangleEdges=function(includeFrame){var visitor=new jsts.triangulate.quadedge.TriangleEdgesListVisitor;this.visitTriangles(visitor,includeFrame);return visitor.getTriangleEdges()};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getTriangleVertices=function(includeFrame){var visitor=new TriangleVertexListVisitor;this.visitTriangles(visitor,includeFrame);return visitor.getTriangleVertices()};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getTriangleCoordinates=function(includeFrame){var visitor=new jsts.triangulate.quadedge.TriangleCoordinatesVisitor;this.visitTriangles(visitor,includeFrame);return visitor.getTriangles()};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getEdgesByFactory=function(geomFact){var quadEdges,edges,i,il,qe,coords;quadEdges=this.getPrimaryEdges(false);edges=[];i=0;il=quadEdges.length;for(i;i0){this.coordList.closeRing();pts=this.coordList.toArray();if(pts.length!==4){return}this.triCoords.push(pts)}};jsts.triangulate.quadedge.TriangleCoordinatesVisitor.prototype.getTriangles=function(){return this.triCoords};jsts.operation.relate.EdgeEndBundle=function(){this.edgeEnds=[];var e=arguments[0]instanceof jsts.geomgraph.EdgeEnd?arguments[0]:arguments[1];var edge=e.getEdge();var coord=e.getCoordinate();var dirCoord=e.getDirectedCoordinate();var label=new jsts.geomgraph.Label(e.getLabel());jsts.geomgraph.EdgeEnd.call(this,edge,coord,dirCoord,label);this.insert(e)};jsts.operation.relate.EdgeEndBundle.prototype=new jsts.geomgraph.EdgeEnd;jsts.operation.relate.EdgeEndBundle.prototype.edgeEnds=null;jsts.operation.relate.EdgeEndBundle.prototype.getLabel=function(){return this.label};jsts.operation.relate.EdgeEndBundle.prototype.getEdgeEnds=function(){return this.edgeEnds};jsts.operation.relate.EdgeEndBundle.prototype.insert=function(e){this.edgeEnds.push(e)};jsts.operation.relate.EdgeEndBundle.prototype.computeLabel=function(boundaryNodeRule){var isArea=false;for(var i=0;i0){loc=jsts.geomgraph.GeometryGraph.determineBoundary(boundaryNodeRule,boundaryCount)}this.label.setLocation(geomIndex,loc)};jsts.operation.relate.EdgeEndBundle.prototype.computeLabelSides=function(geomIndex){this.computeLabelSide(geomIndex,jsts.geomgraph.Position.LEFT);this.computeLabelSide(geomIndex,jsts.geomgraph.Position.RIGHT)};jsts.operation.relate.EdgeEndBundle.prototype.computeLabelSide=function(geomIndex,side){for(var i=0;imaxLen){maxLen=lenBC}if(lenCA>maxLen){maxLen=lenCA}return maxLen};jsts.geom.Triangle.angleBisector=function(a,b,c){var len0,len2,frac,dx,dy,splitPt;len0=b.distance(a);len2=b.distance(c);frac=len0/(len0+len2);dx=c.x-a.x;dy=c.y-a.y;splitPt=new jsts.geom.Coordinate(a.x+frac*dx,a.y+frac*dy);return splitPt};jsts.geom.Triangle.area=function(a,b,c){return Math.abs(((c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y))/2)};jsts.geom.Triangle.signedArea=function(a,b,c){return((c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y))/2};jsts.geom.Triangle.prototype.inCentre=function(){return jsts.geom.Triangle.inCentre(this.p0,this.p1,this.p2)};jsts.noding.OrientedCoordinateArray=function(pts){this.pts=pts;this._orientation=jsts.noding.OrientedCoordinateArray.orientation(pts)};jsts.noding.OrientedCoordinateArray.prototype.pts=null;jsts.noding.OrientedCoordinateArray.prototype._orientation=undefined;jsts.noding.OrientedCoordinateArray.orientation=function(pts){return jsts.geom.CoordinateArrays.increasingDirection(pts)===1};jsts.noding.OrientedCoordinateArray.prototype.compareTo=function(o1){var oca=o1;var comp=jsts.noding.OrientedCoordinateArray.compareOriented(this.pts,this._orientation,oca.pts,oca._orientation);return comp};jsts.noding.OrientedCoordinateArray.compareOriented=function(pts1,orientation1,pts2,orientation2){var dir1=orientation1?1:-1;var dir2=orientation2?1:-1;var limit1=orientation1?pts1.length:-1;var limit2=orientation2?pts2.length:-1;var i1=orientation1?0:pts1.length-1;var i2=orientation2?0:pts2.length-1;var comp=0;while(true){var compPt=pts1[i1].compareTo(pts2[i2]);if(compPt!==0)return compPt;i1+=dir1;i2+=dir2;var done1=i1===limit1;var done2=i2===limit2;if(done1&&!done2)return-1;if(!done1&&done2)return 1;if(done1&&done2)return 0}};jsts.algorithm.CentralEndpointIntersector=function(p00,p01,p10,p11){this.pts=[p00,p01,p10,p11];this.compute()};jsts.algorithm.CentralEndpointIntersector.getIntersection=function(p00,p01,p10,p11){var intor=new jsts.algorithm.CentralEndpointIntersector(p00,p01,p10,p11);return intor.getIntersection()};jsts.algorithm.CentralEndpointIntersector.prototype.pts=null;jsts.algorithm.CentralEndpointIntersector.prototype.intPt=null;jsts.algorithm.CentralEndpointIntersector.prototype.compute=function(){var centroid=jsts.algorithm.CentralEndpointIntersector.average(this.pts);this.intPt=this.findNearestPoint(centroid,this.pts)};jsts.algorithm.CentralEndpointIntersector.prototype.getIntersection=function(){return this.intPt};jsts.algorithm.CentralEndpointIntersector.average=function(pts){var avg=new jsts.geom.Coordinate;var i,n=pts.length;for(i=0;i0){avg.x/=n;avg.y/=n}return avg};jsts.algorithm.CentralEndpointIntersector.prototype.findNearestPoint=function(p,pts){var minDist=Number.MAX_VALUE;var i,result=null,dist;for(i=0;i0?distance:0;var bufEnvSize=envSize+2*expandByDistance;var bufEnvLog10=Math.log(bufEnvSize)/Math.log(10)+1;var minUnitLog10=bufEnvLog10-maxPrecisionDigits;var scaleFactor=Math.pow(10,-minUnitLog10);return scaleFactor};jsts.operation.buffer.BufferOp.bufferOp=function(g,distance){if(arguments.length>2){return jsts.operation.buffer.BufferOp.bufferOp2.apply(this,arguments)}var gBuf=new jsts.operation.buffer.BufferOp(g);var geomBuf=gBuf.getResultGeometry(distance);return geomBuf};jsts.operation.buffer.BufferOp.bufferOp2=function(g,distance,params){if(arguments.length>3){return jsts.operation.buffer.BufferOp.bufferOp3.apply(this,arguments)}var bufOp=new jsts.operation.buffer.BufferOp(g,params);var geomBuf=bufOp.getResultGeometry(distance);return geomBuf};jsts.operation.buffer.BufferOp.bufferOp3=function(g,distance,quadrantSegments){if(arguments.length>4){return jsts.operation.buffer.BufferOp.bufferOp4.apply(this,arguments)}var bufOp=new jsts.operation.buffer.BufferOp(g);bufOp.setQuadrantSegments(quadrantSegments);var geomBuf=bufOp.getResultGeometry(distance);return geomBuf};jsts.operation.buffer.BufferOp.bufferOp4=function(g,distance,quadrantSegments,endCapStyle){var bufOp=new jsts.operation.buffer.BufferOp(g);bufOp.setQuadrantSegments(quadrantSegments);bufOp.setEndCapStyle(endCapStyle);var geomBuf=bufOp.getResultGeometry(distance);return geomBuf};jsts.operation.buffer.BufferOp.prototype.argGeom=null;jsts.operation.buffer.BufferOp.prototype.distance=null;jsts.operation.buffer.BufferOp.prototype.bufParams=null;jsts.operation.buffer.BufferOp.prototype.resultGeometry=null;jsts.operation.buffer.BufferOp.prototype.setEndCapStyle=function(endCapStyle){this.bufParams.setEndCapStyle(endCapStyle)};jsts.operation.buffer.BufferOp.prototype.setQuadrantSegments=function(quadrantSegments){this.bufParams.setQuadrantSegments(quadrantSegments)};jsts.operation.buffer.BufferOp.prototype.getResultGeometry=function(dist){this.distance=dist;this.computeGeometry();return this.resultGeometry};jsts.operation.buffer.BufferOp.prototype.computeGeometry=function(){this.bufferOriginalPrecision();if(this.resultGeometry!==null){return}var argPM=this.argGeom.getPrecisionModel();if(argPM.getType()===jsts.geom.PrecisionModel.FIXED){this.bufferFixedPrecision(argPM)}else{this.bufferReducedPrecision()}};jsts.operation.buffer.BufferOp.prototype.bufferReducedPrecision=function(){var precDigits;var saveException=null;for(precDigits=jsts.operation.buffer.BufferOp.MAX_PRECISION_DIGITS;precDigits>=0;precDigits--){try{this.bufferReducedPrecision2(precDigits)}catch(ex){saveException=ex}if(this.resultGeometry!==null){return}}throw saveException};jsts.operation.buffer.BufferOp.prototype.bufferOriginalPrecision=function(){try{var bufBuilder=new jsts.operation.buffer.BufferBuilder(this.bufParams);this.resultGeometry=bufBuilder.buffer(this.argGeom,this.distance)}catch(e){}};jsts.operation.buffer.BufferOp.prototype.bufferReducedPrecision2=function(precisionDigits){var sizeBasedScaleFactor=jsts.operation.buffer.BufferOp.precisionScaleFactor(this.argGeom,this.distance,precisionDigits); var fixedPM=new jsts.geom.PrecisionModel(sizeBasedScaleFactor);this.bufferFixedPrecision(fixedPM)};jsts.operation.buffer.BufferOp.prototype.bufferFixedPrecision=function(fixedPM){var noder=new jsts.noding.ScaledNoder(new jsts.noding.snapround.MCIndexSnapRounder(new jsts.geom.PrecisionModel(1)),fixedPM.getScale());var bufBuilder=new jsts.operation.buffer.BufferBuilder(this.bufParams);bufBuilder.setWorkingPrecisionModel(fixedPM);bufBuilder.setNoder(noder);this.resultGeometry=bufBuilder.buffer(this.argGeom,this.distance)};jsts.operation.buffer.OffsetSegmentString=function(){this.ptList=[]};jsts.operation.buffer.OffsetSegmentString.prototype.ptList=null;jsts.operation.buffer.OffsetSegmentString.prototype.precisionModel=null;jsts.operation.buffer.OffsetSegmentString.prototype.minimimVertexDistance=0;jsts.operation.buffer.OffsetSegmentString.prototype.setPrecisionModel=function(precisionModel){this.precisionModel=precisionModel};jsts.operation.buffer.OffsetSegmentString.prototype.setMinimumVertexDistance=function(minimimVertexDistance){this.minimimVertexDistance=minimimVertexDistance};jsts.operation.buffer.OffsetSegmentString.prototype.addPt=function(pt){var bufPt=new jsts.geom.Coordinate(pt);this.precisionModel.makePrecise(bufPt);if(this.isRedundant(bufPt))return;this.ptList.push(bufPt)};jsts.operation.buffer.OffsetSegmentString.prototype.addPts=function(pt,isForward){if(isForward){for(var i=0;i=0;i--){this.addPt(pt[i])}}};jsts.operation.buffer.OffsetSegmentString.prototype.isRedundant=function(pt){if(this.ptList.length<1)return false;var lastPt=this.ptList[this.ptList.length-1];var ptDist=pt.distance(lastPt);if(ptDist=2)last2Pt=this.ptList[this.ptList.length-2];if(startPt.equals(lastPt))return;this.ptList.push(startPt)};jsts.operation.buffer.OffsetSegmentString.prototype.reverse=function(){};jsts.operation.buffer.OffsetSegmentString.prototype.getCoordinates=function(){return this.ptList};jsts.algorithm.distance.PointPairDistance=function(){this.pt=[new jsts.geom.Coordinate,new jsts.geom.Coordinate]};jsts.algorithm.distance.PointPairDistance.prototype.pt=null;jsts.algorithm.distance.PointPairDistance.prototype.distance=NaN;jsts.algorithm.distance.PointPairDistance.prototype.isNull=true;jsts.algorithm.distance.PointPairDistance.prototype.initialize=function(p0,p1,distance){if(p0===undefined){this.isNull=true;return}this.pt[0].setCoordinate(p0);this.pt[1].setCoordinate(p1);this.distance=distance!==undefined?distance:p0.distance(p1);this.isNull=false};jsts.algorithm.distance.PointPairDistance.prototype.getDistance=function(){return this.distance};jsts.algorithm.distance.PointPairDistance.prototype.getCoordinates=function(){return this.pt};jsts.algorithm.distance.PointPairDistance.prototype.getCoordinate=function(i){return this.pt[i]};jsts.algorithm.distance.PointPairDistance.prototype.setMaximum=function(ptDist){if(arguments.length===2){this.setMaximum2.apply(this,arguments);return}this.setMaximum(ptDist.pt[0],ptDist.pt[1])};jsts.algorithm.distance.PointPairDistance.prototype.setMaximum2=function(p0,p1){if(this.isNull){this.initialize(p0,p1);return}var dist=p0.distance(p1);if(dist>this.distance)this.initialize(p0,p1,dist)};jsts.algorithm.distance.PointPairDistance.prototype.setMinimum=function(ptDist){if(arguments.length===2){this.setMinimum2.apply(this,arguments);return}this.setMinimum(ptDist.pt[0],ptDist.pt[1])};jsts.algorithm.distance.PointPairDistance.prototype.setMinimum2=function(p0,p1){if(this.isNull){this.initialize(p0,p1);return}var dist=p0.distance(p1);if(dist1||densifyFrac<=0)throw new jsts.error.IllegalArgumentError("Fraction is not in range (0.0 - 1.0]");this.densifyFrac=densifyFrac};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.distance=function(){this.compute(this.g0,this.g1);return ptDist.getDistance()};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.orientedDistance=function(){this.computeOrientedDistance(this.g0,this.g1,this.ptDist);return this.ptDist.getDistance()};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.getCoordinates=function(){return ptDist.getCoordinates()};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.compute=function(g0,g1){this.computeOrientedDistance(g0,g1,this.ptDist);this.computeOrientedDistance(g1,g0,this.ptDist)};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.computeOrientedDistance=function(discreteGeom,geom,ptDist){var distFilter=new MaxPointDistanceFilter(geom);discreteGeom.apply(distFilter);ptDist.setMaximum(distFilter.getMaxPointDistance());if(this.densifyFrac>0){var fracFilter=new MaxDensifiedByFractionDistanceFilter(geom,this.densifyFrac);discreteGeom.apply(fracFilter);ptDist.setMaximum(fracFilter.getMaxPointDistance())}}})();(function(){var ArrayList=javascript.util.ArrayList;var TreeSet=javascript.util.TreeSet;var CoordinateFilter=jsts.geom.CoordinateFilter;jsts.util.UniqueCoordinateArrayFilter=function(){this.treeSet=new TreeSet;this.list=new ArrayList};jsts.util.UniqueCoordinateArrayFilter.prototype=new CoordinateFilter;jsts.util.UniqueCoordinateArrayFilter.prototype.treeSet=null;jsts.util.UniqueCoordinateArrayFilter.prototype.list=null;jsts.util.UniqueCoordinateArrayFilter.prototype.getCoordinates=function(){return this.list.toArray()};jsts.util.UniqueCoordinateArrayFilter.prototype.filter=function(coord){if(!this.treeSet.contains(coord)){this.list.add(coord);this.treeSet.add(coord)}}})();(function(){var CGAlgorithms=jsts.algorithm.CGAlgorithms;var UniqueCoordinateArrayFilter=jsts.util.UniqueCoordinateArrayFilter;var Assert=jsts.util.Assert;var Stack=javascript.util.Stack;var ArrayList=javascript.util.ArrayList;var Arrays=javascript.util.Arrays;var RadialComparator=function(origin){this.origin=origin};RadialComparator.prototype.origin=null;RadialComparator.prototype.compare=function(o1,o2){var p1=o1;var p2=o2;return RadialComparator.polarCompare(this.origin,p1,p2)};RadialComparator.polarCompare=function(o,p,q){var dxp=p.x-o.x;var dyp=p.y-o.y;var dxq=q.x-o.x;var dyq=q.y-o.y;var orient=CGAlgorithms.computeOrientation(o,p,q);if(orient==CGAlgorithms.COUNTERCLOCKWISE)return 1;if(orient==CGAlgorithms.CLOCKWISE)return-1;var op=dxp*dxp+dyp*dyp;var oq=dxq*dxq+dyq*dyq;if(opoq){return 1}return 0};jsts.algorithm.ConvexHull=function(){if(arguments.length===1){var geometry=arguments[0];this.inputPts=jsts.algorithm.ConvexHull.extractCoordinates(geometry);this.geomFactory=geometry.getFactory()}else{this.pts=arguments[0];this.geomFactory=arguments[1]}};jsts.algorithm.ConvexHull.prototype.geomFactory=null;jsts.algorithm.ConvexHull.prototype.inputPts=null;jsts.algorithm.ConvexHull.extractCoordinates=function(geom){var filter=new UniqueCoordinateArrayFilter;geom.apply(filter);return filter.getCoordinates()};jsts.algorithm.ConvexHull.prototype.getConvexHull=function(){if(this.inputPts.length==0){return this.geomFactory.createGeometryCollection(null)}if(this.inputPts.length==1){return this.geomFactory.createPoint(this.inputPts[0])}if(this.inputPts.length==2){return this.geomFactory.createLineString(this.inputPts)}var reducedPts=this.inputPts;if(this.inputPts.length>50){reducedPts=this.reduce(this.inputPts)}var sortedPts=this.preSort(reducedPts);var cHS=this.grahamScan(sortedPts);var cH=cHS.toArray();return this.lineOrPolygon(cH)};jsts.algorithm.ConvexHull.prototype.reduce=function(inputPts){var polyPts=this.computeOctRing(inputPts);if(polyPts==null)return this.inputPts;var reducedSet=new javascript.util.TreeSet;for(var i=0;i0){p=ps.pop()}p=ps.push(p);p=ps.push(c[i])}p=ps.push(c[0]);return ps};jsts.algorithm.ConvexHull.prototype.isBetween=function(c1,c2,c3){if(CGAlgorithms.computeOrientation(c1,c2,c3)!==0){return false}if(c1.x!=c3.x){if(c1.x<=c2.x&&c2.x<=c3.x){return true}if(c3.x<=c2.x&&c2.x<=c1.x){return true}}if(c1.y!=c3.y){if(c1.y<=c2.y&&c2.y<=c3.y){return true}if(c3.y<=c2.y&&c2.y<=c1.y){return true}}return false};jsts.algorithm.ConvexHull.prototype.computeOctRing=function(inputPts){var octPts=this.computeOctPts(inputPts);var coordList=new jsts.geom.CoordinateList;coordList.add(octPts,false);if(coordList.size()<3){return null}coordList.closeRing();return coordList.toCoordinateArray()};jsts.algorithm.ConvexHull.prototype.computeOctPts=function(inputPts){var pts=[];for(var j=0;j<8;j++){pts[j]=inputPts[0]}for(var i=1;ipts[2].y){pts[2]=inputPts[i]}if(inputPts[i].x+inputPts[i].y>pts[3].x+pts[3].y){pts[3]=inputPts[i]}if(inputPts[i].x>pts[4].x){pts[4]=inputPts[i]}if(inputPts[i].x-inputPts[i].y>pts[5].x-pts[5].y){pts[5]=inputPts[i]}if(inputPts[i].y=2,"found LineString with single point");this.insertBoundaryPoint(this.argIndex,coord[0]);this.insertBoundaryPoint(this.argIndex,coord[coord.length-1])};jsts.geomgraph.GeometryGraph.prototype.addPolygonRing=function(lr,cwLeft,cwRight){if(lr.isEmpty())return;var coord=jsts.geom.CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());if(coord.length<4){this.hasTooFewPoints=true;this.invalidPoint=coord[0];return}var left=cwLeft;var right=cwRight;if(jsts.algorithm.CGAlgorithms.isCCW(coord)){left=cwRight;right=cwLeft}var e=new jsts.geomgraph.Edge(coord,new jsts.geomgraph.Label(this.argIndex,Location.BOUNDARY,left,right));this.lineEdgeMap.put(lr,e);this.insertEdge(e);this.insertPoint(this.argIndex,coord[0],Location.BOUNDARY)};jsts.geomgraph.GeometryGraph.prototype.addPolygon=function(p){this.addPolygonRing(p.getExteriorRing(),Location.EXTERIOR,Location.INTERIOR);for(var i=0;i=this.size()){throw new IndexOutOfBoundsException}return this.array[index]};ArrayList.prototype.isEmpty=function(){return this.array.length===0};ArrayList.prototype.size=function(){return this.array.length};ArrayList.prototype.toArray=function(){var array=[];for(var i=0,len=this.array.length;i/g;var reLeadingSpacesAndZeros=RegExp("^["+whitespace+"]*0+(?=.$)");var reNoMatch=/($^)/;var reThis=/\bthis\b/;var reUnescapedString=/['\n\r\t\u2028\u2029\\]/g;var contextProps=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"];var templateCounter=0;var argsClass="[object Arguments]",arrayClass="[object Array]",boolClass="[object Boolean]",dateClass="[object Date]",funcClass="[object Function]",numberClass="[object Number]",objectClass="[object Object]",regexpClass="[object RegExp]",stringClass="[object String]";var cloneableClasses={};cloneableClasses[funcClass]=false;cloneableClasses[argsClass]=cloneableClasses[arrayClass]=cloneableClasses[boolClass]=cloneableClasses[dateClass]=cloneableClasses[numberClass]=cloneableClasses[objectClass]=cloneableClasses[regexpClass]=cloneableClasses[stringClass]=true;var debounceOptions={leading:false,maxWait:0,trailing:false};var descriptor={configurable:false,enumerable:false,value:null,writable:false};var objectTypes={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false};var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};var root=objectTypes[typeof window]&&window||this;var freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports;var freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports;var freeGlobal=objectTypes[typeof global]&&global;if(freeGlobal&&(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal)){root=freeGlobal}function baseIndexOf(array,value,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0;while(++index-1?0:-1:cache?0:-1}function cachePush(value){var cache=this.cache,type=typeof value;if(type=="boolean"||value==null){cache[value]=true}else{if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value,typeCache=cache[type]||(cache[type]={});if(type=="object"){(typeCache[key]||(typeCache[key]=[])).push(value)}else{typeCache[key]=true}}}function charAtCallback(value){return value.charCodeAt(0)}function compareAscending(a,b){var ac=a.criteria,bc=b.criteria,index=-1,length=ac.length;while(++indexother||typeof value=="undefined"){return 1}if(value/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:reInterpolate,variable:"",imports:{_:lodash}};function baseBind(bindData){var func=bindData[0],partialArgs=bindData[2],thisArg=bindData[4];function bound(){if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(this instanceof bound){var thisBinding=baseCreate(func.prototype),result=func.apply(thisBinding,args||arguments);return isObject(result)?result:thisBinding}return func.apply(thisArg,args||arguments)}setBindData(bound,bindData);return bound}function baseClone(value,isDeep,callback,stackA,stackB){if(callback){var result=callback(value);if(typeof result!="undefined"){return result}}var isObj=isObject(value);if(isObj){var className=toString.call(value);if(!cloneableClasses[className]){return value}var ctor=ctorByClass[className];switch(className){case boolClass:case dateClass:return new ctor(+value);case numberClass:case stringClass:return new ctor(value);case regexpClass:result=ctor(value.source,reFlags.exec(value));result.lastIndex=value.lastIndex;return result}}else{return value}var isArr=isArray(value);if(isDeep){var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==value){return stackB[length]}}result=isArr?ctor(value.length):{}}else{result=isArr?slice(value):assign({},value)}if(isArr){if(hasOwnProperty.call(value,"index")){result.index=value.index}if(hasOwnProperty.call(value,"input")){result.input=value.input}}if(!isDeep){return result}stackA.push(value);stackB.push(result);(isArr?forEach:forOwn)(value,function(objValue,key){result[key]=baseClone(objValue,isDeep,callback,stackA,stackB)});if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||context.Object()}}()}function baseCreateCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(typeof thisArg=="undefined"||!("prototype"in func)){return func}var bindData=func.__bindData__;if(typeof bindData=="undefined"){if(support.funcNames){bindData=!func.name}bindData=bindData||!support.funcDecomp;if(!bindData){var source=fnToString.call(func);if(!support.funcNames){bindData=!reFuncName.test(source)}if(!bindData){bindData=reThis.test(source);setBindData(func,bindData)}}}if(bindData===false||bindData!==true&&bindData[1]&1){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 2:return function(a,b){return func.call(thisArg,a,b)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)}}return bind(func,thisArg)}function baseCreateWrapper(bindData){var func=bindData[0],bitmask=bindData[1],partialArgs=bindData[2],partialRightArgs=bindData[3],thisArg=bindData[4],arity=bindData[5];var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,key=func;function bound(){var thisBinding=isBind?thisArg:this;if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(partialRightArgs||isCurry){args||(args=slice(arguments));if(partialRightArgs){push.apply(args,partialRightArgs)}if(isCurry&&args.length=largeArraySize&&indexOf===baseIndexOf,result=[];if(isLarge){var cache=createCache(values);if(cache){indexOf=cacheIndexOf;values=cache}else{isLarge=false}}while(++index-1}})}}stackA.pop();stackB.pop();if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseMerge(object,source,callback,stackA,stackB){(isArray(source)?forEach:forOwn)(source,function(source,key){var found,isArr,result=source,value=object[key];if(source&&((isArr=isArray(source))||isPlainObject(source))){var stackLength=stackA.length;while(stackLength--){if(found=stackA[stackLength]==source){value=stackB[stackLength];break}}if(!found){var isShallow;if(callback){result=callback(value,source);if(isShallow=typeof result!="undefined"){value=result}}if(!isShallow){value=isArr?isArray(value)?value:[]:isPlainObject(value)?value:{}}stackA.push(source);stackB.push(value);if(!isShallow){baseMerge(value,source,callback,stackA,stackB)}}}else{if(callback){result=callback(value,source);if(typeof result=="undefined"){result=source}}if(typeof result!="undefined"){value=result}}object[key]=value})}function baseRandom(min,max){return min+floor(nativeRandom()*(max-min+1))}function baseUniq(array,isSorted,callback){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,result=[];var isLarge=!isSorted&&length>=largeArraySize&&indexOf===baseIndexOf,seen=callback||isLarge?getArray():result;if(isLarge){var cache=createCache(seen);indexOf=cacheIndexOf;seen=cache}while(++index":">",'"':""","'":"'"};var htmlUnescapes=invert(htmlEscapes);var reEscapedHtml=RegExp("("+keys(htmlUnescapes).join("|")+")","g"),reUnescapedHtml=RegExp("["+keys(htmlEscapes).join("")+"]","g");var assign=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;if(argsLength>3&&typeof args[argsLength-2]=="function"){var callback=baseCreateCallback(args[--argsLength-1],args[argsLength--],2)}else if(argsLength>2&&typeof args[argsLength-1]=="function"){callback=args[--argsLength]}while(++argsIndex3&&typeof args[length-2]=="function"){var callback=baseCreateCallback(args[--length-1],args[length--],2)}else if(length>2&&typeof args[length-1]=="function"){callback=args[--length]}var sources=slice(arguments,1,length),index=-1,stackA=getArray(),stackB=getArray();while(++index-1}else if(typeof length=="number"){result=(isString(collection)?collection.indexOf(target,fromIndex):indexOf(collection,target,fromIndex))>-1}else{forOwn(collection,function(value){if(++index>=fromIndex){return!(result=value===target)}})}return result}var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?result[key]++:result[key]=1});function every(collection,callback,thisArg){var result=true;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++indexresult){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current>computed){computed=current;result=value}})}return result}function min(collection,callback,thisArg){var computed=Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index=largeArraySize&&createCache(argsIndex?args[argsIndex]:seen))}}var array=args[0],index=-1,length=array?array.length:0,result=[];outer:while(++index>>1;callback(array[mid])1?arguments:arguments[0],index=-1,length=array?max(pluck(array,"length")):0,result=Array(length<0?0:length);while(++index2?createWrapper(func,17,slice(arguments,2),null,thisArg):createWrapper(func,1,null,null,thisArg)}function bindAll(object){var funcs=arguments.length>1?baseFlatten(arguments,true,false,1):functions(object),index=-1,length=funcs.length;while(++index2?createWrapper(key,19,slice(arguments,2),null,object):createWrapper(key,3,null,null,object)}function compose(){var funcs=arguments,length=funcs.length;while(length--){if(!isFunction(funcs[length])){throw new TypeError}}return function(){var args=arguments,length=funcs.length;while(length--){args=[funcs[length].apply(this,args)]}return args[0]}}function curry(func,arity){arity=typeof arity=="number"?arity:+arity||func.length;return createWrapper(func,4,null,null,null,arity)}function debounce(func,wait,options){var args,maxTimeoutId,result,stamp,thisArg,timeoutId,trailingCall,lastCalled=0,maxWait=false,trailing=true;if(!isFunction(func)){throw new TypeError}wait=nativeMax(0,wait)||0;if(options===true){var leading=true;trailing=false}else if(isObject(options)){leading=options.leading;maxWait="maxWait"in options&&(nativeMax(wait,options.maxWait)||0);trailing="trailing"in options?options.trailing:trailing}var delayed=function(){var remaining=wait-(now()-stamp);if(remaining<=0){if(maxTimeoutId){clearTimeout(maxTimeoutId)}var isCalled=trailingCall;maxTimeoutId=timeoutId=trailingCall=undefined;if(isCalled){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}}else{timeoutId=setTimeout(delayed,remaining)}};var maxDelayed=function(){if(timeoutId){clearTimeout(timeoutId)}maxTimeoutId=timeoutId=trailingCall=undefined;if(trailing||maxWait!==wait){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}};return function(){args=arguments;stamp=now();thisArg=this;trailingCall=trailing&&(timeoutId||!leading);if(maxWait===false){var leadingCall=leading&&!timeoutId}else{if(!maxTimeoutId&&!leading){lastCalled=stamp}var remaining=maxWait-(stamp-lastCalled),isCalled=remaining<=0;if(isCalled){if(maxTimeoutId){maxTimeoutId=clearTimeout(maxTimeoutId)}lastCalled=stamp;result=func.apply(thisArg,args)}else if(!maxTimeoutId){maxTimeoutId=setTimeout(maxDelayed,remaining)}}if(isCalled&&timeoutId){timeoutId=clearTimeout(timeoutId)}else if(!timeoutId&&wait!==maxWait){timeoutId=setTimeout(delayed,wait)}if(leadingCall){isCalled=true;result=func.apply(thisArg,args)}if(isCalled&&!timeoutId&&!maxTimeoutId){args=thisArg=null}return result}}function defer(func){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,1);return setTimeout(function(){func.apply(undefined,args)},1)}function delay(func,wait){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,2);return setTimeout(function(){func.apply(undefined,args)},wait)}function memoize(func,resolver){if(!isFunction(func)){throw new TypeError}var memoized=function(){var cache=memoized.cache,key=resolver?resolver.apply(this,arguments):keyPrefix+arguments[0];return hasOwnProperty.call(cache,key)?cache[key]:cache[key]=func.apply(this,arguments)};memoized.cache={};return memoized}function once(func){var ran,result;if(!isFunction(func)){throw new TypeError}return function(){if(ran){return result}ran=true;result=func.apply(this,arguments);func=null;return result}}function partial(func){return createWrapper(func,16,slice(arguments,1))}function partialRight(func){return createWrapper(func,32,null,slice(arguments,1))}function throttle(func,wait,options){var leading=true,trailing=true;if(!isFunction(func)){throw new TypeError}if(options===false){leading=false}else if(isObject(options)){leading="leading"in options?options.leading:leading;trailing="trailing"in options?options.trailing:trailing}debounceOptions.leading=leading;debounceOptions.maxWait=wait;debounceOptions.trailing=trailing;return debounce(func,wait,debounceOptions)}function wrap(value,wrapper){return createWrapper(wrapper,16,[value])}function constant(value){return function(){return value}}function createCallback(func,thisArg,argCount){var type=typeof func;if(func==null||type=="function"){return baseCreateCallback(func,thisArg,argCount)}if(type!="object"){return property(func)}var props=keys(func),key=props[0],a=func[key];if(props.length==1&&a===a&&!isObject(a)){return function(object){var b=object[key];return a===b&&(a!==0||1/a==1/b)}}return function(object){var length=props.length,result=false;while(length--){if(!(result=baseIsEqual(object[props[length]],func[props[length]],null,true))){break}}return result}}function escape(string){return string==null?"":String(string).replace(reUnescapedHtml,escapeHtmlChar)}function identity(value){return value}function mixin(object,source,options){var chain=true,methodNames=source&&functions(source);if(!source||!options&&!methodNames.length){if(options==null){options=source}ctor=lodashWrapper;source=object;object=lodash;methodNames=functions(source)}if(options===false){chain=false}else if(isObject(options)&&"chain"in options){chain=options.chain}var ctor=object,isFunc=isFunction(ctor);forEach(methodNames,function(methodName){var func=object[methodName]=source[methodName];if(isFunc){ctor.prototype[methodName]=function(){var chainAll=this.__chain__,value=this.__wrapped__,args=[value];push.apply(args,arguments);var result=func.apply(object,args);if(chain||chainAll){if(value===result&&isObject(result)){return this}result=new ctor(result);result.__chain__=chainAll}return result}}})}function noConflict(){context._=oldDash;return this}function noop(){}var now=isNative(now=Date.now)&&now||function(){return(new Date).getTime()};var parseInt=nativeParseInt(whitespace+"08")==8?nativeParseInt:function(value,radix){return nativeParseInt(isString(value)?value.replace(reLeadingSpacesAndZeros,""):value,radix||0)};function property(key){return function(object){return object[key]}}function random(min,max,floating){var noMin=min==null,noMax=max==null;if(floating==null){if(typeof min=="boolean"&&noMax){floating=min;min=1}else if(!noMax&&typeof max=="boolean"){floating=max;noMax=true}}if(noMin&&noMax){max=1}min=+min||0;if(noMax){max=min;min=0}else{max=+max||0}if(floating||min%1||max%1){var rand=nativeRandom();return nativeMin(min+rand*(max-min+parseFloat("1e-"+((rand+"").length-1))),max)}return baseRandom(min,max)}function result(object,key){if(object){var value=object[key];return isFunction(value)?object[key]():value}}function template(text,data,options){var settings=lodash.templateSettings;text=String(text||"");options=defaults({},options,settings);var imports=defaults({},options.imports,settings.imports),importsKeys=keys(imports),importsValues=values(imports);var isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";var reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g");text.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);source+=text.slice(index,offset).replace(reUnescapedString,escapeStringChar);if(escapeValue){source+="' +\n__e("+escapeValue+") +\n'"}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '"}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"}index=offset+match.length;return match});source+="';\n";var variable=options.variable,hasVariable=variable;if(!hasVariable){variable="obj";source="with ("+variable+") {\n"+source+"\n}\n"}source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;");source="function("+variable+") {\n"+(hasVariable?"":variable+" || ("+variable+" = {});\n")+"var __t, __p = '', __e = _.escape"+(isEvaluating?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var sourceURL="\n/*\n//# sourceURL="+(options.sourceURL||"/lodash/template/source["+templateCounter++ +"]")+"\n*/";try{var result=Function(importsKeys,"return "+source+sourceURL).apply(undefined,importsValues)}catch(e){e.source=source;throw e}if(data){return result(data)}result.source=source;return result}function times(n,callback,thisArg){n=(n=+n)>-1?n:0;var index=-1,result=Array(n);callback=baseCreateCallback(callback,thisArg,1);while(++indexvalue||value===undefined)value=x[i]}return value}function variance(x){if(x.length===0)return null;var mean_value=mean(x),deviations=[];for(var i=0;imax_seen){max_seen=seen_this;seen_this=1;value=last}last=sorted[i]}else{seen_this++}}return value}function t_test(sample,x){var sample_mean=mean(sample); var sd=standard_deviation(sample);var rootN=Math.sqrt(sample.length);return(sample_mean-x)/(sd/rootN)}function t_test_two_sample(sample_x,sample_y,difference){var n=sample_x.length,m=sample_y.length;if(!n||!m)return null;if(!difference)difference=0;var meanX=mean(sample_x),meanY=mean(sample_y);var weightedVariance=((n-1)*sample_variance(sample_x)+(m-1)*sample_variance(sample_y))/(n+m-2);return(meanX-meanY-difference)/Math.sqrt(weightedVariance*(1/n+1/m))}function quantile(sample,p){if(sample.length===0)return null;var sorted=sample.slice().sort(function(a,b){return a-b});if(p.length){var results=[];for(var i=0;i1){return null}else if(p===1){return sample[sample.length-1]}else if(p===0){return sample[0]}else if(idx%1!==0){return sample[Math.ceil(idx)-1]}else if(sample.length%2===0){return(sample[idx-1]+sample[idx])/2}else{return sample[idx]}}function iqr(sample){if(sample.length===0)return null;return quantile(sample,.75)-quantile(sample,.25)}function mad(x){if(!x||x.length===0)return null;var median_value=median(x),median_absolute_deviations=[];for(var i=0;i=variance+variance_combinations[i4][j-1]){lower_class_limits[l][j]=lower_class_limit;variance_combinations[l][j]=variance+variance_combinations[i4][j-1]}}}}lower_class_limits[l][1]=1;variance_combinations[l][1]=variance}return{lower_class_limits:lower_class_limits,variance_combinations:variance_combinations}}function jenksBreaks(data,lower_class_limits,n_classes){var k=data.length-1,kclass=[],countNum=n_classes;kclass[n_classes]=data[data.length-1];kclass[0]=data[0];while(countNum>1){kclass[countNum-1]=data[lower_class_limits[k][countNum]-2];k=lower_class_limits[k][countNum]-1;countNum--}return kclass}function jenks(data,n_classes){if(n_classes>data.length)return null;data=data.slice().sort(function(a,b){return a-b});var matrices=jenksMatrices(data,n_classes),lower_class_limits=matrices.lower_class_limits;return jenksBreaks(data,lower_class_limits,n_classes)}function sample_skewness(x){if(x.length<3)return null;var n=x.length,cubed_s=Math.pow(sample_standard_deviation(x),3),sum_cubed_deviations=sum_nth_power_deviations(x,3);return n*sum_cubed_deviations/((n-1)*(n-2)*cubed_s)}var standard_normal_table=[.5,.504,.508,.512,.516,.5199,.5239,.5279,.5319,.5359,.5398,.5438,.5478,.5517,.5557,.5596,.5636,.5675,.5714,.5753,.5793,.5832,.5871,.591,.5948,.5987,.6026,.6064,.6103,.6141,.6179,.6217,.6255,.6293,.6331,.6368,.6406,.6443,.648,.6517,.6554,.6591,.6628,.6664,.67,.6736,.6772,.6808,.6844,.6879,.6915,.695,.6985,.7019,.7054,.7088,.7123,.7157,.719,.7224,.7257,.7291,.7324,.7357,.7389,.7422,.7454,.7486,.7517,.7549,.758,.7611,.7642,.7673,.7704,.7734,.7764,.7794,.7823,.7852,.7881,.791,.7939,.7967,.7995,.8023,.8051,.8078,.8106,.8133,.8159,.8186,.8212,.8238,.8264,.8289,.8315,.834,.8365,.8389,.8413,.8438,.8461,.8485,.8508,.8531,.8554,.8577,.8599,.8621,.8643,.8665,.8686,.8708,.8729,.8749,.877,.879,.881,.883,.8849,.8869,.8888,.8907,.8925,.8944,.8962,.898,.8997,.9015,.9032,.9049,.9066,.9082,.9099,.9115,.9131,.9147,.9162,.9177,.9192,.9207,.9222,.9236,.9251,.9265,.9279,.9292,.9306,.9319,.9332,.9345,.9357,.937,.9382,.9394,.9406,.9418,.9429,.9441,.9452,.9463,.9474,.9484,.9495,.9505,.9515,.9525,.9535,.9545,.9554,.9564,.9573,.9582,.9591,.9599,.9608,.9616,.9625,.9633,.9641,.9649,.9656,.9664,.9671,.9678,.9686,.9693,.9699,.9706,.9713,.9719,.9726,.9732,.9738,.9744,.975,.9756,.9761,.9767,.9772,.9778,.9783,.9788,.9793,.9798,.9803,.9808,.9812,.9817,.9821,.9826,.983,.9834,.9838,.9842,.9846,.985,.9854,.9857,.9861,.9864,.9868,.9871,.9875,.9878,.9881,.9884,.9887,.989,.9893,.9896,.9898,.9901,.9904,.9906,.9909,.9911,.9913,.9916,.9918,.992,.9922,.9925,.9927,.9929,.9931,.9932,.9934,.9936,.9938,.994,.9941,.9943,.9945,.9946,.9948,.9949,.9951,.9952,.9953,.9955,.9956,.9957,.9959,.996,.9961,.9962,.9963,.9964,.9965,.9966,.9967,.9968,.9969,.997,.9971,.9972,.9973,.9974,.9974,.9975,.9976,.9977,.9977,.9978,.9979,.9979,.998,.9981,.9981,.9982,.9982,.9983,.9984,.9984,.9985,.9985,.9986,.9986,.9987,.9987,.9987,.9988,.9988,.9989,.9989,.9989,.999,.999];function cumulative_std_normal_probability(z){var absZ=Math.abs(z),row=Math.floor(absZ*10),column=10*(Math.floor(absZ*100)/10-Math.floor(absZ*100/10)),index=Math.min(row*10+column,standard_normal_table.length-1);if(z>=0){return standard_normal_table[index]}else{return+(1-standard_normal_table[index]).toFixed(4)}}function z_score(x,mean,standard_deviation){return(x-mean)/standard_deviation}function mixin(){var support=!!(Object.defineProperty&&Object.defineProperties);if(!support)throw new Error("without defineProperty, simple-statistics cannot be mixed in");var arrayMethods=["median","standard_deviation","sum","sample_skewness","mean","min","max","quantile","geometric_mean","harmonic_mean"];function wrap(method){return function(){var args=Array.prototype.slice.apply(arguments);args.unshift(this);return ss[method].apply(ss,args)}}for(var i=0;ix1)x1=x;if(yy1)y1=y}function boundLine(coordinates){coordinates.forEach(boundPoint)}function boundMultiLine(coordinates){coordinates.forEach(boundLine)}for(var key in objects){boundGeometry(objects[key])}return[x0,y0,x1,y1]}},{}],71:[function(_dereq_,module,exports){exports.name="cartesian";exports.formatDistance=formatDistance;exports.ringArea=ringArea;exports.absoluteArea=Math.abs;exports.triangleArea=triangleArea;exports.distance=distance;function formatDistance(d){return d.toString()}function ringArea(ring){var i=0,n=ring.length,area=ring[n-1][1]*ring[0][0]-ring[n-1][0]*ring[0][1];while(++imax)max=area,best=i}if(best){t=rings[best],rings[best]=rings[0],rings[0]=t;t=areas[best],areas[best]=areas[0],areas[0]=t}if(areas[0]<0)reverse(rings[0]);for(var i=1;i0)reverse(rings[i])}}}function noop(){}},{"../../":68,"./coordinate-systems":74,"./type":94}],73:[function(_dereq_,module,exports){module.exports=function(objects,id){if(arguments.length<2)id=function(d){return d.id};function idObject(object){if(object&&idObjectType.hasOwnProperty(object.type))idObjectType[object.type](object)}function idFeature(feature){var i=id(feature);if(i==null)delete feature.id;else feature.id=i}var idObjectType={Feature:idFeature,FeatureCollection:function(collection){collection.features.forEach(idFeature)}};for(var key in objects){idObject(objects[key])}return objects}},{}],74:[function(_dereq_,module,exports){module.exports={cartesian:_dereq_("./cartesian"),spherical:_dereq_("./spherical")}},{"./cartesian":71,"./spherical":82}],75:[function(_dereq_,module,exports){module.exports=function(topology){var arcs=topology.arcs,i=-1,n=arcs.length;while(++i0))minimumArea=Number.MIN_VALUE;var filter=type({LineString:noop,MultiLineString:noop,Point:noop,MultiPoint:noop,Polygon:function(polygon){polygon.arcs=filterPolygon(polygon.arcs);if(!polygon.arcs||!polygon.arcs.length){polygon.type=null;delete polygon.arcs}},MultiPolygon:function(multiPolygon){multiPolygon.arcs=multiPolygon.arcs.map(filterPolygon).filter(function(polygon){return polygon&&polygon.length});if(!multiPolygon.arcs.length){multiPolygon.type=null;delete multiPolygon.arcs}},GeometryCollection:function(collection){this.defaults.GeometryCollection.call(this,collection);collection.geometries=collection.geometries.filter(function(geometry){return geometry.type!=null});if(!collection.geometries.length){collection.type=null;delete collection.geometries}}});for(var key in topology.objects){filter.object(topology.objects[key])}prune(topology,options);function filterPolygon(arcs){return arcs.length&&filterExteriorRing(arcs[0])?[arcs.shift()].concat(arcs.filter(filterInteriorRing)):null}function filterExteriorRing(ring){return system.absoluteArea(ringArea(ring))>=minimumArea}function filterInteriorRing(ring){return system.absoluteArea(-ringArea(ring))>=minimumArea}function ringArea(ring){return system.ringArea(topojson.feature(topology,{type:"Polygon",arcs:[ring]}).geometry.coordinates[0])}};function noop(){}},{"../../":68,"./clockwise":72,"./coordinate-systems":74,"./prune":79,"./type":94}],77:[function(_dereq_,module,exports){module.exports=function(objects){function geomifyObject(object){return(object&&geomifyObjectType.hasOwnProperty(object.type)?geomifyObjectType[object.type]:geomifyGeometry)(object)}function geomifyFeature(feature){var geometry=feature.geometry;if(geometry==null){feature.type=null}else{geomifyGeometry(geometry);feature.type=geometry.type;if(geometry.geometries)feature.geometries=geometry.geometries;else if(geometry.coordinates)feature.coordinates=geometry.coordinates}delete feature.geometry;return feature}function geomifyGeometry(geometry){if(!geometry)return{type:null};if(geomifyGeometryType.hasOwnProperty(geometry.type))geomifyGeometryType[geometry.type](geometry);return geometry}var geomifyObjectType={Feature:geomifyFeature,FeatureCollection:function(collection){collection.type="GeometryCollection";collection.geometries=collection.features;collection.features.forEach(geomifyFeature);delete collection.features;return collection}};var geomifyGeometryType={GeometryCollection:function(o){var geometries=o.geometries,i=-1,n=geometries.length;while(++i=minimumArea){target=arc[++j];target[0]=source[0]+dx;target[1]=source[1]+dy;dx=dy=0}else{dx+=source[0];dy+=source[1]}}arc.length=++j}:function(arc){var i=-1,j=-1,n=arc.length,point;while(++i=minimumArea){arc[++j]=point}}arc.length=++j});topology.arcs.forEach(function(arc){var i=-1,n=arc.length;while(++i1?km.toFixed(3)+"km":(km*1e3).toPrecision(3)+"m")+" ("+(radians*180/Math.PI).toPrecision(3)+"°)"}function ringArea(ring){if(!ring.length)return 0;var area=0,p=ring[0],λ=p[0]*radians,φ=p[1]*radians/2+π_4,λ0=λ,cosφ0=Math.cos(φ),sinφ0=Math.sin(φ);for(var i=1,n=ring.length;iπ?area-2*π:area<-π?area+2*π:area)}function absoluteArea(a){return a<0?a+4*π:a}function triangleArea(t){var a=distance(t[0],t[1]),b=distance(t[1],t[2]),c=distance(t[2],t[0]),s=(a+b+c)/2;return 4*Math.atan(Math.sqrt(Math.max(0,Math.tan(s/2)*Math.tan((s-a)/2)*Math.tan((s-b)/2)*Math.tan((s-c)/2))))}function distance(a,b){var Δλ=(b[0]-a[0])*radians,sinΔλ=Math.sin(Δλ),cosΔλ=Math.cos(Δλ),sinφ0=Math.sin(a[1]*radians),cosφ0=Math.cos(a[1]*radians),sinφ1=Math.sin(b[1]*radians),cosφ1=Math.cos(b[1]*radians),_;return Math.atan2(Math.sqrt((_=cosφ1*sinΔλ)*_+(_=cosφ0*sinφ1-sinφ0*cosφ1*cosΔλ)*_),sinφ0*sinφ1+cosφ0*cosφ1*cosΔλ)}function haversinDistance(x0,y0,x1,y1){x0*=radians,y0*=radians,x1*=radians,y1*=radians;return 2*Math.asin(Math.sqrt(haversin(y1-y0)+Math.cos(y0)*Math.cos(y1)*haversin(x1-x0)))}function haversin(x){return(x=Math.sin(x/2))*x}},{}],83:[function(_dereq_,module,exports){var type=_dereq_("./type");module.exports=function(objects,transform){var ε=.01,x0=-180,x0e=x0+ε,x1=180,x1e=x1-ε,y0=-90,y0e=y0+ε,y1=90,y1e=y1-ε,fragments=[];if(transform){var kx=transform.scale[0],ky=transform.scale[1],dx=transform.translate[0],dy=transform.translate[1];x0=Math.round((x0-dx)/kx);x1=Math.round((x1-dx)/kx);y0=Math.round((y0-dy)/ky);y1=Math.round((y1-dy)/ky);x0e=Math.round((x0e-dx)/kx);x1e=Math.round((x1e-dx)/kx);y0e=Math.round((y0e-dy)/ky);y1e=Math.round((y1e-dy)/ky)}function normalizePoint(y){return y<=y0e?[0,y0]:y>=y1e?[0,y1]:[x0,y]}var stitch=type({polygon:function(polygon){var rings=[];for(var j=0,m=polygon.length;j=x1e||y<=y0e||y>=y1e){for(var k=i+1;kx0e&&xky0e&&yk=n)break;fragments.push(ring=ring.slice(k-1));ring[0]=normalizePoint(ring[0][1]);i=-1;n=ring.length}}var fragmentByStart={},fragmentByEnd={};for(var i=0,n=fragments.length;i180+ε||bbox[3]>90+ε;if(!system){system=systems[oversize?"cartesian":"spherical"];if(options)options["coordinate-system"]=system.name}if(system===systems.spherical){if(oversize)throw new Error("spherical coordinates outside of [±180°, ±90°]");if(bbox[0]<-180+ε)bbox[0]=-180;if(bbox[1]<-90+ε)bbox[1]=-90;if(bbox[2]>180-ε)bbox[2]=180;if(bbox[3]>90-ε)bbox[3]=90}if(verbose){console.warn("bounds: "+bbox.join(" ")+" ("+system.name+")")}if(minimumArea)prefilter(objects,function(ring){return system.absoluteArea(system.ringArea(ring))>=minimumArea});if(Q){transform=quantize(objects,bbox,Q);if(verbose){console.warn("quantization: "+transform.scale.map(function(degrees){return system.formatDistance(degrees/180*Math.PI)}).join(" "))}}if(system===systems.spherical&&stitchPoles){stitch(objects,transform)}var topology=topologize(objects);topology.bbox=bbox;if(verbose){console.warn("topology: "+topology.arcs.length+" arcs, "+topology.arcs.reduce(function(p,v){return p+v.length},0)+" points")}if(Q)topology.transform=transform,delta(topology);return topology}},{"./bounds":70,"./compute-id":73,"./coordinate-systems":74,"./delta":75,"./geomify":77,"./prefilter":78,"./quantize":80,"./stitch":83,"./topology/index":89,"./transform-properties":93,"./type":94}],85:[function(_dereq_,module,exports){var join=_dereq_("./join");module.exports=function(topology){var junctionByPoint=join(topology),coordinates=topology.coordinates,lines=topology.lines,rings=topology.rings;for(var i=0,n=lines.length;i>1),t;start>>20^x>>>12;x^=x>>>7^x>>>4;return x}module.exports=function(point){var h=hashFloat(point[0])+31*hashFloat(point[1])|0;return h<0?~h:h}},{}],93:[function(_dereq_,module,exports){module.exports=function(objects,propertyTransform){if(arguments.length<2)propertyTransform=function(){};function transformObject(object){if(object&&transformObjectType.hasOwnProperty(object.type))transformObjectType[object.type](object)}function transformFeature(feature){if(feature.properties){var properties0=feature.properties,properties1={},empty=true;for(var key0 in properties0){if(propertyTransform(properties1,key0,properties0[key0])){empty=false}}if(empty)delete feature.properties;else feature.properties=properties1}}var transformObjectType={Feature:transformFeature,FeatureCollection:function(collection){collection.features.forEach(transformFeature)}};for(var key in objects){transformObject(objects[key])}return objects}},{}],94:[function(_dereq_,module,exports){module.exports=function(types){for(var type in typeDefaults){if(!(type in types)){types[type]=typeDefaults[type]}}types.defaults=typeDefaults;return types};var typeDefaults={Feature:function(feature){if(feature.geometry)this.geometry(feature.geometry)},FeatureCollection:function(collection){var features=collection.features,i=-1,n=features.length;while(++i1){var geomsByArc=[],geom;function arc(i){if(i<0)i=~i;(geomsByArc[i]||(geomsByArc[i]=[])).push(geom)}function line(arcs){arcs.forEach(arc)}function polygon(arcs){arcs.forEach(line)}function geometry(o){if(o.type==="GeometryCollection")o.geometries.forEach(geometry);else if(o.type in geometryType){geom=o;geometryType[o.type](o.arcs)}}var geometryType={LineString:line,MultiLineString:polygon,Polygon:polygon,MultiPolygon:function(arcs){arcs.forEach(polygon)}};geometry(o);geomsByArc.forEach(arguments.length<3?function(geoms,i){arcs.push(i)}:function(geoms,i){if(filter(geoms[0],geoms[geoms.length-1]))arcs.push(i)})}else{for(var i=0,n=topology.arcs.length;i>>1;if(a[mid]0){var up=(i+1>>1)-1,parent=array[up];if(compare(object,parent)>=0)break;array[parent.index=i]=parent;array[object.index=i=up]=object}}function down(i){var object=array[i];while(true){var right=i+1<<1,left=right-1,down=i,child=array[down];if(left