Skip to content

Instantly share code, notes, and snippets.

@kamicut
Created May 14, 2015 13:30
Show Gist options
  • Save kamicut/f22c717486708e171836 to your computer and use it in GitHub Desktop.
Save kamicut/f22c717486708e171836 to your computer and use it in GitHub Desktop.
requirebin sketch
var turf = require('turf')
require('mapbox.js');
var geocolor = require('geocolor');
var cover = require('tile-cover').tiles;
var tilebelt = require('tilebelt')
var bboxes = turf.featurecollection([]);
for (var i=0; i<250; i++) {
var width = 10 * Math.random() + 2;
var height = 10 * Math.random() + 3;
var x = Math.random() * 300 - 150;
var y = Math.random() * 120 - 60;
var extent = [x,y,x+width,y+height];
var bbox = turf.bboxPolygon(extent);
bboxes.features.push(bbox);
}
var tiles = {};
var zoom =7; var opts = {min_zoom: zoom, max_zoom: zoom}
bboxes.features.forEach(function(bbox){
cover(bbox.geometry, opts).forEach(function(tile){
if(!tiles[tile[0]+'/'+tile[1]+'/'+tile[2]]) tiles[tile[0]+'/'+tile[1]+'/'+tile[2]] = 1
else tiles[tile[0]+'/'+tile[1]+'/'+tile[2]]++
})
})
var grid = turf.featurecollection([])
Object.keys(tiles).forEach(function(tile){
tile = tile.split('/').map(parseFloat)
var geom = tilebelt.tileToGeoJSON(tile)
var cell = turf.polygon(geom.coordinates)
cell.properties.count = tiles[tile[0]+'/'+tile[1]+'/'+tile[2]]
grid.features.push(cell)
})
grid = geocolor.quantiles(grid, 'count', 10, ['white', 'red'])
L.mapbox.accessToken = 'pk.eyJ1Ijoia2FtaWN1dCIsImEiOiJMVzF2NThZIn0.WO0ArcIIzYVioen3HpfugQ';
var map = window.L.mapbox.map('map', 'mapbox.streets')
.setView([0, 0], 1);
map.featureLayer.setGeoJSON(grid);
This file has been truncated, but you can view the full file.
require=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function corslite(url,callback,cors){var sent=false;if(typeof window.XMLHttpRequest==="undefined"){return callback(Error("Browser not supported"))}if(typeof cors==="undefined"){var m=url.match(/^\s*https?:\/\/[^\/]*/);cors=m&&m[0]!==location.protocol+"//"+location.domain+(location.port?":"+location.port:"")}var x=new window.XMLHttpRequest;function isSuccessful(status){return status>=200&&status<300||status===304}if(cors&&!("withCredentials"in x)){x=new window.XDomainRequest;var original=callback;callback=function(){if(sent){original.apply(this,arguments)}else{var that=this,args=arguments;setTimeout(function(){original.apply(that,args)},0)}}}function loaded(){if(x.status===undefined||isSuccessful(x.status))callback.call(x,null,x);else callback.call(x,x,null)}if("onload"in x){x.onload=loaded}else{x.onreadystatechange=function readystate(){if(x.readyState===4){loaded()}}}x.onerror=function error(evt){callback.call(this,evt||true,null);callback=function(){}};x.onprogress=function(){};x.ontimeout=function(evt){callback.call(this,evt,null);callback=function(){}};x.onabort=function(evt){callback.call(this,evt,null);callback=function(){}};x.open("GET",url,true);x.send(null);sent=true;return x}if(typeof module!=="undefined")module.exports=corslite},{}],2:[function(require,module,exports){(function(window,document,undefined){var oldL=window.L,L={};L.version="0.7.2";if(typeof module==="object"&&typeof module.exports==="object"){module.exports=L}else if(typeof define==="function"&&define.amd){define(L)}L.noConflict=function(){window.L=oldL;return this};window.L=L;L.Util={extend:function(dest){var sources=Array.prototype.slice.call(arguments,1),i,j,len,src;for(j=0,len=sources.length;j<len;j++){src=sources[j]||{};for(i in src){if(src.hasOwnProperty(i)){dest[i]=src[i]}}}return dest},bind:function(fn,obj){var args=arguments.length>2?Array.prototype.slice.call(arguments,2):null;return function(){return fn.apply(obj,args||arguments)}},stamp:function(){var lastId=0,key="_leaflet_id";return function(obj){obj[key]=obj[key]||++lastId;return obj[key]}}(),invokeEach:function(obj,method,context){var i,args;if(typeof obj==="object"){args=Array.prototype.slice.call(arguments,3);for(i in obj){method.apply(context,[i,obj[i]].concat(args))}return true}return false},limitExecByInterval:function(fn,time,context){var lock,execOnUnlock;return function wrapperFn(){var args=arguments;if(lock){execOnUnlock=true;return}lock=true;setTimeout(function(){lock=false;if(execOnUnlock){wrapperFn.apply(context,args);execOnUnlock=false}},time);fn.apply(context,args)}},falseFn:function(){return false},formatNum:function(num,digits){var pow=Math.pow(10,digits||5);return Math.round(num*pow)/pow},trim:function(str){return str.trim?str.trim():str.replace(/^\s+|\s+$/g,"")},splitWords:function(str){return L.Util.trim(str).split(/\s+/)},setOptions:function(obj,options){obj.options=L.extend({},obj.options,options);return obj.options},getParamString:function(obj,existingUrl,uppercase){var params=[];for(var i in obj){params.push(encodeURIComponent(uppercase?i.toUpperCase():i)+"="+encodeURIComponent(obj[i]))}return(!existingUrl||existingUrl.indexOf("?")===-1?"?":"&")+params.join("&")},template:function(str,data){return str.replace(/\{ *([\w_]+) *\}/g,function(str,key){var value=data[key];if(value===undefined){throw new Error("No value provided for variable "+str)}else if(typeof value==="function"){value=value(data)}return value})},isArray:Array.isArray||function(obj){return Object.prototype.toString.call(obj)==="[object Array]"},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="};(function(){function getPrefixed(name){var i,fn,prefixes=["webkit","moz","o","ms"];for(i=0;i<prefixes.length&&!fn;i++){fn=window[prefixes[i]+name]}return fn}var lastTime=0;function timeoutDefer(fn){var time=+new Date,timeToCall=Math.max(0,16-(time-lastTime));lastTime=time+timeToCall;return window.setTimeout(fn,timeToCall)}var requestFn=window.requestAnimationFrame||getPrefixed("RequestAnimationFrame")||timeoutDefer;var cancelFn=window.cancelAnimationFrame||getPrefixed("CancelAnimationFrame")||getPrefixed("CancelRequestAnimationFrame")||function(id){window.clearTimeout(id)};L.Util.requestAnimFrame=function(fn,context,immediate,element){fn=L.bind(fn,context);if(immediate&&requestFn===timeoutDefer){fn()}else{return requestFn.call(window,fn,element)}};L.Util.cancelAnimFrame=function(id){if(id){cancelFn.call(window,id)}}})();L.extend=L.Util.extend;L.bind=L.Util.bind;L.stamp=L.Util.stamp;L.setOptions=L.Util.setOptions;L.Class=function(){};L.Class.extend=function(props){var NewClass=function(){if(this.initialize){this.initialize.apply(this,arguments)}if(this._initHooks){this.callInitHooks()}};var F=function(){};F.prototype=this.prototype;var proto=new F;proto.constructor=NewClass;NewClass.prototype=proto;for(var i in this){if(this.hasOwnProperty(i)&&i!=="prototype"){NewClass[i]=this[i]}}if(props.statics){L.extend(NewClass,props.statics);delete props.statics}if(props.includes){L.Util.extend.apply(null,[proto].concat(props.includes));delete props.includes}if(props.options&&proto.options){props.options=L.extend({},proto.options,props.options)}L.extend(proto,props);proto._initHooks=[];var parent=this;NewClass.__super__=parent.prototype;proto.callInitHooks=function(){if(this._initHooksCalled){return}if(parent.prototype.callInitHooks){parent.prototype.callInitHooks.call(this)}this._initHooksCalled=true;for(var i=0,len=proto._initHooks.length;i<len;i++){proto._initHooks[i].call(this)}};return NewClass};L.Class.include=function(props){L.extend(this.prototype,props)};L.Class.mergeOptions=function(options){L.extend(this.prototype.options,options)};L.Class.addInitHook=function(fn){var args=Array.prototype.slice.call(arguments,1);var init=typeof fn==="function"?fn:function(){this[fn].apply(this,args)};this.prototype._initHooks=this.prototype._initHooks||[];this.prototype._initHooks.push(init)};var eventsKey="_leaflet_events";L.Mixin={};L.Mixin.Events={addEventListener:function(types,fn,context){if(L.Util.invokeEach(types,this.addEventListener,this,fn,context)){return this}var events=this[eventsKey]=this[eventsKey]||{},contextId=context&&context!==this&&L.stamp(context),i,len,event,type,indexKey,indexLenKey,typeIndex;types=L.Util.splitWords(types);for(i=0,len=types.length;i<len;i++){event={action:fn,context:context||this};type=types[i];if(contextId){indexKey=type+"_idx";indexLenKey=indexKey+"_len";typeIndex=events[indexKey]=events[indexKey]||{};if(!typeIndex[contextId]){typeIndex[contextId]=[];events[indexLenKey]=(events[indexLenKey]||0)+1}typeIndex[contextId].push(event)}else{events[type]=events[type]||[];events[type].push(event)}}return this},hasEventListeners:function(type){var events=this[eventsKey];return!!events&&(type in events&&events[type].length>0||type+"_idx"in events&&events[type+"_idx_len"]>0)},removeEventListener:function(types,fn,context){if(!this[eventsKey]){return this}if(!types){return this.clearAllEventListeners()}if(L.Util.invokeEach(types,this.removeEventListener,this,fn,context)){return this}var events=this[eventsKey],contextId=context&&context!==this&&L.stamp(context),i,len,type,listeners,j,indexKey,indexLenKey,typeIndex,removed;types=L.Util.splitWords(types);for(i=0,len=types.length;i<len;i++){type=types[i];indexKey=type+"_idx";indexLenKey=indexKey+"_len";typeIndex=events[indexKey];if(!fn){delete events[type];delete events[indexKey];delete events[indexLenKey]}else{listeners=contextId&&typeIndex?typeIndex[contextId]:events[type];if(listeners){for(j=listeners.length-1;j>=0;j--){if(listeners[j].action===fn&&(!context||listeners[j].context===context)){removed=listeners.splice(j,1);removed[0].action=L.Util.falseFn}}if(context&&typeIndex&&listeners.length===0){delete typeIndex[contextId];events[indexLenKey]--}}}}return this},clearAllEventListeners:function(){delete this[eventsKey];return this},fireEvent:function(type,data){if(!this.hasEventListeners(type)){return this}var event=L.Util.extend({},data,{type:type,target:this});var events=this[eventsKey],listeners,i,len,typeIndex,contextId;if(events[type]){listeners=events[type].slice();for(i=0,len=listeners.length;i<len;i++){listeners[i].action.call(listeners[i].context,event)}}typeIndex=events[type+"_idx"];for(contextId in typeIndex){listeners=typeIndex[contextId].slice();if(listeners){for(i=0,len=listeners.length;i<len;i++){listeners[i].action.call(listeners[i].context,event)}}}return this},addOneTimeEventListener:function(types,fn,context){if(L.Util.invokeEach(types,this.addOneTimeEventListener,this,fn,context)){return this}var handler=L.bind(function(){this.removeEventListener(types,fn,context).removeEventListener(types,handler,context)},this);return this.addEventListener(types,fn,context).addEventListener(types,handler,context)}};L.Mixin.Events.on=L.Mixin.Events.addEventListener;L.Mixin.Events.off=L.Mixin.Events.removeEventListener;L.Mixin.Events.once=L.Mixin.Events.addOneTimeEventListener;L.Mixin.Events.fire=L.Mixin.Events.fireEvent;(function(){var ie="ActiveXObject"in window,ielt9=ie&&!document.addEventListener,ua=navigator.userAgent.toLowerCase(),webkit=ua.indexOf("webkit")!==-1,chrome=ua.indexOf("chrome")!==-1,phantomjs=ua.indexOf("phantom")!==-1,android=ua.indexOf("android")!==-1,android23=ua.search("android [23]")!==-1,gecko=ua.indexOf("gecko")!==-1,mobile=typeof orientation!==undefined+"",msPointer=window.navigator&&window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints&&!window.PointerEvent,pointer=window.PointerEvent&&window.navigator.pointerEnabled&&window.navigator.maxTouchPoints||msPointer,retina="devicePixelRatio"in window&&window.devicePixelRatio>1||"matchMedia"in window&&window.matchMedia("(min-resolution:144dpi)")&&window.matchMedia("(min-resolution:144dpi)").matches,doc=document.documentElement,ie3d=ie&&"transition"in doc.style,webkit3d="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!android23,gecko3d="MozPerspective"in doc.style,opera3d="OTransition"in doc.style,any3d=!window.L_DISABLE_3D&&(ie3d||webkit3d||gecko3d||opera3d)&&!phantomjs;var touch=!window.L_NO_TOUCH&&!phantomjs&&function(){var startName="ontouchstart";if(pointer||startName in doc){return true}var div=document.createElement("div"),supported=false;if(!div.setAttribute){return false}div.setAttribute(startName,"return;");if(typeof div[startName]==="function"){supported=true}div.removeAttribute(startName);div=null;return supported}();L.Browser={ie:ie,ielt9:ielt9,webkit:webkit,gecko:gecko&&!webkit&&!window.opera&&!ie,android:android,android23:android23,chrome:chrome,ie3d:ie3d,webkit3d:webkit3d,gecko3d:gecko3d,opera3d:opera3d,any3d:any3d,mobile:mobile,mobileWebkit:mobile&&webkit,mobileWebkit3d:mobile&&webkit3d,mobileOpera:mobile&&window.opera,touch:touch,msPointer:msPointer,pointer:pointer,retina:retina}})();L.Point=function(x,y,round){this.x=round?Math.round(x):x;this.y=round?Math.round(y):y};L.Point.prototype={clone:function(){return new L.Point(this.x,this.y)},add:function(point){return this.clone()._add(L.point(point))},_add:function(point){this.x+=point.x;this.y+=point.y;return this},subtract:function(point){return this.clone()._subtract(L.point(point))},_subtract:function(point){this.x-=point.x;this.y-=point.y;return this},divideBy:function(num){return this.clone()._divideBy(num)},_divideBy:function(num){this.x/=num;this.y/=num;return this},multiplyBy:function(num){return this.clone()._multiplyBy(num)},_multiplyBy:function(num){this.x*=num;this.y*=num;return this},round:function(){return this.clone()._round()},_round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},floor:function(){return this.clone()._floor()},_floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},distanceTo:function(point){point=L.point(point);var x=point.x-this.x,y=point.y-this.y;return Math.sqrt(x*x+y*y)},equals:function(point){point=L.point(point);return point.x===this.x&&point.y===this.y},contains:function(point){point=L.point(point);return Math.abs(point.x)<=Math.abs(this.x)&&Math.abs(point.y)<=Math.abs(this.y)},toString:function(){return"Point("+L.Util.formatNum(this.x)+", "+L.Util.formatNum(this.y)+")"}};L.point=function(x,y,round){if(x instanceof L.Point){return x}if(L.Util.isArray(x)){return new L.Point(x[0],x[1])}if(x===undefined||x===null){return x}return new L.Point(x,y,round)};L.Bounds=function(a,b){if(!a){return}var points=b?[a,b]:a;for(var i=0,len=points.length;i<len;i++){this.extend(points[i])}};L.Bounds.prototype={extend:function(point){point=L.point(point);if(!this.min&&!this.max){this.min=point.clone();this.max=point.clone()}else{this.min.x=Math.min(point.x,this.min.x);this.max.x=Math.max(point.x,this.max.x);this.min.y=Math.min(point.y,this.min.y);this.max.y=Math.max(point.y,this.max.y)}return this},getCenter:function(round){return new L.Point((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,round)},getBottomLeft:function(){return new L.Point(this.min.x,this.max.y)},getTopRight:function(){return new L.Point(this.max.x,this.min.y)},getSize:function(){return this.max.subtract(this.min)},contains:function(obj){var min,max;if(typeof obj[0]==="number"||obj instanceof L.Point){obj=L.point(obj)}else{obj=L.bounds(obj)}if(obj instanceof L.Bounds){min=obj.min;max=obj.max}else{min=max=obj}return min.x>=this.min.x&&max.x<=this.max.x&&min.y>=this.min.y&&max.y<=this.max.y},intersects:function(bounds){bounds=L.bounds(bounds);var min=this.min,max=this.max,min2=bounds.min,max2=bounds.max,xIntersects=max2.x>=min.x&&min2.x<=max.x,yIntersects=max2.y>=min.y&&min2.y<=max.y;return xIntersects&&yIntersects},isValid:function(){return!!(this.min&&this.max)}};L.bounds=function(a,b){if(!a||a instanceof L.Bounds){return a}return new L.Bounds(a,b)};L.Transformation=function(a,b,c,d){this._a=a;this._b=b;this._c=c;this._d=d};L.Transformation.prototype={transform:function(point,scale){return this._transform(point.clone(),scale)},_transform:function(point,scale){scale=scale||1;point.x=scale*(this._a*point.x+this._b);point.y=scale*(this._c*point.y+this._d);return point},untransform:function(point,scale){scale=scale||1;return new L.Point((point.x/scale-this._b)/this._a,(point.y/scale-this._d)/this._c)}};L.DomUtil={get:function(id){return typeof id==="string"?document.getElementById(id):id},getStyle:function(el,style){var value=el.style[style];if(!value&&el.currentStyle){value=el.currentStyle[style]}if((!value||value==="auto")&&document.defaultView){var css=document.defaultView.getComputedStyle(el,null);value=css?css[style]:null}return value==="auto"?null:value},getViewportOffset:function(element){var top=0,left=0,el=element,docBody=document.body,docEl=document.documentElement,pos;do{top+=el.offsetTop||0;left+=el.offsetLeft||0;top+=parseInt(L.DomUtil.getStyle(el,"borderTopWidth"),10)||0;left+=parseInt(L.DomUtil.getStyle(el,"borderLeftWidth"),10)||0;pos=L.DomUtil.getStyle(el,"position");if(el.offsetParent===docBody&&pos==="absolute"){break}if(pos==="fixed"){top+=docBody.scrollTop||docEl.scrollTop||0;left+=docBody.scrollLeft||docEl.scrollLeft||0;break}if(pos==="relative"&&!el.offsetLeft){var width=L.DomUtil.getStyle(el,"width"),maxWidth=L.DomUtil.getStyle(el,"max-width"),r=el.getBoundingClientRect();if(width!=="none"||maxWidth!=="none"){left+=r.left+el.clientLeft}top+=r.top+(docBody.scrollTop||docEl.scrollTop||0);break}el=el.offsetParent}while(el);el=element;do{if(el===docBody){break}top-=el.scrollTop||0;left-=el.scrollLeft||0;el=el.parentNode}while(el);return new L.Point(left,top)},documentIsLtr:function(){if(!L.DomUtil._docIsLtrCached){L.DomUtil._docIsLtrCached=true;L.DomUtil._docIsLtr=L.DomUtil.getStyle(document.body,"direction")==="ltr"}return L.DomUtil._docIsLtr},create:function(tagName,className,container){var el=document.createElement(tagName);el.className=className;if(container){container.appendChild(el)}return el},hasClass:function(el,name){if(el.classList!==undefined){return el.classList.contains(name)}var className=L.DomUtil._getClass(el);return className.length>0&&new RegExp("(^|\\s)"+name+"(\\s|$)").test(className)},addClass:function(el,name){if(el.classList!==undefined){var classes=L.Util.splitWords(name);for(var i=0,len=classes.length;i<len;i++){el.classList.add(classes[i])}}else if(!L.DomUtil.hasClass(el,name)){var className=L.DomUtil._getClass(el);L.DomUtil._setClass(el,(className?className+" ":"")+name)}},removeClass:function(el,name){if(el.classList!==undefined){el.classList.remove(name)}else{L.DomUtil._setClass(el,L.Util.trim((" "+L.DomUtil._getClass(el)+" ").replace(" "+name+" "," ")))}},_setClass:function(el,name){if(el.className.baseVal===undefined){el.className=name}else{el.className.baseVal=name}},_getClass:function(el){return el.className.baseVal===undefined?el.className:el.className.baseVal},setOpacity:function(el,value){if("opacity"in el.style){el.style.opacity=value}else if("filter"in el.style){var filter=false,filterName="DXImageTransform.Microsoft.Alpha";try{filter=el.filters.item(filterName)}catch(e){if(value===1){return}}value=Math.round(value*100);if(filter){filter.Enabled=value!==100;filter.Opacity=value}else{el.style.filter+=" progid:"+filterName+"(opacity="+value+")"}}},testProp:function(props){var style=document.documentElement.style;for(var i=0;i<props.length;i++){if(props[i]in style){return props[i]}}return false},getTranslateString:function(point){var is3d=L.Browser.webkit3d,open="translate"+(is3d?"3d":"")+"(",close=(is3d?",0":"")+")";return open+point.x+"px,"+point.y+"px"+close},getScaleString:function(scale,origin){var preTranslateStr=L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1*scale))),scaleStr=" scale("+scale+") ";return preTranslateStr+scaleStr},setPosition:function(el,point,disable3D){el._leaflet_pos=point;if(!disable3D&&L.Browser.any3d){el.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(point)}else{el.style.left=point.x+"px";el.style.top=point.y+"px"}},getPosition:function(el){return el._leaflet_pos}};L.DomUtil.TRANSFORM=L.DomUtil.testProp(["transform","WebkitTransform","OTransform","MozTransform","msTransform"]);L.DomUtil.TRANSITION=L.DomUtil.testProp(["webkitTransition","transition","OTransition","MozTransition","msTransition"]);L.DomUtil.TRANSITION_END=L.DomUtil.TRANSITION==="webkitTransition"||L.DomUtil.TRANSITION==="OTransition"?L.DomUtil.TRANSITION+"End":"transitionend";(function(){if("onselectstart"in document){L.extend(L.DomUtil,{disableTextSelection:function(){L.DomEvent.on(window,"selectstart",L.DomEvent.preventDefault)},enableTextSelection:function(){L.DomEvent.off(window,"selectstart",L.DomEvent.preventDefault)}})}else{var userSelectProperty=L.DomUtil.testProp(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);L.extend(L.DomUtil,{disableTextSelection:function(){if(userSelectProperty){var style=document.documentElement.style;this._userSelect=style[userSelectProperty];style[userSelectProperty]="none"}},enableTextSelection:function(){if(userSelectProperty){document.documentElement.style[userSelectProperty]=this._userSelect;delete this._userSelect}}})}L.extend(L.DomUtil,{disableImageDrag:function(){L.DomEvent.on(window,"dragstart",L.DomEvent.preventDefault)},enableImageDrag:function(){L.DomEvent.off(window,"dragstart",L.DomEvent.preventDefault)}})})();L.LatLng=function(lat,lng,alt){lat=parseFloat(lat);lng=parseFloat(lng);if(isNaN(lat)||isNaN(lng)){throw new Error("Invalid LatLng object: ("+lat+", "+lng+")")}this.lat=lat;this.lng=lng;if(alt!==undefined){this.alt=parseFloat(alt)}};L.extend(L.LatLng,{DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,MAX_MARGIN:1e-9});L.LatLng.prototype={equals:function(obj){if(!obj){return false}obj=L.latLng(obj);var margin=Math.max(Math.abs(this.lat-obj.lat),Math.abs(this.lng-obj.lng));return margin<=L.LatLng.MAX_MARGIN},toString:function(precision){return"LatLng("+L.Util.formatNum(this.lat,precision)+", "+L.Util.formatNum(this.lng,precision)+")"},distanceTo:function(other){other=L.latLng(other);var R=6378137,d2r=L.LatLng.DEG_TO_RAD,dLat=(other.lat-this.lat)*d2r,dLon=(other.lng-this.lng)*d2r,lat1=this.lat*d2r,lat2=other.lat*d2r,sin1=Math.sin(dLat/2),sin2=Math.sin(dLon/2);var a=sin1*sin1+sin2*sin2*Math.cos(lat1)*Math.cos(lat2);return R*2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},wrap:function(a,b){var lng=this.lng;a=a||-180;b=b||180;lng=(lng+b)%(b-a)+(lng<a||lng===b?b:a);return new L.LatLng(this.lat,lng)}};L.latLng=function(a,b){if(a instanceof L.LatLng){return a}if(L.Util.isArray(a)){if(typeof a[0]==="number"||typeof a[0]==="string"){return new L.LatLng(a[0],a[1],a[2])}else{return null}}if(a===undefined||a===null){return a}if(typeof a==="object"&&"lat"in a){return new L.LatLng(a.lat,"lng"in a?a.lng:a.lon)}if(b===undefined){return null}return new L.LatLng(a,b)};L.LatLngBounds=function(southWest,northEast){if(!southWest){return}var latlngs=northEast?[southWest,northEast]:southWest;for(var i=0,len=latlngs.length;i<len;i++){this.extend(latlngs[i])}};L.LatLngBounds.prototype={extend:function(obj){if(!obj){return this}var latLng=L.latLng(obj);if(latLng!==null){obj=latLng}else{obj=L.latLngBounds(obj)}if(obj instanceof L.LatLng){if(!this._southWest&&!this._northEast){this._southWest=new L.LatLng(obj.lat,obj.lng);this._northEast=new L.LatLng(obj.lat,obj.lng)}else{this._southWest.lat=Math.min(obj.lat,this._southWest.lat);this._southWest.lng=Math.min(obj.lng,this._southWest.lng);this._northEast.lat=Math.max(obj.lat,this._northEast.lat);this._northEast.lng=Math.max(obj.lng,this._northEast.lng)}}else if(obj instanceof L.LatLngBounds){this.extend(obj._southWest);this.extend(obj._northEast)}return this},pad:function(bufferRatio){var sw=this._southWest,ne=this._northEast,heightBuffer=Math.abs(sw.lat-ne.lat)*bufferRatio,widthBuffer=Math.abs(sw.lng-ne.lng)*bufferRatio;return new L.LatLngBounds(new L.LatLng(sw.lat-heightBuffer,sw.lng-widthBuffer),new L.LatLng(ne.lat+heightBuffer,ne.lng+widthBuffer))},getCenter:function(){return new L.LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new L.LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new L.LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(obj){if(typeof obj[0]==="number"||obj instanceof L.LatLng){obj=L.latLng(obj)}else{obj=L.latLngBounds(obj)}var sw=this._southWest,ne=this._northEast,sw2,ne2;if(obj instanceof L.LatLngBounds){sw2=obj.getSouthWest();ne2=obj.getNorthEast()}else{sw2=ne2=obj}return sw2.lat>=sw.lat&&ne2.lat<=ne.lat&&sw2.lng>=sw.lng&&ne2.lng<=ne.lng},intersects:function(bounds){bounds=L.latLngBounds(bounds);var sw=this._southWest,ne=this._northEast,sw2=bounds.getSouthWest(),ne2=bounds.getNorthEast(),latIntersects=ne2.lat>=sw.lat&&sw2.lat<=ne.lat,lngIntersects=ne2.lng>=sw.lng&&sw2.lng<=ne.lng;return latIntersects&&lngIntersects},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(bounds){if(!bounds){return false}bounds=L.latLngBounds(bounds);return this._southWest.equals(bounds.getSouthWest())&&this._northEast.equals(bounds.getNorthEast())},isValid:function(){return!!(this._southWest&&this._northEast)}};L.latLngBounds=function(a,b){if(!a||a instanceof L.LatLngBounds){return a}return new L.LatLngBounds(a,b)};L.Projection={};L.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(latlng){var d=L.LatLng.DEG_TO_RAD,max=this.MAX_LATITUDE,lat=Math.max(Math.min(max,latlng.lat),-max),x=latlng.lng*d,y=lat*d;y=Math.log(Math.tan(Math.PI/4+y/2));return new L.Point(x,y)},unproject:function(point){var d=L.LatLng.RAD_TO_DEG,lng=point.x*d,lat=(2*Math.atan(Math.exp(point.y))-Math.PI/2)*d;return new L.LatLng(lat,lng)}};L.Projection.LonLat={project:function(latlng){return new L.Point(latlng.lng,latlng.lat)},unproject:function(point){return new L.LatLng(point.y,point.x)}};L.CRS={latLngToPoint:function(latlng,zoom){var projectedPoint=this.projection.project(latlng),scale=this.scale(zoom);return this.transformation._transform(projectedPoint,scale)},pointToLatLng:function(point,zoom){var scale=this.scale(zoom),untransformedPoint=this.transformation.untransform(point,scale);return this.projection.unproject(untransformedPoint)},project:function(latlng){return this.projection.project(latlng)},scale:function(zoom){return 256*Math.pow(2,zoom)},getSize:function(zoom){var s=this.scale(zoom);return L.point(s,s)}};L.CRS.Simple=L.extend({},L.CRS,{projection:L.Projection.LonLat,transformation:new L.Transformation(1,0,-1,0),scale:function(zoom){return Math.pow(2,zoom)}});L.CRS.EPSG3857=L.extend({},L.CRS,{code:"EPSG:3857",projection:L.Projection.SphericalMercator,transformation:new L.Transformation(.5/Math.PI,.5,-.5/Math.PI,.5),project:function(latlng){var projectedPoint=this.projection.project(latlng),earthRadius=6378137;return projectedPoint.multiplyBy(earthRadius)}});L.CRS.EPSG900913=L.extend({},L.CRS.EPSG3857,{code:"EPSG:900913"});L.CRS.EPSG4326=L.extend({},L.CRS,{code:"EPSG:4326",projection:L.Projection.LonLat,transformation:new L.Transformation(1/360,.5,-1/360,.5)});L.Map=L.Class.extend({includes:L.Mixin.Events,options:{crs:L.CRS.EPSG3857,fadeAnimation:L.DomUtil.TRANSITION&&!L.Browser.android23,trackResize:true,markerZoomAnimation:L.DomUtil.TRANSITION&&L.Browser.any3d},initialize:function(id,options){options=L.setOptions(this,options);this._initContainer(id);this._initLayout();this._onResize=L.bind(this._onResize,this);this._initEvents();if(options.maxBounds){this.setMaxBounds(options.maxBounds)}if(options.center&&options.zoom!==undefined){this.setView(L.latLng(options.center),options.zoom,{reset:true})}this._handlers=[];this._layers={};this._zoomBoundLayers={};this._tileLayersNum=0;this.callInitHooks();this._addLayers(options.layers)},setView:function(center,zoom){zoom=zoom===undefined?this.getZoom():zoom;this._resetView(L.latLng(center),this._limitZoom(zoom));return this},setZoom:function(zoom,options){if(!this._loaded){this._zoom=this._limitZoom(zoom);return this}return this.setView(this.getCenter(),zoom,{zoom:options})},zoomIn:function(delta,options){return this.setZoom(this._zoom+(delta||1),options)},zoomOut:function(delta,options){return this.setZoom(this._zoom-(delta||1),options)},setZoomAround:function(latlng,zoom,options){var scale=this.getZoomScale(zoom),viewHalf=this.getSize().divideBy(2),containerPoint=latlng instanceof L.Point?latlng:this.latLngToContainerPoint(latlng),centerOffset=containerPoint.subtract(viewHalf).multiplyBy(1-1/scale),newCenter=this.containerPointToLatLng(viewHalf.add(centerOffset));return this.setView(newCenter,zoom,{zoom:options})},fitBounds:function(bounds,options){options=options||{};bounds=bounds.getBounds?bounds.getBounds():L.latLngBounds(bounds);var paddingTL=L.point(options.paddingTopLeft||options.padding||[0,0]),paddingBR=L.point(options.paddingBottomRight||options.padding||[0,0]),zoom=this.getBoundsZoom(bounds,false,paddingTL.add(paddingBR)),paddingOffset=paddingBR.subtract(paddingTL).divideBy(2),swPoint=this.project(bounds.getSouthWest(),zoom),nePoint=this.project(bounds.getNorthEast(),zoom),center=this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset),zoom);zoom=options&&options.maxZoom?Math.min(options.maxZoom,zoom):zoom;return this.setView(center,zoom,options)},fitWorld:function(options){return this.fitBounds([[-90,-180],[90,180]],options)},panTo:function(center,options){return this.setView(center,this._zoom,{pan:options})},panBy:function(offset){this.fire("movestart");this._rawPanBy(L.point(offset));this.fire("move");return this.fire("moveend")},setMaxBounds:function(bounds){bounds=L.latLngBounds(bounds);this.options.maxBounds=bounds;if(!bounds){return this.off("moveend",this._panInsideMaxBounds,this)}if(this._loaded){this._panInsideMaxBounds()}return this.on("moveend",this._panInsideMaxBounds,this)},panInsideBounds:function(bounds,options){var center=this.getCenter(),newCenter=this._limitCenter(center,this._zoom,bounds);if(center.equals(newCenter)){return this}return this.panTo(newCenter,options)},addLayer:function(layer){var id=L.stamp(layer);if(this._layers[id]){return this}this._layers[id]=layer;if(layer.options&&(!isNaN(layer.options.maxZoom)||!isNaN(layer.options.minZoom))){this._zoomBoundLayers[id]=layer;this._updateZoomLevels()}if(this.options.zoomAnimation&&L.TileLayer&&layer instanceof L.TileLayer){this._tileLayersNum++;this._tileLayersToLoad++;layer.on("load",this._onTileLayerLoad,this)}if(this._loaded){this._layerAdd(layer)}return this},removeLayer:function(layer){var id=L.stamp(layer);if(!this._layers[id]){return this}if(this._loaded){layer.onRemove(this)}delete this._layers[id];if(this._loaded){this.fire("layerremove",{layer:layer})}if(this._zoomBoundLayers[id]){delete this._zoomBoundLayers[id];this._updateZoomLevels()}if(this.options.zoomAnimation&&L.TileLayer&&layer instanceof L.TileLayer){this._tileLayersNum--;this._tileLayersToLoad--;layer.off("load",this._onTileLayerLoad,this)}return this},hasLayer:function(layer){if(!layer){return false}return L.stamp(layer)in this._layers},eachLayer:function(method,context){for(var i in this._layers){method.call(context,this._layers[i])}return this},invalidateSize:function(options){if(!this._loaded){return this}options=L.extend({animate:false,pan:true},options===true?{animate:true}:options);var oldSize=this.getSize();this._sizeChanged=true;this._initialCenter=null;var newSize=this.getSize(),oldCenter=oldSize.divideBy(2).round(),newCenter=newSize.divideBy(2).round(),offset=oldCenter.subtract(newCenter);if(!offset.x&&!offset.y){return this}if(options.animate&&options.pan){this.panBy(offset)}else{if(options.pan){this._rawPanBy(offset)}this.fire("move");if(options.debounceMoveend){clearTimeout(this._sizeTimer);this._sizeTimer=setTimeout(L.bind(this.fire,this,"moveend"),200)}else{this.fire("moveend")}}return this.fire("resize",{oldSize:oldSize,newSize:newSize})},addHandler:function(name,HandlerClass){if(!HandlerClass){return this}var handler=this[name]=new HandlerClass(this);this._handlers.push(handler);if(this.options[name]){handler.enable()}return this},remove:function(){if(this._loaded){this.fire("unload")}this._initEvents("off");try{delete this._container._leaflet}catch(e){this._container._leaflet=undefined}this._clearPanes();if(this._clearControlPos){this._clearControlPos()}this._clearHandlers();return this},getCenter:function(){this._checkIfLoaded();if(this._initialCenter&&!this._moved()){return this._initialCenter}return this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var bounds=this.getPixelBounds(),sw=this.unproject(bounds.getBottomLeft()),ne=this.unproject(bounds.getTopRight());return new L.LatLngBounds(sw,ne)},getMinZoom:function(){return this.options.minZoom===undefined?this._layersMinZoom===undefined?0:this._layersMinZoom:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===undefined?this._layersMaxZoom===undefined?Infinity:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(bounds,inside,padding){bounds=L.latLngBounds(bounds);var zoom=this.getMinZoom()-(inside?1:0),maxZoom=this.getMaxZoom(),size=this.getSize(),nw=bounds.getNorthWest(),se=bounds.getSouthEast(),zoomNotFound=true,boundsSize;padding=L.point(padding||[0,0]);do{zoom++;boundsSize=this.project(se,zoom).subtract(this.project(nw,zoom)).add(padding);
zoomNotFound=!inside?size.contains(boundsSize):boundsSize.x<size.x||boundsSize.y<size.y}while(zoomNotFound&&zoom<=maxZoom);if(zoomNotFound&&inside){return null}return inside?zoom:zoom-1},getSize:function(){if(!this._size||this._sizeChanged){this._size=new L.Point(this._container.clientWidth,this._container.clientHeight);this._sizeChanged=false}return this._size.clone()},getPixelBounds:function(){var topLeftPoint=this._getTopLeftPoint();return new L.Bounds(topLeftPoint,topLeftPoint.add(this.getSize()))},getPixelOrigin:function(){this._checkIfLoaded();return this._initialTopLeftPoint},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(toZoom){var crs=this.options.crs;return crs.scale(toZoom)/crs.scale(this._zoom)},getScaleZoom:function(scale){return this._zoom+Math.log(scale)/Math.LN2},project:function(latlng,zoom){zoom=zoom===undefined?this._zoom:zoom;return this.options.crs.latLngToPoint(L.latLng(latlng),zoom)},unproject:function(point,zoom){zoom=zoom===undefined?this._zoom:zoom;return this.options.crs.pointToLatLng(L.point(point),zoom)},layerPointToLatLng:function(point){var projectedPoint=L.point(point).add(this.getPixelOrigin());return this.unproject(projectedPoint)},latLngToLayerPoint:function(latlng){var projectedPoint=this.project(L.latLng(latlng))._round();return projectedPoint._subtract(this.getPixelOrigin())},containerPointToLayerPoint:function(point){return L.point(point).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(point){return L.point(point).add(this._getMapPanePos())},containerPointToLatLng:function(point){var layerPoint=this.containerPointToLayerPoint(L.point(point));return this.layerPointToLatLng(layerPoint)},latLngToContainerPoint:function(latlng){return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng)))},mouseEventToContainerPoint:function(e){return L.DomEvent.getMousePosition(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(id){var container=this._container=L.DomUtil.get(id);if(!container){throw new Error("Map container not found.")}else if(container._leaflet){throw new Error("Map container is already initialized.")}container._leaflet=true},_initLayout:function(){var container=this._container;L.DomUtil.addClass(container,"leaflet-container"+(L.Browser.touch?" leaflet-touch":"")+(L.Browser.retina?" leaflet-retina":"")+(L.Browser.ielt9?" leaflet-oldie":"")+(this.options.fadeAnimation?" leaflet-fade-anim":""));var position=L.DomUtil.getStyle(container,"position");if(position!=="absolute"&&position!=="relative"&&position!=="fixed"){container.style.position="relative"}this._initPanes();if(this._initControlPos){this._initControlPos()}},_initPanes:function(){var panes=this._panes={};this._mapPane=panes.mapPane=this._createPane("leaflet-map-pane",this._container);this._tilePane=panes.tilePane=this._createPane("leaflet-tile-pane",this._mapPane);panes.objectsPane=this._createPane("leaflet-objects-pane",this._mapPane);panes.shadowPane=this._createPane("leaflet-shadow-pane");panes.overlayPane=this._createPane("leaflet-overlay-pane");panes.markerPane=this._createPane("leaflet-marker-pane");panes.popupPane=this._createPane("leaflet-popup-pane");var zoomHide=" leaflet-zoom-hide";if(!this.options.markerZoomAnimation){L.DomUtil.addClass(panes.markerPane,zoomHide);L.DomUtil.addClass(panes.shadowPane,zoomHide);L.DomUtil.addClass(panes.popupPane,zoomHide)}},_createPane:function(className,container){return L.DomUtil.create("div",className,container||this._panes.objectsPane)},_clearPanes:function(){this._container.removeChild(this._mapPane)},_addLayers:function(layers){layers=layers?L.Util.isArray(layers)?layers:[layers]:[];for(var i=0,len=layers.length;i<len;i++){this.addLayer(layers[i])}},_resetView:function(center,zoom,preserveMapOffset,afterZoomAnim){var zoomChanged=this._zoom!==zoom;if(!afterZoomAnim){this.fire("movestart");if(zoomChanged){this.fire("zoomstart")}}this._zoom=zoom;this._initialCenter=center;this._initialTopLeftPoint=this._getNewTopLeftPoint(center);if(!preserveMapOffset){L.DomUtil.setPosition(this._mapPane,new L.Point(0,0))}else{this._initialTopLeftPoint._add(this._getMapPanePos())}this._tileLayersToLoad=this._tileLayersNum;var loading=!this._loaded;this._loaded=true;this.fire("viewreset",{hard:!preserveMapOffset});if(loading){this.fire("load");this.eachLayer(this._layerAdd,this)}this.fire("move");if(zoomChanged||afterZoomAnim){this.fire("zoomend")}this.fire("moveend",{hard:!preserveMapOffset})},_rawPanBy:function(offset){L.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(offset))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_updateZoomLevels:function(){var i,minZoom=Infinity,maxZoom=-Infinity,oldZoomSpan=this._getZoomSpan();for(i in this._zoomBoundLayers){var layer=this._zoomBoundLayers[i];if(!isNaN(layer.options.minZoom)){minZoom=Math.min(minZoom,layer.options.minZoom)}if(!isNaN(layer.options.maxZoom)){maxZoom=Math.max(maxZoom,layer.options.maxZoom)}}if(i===undefined){this._layersMaxZoom=this._layersMinZoom=undefined}else{this._layersMaxZoom=maxZoom;this._layersMinZoom=minZoom}if(oldZoomSpan!==this._getZoomSpan()){this.fire("zoomlevelschange")}},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded){throw new Error("Set map center and zoom first.")}},_initEvents:function(onOff){if(!L.DomEvent){return}onOff=onOff||"on";L.DomEvent[onOff](this._container,"click",this._onMouseClick,this);var events=["dblclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","contextmenu"],i,len;for(i=0,len=events.length;i<len;i++){L.DomEvent[onOff](this._container,events[i],this._fireMouseEvent,this)}if(this.options.trackResize){L.DomEvent[onOff](window,"resize",this._onResize,this)}},_onResize:function(){L.Util.cancelAnimFrame(this._resizeRequest);this._resizeRequest=L.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:true})},this,false,this._container)},_onMouseClick:function(e){if(!this._loaded||!e._simulated&&(this.dragging&&this.dragging.moved()||this.boxZoom&&this.boxZoom.moved())||L.DomEvent._skipped(e)){return}this.fire("preclick");this._fireMouseEvent(e)},_fireMouseEvent:function(e){if(!this._loaded||L.DomEvent._skipped(e)){return}var type=e.type;type=type==="mouseenter"?"mouseover":type==="mouseleave"?"mouseout":type;if(!this.hasEventListeners(type)){return}if(type==="contextmenu"){L.DomEvent.preventDefault(e)}var containerPoint=this.mouseEventToContainerPoint(e),layerPoint=this.containerPointToLayerPoint(containerPoint),latlng=this.layerPointToLatLng(layerPoint);this.fire(type,{latlng:latlng,layerPoint:layerPoint,containerPoint:containerPoint,originalEvent:e})},_onTileLayerLoad:function(){this._tileLayersToLoad--;if(this._tileLayersNum&&!this._tileLayersToLoad){this.fire("tilelayersload")}},_clearHandlers:function(){for(var i=0,len=this._handlers.length;i<len;i++){this._handlers[i].disable()}},whenReady:function(callback,context){if(this._loaded){callback.call(context||this,this)}else{this.on("load",callback,context)}return this},_layerAdd:function(layer){layer.onAdd(this);this.fire("layeradd",{layer:layer})},_getMapPanePos:function(){return L.DomUtil.getPosition(this._mapPane)},_moved:function(){var pos=this._getMapPanePos();return pos&&!pos.equals([0,0])},_getTopLeftPoint:function(){return this.getPixelOrigin().subtract(this._getMapPanePos())},_getNewTopLeftPoint:function(center,zoom){var viewHalf=this.getSize()._divideBy(2);return this.project(center,zoom)._subtract(viewHalf)._round()},_latLngToNewLayerPoint:function(latlng,newZoom,newCenter){var topLeft=this._getNewTopLeftPoint(newCenter,newZoom).add(this._getMapPanePos());return this.project(latlng,newZoom)._subtract(topLeft)},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(latlng){return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint())},_limitCenter:function(center,zoom,bounds){if(!bounds){return center}var centerPoint=this.project(center,zoom),viewHalf=this.getSize().divideBy(2),viewBounds=new L.Bounds(centerPoint.subtract(viewHalf),centerPoint.add(viewHalf)),offset=this._getBoundsOffset(viewBounds,bounds,zoom);return this.unproject(centerPoint.add(offset),zoom)},_limitOffset:function(offset,bounds){if(!bounds){return offset}var viewBounds=this.getPixelBounds(),newBounds=new L.Bounds(viewBounds.min.add(offset),viewBounds.max.add(offset));return offset.add(this._getBoundsOffset(newBounds,bounds))},_getBoundsOffset:function(pxBounds,maxBounds,zoom){var nwOffset=this.project(maxBounds.getNorthWest(),zoom).subtract(pxBounds.min),seOffset=this.project(maxBounds.getSouthEast(),zoom).subtract(pxBounds.max),dx=this._rebound(nwOffset.x,-seOffset.x),dy=this._rebound(nwOffset.y,-seOffset.y);return new L.Point(dx,dy)},_rebound:function(left,right){return left+right>0?Math.round(left-right)/2:Math.max(0,Math.ceil(left))-Math.max(0,Math.floor(right))},_limitZoom:function(zoom){var min=this.getMinZoom(),max=this.getMaxZoom();return Math.max(min,Math.min(max,zoom))}});L.map=function(id,options){return new L.Map(id,options)};L.Projection.Mercator={MAX_LATITUDE:85.0840591556,R_MINOR:6356752.314245179,R_MAJOR:6378137,project:function(latlng){var d=L.LatLng.DEG_TO_RAD,max=this.MAX_LATITUDE,lat=Math.max(Math.min(max,latlng.lat),-max),r=this.R_MAJOR,r2=this.R_MINOR,x=latlng.lng*d*r,y=lat*d,tmp=r2/r,eccent=Math.sqrt(1-tmp*tmp),con=eccent*Math.sin(y);con=Math.pow((1-con)/(1+con),eccent*.5);var ts=Math.tan(.5*(Math.PI*.5-y))/con;y=-r*Math.log(ts);return new L.Point(x,y)},unproject:function(point){var d=L.LatLng.RAD_TO_DEG,r=this.R_MAJOR,r2=this.R_MINOR,lng=point.x*d/r,tmp=r2/r,eccent=Math.sqrt(1-tmp*tmp),ts=Math.exp(-point.y/r),phi=Math.PI/2-2*Math.atan(ts),numIter=15,tol=1e-7,i=numIter,dphi=.1,con;while(Math.abs(dphi)>tol&&--i>0){con=eccent*Math.sin(phi);dphi=Math.PI/2-2*Math.atan(ts*Math.pow((1-con)/(1+con),.5*eccent))-phi;phi+=dphi}return new L.LatLng(phi*d,lng)}};L.CRS.EPSG3395=L.extend({},L.CRS,{code:"EPSG:3395",projection:L.Projection.Mercator,transformation:function(){var m=L.Projection.Mercator,r=m.R_MAJOR,scale=.5/(Math.PI*r);return new L.Transformation(scale,.5,-scale,.5)}()});L.TileLayer=L.Class.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile},initialize:function(url,options){options=L.setOptions(this,options);if(options.detectRetina&&L.Browser.retina&&options.maxZoom>0){options.tileSize=Math.floor(options.tileSize/2);options.zoomOffset++;if(options.minZoom>0){options.minZoom--}this.options.maxZoom--}if(options.bounds){options.bounds=L.latLngBounds(options.bounds)}this._url=url;var subdomains=this.options.subdomains;if(typeof subdomains==="string"){this.options.subdomains=subdomains.split("")}},onAdd:function(map){this._map=map;this._animated=map._zoomAnimated;this._initContainer();map.on({viewreset:this._reset,moveend:this._update},this);if(this._animated){map.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this)}if(!this.options.updateWhenIdle){this._limitedUpdate=L.Util.limitExecByInterval(this._update,150,this);map.on("move",this._limitedUpdate,this)}this._reset();this._update()},addTo:function(map){map.addLayer(this);return this},onRemove:function(map){this._container.parentNode.removeChild(this._container);map.off({viewreset:this._reset,moveend:this._update},this);if(this._animated){map.off({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this)}if(!this.options.updateWhenIdle){map.off("move",this._limitedUpdate,this)}this._container=null;this._map=null},bringToFront:function(){var pane=this._map._panes.tilePane;if(this._container){pane.appendChild(this._container);this._setAutoZIndex(pane,Math.max)}return this},bringToBack:function(){var pane=this._map._panes.tilePane;if(this._container){pane.insertBefore(this._container,pane.firstChild);this._setAutoZIndex(pane,Math.min)}return this},getAttribution:function(){return this.options.attribution},getContainer:function(){return this._container},setOpacity:function(opacity){this.options.opacity=opacity;if(this._map){this._updateOpacity()}return this},setZIndex:function(zIndex){this.options.zIndex=zIndex;this._updateZIndex();return this},setUrl:function(url,noRedraw){this._url=url;if(!noRedraw){this.redraw()}return this},redraw:function(){if(this._map){this._reset({hard:true});this._update()}return this},_updateZIndex:function(){if(this._container&&this.options.zIndex!==undefined){this._container.style.zIndex=this.options.zIndex}},_setAutoZIndex:function(pane,compare){var layers=pane.children,edgeZIndex=-compare(Infinity,-Infinity),zIndex,i,len;for(i=0,len=layers.length;i<len;i++){if(layers[i]!==this._container){zIndex=parseInt(layers[i].style.zIndex,10);if(!isNaN(zIndex)){edgeZIndex=compare(edgeZIndex,zIndex)}}}this.options.zIndex=this._container.style.zIndex=(isFinite(edgeZIndex)?edgeZIndex:0)+compare(1,-1)},_updateOpacity:function(){var i,tiles=this._tiles;if(L.Browser.ielt9){for(i in tiles){L.DomUtil.setOpacity(tiles[i],this.options.opacity)}}else{L.DomUtil.setOpacity(this._container,this.options.opacity)}},_initContainer:function(){var tilePane=this._map._panes.tilePane;if(!this._container){this._container=L.DomUtil.create("div","leaflet-layer");this._updateZIndex();if(this._animated){var className="leaflet-tile-container";this._bgBuffer=L.DomUtil.create("div",className,this._container);this._tileContainer=L.DomUtil.create("div",className,this._container)}else{this._tileContainer=this._container}tilePane.appendChild(this._container);if(this.options.opacity<1){this._updateOpacity()}}},_reset:function(e){for(var key in this._tiles){this.fire("tileunload",{tile:this._tiles[key]})}this._tiles={};this._tilesToLoad=0;if(this.options.reuseTiles){this._unusedTiles=[]}this._tileContainer.innerHTML="";if(this._animated&&e&&e.hard){this._clearBgBuffer()}this._initContainer()},_getTileSize:function(){var map=this._map,zoom=map.getZoom()+this.options.zoomOffset,zoomN=this.options.maxNativeZoom,tileSize=this.options.tileSize;if(zoomN&&zoom>zoomN){tileSize=Math.round(map.getZoomScale(zoom)/map.getZoomScale(zoomN)*tileSize)}return tileSize},_update:function(){if(!this._map){return}var map=this._map,bounds=map.getPixelBounds(),zoom=map.getZoom(),tileSize=this._getTileSize();if(zoom>this.options.maxZoom||zoom<this.options.minZoom){return}var tileBounds=L.bounds(bounds.min.divideBy(tileSize)._floor(),bounds.max.divideBy(tileSize)._floor());this._addTilesFromCenterOut(tileBounds);if(this.options.unloadInvisibleTiles||this.options.reuseTiles){this._removeOtherTiles(tileBounds)}},_addTilesFromCenterOut:function(bounds){var queue=[],center=bounds.getCenter();var j,i,point;for(j=bounds.min.y;j<=bounds.max.y;j++){for(i=bounds.min.x;i<=bounds.max.x;i++){point=new L.Point(i,j);if(this._tileShouldBeLoaded(point)){queue.push(point)}}}var tilesToLoad=queue.length;if(tilesToLoad===0){return}queue.sort(function(a,b){return a.distanceTo(center)-b.distanceTo(center)});var fragment=document.createDocumentFragment();if(!this._tilesToLoad){this.fire("loading")}this._tilesToLoad+=tilesToLoad;for(i=0;i<tilesToLoad;i++){this._addTile(queue[i],fragment)}this._tileContainer.appendChild(fragment)},_tileShouldBeLoaded:function(tilePoint){if(tilePoint.x+":"+tilePoint.y in this._tiles){return false}var options=this.options;if(!options.continuousWorld){var limit=this._getWrapTileNum();if(options.noWrap&&(tilePoint.x<0||tilePoint.x>=limit.x)||tilePoint.y<0||tilePoint.y>=limit.y){return false}}if(options.bounds){var tileSize=options.tileSize,nwPoint=tilePoint.multiplyBy(tileSize),sePoint=nwPoint.add([tileSize,tileSize]),nw=this._map.unproject(nwPoint),se=this._map.unproject(sePoint);if(!options.continuousWorld&&!options.noWrap){nw=nw.wrap();se=se.wrap()}if(!options.bounds.intersects([nw,se])){return false}}return true},_removeOtherTiles:function(bounds){var kArr,x,y,key;for(key in this._tiles){kArr=key.split(":");x=parseInt(kArr[0],10);y=parseInt(kArr[1],10);if(x<bounds.min.x||x>bounds.max.x||y<bounds.min.y||y>bounds.max.y){this._removeTile(key)}}},_removeTile:function(key){var tile=this._tiles[key];this.fire("tileunload",{tile:tile,url:tile.src});if(this.options.reuseTiles){L.DomUtil.removeClass(tile,"leaflet-tile-loaded");this._unusedTiles.push(tile)}else if(tile.parentNode===this._tileContainer){this._tileContainer.removeChild(tile)}if(!L.Browser.android){tile.onload=null;tile.src=L.Util.emptyImageUrl}delete this._tiles[key]},_addTile:function(tilePoint,container){var tilePos=this._getTilePos(tilePoint);var tile=this._getTile();L.DomUtil.setPosition(tile,tilePos,L.Browser.chrome);this._tiles[tilePoint.x+":"+tilePoint.y]=tile;this._loadTile(tile,tilePoint);if(tile.parentNode!==this._tileContainer){container.appendChild(tile)}},_getZoomForUrl:function(){var options=this.options,zoom=this._map.getZoom();if(options.zoomReverse){zoom=options.maxZoom-zoom}zoom+=options.zoomOffset;return options.maxNativeZoom?Math.min(zoom,options.maxNativeZoom):zoom},_getTilePos:function(tilePoint){var origin=this._map.getPixelOrigin(),tileSize=this._getTileSize();return tilePoint.multiplyBy(tileSize).subtract(origin)},getTileUrl:function(tilePoint){return L.Util.template(this._url,L.extend({s:this._getSubdomain(tilePoint),z:tilePoint.z,x:tilePoint.x,y:tilePoint.y},this.options))},_getWrapTileNum:function(){var crs=this._map.options.crs,size=crs.getSize(this._map.getZoom());return size.divideBy(this._getTileSize())._floor()},_adjustTilePoint:function(tilePoint){var limit=this._getWrapTileNum();if(!this.options.continuousWorld&&!this.options.noWrap){tilePoint.x=(tilePoint.x%limit.x+limit.x)%limit.x}if(this.options.tms){tilePoint.y=limit.y-tilePoint.y-1}tilePoint.z=this._getZoomForUrl()},_getSubdomain:function(tilePoint){var index=Math.abs(tilePoint.x+tilePoint.y)%this.options.subdomains.length;return this.options.subdomains[index]},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var tile=this._unusedTiles.pop();this._resetTile(tile);return tile}return this._createTile()},_resetTile:function(){},_createTile:function(){var tile=L.DomUtil.create("img","leaflet-tile");tile.style.width=tile.style.height=this._getTileSize()+"px";tile.galleryimg="no";tile.onselectstart=tile.onmousemove=L.Util.falseFn;if(L.Browser.ielt9&&this.options.opacity!==undefined){L.DomUtil.setOpacity(tile,this.options.opacity)}if(L.Browser.mobileWebkit3d){tile.style.WebkitBackfaceVisibility="hidden"}return tile},_loadTile:function(tile,tilePoint){tile._layer=this;tile.onload=this._tileOnLoad;tile.onerror=this._tileOnError;this._adjustTilePoint(tilePoint);tile.src=this.getTileUrl(tilePoint);this.fire("tileloadstart",{tile:tile,url:tile.src})},_tileLoaded:function(){this._tilesToLoad--;if(this._animated){L.DomUtil.addClass(this._tileContainer,"leaflet-zoom-animated")}if(!this._tilesToLoad){this.fire("load");if(this._animated){clearTimeout(this._clearBgBufferTimer);this._clearBgBufferTimer=setTimeout(L.bind(this._clearBgBuffer,this),500)}}},_tileOnLoad:function(){var layer=this._layer;if(this.src!==L.Util.emptyImageUrl){L.DomUtil.addClass(this,"leaflet-tile-loaded");layer.fire("tileload",{tile:this,url:this.src})}layer._tileLoaded()},_tileOnError:function(){var layer=this._layer;layer.fire("tileerror",{tile:this,url:this.src});var newUrl=layer.options.errorTileUrl;if(newUrl){this.src=newUrl}layer._tileLoaded()}});L.tileLayer=function(url,options){return new L.TileLayer(url,options)};L.TileLayer.WMS=L.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:false},initialize:function(url,options){this._url=url;var wmsParams=L.extend({},this.defaultWmsParams),tileSize=options.tileSize||this.options.tileSize;if(options.detectRetina&&L.Browser.retina){wmsParams.width=wmsParams.height=tileSize*2}else{wmsParams.width=wmsParams.height=tileSize}for(var i in options){if(!this.options.hasOwnProperty(i)&&i!=="crs"){wmsParams[i]=options[i]}}this.wmsParams=wmsParams;L.setOptions(this,options)},onAdd:function(map){this._crs=this.options.crs||map.options.crs;this._wmsVersion=parseFloat(this.wmsParams.version);var projectionKey=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[projectionKey]=this._crs.code;L.TileLayer.prototype.onAdd.call(this,map)},getTileUrl:function(tilePoint){var map=this._map,tileSize=this.options.tileSize,nwPoint=tilePoint.multiplyBy(tileSize),sePoint=nwPoint.add([tileSize,tileSize]),nw=this._crs.project(map.unproject(nwPoint,tilePoint.z)),se=this._crs.project(map.unproject(sePoint,tilePoint.z)),bbox=this._wmsVersion>=1.3&&this._crs===L.CRS.EPSG4326?[se.y,nw.x,nw.y,se.x].join(","):[nw.x,se.y,se.x,nw.y].join(","),url=L.Util.template(this._url,{s:this._getSubdomain(tilePoint)});return url+L.Util.getParamString(this.wmsParams,url,true)+"&BBOX="+bbox},setParams:function(params,noRedraw){L.extend(this.wmsParams,params);if(!noRedraw){this.redraw()}return this}});L.tileLayer.wms=function(url,options){return new L.TileLayer.WMS(url,options)};L.TileLayer.Canvas=L.TileLayer.extend({options:{async:false},initialize:function(options){L.setOptions(this,options)},redraw:function(){if(this._map){this._reset({hard:true});this._update()}for(var i in this._tiles){this._redrawTile(this._tiles[i])}return this},_redrawTile:function(tile){this.drawTile(tile,tile._tilePoint,this._map._zoom)},_createTile:function(){var tile=L.DomUtil.create("canvas","leaflet-tile");tile.width=tile.height=this.options.tileSize;tile.onselectstart=tile.onmousemove=L.Util.falseFn;return tile},_loadTile:function(tile,tilePoint){tile._layer=this;tile._tilePoint=tilePoint;this._redrawTile(tile);if(!this.options.async){this.tileDrawn(tile)}},drawTile:function(){},tileDrawn:function(tile){this._tileOnLoad.call(tile)}});L.tileLayer.canvas=function(options){return new L.TileLayer.Canvas(options)};L.ImageOverlay=L.Class.extend({includes:L.Mixin.Events,options:{opacity:1},initialize:function(url,bounds,options){this._url=url;this._bounds=L.latLngBounds(bounds);L.setOptions(this,options)},onAdd:function(map){this._map=map;if(!this._image){this._initImage()}map._panes.overlayPane.appendChild(this._image);map.on("viewreset",this._reset,this);if(map.options.zoomAnimation&&L.Browser.any3d){map.on("zoomanim",this._animateZoom,this)}this._reset()},onRemove:function(map){map.getPanes().overlayPane.removeChild(this._image);map.off("viewreset",this._reset,this);if(map.options.zoomAnimation){map.off("zoomanim",this._animateZoom,this)}},addTo:function(map){map.addLayer(this);return this},setOpacity:function(opacity){this.options.opacity=opacity;this._updateOpacity();return this},bringToFront:function(){if(this._image){this._map._panes.overlayPane.appendChild(this._image)}return this},bringToBack:function(){var pane=this._map._panes.overlayPane;if(this._image){pane.insertBefore(this._image,pane.firstChild)}return this},setUrl:function(url){this._url=url;this._image.src=this._url},getAttribution:function(){return this.options.attribution},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer");if(this._map.options.zoomAnimation&&L.Browser.any3d){L.DomUtil.addClass(this._image,"leaflet-zoom-animated")}else{L.DomUtil.addClass(this._image,"leaflet-zoom-hide")}this._updateOpacity();L.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(e){var map=this._map,image=this._image,scale=map.getZoomScale(e.zoom),nw=this._bounds.getNorthWest(),se=this._bounds.getSouthEast(),topLeft=map._latLngToNewLayerPoint(nw,e.zoom,e.center),size=map._latLngToNewLayerPoint(se,e.zoom,e.center)._subtract(topLeft),origin=topLeft._add(size._multiplyBy(1/2*(1-1/scale)));image.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(origin)+" scale("+scale+") "},_reset:function(){var image=this._image,topLeft=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),size=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);L.DomUtil.setPosition(image,topLeft);image.style.width=size.x+"px";image.style.height=size.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){L.DomUtil.setOpacity(this._image,this.options.opacity)}});L.imageOverlay=function(url,bounds,options){return new L.ImageOverlay(url,bounds,options)};L.Icon=L.Class.extend({options:{className:""},initialize:function(options){L.setOptions(this,options)},createIcon:function(oldIcon){return this._createIcon("icon",oldIcon)},createShadow:function(oldIcon){return this._createIcon("shadow",oldIcon)},_createIcon:function(name,oldIcon){var src=this._getIconUrl(name);if(!src){if(name==="icon"){throw new Error("iconUrl not set in Icon options (see the docs).")}return null}var img;if(!oldIcon||oldIcon.tagName!=="IMG"){img=this._createImg(src)}else{img=this._createImg(src,oldIcon)}this._setIconStyles(img,name);return img},_setIconStyles:function(img,name){var options=this.options,size=L.point(options[name+"Size"]),anchor;if(name==="shadow"){anchor=L.point(options.shadowAnchor||options.iconAnchor)}else{anchor=L.point(options.iconAnchor)}if(!anchor&&size){anchor=size.divideBy(2,true)}img.className="leaflet-marker-"+name+" "+options.className;if(anchor){img.style.marginLeft=-anchor.x+"px";img.style.marginTop=-anchor.y+"px"}if(size){img.style.width=size.x+"px";img.style.height=size.y+"px"}},_createImg:function(src,el){el=el||document.createElement("img");el.src=src;return el},_getIconUrl:function(name){if(L.Browser.retina&&this.options[name+"RetinaUrl"]){return this.options[name+"RetinaUrl"]}return this.options[name+"Url"]}});L.icon=function(options){return new L.Icon(options)};L.Icon.Default=L.Icon.extend({options:{iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]},_getIconUrl:function(name){var key=name+"Url";if(this.options[key]){return this.options[key]}if(L.Browser.retina&&name==="icon"){name+="-2x"}var path=L.Icon.Default.imagePath;if(!path){throw new Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.")}return path+"/marker-"+name+".png"}});L.Icon.Default.imagePath=function(){var scripts=document.getElementsByTagName("script"),leafletRe=/[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;var i,len,src,matches,path;for(i=0,len=scripts.length;i<len;i++){src=scripts[i].src;matches=src.match(leafletRe);if(matches){path=src.split(leafletRe)[0];return(path?path+"/":"")+"images"}}}();L.Marker=L.Class.extend({includes:L.Mixin.Events,options:{icon:new L.Icon.Default,title:"",alt:"",clickable:true,draggable:false,keyboard:true,zIndexOffset:0,opacity:1,riseOnHover:false,riseOffset:250},initialize:function(latlng,options){L.setOptions(this,options);this._latlng=L.latLng(latlng)},onAdd:function(map){this._map=map;map.on("viewreset",this.update,this);this._initIcon();this.update();this.fire("add");if(map.options.zoomAnimation&&map.options.markerZoomAnimation){map.on("zoomanim",this._animateZoom,this)}},addTo:function(map){map.addLayer(this);return this},onRemove:function(map){if(this.dragging){this.dragging.disable()}this._removeIcon();this._removeShadow();this.fire("remove");map.off({viewreset:this.update,zoomanim:this._animateZoom},this);this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(latlng){this._latlng=L.latLng(latlng);this.update();return this.fire("move",{latlng:this._latlng})},setZIndexOffset:function(offset){this.options.zIndexOffset=offset;this.update();return this},setIcon:function(icon){this.options.icon=icon;if(this._map){this._initIcon();this.update()}if(this._popup){this.bindPopup(this._popup)}return this},update:function(){if(this._icon){var pos=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(pos)}return this},_initIcon:function(){var options=this.options,map=this._map,animation=map.options.zoomAnimation&&map.options.markerZoomAnimation,classToAdd=animation?"leaflet-zoom-animated":"leaflet-zoom-hide";var icon=options.icon.createIcon(this._icon),addIcon=false;if(icon!==this._icon){if(this._icon){this._removeIcon()}addIcon=true;if(options.title){icon.title=options.title}if(options.alt){icon.alt=options.alt}}L.DomUtil.addClass(icon,classToAdd);if(options.keyboard){icon.tabIndex="0"}this._icon=icon;this._initInteraction();if(options.riseOnHover){L.DomEvent.on(icon,"mouseover",this._bringToFront,this).on(icon,"mouseout",this._resetZIndex,this)}var newShadow=options.icon.createShadow(this._shadow),addShadow=false;if(newShadow!==this._shadow){this._removeShadow();addShadow=true}if(newShadow){L.DomUtil.addClass(newShadow,classToAdd)}this._shadow=newShadow;if(options.opacity<1){this._updateOpacity()}var panes=this._map._panes;if(addIcon){panes.markerPane.appendChild(this._icon)}if(newShadow&&addShadow){panes.shadowPane.appendChild(this._shadow)}},_removeIcon:function(){if(this.options.riseOnHover){L.DomEvent.off(this._icon,"mouseover",this._bringToFront).off(this._icon,"mouseout",this._resetZIndex)}this._map._panes.markerPane.removeChild(this._icon);this._icon=null},_removeShadow:function(){if(this._shadow){this._map._panes.shadowPane.removeChild(this._shadow)}this._shadow=null},_setPos:function(pos){L.DomUtil.setPosition(this._icon,pos);if(this._shadow){L.DomUtil.setPosition(this._shadow,pos)}this._zIndex=pos.y+this.options.zIndexOffset;this._resetZIndex()},_updateZIndex:function(offset){this._icon.style.zIndex=this._zIndex+offset},_animateZoom:function(opt){var pos=this._map._latLngToNewLayerPoint(this._latlng,opt.zoom,opt.center).round();this._setPos(pos)},_initInteraction:function(){if(!this.options.clickable){return}var icon=this._icon,events=["dblclick","mousedown","mouseover","mouseout","contextmenu"];L.DomUtil.addClass(icon,"leaflet-clickable");L.DomEvent.on(icon,"click",this._onMouseClick,this);L.DomEvent.on(icon,"keypress",this._onKeyPress,this);for(var i=0;i<events.length;i++){L.DomEvent.on(icon,events[i],this._fireMouseEvent,this)}if(L.Handler.MarkerDrag){this.dragging=new L.Handler.MarkerDrag(this);if(this.options.draggable){this.dragging.enable()}}},_onMouseClick:function(e){var wasDragged=this.dragging&&this.dragging.moved();if(this.hasEventListeners(e.type)||wasDragged){L.DomEvent.stopPropagation(e)}if(wasDragged){return}if((!this.dragging||!this.dragging._enabled)&&this._map.dragging&&this._map.dragging.moved()){return}this.fire(e.type,{originalEvent:e,latlng:this._latlng})},_onKeyPress:function(e){if(e.keyCode===13){this.fire("click",{originalEvent:e,latlng:this._latlng})}},_fireMouseEvent:function(e){this.fire(e.type,{originalEvent:e,latlng:this._latlng});if(e.type==="contextmenu"&&this.hasEventListeners(e.type)){L.DomEvent.preventDefault(e)}if(e.type!=="mousedown"){L.DomEvent.stopPropagation(e)}else{L.DomEvent.preventDefault(e)}},setOpacity:function(opacity){this.options.opacity=opacity;if(this._map){this._updateOpacity()}return this},_updateOpacity:function(){L.DomUtil.setOpacity(this._icon,this.options.opacity);if(this._shadow){L.DomUtil.setOpacity(this._shadow,this.options.opacity)}},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)}});L.marker=function(latlng,options){return new L.Marker(latlng,options)};L.DivIcon=L.Icon.extend({options:{iconSize:[12,12],className:"leaflet-div-icon",html:false},createIcon:function(oldIcon){var div=oldIcon&&oldIcon.tagName==="DIV"?oldIcon:document.createElement("div"),options=this.options;if(options.html!==false){div.innerHTML=options.html}else{div.innerHTML=""}if(options.bgPos){div.style.backgroundPosition=-options.bgPos.x+"px "+-options.bgPos.y+"px"}this._setIconStyles(div,"icon");return div},createShadow:function(){return null;
}});L.divIcon=function(options){return new L.DivIcon(options)};L.Map.mergeOptions({closePopupOnClick:true});L.Popup=L.Class.extend({includes:L.Mixin.Events,options:{minWidth:50,maxWidth:300,autoPan:true,closeButton:true,offset:[0,7],autoPanPadding:[5,5],keepInView:false,className:"",zoomAnimation:true},initialize:function(options,source){L.setOptions(this,options);this._source=source;this._animated=L.Browser.any3d&&this.options.zoomAnimation;this._isOpen=false},onAdd:function(map){this._map=map;if(!this._container){this._initLayout()}var animFade=map.options.fadeAnimation;if(animFade){L.DomUtil.setOpacity(this._container,0)}map._panes.popupPane.appendChild(this._container);map.on(this._getEvents(),this);this.update();if(animFade){L.DomUtil.setOpacity(this._container,1)}this.fire("open");map.fire("popupopen",{popup:this});if(this._source){this._source.fire("popupopen",{popup:this})}},addTo:function(map){map.addLayer(this);return this},openOn:function(map){map.openPopup(this);return this},onRemove:function(map){map._panes.popupPane.removeChild(this._container);L.Util.falseFn(this._container.offsetWidth);map.off(this._getEvents(),this);if(map.options.fadeAnimation){L.DomUtil.setOpacity(this._container,0)}this._map=null;this.fire("close");map.fire("popupclose",{popup:this});if(this._source){this._source.fire("popupclose",{popup:this})}},getLatLng:function(){return this._latlng},setLatLng:function(latlng){this._latlng=L.latLng(latlng);if(this._map){this._updatePosition();this._adjustPan()}return this},getContent:function(){return this._content},setContent:function(content){this._content=content;this.update();return this},update:function(){if(!this._map){return}this._container.style.visibility="hidden";this._updateContent();this._updateLayout();this._updatePosition();this._container.style.visibility="";this._adjustPan()},_getEvents:function(){var events={viewreset:this._updatePosition};if(this._animated){events.zoomanim=this._zoomAnimation}if("closeOnClick"in this.options?this.options.closeOnClick:this._map.options.closePopupOnClick){events.preclick=this._close}if(this.options.keepInView){events.moveend=this._adjustPan}return events},_close:function(){if(this._map){this._map.closePopup(this)}},_initLayout:function(){var prefix="leaflet-popup",containerClass=prefix+" "+this.options.className+" leaflet-zoom-"+(this._animated?"animated":"hide"),container=this._container=L.DomUtil.create("div",containerClass),closeButton;if(this.options.closeButton){closeButton=this._closeButton=L.DomUtil.create("a",prefix+"-close-button",container);closeButton.href="#close";closeButton.innerHTML="&#215;";L.DomEvent.disableClickPropagation(closeButton);L.DomEvent.on(closeButton,"click",this._onCloseButtonClick,this)}var wrapper=this._wrapper=L.DomUtil.create("div",prefix+"-content-wrapper",container);L.DomEvent.disableClickPropagation(wrapper);this._contentNode=L.DomUtil.create("div",prefix+"-content",wrapper);L.DomEvent.disableScrollPropagation(this._contentNode);L.DomEvent.on(wrapper,"contextmenu",L.DomEvent.stopPropagation);this._tipContainer=L.DomUtil.create("div",prefix+"-tip-container",container);this._tip=L.DomUtil.create("div",prefix+"-tip",this._tipContainer)},_updateContent:function(){if(!this._content){return}if(typeof this._content==="string"){this._contentNode.innerHTML=this._content}else{while(this._contentNode.hasChildNodes()){this._contentNode.removeChild(this._contentNode.firstChild)}this._contentNode.appendChild(this._content)}this.fire("contentupdate")},_updateLayout:function(){var container=this._contentNode,style=container.style;style.width="";style.whiteSpace="nowrap";var width=container.offsetWidth;width=Math.min(width,this.options.maxWidth);width=Math.max(width,this.options.minWidth);style.width=width+1+"px";style.whiteSpace="";style.height="";var height=container.offsetHeight,maxHeight=this.options.maxHeight,scrolledClass="leaflet-popup-scrolled";if(maxHeight&&height>maxHeight){style.height=maxHeight+"px";L.DomUtil.addClass(container,scrolledClass)}else{L.DomUtil.removeClass(container,scrolledClass)}this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(!this._map){return}var pos=this._map.latLngToLayerPoint(this._latlng),animated=this._animated,offset=L.point(this.options.offset);if(animated){L.DomUtil.setPosition(this._container,pos)}this._containerBottom=-offset.y-(animated?0:pos.y);this._containerLeft=-Math.round(this._containerWidth/2)+offset.x+(animated?0:pos.x);this._container.style.bottom=this._containerBottom+"px";this._container.style.left=this._containerLeft+"px"},_zoomAnimation:function(opt){var pos=this._map._latLngToNewLayerPoint(this._latlng,opt.zoom,opt.center);L.DomUtil.setPosition(this._container,pos)},_adjustPan:function(){if(!this.options.autoPan){return}var map=this._map,containerHeight=this._container.offsetHeight,containerWidth=this._containerWidth,layerPos=new L.Point(this._containerLeft,-containerHeight-this._containerBottom);if(this._animated){layerPos._add(L.DomUtil.getPosition(this._container))}var containerPos=map.layerPointToContainerPoint(layerPos),padding=L.point(this.options.autoPanPadding),paddingTL=L.point(this.options.autoPanPaddingTopLeft||padding),paddingBR=L.point(this.options.autoPanPaddingBottomRight||padding),size=map.getSize(),dx=0,dy=0;if(containerPos.x+containerWidth+paddingBR.x>size.x){dx=containerPos.x+containerWidth-size.x+paddingBR.x}if(containerPos.x-dx-paddingTL.x<0){dx=containerPos.x-paddingTL.x}if(containerPos.y+containerHeight+paddingBR.y>size.y){dy=containerPos.y+containerHeight-size.y+paddingBR.y}if(containerPos.y-dy-paddingTL.y<0){dy=containerPos.y-paddingTL.y}if(dx||dy){map.fire("autopanstart").panBy([dx,dy])}},_onCloseButtonClick:function(e){this._close();L.DomEvent.stop(e)}});L.popup=function(options,source){return new L.Popup(options,source)};L.Map.include({openPopup:function(popup,latlng,options){this.closePopup();if(!(popup instanceof L.Popup)){var content=popup;popup=new L.Popup(options).setLatLng(latlng).setContent(content)}popup._isOpen=true;this._popup=popup;return this.addLayer(popup)},closePopup:function(popup){if(!popup||popup===this._popup){popup=this._popup;this._popup=null}if(popup){this.removeLayer(popup);popup._isOpen=false}return this}});L.Marker.include({openPopup:function(){if(this._popup&&this._map&&!this._map.hasLayer(this._popup)){this._popup.setLatLng(this._latlng);this._map.openPopup(this._popup)}return this},closePopup:function(){if(this._popup){this._popup._close()}return this},togglePopup:function(){if(this._popup){if(this._popup._isOpen){this.closePopup()}else{this.openPopup()}}return this},bindPopup:function(content,options){var anchor=L.point(this.options.icon.options.popupAnchor||[0,0]);anchor=anchor.add(L.Popup.prototype.options.offset);if(options&&options.offset){anchor=anchor.add(options.offset)}options=L.extend({offset:anchor},options);if(!this._popupHandlersAdded){this.on("click",this.togglePopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this);this._popupHandlersAdded=true}if(content instanceof L.Popup){L.setOptions(content,options);this._popup=content}else{this._popup=new L.Popup(options,this).setContent(content)}return this},setPopupContent:function(content){if(this._popup){this._popup.setContent(content)}return this},unbindPopup:function(){if(this._popup){this._popup=null;this.off("click",this.togglePopup,this).off("remove",this.closePopup,this).off("move",this._movePopup,this);this._popupHandlersAdded=false}return this},getPopup:function(){return this._popup},_movePopup:function(e){this._popup.setLatLng(e.latlng)}});L.LayerGroup=L.Class.extend({initialize:function(layers){this._layers={};var i,len;if(layers){for(i=0,len=layers.length;i<len;i++){this.addLayer(layers[i])}}},addLayer:function(layer){var id=this.getLayerId(layer);this._layers[id]=layer;if(this._map){this._map.addLayer(layer)}return this},removeLayer:function(layer){var id=layer in this._layers?layer:this.getLayerId(layer);if(this._map&&this._layers[id]){this._map.removeLayer(this._layers[id])}delete this._layers[id];return this},hasLayer:function(layer){if(!layer){return false}return layer in this._layers||this.getLayerId(layer)in this._layers},clearLayers:function(){this.eachLayer(this.removeLayer,this);return this},invoke:function(methodName){var args=Array.prototype.slice.call(arguments,1),i,layer;for(i in this._layers){layer=this._layers[i];if(layer[methodName]){layer[methodName].apply(layer,args)}}return this},onAdd:function(map){this._map=map;this.eachLayer(map.addLayer,map)},onRemove:function(map){this.eachLayer(map.removeLayer,map);this._map=null},addTo:function(map){map.addLayer(this);return this},eachLayer:function(method,context){for(var i in this._layers){method.call(context,this._layers[i])}return this},getLayer:function(id){return this._layers[id]},getLayers:function(){var layers=[];for(var i in this._layers){layers.push(this._layers[i])}return layers},setZIndex:function(zIndex){return this.invoke("setZIndex",zIndex)},getLayerId:function(layer){return L.stamp(layer)}});L.layerGroup=function(layers){return new L.LayerGroup(layers)};L.FeatureGroup=L.LayerGroup.extend({includes:L.Mixin.Events,statics:{EVENTS:"click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose"},addLayer:function(layer){if(this.hasLayer(layer)){return this}if("on"in layer){layer.on(L.FeatureGroup.EVENTS,this._propagateEvent,this)}L.LayerGroup.prototype.addLayer.call(this,layer);if(this._popupContent&&layer.bindPopup){layer.bindPopup(this._popupContent,this._popupOptions)}return this.fire("layeradd",{layer:layer})},removeLayer:function(layer){if(!this.hasLayer(layer)){return this}if(layer in this._layers){layer=this._layers[layer]}layer.off(L.FeatureGroup.EVENTS,this._propagateEvent,this);L.LayerGroup.prototype.removeLayer.call(this,layer);if(this._popupContent){this.invoke("unbindPopup")}return this.fire("layerremove",{layer:layer})},bindPopup:function(content,options){this._popupContent=content;this._popupOptions=options;return this.invoke("bindPopup",content,options)},openPopup:function(latlng){for(var id in this._layers){this._layers[id].openPopup(latlng);break}return this},setStyle:function(style){return this.invoke("setStyle",style)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var bounds=new L.LatLngBounds;this.eachLayer(function(layer){bounds.extend(layer instanceof L.Marker?layer.getLatLng():layer.getBounds())});return bounds},_propagateEvent:function(e){e=L.extend({layer:e.target,target:this},e);this.fire(e.type,e)}});L.featureGroup=function(layers){return new L.FeatureGroup(layers)};L.Path=L.Class.extend({includes:[L.Mixin.Events],statics:{CLIP_PADDING:function(){var max=L.Browser.mobile?1280:2e3,target=(max/Math.max(window.outerWidth,window.outerHeight)-1)/2;return Math.max(0,Math.min(.5,target))}()},options:{stroke:true,color:"#0033ff",dashArray:null,lineCap:null,lineJoin:null,weight:5,opacity:.5,fill:false,fillColor:null,fillOpacity:.2,clickable:true},initialize:function(options){L.setOptions(this,options)},onAdd:function(map){this._map=map;if(!this._container){this._initElements();this._initEvents()}this.projectLatlngs();this._updatePath();if(this._container){this._map._pathRoot.appendChild(this._container)}this.fire("add");map.on({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},addTo:function(map){map.addLayer(this);return this},onRemove:function(map){map._pathRoot.removeChild(this._container);this.fire("remove");this._map=null;if(L.Browser.vml){this._container=null;this._stroke=null;this._fill=null}map.off({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},projectLatlngs:function(){},setStyle:function(style){L.setOptions(this,style);if(this._container){this._updateStyle()}return this},redraw:function(){if(this._map){this.projectLatlngs();this._updatePath()}return this}});L.Map.include({_updatePathViewport:function(){var p=L.Path.CLIP_PADDING,size=this.getSize(),panePos=L.DomUtil.getPosition(this._mapPane),min=panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()),max=min.add(size.multiplyBy(1+p*2)._round());this._pathViewport=new L.Bounds(min,max)}});L.Path.SVG_NS="http://www.w3.org/2000/svg";L.Browser.svg=!!(document.createElementNS&&document.createElementNS(L.Path.SVG_NS,"svg").createSVGRect);L.Path=L.Path.extend({statics:{SVG:L.Browser.svg},bringToFront:function(){var root=this._map._pathRoot,path=this._container;if(path&&root.lastChild!==path){root.appendChild(path)}return this},bringToBack:function(){var root=this._map._pathRoot,path=this._container,first=root.firstChild;if(path&&first!==path){root.insertBefore(path,first)}return this},getPathString:function(){},_createElement:function(name){return document.createElementNS(L.Path.SVG_NS,name)},_initElements:function(){this._map._initPathRoot();this._initPath();this._initStyle()},_initPath:function(){this._container=this._createElement("g");this._path=this._createElement("path");if(this.options.className){L.DomUtil.addClass(this._path,this.options.className)}this._container.appendChild(this._path)},_initStyle:function(){if(this.options.stroke){this._path.setAttribute("stroke-linejoin","round");this._path.setAttribute("stroke-linecap","round")}if(this.options.fill){this._path.setAttribute("fill-rule","evenodd")}if(this.options.pointerEvents){this._path.setAttribute("pointer-events",this.options.pointerEvents)}if(!this.options.clickable&&!this.options.pointerEvents){this._path.setAttribute("pointer-events","none")}this._updateStyle()},_updateStyle:function(){if(this.options.stroke){this._path.setAttribute("stroke",this.options.color);this._path.setAttribute("stroke-opacity",this.options.opacity);this._path.setAttribute("stroke-width",this.options.weight);if(this.options.dashArray){this._path.setAttribute("stroke-dasharray",this.options.dashArray)}else{this._path.removeAttribute("stroke-dasharray")}if(this.options.lineCap){this._path.setAttribute("stroke-linecap",this.options.lineCap)}if(this.options.lineJoin){this._path.setAttribute("stroke-linejoin",this.options.lineJoin)}}else{this._path.setAttribute("stroke","none")}if(this.options.fill){this._path.setAttribute("fill",this.options.fillColor||this.options.color);this._path.setAttribute("fill-opacity",this.options.fillOpacity)}else{this._path.setAttribute("fill","none")}},_updatePath:function(){var str=this.getPathString();if(!str){str="M0 0"}this._path.setAttribute("d",str)},_initEvents:function(){if(this.options.clickable){if(L.Browser.svg||!L.Browser.vml){L.DomUtil.addClass(this._path,"leaflet-clickable")}L.DomEvent.on(this._container,"click",this._onMouseClick,this);var events=["dblclick","mousedown","mouseover","mouseout","mousemove","contextmenu"];for(var i=0;i<events.length;i++){L.DomEvent.on(this._container,events[i],this._fireMouseEvent,this)}}},_onMouseClick:function(e){if(this._map.dragging&&this._map.dragging.moved()){return}this._fireMouseEvent(e)},_fireMouseEvent:function(e){if(!this.hasEventListeners(e.type)){return}var map=this._map,containerPoint=map.mouseEventToContainerPoint(e),layerPoint=map.containerPointToLayerPoint(containerPoint),latlng=map.layerPointToLatLng(layerPoint);this.fire(e.type,{latlng:latlng,layerPoint:layerPoint,containerPoint:containerPoint,originalEvent:e});if(e.type==="contextmenu"){L.DomEvent.preventDefault(e)}if(e.type!=="mousemove"){L.DomEvent.stopPropagation(e)}}});L.Map.include({_initPathRoot:function(){if(!this._pathRoot){this._pathRoot=L.Path.prototype._createElement("svg");this._panes.overlayPane.appendChild(this._pathRoot);if(this.options.zoomAnimation&&L.Browser.any3d){L.DomUtil.addClass(this._pathRoot,"leaflet-zoom-animated");this.on({zoomanim:this._animatePathZoom,zoomend:this._endPathZoom})}else{L.DomUtil.addClass(this._pathRoot,"leaflet-zoom-hide")}this.on("moveend",this._updateSvgViewport);this._updateSvgViewport()}},_animatePathZoom:function(e){var scale=this.getZoomScale(e.zoom),offset=this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min);this._pathRoot.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(offset)+" scale("+scale+") ";this._pathZooming=true},_endPathZoom:function(){this._pathZooming=false},_updateSvgViewport:function(){if(this._pathZooming){return}this._updatePathViewport();var vp=this._pathViewport,min=vp.min,max=vp.max,width=max.x-min.x,height=max.y-min.y,root=this._pathRoot,pane=this._panes.overlayPane;if(L.Browser.mobileWebkit){pane.removeChild(root)}L.DomUtil.setPosition(root,min);root.setAttribute("width",width);root.setAttribute("height",height);root.setAttribute("viewBox",[min.x,min.y,width,height].join(" "));if(L.Browser.mobileWebkit){pane.appendChild(root)}}});L.Path.include({bindPopup:function(content,options){if(content instanceof L.Popup){this._popup=content}else{if(!this._popup||options){this._popup=new L.Popup(options,this)}this._popup.setContent(content)}if(!this._popupHandlersAdded){this.on("click",this._openPopup,this).on("remove",this.closePopup,this);this._popupHandlersAdded=true}return this},unbindPopup:function(){if(this._popup){this._popup=null;this.off("click",this._openPopup).off("remove",this.closePopup);this._popupHandlersAdded=false}return this},openPopup:function(latlng){if(this._popup){latlng=latlng||this._latlng||this._latlngs[Math.floor(this._latlngs.length/2)];this._openPopup({latlng:latlng})}return this},closePopup:function(){if(this._popup){this._popup._close()}return this},_openPopup:function(e){this._popup.setLatLng(e.latlng);this._map.openPopup(this._popup)}});L.Browser.vml=!L.Browser.svg&&function(){try{var div=document.createElement("div");div.innerHTML='<v:shape adj="1"/>';var shape=div.firstChild;shape.style.behavior="url(#default#VML)";return shape&&typeof shape.adj==="object"}catch(e){return false}}();L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:true,CLIP_PADDING:.02},_createElement:function(){try{document.namespaces.add("lvml","urn:schemas-microsoft-com:vml");return function(name){return document.createElement("<lvml:"+name+' class="lvml">')}}catch(e){return function(name){return document.createElement("<"+name+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var container=this._container=this._createElement("shape");L.DomUtil.addClass(container,"leaflet-vml-shape"+(this.options.className?" "+this.options.className:""));if(this.options.clickable){L.DomUtil.addClass(container,"leaflet-clickable")}container.coordsize="1 1";this._path=this._createElement("path");container.appendChild(this._path);this._map._pathRoot.appendChild(container)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var stroke=this._stroke,fill=this._fill,options=this.options,container=this._container;container.stroked=options.stroke;container.filled=options.fill;if(options.stroke){if(!stroke){stroke=this._stroke=this._createElement("stroke");stroke.endcap="round";container.appendChild(stroke)}stroke.weight=options.weight+"px";stroke.color=options.color;stroke.opacity=options.opacity;if(options.dashArray){stroke.dashStyle=L.Util.isArray(options.dashArray)?options.dashArray.join(" "):options.dashArray.replace(/( *, *)/g," ")}else{stroke.dashStyle=""}if(options.lineCap){stroke.endcap=options.lineCap.replace("butt","flat")}if(options.lineJoin){stroke.joinstyle=options.lineJoin}}else if(stroke){container.removeChild(stroke);this._stroke=null}if(options.fill){if(!fill){fill=this._fill=this._createElement("fill");container.appendChild(fill)}fill.color=options.fillColor||options.color;fill.opacity=options.fillOpacity}else if(fill){container.removeChild(fill);this._fill=null}},_updatePath:function(){var style=this._container.style;style.display="none";this._path.v=this.getPathString()+" ";style.display=""}});L.Map.include(L.Browser.svg||!L.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot){return}var root=this._pathRoot=document.createElement("div");root.className="leaflet-vml-container";this._panes.overlayPane.appendChild(root);this.on("moveend",this._updatePathViewport);this._updatePathViewport()}});L.Browser.canvas=function(){return!!document.createElement("canvas").getContext}();L.Path=L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?L.Path:L.Path.extend({statics:{CANVAS:true,SVG:false},redraw:function(){if(this._map){this.projectLatlngs();this._requestUpdate()}return this},setStyle:function(style){L.setOptions(this,style);if(this._map){this._updateStyle();this._requestUpdate()}return this},onRemove:function(map){map.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this);if(this.options.clickable){this._map.off("click",this._onClick,this);this._map.off("mousemove",this._onMouseMove,this)}this._requestUpdate();this.fire("remove");this._map=null},_requestUpdate:function(){if(this._map&&!L.Path._updateRequest){L.Path._updateRequest=L.Util.requestAnimFrame(this._fireMapMoveEnd,this._map)}},_fireMapMoveEnd:function(){L.Path._updateRequest=null;this.fire("moveend")},_initElements:function(){this._map._initPathRoot();this._ctx=this._map._canvasCtx},_updateStyle:function(){var options=this.options;if(options.stroke){this._ctx.lineWidth=options.weight;this._ctx.strokeStyle=options.color}if(options.fill){this._ctx.fillStyle=options.fillColor||options.color}},_drawPath:function(){var i,j,len,len2,point,drawMethod;this._ctx.beginPath();for(i=0,len=this._parts.length;i<len;i++){for(j=0,len2=this._parts[i].length;j<len2;j++){point=this._parts[i][j];drawMethod=(j===0?"move":"line")+"To";this._ctx[drawMethod](point.x,point.y)}if(this instanceof L.Polygon){this._ctx.closePath()}}},_checkIfEmpty:function(){return!this._parts.length},_updatePath:function(){if(this._checkIfEmpty()){return}var ctx=this._ctx,options=this.options;this._drawPath();ctx.save();this._updateStyle();if(options.fill){ctx.globalAlpha=options.fillOpacity;ctx.fill()}if(options.stroke){ctx.globalAlpha=options.opacity;ctx.stroke()}ctx.restore()},_initEvents:function(){if(this.options.clickable){this._map.on("mousemove",this._onMouseMove,this);this._map.on("click",this._onClick,this)}},_onClick:function(e){if(this._containsPoint(e.layerPoint)){this.fire("click",e)}},_onMouseMove:function(e){if(!this._map||this._map._animatingZoom){return}if(this._containsPoint(e.layerPoint)){this._ctx.canvas.style.cursor="pointer";this._mouseInside=true;this.fire("mouseover",e)}else if(this._mouseInside){this._ctx.canvas.style.cursor="";this._mouseInside=false;this.fire("mouseout",e)}}});L.Map.include(L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?{}:{_initPathRoot:function(){var root=this._pathRoot,ctx;if(!root){root=this._pathRoot=document.createElement("canvas");root.style.position="absolute";ctx=this._canvasCtx=root.getContext("2d");ctx.lineCap="round";ctx.lineJoin="round";this._panes.overlayPane.appendChild(root);if(this.options.zoomAnimation){this._pathRoot.className="leaflet-zoom-animated";this.on("zoomanim",this._animatePathZoom);this.on("zoomend",this._endPathZoom)}this.on("moveend",this._updateCanvasViewport);this._updateCanvasViewport()}},_updateCanvasViewport:function(){if(this._pathZooming){return}this._updatePathViewport();var vp=this._pathViewport,min=vp.min,size=vp.max.subtract(min),root=this._pathRoot;L.DomUtil.setPosition(root,min);root.width=size.x;root.height=size.y;root.getContext("2d").translate(-min.x,-min.y)}});L.LineUtil={simplify:function(points,tolerance){if(!tolerance||!points.length){return points.slice()}var sqTolerance=tolerance*tolerance;points=this._reducePoints(points,sqTolerance);points=this._simplifyDP(points,sqTolerance);return points},pointToSegmentDistance:function(p,p1,p2){return Math.sqrt(this._sqClosestPointOnSegment(p,p1,p2,true))},closestPointOnSegment:function(p,p1,p2){return this._sqClosestPointOnSegment(p,p1,p2)},_simplifyDP:function(points,sqTolerance){var len=points.length,ArrayConstructor=typeof Uint8Array!==undefined+""?Uint8Array:Array,markers=new ArrayConstructor(len);markers[0]=markers[len-1]=1;this._simplifyDPStep(points,markers,sqTolerance,0,len-1);var i,newPoints=[];for(i=0;i<len;i++){if(markers[i]){newPoints.push(points[i])}}return newPoints},_simplifyDPStep:function(points,markers,sqTolerance,first,last){var maxSqDist=0,index,i,sqDist;for(i=first+1;i<=last-1;i++){sqDist=this._sqClosestPointOnSegment(points[i],points[first],points[last],true);if(sqDist>maxSqDist){index=i;maxSqDist=sqDist}}if(maxSqDist>sqTolerance){markers[index]=1;this._simplifyDPStep(points,markers,sqTolerance,first,index);this._simplifyDPStep(points,markers,sqTolerance,index,last)}},_reducePoints:function(points,sqTolerance){var reducedPoints=[points[0]];for(var i=1,prev=0,len=points.length;i<len;i++){if(this._sqDist(points[i],points[prev])>sqTolerance){reducedPoints.push(points[i]);prev=i}}if(prev<len-1){reducedPoints.push(points[len-1])}return reducedPoints},clipSegment:function(a,b,bounds,useLastCode){var codeA=useLastCode?this._lastCode:this._getBitCode(a,bounds),codeB=this._getBitCode(b,bounds),codeOut,p,newCode;this._lastCode=codeB;while(true){if(!(codeA|codeB)){return[a,b]}else if(codeA&codeB){return false}else{codeOut=codeA||codeB;p=this._getEdgeIntersection(a,b,codeOut,bounds);newCode=this._getBitCode(p,bounds);if(codeOut===codeA){a=p;codeA=newCode}else{b=p;codeB=newCode}}}},_getEdgeIntersection:function(a,b,code,bounds){var dx=b.x-a.x,dy=b.y-a.y,min=bounds.min,max=bounds.max;if(code&8){return new L.Point(a.x+dx*(max.y-a.y)/dy,max.y)}else if(code&4){return new L.Point(a.x+dx*(min.y-a.y)/dy,min.y)}else if(code&2){return new L.Point(max.x,a.y+dy*(max.x-a.x)/dx)}else if(code&1){return new L.Point(min.x,a.y+dy*(min.x-a.x)/dx)}},_getBitCode:function(p,bounds){var code=0;if(p.x<bounds.min.x){code|=1}else if(p.x>bounds.max.x){code|=2}if(p.y<bounds.min.y){code|=4}else if(p.y>bounds.max.y){code|=8}return code},_sqDist:function(p1,p2){var dx=p2.x-p1.x,dy=p2.y-p1.y;return dx*dx+dy*dy},_sqClosestPointOnSegment:function(p,p1,p2,sqDist){var x=p1.x,y=p1.y,dx=p2.x-x,dy=p2.y-y,dot=dx*dx+dy*dy,t;if(dot>0){t=((p.x-x)*dx+(p.y-y)*dy)/dot;if(t>1){x=p2.x;y=p2.y}else if(t>0){x+=dx*t;y+=dy*t}}dx=p.x-x;dy=p.y-y;return sqDist?dx*dx+dy*dy:new L.Point(x,y)}};L.Polyline=L.Path.extend({initialize:function(latlngs,options){L.Path.prototype.initialize.call(this,options);this._latlngs=this._convertLatLngs(latlngs)},options:{smoothFactor:1,noClip:false},projectLatlngs:function(){this._originalPoints=[];for(var i=0,len=this._latlngs.length;i<len;i++){this._originalPoints[i]=this._map.latLngToLayerPoint(this._latlngs[i])}},getPathString:function(){for(var i=0,len=this._parts.length,str="";i<len;i++){str+=this._getPathPartStr(this._parts[i])}return str},getLatLngs:function(){return this._latlngs},setLatLngs:function(latlngs){this._latlngs=this._convertLatLngs(latlngs);return this.redraw()},addLatLng:function(latlng){this._latlngs.push(L.latLng(latlng));return this.redraw()},spliceLatLngs:function(){var removed=[].splice.apply(this._latlngs,arguments);this._convertLatLngs(this._latlngs,true);this.redraw();return removed},closestLayerPoint:function(p){var minDistance=Infinity,parts=this._parts,p1,p2,minPoint=null;for(var j=0,jLen=parts.length;j<jLen;j++){var points=parts[j];for(var i=1,len=points.length;i<len;i++){p1=points[i-1];p2=points[i];var sqDist=L.LineUtil._sqClosestPointOnSegment(p,p1,p2,true);if(sqDist<minDistance){minDistance=sqDist;minPoint=L.LineUtil._sqClosestPointOnSegment(p,p1,p2)}}}if(minPoint){minPoint.distance=Math.sqrt(minDistance)}return minPoint},getBounds:function(){return new L.LatLngBounds(this.getLatLngs())},_convertLatLngs:function(latlngs,overwrite){var i,len,target=overwrite?latlngs:[];for(i=0,len=latlngs.length;i<len;i++){if(L.Util.isArray(latlngs[i])&&typeof latlngs[i][0]!=="number"){return}target[i]=L.latLng(latlngs[i])}return target},_initEvents:function(){L.Path.prototype._initEvents.call(this)},_getPathPartStr:function(points){var round=L.Path.VML;for(var j=0,len2=points.length,str="",p;j<len2;j++){p=points[j];if(round){p._round()}str+=(j?"L":"M")+p.x+" "+p.y}return str},_clipPoints:function(){var points=this._originalPoints,len=points.length,i,k,segment;if(this.options.noClip){this._parts=[points];return}this._parts=[];var parts=this._parts,vp=this._map._pathViewport,lu=L.LineUtil;for(i=0,k=0;i<len-1;i++){segment=lu.clipSegment(points[i],points[i+1],vp,i);if(!segment){continue}parts[k]=parts[k]||[];parts[k].push(segment[0]);if(segment[1]!==points[i+1]||i===len-2){parts[k].push(segment[1]);k++}}},_simplifyPoints:function(){var parts=this._parts,lu=L.LineUtil;for(var i=0,len=parts.length;i<len;i++){parts[i]=lu.simplify(parts[i],this.options.smoothFactor)}},_updatePath:function(){if(!this._map){return}this._clipPoints();this._simplifyPoints();L.Path.prototype._updatePath.call(this)}});L.polyline=function(latlngs,options){return new L.Polyline(latlngs,options)};L.PolyUtil={};L.PolyUtil.clipPolygon=function(points,bounds){var clippedPoints,edges=[1,4,2,8],i,j,k,a,b,len,edge,p,lu=L.LineUtil;for(i=0,len=points.length;i<len;i++){points[i]._code=lu._getBitCode(points[i],bounds)}for(k=0;k<4;k++){edge=edges[k];clippedPoints=[];for(i=0,len=points.length,j=len-1;i<len;j=i++){a=points[i];b=points[j];if(!(a._code&edge)){if(b._code&edge){p=lu._getEdgeIntersection(b,a,edge,bounds);p._code=lu._getBitCode(p,bounds);clippedPoints.push(p)}clippedPoints.push(a)}else if(!(b._code&edge)){p=lu._getEdgeIntersection(b,a,edge,bounds);p._code=lu._getBitCode(p,bounds);clippedPoints.push(p)}}points=clippedPoints}return points};L.Polygon=L.Polyline.extend({options:{fill:true},initialize:function(latlngs,options){L.Polyline.prototype.initialize.call(this,latlngs,options);this._initWithHoles(latlngs)},_initWithHoles:function(latlngs){var i,len,hole;if(latlngs&&L.Util.isArray(latlngs[0])&&typeof latlngs[0][0]!=="number"){this._latlngs=this._convertLatLngs(latlngs[0]);this._holes=latlngs.slice(1);for(i=0,len=this._holes.length;i<len;i++){hole=this._holes[i]=this._convertLatLngs(this._holes[i]);if(hole[0].equals(hole[hole.length-1])){hole.pop()}}}latlngs=this._latlngs;if(latlngs.length>=2&&latlngs[0].equals(latlngs[latlngs.length-1])){latlngs.pop()}},projectLatlngs:function(){L.Polyline.prototype.projectLatlngs.call(this);this._holePoints=[];if(!this._holes){return}var i,j,len,len2;for(i=0,len=this._holes.length;i<len;i++){this._holePoints[i]=[];for(j=0,len2=this._holes[i].length;j<len2;j++){this._holePoints[i][j]=this._map.latLngToLayerPoint(this._holes[i][j])}}},setLatLngs:function(latlngs){if(latlngs&&L.Util.isArray(latlngs[0])&&typeof latlngs[0][0]!=="number"){this._initWithHoles(latlngs);return this.redraw()}else{return L.Polyline.prototype.setLatLngs.call(this,latlngs)}},_clipPoints:function(){var points=this._originalPoints,newParts=[];this._parts=[points].concat(this._holePoints);if(this.options.noClip){return}for(var i=0,len=this._parts.length;i<len;i++){var clipped=L.PolyUtil.clipPolygon(this._parts[i],this._map._pathViewport);if(clipped.length){newParts.push(clipped)}}this._parts=newParts},_getPathPartStr:function(points){var str=L.Polyline.prototype._getPathPartStr.call(this,points);return str+(L.Browser.svg?"z":"x")}});L.polygon=function(latlngs,options){return new L.Polygon(latlngs,options)};(function(){function createMulti(Klass){return L.FeatureGroup.extend({initialize:function(latlngs,options){this._layers={};this._options=options;this.setLatLngs(latlngs)},setLatLngs:function(latlngs){var i=0,len=latlngs.length;this.eachLayer(function(layer){if(i<len){layer.setLatLngs(latlngs[i++])}else{this.removeLayer(layer)}},this);while(i<len){this.addLayer(new Klass(latlngs[i++],this._options))}return this},getLatLngs:function(){var latlngs=[];this.eachLayer(function(layer){latlngs.push(layer.getLatLngs())});return latlngs}})}L.MultiPolyline=createMulti(L.Polyline);L.MultiPolygon=createMulti(L.Polygon);L.multiPolyline=function(latlngs,options){return new L.MultiPolyline(latlngs,options)};L.multiPolygon=function(latlngs,options){return new L.MultiPolygon(latlngs,options);
}})();L.Rectangle=L.Polygon.extend({initialize:function(latLngBounds,options){L.Polygon.prototype.initialize.call(this,this._boundsToLatLngs(latLngBounds),options)},setBounds:function(latLngBounds){this.setLatLngs(this._boundsToLatLngs(latLngBounds))},_boundsToLatLngs:function(latLngBounds){latLngBounds=L.latLngBounds(latLngBounds);return[latLngBounds.getSouthWest(),latLngBounds.getNorthWest(),latLngBounds.getNorthEast(),latLngBounds.getSouthEast()]}});L.rectangle=function(latLngBounds,options){return new L.Rectangle(latLngBounds,options)};L.Circle=L.Path.extend({initialize:function(latlng,radius,options){L.Path.prototype.initialize.call(this,options);this._latlng=L.latLng(latlng);this._mRadius=radius},options:{fill:true},setLatLng:function(latlng){this._latlng=L.latLng(latlng);return this.redraw()},setRadius:function(radius){this._mRadius=radius;return this.redraw()},projectLatlngs:function(){var lngRadius=this._getLngRadius(),latlng=this._latlng,pointLeft=this._map.latLngToLayerPoint([latlng.lat,latlng.lng-lngRadius]);this._point=this._map.latLngToLayerPoint(latlng);this._radius=Math.max(this._point.x-pointLeft.x,1)},getBounds:function(){var lngRadius=this._getLngRadius(),latRadius=this._mRadius/40075017*360,latlng=this._latlng;return new L.LatLngBounds([latlng.lat-latRadius,latlng.lng-lngRadius],[latlng.lat+latRadius,latlng.lng+lngRadius])},getLatLng:function(){return this._latlng},getPathString:function(){var p=this._point,r=this._radius;if(this._checkIfEmpty()){return""}if(L.Browser.svg){return"M"+p.x+","+(p.y-r)+"A"+r+","+r+",0,1,1,"+(p.x-.1)+","+(p.y-r)+" z"}else{p._round();r=Math.round(r);return"AL "+p.x+","+p.y+" "+r+","+r+" 0,"+65535*360}},getRadius:function(){return this._mRadius},_getLatRadius:function(){return this._mRadius/40075017*360},_getLngRadius:function(){return this._getLatRadius()/Math.cos(L.LatLng.DEG_TO_RAD*this._latlng.lat)},_checkIfEmpty:function(){if(!this._map){return false}var vp=this._map._pathViewport,r=this._radius,p=this._point;return p.x-r>vp.max.x||p.y-r>vp.max.y||p.x+r<vp.min.x||p.y+r<vp.min.y}});L.circle=function(latlng,radius,options){return new L.Circle(latlng,radius,options)};L.CircleMarker=L.Circle.extend({options:{radius:10,weight:2},initialize:function(latlng,options){L.Circle.prototype.initialize.call(this,latlng,null,options);this._radius=this.options.radius},projectLatlngs:function(){this._point=this._map.latLngToLayerPoint(this._latlng)},_updateStyle:function(){L.Circle.prototype._updateStyle.call(this);this.setRadius(this.options.radius)},setLatLng:function(latlng){L.Circle.prototype.setLatLng.call(this,latlng);if(this._popup&&this._popup._isOpen){this._popup.setLatLng(latlng)}return this},setRadius:function(radius){this.options.radius=this._radius=radius;return this.redraw()},getRadius:function(){return this._radius}});L.circleMarker=function(latlng,options){return new L.CircleMarker(latlng,options)};L.Polyline.include(!L.Path.CANVAS?{}:{_containsPoint:function(p,closed){var i,j,k,len,len2,dist,part,w=this.options.weight/2;if(L.Browser.touch){w+=10}for(i=0,len=this._parts.length;i<len;i++){part=this._parts[i];for(j=0,len2=part.length,k=len2-1;j<len2;k=j++){if(!closed&&j===0){continue}dist=L.LineUtil.pointToSegmentDistance(p,part[k],part[j]);if(dist<=w){return true}}}return false}});L.Polygon.include(!L.Path.CANVAS?{}:{_containsPoint:function(p){var inside=false,part,p1,p2,i,j,k,len,len2;if(L.Polyline.prototype._containsPoint.call(this,p,true)){return true}for(i=0,len=this._parts.length;i<len;i++){part=this._parts[i];for(j=0,len2=part.length,k=len2-1;j<len2;k=j++){p1=part[j];p2=part[k];if(p1.y>p.y!==p2.y>p.y&&p.x<(p2.x-p1.x)*(p.y-p1.y)/(p2.y-p1.y)+p1.x){inside=!inside}}}return inside}});L.Circle.include(!L.Path.CANVAS?{}:{_drawPath:function(){var p=this._point;this._ctx.beginPath();this._ctx.arc(p.x,p.y,this._radius,0,Math.PI*2,false)},_containsPoint:function(p){var center=this._point,w2=this.options.stroke?this.options.weight/2:0;return p.distanceTo(center)<=this._radius+w2}});L.CircleMarker.include(!L.Path.CANVAS?{}:{_updateStyle:function(){L.Path.prototype._updateStyle.call(this)}});L.GeoJSON=L.FeatureGroup.extend({initialize:function(geojson,options){L.setOptions(this,options);this._layers={};if(geojson){this.addData(geojson)}},addData:function(geojson){var features=L.Util.isArray(geojson)?geojson:geojson.features,i,len,feature;if(features){for(i=0,len=features.length;i<len;i++){feature=features[i];if(feature.geometries||feature.geometry||feature.features||feature.coordinates){this.addData(features[i])}}return this}var options=this.options;if(options.filter&&!options.filter(geojson)){return}var layer=L.GeoJSON.geometryToLayer(geojson,options.pointToLayer,options.coordsToLatLng,options);layer.feature=L.GeoJSON.asFeature(geojson);layer.defaultOptions=layer.options;this.resetStyle(layer);if(options.onEachFeature){options.onEachFeature(geojson,layer)}return this.addLayer(layer)},resetStyle:function(layer){var style=this.options.style;if(style){L.Util.extend(layer.options,layer.defaultOptions);this._setLayerStyle(layer,style)}},setStyle:function(style){this.eachLayer(function(layer){this._setLayerStyle(layer,style)},this)},_setLayerStyle:function(layer,style){if(typeof style==="function"){style=style(layer.feature)}if(layer.setStyle){layer.setStyle(style)}}});L.extend(L.GeoJSON,{geometryToLayer:function(geojson,pointToLayer,coordsToLatLng,vectorOptions){var geometry=geojson.type==="Feature"?geojson.geometry:geojson,coords=geometry.coordinates,layers=[],latlng,latlngs,i,len;coordsToLatLng=coordsToLatLng||this.coordsToLatLng;switch(geometry.type){case"Point":latlng=coordsToLatLng(coords);return pointToLayer?pointToLayer(geojson,latlng):new L.Marker(latlng);case"MultiPoint":for(i=0,len=coords.length;i<len;i++){latlng=coordsToLatLng(coords[i]);layers.push(pointToLayer?pointToLayer(geojson,latlng):new L.Marker(latlng))}return new L.FeatureGroup(layers);case"LineString":latlngs=this.coordsToLatLngs(coords,0,coordsToLatLng);return new L.Polyline(latlngs,vectorOptions);case"Polygon":if(coords.length===2&&!coords[1].length){throw new Error("Invalid GeoJSON object.")}latlngs=this.coordsToLatLngs(coords,1,coordsToLatLng);return new L.Polygon(latlngs,vectorOptions);case"MultiLineString":latlngs=this.coordsToLatLngs(coords,1,coordsToLatLng);return new L.MultiPolyline(latlngs,vectorOptions);case"MultiPolygon":latlngs=this.coordsToLatLngs(coords,2,coordsToLatLng);return new L.MultiPolygon(latlngs,vectorOptions);case"GeometryCollection":for(i=0,len=geometry.geometries.length;i<len;i++){layers.push(this.geometryToLayer({geometry:geometry.geometries[i],type:"Feature",properties:geojson.properties},pointToLayer,coordsToLatLng,vectorOptions))}return new L.FeatureGroup(layers);default:throw new Error("Invalid GeoJSON object.")}},coordsToLatLng:function(coords){return new L.LatLng(coords[1],coords[0],coords[2])},coordsToLatLngs:function(coords,levelsDeep,coordsToLatLng){var latlng,i,len,latlngs=[];for(i=0,len=coords.length;i<len;i++){latlng=levelsDeep?this.coordsToLatLngs(coords[i],levelsDeep-1,coordsToLatLng):(coordsToLatLng||this.coordsToLatLng)(coords[i]);latlngs.push(latlng)}return latlngs},latLngToCoords:function(latlng){var coords=[latlng.lng,latlng.lat];if(latlng.alt!==undefined){coords.push(latlng.alt)}return coords},latLngsToCoords:function(latLngs){var coords=[];for(var i=0,len=latLngs.length;i<len;i++){coords.push(L.GeoJSON.latLngToCoords(latLngs[i]))}return coords},getFeature:function(layer,newGeometry){return layer.feature?L.extend({},layer.feature,{geometry:newGeometry}):L.GeoJSON.asFeature(newGeometry)},asFeature:function(geoJSON){if(geoJSON.type==="Feature"){return geoJSON}return{type:"Feature",properties:{},geometry:geoJSON}}});var PointToGeoJSON={toGeoJSON:function(){return L.GeoJSON.getFeature(this,{type:"Point",coordinates:L.GeoJSON.latLngToCoords(this.getLatLng())})}};L.Marker.include(PointToGeoJSON);L.Circle.include(PointToGeoJSON);L.CircleMarker.include(PointToGeoJSON);L.Polyline.include({toGeoJSON:function(){return L.GeoJSON.getFeature(this,{type:"LineString",coordinates:L.GeoJSON.latLngsToCoords(this.getLatLngs())})}});L.Polygon.include({toGeoJSON:function(){var coords=[L.GeoJSON.latLngsToCoords(this.getLatLngs())],i,len,hole;coords[0].push(coords[0][0]);if(this._holes){for(i=0,len=this._holes.length;i<len;i++){hole=L.GeoJSON.latLngsToCoords(this._holes[i]);hole.push(hole[0]);coords.push(hole)}}return L.GeoJSON.getFeature(this,{type:"Polygon",coordinates:coords})}});(function(){function multiToGeoJSON(type){return function(){var coords=[];this.eachLayer(function(layer){coords.push(layer.toGeoJSON().geometry.coordinates)});return L.GeoJSON.getFeature(this,{type:type,coordinates:coords})}}L.MultiPolyline.include({toGeoJSON:multiToGeoJSON("MultiLineString")});L.MultiPolygon.include({toGeoJSON:multiToGeoJSON("MultiPolygon")});L.LayerGroup.include({toGeoJSON:function(){var geometry=this.feature&&this.feature.geometry,jsons=[],json;if(geometry&&geometry.type==="MultiPoint"){return multiToGeoJSON("MultiPoint").call(this)}var isGeometryCollection=geometry&&geometry.type==="GeometryCollection";this.eachLayer(function(layer){if(layer.toGeoJSON){json=layer.toGeoJSON();jsons.push(isGeometryCollection?json.geometry:L.GeoJSON.asFeature(json))}});if(isGeometryCollection){return L.GeoJSON.getFeature(this,{geometries:jsons,type:"GeometryCollection"})}return{type:"FeatureCollection",features:jsons}}})})();L.geoJson=function(geojson,options){return new L.GeoJSON(geojson,options)};L.DomEvent={addListener:function(obj,type,fn,context){var id=L.stamp(fn),key="_leaflet_"+type+id,handler,originalHandler,newType;if(obj[key]){return this}handler=function(e){return fn.call(context||obj,e||L.DomEvent._getEvent())};if(L.Browser.pointer&&type.indexOf("touch")===0){return this.addPointerListener(obj,type,handler,id)}if(L.Browser.touch&&type==="dblclick"&&this.addDoubleTapListener){this.addDoubleTapListener(obj,handler,id)}if("addEventListener"in obj){if(type==="mousewheel"){obj.addEventListener("DOMMouseScroll",handler,false);obj.addEventListener(type,handler,false)}else if(type==="mouseenter"||type==="mouseleave"){originalHandler=handler;newType=type==="mouseenter"?"mouseover":"mouseout";handler=function(e){if(!L.DomEvent._checkMouse(obj,e)){return}return originalHandler(e)};obj.addEventListener(newType,handler,false)}else if(type==="click"&&L.Browser.android){originalHandler=handler;handler=function(e){return L.DomEvent._filterClick(e,originalHandler)};obj.addEventListener(type,handler,false)}else{obj.addEventListener(type,handler,false)}}else if("attachEvent"in obj){obj.attachEvent("on"+type,handler)}obj[key]=handler;return this},removeListener:function(obj,type,fn){var id=L.stamp(fn),key="_leaflet_"+type+id,handler=obj[key];if(!handler){return this}if(L.Browser.pointer&&type.indexOf("touch")===0){this.removePointerListener(obj,type,id)}else if(L.Browser.touch&&type==="dblclick"&&this.removeDoubleTapListener){this.removeDoubleTapListener(obj,id)}else if("removeEventListener"in obj){if(type==="mousewheel"){obj.removeEventListener("DOMMouseScroll",handler,false);obj.removeEventListener(type,handler,false)}else if(type==="mouseenter"||type==="mouseleave"){obj.removeEventListener(type==="mouseenter"?"mouseover":"mouseout",handler,false)}else{obj.removeEventListener(type,handler,false)}}else if("detachEvent"in obj){obj.detachEvent("on"+type,handler)}obj[key]=null;return this},stopPropagation:function(e){if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}L.DomEvent._skipped(e);return this},disableScrollPropagation:function(el){var stop=L.DomEvent.stopPropagation;return L.DomEvent.on(el,"mousewheel",stop).on(el,"MozMousePixelScroll",stop)},disableClickPropagation:function(el){var stop=L.DomEvent.stopPropagation;for(var i=L.Draggable.START.length-1;i>=0;i--){L.DomEvent.on(el,L.Draggable.START[i],stop)}return L.DomEvent.on(el,"click",L.DomEvent._fakeStop).on(el,"dblclick",stop)},preventDefault:function(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}return this},stop:function(e){return L.DomEvent.preventDefault(e).stopPropagation(e)},getMousePosition:function(e,container){if(!container){return new L.Point(e.clientX,e.clientY)}var rect=container.getBoundingClientRect();return new L.Point(e.clientX-rect.left-container.clientLeft,e.clientY-rect.top-container.clientTop)},getWheelDelta:function(e){var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120}if(e.detail){delta=-e.detail/3}return delta},_skipEvents:{},_fakeStop:function(e){L.DomEvent._skipEvents[e.type]=true},_skipped:function(e){var skipped=this._skipEvents[e.type];this._skipEvents[e.type]=false;return skipped},_checkMouse:function(el,e){var related=e.relatedTarget;if(!related){return true}try{while(related&&related!==el){related=related.parentNode}}catch(err){return false}return related!==el},_getEvent:function(){var e=window.event;if(!e){var caller=arguments.callee.caller;while(caller){e=caller["arguments"][0];if(e&&window.Event===e.constructor){break}caller=caller.caller}}return e},_filterClick:function(e,handler){var timeStamp=e.timeStamp||e.originalEvent.timeStamp,elapsed=L.DomEvent._lastClick&&timeStamp-L.DomEvent._lastClick;if(elapsed&&elapsed>100&&elapsed<500||e.target._simulatedClick&&!e._simulated){L.DomEvent.stop(e);return}L.DomEvent._lastClick=timeStamp;return handler(e)}};L.DomEvent.on=L.DomEvent.addListener;L.DomEvent.off=L.DomEvent.removeListener;L.Draggable=L.Class.extend({includes:L.Mixin.Events,statics:{START:L.Browser.touch?["touchstart","mousedown"]:["mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},initialize:function(element,dragStartTarget){this._element=element;this._dragStartTarget=dragStartTarget||element},enable:function(){if(this._enabled){return}for(var i=L.Draggable.START.length-1;i>=0;i--){L.DomEvent.on(this._dragStartTarget,L.Draggable.START[i],this._onDown,this)}this._enabled=true},disable:function(){if(!this._enabled){return}for(var i=L.Draggable.START.length-1;i>=0;i--){L.DomEvent.off(this._dragStartTarget,L.Draggable.START[i],this._onDown,this)}this._enabled=false;this._moved=false},_onDown:function(e){this._moved=false;if(e.shiftKey||e.which!==1&&e.button!==1&&!e.touches){return}L.DomEvent.stopPropagation(e);if(L.Draggable._disabled){return}L.DomUtil.disableImageDrag();L.DomUtil.disableTextSelection();if(this._moving){return}var first=e.touches?e.touches[0]:e;this._startPoint=new L.Point(first.clientX,first.clientY);this._startPos=this._newPos=L.DomUtil.getPosition(this._element);L.DomEvent.on(document,L.Draggable.MOVE[e.type],this._onMove,this).on(document,L.Draggable.END[e.type],this._onUp,this)},_onMove:function(e){if(e.touches&&e.touches.length>1){this._moved=true;return}var first=e.touches&&e.touches.length===1?e.touches[0]:e,newPoint=new L.Point(first.clientX,first.clientY),offset=newPoint.subtract(this._startPoint);if(!offset.x&&!offset.y){return}if(L.Browser.touch&&Math.abs(offset.x)+Math.abs(offset.y)<3){return}L.DomEvent.preventDefault(e);if(!this._moved){this.fire("dragstart");this._moved=true;this._startPos=L.DomUtil.getPosition(this._element).subtract(offset);L.DomUtil.addClass(document.body,"leaflet-dragging");this._lastTarget=e.target||e.srcElement;L.DomUtil.addClass(this._lastTarget,"leaflet-drag-target")}this._newPos=this._startPos.add(offset);this._moving=true;L.Util.cancelAnimFrame(this._animRequest);this._animRequest=L.Util.requestAnimFrame(this._updatePosition,this,true,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag");L.DomUtil.setPosition(this._element,this._newPos);this.fire("drag")},_onUp:function(){L.DomUtil.removeClass(document.body,"leaflet-dragging");if(this._lastTarget){L.DomUtil.removeClass(this._lastTarget,"leaflet-drag-target");this._lastTarget=null}for(var i in L.Draggable.MOVE){L.DomEvent.off(document,L.Draggable.MOVE[i],this._onMove).off(document,L.Draggable.END[i],this._onUp)}L.DomUtil.enableImageDrag();L.DomUtil.enableTextSelection();if(this._moved&&this._moving){L.Util.cancelAnimFrame(this._animRequest);this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})}this._moving=false}});L.Handler=L.Class.extend({initialize:function(map){this._map=map},enable:function(){if(this._enabled){return}this._enabled=true;this.addHooks()},disable:function(){if(!this._enabled){return}this._enabled=false;this.removeHooks()},enabled:function(){return!!this._enabled}});L.Map.mergeOptions({dragging:true,inertia:!L.Browser.android23,inertiaDeceleration:3400,inertiaMaxSpeed:Infinity,inertiaThreshold:L.Browser.touch?32:18,easeLinearity:.25,worldCopyJump:false});L.Map.Drag=L.Handler.extend({addHooks:function(){if(!this._draggable){var map=this._map;this._draggable=new L.Draggable(map._mapPane,map._container);this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this);if(map.options.worldCopyJump){this._draggable.on("predrag",this._onPreDrag,this);map.on("viewreset",this._onViewReset,this);map.whenReady(this._onViewReset,this)}}this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){var map=this._map;if(map._panAnim){map._panAnim.stop()}map.fire("movestart").fire("dragstart");if(map.options.inertia){this._positions=[];this._times=[]}},_onDrag:function(){if(this._map.options.inertia){var time=this._lastTime=+new Date,pos=this._lastPos=this._draggable._newPos;this._positions.push(pos);this._times.push(time);if(time-this._times[0]>200){this._positions.shift();this._times.shift()}}this._map.fire("move").fire("drag")},_onViewReset:function(){var pxCenter=this._map.getSize()._divideBy(2),pxWorldCenter=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=pxWorldCenter.subtract(pxCenter).x;this._worldWidth=this._map.project([0,180]).x},_onPreDrag:function(){var worldWidth=this._worldWidth,halfWidth=Math.round(worldWidth/2),dx=this._initialWorldOffset,x=this._draggable._newPos.x,newX1=(x-halfWidth+dx)%worldWidth+halfWidth-dx,newX2=(x+halfWidth+dx)%worldWidth-halfWidth-dx,newX=Math.abs(newX1+dx)<Math.abs(newX2+dx)?newX1:newX2;this._draggable._newPos.x=newX},_onDragEnd:function(e){var map=this._map,options=map.options,delay=+new Date-this._lastTime,noInertia=!options.inertia||delay>options.inertiaThreshold||!this._positions[0];map.fire("dragend",e);if(noInertia){map.fire("moveend")}else{var direction=this._lastPos.subtract(this._positions[0]),duration=(this._lastTime+delay-this._times[0])/1e3,ease=options.easeLinearity,speedVector=direction.multiplyBy(ease/duration),speed=speedVector.distanceTo([0,0]),limitedSpeed=Math.min(options.inertiaMaxSpeed,speed),limitedSpeedVector=speedVector.multiplyBy(limitedSpeed/speed),decelerationDuration=limitedSpeed/(options.inertiaDeceleration*ease),offset=limitedSpeedVector.multiplyBy(-decelerationDuration/2).round();if(!offset.x||!offset.y){map.fire("moveend")}else{offset=map._limitOffset(offset,map.options.maxBounds);L.Util.requestAnimFrame(function(){map.panBy(offset,{duration:decelerationDuration,easeLinearity:ease,noMoveStart:true})})}}}});L.Map.addInitHook("addHandler","dragging",L.Map.Drag);L.Map.mergeOptions({doubleClickZoom:true});L.Map.DoubleClickZoom=L.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(e){var map=this._map,zoom=map.getZoom()+(e.originalEvent.shiftKey?-1:1);if(map.options.doubleClickZoom==="center"){map.setZoom(zoom)}else{map.setZoomAround(e.containerPoint,zoom)}}});L.Map.addInitHook("addHandler","doubleClickZoom",L.Map.DoubleClickZoom);L.Map.mergeOptions({scrollWheelZoom:true});L.Map.ScrollWheelZoom=L.Handler.extend({addHooks:function(){L.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this);L.DomEvent.on(this._map._container,"MozMousePixelScroll",L.DomEvent.preventDefault);this._delta=0},removeHooks:function(){L.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll);L.DomEvent.off(this._map._container,"MozMousePixelScroll",L.DomEvent.preventDefault)},_onWheelScroll:function(e){var delta=L.DomEvent.getWheelDelta(e);this._delta+=delta;this._lastMousePos=this._map.mouseEventToContainerPoint(e);if(!this._startTime){this._startTime=+new Date}var left=Math.max(40-(+new Date-this._startTime),0);clearTimeout(this._timer);this._timer=setTimeout(L.bind(this._performZoom,this),left);L.DomEvent.preventDefault(e);L.DomEvent.stopPropagation(e)},_performZoom:function(){var map=this._map,delta=this._delta,zoom=map.getZoom();delta=delta>0?Math.ceil(delta):Math.floor(delta);delta=Math.max(Math.min(delta,4),-4);delta=map._limitZoom(zoom+delta)-zoom;this._delta=0;this._startTime=null;if(!delta){return}if(map.options.scrollWheelZoom==="center"){map.setZoom(zoom+delta)}else{map.setZoomAround(this._lastMousePos,zoom+delta)}}});L.Map.addInitHook("addHandler","scrollWheelZoom",L.Map.ScrollWheelZoom);L.extend(L.DomEvent,{_touchstart:L.Browser.msPointer?"MSPointerDown":L.Browser.pointer?"pointerdown":"touchstart",_touchend:L.Browser.msPointer?"MSPointerUp":L.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(obj,handler,id){var last,doubleTap=false,delay=250,touch,pre="_leaflet_",touchstart=this._touchstart,touchend=this._touchend,trackedTouches=[];function onTouchStart(e){var count;if(L.Browser.pointer){trackedTouches.push(e.pointerId);count=trackedTouches.length}else{count=e.touches.length}if(count>1){return}var now=Date.now(),delta=now-(last||now);touch=e.touches?e.touches[0]:e;doubleTap=delta>0&&delta<=delay;last=now}function onTouchEnd(e){if(L.Browser.pointer){var idx=trackedTouches.indexOf(e.pointerId);if(idx===-1){return}trackedTouches.splice(idx,1)}if(doubleTap){if(L.Browser.pointer){var newTouch={},prop;for(var i in touch){prop=touch[i];if(typeof prop==="function"){newTouch[i]=prop.bind(touch)}else{newTouch[i]=prop}}touch=newTouch}touch.type="dblclick";handler(touch);last=null}}obj[pre+touchstart+id]=onTouchStart;obj[pre+touchend+id]=onTouchEnd;var endElement=L.Browser.pointer?document.documentElement:obj;obj.addEventListener(touchstart,onTouchStart,false);endElement.addEventListener(touchend,onTouchEnd,false);if(L.Browser.pointer){endElement.addEventListener(L.DomEvent.POINTER_CANCEL,onTouchEnd,false)}return this},removeDoubleTapListener:function(obj,id){var pre="_leaflet_";obj.removeEventListener(this._touchstart,obj[pre+this._touchstart+id],false);(L.Browser.pointer?document.documentElement:obj).removeEventListener(this._touchend,obj[pre+this._touchend+id],false);if(L.Browser.pointer){document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL,obj[pre+this._touchend+id],false)}return this}});L.extend(L.DomEvent,{POINTER_DOWN:L.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:L.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:L.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:L.Browser.msPointer?"MSPointerCancel":"pointercancel",_pointers:[],_pointerDocumentListener:false,addPointerListener:function(obj,type,handler,id){switch(type){case"touchstart":return this.addPointerListenerStart(obj,type,handler,id);case"touchend":return this.addPointerListenerEnd(obj,type,handler,id);case"touchmove":return this.addPointerListenerMove(obj,type,handler,id);default:throw"Unknown touch event type"}},addPointerListenerStart:function(obj,type,handler,id){var pre="_leaflet_",pointers=this._pointers;var cb=function(e){L.DomEvent.preventDefault(e);var alreadyInArray=false;for(var i=0;i<pointers.length;i++){if(pointers[i].pointerId===e.pointerId){alreadyInArray=true;break}}if(!alreadyInArray){pointers.push(e)}e.touches=pointers.slice();e.changedTouches=[e];handler(e)};obj[pre+"touchstart"+id]=cb;obj.addEventListener(this.POINTER_DOWN,cb,false);if(!this._pointerDocumentListener){var internalCb=function(e){for(var i=0;i<pointers.length;i++){if(pointers[i].pointerId===e.pointerId){pointers.splice(i,1);break}}};document.documentElement.addEventListener(this.POINTER_UP,internalCb,false);document.documentElement.addEventListener(this.POINTER_CANCEL,internalCb,false);this._pointerDocumentListener=true}return this},addPointerListenerMove:function(obj,type,handler,id){var pre="_leaflet_",touches=this._pointers;function cb(e){if((e.pointerType===e.MSPOINTER_TYPE_MOUSE||e.pointerType==="mouse")&&e.buttons===0){return}for(var i=0;i<touches.length;i++){if(touches[i].pointerId===e.pointerId){touches[i]=e;break}}e.touches=touches.slice();e.changedTouches=[e];handler(e)}obj[pre+"touchmove"+id]=cb;obj.addEventListener(this.POINTER_MOVE,cb,false);return this},addPointerListenerEnd:function(obj,type,handler,id){var pre="_leaflet_",touches=this._pointers;var cb=function(e){for(var i=0;i<touches.length;i++){if(touches[i].pointerId===e.pointerId){touches.splice(i,1);break}}e.touches=touches.slice();e.changedTouches=[e];handler(e)};obj[pre+"touchend"+id]=cb;obj.addEventListener(this.POINTER_UP,cb,false);obj.addEventListener(this.POINTER_CANCEL,cb,false);return this},removePointerListener:function(obj,type,id){var pre="_leaflet_",cb=obj[pre+type+id];switch(type){case"touchstart":obj.removeEventListener(this.POINTER_DOWN,cb,false);break;case"touchmove":obj.removeEventListener(this.POINTER_MOVE,cb,false);break;case"touchend":obj.removeEventListener(this.POINTER_UP,cb,false);obj.removeEventListener(this.POINTER_CANCEL,cb,false);break}return this}});L.Map.mergeOptions({touchZoom:L.Browser.touch&&!L.Browser.android23,bounceAtZoomLimits:true});L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(e){var map=this._map;if(!e.touches||e.touches.length!==2||map._animatingZoom||this._zooming){return}var p1=map.mouseEventToLayerPoint(e.touches[0]),p2=map.mouseEventToLayerPoint(e.touches[1]),viewCenter=map._getCenterLayerPoint();this._startCenter=p1.add(p2)._divideBy(2);this._startDist=p1.distanceTo(p2);this._moved=false;this._zooming=true;this._centerOffset=viewCenter.subtract(this._startCenter);if(map._panAnim){map._panAnim.stop()}L.DomEvent.on(document,"touchmove",this._onTouchMove,this).on(document,"touchend",this._onTouchEnd,this);L.DomEvent.preventDefault(e)},_onTouchMove:function(e){var map=this._map;if(!e.touches||e.touches.length!==2||!this._zooming){return}var p1=map.mouseEventToLayerPoint(e.touches[0]),p2=map.mouseEventToLayerPoint(e.touches[1]);this._scale=p1.distanceTo(p2)/this._startDist;this._delta=p1._add(p2)._divideBy(2)._subtract(this._startCenter);if(this._scale===1){return}if(!map.options.bounceAtZoomLimits){if(map.getZoom()===map.getMinZoom()&&this._scale<1||map.getZoom()===map.getMaxZoom()&&this._scale>1){return}}if(!this._moved){L.DomUtil.addClass(map._mapPane,"leaflet-touching");map.fire("movestart").fire("zoomstart");this._moved=true}L.Util.cancelAnimFrame(this._animRequest);this._animRequest=L.Util.requestAnimFrame(this._updateOnMove,this,true,this._map._container);L.DomEvent.preventDefault(e)},_updateOnMove:function(){var map=this._map,origin=this._getScaleOrigin(),center=map.layerPointToLatLng(origin),zoom=map.getScaleZoom(this._scale);map._animateZoom(center,zoom,this._startCenter,this._scale,this._delta,false,true)},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=false;return}var map=this._map;this._zooming=false;L.DomUtil.removeClass(map._mapPane,"leaflet-touching");L.Util.cancelAnimFrame(this._animRequest);L.DomEvent.off(document,"touchmove",this._onTouchMove).off(document,"touchend",this._onTouchEnd);var origin=this._getScaleOrigin(),center=map.layerPointToLatLng(origin),oldZoom=map.getZoom(),floatZoomDelta=map.getScaleZoom(this._scale)-oldZoom,roundZoomDelta=floatZoomDelta>0?Math.ceil(floatZoomDelta):Math.floor(floatZoomDelta),zoom=map._limitZoom(oldZoom+roundZoomDelta),scale=map.getZoomScale(zoom)/this._scale;map._animateZoom(center,zoom,origin,scale)},_getScaleOrigin:function(){var centerOffset=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(centerOffset)}});L.Map.addInitHook("addHandler","touchZoom",L.Map.TouchZoom);L.Map.mergeOptions({tap:true,tapTolerance:15});L.Map.Tap=L.Handler.extend({addHooks:function(){L.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){L.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(e){if(!e.touches){return}L.DomEvent.preventDefault(e);this._fireClick=true;if(e.touches.length>1){this._fireClick=false;clearTimeout(this._holdTimeout);return}var first=e.touches[0],el=first.target;this._startPos=this._newPos=new L.Point(first.clientX,first.clientY);if(el.tagName&&el.tagName.toLowerCase()==="a"){L.DomUtil.addClass(el,"leaflet-active")}this._holdTimeout=setTimeout(L.bind(function(){if(this._isTapValid()){this._fireClick=false;this._onUp();this._simulateEvent("contextmenu",first)}},this),1e3);L.DomEvent.on(document,"touchmove",this._onMove,this).on(document,"touchend",this._onUp,this)},_onUp:function(e){clearTimeout(this._holdTimeout);L.DomEvent.off(document,"touchmove",this._onMove,this).off(document,"touchend",this._onUp,this);if(this._fireClick&&e&&e.changedTouches){var first=e.changedTouches[0],el=first.target;if(el&&el.tagName&&el.tagName.toLowerCase()==="a"){L.DomUtil.removeClass(el,"leaflet-active")}if(this._isTapValid()){this._simulateEvent("click",first)}}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(e){var first=e.touches[0];this._newPos=new L.Point(first.clientX,first.clientY)},_simulateEvent:function(type,e){var simulatedEvent=document.createEvent("MouseEvents");simulatedEvent._simulated=true;e.target._simulatedClick=true;simulatedEvent.initMouseEvent(type,true,true,window,1,e.screenX,e.screenY,e.clientX,e.clientY,false,false,false,false,0,null);e.target.dispatchEvent(simulatedEvent)}});if(L.Browser.touch&&!L.Browser.pointer){L.Map.addInitHook("addHandler","tap",L.Map.Tap)}L.Map.mergeOptions({boxZoom:true});L.Map.BoxZoom=L.Handler.extend({initialize:function(map){this._map=map;this._container=map._container;this._pane=map._panes.overlayPane;this._moved=false},addHooks:function(){L.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){L.DomEvent.off(this._container,"mousedown",this._onMouseDown);this._moved=false},moved:function(){return this._moved},_onMouseDown:function(e){this._moved=false;if(!e.shiftKey||e.which!==1&&e.button!==1){return false}L.DomUtil.disableTextSelection();L.DomUtil.disableImageDrag();this._startLayerPoint=this._map.mouseEventToLayerPoint(e);L.DomEvent.on(document,"mousemove",this._onMouseMove,this).on(document,"mouseup",this._onMouseUp,this).on(document,"keydown",this._onKeyDown,this)},_onMouseMove:function(e){if(!this._moved){this._box=L.DomUtil.create("div","leaflet-zoom-box",this._pane);L.DomUtil.setPosition(this._box,this._startLayerPoint);this._container.style.cursor="crosshair";this._map.fire("boxzoomstart")}var startPoint=this._startLayerPoint,box=this._box,layerPoint=this._map.mouseEventToLayerPoint(e),offset=layerPoint.subtract(startPoint),newPos=new L.Point(Math.min(layerPoint.x,startPoint.x),Math.min(layerPoint.y,startPoint.y));L.DomUtil.setPosition(box,newPos);this._moved=true;box.style.width=Math.max(0,Math.abs(offset.x)-4)+"px";box.style.height=Math.max(0,Math.abs(offset.y)-4)+"px"},_finish:function(){if(this._moved){this._pane.removeChild(this._box);this._container.style.cursor=""}L.DomUtil.enableTextSelection();L.DomUtil.enableImageDrag();L.DomEvent.off(document,"mousemove",this._onMouseMove).off(document,"mouseup",this._onMouseUp).off(document,"keydown",this._onKeyDown)},_onMouseUp:function(e){this._finish();var map=this._map,layerPoint=map.mouseEventToLayerPoint(e);
if(this._startLayerPoint.equals(layerPoint)){return}var bounds=new L.LatLngBounds(map.layerPointToLatLng(this._startLayerPoint),map.layerPointToLatLng(layerPoint));map.fitBounds(bounds);map.fire("boxzoomend",{boxZoomBounds:bounds})},_onKeyDown:function(e){if(e.keyCode===27){this._finish()}}});L.Map.addInitHook("addHandler","boxZoom",L.Map.BoxZoom);L.Map.mergeOptions({keyboard:true,keyboardPanOffset:80,keyboardZoomOffset:1});L.Map.Keyboard=L.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,173]},initialize:function(map){this._map=map;this._setPanOffset(map.options.keyboardPanOffset);this._setZoomOffset(map.options.keyboardZoomOffset)},addHooks:function(){var container=this._map._container;if(container.tabIndex===-1){container.tabIndex="0"}L.DomEvent.on(container,"focus",this._onFocus,this).on(container,"blur",this._onBlur,this).on(container,"mousedown",this._onMouseDown,this);this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var container=this._map._container;L.DomEvent.off(container,"focus",this._onFocus,this).off(container,"blur",this._onBlur,this).off(container,"mousedown",this._onMouseDown,this);this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){if(this._focused){return}var body=document.body,docEl=document.documentElement,top=body.scrollTop||docEl.scrollTop,left=body.scrollLeft||docEl.scrollLeft;this._map._container.focus();window.scrollTo(left,top)},_onFocus:function(){this._focused=true;this._map.fire("focus")},_onBlur:function(){this._focused=false;this._map.fire("blur")},_setPanOffset:function(pan){var keys=this._panKeys={},codes=this.keyCodes,i,len;for(i=0,len=codes.left.length;i<len;i++){keys[codes.left[i]]=[-1*pan,0]}for(i=0,len=codes.right.length;i<len;i++){keys[codes.right[i]]=[pan,0]}for(i=0,len=codes.down.length;i<len;i++){keys[codes.down[i]]=[0,pan]}for(i=0,len=codes.up.length;i<len;i++){keys[codes.up[i]]=[0,-1*pan]}},_setZoomOffset:function(zoom){var keys=this._zoomKeys={},codes=this.keyCodes,i,len;for(i=0,len=codes.zoomIn.length;i<len;i++){keys[codes.zoomIn[i]]=zoom}for(i=0,len=codes.zoomOut.length;i<len;i++){keys[codes.zoomOut[i]]=-zoom}},_addHooks:function(){L.DomEvent.on(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){L.DomEvent.off(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(e){var key=e.keyCode,map=this._map;if(key in this._panKeys){if(map._panAnim&&map._panAnim._inProgress){return}map.panBy(this._panKeys[key]);if(map.options.maxBounds){map.panInsideBounds(map.options.maxBounds)}}else if(key in this._zoomKeys){map.setZoom(map.getZoom()+this._zoomKeys[key])}else{return}L.DomEvent.stop(e)}});L.Map.addInitHook("addHandler","keyboard",L.Map.Keyboard);L.Handler.MarkerDrag=L.Handler.extend({initialize:function(marker){this._marker=marker},addHooks:function(){var icon=this._marker._icon;if(!this._draggable){this._draggable=new L.Draggable(icon,icon)}this._draggable.on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this);this._draggable.enable();L.DomUtil.addClass(this._marker._icon,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off("dragstart",this._onDragStart,this).off("drag",this._onDrag,this).off("dragend",this._onDragEnd,this);this._draggable.disable();L.DomUtil.removeClass(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(){var marker=this._marker,shadow=marker._shadow,iconPos=L.DomUtil.getPosition(marker._icon),latlng=marker._map.layerPointToLatLng(iconPos);if(shadow){L.DomUtil.setPosition(shadow,iconPos)}marker._latlng=latlng;marker.fire("move",{latlng:latlng}).fire("drag")},_onDragEnd:function(e){this._marker.fire("moveend").fire("dragend",e)}});L.Control=L.Class.extend({options:{position:"topright"},initialize:function(options){L.setOptions(this,options)},getPosition:function(){return this.options.position},setPosition:function(position){var map=this._map;if(map){map.removeControl(this)}this.options.position=position;if(map){map.addControl(this)}return this},getContainer:function(){return this._container},addTo:function(map){this._map=map;var container=this._container=this.onAdd(map),pos=this.getPosition(),corner=map._controlCorners[pos];L.DomUtil.addClass(container,"leaflet-control");if(pos.indexOf("bottom")!==-1){corner.insertBefore(container,corner.firstChild)}else{corner.appendChild(container)}return this},removeFrom:function(map){var pos=this.getPosition(),corner=map._controlCorners[pos];corner.removeChild(this._container);this._map=null;if(this.onRemove){this.onRemove(map)}return this},_refocusOnMap:function(){if(this._map){this._map.getContainer().focus()}}});L.control=function(options){return new L.Control(options)};L.Map.include({addControl:function(control){control.addTo(this);return this},removeControl:function(control){control.removeFrom(this);return this},_initControlPos:function(){var corners=this._controlCorners={},l="leaflet-",container=this._controlContainer=L.DomUtil.create("div",l+"control-container",this._container);function createCorner(vSide,hSide){var className=l+vSide+" "+l+hSide;corners[vSide+hSide]=L.DomUtil.create("div",className,container)}createCorner("top","left");createCorner("top","right");createCorner("bottom","left");createCorner("bottom","right")},_clearControlPos:function(){this._container.removeChild(this._controlContainer)}});L.Control.Zoom=L.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(map){var zoomName="leaflet-control-zoom",container=L.DomUtil.create("div",zoomName+" leaflet-bar");this._map=map;this._zoomInButton=this._createButton(this.options.zoomInText,this.options.zoomInTitle,zoomName+"-in",container,this._zoomIn,this);this._zoomOutButton=this._createButton(this.options.zoomOutText,this.options.zoomOutTitle,zoomName+"-out",container,this._zoomOut,this);this._updateDisabled();map.on("zoomend zoomlevelschange",this._updateDisabled,this);return container},onRemove:function(map){map.off("zoomend zoomlevelschange",this._updateDisabled,this)},_zoomIn:function(e){this._map.zoomIn(e.shiftKey?3:1)},_zoomOut:function(e){this._map.zoomOut(e.shiftKey?3:1)},_createButton:function(html,title,className,container,fn,context){var link=L.DomUtil.create("a",className,container);link.innerHTML=html;link.href="#";link.title=title;var stop=L.DomEvent.stopPropagation;L.DomEvent.on(link,"click",stop).on(link,"mousedown",stop).on(link,"dblclick",stop).on(link,"click",L.DomEvent.preventDefault).on(link,"click",fn,context).on(link,"click",this._refocusOnMap,context);return link},_updateDisabled:function(){var map=this._map,className="leaflet-disabled";L.DomUtil.removeClass(this._zoomInButton,className);L.DomUtil.removeClass(this._zoomOutButton,className);if(map._zoom===map.getMinZoom()){L.DomUtil.addClass(this._zoomOutButton,className)}if(map._zoom===map.getMaxZoom()){L.DomUtil.addClass(this._zoomInButton,className)}}});L.Map.mergeOptions({zoomControl:true});L.Map.addInitHook(function(){if(this.options.zoomControl){this.zoomControl=new L.Control.Zoom;this.addControl(this.zoomControl)}});L.control.zoom=function(options){return new L.Control.Zoom(options)};L.Control.Attribution=L.Control.extend({options:{position:"bottomright",prefix:'<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'},initialize:function(options){L.setOptions(this,options);this._attributions={}},onAdd:function(map){this._container=L.DomUtil.create("div","leaflet-control-attribution");L.DomEvent.disableClickPropagation(this._container);for(var i in map._layers){if(map._layers[i].getAttribution){this.addAttribution(map._layers[i].getAttribution())}}map.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this);this._update();return this._container},onRemove:function(map){map.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(prefix){this.options.prefix=prefix;this._update();return this},addAttribution:function(text){if(!text){return}if(!this._attributions[text]){this._attributions[text]=0}this._attributions[text]++;this._update();return this},removeAttribution:function(text){if(!text){return}if(this._attributions[text]){this._attributions[text]--;this._update()}return this},_update:function(){if(!this._map){return}var attribs=[];for(var i in this._attributions){if(this._attributions[i]){attribs.push(i)}}var prefixAndAttribs=[];if(this.options.prefix){prefixAndAttribs.push(this.options.prefix)}if(attribs.length){prefixAndAttribs.push(attribs.join(", "))}this._container.innerHTML=prefixAndAttribs.join(" | ")},_onLayerAdd:function(e){if(e.layer.getAttribution){this.addAttribution(e.layer.getAttribution())}},_onLayerRemove:function(e){if(e.layer.getAttribution){this.removeAttribution(e.layer.getAttribution())}}});L.Map.mergeOptions({attributionControl:true});L.Map.addInitHook(function(){if(this.options.attributionControl){this.attributionControl=(new L.Control.Attribution).addTo(this)}});L.control.attribution=function(options){return new L.Control.Attribution(options)};L.Control.Scale=L.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:true,imperial:true,updateWhenIdle:false},onAdd:function(map){this._map=map;var className="leaflet-control-scale",container=L.DomUtil.create("div",className),options=this.options;this._addScales(options,className,container);map.on(options.updateWhenIdle?"moveend":"move",this._update,this);map.whenReady(this._update,this);return container},onRemove:function(map){map.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(options,className,container){if(options.metric){this._mScale=L.DomUtil.create("div",className+"-line",container)}if(options.imperial){this._iScale=L.DomUtil.create("div",className+"-line",container)}},_update:function(){var bounds=this._map.getBounds(),centerLat=bounds.getCenter().lat,halfWorldMeters=6378137*Math.PI*Math.cos(centerLat*Math.PI/180),dist=halfWorldMeters*(bounds.getNorthEast().lng-bounds.getSouthWest().lng)/180,size=this._map.getSize(),options=this.options,maxMeters=0;if(size.x>0){maxMeters=dist*(options.maxWidth/size.x)}this._updateScales(options,maxMeters)},_updateScales:function(options,maxMeters){if(options.metric&&maxMeters){this._updateMetric(maxMeters)}if(options.imperial&&maxMeters){this._updateImperial(maxMeters)}},_updateMetric:function(maxMeters){var meters=this._getRoundNum(maxMeters);this._mScale.style.width=this._getScaleWidth(meters/maxMeters)+"px";this._mScale.innerHTML=meters<1e3?meters+" m":meters/1e3+" km"},_updateImperial:function(maxMeters){var maxFeet=maxMeters*3.2808399,scale=this._iScale,maxMiles,miles,feet;if(maxFeet>5280){maxMiles=maxFeet/5280;miles=this._getRoundNum(maxMiles);scale.style.width=this._getScaleWidth(miles/maxMiles)+"px";scale.innerHTML=miles+" mi"}else{feet=this._getRoundNum(maxFeet);scale.style.width=this._getScaleWidth(feet/maxFeet)+"px";scale.innerHTML=feet+" ft"}},_getScaleWidth:function(ratio){return Math.round(this.options.maxWidth*ratio)-10},_getRoundNum:function(num){var pow10=Math.pow(10,(Math.floor(num)+"").length-1),d=num/pow10;d=d>=10?10:d>=5?5:d>=3?3:d>=2?2:1;return pow10*d}});L.control.scale=function(options){return new L.Control.Scale(options)};L.Control.Layers=L.Control.extend({options:{collapsed:true,position:"topright",autoZIndex:true},initialize:function(baseLayers,overlays,options){L.setOptions(this,options);this._layers={};this._lastZIndex=0;this._handlingClick=false;for(var i in baseLayers){this._addLayer(baseLayers[i],i)}for(i in overlays){this._addLayer(overlays[i],i,true)}},onAdd:function(map){this._initLayout();this._update();map.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this);return this._container},onRemove:function(map){map.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(layer,name){this._addLayer(layer,name);this._update();return this},addOverlay:function(layer,name){this._addLayer(layer,name,true);this._update();return this},removeLayer:function(layer){var id=L.stamp(layer);delete this._layers[id];this._update();return this},_initLayout:function(){var className="leaflet-control-layers",container=this._container=L.DomUtil.create("div",className);container.setAttribute("aria-haspopup",true);if(!L.Browser.touch){L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container)}else{L.DomEvent.on(container,"click",L.DomEvent.stopPropagation)}var form=this._form=L.DomUtil.create("form",className+"-list");if(this.options.collapsed){if(!L.Browser.android){L.DomEvent.on(container,"mouseover",this._expand,this).on(container,"mouseout",this._collapse,this)}var link=this._layersLink=L.DomUtil.create("a",className+"-toggle",container);link.href="#";link.title="Layers";if(L.Browser.touch){L.DomEvent.on(link,"click",L.DomEvent.stop).on(link,"click",this._expand,this)}else{L.DomEvent.on(link,"focus",this._expand,this)}L.DomEvent.on(form,"click",function(){setTimeout(L.bind(this._onInputClick,this),0)},this);this._map.on("click",this._collapse,this)}else{this._expand()}this._baseLayersList=L.DomUtil.create("div",className+"-base",form);this._separator=L.DomUtil.create("div",className+"-separator",form);this._overlaysList=L.DomUtil.create("div",className+"-overlays",form);container.appendChild(form)},_addLayer:function(layer,name,overlay){var id=L.stamp(layer);this._layers[id]={layer:layer,name:name,overlay:overlay};if(this.options.autoZIndex&&layer.setZIndex){this._lastZIndex++;layer.setZIndex(this._lastZIndex)}},_update:function(){if(!this._container){return}this._baseLayersList.innerHTML="";this._overlaysList.innerHTML="";var baseLayersPresent=false,overlaysPresent=false,i,obj;for(i in this._layers){obj=this._layers[i];this._addItem(obj);overlaysPresent=overlaysPresent||obj.overlay;baseLayersPresent=baseLayersPresent||!obj.overlay}this._separator.style.display=overlaysPresent&&baseLayersPresent?"":"none"},_onLayerChange:function(e){var obj=this._layers[L.stamp(e.layer)];if(!obj){return}if(!this._handlingClick){this._update()}var type=obj.overlay?e.type==="layeradd"?"overlayadd":"overlayremove":e.type==="layeradd"?"baselayerchange":null;if(type){this._map.fire(type,obj)}},_createRadioElement:function(name,checked){var radioHtml='<input type="radio" class="leaflet-control-layers-selector" name="'+name+'"';if(checked){radioHtml+=' checked="checked"'}radioHtml+="/>";var radioFragment=document.createElement("div");radioFragment.innerHTML=radioHtml;return radioFragment.firstChild},_addItem:function(obj){var label=document.createElement("label"),input,checked=this._map.hasLayer(obj.layer);if(obj.overlay){input=document.createElement("input");input.type="checkbox";input.className="leaflet-control-layers-selector";input.defaultChecked=checked}else{input=this._createRadioElement("leaflet-base-layers",checked)}input.layerId=L.stamp(obj.layer);L.DomEvent.on(input,"click",this._onInputClick,this);var name=document.createElement("span");name.innerHTML=" "+obj.name;label.appendChild(input);label.appendChild(name);var container=obj.overlay?this._overlaysList:this._baseLayersList;container.appendChild(label);return label},_onInputClick:function(){var i,input,obj,inputs=this._form.getElementsByTagName("input"),inputsLen=inputs.length;this._handlingClick=true;for(i=0;i<inputsLen;i++){input=inputs[i];obj=this._layers[input.layerId];if(input.checked&&!this._map.hasLayer(obj.layer)){this._map.addLayer(obj.layer)}else if(!input.checked&&this._map.hasLayer(obj.layer)){this._map.removeLayer(obj.layer)}}this._handlingClick=false;this._refocusOnMap()},_expand:function(){L.DomUtil.addClass(this._container,"leaflet-control-layers-expanded")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-layers-expanded","")}});L.control.layers=function(baseLayers,overlays,options){return new L.Control.Layers(baseLayers,overlays,options)};L.PosAnimation=L.Class.extend({includes:L.Mixin.Events,run:function(el,newPos,duration,easeLinearity){this.stop();this._el=el;this._inProgress=true;this._newPos=newPos;this.fire("start");el.style[L.DomUtil.TRANSITION]="all "+(duration||.25)+"s cubic-bezier(0,0,"+(easeLinearity||.5)+",1)";L.DomEvent.on(el,L.DomUtil.TRANSITION_END,this._onTransitionEnd,this);L.DomUtil.setPosition(el,newPos);L.Util.falseFn(el.offsetWidth);this._stepTimer=setInterval(L.bind(this._onStep,this),50)},stop:function(){if(!this._inProgress){return}L.DomUtil.setPosition(this._el,this._getPos());this._onTransitionEnd();L.Util.falseFn(this._el.offsetWidth)},_onStep:function(){var stepPos=this._getPos();if(!stepPos){this._onTransitionEnd();return}this._el._leaflet_pos=stepPos;this.fire("step")},_transformRe:/([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,_getPos:function(){var left,top,matches,el=this._el,style=window.getComputedStyle(el);if(L.Browser.any3d){matches=style[L.DomUtil.TRANSFORM].match(this._transformRe);if(!matches){return}left=parseFloat(matches[1]);top=parseFloat(matches[2])}else{left=parseFloat(style.left);top=parseFloat(style.top)}return new L.Point(left,top,true)},_onTransitionEnd:function(){L.DomEvent.off(this._el,L.DomUtil.TRANSITION_END,this._onTransitionEnd,this);if(!this._inProgress){return}this._inProgress=false;this._el.style[L.DomUtil.TRANSITION]="";this._el._leaflet_pos=this._newPos;clearInterval(this._stepTimer);this.fire("step").fire("end")}});L.Map.include({setView:function(center,zoom,options){zoom=zoom===undefined?this._zoom:this._limitZoom(zoom);center=this._limitCenter(L.latLng(center),zoom,this.options.maxBounds);options=options||{};if(this._panAnim){this._panAnim.stop()}if(this._loaded&&!options.reset&&options!==true){if(options.animate!==undefined){options.zoom=L.extend({animate:options.animate},options.zoom);options.pan=L.extend({animate:options.animate},options.pan)}var animated=this._zoom!==zoom?this._tryAnimatedZoom&&this._tryAnimatedZoom(center,zoom,options.zoom):this._tryAnimatedPan(center,options.pan);if(animated){clearTimeout(this._sizeTimer);return this}}this._resetView(center,zoom);return this},panBy:function(offset,options){offset=L.point(offset).round();options=options||{};if(!offset.x&&!offset.y){return this}if(!this._panAnim){this._panAnim=new L.PosAnimation;this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)}if(!options.noMoveStart){this.fire("movestart")}if(options.animate!==false){L.DomUtil.addClass(this._mapPane,"leaflet-pan-anim");var newPos=this._getMapPanePos().subtract(offset);this._panAnim.run(this._mapPane,newPos,options.duration||.25,options.easeLinearity)}else{this._rawPanBy(offset);this.fire("move").fire("moveend")}return this},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){L.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim");this.fire("moveend")},_tryAnimatedPan:function(center,options){var offset=this._getCenterOffset(center)._floor();if((options&&options.animate)!==true&&!this.getSize().contains(offset)){return false}this.panBy(offset,options);return true}});L.PosAnimation=L.DomUtil.TRANSITION?L.PosAnimation:L.PosAnimation.extend({run:function(el,newPos,duration,easeLinearity){this.stop();this._el=el;this._inProgress=true;this._duration=duration||.25;this._easeOutPower=1/Math.max(easeLinearity||.5,.2);this._startPos=L.DomUtil.getPosition(el);this._offset=newPos.subtract(this._startPos);this._startTime=+new Date;this.fire("start");this._animate()},stop:function(){if(!this._inProgress){return}this._step();this._complete()},_animate:function(){this._animId=L.Util.requestAnimFrame(this._animate,this);this._step()},_step:function(){var elapsed=+new Date-this._startTime,duration=this._duration*1e3;if(elapsed<duration){this._runFrame(this._easeOut(elapsed/duration))}else{this._runFrame(1);this._complete()}},_runFrame:function(progress){var pos=this._startPos.add(this._offset.multiplyBy(progress));L.DomUtil.setPosition(this._el,pos);this.fire("step")},_complete:function(){L.Util.cancelAnimFrame(this._animId);this._inProgress=false;this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}});L.Map.mergeOptions({zoomAnimation:true,zoomAnimationThreshold:4});if(L.DomUtil.TRANSITION){L.Map.addInitHook(function(){this._zoomAnimated=this.options.zoomAnimation&&L.DomUtil.TRANSITION&&L.Browser.any3d&&!L.Browser.android23&&!L.Browser.mobileOpera;if(this._zoomAnimated){L.DomEvent.on(this._mapPane,L.DomUtil.TRANSITION_END,this._catchTransitionEnd,this)}})}L.Map.include(!L.DomUtil.TRANSITION?{}:{_catchTransitionEnd:function(e){if(this._animatingZoom&&e.propertyName.indexOf("transform")>=0){this._onZoomTransitionEnd()}},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(center,zoom,options){if(this._animatingZoom){return true}options=options||{};if(!this._zoomAnimated||options.animate===false||this._nothingToAnimate()||Math.abs(zoom-this._zoom)>this.options.zoomAnimationThreshold){return false}var scale=this.getZoomScale(zoom),offset=this._getCenterOffset(center)._divideBy(1-1/scale),origin=this._getCenterLayerPoint()._add(offset);if(options.animate!==true&&!this.getSize().contains(offset)){return false}this.fire("movestart").fire("zoomstart");this._animateZoom(center,zoom,origin,scale,null,true);return true},_animateZoom:function(center,zoom,origin,scale,delta,backwards,forTouchZoom){if(!forTouchZoom){this._animatingZoom=true}L.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim");this._animateToCenter=center;this._animateToZoom=zoom;if(L.Draggable){L.Draggable._disabled=true}L.Util.requestAnimFrame(function(){this.fire("zoomanim",{center:center,zoom:zoom,origin:origin,scale:scale,delta:delta,backwards:backwards})},this)},_onZoomTransitionEnd:function(){this._animatingZoom=false;L.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim");this._resetView(this._animateToCenter,this._animateToZoom,true,true);if(L.Draggable){L.Draggable._disabled=false}}});L.TileLayer.include({_animateZoom:function(e){if(!this._animating){this._animating=true;this._prepareBgBuffer()}var bg=this._bgBuffer,transform=L.DomUtil.TRANSFORM,initialTransform=e.delta?L.DomUtil.getTranslateString(e.delta):bg.style[transform],scaleStr=L.DomUtil.getScaleString(e.scale,e.origin);bg.style[transform]=e.backwards?scaleStr+" "+initialTransform:initialTransform+" "+scaleStr},_endZoomAnim:function(){var front=this._tileContainer,bg=this._bgBuffer;front.style.visibility="";front.parentNode.appendChild(front);L.Util.falseFn(bg.offsetWidth);this._animating=false},_clearBgBuffer:function(){var map=this._map;if(map&&!map._animatingZoom&&!map.touchZoom._zooming){this._bgBuffer.innerHTML="";this._bgBuffer.style[L.DomUtil.TRANSFORM]=""}},_prepareBgBuffer:function(){var front=this._tileContainer,bg=this._bgBuffer;var bgLoaded=this._getLoadedTilesPercentage(bg),frontLoaded=this._getLoadedTilesPercentage(front);if(bg&&bgLoaded>.5&&frontLoaded<.5){front.style.visibility="hidden";this._stopLoadingImages(front);return}bg.style.visibility="hidden";bg.style[L.DomUtil.TRANSFORM]="";this._tileContainer=bg;bg=this._bgBuffer=front;this._stopLoadingImages(bg);clearTimeout(this._clearBgBufferTimer)},_getLoadedTilesPercentage:function(container){var tiles=container.getElementsByTagName("img"),i,len,count=0;for(i=0,len=tiles.length;i<len;i++){if(tiles[i].complete){count++}}return count/len},_stopLoadingImages:function(container){var tiles=Array.prototype.slice.call(container.getElementsByTagName("img")),i,len,tile;for(i=0,len=tiles.length;i<len;i++){tile=tiles[i];if(!tile.complete){tile.onload=L.Util.falseFn;tile.onerror=L.Util.falseFn;tile.src=L.Util.emptyImageUrl;tile.parentNode.removeChild(tile)}}}});L.Map.include({_defaultLocateOptions:{watch:false,setView:false,maxZoom:Infinity,timeout:1e4,maximumAge:0,enableHighAccuracy:false},locate:function(options){options=this._locateOptions=L.extend(this._defaultLocateOptions,options);if(!navigator.geolocation){this._handleGeolocationError({code:0,message:"Geolocation not supported."});return this}var onResponse=L.bind(this._handleGeolocationResponse,this),onError=L.bind(this._handleGeolocationError,this);if(options.watch){this._locationWatchId=navigator.geolocation.watchPosition(onResponse,onError,options)}else{navigator.geolocation.getCurrentPosition(onResponse,onError,options)}return this},stopLocate:function(){if(navigator.geolocation){navigator.geolocation.clearWatch(this._locationWatchId)}if(this._locateOptions){this._locateOptions.setView=false}return this},_handleGeolocationError:function(error){var c=error.code,message=error.message||(c===1?"permission denied":c===2?"position unavailable":"timeout");if(this._locateOptions.setView&&!this._loaded){this.fitWorld()}this.fire("locationerror",{code:c,message:"Geolocation error: "+message+"."})},_handleGeolocationResponse:function(pos){var lat=pos.coords.latitude,lng=pos.coords.longitude,latlng=new L.LatLng(lat,lng),latAccuracy=180*pos.coords.accuracy/40075017,lngAccuracy=latAccuracy/Math.cos(L.LatLng.DEG_TO_RAD*lat),bounds=L.latLngBounds([lat-latAccuracy,lng-lngAccuracy],[lat+latAccuracy,lng+lngAccuracy]),options=this._locateOptions;if(options.setView){var zoom=Math.min(this.getBoundsZoom(bounds),options.maxZoom);this.setView(latlng,zoom)}var data={latlng:latlng,bounds:bounds,timestamp:pos.timestamp};for(var i in pos.coords){if(typeof pos.coords[i]==="number"){data[i]=pos.coords[i]}}this.fire("locationfound",data)}})})(window,document)},{}],3:[function(require,module,exports){(function(root,factory){if(typeof exports==="object"&&exports){factory(exports)}else{var mustache={};factory(mustache);if(typeof define==="function"&&define.amd){define(mustache)}else{root.Mustache=mustache}}})(this,function(mustache){var whiteRe=/\s*/;var spaceRe=/\s+/;var nonSpaceRe=/\S/;var eqRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;var RegExp_test=RegExp.prototype.test;function testRegExp(re,string){return RegExp_test.call(re,string)}function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var Object_toString=Object.prototype.toString;var isArray=Array.isArray||function(object){return Object_toString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var entityMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function escapeHtml(string){return String(string).replace(/[&<>"'\/]/g,function(s){return entityMap[s]})}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function(){return this.tail===""};Scanner.prototype.scan=function(re){var match=this.tail.match(re);if(match&&match.index===0){var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string}return""};Scanner.prototype.scanUntil=function(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parent){this.view=view==null?{}:view;this.parent=parent;this._cache={".":this.view}}Context.make=function(view){return view instanceof Context?view:new Context(view)};Context.prototype.push=function(view){return new Context(view,this)};Context.prototype.lookup=function(name){var value;if(name in this._cache){value=this._cache[name]}else{var context=this;while(context){if(name.indexOf(".")>0){value=context.view;var names=name.split("."),i=0;while(value!=null&&i<names.length){value=value[names[i++]]}}else{value=context.view[name]}if(value!=null)break;context=context.parent}this._cache[name]=value}if(isFunction(value)){value=value.call(this.view)}return value};function Writer(){this.clearCache()}Writer.prototype.clearCache=function(){this._cache={};this._partialCache={}};Writer.prototype.compile=function(template,tags){var fn=this._cache[template];if(!fn){var tokens=mustache.parse(template,tags);fn=this._cache[template]=this.compileTokens(tokens,template)}return fn};Writer.prototype.compilePartial=function(name,template,tags){var fn=this.compile(template,tags);this._partialCache[name]=fn;return fn};Writer.prototype.getPartial=function(name){if(!(name in this._partialCache)&&this._loadPartial){this.compilePartial(name,this._loadPartial(name))}return this._partialCache[name]};Writer.prototype.compileTokens=function(tokens,template){var self=this;return function(view,partials){if(partials){if(isFunction(partials)){self._loadPartial=partials}else{for(var name in partials){self.compilePartial(name,partials[name])}}}return renderTokens(tokens,self,Context.make(view),template)}};Writer.prototype.render=function(template,view,partials){return this.compile(template)(view,partials)};function renderTokens(tokens,writer,context,template){var buffer="";function subRender(template){return writer.render(template,context)}var token,tokenValue,value;for(var i=0,len=tokens.length;i<len;++i){token=tokens[i];tokenValue=token[1];switch(token[0]){case"#":value=context.lookup(tokenValue);if(typeof value==="object"||typeof value==="string"){if(isArray(value)){for(var j=0,jlen=value.length;j<jlen;++j){buffer+=renderTokens(token[4],writer,context.push(value[j]),template)}}else if(value){buffer+=renderTokens(token[4],writer,context.push(value),template)}}else if(isFunction(value)){var text=template==null?null:template.slice(token[3],token[5]);value=value.call(context.view,text,subRender);if(value!=null)buffer+=value}else if(value){buffer+=renderTokens(token[4],writer,context,template)}break;case"^":value=context.lookup(tokenValue);if(!value||isArray(value)&&value.length===0){buffer+=renderTokens(token[4],writer,context,template)}break;case">":value=writer.getPartial(tokenValue);if(isFunction(value))buffer+=value(context);break;case"&":value=context.lookup(tokenValue);if(value!=null)buffer+=value;break;case"name":value=context.lookup(tokenValue);if(value!=null)buffer+=mustache.escape(value);break;case"text":buffer+=tokenValue;break}}return buffer}function nestTokens(tokens){var tree=[];var collector=tree;var sections=[];var token;for(var i=0,len=tokens.length;i<len;++i){token=tokens[i];switch(token[0]){case"#":case"^":sections.push(token);collector.push(token);collector=token[4]=[];break;case"/":var section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:tree;break;default:collector.push(token)}}return tree}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,len=tokens.length;i<len;++i){token=tokens[i];if(token){if(token[0]==="text"&&lastToken&&lastToken[0]==="text"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{lastToken=token;squashedTokens.push(token)}}}return squashedTokens}function escapeTags(tags){return[new RegExp(escapeRegExp(tags[0])+"\\s*"),new RegExp("\\s*"+escapeRegExp(tags[1]))]}function parseTemplate(template,tags){template=template||"";tags=tags||mustache.tags;if(typeof tags==="string")tags=tags.split(spaceRe);if(tags.length!==2)throw new Error("Invalid tags: "+tags.join(", "));var tagRes=escapeTags(tags);var scanner=new Scanner(template);var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length){delete tokens[spaces.pop()]}}else{spaces=[]}hasTag=false;nonSpace=false}var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(tagRes[0]);if(value){for(var i=0,len=value.length;i<len;++i){chr=value.charAt(i);if(isWhitespace(chr)){
spaces.push(tokens.length)}else{nonSpace=true}tokens.push(["text",chr,start,start+1]);start+=1;if(chr=="\n")stripSpace()}}if(!scanner.scan(tagRes[0]))break;hasTag=true;type=scanner.scan(tagRe)||"name";scanner.scan(whiteRe);if(type==="="){value=scanner.scanUntil(eqRe);scanner.scan(eqRe);scanner.scanUntil(tagRes[1])}else if(type==="{"){value=scanner.scanUntil(new RegExp("\\s*"+escapeRegExp("}"+tags[1])));scanner.scan(curlyRe);scanner.scanUntil(tagRes[1]);type="&"}else{value=scanner.scanUntil(tagRes[1])}if(!scanner.scan(tagRes[1]))throw new Error("Unclosed tag at "+scanner.pos);token=[type,value,start,scanner.pos];tokens.push(token);if(type==="#"||type==="^"){sections.push(token)}else if(type==="/"){openSection=sections.pop();if(!openSection){throw new Error('Unopened section "'+value+'" at '+start)}if(openSection[1]!==value){throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}}else if(type==="name"||type==="{"||type==="&"){nonSpace=true}else if(type==="="){tags=value.split(spaceRe);if(tags.length!==2){throw new Error("Invalid tags at "+start+": "+tags.join(", "))}tagRes=escapeTags(tags)}}openSection=sections.pop();if(openSection){throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos)}return nestTokens(squashTokens(tokens))}mustache.name="mustache.js";mustache.version="0.7.3";mustache.tags=["{{","}}"];mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer;mustache.parse=parseTemplate;mustache.escape=escapeHtml;var defaultWriter=new Writer;mustache.clearCache=function(){return defaultWriter.clearCache()};mustache.compile=function(template,tags){return defaultWriter.compile(template,tags)};mustache.compilePartial=function(name,template,tags){return defaultWriter.compilePartial(name,template,tags)};mustache.compileTokens=function(tokens,template){return defaultWriter.compileTokens(tokens,template)};mustache.render=function(template,view,partials){return defaultWriter.render(template,view,partials)};mustache.to_html=function(template,view,partials,send){var result=mustache.render(template,view,partials);if(isFunction(send)){send(result)}else{return result}}})},{}],4:[function(require,module,exports){var html_sanitize=require("./sanitizer-bundle.js");module.exports=function(_){if(!_)return"";return html_sanitize(_,cleanUrl,cleanId)};function cleanUrl(url){"use strict";if(/^https?/.test(url.getScheme()))return url.toString();if(/^mailto?/.test(url.getScheme()))return url.toString();if("data"==url.getScheme()&&/^image/.test(url.getPath())){return url.toString()}}function cleanId(id){return id}},{"./sanitizer-bundle.js":5}],5:[function(require,module,exports){var URI=function(){function parse(uriStr){var m=(""+uriStr).match(URI_RE_);if(!m){return null}return new URI(nullIfAbsent(m[1]),nullIfAbsent(m[2]),nullIfAbsent(m[3]),nullIfAbsent(m[4]),nullIfAbsent(m[5]),nullIfAbsent(m[6]),nullIfAbsent(m[7]))}function create(scheme,credentials,domain,port,path,query,fragment){var uri=new URI(encodeIfExists2(scheme,URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),encodeIfExists2(credentials,URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),encodeIfExists(domain),port>0?port.toString():null,encodeIfExists2(path,URI_DISALLOWED_IN_PATH_),null,encodeIfExists(fragment));if(query){if("string"===typeof query){uri.setRawQuery(query.replace(/[^?&=0-9A-Za-z_\-~.%]/g,encodeOne))}else{uri.setAllParameters(query)}}return uri}function encodeIfExists(unescapedPart){if("string"==typeof unescapedPart){return encodeURIComponent(unescapedPart)}return null}function encodeIfExists2(unescapedPart,extra){if("string"==typeof unescapedPart){return encodeURI(unescapedPart).replace(extra,encodeOne)}return null}function encodeOne(ch){var n=ch.charCodeAt(0);return"%"+"0123456789ABCDEF".charAt(n>>4&15)+"0123456789ABCDEF".charAt(n&15)}function normPath(path){return path.replace(/(^|\/)\.(?:\/|$)/g,"$1").replace(/\/{2,}/g,"/")}var PARENT_DIRECTORY_HANDLER=new RegExp(""+"(/|^)"+"(?:[^./][^/]*|\\.{2,}(?:[^./][^/]*)|\\.{3,}[^/]*)"+"/\\.\\.(?:/|$)");var PARENT_DIRECTORY_HANDLER_RE=new RegExp(PARENT_DIRECTORY_HANDLER);var EXTRA_PARENT_PATHS_RE=/^(?:\.\.\/)*(?:\.\.$)?/;function collapse_dots(path){if(path===null){return null}var p=normPath(path);var r=PARENT_DIRECTORY_HANDLER_RE;for(var q;(q=p.replace(r,"$1"))!=p;p=q){}return p}function resolve(baseUri,relativeUri){var absoluteUri=baseUri.clone();var overridden=relativeUri.hasScheme();if(overridden){absoluteUri.setRawScheme(relativeUri.getRawScheme())}else{overridden=relativeUri.hasCredentials()}if(overridden){absoluteUri.setRawCredentials(relativeUri.getRawCredentials())}else{overridden=relativeUri.hasDomain()}if(overridden){absoluteUri.setRawDomain(relativeUri.getRawDomain())}else{overridden=relativeUri.hasPort()}var rawPath=relativeUri.getRawPath();var simplifiedPath=collapse_dots(rawPath);if(overridden){absoluteUri.setPort(relativeUri.getPort());simplifiedPath=simplifiedPath&&simplifiedPath.replace(EXTRA_PARENT_PATHS_RE,"")}else{overridden=!!rawPath;if(overridden){if(simplifiedPath.charCodeAt(0)!==47){var absRawPath=collapse_dots(absoluteUri.getRawPath()||"").replace(EXTRA_PARENT_PATHS_RE,"");var slash=absRawPath.lastIndexOf("/")+1;simplifiedPath=collapse_dots((slash?absRawPath.substring(0,slash):"")+collapse_dots(rawPath)).replace(EXTRA_PARENT_PATHS_RE,"")}}else{simplifiedPath=simplifiedPath&&simplifiedPath.replace(EXTRA_PARENT_PATHS_RE,"");if(simplifiedPath!==rawPath){absoluteUri.setRawPath(simplifiedPath)}}}if(overridden){absoluteUri.setRawPath(simplifiedPath)}else{overridden=relativeUri.hasQuery()}if(overridden){absoluteUri.setRawQuery(relativeUri.getRawQuery())}else{overridden=relativeUri.hasFragment()}if(overridden){absoluteUri.setRawFragment(relativeUri.getRawFragment())}return absoluteUri}function URI(rawScheme,rawCredentials,rawDomain,port,rawPath,rawQuery,rawFragment){this.scheme_=rawScheme;this.credentials_=rawCredentials;this.domain_=rawDomain;this.port_=port;this.path_=rawPath;this.query_=rawQuery;this.fragment_=rawFragment;this.paramCache_=null}URI.prototype.toString=function(){var out=[];if(null!==this.scheme_){out.push(this.scheme_,":")}if(null!==this.domain_){out.push("//");if(null!==this.credentials_){out.push(this.credentials_,"@")}out.push(this.domain_);if(null!==this.port_){out.push(":",this.port_.toString())}}if(null!==this.path_){out.push(this.path_)}if(null!==this.query_){out.push("?",this.query_)}if(null!==this.fragment_){out.push("#",this.fragment_)}return out.join("")};URI.prototype.clone=function(){return new URI(this.scheme_,this.credentials_,this.domain_,this.port_,this.path_,this.query_,this.fragment_)};URI.prototype.getScheme=function(){return this.scheme_&&decodeURIComponent(this.scheme_).toLowerCase()};URI.prototype.getRawScheme=function(){return this.scheme_};URI.prototype.setScheme=function(newScheme){this.scheme_=encodeIfExists2(newScheme,URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_);return this};URI.prototype.setRawScheme=function(newScheme){this.scheme_=newScheme?newScheme:null;return this};URI.prototype.hasScheme=function(){return null!==this.scheme_};URI.prototype.getCredentials=function(){return this.credentials_&&decodeURIComponent(this.credentials_)};URI.prototype.getRawCredentials=function(){return this.credentials_};URI.prototype.setCredentials=function(newCredentials){this.credentials_=encodeIfExists2(newCredentials,URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_);return this};URI.prototype.setRawCredentials=function(newCredentials){this.credentials_=newCredentials?newCredentials:null;return this};URI.prototype.hasCredentials=function(){return null!==this.credentials_};URI.prototype.getDomain=function(){return this.domain_&&decodeURIComponent(this.domain_)};URI.prototype.getRawDomain=function(){return this.domain_};URI.prototype.setDomain=function(newDomain){return this.setRawDomain(newDomain&&encodeURIComponent(newDomain))};URI.prototype.setRawDomain=function(newDomain){this.domain_=newDomain?newDomain:null;return this.setRawPath(this.path_)};URI.prototype.hasDomain=function(){return null!==this.domain_};URI.prototype.getPort=function(){return this.port_&&decodeURIComponent(this.port_)};URI.prototype.setPort=function(newPort){if(newPort){newPort=Number(newPort);if(newPort!==(newPort&65535)){throw new Error("Bad port number "+newPort)}this.port_=""+newPort}else{this.port_=null}return this};URI.prototype.hasPort=function(){return null!==this.port_};URI.prototype.getPath=function(){return this.path_&&decodeURIComponent(this.path_)};URI.prototype.getRawPath=function(){return this.path_};URI.prototype.setPath=function(newPath){return this.setRawPath(encodeIfExists2(newPath,URI_DISALLOWED_IN_PATH_))};URI.prototype.setRawPath=function(newPath){if(newPath){newPath=String(newPath);this.path_=!this.domain_||/^\//.test(newPath)?newPath:"/"+newPath}else{this.path_=null}return this};URI.prototype.hasPath=function(){return null!==this.path_};URI.prototype.getQuery=function(){return this.query_&&decodeURIComponent(this.query_).replace(/\+/g," ")};URI.prototype.getRawQuery=function(){return this.query_};URI.prototype.setQuery=function(newQuery){this.paramCache_=null;this.query_=encodeIfExists(newQuery);return this};URI.prototype.setRawQuery=function(newQuery){this.paramCache_=null;this.query_=newQuery?newQuery:null;return this};URI.prototype.hasQuery=function(){return null!==this.query_};URI.prototype.setAllParameters=function(params){if(typeof params==="object"){if(!(params instanceof Array)&&(params instanceof Object||Object.prototype.toString.call(params)!=="[object Array]")){var newParams=[];var i=-1;for(var k in params){var v=params[k];if("string"===typeof v){newParams[++i]=k;newParams[++i]=v}}params=newParams}}this.paramCache_=null;var queryBuf=[];var separator="";for(var j=0;j<params.length;){var k=params[j++];var v=params[j++];queryBuf.push(separator,encodeURIComponent(k.toString()));separator="&";if(v){queryBuf.push("=",encodeURIComponent(v.toString()))}}this.query_=queryBuf.join("");return this};URI.prototype.checkParameterCache_=function(){if(!this.paramCache_){var q=this.query_;if(!q){this.paramCache_=[]}else{var cgiParams=q.split(/[&\?]/);var out=[];var k=-1;for(var i=0;i<cgiParams.length;++i){var m=cgiParams[i].match(/^([^=]*)(?:=(.*))?$/);out[++k]=decodeURIComponent(m[1]).replace(/\+/g," ");out[++k]=decodeURIComponent(m[2]||"").replace(/\+/g," ")}this.paramCache_=out}}};URI.prototype.setParameterValues=function(key,values){if(typeof values==="string"){values=[values]}this.checkParameterCache_();var newValueIndex=0;var pc=this.paramCache_;var params=[];for(var i=0,k=0;i<pc.length;i+=2){if(key===pc[i]){if(newValueIndex<values.length){params.push(key,values[newValueIndex++])}}else{params.push(pc[i],pc[i+1])}}while(newValueIndex<values.length){params.push(key,values[newValueIndex++])}this.setAllParameters(params);return this};URI.prototype.removeParameter=function(key){return this.setParameterValues(key,[])};URI.prototype.getAllParameters=function(){this.checkParameterCache_();return this.paramCache_.slice(0,this.paramCache_.length)};URI.prototype.getParameterValues=function(paramNameUnescaped){this.checkParameterCache_();var values=[];for(var i=0;i<this.paramCache_.length;i+=2){if(paramNameUnescaped===this.paramCache_[i]){values.push(this.paramCache_[i+1])}}return values};URI.prototype.getParameterMap=function(paramNameUnescaped){this.checkParameterCache_();var paramMap={};for(var i=0;i<this.paramCache_.length;i+=2){var key=this.paramCache_[i++],value=this.paramCache_[i++];if(!(key in paramMap)){paramMap[key]=[value]}else{paramMap[key].push(value)}}return paramMap};URI.prototype.getParameterValue=function(paramNameUnescaped){this.checkParameterCache_();for(var i=0;i<this.paramCache_.length;i+=2){if(paramNameUnescaped===this.paramCache_[i]){return this.paramCache_[i+1]}}return null};URI.prototype.getFragment=function(){return this.fragment_&&decodeURIComponent(this.fragment_)};URI.prototype.getRawFragment=function(){return this.fragment_};URI.prototype.setFragment=function(newFragment){this.fragment_=newFragment?encodeURIComponent(newFragment):null;return this};URI.prototype.setRawFragment=function(newFragment){this.fragment_=newFragment?newFragment:null;return this};URI.prototype.hasFragment=function(){return null!==this.fragment_};function nullIfAbsent(matchPart){return"string"==typeof matchPart&&matchPart.length>0?matchPart:null}var URI_RE_=new RegExp("^"+"(?:"+"([^:/?#]+)"+":)?"+"(?://"+"(?:([^/?#]*)@)?"+"([^/?#:@]*)"+"(?::([0-9]+))?"+")?"+"([^?#]+)?"+"(?:\\?([^#]*))?"+"(?:#(.*))?"+"$");var URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_=/[#\/\?@]/g;var URI_DISALLOWED_IN_PATH_=/[\#\?]/g;URI.parse=parse;URI.create=create;URI.resolve=resolve;URI.collapse_dots=collapse_dots;URI.utils={mimeTypeOf:function(uri){var uriObj=parse(uri);if(/\.html$/.test(uriObj.getPath())){return"text/html"}else{return"application/javascript"}},resolve:function(base,uri){if(base){return resolve(parse(base),parse(uri)).toString()}else{return""+uri}}};return URI}();var html4={};html4.atype={NONE:0,URI:1,URI_FRAGMENT:11,SCRIPT:2,STYLE:3,HTML:12,ID:4,IDREF:5,IDREFS:6,GLOBAL_NAME:7,LOCAL_NAME:8,CLASSES:9,FRAME_TARGET:10,MEDIA_QUERY:13};html4["atype"]=html4.atype;html4.ATTRIBS={"*::class":9,"*::dir":0,"*::draggable":0,"*::hidden":0,"*::id":4,"*::inert":0,"*::itemprop":0,"*::itemref":6,"*::itemscope":0,"*::lang":0,"*::onblur":2,"*::onchange":2,"*::onclick":2,"*::ondblclick":2,"*::onfocus":2,"*::onkeydown":2,"*::onkeypress":2,"*::onkeyup":2,"*::onload":2,"*::onmousedown":2,"*::onmousemove":2,"*::onmouseout":2,"*::onmouseover":2,"*::onmouseup":2,"*::onreset":2,"*::onscroll":2,"*::onselect":2,"*::onsubmit":2,"*::onunload":2,"*::spellcheck":0,"*::style":3,"*::title":0,"*::translate":0,"a::accesskey":0,"a::coords":0,"a::href":1,"a::hreflang":0,"a::name":7,"a::onblur":2,"a::onfocus":2,"a::shape":0,"a::tabindex":0,"a::target":10,"a::type":0,"area::accesskey":0,"area::alt":0,"area::coords":0,"area::href":1,"area::nohref":0,"area::onblur":2,"area::onfocus":2,"area::shape":0,"area::tabindex":0,"area::target":10,"audio::controls":0,"audio::loop":0,"audio::mediagroup":5,"audio::muted":0,"audio::preload":0,"bdo::dir":0,"blockquote::cite":1,"br::clear":0,"button::accesskey":0,"button::disabled":0,"button::name":8,"button::onblur":2,"button::onfocus":2,"button::tabindex":0,"button::type":0,"button::value":0,"canvas::height":0,"canvas::width":0,"caption::align":0,"col::align":0,"col::char":0,"col::charoff":0,"col::span":0,"col::valign":0,"col::width":0,"colgroup::align":0,"colgroup::char":0,"colgroup::charoff":0,"colgroup::span":0,"colgroup::valign":0,"colgroup::width":0,"command::checked":0,"command::command":5,"command::disabled":0,"command::icon":1,"command::label":0,"command::radiogroup":0,"command::type":0,"data::value":0,"del::cite":1,"del::datetime":0,"details::open":0,"dir::compact":0,"div::align":0,"dl::compact":0,"fieldset::disabled":0,"font::color":0,"font::face":0,"font::size":0,"form::accept":0,"form::action":1,"form::autocomplete":0,"form::enctype":0,"form::method":0,"form::name":7,"form::novalidate":0,"form::onreset":2,"form::onsubmit":2,"form::target":10,"h1::align":0,"h2::align":0,"h3::align":0,"h4::align":0,"h5::align":0,"h6::align":0,"hr::align":0,"hr::noshade":0,"hr::size":0,"hr::width":0,"iframe::align":0,"iframe::frameborder":0,"iframe::height":0,"iframe::marginheight":0,"iframe::marginwidth":0,"iframe::width":0,"img::align":0,"img::alt":0,"img::border":0,"img::height":0,"img::hspace":0,"img::ismap":0,"img::name":7,"img::src":1,"img::usemap":11,"img::vspace":0,"img::width":0,"input::accept":0,"input::accesskey":0,"input::align":0,"input::alt":0,"input::autocomplete":0,"input::checked":0,"input::disabled":0,"input::inputmode":0,"input::ismap":0,"input::list":5,"input::max":0,"input::maxlength":0,"input::min":0,"input::multiple":0,"input::name":8,"input::onblur":2,"input::onchange":2,"input::onfocus":2,"input::onselect":2,"input::placeholder":0,"input::readonly":0,"input::required":0,"input::size":0,"input::src":1,"input::step":0,"input::tabindex":0,"input::type":0,"input::usemap":11,"input::value":0,"ins::cite":1,"ins::datetime":0,"label::accesskey":0,"label::for":5,"label::onblur":2,"label::onfocus":2,"legend::accesskey":0,"legend::align":0,"li::type":0,"li::value":0,"map::name":7,"menu::compact":0,"menu::label":0,"menu::type":0,"meter::high":0,"meter::low":0,"meter::max":0,"meter::min":0,"meter::value":0,"ol::compact":0,"ol::reversed":0,"ol::start":0,"ol::type":0,"optgroup::disabled":0,"optgroup::label":0,"option::disabled":0,"option::label":0,"option::selected":0,"option::value":0,"output::for":6,"output::name":8,"p::align":0,"pre::width":0,"progress::max":0,"progress::min":0,"progress::value":0,"q::cite":1,"select::autocomplete":0,"select::disabled":0,"select::multiple":0,"select::name":8,"select::onblur":2,"select::onchange":2,"select::onfocus":2,"select::required":0,"select::size":0,"select::tabindex":0,"source::type":0,"table::align":0,"table::bgcolor":0,"table::border":0,"table::cellpadding":0,"table::cellspacing":0,"table::frame":0,"table::rules":0,"table::summary":0,"table::width":0,"tbody::align":0,"tbody::char":0,"tbody::charoff":0,"tbody::valign":0,"td::abbr":0,"td::align":0,"td::axis":0,"td::bgcolor":0,"td::char":0,"td::charoff":0,"td::colspan":0,"td::headers":6,"td::height":0,"td::nowrap":0,"td::rowspan":0,"td::scope":0,"td::valign":0,"td::width":0,"textarea::accesskey":0,"textarea::autocomplete":0,"textarea::cols":0,"textarea::disabled":0,"textarea::inputmode":0,"textarea::name":8,"textarea::onblur":2,"textarea::onchange":2,"textarea::onfocus":2,"textarea::onselect":2,"textarea::placeholder":0,"textarea::readonly":0,"textarea::required":0,"textarea::rows":0,"textarea::tabindex":0,"textarea::wrap":0,"tfoot::align":0,"tfoot::char":0,"tfoot::charoff":0,"tfoot::valign":0,"th::abbr":0,"th::align":0,"th::axis":0,"th::bgcolor":0,"th::char":0,"th::charoff":0,"th::colspan":0,"th::headers":6,"th::height":0,"th::nowrap":0,"th::rowspan":0,"th::scope":0,"th::valign":0,"th::width":0,"thead::align":0,"thead::char":0,"thead::charoff":0,"thead::valign":0,"tr::align":0,"tr::bgcolor":0,"tr::char":0,"tr::charoff":0,"tr::valign":0,"track::default":0,"track::kind":0,"track::label":0,"track::srclang":0,"ul::compact":0,"ul::type":0,"video::controls":0,"video::height":0,"video::loop":0,"video::mediagroup":5,"video::muted":0,"video::poster":1,"video::preload":0,"video::width":0};html4["ATTRIBS"]=html4.ATTRIBS;html4.eflags={OPTIONAL_ENDTAG:1,EMPTY:2,CDATA:4,RCDATA:8,UNSAFE:16,FOLDABLE:32,SCRIPT:64,STYLE:128,VIRTUALIZED:256};html4["eflags"]=html4.eflags;html4.ELEMENTS={a:0,abbr:0,acronym:0,address:0,applet:272,area:2,article:0,aside:0,audio:0,b:0,base:274,basefont:274,bdi:0,bdo:0,big:0,blockquote:0,body:305,br:2,button:0,canvas:0,caption:0,center:0,cite:0,code:0,col:2,colgroup:1,command:2,data:0,datalist:0,dd:1,del:0,details:0,dfn:0,dialog:272,dir:0,div:0,dl:0,dt:1,em:0,fieldset:0,figcaption:0,figure:0,font:0,footer:0,form:0,frame:274,frameset:272,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0,head:305,header:0,hgroup:0,hr:2,html:305,i:0,iframe:16,img:2,input:2,ins:0,isindex:274,kbd:0,keygen:274,label:0,legend:0,li:1,link:274,map:0,mark:0,menu:0,meta:274,meter:0,nav:0,nobr:0,noembed:276,noframes:276,noscript:276,object:272,ol:0,optgroup:0,option:1,output:0,p:1,param:274,pre:0,progress:0,q:0,s:0,samp:0,script:84,section:0,select:0,small:0,source:2,span:0,strike:0,strong:0,style:148,sub:0,summary:0,sup:0,table:0,tbody:1,td:1,textarea:8,tfoot:1,th:1,thead:1,time:0,title:280,tr:1,track:2,tt:0,u:0,ul:0,"var":0,video:0,wbr:2};html4["ELEMENTS"]=html4.ELEMENTS;html4.ELEMENT_DOM_INTERFACES={a:"HTMLAnchorElement",abbr:"HTMLElement",acronym:"HTMLElement",address:"HTMLElement",applet:"HTMLAppletElement",area:"HTMLAreaElement",article:"HTMLElement",aside:"HTMLElement",audio:"HTMLAudioElement",b:"HTMLElement",base:"HTMLBaseElement",basefont:"HTMLBaseFontElement",bdi:"HTMLElement",bdo:"HTMLElement",big:"HTMLElement",blockquote:"HTMLQuoteElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",center:"HTMLElement",cite:"HTMLElement",code:"HTMLElement",col:"HTMLTableColElement",colgroup:"HTMLTableColElement",command:"HTMLCommandElement",data:"HTMLElement",datalist:"HTMLDataListElement",dd:"HTMLElement",del:"HTMLModElement",details:"HTMLDetailsElement",dfn:"HTMLElement",dialog:"HTMLDialogElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",dt:"HTMLElement",em:"HTMLElement",fieldset:"HTMLFieldSetElement",figcaption:"HTMLElement",figure:"HTMLElement",font:"HTMLFontElement",footer:"HTMLElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",h2:"HTMLHeadingElement",h3:"HTMLHeadingElement",h4:"HTMLHeadingElement",h5:"HTMLHeadingElement",h6:"HTMLHeadingElement",head:"HTMLHeadElement",header:"HTMLElement",hgroup:"HTMLElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",i:"HTMLElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",ins:"HTMLModElement",isindex:"HTMLUnknownElement",kbd:"HTMLElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",mark:"HTMLElement",menu:"HTMLMenuElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",nav:"HTMLElement",nobr:"HTMLElement",noembed:"HTMLElement",noframes:"HTMLElement",noscript:"HTMLElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",s:"HTMLElement",samp:"HTMLElement",script:"HTMLScriptElement",section:"HTMLElement",select:"HTMLSelectElement",small:"HTMLElement",source:"HTMLSourceElement",span:"HTMLSpanElement",strike:"HTMLElement",strong:"HTMLElement",style:"HTMLStyleElement",sub:"HTMLElement",summary:"HTMLElement",sup:"HTMLElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",td:"HTMLTableDataCellElement",textarea:"HTMLTextAreaElement",tfoot:"HTMLTableSectionElement",th:"HTMLTableHeaderCellElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",tt:"HTMLElement",u:"HTMLElement",ul:"HTMLUListElement","var":"HTMLElement",video:"HTMLVideoElement",wbr:"HTMLElement"};html4["ELEMENT_DOM_INTERFACES"]=html4.ELEMENT_DOM_INTERFACES;html4.ueffects={NOT_LOADED:0,SAME_DOCUMENT:1,NEW_DOCUMENT:2};html4["ueffects"]=html4.ueffects;html4.URIEFFECTS={"a::href":2,"area::href":2,"blockquote::cite":0,"command::icon":1,"del::cite":0,"form::action":2,"img::src":1,"input::src":1,"ins::cite":0,"q::cite":0,"video::poster":1};html4["URIEFFECTS"]=html4.URIEFFECTS;html4.ltypes={UNSANDBOXED:2,SANDBOXED:1,DATA:0};html4["ltypes"]=html4.ltypes;html4.LOADERTYPES={"a::href":2,"area::href":2,"blockquote::cite":2,"command::icon":1,"del::cite":2,"form::action":2,"img::src":1,"input::src":1,"ins::cite":2,"q::cite":2,"video::poster":1};html4["LOADERTYPES"]=html4.LOADERTYPES;if("I".toLowerCase()!=="i"){throw"I/i problem"}var html=function(html4){var parseCssDeclarations,sanitizeCssProperty,cssSchema;if("undefined"!==typeof window){parseCssDeclarations=window["parseCssDeclarations"];sanitizeCssProperty=window["sanitizeCssProperty"];cssSchema=window["cssSchema"]}var ENTITIES={lt:"<",LT:"<",gt:">",GT:">",amp:"&",AMP:"&",quot:'"',apos:"'",nbsp:" "};var decimalEscapeRe=/^#(\d+)$/;var hexEscapeRe=/^#x([0-9A-Fa-f]+)$/;var safeEntityNameRe=/^[A-Za-z][A-za-z0-9]+$/;var entityLookupElement="undefined"!==typeof window&&window["document"]?window["document"].createElement("textarea"):null;function lookupEntity(name){if(ENTITIES.hasOwnProperty(name)){return ENTITIES[name]}var m=name.match(decimalEscapeRe);if(m){return String.fromCharCode(parseInt(m[1],10))}else if(!!(m=name.match(hexEscapeRe))){return String.fromCharCode(parseInt(m[1],16))}else if(entityLookupElement&&safeEntityNameRe.test(name)){entityLookupElement.innerHTML="&"+name+";";var text=entityLookupElement.textContent;ENTITIES[name]=text;return text}else{return"&"+name+";"}}function decodeOneEntity(_,name){return lookupEntity(name)}var nulRe=/\0/g;function stripNULs(s){return s.replace(nulRe,"")}var ENTITY_RE_1=/&(#[0-9]+|#[xX][0-9A-Fa-f]+|\w+);/g;var ENTITY_RE_2=/^(#[0-9]+|#[xX][0-9A-Fa-f]+|\w+);/;function unescapeEntities(s){return s.replace(ENTITY_RE_1,decodeOneEntity)}var ampRe=/&/g;var looseAmpRe=/&([^a-z#]|#(?:[^0-9x]|x(?:[^0-9a-f]|$)|$)|$)/gi;var ltRe=/[<]/g;var gtRe=/>/g;var quotRe=/\"/g;function escapeAttrib(s){return(""+s).replace(ampRe,"&amp;").replace(ltRe,"&lt;").replace(gtRe,"&gt;").replace(quotRe,"&#34;")}function normalizeRCData(rcdata){return rcdata.replace(looseAmpRe,"&amp;$1").replace(ltRe,"&lt;").replace(gtRe,"&gt;")}var ATTR_RE=new RegExp("^\\s*"+"([-.:\\w]+)"+"(?:"+("\\s*(=)\\s*"+"("+('(")[^"]*("|$)'+"|"+"(')[^']*('|$)"+"|"+"(?=[a-z][-\\w]*\\s*=)"+"|"+"[^\"'\\s]*")+")")+")?","i");var splitWillCapture="a,b".split(/(,)/).length===3;var EFLAGS_TEXT=html4.eflags["CDATA"]|html4.eflags["RCDATA"];function makeSaxParser(handler){var hcopy={cdata:handler.cdata||handler["cdata"],comment:handler.comment||handler["comment"],endDoc:handler.endDoc||handler["endDoc"],endTag:handler.endTag||handler["endTag"],pcdata:handler.pcdata||handler["pcdata"],rcdata:handler.rcdata||handler["rcdata"],startDoc:handler.startDoc||handler["startDoc"],startTag:handler.startTag||handler["startTag"]};return function(htmlText,param){return parse(htmlText,hcopy,param)}}var continuationMarker={};function parse(htmlText,handler,param){var m,p,tagName;var parts=htmlSplit(htmlText);var state={noMoreGT:false,noMoreEndComments:false};parseCPS(handler,parts,0,state,param)}function continuationMaker(h,parts,initial,state,param){return function(){parseCPS(h,parts,initial,state,param)}}function parseCPS(h,parts,initial,state,param){try{if(h.startDoc&&initial==0){h.startDoc(param)}var m,p,tagName;for(var pos=initial,end=parts.length;pos<end;){var current=parts[pos++];var next=parts[pos];switch(current){case"&":if(ENTITY_RE_2.test(next)){if(h.pcdata){h.pcdata("&"+next,param,continuationMarker,continuationMaker(h,parts,pos,state,param))}pos++}else{if(h.pcdata){h.pcdata("&amp;",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}break;case"</":if(m=/^([-\w:]+)[^\'\"]*/.exec(next)){if(m[0].length===next.length&&parts[pos+1]===">"){pos+=2;tagName=m[1].toLowerCase();if(h.endTag){h.endTag(tagName,param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}else{pos=parseEndTag(parts,pos,h,param,continuationMarker,state)}}else{if(h.pcdata){h.pcdata("&lt;/",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}break;case"<":if(m=/^([-\w:]+)\s*\/?/.exec(next)){if(m[0].length===next.length&&parts[pos+1]===">"){pos+=2;tagName=m[1].toLowerCase();if(h.startTag){h.startTag(tagName,[],param,continuationMarker,continuationMaker(h,parts,pos,state,param))}var eflags=html4.ELEMENTS[tagName];if(eflags&EFLAGS_TEXT){var tag={name:tagName,next:pos,eflags:eflags};pos=parseText(parts,tag,h,param,continuationMarker,state)}}else{pos=parseStartTag(parts,pos,h,param,continuationMarker,state)}}else{if(h.pcdata){h.pcdata("&lt;",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}break;case"<!--":if(!state.noMoreEndComments){for(p=pos+1;p<end;p++){if(parts[p]===">"&&/--$/.test(parts[p-1])){break}}if(p<end){if(h.comment){var comment=parts.slice(pos,p).join("");h.comment(comment.substr(0,comment.length-2),param,continuationMarker,continuationMaker(h,parts,p+1,state,param))}pos=p+1}else{state.noMoreEndComments=true}}if(state.noMoreEndComments){if(h.pcdata){h.pcdata("&lt;!--",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}break;case"<!":if(!/^\w/.test(next)){if(h.pcdata){h.pcdata("&lt;!",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}else{if(!state.noMoreGT){for(p=pos+1;p<end;p++){if(parts[p]===">"){break}}if(p<end){pos=p+1}else{state.noMoreGT=true}}if(state.noMoreGT){if(h.pcdata){h.pcdata("&lt;!",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}}break;case"<?":if(!state.noMoreGT){for(p=pos+1;p<end;p++){if(parts[p]===">"){break}}if(p<end){pos=p+1}else{state.noMoreGT=true}}if(state.noMoreGT){if(h.pcdata){h.pcdata("&lt;?",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}}break;case">":if(h.pcdata){h.pcdata("&gt;",param,continuationMarker,continuationMaker(h,parts,pos,state,param))}break;case"":break;default:if(h.pcdata){h.pcdata(current,param,continuationMarker,continuationMaker(h,parts,pos,state,param))}break}}if(h.endDoc){h.endDoc(param)}}catch(e){if(e!==continuationMarker){throw e}}}function htmlSplit(str){var re=/(<\/|<\!--|<[!?]|[&<>])/g;str+="";if(splitWillCapture){return str.split(re)}else{var parts=[];var lastPos=0;var m;while((m=re.exec(str))!==null){parts.push(str.substring(lastPos,m.index));parts.push(m[0]);lastPos=m.index+m[0].length}parts.push(str.substring(lastPos));return parts}}function parseEndTag(parts,pos,h,param,continuationMarker,state){var tag=parseTagAndAttrs(parts,pos);if(!tag){return parts.length}if(h.endTag){h.endTag(tag.name,param,continuationMarker,continuationMaker(h,parts,pos,state,param))}return tag.next}function parseStartTag(parts,pos,h,param,continuationMarker,state){var tag=parseTagAndAttrs(parts,pos);if(!tag){return parts.length}if(h.startTag){h.startTag(tag.name,tag.attrs,param,continuationMarker,continuationMaker(h,parts,tag.next,state,param))}if(tag.eflags&EFLAGS_TEXT){return parseText(parts,tag,h,param,continuationMarker,state)}else{return tag.next}}var endTagRe={};function parseText(parts,tag,h,param,continuationMarker,state){var end=parts.length;if(!endTagRe.hasOwnProperty(tag.name)){endTagRe[tag.name]=new RegExp("^"+tag.name+"(?:[\\s\\/]|$)","i")}var re=endTagRe[tag.name];var first=tag.next;var p=tag.next+1;for(;p<end;p++){if(parts[p-1]==="</"&&re.test(parts[p])){break}}if(p<end){p-=1}var buf=parts.slice(first,p).join("");if(tag.eflags&html4.eflags["CDATA"]){if(h.cdata){h.cdata(buf,param,continuationMarker,continuationMaker(h,parts,p,state,param))}}else if(tag.eflags&html4.eflags["RCDATA"]){if(h.rcdata){h.rcdata(normalizeRCData(buf),param,continuationMarker,continuationMaker(h,parts,p,state,param))}}else{throw new Error("bug")}return p}function parseTagAndAttrs(parts,pos){var m=/^([-\w:]+)/.exec(parts[pos]);var tag={};tag.name=m[1].toLowerCase();tag.eflags=html4.ELEMENTS[tag.name];var buf=parts[pos].substr(m[0].length);var p=pos+1;var end=parts.length;for(;p<end;p++){if(parts[p]===">"){break}buf+=parts[p]}if(end<=p){return void 0}var attrs=[];while(buf!==""){m=ATTR_RE.exec(buf);if(!m){buf=buf.replace(/^[\s\S][^a-z\s]*/,"")}else if(m[4]&&!m[5]||m[6]&&!m[7]){var quote=m[4]||m[6];var sawQuote=false;var abuf=[buf,parts[p++]];for(;p<end;p++){if(sawQuote){if(parts[p]===">"){break}}else if(0<=parts[p].indexOf(quote)){sawQuote=true}abuf.push(parts[p])}if(end<=p){break}buf=abuf.join("");continue}else{var aName=m[1].toLowerCase();var aValue=m[2]?decodeValue(m[3]):"";attrs.push(aName,aValue);buf=buf.substr(m[0].length)}}tag.attrs=attrs;tag.next=p+1;return tag}function decodeValue(v){var q=v.charCodeAt(0);if(q===34||q===39){v=v.substr(1,v.length-2)}return unescapeEntities(stripNULs(v))}function makeHtmlSanitizer(tagPolicy){var stack;var ignoring;var emit=function(text,out){if(!ignoring){out.push(text)}};return makeSaxParser({startDoc:function(_){stack=[];ignoring=false},startTag:function(tagNameOrig,attribs,out){if(ignoring){return}if(!html4.ELEMENTS.hasOwnProperty(tagNameOrig)){return}var eflagsOrig=html4.ELEMENTS[tagNameOrig];if(eflagsOrig&html4.eflags["FOLDABLE"]){return}var decision=tagPolicy(tagNameOrig,attribs);if(!decision){ignoring=!(eflagsOrig&html4.eflags["EMPTY"]);return}else if(typeof decision!=="object"){throw new Error("tagPolicy did not return object (old API?)")}if("attribs"in decision){attribs=decision["attribs"]}else{throw new Error("tagPolicy gave no attribs");
}var eflagsRep;var tagNameRep;if("tagName"in decision){tagNameRep=decision["tagName"];eflagsRep=html4.ELEMENTS[tagNameRep]}else{tagNameRep=tagNameOrig;eflagsRep=eflagsOrig}if(eflagsOrig&html4.eflags["OPTIONAL_ENDTAG"]){var onStack=stack[stack.length-1];if(onStack&&onStack.orig===tagNameOrig&&(onStack.rep!==tagNameRep||tagNameOrig!==tagNameRep)){out.push("</",onStack.rep,">")}}if(!(eflagsOrig&html4.eflags["EMPTY"])){stack.push({orig:tagNameOrig,rep:tagNameRep})}out.push("<",tagNameRep);for(var i=0,n=attribs.length;i<n;i+=2){var attribName=attribs[i],value=attribs[i+1];if(value!==null&&value!==void 0){out.push(" ",attribName,'="',escapeAttrib(value),'"')}}out.push(">");if(eflagsOrig&html4.eflags["EMPTY"]&&!(eflagsRep&html4.eflags["EMPTY"])){out.push("</",tagNameRep,">")}},endTag:function(tagName,out){if(ignoring){ignoring=false;return}if(!html4.ELEMENTS.hasOwnProperty(tagName)){return}var eflags=html4.ELEMENTS[tagName];if(!(eflags&(html4.eflags["EMPTY"]|html4.eflags["FOLDABLE"]))){var index;if(eflags&html4.eflags["OPTIONAL_ENDTAG"]){for(index=stack.length;--index>=0;){var stackElOrigTag=stack[index].orig;if(stackElOrigTag===tagName){break}if(!(html4.ELEMENTS[stackElOrigTag]&html4.eflags["OPTIONAL_ENDTAG"])){return}}}else{for(index=stack.length;--index>=0;){if(stack[index].orig===tagName){break}}}if(index<0){return}for(var i=stack.length;--i>index;){var stackElRepTag=stack[i].rep;if(!(html4.ELEMENTS[stackElRepTag]&html4.eflags["OPTIONAL_ENDTAG"])){out.push("</",stackElRepTag,">")}}if(index<stack.length){tagName=stack[index].rep}stack.length=index;out.push("</",tagName,">")}},pcdata:emit,rcdata:emit,cdata:emit,endDoc:function(out){for(;stack.length;stack.length--){out.push("</",stack[stack.length-1].rep,">")}}})}var ALLOWED_URI_SCHEMES=/^(?:https?|mailto|data)$/i;function safeUri(uri,effect,ltype,hints,naiveUriRewriter){if(!naiveUriRewriter){return null}try{var parsed=URI.parse(""+uri);if(parsed){if(!parsed.hasScheme()||ALLOWED_URI_SCHEMES.test(parsed.getScheme())){var safe=naiveUriRewriter(parsed,effect,ltype,hints);return safe?safe.toString():null}}}catch(e){return null}return null}function log(logger,tagName,attribName,oldValue,newValue){if(!attribName){logger(tagName+" removed",{change:"removed",tagName:tagName})}if(oldValue!==newValue){var changed="changed";if(oldValue&&!newValue){changed="removed"}else if(!oldValue&&newValue){changed="added"}logger(tagName+"."+attribName+" "+changed,{change:changed,tagName:tagName,attribName:attribName,oldValue:oldValue,newValue:newValue})}}function lookupAttribute(map,tagName,attribName){var attribKey;attribKey=tagName+"::"+attribName;if(map.hasOwnProperty(attribKey)){return map[attribKey]}attribKey="*::"+attribName;if(map.hasOwnProperty(attribKey)){return map[attribKey]}return void 0}function getAttributeType(tagName,attribName){return lookupAttribute(html4.ATTRIBS,tagName,attribName)}function getLoaderType(tagName,attribName){return lookupAttribute(html4.LOADERTYPES,tagName,attribName)}function getUriEffect(tagName,attribName){return lookupAttribute(html4.URIEFFECTS,tagName,attribName)}function sanitizeAttribs(tagName,attribs,opt_naiveUriRewriter,opt_nmTokenPolicy,opt_logger){for(var i=0;i<attribs.length;i+=2){var attribName=attribs[i];var value=attribs[i+1];var oldValue=value;var atype=null,attribKey;if((attribKey=tagName+"::"+attribName,html4.ATTRIBS.hasOwnProperty(attribKey))||(attribKey="*::"+attribName,html4.ATTRIBS.hasOwnProperty(attribKey))){atype=html4.ATTRIBS[attribKey]}if(atype!==null){switch(atype){case html4.atype["NONE"]:break;case html4.atype["SCRIPT"]:value=null;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break;case html4.atype["STYLE"]:if("undefined"===typeof parseCssDeclarations){value=null;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break}var sanitizedDeclarations=[];parseCssDeclarations(value,{declaration:function(property,tokens){var normProp=property.toLowerCase();var schema=cssSchema[normProp];if(!schema){return}sanitizeCssProperty(normProp,schema,tokens,opt_naiveUriRewriter?function(url){return safeUri(url,html4.ueffects.SAME_DOCUMENT,html4.ltypes.SANDBOXED,{TYPE:"CSS",CSS_PROP:normProp},opt_naiveUriRewriter)}:null);sanitizedDeclarations.push(property+": "+tokens.join(" "))}});value=sanitizedDeclarations.length>0?sanitizedDeclarations.join(" ; "):null;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break;case html4.atype["ID"]:case html4.atype["IDREF"]:case html4.atype["IDREFS"]:case html4.atype["GLOBAL_NAME"]:case html4.atype["LOCAL_NAME"]:case html4.atype["CLASSES"]:value=opt_nmTokenPolicy?opt_nmTokenPolicy(value):value;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break;case html4.atype["URI"]:value=safeUri(value,getUriEffect(tagName,attribName),getLoaderType(tagName,attribName),{TYPE:"MARKUP",XML_ATTR:attribName,XML_TAG:tagName},opt_naiveUriRewriter);if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break;case html4.atype["URI_FRAGMENT"]:if(value&&"#"===value.charAt(0)){value=value.substring(1);value=opt_nmTokenPolicy?opt_nmTokenPolicy(value):value;if(value!==null&&value!==void 0){value="#"+value}}else{value=null}if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break;default:value=null;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}break}}else{value=null;if(opt_logger){log(opt_logger,tagName,attribName,oldValue,value)}}attribs[i+1]=value}return attribs}function makeTagPolicy(opt_naiveUriRewriter,opt_nmTokenPolicy,opt_logger){return function(tagName,attribs){if(!(html4.ELEMENTS[tagName]&html4.eflags["UNSAFE"])){return{attribs:sanitizeAttribs(tagName,attribs,opt_naiveUriRewriter,opt_nmTokenPolicy,opt_logger)}}else{if(opt_logger){log(opt_logger,tagName,undefined,undefined,undefined)}}}}function sanitizeWithPolicy(inputHtml,tagPolicy){var outputArray=[];makeHtmlSanitizer(tagPolicy)(inputHtml,outputArray);return outputArray.join("")}function sanitize(inputHtml,opt_naiveUriRewriter,opt_nmTokenPolicy,opt_logger){var tagPolicy=makeTagPolicy(opt_naiveUriRewriter,opt_nmTokenPolicy,opt_logger);return sanitizeWithPolicy(inputHtml,tagPolicy)}var html={};html.escapeAttrib=html["escapeAttrib"]=escapeAttrib;html.makeHtmlSanitizer=html["makeHtmlSanitizer"]=makeHtmlSanitizer;html.makeSaxParser=html["makeSaxParser"]=makeSaxParser;html.makeTagPolicy=html["makeTagPolicy"]=makeTagPolicy;html.normalizeRCData=html["normalizeRCData"]=normalizeRCData;html.sanitize=html["sanitize"]=sanitize;html.sanitizeAttribs=html["sanitizeAttribs"]=sanitizeAttribs;html.sanitizeWithPolicy=html["sanitizeWithPolicy"]=sanitizeWithPolicy;html.unescapeEntities=html["unescapeEntities"]=unescapeEntities;return html}(html4);var html_sanitize=html["sanitize"];html4.ATTRIBS["*::style"]=0;html4.ELEMENTS["style"]=0;html4.ATTRIBS["a::target"]=0;html4.ELEMENTS["video"]=0;html4.ATTRIBS["video::src"]=0;html4.ATTRIBS["video::poster"]=0;html4.ATTRIBS["video::controls"]=0;html4.ELEMENTS["audio"]=0;html4.ATTRIBS["audio::src"]=0;html4.ATTRIBS["video::autoplay"]=0;html4.ATTRIBS["video::controls"]=0;if(typeof module!=="undefined"){module.exports=html_sanitize}},{}],6:[function(require,module,exports){module.exports={author:"Mapbox",name:"mapbox.js",description:"mapbox javascript api",version:"2.1.9",homepage:"http://mapbox.com/",repository:{type:"git",url:"git://github.com/mapbox/mapbox.js.git"},main:"src/index.js",dependencies:{leaflet:"0.7.3",mustache:"0.7.3",corslite:"0.0.6","sanitize-caja":"0.1.3"},scripts:{},devDependencies:{browserify:"^6.3.2","clean-css":"~2.0.7","expect.js":"0.3.1",happen:"0.1.3",jshint:"2.4.4","leaflet-fullscreen":"0.0.4","leaflet-hash":"0.2.1",marked:"~0.3.0",minifyify:"^6.1.0",minimist:"0.0.5",mocha:"1.17.1","mocha-phantomjs":"3.1.6",sinon:"1.10.2"},optionalDependencies:{},engines:{node:"*"},readme:"# mapbox.js\n\n[![Build Status](https://travis-ci.org/mapbox/mapbox.js.png?branch=v1)](https://travis-ci.org/mapbox/mapbox.js)\n\nThis is the Mapbox Javascript API, version 2.x. It's built as a [Leaflet](http://leafletjs.com/)\nplugin. You can [read about its launch](http://mapbox.com/blog/mapbox-js-with-leaflet/).\n\n## [API](http://mapbox.com/mapbox.js/api/)\n\nManaged as Markdown in `API.md`, following the standards in `DOCUMENTING.md`\n\n## [Examples](http://mapbox.com/mapbox.js/example/v1.0.0/)\n\n## Usage\n\nRecommended usage is via the Mapbox CDN:\n\n```html\n<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.js'></script>\n<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.5/mapbox.css' rel='stylesheet' />\n```\n\nThe `mapbox.js` file includes the Leaflet library. Alternatively, you can use `mapbox.standalone.js`, which does not include Leaflet (you will have to provide it yourself).\n\nSee the [API documentation](http://mapbox.com/mapbox.js/api/) and [Examples](http://mapbox.com/mapbox.js/example/v1.0.0/) for further help.\n\n## Usage with [Browserify](http://browserify.org/)\n\nInstall the mapbox.js module and add it to `dependencies` in package.json:\n\n```sh\nnpm install mapbox.js --save\n```\n\nRequire mapbox in your script:\n\n```js\n// main.js\n\nrequire('mapbox.js'); // <-- auto-attaches to window.L\n```\n\nBrowserify it:\n\n```sh\nbrowserify main.js -o bundle.js\n```\n\n## Usage with Bower\n\nYou can install `mapbox.js` with [bower](http://bower.io/) by running\n\n```sh\nbower install mapbox.js\n```\n\n## Usage as Download\n\nYou can [download a built release at the mapbox.js-bower repository](https://github.com/mapbox/mapbox.js-bower/releases).\n\n## Building\n\nRequires [node.js](http://nodejs.org/) installed on your system.\n\n``` sh\ngit clone https://github.com/mapbox/mapbox.js.git\ncd mapbox.js\nnpm install\nmake\n```\n\nThis project uses [browserify](https://github.com/substack/node-browserify) to combine\ndependencies and installs a local copy when you run `npm install`.\n`make` will build the project in `dist/`.\n\n### Tests\n\nTest with [phantomjs](http://phantomjs.org/):\n\n``` sh\nnpm test\n```\n\nTo test in a browser, run a [local development server](https://gist.github.com/tmcw/4989751)\nand go to `/test`.\n\n### Version v0.x.x\n\n[Version v0.x.x can be accessed in the v0 branch.](https://github.com/mapbox/mapbox.js/tree/v0).\n\n### Editing Icons\n\nRequirements:\n\n inkscape\n pngquant\n convert (part of imagemagick)\n\n1. Make edits to `theme/images/icons.svg`.\n2. Run `./theme/images/render.sh` to update sprites from your edits.\n3. Add a CSS reference with the appropriate pixel coordinate if adding a new icon.\n",readmeFilename:"package/README.md"}},{}],7:[function(require,module,exports){"use strict";module.exports={HTTP_URL:"http://a.tiles.mapbox.com/v4",HTTPS_URL:"https://a.tiles.mapbox.com/v4",FORCE_HTTPS:false,REQUIRE_ACCESS_TOKEN:true}},{}],8:[function(require,module,exports){"use strict";var util=require("./util"),urlhelper=require("./url"),request=require("./request"),marker=require("./marker"),simplestyle=require("./simplestyle");var FeatureLayer=L.FeatureGroup.extend({options:{filter:function(){return true},sanitizer:require("sanitize-caja"),style:simplestyle.style,popupOptions:{closeButton:false}},initialize:function(_,options){L.setOptions(this,options);this._layers={};if(typeof _==="string"){util.idUrl(_,this)}else if(_&&typeof _==="object"){this.setGeoJSON(_)}},setGeoJSON:function(_){this._geojson=_;this.clearLayers();this._initialize(_);return this},getGeoJSON:function(){return this._geojson},loadURL:function(url){if(this._request&&"abort"in this._request)this._request.abort();this._request=request(url,L.bind(function(err,json){this._request=null;if(err&&err.type!=="abort"){util.log("could not load features at "+url);this.fire("error",{error:err})}else if(json){this.setGeoJSON(json);this.fire("ready")}},this));return this},loadID:function(id){return this.loadURL(urlhelper("/"+id+"/features.json",this.options.accessToken))},setFilter:function(_){this.options.filter=_;if(this._geojson){this.clearLayers();this._initialize(this._geojson)}return this},getFilter:function(){return this.options.filter},_initialize:function(json){var features=L.Util.isArray(json)?json:json.features,i,len;if(features){for(i=0,len=features.length;i<len;i++){if(features[i].geometries||features[i].geometry||features[i].features){this._initialize(features[i])}}}else if(this.options.filter(json)){var opts={accessToken:this.options.accessToken},pointToLayer=this.options.pointToLayer||function(feature,latlon){return marker.style(feature,latlon,opts)},layer=L.GeoJSON.geometryToLayer(json,pointToLayer),popupHtml=marker.createPopup(json,this.options.sanitizer),style=this.options.style,defaultStyle=style===simplestyle.style;if(style&&"setStyle"in layer&&!(defaultStyle&&(layer instanceof L.Circle||layer instanceof L.CircleMarker))){if(typeof style==="function"){style=style(json)}layer.setStyle(style)}layer.feature=json;if(popupHtml){layer.bindPopup(popupHtml,this.options.popupOptions)}this.addLayer(layer)}}});module.exports.FeatureLayer=FeatureLayer;module.exports.featureLayer=function(_,options){return new FeatureLayer(_,options)}},{"./marker":22,"./request":23,"./simplestyle":25,"./url":27,"./util":28,"sanitize-caja":4}],9:[function(require,module,exports){"use strict";var Feedback=L.Class.extend({includes:L.Mixin.Events,data:{},record:function(data){L.extend(this.data,data);this.fire("change")}});module.exports=new Feedback},{}],10:[function(require,module,exports){"use strict";var util=require("./util"),urlhelper=require("./url"),feedback=require("./feedback"),request=require("./request");module.exports=function(url,options){var geocoder={};util.strict(url,"string");if(url.indexOf("/")===-1){url=urlhelper("/geocode/"+url+"/{query}.json",options&&options.accessToken)}geocoder.getURL=function(){return url};geocoder.queryURL=function(_){var query;if(typeof _!=="string"){var parts=[];for(var i=0;i<_.length;i++){parts[i]=encodeURIComponent(_[i])}query=parts.join(";")}else{query=encodeURIComponent(_)}feedback.record({geocoding:query});return L.Util.template(geocoder.getURL(),{query:query})};geocoder.query=function(_,callback){util.strict(callback,"function");request(geocoder.queryURL(_),function(err,json){if(json&&(json.length||json.features)){var res={results:json};if(json.features&&json.features.length){res.latlng=[json.features[0].center[1],json.features[0].center[0]];if(json.features[0].bbox){res.bounds=json.features[0].bbox;res.lbounds=util.lbounds(res.bounds)}}callback(null,res)}else callback(err||true)});return geocoder};geocoder.reverseQuery=function(_,callback){var q="";function normalize(x){if(x.lat!==undefined&&x.lng!==undefined){return x.lng+","+x.lat}else if(x.lat!==undefined&&x.lon!==undefined){return x.lon+","+x.lat}else{return x[0]+","+x[1]}}if(_.length&&_[0].length){for(var i=0,pts=[];i<_.length;i++){pts.push(normalize(_[i]))}q=pts.join(";")}else{q=normalize(_)}request(geocoder.queryURL(q),function(err,json){callback(err,json)});return geocoder};return geocoder}},{"./feedback":9,"./request":23,"./url":27,"./util":28}],11:[function(require,module,exports){"use strict";var geocoder=require("./geocoder"),util=require("./util");var GeocoderControl=L.Control.extend({includes:L.Mixin.Events,options:{position:"topleft",pointZoom:16,keepOpen:false,autocomplete:false},initialize:function(_,options){L.Util.setOptions(this,options);this.setURL(_);this._updateSubmit=L.bind(this._updateSubmit,this);this._updateAutocomplete=L.bind(this._updateAutocomplete,this);this._chooseResult=L.bind(this._chooseResult,this)},setURL:function(_){this.geocoder=geocoder(_,{accessToken:this.options.accessToken});return this},getURL:function(){return this.geocoder.getURL()},setID:function(_){return this.setURL(_)},setTileJSON:function(_){return this.setURL(_.geocoder)},_toggle:function(e){if(e)L.DomEvent.stop(e);if(L.DomUtil.hasClass(this._container,"active")){L.DomUtil.removeClass(this._container,"active");this._results.innerHTML="";this._input.blur()}else{L.DomUtil.addClass(this._container,"active");this._input.focus();this._input.select()}},_closeIfOpen:function(e){if(L.DomUtil.hasClass(this._container,"active")&&!this.options.keepOpen){L.DomUtil.removeClass(this._container,"active");this._results.innerHTML="";this._input.blur()}},onAdd:function(map){var container=L.DomUtil.create("div","leaflet-control-mapbox-geocoder leaflet-bar leaflet-control"),link=L.DomUtil.create("a","leaflet-control-mapbox-geocoder-toggle mapbox-icon mapbox-icon-geocoder",container),results=L.DomUtil.create("div","leaflet-control-mapbox-geocoder-results",container),wrap=L.DomUtil.create("div","leaflet-control-mapbox-geocoder-wrap",container),form=L.DomUtil.create("form","leaflet-control-mapbox-geocoder-form",wrap),input=L.DomUtil.create("input","",form);link.href="#";link.innerHTML="&nbsp;";input.type="text";input.setAttribute("placeholder","Search");L.DomEvent.addListener(form,"submit",this._geocode,this);L.DomEvent.addListener(input,"keyup",this._autocomplete,this);L.DomEvent.disableClickPropagation(container);this._map=map;this._results=results;this._input=input;this._form=form;if(this.options.keepOpen){L.DomUtil.addClass(container,"active")}else{this._map.on("click",this._closeIfOpen,this);L.DomEvent.addListener(link,"click",this._toggle,this)}return container},_updateSubmit:function(err,resp){L.DomUtil.removeClass(this._container,"searching");this._results.innerHTML="";if(err||!resp){this.fire("error",{error:err})}else{var features=[];if(resp.results&&resp.results.features){features=resp.results.features}if(features.length===1){this.fire("autoselect",{feature:features[0]});this.fire("found",{results:resp.results});this._chooseResult(features[0]);this._closeIfOpen()}else if(features.length>1){this.fire("found",{results:resp.results});this._displayResults(features)}else{this._displayResults(features)}}},_updateAutocomplete:function(err,resp){this._results.innerHTML="";if(err||!resp){this.fire("error",{error:err})}else{var features=[];if(resp.results&&resp.results.features){features=resp.results.features}if(features.length){this.fire("found",{results:resp.results})}this._displayResults(features)}},_displayResults:function(features){for(var i=0,l=Math.min(features.length,5);i<l;i++){var feature=features[i];var name=feature.place_name;if(!name.length)continue;var r=L.DomUtil.create("a","",this._results);var text="innerText"in r?"innerText":"textContent";r[text]=name;r.href="#";L.bind(function(feature){L.DomEvent.addListener(r,"click",function(e){this._chooseResult(feature);L.DomEvent.stop(e);this.fire("select",{feature:feature})},this)},this)(feature)}if(features.length>5){var outof=L.DomUtil.create("span","",this._results);outof.innerHTML="Top 5 of "+features.length+" results"}},_chooseResult:function(result){if(result.bbox){this._map.fitBounds(util.lbounds(result.bbox))}else if(result.center){this._map.setView([result.center[1],result.center[0]],this._map.getZoom()===undefined?this.options.pointZoom:Math.max(this._map.getZoom(),this.options.pointZoom))}},_geocode:function(e){L.DomEvent.preventDefault(e);if(this._input.value==="")return this._updateSubmit();L.DomUtil.addClass(this._container,"searching");this.geocoder.query(this._input.value,this._updateSubmit)},_autocomplete:function(e){if(!this.options.autocomplete)return;if(this._input.value==="")return this._updateAutocomplete();this.geocoder.query(this._input.value,this._updateAutocomplete)}});module.exports.GeocoderControl=GeocoderControl;module.exports.geocoderControl=function(_,options){return new GeocoderControl(_,options)}},{"./geocoder":10,"./util":28}],12:[function(require,module,exports){"use strict";function utfDecode(c){if(c>=93)c--;if(c>=35)c--;return c-32}module.exports=function(data){return function(x,y){if(!data)return;var idx=utfDecode(data.grid[y].charCodeAt(x)),key=data.keys[idx];return data.data[key]}}},{}],13:[function(require,module,exports){"use strict";var util=require("./util"),Mustache=require("mustache");var GridControl=L.Control.extend({options:{pinnable:true,follow:false,sanitizer:require("sanitize-caja"),touchTeaser:true,location:true},_currentContent:"",_pinned:false,initialize:function(_,options){L.Util.setOptions(this,options);util.strict_instance(_,L.Class,"L.mapbox.gridLayer");this._layer=_},setTemplate:function(template){util.strict(template,"string");this.options.template=template;return this},_template:function(format,data){if(!data)return;var template=this.options.template||this._layer.getTileJSON().template;if(template){var d={};d["__"+format+"__"]=true;return this.options.sanitizer(Mustache.to_html(template,L.extend(d,data)))}},_show:function(content,o){if(content===this._currentContent)return;this._currentContent=content;if(this.options.follow){this._popup.setContent(content).setLatLng(o.latLng);if(this._map._popup!==this._popup)this._popup.openOn(this._map)}else{this._container.style.display="block";this._contentWrapper.innerHTML=content}},hide:function(){this._pinned=false;this._currentContent="";this._map.closePopup();this._container.style.display="none";this._contentWrapper.innerHTML="";L.DomUtil.removeClass(this._container,"closable");return this},_mouseover:function(o){if(o.data){L.DomUtil.addClass(this._map._container,"map-clickable")}else{L.DomUtil.removeClass(this._map._container,"map-clickable")}if(this._pinned)return;var content=this._template("teaser",o.data);if(content){this._show(content,o)}else{this.hide()}},_mousemove:function(o){if(this._pinned)return;if(!this.options.follow)return;this._popup.setLatLng(o.latLng)},_navigateTo:function(url){window.top.location.href=url},_click:function(o){var location_formatted=this._template("location",o.data);if(this.options.location&&location_formatted&&location_formatted.search(/^https?:/)===0){return this._navigateTo(this._template("location",o.data))}if(!this.options.pinnable)return;var content=this._template("full",o.data);if(!content&&this.options.touchTeaser&&L.Browser.touch){content=this._template("teaser",o.data)}if(content){L.DomUtil.addClass(this._container,"closable");this._pinned=true;this._show(content,o)}else if(this._pinned){L.DomUtil.removeClass(this._container,"closable");this._pinned=false;this.hide()}},_onPopupClose:function(){this._currentContent=null;this._pinned=false},_createClosebutton:function(container,fn){var link=L.DomUtil.create("a","close",container);link.innerHTML="close";link.href="#";link.title="close";L.DomEvent.on(link,"click",L.DomEvent.stopPropagation).on(link,"mousedown",L.DomEvent.stopPropagation).on(link,"dblclick",L.DomEvent.stopPropagation).on(link,"click",L.DomEvent.preventDefault).on(link,"click",fn,this);return link},onAdd:function(map){this._map=map;var className="leaflet-control-grid map-tooltip",container=L.DomUtil.create("div",className),contentWrapper=L.DomUtil.create("div","map-tooltip-content");container.style.display="none";this._createClosebutton(container,this.hide);container.appendChild(contentWrapper);this._contentWrapper=contentWrapper;this._popup=new L.Popup({autoPan:false,closeOnClick:false});map.on("popupclose",this._onPopupClose,this);L.DomEvent.disableClickPropagation(container).addListener(container,"mousewheel",L.DomEvent.stopPropagation);this._layer.on("mouseover",this._mouseover,this).on("mousemove",this._mousemove,this).on("click",this._click,this);return container},onRemove:function(map){map.off("popupclose",this._onPopupClose,this);this._layer.off("mouseover",this._mouseover,this).off("mousemove",this._mousemove,this).off("click",this._click,this)}});module.exports.GridControl=GridControl;module.exports.gridControl=function(_,options){return new GridControl(_,options)}},{"./util":28,mustache:3,"sanitize-caja":4}],14:[function(require,module,exports){"use strict";var util=require("./util"),request=require("./request"),grid=require("./grid");var GridLayer=L.Class.extend({includes:[L.Mixin.Events,require("./load_tilejson")],options:{template:function(){return""}},_mouseOn:null,_tilejson:{},_cache:{},initialize:function(_,options){L.Util.setOptions(this,options);this._loadTileJSON(_)},_setTileJSON:function(json){util.strict(json,"object");L.extend(this.options,{grids:json.grids,minZoom:json.minzoom,maxZoom:json.maxzoom,bounds:json.bounds&&util.lbounds(json.bounds)});this._tilejson=json;this._cache={};this._update();return this},getTileJSON:function(){return this._tilejson},active:function(){return!!(this._map&&this.options.grids&&this.options.grids.length)},addTo:function(map){map.addLayer(this);return this},onAdd:function(map){this._map=map;this._update();this._map.on("click",this._click,this).on("mousemove",this._move,this).on("moveend",this._update,this)},onRemove:function(){this._map.off("click",this._click,this).off("mousemove",this._move,this).off("moveend",this._update,this)},getData:function(latlng,callback){if(!this.active())return;var map=this._map,point=map.project(latlng.wrap()),tileSize=256,resolution=4,x=Math.floor(point.x/tileSize),y=Math.floor(point.y/tileSize),max=map.options.crs.scale(map.getZoom())/tileSize;x=(x+max)%max;y=(y+max)%max;this._getTile(map.getZoom(),x,y,function(grid){var gridX=Math.floor((point.x-x*tileSize)/resolution),gridY=Math.floor((point.y-y*tileSize)/resolution);callback(grid(gridX,gridY))});return this},_click:function(e){this.getData(e.latlng,L.bind(function(data){this.fire("click",{latLng:e.latlng,data:data})},this))},_move:function(e){this.getData(e.latlng,L.bind(function(data){if(data!==this._mouseOn){if(this._mouseOn){this.fire("mouseout",{latLng:e.latlng,data:this._mouseOn})}this.fire("mouseover",{latLng:e.latlng,data:data});this._mouseOn=data}else{this.fire("mousemove",{latLng:e.latlng,data:data})}},this))},_getTileURL:function(tilePoint){var urls=this.options.grids,index=(tilePoint.x+tilePoint.y)%urls.length,url=urls[index];return L.Util.template(url,tilePoint)},_update:function(){if(!this.active())return;var bounds=this._map.getPixelBounds(),z=this._map.getZoom(),tileSize=256;if(z>this.options.maxZoom||z<this.options.minZoom)return;var tileBounds=L.bounds(bounds.min.divideBy(tileSize)._floor(),bounds.max.divideBy(tileSize)._floor()),max=this._map.options.crs.scale(z)/tileSize;for(var x=tileBounds.min.x;x<=tileBounds.max.x;x++){for(var y=tileBounds.min.y;y<=tileBounds.max.y;y++){this._getTile(z,(x%max+max)%max,(y%max+max)%max)}}},_getTile:function(z,x,y,callback){var key=z+"_"+x+"_"+y,tilePoint=L.point(x,y);tilePoint.z=z;if(!this._tileShouldBeLoaded(tilePoint)){return}if(key in this._cache){if(!callback)return;if(typeof this._cache[key]==="function"){callback(this._cache[key])}else{this._cache[key].push(callback)}return}this._cache[key]=[];if(callback){this._cache[key].push(callback)}request(this._getTileURL(tilePoint),L.bind(function(err,json){var callbacks=this._cache[key];this._cache[key]=grid(json);for(var i=0;i<callbacks.length;++i){callbacks[i](this._cache[key])}},this))},_tileShouldBeLoaded:function(tilePoint){if(tilePoint.z>this.options.maxZoom||tilePoint.z<this.options.minZoom){return false}if(this.options.bounds){var tileSize=256,nwPoint=tilePoint.multiplyBy(tileSize),sePoint=nwPoint.add(new L.Point(tileSize,tileSize)),nw=this._map.unproject(nwPoint),se=this._map.unproject(sePoint),bounds=new L.LatLngBounds([nw,se]);if(!this.options.bounds.intersects(bounds)){return false}}return true}});module.exports.GridLayer=GridLayer;module.exports.gridLayer=function(_,options){return new GridLayer(_,options)}},{"./grid":12,"./load_tilejson":18,"./request":23,"./util":28}],15:[function(require,module,exports){"use strict";var InfoControl=L.Control.extend({options:{position:"bottomright",sanitizer:require("sanitize-caja")},initialize:function(options){L.setOptions(this,options);this._info={};console.warn("infoControl has been deprecated and will be removed in mapbox.js v3.0.0. Use the default attribution control instead, which is now responsive.")},onAdd:function(map){this._container=L.DomUtil.create("div","mapbox-control-info mapbox-small");this._content=L.DomUtil.create("div","map-info-container",this._container);var link=L.DomUtil.create("a","mapbox-info-toggle mapbox-icon mapbox-icon-info",this._container);link.href="#";L.DomEvent.addListener(link,"click",this._showInfo,this);L.DomEvent.disableClickPropagation(this._container);for(var i in map._layers){if(map._layers[i].getAttribution){this.addInfo(map._layers[i].getAttribution())}}map.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this);this._update();return this._container},onRemove:function(map){map.off("layeradd",this._onLayerAdd,this).off("layerremove",this._onLayerRemove,this)},addInfo:function(text){if(!text)return this;if(!this._info[text])this._info[text]=0;this._info[text]=true;return this._update()},removeInfo:function(text){if(!text)return this;if(this._info[text])this._info[text]=false;return this._update()},_showInfo:function(e){L.DomEvent.preventDefault(e);if(this._active===true)return this._hidecontent();L.DomUtil.addClass(this._container,"active");this._active=true;this._update()},_hidecontent:function(){this._content.innerHTML="";this._active=false;L.DomUtil.removeClass(this._container,"active");return},_update:function(){if(!this._map){return this}this._content.innerHTML="";var hide="none";var info=[];for(var i in this._info){if(this._info.hasOwnProperty(i)&&this._info[i]){info.push(this.options.sanitizer(i));hide="block"}}this._content.innerHTML+=info.join(" | ");this._container.style.display=hide;return this},_onLayerAdd:function(e){if(e.layer.getAttribution&&e.layer.getAttribution()){this.addInfo(e.layer.getAttribution())}else if("on"in e.layer&&e.layer.getAttribution){e.layer.on("ready",L.bind(function(){this.addInfo(e.layer.getAttribution())},this))}},_onLayerRemove:function(e){if(e.layer.getAttribution){this.removeInfo(e.layer.getAttribution())}}});module.exports.InfoControl=InfoControl;module.exports.infoControl=function(options){return new InfoControl(options)}},{"sanitize-caja":4}],16:[function(require,module,exports){window.L=require("leaflet/dist/leaflet-src")},{"leaflet/dist/leaflet-src":2}],17:[function(require,module,exports){"use strict";var LegendControl=L.Control.extend({options:{position:"bottomright",sanitizer:require("sanitize-caja")},initialize:function(options){L.setOptions(this,options);this._legends={}},onAdd:function(map){this._container=L.DomUtil.create("div","map-legends wax-legends");L.DomEvent.disableClickPropagation(this._container);this._update();return this._container},addLegend:function(text){if(!text){return this}if(!this._legends[text]){this._legends[text]=0}this._legends[text]++;return this._update()},removeLegend:function(text){if(!text){return this}if(this._legends[text])this._legends[text]--;return this._update()},_update:function(){if(!this._map){return this}this._container.innerHTML="";var hide="none";for(var i in this._legends){if(this._legends.hasOwnProperty(i)&&this._legends[i]){var div=L.DomUtil.create("div","map-legend wax-legend",this._container);div.innerHTML=this.options.sanitizer(i);hide="block"}}this._container.style.display=hide;return this}});module.exports.LegendControl=LegendControl;module.exports.legendControl=function(options){return new LegendControl(options)}},{"sanitize-caja":4}],18:[function(require,module,exports){"use strict";var request=require("./request"),url=require("./url"),util=require("./util");module.exports={_loadTileJSON:function(_){if(typeof _==="string"){_=url.tileJSON(_,this.options&&this.options.accessToken);request(_,L.bind(function(err,json){if(err){util.log("could not load TileJSON at "+_);this.fire("error",{error:err})}else if(json){this._setTileJSON(json);this.fire("ready")}},this))}else if(_&&typeof _==="object"){this._setTileJSON(_)}}}},{"./request":23,"./url":27,"./util":28}],19:[function(require,module,exports){"use strict";var util=require("./util"),tileLayer=require("./tile_layer").tileLayer,featureLayer=require("./feature_layer").featureLayer,gridLayer=require("./grid_layer").gridLayer,gridControl=require("./grid_control").gridControl,infoControl=require("./info_control").infoControl,shareControl=require("./share_control").shareControl,legendControl=require("./legend_control").legendControl,mapboxLogoControl=require("./mapbox_logo").mapboxLogoControl,feedback=require("./feedback");
function withAccessToken(options,accessToken){if(!accessToken||options.accessToken)return options;return L.extend({accessToken:accessToken},options)}var LMap=L.Map.extend({includes:[require("./load_tilejson")],options:{tileLayer:{},featureLayer:{},gridLayer:{},legendControl:{},gridControl:{},infoControl:false,shareControl:false,sanitizer:require("sanitize-caja")},_tilejson:{},initialize:function(element,_,options){L.Map.prototype.initialize.call(this,element,L.extend({},L.Map.prototype.options,options));if(this.attributionControl){this.attributionControl.setPrefix("");var compact=this.options.attributionControl.compact;if(compact||compact!==false&&this._container.offsetWidth<=640){L.DomUtil.addClass(this.attributionControl._container,"leaflet-compact-attribution")}if(compact===undefined){this.on("resize",function(){if(this._container.offsetWidth>640){L.DomUtil.removeClass(this.attributionControl._container,"leaflet-compact-attribution")}else{L.DomUtil.addClass(this.attributionControl._container,"leaflet-compact-attribution")}})}}if(this.options.tileLayer){this.tileLayer=tileLayer(undefined,withAccessToken(this.options.tileLayer,this.options.accessToken));this.addLayer(this.tileLayer)}if(this.options.featureLayer){this.featureLayer=featureLayer(undefined,withAccessToken(this.options.featureLayer,this.options.accessToken));this.addLayer(this.featureLayer)}if(this.options.gridLayer){this.gridLayer=gridLayer(undefined,withAccessToken(this.options.gridLayer,this.options.accessToken));this.addLayer(this.gridLayer)}if(this.options.gridLayer&&this.options.gridControl){this.gridControl=gridControl(this.gridLayer,this.options.gridControl);this.addControl(this.gridControl)}if(this.options.infoControl){this.infoControl=infoControl(this.options.infoControl);this.addControl(this.infoControl)}if(this.options.legendControl){this.legendControl=legendControl(this.options.legendControl);this.addControl(this.legendControl)}if(this.options.shareControl){this.shareControl=shareControl(undefined,withAccessToken(this.options.shareControl,this.options.accessToken));this.addControl(this.shareControl)}this._mapboxLogoControl=mapboxLogoControl(this.options.mapboxLogoControl);this.addControl(this._mapboxLogoControl);this._loadTileJSON(_);this.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this).on("moveend",this._updateMapFeedbackLink,this);this.whenReady(function(){feedback.on("change",this._updateMapFeedbackLink,this)});this.on("unload",function(){feedback.off("change",this._updateMapFeedbackLink,this)})},_setTileJSON:function(_){this._tilejson=_;this._initialize(_);return this},getTileJSON:function(){return this._tilejson},_initialize:function(json){if(this.tileLayer){this.tileLayer._setTileJSON(json);this._updateLayer(this.tileLayer)}if(this.featureLayer&&!this.featureLayer.getGeoJSON()&&json.data&&json.data[0]){this.featureLayer.loadURL(json.data[0])}if(this.gridLayer){this.gridLayer._setTileJSON(json);this._updateLayer(this.gridLayer)}if(this.infoControl&&json.attribution){this.infoControl.addInfo(this.options.sanitizer(json.attribution));this._updateMapFeedbackLink()}if(this.legendControl&&json.legend){this.legendControl.addLegend(json.legend)}if(this.shareControl){this.shareControl._setTileJSON(json)}this._mapboxLogoControl._setTileJSON(json);if(!this._loaded&&json.center){var zoom=this.getZoom()!==undefined?this.getZoom():json.center[2],center=L.latLng(json.center[1],json.center[0]);this.setView(center,zoom)}},_updateMapFeedbackLink:function(){if(!this._controlContainer.getElementsByClassName)return;var link=this._controlContainer.getElementsByClassName("mapbox-improve-map");if(link.length&&this._loaded){var center=this.getCenter().wrap();var tilejson=this._tilejson||{};var id=tilejson.id||"";var hash="#"+id+"/"+center.lng.toFixed(3)+"/"+center.lat.toFixed(3)+"/"+this.getZoom();for(var key in feedback.data){hash+="/"+key+"="+feedback.data[key]}for(var i=0;i<link.length;i++){link[i].hash=hash}}},_onLayerAdd:function(e){if("on"in e.layer){e.layer.on("ready",this._onLayerReady,this)}window.setTimeout(L.bind(this._updateMapFeedbackLink,this),0)},_onLayerRemove:function(e){if("on"in e.layer){e.layer.off("ready",this._onLayerReady,this)}window.setTimeout(L.bind(this._updateMapFeedbackLink,this),0)},_onLayerReady:function(e){this._updateLayer(e.target)},_updateLayer:function(layer){if(!layer.options)return;if(this.infoControl&&this._loaded){this.infoControl.addInfo(layer.options.infoControl)}if(this.attributionControl&&this._loaded&&layer.getAttribution){this.attributionControl.addAttribution(layer.getAttribution())}if(!(L.stamp(layer)in this._zoomBoundLayers)&&(layer.options.maxZoom||layer.options.minZoom)){this._zoomBoundLayers[L.stamp(layer)]=layer}this._updateMapFeedbackLink();this._updateZoomLevels()}});module.exports.Map=LMap;module.exports.map=function(element,_,options){return new LMap(element,_,options)}},{"./feature_layer":8,"./feedback":9,"./grid_control":13,"./grid_layer":14,"./info_control":15,"./legend_control":17,"./load_tilejson":18,"./mapbox_logo":21,"./share_control":24,"./tile_layer":26,"./util":28,"sanitize-caja":4}],20:[function(require,module,exports){"use strict";var geocoderControl=require("./geocoder_control"),gridControl=require("./grid_control"),featureLayer=require("./feature_layer"),legendControl=require("./legend_control"),shareControl=require("./share_control"),tileLayer=require("./tile_layer"),infoControl=require("./info_control"),map=require("./map"),gridLayer=require("./grid_layer");L.mapbox=module.exports={VERSION:require("../package.json").version,geocoder:require("./geocoder"),marker:require("./marker"),simplestyle:require("./simplestyle"),tileLayer:tileLayer.tileLayer,TileLayer:tileLayer.TileLayer,infoControl:infoControl.infoControl,InfoControl:infoControl.InfoControl,shareControl:shareControl.shareControl,ShareControl:shareControl.ShareControl,legendControl:legendControl.legendControl,LegendControl:legendControl.LegendControl,geocoderControl:geocoderControl.geocoderControl,GeocoderControl:geocoderControl.GeocoderControl,gridControl:gridControl.gridControl,GridControl:gridControl.GridControl,gridLayer:gridLayer.gridLayer,GridLayer:gridLayer.GridLayer,featureLayer:featureLayer.featureLayer,FeatureLayer:featureLayer.FeatureLayer,map:map.map,Map:map.Map,config:require("./config"),sanitize:require("sanitize-caja"),template:require("mustache").to_html,feedback:require("./feedback")};window.L.Icon.Default.imagePath=(document.location.protocol=="https:"||document.location.protocol=="http:"?"":"https:")+"//api.tiles.mapbox.com/mapbox.js/"+"v"+require("../package.json").version+"/images"},{"../package.json":6,"./config":7,"./feature_layer":8,"./feedback":9,"./geocoder":10,"./geocoder_control":11,"./grid_control":13,"./grid_layer":14,"./info_control":15,"./legend_control":17,"./map":19,"./marker":22,"./share_control":24,"./simplestyle":25,"./tile_layer":26,mustache:3,"sanitize-caja":4}],21:[function(require,module,exports){"use strict";var MapboxLogoControl=L.Control.extend({options:{position:"bottomleft"},initialize:function(options){L.setOptions(this,options)},onAdd:function(map){this._container=L.DomUtil.create("div","mapbox-logo");return this._container},_setTileJSON:function(json){if(json.mapbox_logo){L.DomUtil.addClass(this._container,"mapbox-logo-true")}}});module.exports.MapboxLogoControl=MapboxLogoControl;module.exports.mapboxLogoControl=function(options){return new MapboxLogoControl(options)}},{}],22:[function(require,module,exports){"use strict";var url=require("./url"),util=require("./util"),sanitize=require("sanitize-caja");function icon(fp,options){fp=fp||{};var sizes={small:[20,50],medium:[30,70],large:[35,90]},size=fp["marker-size"]||"medium",symbol="marker-symbol"in fp&&fp["marker-symbol"]!==""?"-"+fp["marker-symbol"]:"",color=(fp["marker-color"]||"7e7e7e").replace("#","");return L.icon({iconUrl:url("/marker/"+"pin-"+size.charAt(0)+symbol+"+"+color+(L.Browser.retina?"@2x":"")+".png",options&&options.accessToken),iconSize:sizes[size],iconAnchor:[sizes[size][0]/2,sizes[size][1]/2],popupAnchor:[0,-sizes[size][1]/2]})}function style(f,latlon,options){return L.marker(latlon,{icon:icon(f.properties,options),title:util.strip_tags(sanitize(f.properties&&f.properties.title||""))})}function createPopup(f,sanitizer){if(!f||!f.properties)return"";var popup="";if(f.properties.title){popup+='<div class="marker-title">'+f.properties.title+"</div>"}if(f.properties.description){popup+='<div class="marker-description">'+f.properties.description+"</div>"}return(sanitizer||sanitize)(popup)}module.exports={icon:icon,style:style,createPopup:createPopup}},{"./url":27,"./util":28,"sanitize-caja":4}],23:[function(require,module,exports){"use strict";var corslite=require("corslite"),strict=require("./util").strict,config=require("./config"),protocol=/^(https?:)?(?=\/\/(.|api)\.tiles\.mapbox\.com\/)/;module.exports=function(url,callback){strict(url,"string");strict(callback,"function");url=url.replace(protocol,function(match,protocol){if(!("withCredentials"in new window.XMLHttpRequest)){return document.location.protocol}else if("https:"===protocol||"https:"===document.location.protocol||config.FORCE_HTTPS){return"https:"}else{return"http:"}});return corslite(url,onload);function onload(err,resp){if(!err&&resp){resp=JSON.parse(resp.responseText)}callback(err,resp)}}},{"./config":7,"./util":28,corslite:1}],24:[function(require,module,exports){"use strict";var urlhelper=require("./url");var ShareControl=L.Control.extend({includes:[require("./load_tilejson")],options:{position:"topleft",url:""},initialize:function(_,options){L.setOptions(this,options);this._loadTileJSON(_)},_setTileJSON:function(json){this._tilejson=json},onAdd:function(map){this._map=map;var container=L.DomUtil.create("div","leaflet-control-mapbox-share leaflet-bar");var link=L.DomUtil.create("a","mapbox-share mapbox-icon mapbox-icon-share",container);link.href="#";this._modal=L.DomUtil.create("div","mapbox-modal",this._map._container);this._mask=L.DomUtil.create("div","mapbox-modal-mask",this._modal);this._content=L.DomUtil.create("div","mapbox-modal-content",this._modal);L.DomEvent.addListener(link,"click",this._shareClick,this);L.DomEvent.disableClickPropagation(container);this._map.on("mousedown",this._clickOut,this);return container},_clickOut:function(e){if(this._sharing){L.DomEvent.preventDefault(e);L.DomUtil.removeClass(this._modal,"active");this._content.innerHTML="";this._sharing=null;return}},_shareClick:function(e){L.DomEvent.stop(e);if(this._sharing)return this._clickOut(e);var tilejson=this._tilejson||this._map._tilejson||{},url=encodeURIComponent(this.options.url||tilejson.webpage||window.location),name=encodeURIComponent(tilejson.name),image=urlhelper("/"+tilejson.id+"/"+this._map.getCenter().lng+","+this._map.getCenter().lat+","+this._map.getZoom()+"/600x600.png",this.options.accessToken),embed=urlhelper("/"+tilejson.id+".html",this.options.accessToken),twitter="//twitter.com/intent/tweet?status="+name+" "+url,facebook="//www.facebook.com/sharer.php?u="+url+"&t="+encodeURIComponent(tilejson.name),pinterest="//www.pinterest.com/pin/create/button/?url="+url+"&media="+image+"&description="+tilejson.name,share=("<h3>Share this map</h3>"+"<div class='mapbox-share-buttons'><a class='mapbox-button mapbox-button-icon mapbox-icon-facebook' target='_blank' href='{{facebook}}'>Facebook</a>"+"<a class='mapbox-button mapbox-button-icon mapbox-icon-twitter' target='_blank' href='{{twitter}}'>Twitter</a>"+"<a class='mapbox-button mapbox-button-icon mapbox-icon-pinterest' target='_blank' href='{{pinterest}}'>Pinterest</a></div>").replace("{{twitter}}",twitter).replace("{{facebook}}",facebook).replace("{{pinterest}}",pinterest),embedValue='<iframe width="100%" height="500px" frameBorder="0" src="{{embed}}"></iframe>'.replace("{{embed}}",embed),embedLabel="Copy and paste this <strong>HTML code</strong> into documents to embed this map on web pages.";L.DomUtil.addClass(this._modal,"active");this._sharing=L.DomUtil.create("div","mapbox-modal-body",this._content);this._sharing.innerHTML=share;var input=L.DomUtil.create("input","mapbox-embed",this._sharing);input.type="text";input.value=embedValue;var label=L.DomUtil.create("label","mapbox-embed-description",this._sharing);label.innerHTML=embedLabel;var close=L.DomUtil.create("a","leaflet-popup-close-button",this._sharing);close.href="#";L.DomEvent.disableClickPropagation(this._sharing);L.DomEvent.addListener(close,"click",this._clickOut,this);L.DomEvent.addListener(input,"click",function(e){e.target.focus();e.target.select()})}});module.exports.ShareControl=ShareControl;module.exports.shareControl=function(_,options){return new ShareControl(_,options)}},{"./load_tilejson":18,"./url":27}],25:[function(require,module,exports){"use strict";var defaults={stroke:"#555555","stroke-width":2,"stroke-opacity":1,fill:"#555555","fill-opacity":.5};var mapping=[["stroke","color"],["stroke-width","weight"],["stroke-opacity","opacity"],["fill","fillColor"],["fill-opacity","fillOpacity"]];function fallback(a,b){var c={};for(var k in b){if(a[k]===undefined)c[k]=b[k];else c[k]=a[k]}return c}function remap(a){var d={};for(var i=0;i<mapping.length;i++){d[mapping[i][1]]=a[mapping[i][0]]}return d}function style(feature){return remap(fallback(feature.properties||{},defaults))}module.exports={style:style,defaults:defaults}},{}],26:[function(require,module,exports){"use strict";var util=require("./util");var formatPattern=/\.((?:png|jpg)\d*)(?=$|\?)/;var TileLayer=L.TileLayer.extend({includes:[require("./load_tilejson")],options:{sanitizer:require("sanitize-caja")},formats:["png","jpg","png32","png64","png128","png256","jpg70","jpg80","jpg90"],scalePrefix:"@2x.",initialize:function(_,options){L.TileLayer.prototype.initialize.call(this,undefined,options);this._tilejson={};if(options&&options.format){util.strict_oneof(options.format,this.formats)}this._loadTileJSON(_)},setFormat:function(_){util.strict(_,"string");this.options.format=_;this.redraw();return this},setUrl:null,_setTileJSON:function(json){util.strict(json,"object");this.options.format=this.options.format||json.tiles[0].match(formatPattern)[1];L.extend(this.options,{tiles:json.tiles,attribution:this.options.sanitizer(json.attribution),minZoom:json.minzoom||0,maxZoom:json.maxzoom||18,tms:json.scheme==="tms",bounds:json.bounds&&util.lbounds(json.bounds)});this._tilejson=json;this.redraw();return this},getTileJSON:function(){return this._tilejson},getTileUrl:function(tilePoint){var tiles=this.options.tiles,index=Math.floor(Math.abs(tilePoint.x+tilePoint.y)%tiles.length),url=tiles[index];var templated=L.Util.template(url,tilePoint);if(!templated){return templated}else{return templated.replace(formatPattern,(L.Browser.retina?this.scalePrefix:".")+this.options.format)}},_update:function(){if(this.options.tiles){L.TileLayer.prototype._update.call(this)}}});module.exports.TileLayer=TileLayer;module.exports.tileLayer=function(_,options){return new TileLayer(_,options)}},{"./load_tilejson":18,"./util":28,"sanitize-caja":4}],27:[function(require,module,exports){"use strict";var config=require("./config"),version=require("../package.json").version;module.exports=function(path,accessToken){accessToken=accessToken||L.mapbox.accessToken;if(!accessToken&&config.REQUIRE_ACCESS_TOKEN){throw new Error("An API access token is required to use Mapbox.js. "+"See https://www.mapbox.com/mapbox.js/api/v"+version+"/api-access-tokens/")}var url="https:"===document.location.protocol||config.FORCE_HTTPS?config.HTTPS_URL:config.HTTP_URL;url+=path;url+=url.indexOf("?")!==-1?"&access_token=":"?access_token=";if(config.REQUIRE_ACCESS_TOKEN){if(accessToken[0]==="s"){throw new Error("Use a public access token (pk.*) with Mapbox.js, not a secret access token (sk.*). "+"See https://www.mapbox.com/mapbox.js/api/v"+version+"/api-access-tokens/")}url+=accessToken}return url};module.exports.tileJSON=function(urlOrMapID,accessToken){if(urlOrMapID.indexOf("/")!==-1)return urlOrMapID;var url=module.exports("/"+urlOrMapID+".json",accessToken);if(url.indexOf("https")===0)url+="&secure";return url}},{"../package.json":6,"./config":7}],28:[function(require,module,exports){"use strict";module.exports={idUrl:function(_,t){if(_.indexOf("/")==-1)t.loadID(_);else t.loadURL(_)},log:function(_){if(typeof console==="object"&&typeof console.error==="function"){console.error(_)}},strict:function(_,type){if(typeof _!==type){throw new Error("Invalid argument: "+type+" expected")}},strict_instance:function(_,klass,name){if(!(_ instanceof klass)){throw new Error("Invalid argument: "+name+" expected")}},strict_oneof:function(_,values){if(!contains(_,values)){throw new Error("Invalid argument: "+_+" given, valid values are "+values.join(", "))}},strip_tags:function(_){return _.replace(/<[^<]+>/g,"")},lbounds:function(_){return new L.LatLngBounds([[_[1],_[0]],[_[3],_[2]]])}};function contains(item,list){if(!list||!list.length)return false;for(var i=0;i<list.length;i++){if(list[i]==item)return true}return false}},{}],"mapbox.js":[function(require,module,exports){require("./leaflet");require("./mapbox")},{"./leaflet":16,"./mapbox":20}]},{},[]);require=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var d2r=Math.PI/180,r2d=180/Math.PI;function tileToBBOX(tile){var e=tile2lon(tile[0]+1,tile[2]);var w=tile2lon(tile[0],tile[2]);var s=tile2lat(tile[1]+1,tile[2]);var n=tile2lat(tile[1],tile[2]);return[w,s,e,n]}function tileToGeoJSON(tile){var bbox=tileToBBOX(tile);var poly={type:"Polygon",coordinates:[[[bbox[0],bbox[1]],[bbox[0],bbox[3]],[bbox[2],bbox[3]],[bbox[2],bbox[1]],[bbox[0],bbox[1]]]]};return poly}function tile2lon(x,z){return x/Math.pow(2,z)*360-180}function tile2lat(y,z){var n=Math.PI-2*Math.PI*y/Math.pow(2,z);return r2d*Math.atan(.5*(Math.exp(n)-Math.exp(-n)))}function pointToTile(lon,lat,z){var latr=lat*d2r,z2=Math.pow(2,z);return[Math.floor((lon+180)/360*z2),Math.floor((1-Math.log(Math.tan(latr)+1/Math.cos(latr))/Math.PI)/2*z2),z]}function getChildren(tile){return[[tile[0]*2,tile[1]*2,tile[2]+1],[tile[0]*2+1,tile[1]*2,tile[2]+1],[tile[0]*2+1,tile[1]*2+1,tile[2]+1],[tile[0]*2,tile[1]*2+1,tile[2]+1]]}function getParent(tile){if(tile[0]%2===0&&tile[1]%2===0){return[tile[0]/2,tile[1]/2,tile[2]-1]}else if(tile[0]%2===0&&!tile[1]%2===0){return[tile[0]/2,(tile[1]-1)/2,tile[2]-1]}else if(!tile[0]%2===0&&tile[1]%2===0){return[(tile[0]-1)/2,tile[1]/2,tile[2]-1]}else{return[(tile[0]-1)/2,(tile[1]-1)/2,tile[2]-1]}}function getSiblings(tile){return getChildren(getParent(tile))}function hasSiblings(tile,tiles){var siblings=getSiblings(tile);for(var i=0;i<siblings.length;i++){if(!hasTile(tiles,siblings[i]))return false}return true}function hasTile(tiles,tile){for(var i=0;i<tiles.length;i++){if(tilesEqual(tiles[i],tile))return true}return false}function tilesEqual(tile1,tile2){return tile1[0]===tile2[0]&&tile1[1]===tile2[1]&&tile1[2]===tile2[2]}function tileToQuadkey(tile){var index="";for(var z=tile[2];z>0;z--){var b=0;var mask=1<<z-1;if((tile[0]&mask)!==0)b++;if((tile[1]&mask)!==0)b+=2;index+=b.toString()}return index}function quadkeyToTile(quadkey){var x=0;var y=0;var z=quadkey.length;for(var i=z;i>0;i--){var mask=1<<i-1;switch(quadkey[z-i]){case"0":break;case"1":x|=mask;break;case"2":y|=mask;break;case"3":x|=mask;y|=mask;break}}return[x,y,z]}function bboxToTile(bboxCoords){var min=pointToTile(bboxCoords[0],bboxCoords[1],32);var max=pointToTile(bboxCoords[2],bboxCoords[3],32);var bbox=[min[0],min[1],max[0],max[1]];var z=getBboxZoom(bbox);if(z===0)return[0,0,0];var x=bbox[0]>>>32-z;var y=bbox[1]>>>32-z;return[x,y,z]}function getBboxZoom(bbox){var MAX_ZOOM=28;for(var z=0;z<MAX_ZOOM;z++){var mask=1<<32-(z+1);if((bbox[0]&mask)!=(bbox[2]&mask)||(bbox[1]&mask)!=(bbox[3]&mask)){return z}}return MAX_ZOOM}function pointToTileFraction(lon,lat,z){var tile=pointToTile(lon,lat,z);var bbox=tileToBBOX(tile);var xTileOffset=bbox[2]-bbox[0];var xPointOffset=lon-bbox[0];var xPercentOffset=xPointOffset/xTileOffset;var yTileOffset=bbox[1]-bbox[3];var yPointOffset=lat-bbox[3];var yPercentOffset=yPointOffset/yTileOffset;return[tile[0]+xPercentOffset,tile[1]+yPercentOffset,z]}module.exports={tileToGeoJSON:tileToGeoJSON,tileToBBOX:tileToBBOX,getChildren:getChildren,getParent:getParent,getSiblings:getSiblings,hasTile:hasTile,hasSiblings:hasSiblings,tilesEqual:tilesEqual,tileToQuadkey:tileToQuadkey,quadkeyToTile:quadkeyToTile,pointToTile:pointToTile,bboxToTile:bboxToTile,pointToTileFraction:pointToTileFraction}},{}],"tile-cover":[function(require,module,exports){var tilebelt=require("tilebelt");module.exports.geojson=function(geom,limits){var locked=getLocked(geom,limits);var tileFeatures=locked.map(function(t){return{type:"Feature",geometry:tilebelt.tileToGeoJSON(t),properties:{}}});return{type:"FeatureCollection",features:tileFeatures}};module.exports.tiles=function(geom,limits){var locked=getLocked(geom,limits);return locked};module.exports.indexes=function(geom,limits){var locked=getLocked(geom,limits);return locked.map(function(tile){return tilebelt.tileToQuadkey(tile)})};function getLocked(geom,limits){var locked,i,tileHash={};if(geom.type==="Point"){locked=[tilebelt.pointToTile(geom.coordinates[0],geom.coordinates[1],limits.max_zoom)]}else if(geom.type==="MultiPoint"){var quadkeys={};locked=[];for(i=0;i<geom.coordinates.length;i++){var tile=tilebelt.pointToTile(geom.coordinates[i][0],geom.coordinates[i][1],limits.max_zoom);var quadkey=tilebelt.tileToQuadkey(tile);if(!quadkeys[quadkey]){quadkeys[quadkey]=true;locked.push(tile)}}}else if(geom.type==="LineString"){lineCover(tileHash,geom.coordinates,limits.max_zoom)}else if(geom.type==="MultiLineString"){for(i=0;i<geom.coordinates.length;i++){lineCover(tileHash,geom.coordinates[i],limits.max_zoom)}}else if(geom.type==="Polygon"){polyRingCover(tileHash,geom.coordinates,limits.max_zoom)}else if(geom.type==="MultiPolygon"){for(i=0;i<geom.coordinates.length;i++){polyRingCover(tileHash,geom.coordinates[i],limits.max_zoom)}}else{throw new Error("Geometry type not implemented")}if(!locked){if(limits.min_zoom!==limits.max_zoom){tileHash=mergeTiles(tileHash,limits)}locked=hashToArray(tileHash)}return locked}function mergeTiles(tileHash,limits){var mergedTileHash={};for(var z=limits.max_zoom;z>limits.min_zoom;z--){var keys=Object.keys(tileHash);var parentTileHash={};for(var i=0;i<keys.length;i++){var id1=+keys[i],t=fromID(id1);if(t[0]%2===0&&t[1]%2===0){var id2=toID(t[0]+1,t[1],z),id3=toID(t[0],t[1]+1,z),id4=toID(t[0]+1,t[1]+1,z);if(tileHash[id2]&&tileHash[id3]&&tileHash[id4]){tileHash[id1]=false;tileHash[id2]=false;tileHash[id3]=false;tileHash[id4]=false;var parentId=toID(t[0]/2,t[1]/2,z-1);(z-1===limits.min_zoom?mergedTileHash:parentTileHash)[parentId]=true}}}for(var i=0;i<keys.length;i++){if(tileHash[keys[i]]){mergedTileHash[+keys[i]]=true}}tileHash=parentTileHash}return mergedTileHash}function polyRingCover(tileHash,geom,max_zoom){var tiled=getTiledPoly(geom,max_zoom);var y=tiled.minY;while(y<=tiled.maxY){var intersections=[];for(var r=0;r<tiled.geom.length;r++){var ring=tiled.geom[r];for(var i=0;i<ring.length;i++){var curr=ring[i];var next=ring[i+1]||ring[0];var localMin=isLocalMin(i,ring);var localMax=isLocalMax(i,ring);var intersection=lineIntersects(0,y,1,y,curr[0],curr[1],next[0],next[1],localMin||localMax);if(intersection){intersections.push([Math.round(intersection[0]),Math.round(intersection[1]),r,i,"nonhoriz",localMin,localMax])}}}intersections.sort(compareX);for(var i=0;i<intersections.length-1;i++){if(i%2===0){var enter=intersections[i][0];var exit=intersections[i+1][0];var x=enter;while(x<=exit){tileHash[toID(x,y,max_zoom)]=true;x++}}}y++}for(var i=0;i<geom.length;i++){lineCover(tileHash,geom[i],max_zoom)}}function compareX(a,b){return a[0]-b[0]}module.exports.getTiledPoly=getTiledPoly;function getTiledPoly(geom,max_zoom,latlon){var minY=Infinity;var maxY=-Infinity;var tiled=[];var ring;var last;for(var i=0;i<geom.length;i++){tiledRing=[];last=[];for(var k=0;k<geom[i].length;k++){var next=tilebelt.pointToTile(geom[i][k][0],geom[i][k][1],max_zoom);if(latlon){var bbox=tilebelt.tileToBBOX(next,max_zoom);next=[bbox[0]+(bbox[2]-bbox[0])*.5,bbox[1]+(bbox[3]-bbox[1])*.5]}if(last[0]===next[0]&&last[1]===next[1])continue;minY=Math.min(minY,next[1]);maxY=Math.max(maxY,next[1]);tiledRing.push(next);last=next}if(tiledRing.length>=4)tiled.push(tiledRing)}return{minY:minY,maxY:maxY,geom:tiled}}module.exports.isLocalMin=isLocalMin;module.exports.isLocalMax=isLocalMax;function isLocalMin(i,ring){var mod=ring.length;var prev=ring[i];var curr=ring[(i+1)%mod];var next=ring[(i+2)%mod];if(curr[1]>=prev[1])return false;var j=(i+1)%mod;while(j!==i&&curr[1]===next[1]){next=ring[(j+2)%mod];j=(j+1)%mod}return curr[1]<next[1]}function isLocalMax(i,ring){var mod=ring.length;var prev=ring[i];var curr=ring[(i+1)%mod];var next=ring[(i+2)%mod];if(curr[1]<=prev[1])return false;var j=(i+1)%mod;while(j!==i&&curr[1]===next[1]){next=ring[(j+2)%mod];j=(j+1)%mod}return curr[1]>next[1]}function lineIntersects(line1StartX,line1StartY,line1EndX,line1EndY,line2StartX,line2StartY,line2EndX,line2EndY,localMinMax){var denominator,a,b,numerator1,numerator2,onLine1=false,onLine2=false,res=[null,null];denominator=(line2EndY-line2StartY)*(line1EndX-line1StartX)-(line2EndX-line2StartX)*(line1EndY-line1StartY);if(denominator===0){if(res[0]!==null&&res[1]!==null){return res}else{return false}}a=line1StartY-line2StartY;b=line1StartX-line2StartX;numerator1=(line2EndX-line2StartX)*a-(line2EndY-line2StartY)*b;numerator2=(line1EndX-line1StartX)*a-(line1EndY-line1StartY)*b;a=numerator1/denominator;b=numerator2/denominator;res[0]=line1StartX+a*(line1EndX-line1StartX);res[1]=line1StartY+a*(line1EndY-line1StartY);if(b>0&&b<1||res[0]===line2StartX&&res[1]===line2StartY||localMinMax&&res[0]===line2EndX&&res[1]===line2EndY){return res}else{return false}}function lineCover(tileHash,coords,max_zoom){for(var i=0;i<coords.length-1;i++){var start=tilebelt.pointToTileFraction(coords[i][0],coords[i][1],max_zoom),stop=tilebelt.pointToTileFraction(coords[i+1][0],coords[i+1][1],max_zoom),x0=start[0],y0=start[1],x1=stop[0],y1=stop[1],dx=x1-x0,dy=y1-y0,sx=dx>0?1:-1,sy=dy>0?1:-1,x=Math.floor(x0),y=Math.floor(y0),tMaxX=Math.abs(((dx>0?1:0)+x-x0)/dx),tMaxY=Math.abs(((dy>0?1:0)+y-y0)/dy),tdx=Math.abs(sx/dx),tdy=Math.abs(sy/dy);tileHash[toID(x,y,max_zoom)]=true;if(dy===0&&dx===0)continue;if(isNaN(tMaxX))tMaxX=Infinity;if(isNaN(tMaxY))tMaxY=Infinity;while(tMaxX<1||tMaxY<1){if(tMaxX<tMaxY){tMaxX+=tdx;x+=sx}else{tMaxY+=tdy;y+=sy}tileHash[toID(x,y,max_zoom)]=true}}}function hashToArray(hash){var keys=Object.keys(hash);var tiles=[];for(var i=0;i<keys.length;i++){tiles.push(fromID(+keys[i]))}return tiles}function toID(x,y,z){var dim=2*(1<<z);return(dim*y+x)*32+z}function fromID(id){var z=id%32,dim=2*(1<<z),xy=(id-z)/32,x=xy%dim,y=(xy-x)/dim%dim;return[x,y,z]}},{tilebelt:1}]},{},[]);require=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");
return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length,2);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i]&127)}return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(target_start>=target.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],3:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],4:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],5:[function(require,module,exports){var average=require("turf-average");var sum=require("turf-sum");var median=require("turf-median");var min=require("turf-min");var max=require("turf-max");var deviation=require("turf-deviation");var variance=require("turf-variance");var count=require("turf-count");var operations={};operations.average=average;operations.sum=sum;operations.median=median;operations.min=min;operations.max=max;operations.deviation=deviation;operations.variance=variance;operations.count=count;module.exports=function(polygons,points,aggregations){for(var i=0,len=aggregations.length;i<len;i++){var agg=aggregations[i],operation=agg.aggregation,unrecognizedError;if(isAggregationOperation(operation)){if(operation==="count"){polygons=operations[operation](polygons,points,agg.outField)}else{polygons=operations[operation](polygons,points,agg.inField,agg.outField)}}else{throw new Error('"'+operation+'" is not a recognized aggregation operation.')}}return polygons};function isAggregationOperation(operation){return operation==="average"||operation==="sum"||operation==="median"||operation==="min"||operation==="max"||operation==="deviation"||operation==="variance"||operation==="count"}},{"turf-average":10,"turf-count":55,"turf-deviation":57,"turf-max":90,"turf-median":91,"turf-min":95,"turf-sum":115,"turf-variance":124}],6:[function(require,module,exports){var distance=require("turf-distance");var point=require("turf-point");var bearing=require("turf-bearing");var destination=require("turf-destination");module.exports=function(line,dist,units){var coords;if(line.type==="Feature")coords=line.geometry.coordinates;else if(line.type==="LineString")coords=line.geometry.coordinates;else throw new Error("input must be a LineString Feature or Geometry");var travelled=0;for(var i=0;i<coords.length;i++){if(dist>=travelled&&i===coords.length-1)break;else if(travelled>=dist){var overshot=dist-travelled;if(!overshot)return point(coords[i]);else{var direction=bearing(point(coords[i]),point(coords[i-1]))-180;var interpolated=destination(point(coords[i]),overshot,direction,units);return interpolated}}else{travelled+=distance(point(coords[i]),point(coords[i+1]),units)}}return point(coords[coords.length-1])}},{"turf-bearing":12,"turf-destination":56,"turf-distance":59,"turf-point":101}],7:[function(require,module,exports){var geometryArea=require("geojson-area").geometry;module.exports=function(_){if(_.type==="FeatureCollection"){for(var i=0,sum=0;i<_.features.length;i++){if(_.features[i].geometry){sum+=geometryArea(_.features[i].geometry)}}return sum}else if(_.type==="Feature"){return geometryArea(_.geometry)}else{return geometryArea(_)}}},{"geojson-area":8}],8:[function(require,module,exports){var wgs84=require("wgs84");module.exports.geometry=geometry;module.exports.ring=ringArea;function geometry(_){var area=0,i;switch(_.type){case"Polygon":return polygonArea(_.coordinates);case"MultiPolygon":for(i=0;i<_.coordinates.length;i++){area+=polygonArea(_.coordinates[i])}return area;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(i=0;i<_.geometries.length;i++){area+=geometry(_.geometries[i])}return area}}function polygonArea(coords){var area=0;if(coords&&coords.length>0){area+=Math.abs(ringArea(coords[0]));for(var i=1;i<coords.length;i++){area-=Math.abs(ringArea(coords[i]))}}return area}function ringArea(coords){var area=0;if(coords.length>2){var p1,p2;for(var i=0;i<coords.length-1;i++){p1=coords[i];p2=coords[i+1];area+=rad(p2[0]-p1[0])*(2+Math.sin(rad(p1[1]))+Math.sin(rad(p2[1])))}area=area*wgs84.RADIUS*wgs84.RADIUS/2}return area}function rad(_){return _*Math.PI/180}},{wgs84:9}],9:[function(require,module,exports){module.exports.RADIUS=6378137;module.exports.FLATTENING=1/298.257223563;module.exports.POLAR_RADIUS=6356752.3142},{}],10:[function(require,module,exports){var inside=require("turf-inside");module.exports=function(polyFC,ptFC,inField,outField,done){polyFC.features.forEach(function(poly){if(!poly.properties)poly.properties={};var values=[];ptFC.features.forEach(function(pt){if(inside(pt,poly))values.push(pt.properties[inField])});poly.properties[outField]=average(values)});return polyFC};function average(values){var sum=0;for(var i=0;i<values.length;i++){sum+=values[i]}return sum/values.length}},{"turf-inside":75}],11:[function(require,module,exports){var polygon=require("turf-polygon");module.exports=function(bbox){var lowLeft=[bbox[0],bbox[1]];var topLeft=[bbox[0],bbox[3]];var topRight=[bbox[2],bbox[3]];var lowRight=[bbox[2],bbox[1]];var poly=polygon([[lowLeft,lowRight,topRight,topLeft,lowLeft]]);return poly}},{"turf-polygon":102}],12:[function(require,module,exports){module.exports=function(point1,point2){var coordinates1=point1.geometry.coordinates;var coordinates2=point2.geometry.coordinates;var lon1=toRad(coordinates1[0]);var lon2=toRad(coordinates2[0]);var lat1=toRad(coordinates1[1]);var lat2=toRad(coordinates2[1]);var a=Math.sin(lon2-lon1)*Math.cos(lat2);var b=Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1);var bearing=toDeg(Math.atan2(a,b));return bearing};function toRad(degree){return degree*Math.PI/180}function toDeg(radian){return radian*180/Math.PI}},{}],13:[function(require,module,exports){var linestring=require("turf-linestring");var Spline=require("./spline.js");module.exports=function(line,resolution,sharpness){var lineOut=linestring([]);lineOut.properties=line.properties;var pts=line.geometry.coordinates.map(function(pt){return{x:pt[0],y:pt[1]}});var spline=new Spline({points:pts,duration:resolution,sharpness:sharpness});for(var i=0;i<spline.duration;i+=10){var pos=spline.pos(i);if(Math.floor(i/100)%2===0){lineOut.geometry.coordinates.push([pos.x,pos.y])}}return lineOut}},{"./spline.js":14,"turf-linestring":89}],14:[function(require,module,exports){var Spline=function(options){this.points=options.points||[];this.duration=options.duration||1e4;this.sharpness=options.sharpness||.85;this.centers=[];this.controls=[];this.stepLength=options.stepLength||60;this.length=this.points.length;this.delay=0;for(var i=0;i<this.length;i++)this.points[i].z=this.points[i].z||0;for(var i=0;i<this.length-1;i++){var p1=this.points[i];var p2=this.points[i+1];this.centers.push({x:(p1.x+p2.x)/2,y:(p1.y+p2.y)/2,z:(p1.z+p2.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var i=0;i<this.centers.length-1;i++){var p1=this.centers[i];var p2=this.centers[i+1];var dx=this.points[i+1].x-(this.centers[i].x+this.centers[i+1].x)/2;var dy=this.points[i+1].y-(this.centers[i].y+this.centers[i+1].y)/2;var dz=this.points[i+1].z-(this.centers[i].y+this.centers[i+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[i+1].x+this.sharpness*(this.centers[i].x+dx),y:(1-this.sharpness)*this.points[i+1].y+this.sharpness*(this.centers[i].y+dy),z:(1-this.sharpness)*this.points[i+1].z+this.sharpness*(this.centers[i].z+dz)},{x:(1-this.sharpness)*this.points[i+1].x+this.sharpness*(this.centers[i+1].x+dx),y:(1-this.sharpness)*this.points[i+1].y+this.sharpness*(this.centers[i+1].y+dy),z:(1-this.sharpness)*this.points[i+1].z+this.sharpness*(this.centers[i+1].z+dz)}])}this.controls.push([this.points[this.length-1],this.points[this.length-1]]);this.steps=this.cacheSteps(this.stepLength);return this};Spline.prototype.cacheSteps=function(mindist){var steps=[];var laststep=this.pos(0);steps.push(0);for(var t=0;t<this.duration;t+=10){var step=this.pos(t);var dist=Math.sqrt((step.x-laststep.x)*(step.x-laststep.x)+(step.y-laststep.y)*(step.y-laststep.y)+(step.z-laststep.z)*(step.z-laststep.z));if(dist>mindist){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.pos=function(time){function bezier(t,p1,c1,c2,p2){var B=function(t){var t2=t*t,t3=t2*t;return[t3,3*t2*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)];
};var b=B(t);var pos={x:p2.x*b[0]+c2.x*b[1]+c1.x*b[2]+p1.x*b[3],y:p2.y*b[0]+c2.y*b[1]+c1.y*b[2]+p1.y*b[3],z:p2.z*b[0]+c2.z*b[1]+c1.z*b[2]+p1.z*b[3]};return pos}var t=time-this.delay;if(t<0)t=0;if(t>this.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])};module.exports=Spline},{}],15:[function(require,module,exports){var featurecollection=require("turf-featurecollection");var polygon=require("turf-polygon");var combine=require("turf-combine");var jsts=require("jsts");module.exports=function(feature,radius,units){var buffered;switch(units){case"miles":radius=radius/69.047;break;case"feet":radius=radius/364568;break;case"kilometers":radius=radius/111.12;break;case"meters":radius=radius/111120;break;case"degrees":break}if(feature.type==="FeatureCollection"){var multi=combine(feature);multi.properties={};buffered=bufferOp(multi,radius);return buffered}else{buffered=bufferOp(feature,radius);return buffered}};var bufferOp=function(feature,radius){var reader=new jsts.io.GeoJSONReader;var geom=reader.read(JSON.stringify(feature.geometry));var buffered=geom.buffer(radius);var parser=new jsts.io.GeoJSONParser;buffered=parser.write(buffered);if(buffered.type==="MultiPolygon"){buffered={type:"Feature",geometry:buffered,properties:{}};buffered=featurecollection([buffered])}else{buffered=featurecollection([polygon(buffered.coordinates)])}return buffered}},{jsts:16,"turf-combine":23,"turf-featurecollection":71,"turf-polygon":102}],16:[function(require,module,exports){require("javascript.util");var jsts=require("./lib/jsts");module.exports=jsts},{"./lib/jsts":17,"javascript.util":19}],17:[function(require,module,exports){jsts={version:"0.15.0",algorithm:{distance:{},locate:{}},error:{},geom:{util:{}},geomgraph:{index:{}},index:{bintree:{},chain:{},kdtree:{},quadtree:{},strtree:{}},io:{},noding:{snapround:{}},operation:{buffer:{},distance:{},overlay:{snap:{}},polygonize:{},predicate:{},relate:{},union:{},valid:{}},planargraph:{},simplify:{},triangulate:{quadedge:{}},util:{}};if(typeof String.prototype.trim!=="function"){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}jsts.abstractFunc=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.error={};jsts.error.IllegalArgumentError=function(message){this.name="IllegalArgumentError";this.message=message};jsts.error.IllegalArgumentError.prototype=new Error;jsts.error.TopologyError=function(message,pt){this.name="TopologyError";this.message=pt?message+" [ "+pt+" ]":message};jsts.error.TopologyError.prototype=new Error;jsts.error.AbstractMethodInvocationError=function(){this.name="AbstractMethodInvocationError";this.message="Abstract method called, should be implemented in subclass."};jsts.error.AbstractMethodInvocationError.prototype=new Error;jsts.error.NotImplementedError=function(){this.name="NotImplementedError";this.message="This method has not yet been implemented."};jsts.error.NotImplementedError.prototype=new Error;jsts.error.NotRepresentableError=function(message){this.name="NotRepresentableError";this.message=message};jsts.error.NotRepresentableError.prototype=new Error;jsts.error.LocateFailureError=function(message){this.name="LocateFailureError";this.message=message};jsts.error.LocateFailureError.prototype=new Error;if(typeof module!=="undefined")module.exports=jsts;jsts.geom.GeometryFilter=function(){};jsts.geom.GeometryFilter.prototype.filter=function(geom){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.util.PolygonExtracter=function(comps){this.comps=comps};jsts.geom.util.PolygonExtracter.prototype=new jsts.geom.GeometryFilter;jsts.geom.util.PolygonExtracter.prototype.comps=null;jsts.geom.util.PolygonExtracter.getPolygons=function(geom,list){if(list===undefined){list=[]}if(geom instanceof jsts.geom.Polygon){list.push(geom)}else if(geom instanceof jsts.geom.GeometryCollection){geom.apply(new jsts.geom.util.PolygonExtracter(list))}return list};jsts.geom.util.PolygonExtracter.prototype.filter=function(geom){if(geom instanceof jsts.geom.Polygon)this.comps.push(geom)};jsts.io.WKTParser=function(geometryFactory){this.geometryFactory=geometryFactory||new jsts.geom.GeometryFactory;this.regExes={typeStr:/^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,emptyTypeStr:/^\s*(\w+)\s*EMPTY\s*$/,spaces:/\s+/,parenComma:/\)\s*,\s*\(/,doubleParenComma:/\)\s*\)\s*,\s*\(\s*\(/,trimParens:/^\s*\(?(.*?)\)?\s*$/}};jsts.io.WKTParser.prototype.read=function(wkt){var geometry,type,str;wkt=wkt.replace(/[\n\r]/g," ");var matches=this.regExes.typeStr.exec(wkt);if(wkt.search("EMPTY")!==-1){matches=this.regExes.emptyTypeStr.exec(wkt);matches[2]=undefined}if(matches){type=matches[1].toLowerCase();str=matches[2];if(this.parse[type]){geometry=this.parse[type].apply(this,[str])}}if(geometry===undefined)throw new Error("Could not parse WKT "+wkt);return geometry};jsts.io.WKTParser.prototype.write=function(geometry){return this.extractGeometry(geometry)};jsts.io.WKTParser.prototype.extractGeometry=function(geometry){var type=geometry.CLASS_NAME.split(".")[2].toLowerCase();if(!this.extract[type]){return null}var wktType=type.toUpperCase();var data;if(geometry.isEmpty()){data=wktType+" EMPTY"}else{data=wktType+"("+this.extract[type].apply(this,[geometry])+")"}return data};jsts.io.WKTParser.prototype.extract={coordinate:function(coordinate){return coordinate.x+" "+coordinate.y},point:function(point){return point.coordinate.x+" "+point.coordinate.y},multipoint:function(multipoint){var array=[];for(var i=0,len=multipoint.geometries.length;i<len;++i){array.push("("+this.extract.point.apply(this,[multipoint.geometries[i]])+")")}return array.join(",")},linestring:function(linestring){var array=[];for(var i=0,len=linestring.points.length;i<len;++i){array.push(this.extract.coordinate.apply(this,[linestring.points[i]]))}return array.join(",")},multilinestring:function(multilinestring){var array=[];for(var i=0,len=multilinestring.geometries.length;i<len;++i){array.push("("+this.extract.linestring.apply(this,[multilinestring.geometries[i]])+")")}return array.join(",")},polygon:function(polygon){var array=[];array.push("("+this.extract.linestring.apply(this,[polygon.shell])+")");for(var i=0,len=polygon.holes.length;i<len;++i){array.push("("+this.extract.linestring.apply(this,[polygon.holes[i]])+")")}return array.join(",")},multipolygon:function(multipolygon){var array=[];for(var i=0,len=multipolygon.geometries.length;i<len;++i){array.push("("+this.extract.polygon.apply(this,[multipolygon.geometries[i]])+")")}return array.join(",")},geometrycollection:function(collection){var array=[];for(var i=0,len=collection.geometries.length;i<len;++i){array.push(this.extractGeometry.apply(this,[collection.geometries[i]]))}return array.join(",")}};jsts.io.WKTParser.prototype.parse={point:function(str){if(str===undefined){return this.geometryFactory.createPoint(null)}var coords=str.trim().split(this.regExes.spaces);return this.geometryFactory.createPoint(new jsts.geom.Coordinate(coords[0],coords[1]))},multipoint:function(str){if(str===undefined){return this.geometryFactory.createMultiPoint(null)}var point;var points=str.trim().split(",");var components=[];for(var i=0,len=points.length;i<len;++i){point=points[i].replace(this.regExes.trimParens,"$1");components.push(this.parse.point.apply(this,[point]))}return this.geometryFactory.createMultiPoint(components)},linestring:function(str){if(str===undefined){return this.geometryFactory.createLineString(null)}var points=str.trim().split(",");var components=[];var coords;for(var i=0,len=points.length;i<len;++i){coords=points[i].trim().split(this.regExes.spaces);components.push(new jsts.geom.Coordinate(coords[0],coords[1]))}return this.geometryFactory.createLineString(components)},linearring:function(str){if(str===undefined){return this.geometryFactory.createLinearRing(null)}var points=str.trim().split(",");var components=[];var coords;for(var i=0,len=points.length;i<len;++i){coords=points[i].trim().split(this.regExes.spaces);components.push(new jsts.geom.Coordinate(coords[0],coords[1]))}return this.geometryFactory.createLinearRing(components)},multilinestring:function(str){if(str===undefined){return this.geometryFactory.createMultiLineString(null)}var line;var lines=str.trim().split(this.regExes.parenComma);var components=[];for(var i=0,len=lines.length;i<len;++i){line=lines[i].replace(this.regExes.trimParens,"$1");components.push(this.parse.linestring.apply(this,[line]))}return this.geometryFactory.createMultiLineString(components)},polygon:function(str){if(str===undefined){return this.geometryFactory.createPolygon(null)}var ring,linestring,linearring;var rings=str.trim().split(this.regExes.parenComma);var shell;var holes=[];for(var i=0,len=rings.length;i<len;++i){ring=rings[i].replace(this.regExes.trimParens,"$1");linestring=this.parse.linestring.apply(this,[ring]);linearring=this.geometryFactory.createLinearRing(linestring.points);if(i===0){shell=linearring}else{holes.push(linearring)}}return this.geometryFactory.createPolygon(shell,holes)},multipolygon:function(str){if(str===undefined){return this.geometryFactory.createMultiPolygon(null)}var polygon;var polygons=str.trim().split(this.regExes.doubleParenComma);var components=[];for(var i=0,len=polygons.length;i<len;++i){polygon=polygons[i].replace(this.regExes.trimParens,"$1");components.push(this.parse.polygon.apply(this,[polygon]))}return this.geometryFactory.createMultiPolygon(components)},geometrycollection:function(str){if(str===undefined){return this.geometryFactory.createGeometryCollection(null)}str=str.replace(/,\s*([A-Za-z])/g,"|$1");var wktArray=str.trim().split("|");var components=[];for(var i=0,len=wktArray.length;i<len;++i){components.push(jsts.io.WKTParser.prototype.read.apply(this,[wktArray[i]]))}return this.geometryFactory.createGeometryCollection(components)}};jsts.index.ItemVisitor=function(){};jsts.index.ItemVisitor.prototype.visitItem=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.algorithm.CGAlgorithms=function(){};jsts.algorithm.CGAlgorithms.CLOCKWISE=-1;jsts.algorithm.CGAlgorithms.RIGHT=jsts.algorithm.CGAlgorithms.CLOCKWISE;jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE=1;jsts.algorithm.CGAlgorithms.LEFT=jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE;jsts.algorithm.CGAlgorithms.COLLINEAR=0;jsts.algorithm.CGAlgorithms.STRAIGHT=jsts.algorithm.CGAlgorithms.COLLINEAR;jsts.algorithm.CGAlgorithms.orientationIndex=function(p1,p2,q){var dx1,dy1,dx2,dy2;dx1=p2.x-p1.x;dy1=p2.y-p1.y;dx2=q.x-p2.x;dy2=q.y-p2.y;return jsts.algorithm.RobustDeterminant.signOfDet2x2(dx1,dy1,dx2,dy2)};jsts.algorithm.CGAlgorithms.isPointInRing=function(p,ring){return jsts.algorithm.CGAlgorithms.locatePointInRing(p,ring)!==jsts.geom.Location.EXTERIOR};jsts.algorithm.CGAlgorithms.locatePointInRing=function(p,ring){return jsts.algorithm.RayCrossingCounter.locatePointInRing(p,ring)};jsts.algorithm.CGAlgorithms.isOnLine=function(p,pt){var lineIntersector,i,il,p0,p1;lineIntersector=new jsts.algorithm.RobustLineIntersector;for(i=1,il=pt.length;i<il;i++){p0=pt[i-1];p1=pt[i];lineIntersector.computeIntersection(p,p0,p1);if(lineIntersector.hasIntersection()){return true}}return false};jsts.algorithm.CGAlgorithms.isCCW=function(ring){var nPts,hiPt,hiIndex,p,iPrev,iNext,prev,next,i,disc,isCCW;nPts=ring.length-1;if(nPts<3){throw new jsts.IllegalArgumentError("Ring has fewer than 3 points, so orientation cannot be determined")}hiPt=ring[0];hiIndex=0;i=1;for(i;i<=nPts;i++){p=ring[i];if(p.y>hiPt.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;i<il;i++){dist=jsts.algorithm.CGAlgorithms.distancePointLine(p,line[i],line[i+1]);if(dist<minDistance){minDistance=dist}}return minDistance};jsts.algorithm.CGAlgorithms.distanceLineLine=function(A,B,C,D){if(A.equals(B)){return jsts.algorithm.CGAlgorithms.distancePointLine(A,C,D)}if(C.equals(D)){return jsts.algorithm.CGAlgorithms.distancePointLine(D,A,B)}var r_top,r_bot,s_top,s_bot,s,r;r_top=(A.y-C.y)*(D.x-C.x)-(A.x-C.x)*(D.y-C.y);r_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);s_top=(A.y-C.y)*(B.x-A.x)-(A.x-C.x)*(B.y-A.y);s_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);if(r_bot===0||s_bot===0){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))))}s=s_top/s_bot;r=r_top/r_bot;if(r<0||r>1||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;i<il;i++){bx=ring[i].x;by=ring[i].y;cx=ring[i+1].x;cy=ring[i+1].y;sum+=(bx+cx)*(cy-by)}return-sum/2};jsts.algorithm.CGAlgorithms.signedArea=function(ring){var n,sum,p,bx,by,i,cx,cy;n=ring.length;if(n<3){return 0}sum=0;p=ring[0];bx=p.x;by=p.y;for(i=1;i<n;i++){p=ring[i];cx=p.x;cy=p.y;sum+=(bx+cx)*(cy-by);bx=cx;by=cy}return-sum/2};jsts.algorithm.CGAlgorithms.computeLength=function(pts){var n=pts.length,len,x0,y0,x1,y1,dx,dy,p,i,il;if(n<=1){return 0}len=0;p=pts[0];x0=p.x;y0=p.y;i=1,il=n;for(i;i<n;i++){p=pts[i];x1=p.x;y1=p.y;dx=x1-x0;dy=y1-y0;len+=Math.sqrt(dx*dx+dy*dy);x0=x1;y0=y1}return len};jsts.algorithm.CGAlgorithms.length=function(){};jsts.algorithm.Angle=function(){};jsts.algorithm.Angle.PI_TIMES_2=2*Math.PI;jsts.algorithm.Angle.PI_OVER_2=Math.PI/2;jsts.algorithm.Angle.PI_OVER_4=Math.PI/4;jsts.algorithm.Angle.COUNTERCLOCKWISE=jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE;jsts.algorithm.Angle.CLOCKWISE=jsts.algorithm.CGAlgorithms.CLOCKWISE;jsts.algorithm.Angle.NONE=jsts.algorithm.CGAlgorithms.COLLINEAR;jsts.algorithm.Angle.toDegrees=function(radians){return radians*180/Math.PI};jsts.algorithm.Angle.toRadians=function(angleDegrees){return angleDegrees*Math.PI/180};jsts.algorithm.Angle.angle=function(){if(arguments.length===1){return jsts.algorithm.Angle.angleFromOrigo(arguments[0])}else{return jsts.algorithm.Angle.angleBetweenCoords(arguments[0],arguments[1])}};jsts.algorithm.Angle.angleBetweenCoords=function(p0,p1){var dx,dy;dx=p1.x-p0.x;dy=p1.y-p0.y;return Math.atan2(dy,dx)};jsts.algorithm.Angle.angleFromOrigo=function(p){return Math.atan2(p.y,p.x)};jsts.algorithm.Angle.isAcute=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.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(ang1<ang2){delAngle=ang2-ang1}else{delAngle=ang1-ang2}if(delAngle>Math.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;i<geoms.length;i++){var g=geoms[i];jsts.geom.util.LinearComponentExtracter.getLines3(g,lines)}return lines};jsts.geom.util.LinearComponentExtracter.getLines2=function(geoms,lines,forceToLineString){for(var i=0;i<geoms.length;i++){var g=geoms[i];jsts.geom.util.LinearComponentExtracter.getLines4(g,lines,forceToLineString)}return lines};jsts.geom.util.LinearComponentExtracter.getLines3=function(geom,lines){if(geom instanceof LineString){lines.add(geom)}else{geom.apply(new jsts.geom.util.LinearComponentExtracter(lines))}return lines};jsts.geom.util.LinearComponentExtracter.getLines4=function(geom,lines,forceToLineString){geom.apply(new jsts.geom.util.LinearComponentExtracter(lines,forceToLineString));return lines};jsts.geom.util.LinearComponentExtracter.getLines5=function(geom){return jsts.geom.util.LinearComponentExtracter.getLines6(geom,false)};jsts.geom.util.LinearComponentExtracter.getLines6=function(geom,forceToLineString){var lines=[];geom.apply(new jsts.geom.util.LinearComponentExtracter(lines,forceToLineString));return lines};jsts.geom.util.LinearComponentExtracter.prototype.setForceToLineString=function(isForcedToLineString){this.isForcedToLineString=isForcedToLineString};jsts.geom.util.LinearComponentExtracter.prototype.filter=function(geom){if(this.isForcedToLineString&&geom instanceof jsts.geom.LinearRing){var line=geom.getFactory().createLineString(geom.getCoordinateSequence());this.lines.push(line);return}if(geom instanceof jsts.geom.LineString||geom instanceof jsts.geom.LinearRing)this.lines.push(geom)};jsts.geom.Location=function(){};jsts.geom.Location.INTERIOR=0;jsts.geom.Location.BOUNDARY=1;jsts.geom.Location.EXTERIOR=2;jsts.geom.Location.NONE=-1;jsts.geom.Location.toLocationSymbol=function(locationValue){switch(locationValue){case jsts.geom.Location.EXTERIOR:return"e";case jsts.geom.Location.BOUNDARY:return"b";case jsts.geom.Location.INTERIOR:return"i";case jsts.geom.Location.NONE:return"-"}throw new jsts.IllegalArgumentError("Unknown location value: "+locationValue)};(function(){jsts.io.GeoJSONReader=function(geometryFactory){this.geometryFactory=geometryFactory||new jsts.geom.GeometryFactory;this.precisionModel=this.geometryFactory.getPrecisionModel();this.parser=new jsts.io.GeoJSONParser(this.geometryFactory)};jsts.io.GeoJSONReader.prototype.read=function(geoJson){var geometry=this.parser.read(geoJson);if(this.precisionModel.getType()===jsts.geom.PrecisionModel.FIXED){this.reducePrecision(geometry)}return geometry};jsts.io.GeoJSONReader.prototype.reducePrecision=function(geometry){var i,len;if(geometry.coordinate){this.precisionModel.makePrecise(geometry.coordinate)}else if(geometry.points){for(i=0,len=geometry.points.length;i<len;i++){this.precisionModel.makePrecise(geometry.points[i])}}else if(geometry.geometries){for(i=0,len=geometry.geometries.length;i<len;i++){this.reducePrecision(geometry.geometries[i])}}}})();jsts.geom.Geometry=function(factory){this.factory=factory};jsts.geom.Geometry.prototype.envelope=null;jsts.geom.Geometry.prototype.factory=null;jsts.geom.Geometry.prototype.getGeometryType=function(){return"Geometry"};jsts.geom.Geometry.hasNonEmptyElements=function(geometries){var i;for(i=0;i<geometries.length;i++){if(!geometries[i].isEmpty()){return true}}return false};jsts.geom.Geometry.hasNullElements=function(array){var i;for(i=0;i<array.length;i++){if(array[i]===null){return true}}return false};jsts.geom.Geometry.prototype.getFactory=function(){if(this.factory===null||this.factory===undefined){this.factory=new jsts.geom.GeometryFactory}return this.factory};jsts.geom.Geometry.prototype.getNumGeometries=function(){return 1};jsts.geom.Geometry.prototype.getGeometryN=function(n){return this};jsts.geom.Geometry.prototype.getPrecisionModel=function(){return this.getFactory().getPrecisionModel()};jsts.geom.Geometry.prototype.getCoordinate=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.getCoordinates=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.getNumPoints=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.isSimple=function(){this.checkNotGeometryCollection(this);var op=new jsts.operation.IsSimpleOp(this);return op.isSimple()};jsts.geom.Geometry.prototype.isValid=function(){var isValidOp=new jsts.operation.valid.IsValidOp(this);return isValidOp.isValid()};jsts.geom.Geometry.prototype.isEmpty=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.geom.Geometry.prototype.distance=function(g){return jsts.operation.distance.DistanceOp.distance(this,g)};jsts.geom.Geometry.prototype.isWithinDistance=function(geom,distance){var envDist=this.getEnvelopeInternal().distance(geom.getEnvelopeInternal());if(envDist>distance){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 jsts.operation.predicate.RectangleIntersects.intersects(this,g)}if(g.isRectangle()){return jsts.operation.predicate.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 jsts.operation.predicate.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;i<sortedClasses.length;i++){if(this instanceof sortedClasses[i])return i}jsts.util.Assert.shouldNeverReachHere("Class not supported: "+this);return-1};jsts.geom.Geometry.prototype.toString=function(){return(new jsts.io.WKTWriter).write(this)};jsts.geom.Geometry.prototype.createPointFromInternalCoord=function(coord,exemplar){exemplar.getPrecisionModel().makePrecise(coord);return exemplar.getFactory().createPoint(coord)};(function(){jsts.geom.Coordinate=function(x,y){if(typeof x==="number"){this.x=x;this.y=y}else if(x instanceof jsts.geom.Coordinate){this.x=parseFloat(x.x);this.y=parseFloat(x.y)}else if(x===undefined||x===null){this.x=0;this.y=0}else if(typeof x==="string"){this.x=parseFloat(x);this.y=parseFloat(y)}};jsts.geom.Coordinate.prototype.setCoordinate=function(other){this.x=other.x;this.y=other.y};jsts.geom.Coordinate.prototype.clone=function(){return new jsts.geom.Coordinate(this.x,this.y)};jsts.geom.Coordinate.prototype.distance=function(p){var dx=this.x-p.x;var dy=this.y-p.y;return Math.sqrt(dx*dx+dy*dy)};jsts.geom.Coordinate.prototype.equals2D=function(other){if(this.x!==other.x){return false}if(this.y!==other.y){return false}return true};jsts.geom.Coordinate.prototype.equals=function(other){if(!other instanceof jsts.geom.Coordinate||other===undefined){return false}return this.equals2D(other)};jsts.geom.Coordinate.prototype.compareTo=function(other){if(this.x<other.x){return-1}if(this.x>other.x){return 1}if(this.y<other.y){return-1}if(this.y>other.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(x1<x2){this.minx=x1;this.maxx=x2}else{this.minx=x2;this.maxx=x1}if(y1<y2){this.miny=y1;this.maxy=y2}else{this.miny=y2;this.maxy=y1}};jsts.geom.Envelope.prototype.initFromCoordinates=function(p1,p2){this.initFromValues(p1.x,p2.x,p1.y,p2.y)};jsts.geom.Envelope.prototype.initFromCoordinate=function(p){this.initFromValues(p.x,p.x,p.y,p.y)};jsts.geom.Envelope.prototype.initFromEnvelope=function(env){this.minx=env.minx;this.maxx=env.maxx;this.miny=env.miny;this.maxy=env.maxy};jsts.geom.Envelope.prototype.setToNull=function(){this.minx=0;this.maxx=-1;this.miny=0;this.maxy=-1};jsts.geom.Envelope.prototype.isNull=function(){return this.maxx<this.minx};jsts.geom.Envelope.prototype.getHeight=function(){if(this.isNull()){return 0}return this.maxy-this.miny};jsts.geom.Envelope.prototype.getWidth=function(){if(this.isNull()){return 0}return this.maxx-this.minx};jsts.geom.Envelope.prototype.getMinX=function(){return this.minx};jsts.geom.Envelope.prototype.getMaxX=function(){return this.maxx};jsts.geom.Envelope.prototype.getMinY=function(){return this.miny};jsts.geom.Envelope.prototype.getMaxY=function(){return this.maxy};jsts.geom.Envelope.prototype.getArea=function(){return this.getWidth()*this.getHeight()};jsts.geom.Envelope.prototype.expandToInclude=function(){if(arguments[0]instanceof jsts.geom.Coordinate){this.expandToIncludeCoordinate(arguments[0])}else if(arguments[0]instanceof jsts.geom.Envelope){this.expandToIncludeEnvelope(arguments[0])}else{this.expandToIncludeValues(arguments[0],arguments[1])}};jsts.geom.Envelope.prototype.expandToIncludeCoordinate=function(p){this.expandToIncludeValues(p.x,p.y)};jsts.geom.Envelope.prototype.expandToIncludeValues=function(x,y){if(this.isNull()){this.minx=x;this.maxx=x;this.miny=y;this.maxy=y}else{if(x<this.minx){this.minx=x}if(x>this.maxx){this.maxx=x}if(y<this.miny){this.miny=y}if(y>this.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.minx<this.minx){this.minx=other.minx}if(other.maxx>this.maxx){this.maxx=other.maxx}if(other.miny<this.miny){this.miny=other.miny}if(other.maxy>this.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.maxx<env.maxx?this.maxx:env.maxx;var intMaxY=this.maxy<env.maxy?this.maxy:env.maxy;return new jsts.geom.Envelope(intMinX,intMaxX,intMinY,intMaxY)};jsts.geom.Envelope.prototype.intersects=function(){if(arguments[0]instanceof jsts.geom.Envelope){return this.intersectsEnvelope(arguments[0])}else if(arguments[0]instanceof jsts.geom.Coordinate){return this.intersectsCoordinate(arguments[0])}else{return this.intersectsValues(arguments[0],arguments[1])}};jsts.geom.Envelope.prototype.intersectsEnvelope=function(other){if(this.isNull()||other.isNull()){return false}var result=!(other.minx>this.maxx||other.maxx<this.minx||other.miny>this.maxy||other.maxy<this.miny);return result};jsts.geom.Envelope.prototype.intersectsCoordinate=function(p){return this.intersectsValues(p.x,p.y)};jsts.geom.Envelope.prototype.intersectsValues=function(x,y){if(this.isNull()){return false}return!(x>this.maxx||x<this.minx||y>this.maxy||y<this.miny)};jsts.geom.Envelope.prototype.contains=function(){if(arguments[0]instanceof jsts.geom.Envelope){return this.containsEnvelope(arguments[0])}else if(arguments[0]instanceof jsts.geom.Coordinate){return this.containsCoordinate(arguments[0])}else{return this.containsValues(arguments[0],arguments[1])}};jsts.geom.Envelope.prototype.containsEnvelope=function(other){return this.coversEnvelope(other)};jsts.geom.Envelope.prototype.containsCoordinate=function(p){return this.coversCoordinate(p)};jsts.geom.Envelope.prototype.containsValues=function(x,y){return this.coversValues(x,y)};jsts.geom.Envelope.prototype.covers=function(){if(arguments[0]instanceof jsts.geom.Envelope){return this.coversEnvelope(arguments[0])}else if(arguments[0]instanceof jsts.geom.Coordinate){return this.coversCoordinate(arguments[0])}else{return this.coversValues(arguments[0],arguments[1])}};jsts.geom.Envelope.prototype.coversValues=function(x,y){if(this.isNull()){return false}return x>=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.maxx<env.minx){dx=env.minx-this.maxx}if(this.minx>env.maxx){dx=this.minx-env.maxx}var dy=0;if(this.maxy<env.miny){dy=env.miny-this.maxy}if(this.miny>env.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.x<p2.x?p1.x:p2.x;var xc2=p1.x>p2.x?p1.x:p2.x;var yc1=p1.y<p2.y?p1.y:p2.y;var yc2=p1.y>p2.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(maxp<minq){return false}minq=Math.min(q1.y,q2.y);maxq=Math.max(q1.y,q2.y);minp=Math.min(p1.y,p2.y);maxp=Math.max(p1.y,p2.y);if(minp>maxq){return false}if(maxp<minq){return false}return true};jsts.geom.Envelope.prototype.clone=function(){return new jsts.geom.Envelope(this.minx,this.maxx,this.miny,this.maxy)};jsts.geom.util.GeometryCombiner=function(geoms){this.geomFactory=jsts.geom.util.GeometryCombiner.extractFactory(geoms);this.inputGeoms=geoms};jsts.geom.util.GeometryCombiner.combine=function(geoms){if(arguments.length>1)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;i<geom.getNumGeometries();i++){var elemGeom=geom.getGeometryN(i);if(this.skipEmpty&&elemGeom.isEmpty()){continue}elems.add(elemGeom)}};jsts.geom.PrecisionModel=function(modelType){if(typeof modelType==="number"){this.modelType=jsts.geom.PrecisionModel.FIXED;this.scale=modelType;return}this.modelType=modelType||jsts.geom.PrecisionModel.FLOATING;if(this.modelType===jsts.geom.PrecisionModel.FIXED){this.scale=1}};jsts.geom.PrecisionModel.FLOATING="FLOATING";jsts.geom.PrecisionModel.FIXED="FIXED";jsts.geom.PrecisionModel.FLOATING_SINGLE="FLOATING_SINGLE";jsts.geom.PrecisionModel.prototype.scale=null;jsts.geom.PrecisionModel.prototype.modelType=null;jsts.geom.PrecisionModel.prototype.isFloating=function(){return this.modelType===jsts.geom.PrecisionModel.FLOATING||this.modelType===jsts.geom.PrecisionModel.FLOATING_SINLGE};jsts.geom.PrecisionModel.prototype.getScale=function(){return this.scale};jsts.geom.PrecisionModel.prototype.getType=function(){return this.modelType};jsts.geom.PrecisionModel.prototype.equals=function(other){return true;if(!(other instanceof jsts.geom.PrecisionModel)){return false}var otherPrecisionModel=other;return this.modelType===otherPrecisionModel.modelType&&this.scale===otherPrecisionModel.scale};jsts.geom.PrecisionModel.prototype.makePrecise=function(val){if(val instanceof jsts.geom.Coordinate){this.makePrecise2(val);return}if(isNaN(val))return val;if(this.modelType===jsts.geom.PrecisionModel.FIXED){return Math.round(val*this.scale)/this.scale}return val};jsts.geom.PrecisionModel.prototype.makePrecise2=function(coord){if(this.modelType===jsts.geom.PrecisionModel.FLOATING)return;coord.x=this.makePrecise(coord.x);coord.y=this.makePrecise(coord.y)};jsts.geom.PrecisionModel.prototype.compareTo=function(o){var other=o;return 0};jsts.geom.CoordinateFilter=function(){};jsts.geom.CoordinateFilter.prototype.filter=function(coord){throw new jsts.error.AbstractMethodInvocationError};jsts.simplify.DouglasPeuckerLineSimplifier=function(pts){this.pts=pts;this.seg=new jsts.geom.LineSegment};jsts.simplify.DouglasPeuckerLineSimplifier.prototype.pts=null;jsts.simplify.DouglasPeuckerLineSimplifier.prototype.usePt=null;jsts.simplify.DouglasPeuckerLineSimplifier.prototype.distanceTolerance=null;jsts.simplify.DouglasPeuckerLineSimplifier.simplify=function(pts,distanceTolerance){var simp=new jsts.simplify.DouglasPeuckerLineSimplifier(pts);simp.setDistanceTolerance(distanceTolerance);return simp.simplify()};jsts.simplify.DouglasPeuckerLineSimplifier.prototype.setDistanceTolerance=function(distanceTolerance){this.distanceTolerance=distanceTolerance};jsts.simplify.DouglasPeuckerLineSimplifier.prototype.simplify=function(){this.usePt=[];for(var i=0;i<this.pts.length;i++){this.usePt[i]=true}this.simplifySection(0,this.pts.length-1);var coordList=new jsts.geom.CoordinateList;for(var j=0;j<this.pts.length;j++){if(this.usePt[j]){coordList.add(new jsts.geom.Coordinate(this.pts[j]))}}return coordList.toCoordinateArray()};jsts.simplify.DouglasPeuckerLineSimplifier.prototype.seg=null;jsts.simplify.DouglasPeuckerLineSimplifier.prototype.simplifySection=function(i,j){if(i+1==j){return}this.seg.p0=this.pts[i];this.seg.p1=this.pts[j];var maxDistance=-1;var maxIndex=i;for(var k=i+1;k<j;k++){var distance=this.seg.distance(this.pts[k]);if(distance>maxDistance){maxDistance=distance;maxIndex=k}}if(maxDistance<=this.distanceTolerance){for(var l=i+1;l<j;l++){this.usePt[l]=false}}else{this.simplifySection(i,maxIndex);this.simplifySection(maxIndex,j)}};jsts.geomgraph.EdgeIntersection=function(coord,segmentIndex,dist){this.coord=new jsts.geom.Coordinate(coord);this.segmentIndex=segmentIndex;this.dist=dist};jsts.geomgraph.EdgeIntersection.prototype.coord=null;jsts.geomgraph.EdgeIntersection.prototype.segmentIndex=null;jsts.geomgraph.EdgeIntersection.prototype.dist=null;jsts.geomgraph.EdgeIntersection.prototype.getCoordinate=function(){return this.coord};jsts.geomgraph.EdgeIntersection.prototype.getSegmentIndex=function(){return this.segmentIndex};jsts.geomgraph.EdgeIntersection.prototype.getDistance=function(){return this.dist};jsts.geomgraph.EdgeIntersection.prototype.compareTo=function(other){return this.compare(other.segmentIndex,other.dist)};jsts.geomgraph.EdgeIntersection.prototype.compare=function(segmentIndex,dist){if(this.segmentIndex<segmentIndex)return-1;if(this.segmentIndex>segmentIndex)return 1;if(this.dist<dist)return-1;if(this.dist>dist)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.Point=function(coordinate,factory){this.factory=factory;if(coordinate===undefined)return;this.coordinate=coordinate};jsts.geom.Point.prototype=new jsts.geom.Geometry;jsts.geom.Point.constructor=jsts.geom.Point;jsts.geom.Point.CLASS_NAME="jsts.geom.Point";jsts.geom.Point.prototype.coordinate=null;jsts.geom.Point.prototype.getX=function(){return this.coordinate.x};jsts.geom.Point.prototype.getY=function(){return this.coordinate.y};jsts.geom.Point.prototype.getCoordinate=function(){return this.coordinate};jsts.geom.Point.prototype.getCoordinates=function(){return this.isEmpty()?[]:[this.coordinate]};jsts.geom.Point.prototype.getCoordinateSequence=function(){return this.isEmpty()?[]:[this.coordinate]};jsts.geom.Point.prototype.isEmpty=function(){return this.coordinate===null};jsts.geom.Point.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}if(this.isEmpty()&&other.isEmpty()){return true}return this.equal(other.getCoordinate(),this.getCoordinate(),tolerance)};jsts.geom.Point.prototype.getNumPoints=function(){return this.isEmpty()?0:1};jsts.geom.Point.prototype.isSimple=function(){return true};jsts.geom.Point.prototype.getBoundary=function(){return new jsts.geom.GeometryCollection(null)};jsts.geom.Point.prototype.computeEnvelopeInternal=function(){if(this.isEmpty()){return new jsts.geom.Envelope}return new jsts.geom.Envelope(this.coordinate)};jsts.geom.Point.prototype.apply=function(filter){if(filter instanceof jsts.geom.GeometryFilter||filter instanceof jsts.geom.GeometryComponentFilter){filter.filter(this)}else if(filter instanceof jsts.geom.CoordinateFilter){if(this.isEmpty()){return}filter.filter(this.getCoordinate())}};jsts.geom.Point.prototype.clone=function(){return new jsts.geom.Point(this.coordinate.clone(),this.factory)};jsts.geom.Point.prototype.getDimension=function(){return 0};jsts.geom.Point.prototype.getBoundaryDimension=function(){return jsts.geom.Dimension.FALSE};jsts.geom.Point.prototype.reverse=function(){return this.clone()};jsts.geom.Point.prototype.isValid=function(){if(!jsts.operation.valid.IsValidOp.isValid(this.getCoordinate())){return false}return true};jsts.geom.Point.prototype.normalize=function(){};jsts.geom.Point.prototype.compareToSameClass=function(other){var point=other;return this.getCoordinate().compareTo(point.getCoordinate())};jsts.geom.Point.prototype.getGeometryType=function(){return"Point"};jsts.geom.Point.prototype.hashCode=function(){return"Point_"+this.coordinate.hashCode()};jsts.geom.Point.prototype.CLASS_NAME="jsts.geom.Point";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(i<il&&j<jl){var comparison=this.points[i].compareTo(line.points[j]);if(comparison!==0){return comparison}i++;j++}if(i<il){return 1}if(j<jl){return-1}return 0};jsts.geom.LineString.prototype.apply=function(filter){if(filter instanceof jsts.geom.GeometryFilter||filter instanceof jsts.geom.GeometryComponentFilter){filter.filter(this)}else if(filter instanceof jsts.geom.CoordinateFilter){for(var i=0,len=this.points.length;i<len;i++){filter.filter(this.points[i])}}else if(filter instanceof jsts.geom.CoordinateSequenceFilter){this.apply2.apply(this,arguments)}};jsts.geom.LineString.prototype.apply2=function(filter){if(this.points.length===0)return;for(var i=0;i<this.points.length;i++){filter.filter(this.points,i);if(filter.isDone())break}if(filter.isGeometryChanged()){}};jsts.geom.LineString.prototype.clone=function(){var points=[];for(var i=0,len=this.points.length;i<len;i++){points.push(this.points[i].clone())}return this.factory.createLineString(points)};jsts.geom.LineString.prototype.normalize=function(){var i,il,j,ci,cj,len;len=this.points.length;il=parseInt(len/2);for(i=0;i<il;i++){j=len-1-i;ci=this.points[i];cj=this.points[j];if(!ci.equals(cj)){if(ci.compareTo(cj)>0){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;x<shellCoordinates.length;x++){k++;coordinates[k]=shellCoordinates[x]}for(var i=0;i<this.holes.length;i++){var childCoordinates=this.holes[i].getCoordinates();for(var j=0;j<childCoordinates.length;j++){k++;coordinates[k]=childCoordinates[j]}}return coordinates};jsts.geom.Polygon.prototype.getNumPoints=function(){var numPoints=this.shell.getNumPoints();for(var i=0;i<this.holes.length;i++){numPoints+=this.holes[i].getNumPoints()}return numPoints};jsts.geom.Polygon.prototype.isEmpty=function(){return this.shell.isEmpty()};jsts.geom.Polygon.prototype.isRectangle=function(){if(this.getNumInteriorRing()!=0)return false;if(this.shell==null)return false;if(this.shell.getNumPoints()!=5)return false;var seq=this.shell.getCoordinateSequence();var env=this.getEnvelopeInternal();for(var i=0;i<5;i++){var x=seq[i].x;if(!(x==env.getMinX()||x==env.getMaxX()))return false;var y=seq[i].y;if(!(y==env.getMinY()||y==env.getMaxY()))return false}var prevX=seq[0].x;var prevY=seq[0].y;for(var i=1;i<=4;i++){var x=seq[i].x;var y=seq[i].y;var xChanged=x!=prevX;var yChanged=y!=prevY;if(xChanged==yChanged)return false;prevX=x;prevY=y}return true};jsts.geom.Polygon.prototype.getExteriorRing=function(){return this.shell};jsts.geom.Polygon.prototype.getInteriorRingN=function(n){return this.holes[n]};jsts.geom.Polygon.prototype.getNumInteriorRing=function(){return this.holes.length};jsts.geom.Polygon.prototype.getArea=function(){var area=0;area+=Math.abs(jsts.algorithm.CGAlgorithms.signedArea(this.shell.getCoordinateSequence()));for(var i=0;i<this.holes.length;i++){area-=Math.abs(jsts.algorithm.CGAlgorithms.signedArea(this.holes[i].getCoordinateSequence()))}return area};jsts.geom.Polygon.prototype.getLength=function(){var len=0;len+=this.shell.getLength();for(var i=0;i<this.holes.length;i++){len+=this.holes[i].getLength()}return len};jsts.geom.Polygon.prototype.getBoundary=function(){if(this.isEmpty()){return this.getFactory().createMultiLineString(null)}var rings=[];rings[0]=this.shell.clone();for(var i=0,len=this.holes.length;i<len;i++){rings[i+1]=this.holes[i].clone()}if(rings.length<=1)return rings[0];return this.getFactory().createMultiLineString(rings)};jsts.geom.Polygon.prototype.computeEnvelopeInternal=function(){return this.shell.getEnvelopeInternal()};jsts.geom.Polygon.prototype.getDimension=function(){return 2};jsts.geom.Polygon.prototype.getBoundaryDimension=function(){return 1};jsts.geom.Polygon.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}if(this.isEmpty()&&other.isEmpty()){return true}if(this.isEmpty()!==other.isEmpty()){return false}if(!this.shell.equalsExact(other.shell,tolerance)){return false}if(this.holes.length!==other.holes.length){return false}if(this.holes.length!==other.holes.length){return false}for(var i=0;i<this.holes.length;i++){if(!this.holes[i].equalsExact(other.holes[i],tolerance)){return false}}return true};jsts.geom.Polygon.prototype.compareToSameClass=function(o){return this.shell.compareToSameClass(o.shell)};jsts.geom.Polygon.prototype.apply=function(filter){if(filter instanceof jsts.geom.GeometryComponentFilter){filter.filter(this);this.shell.apply(filter);for(var i=0,len=this.holes.length;i<len;i++){this.holes[i].apply(filter)}}else if(filter instanceof jsts.geom.GeometryFilter){filter.filter(this)}else if(filter instanceof jsts.geom.CoordinateFilter){this.shell.apply(filter);for(var i=0,len=this.holes.length;i<len;i++){this.holes[i].apply(filter)}}else if(filter instanceof jsts.geom.CoordinateSequenceFilter){this.apply2.apply(this,arguments)}};jsts.geom.Polygon.prototype.apply2=function(filter){this.shell.apply(filter);if(!filter.isDone()){for(var i=0;i<this.holes.length;i++){this.holes[i].apply(filter);if(filter.isDone())break}}if(filter.isGeometryChanged()){}};jsts.geom.Polygon.prototype.clone=function(){var holes=[];for(var i=0,len=this.holes.length;i<len;i++){holes.push(this.holes[i].clone())}return this.factory.createPolygon(this.shell.clone(),holes)};jsts.geom.Polygon.prototype.normalize=function(){this.normalize2(this.shell,true);for(var i=0,len=this.holes.length;i<len;i++){this.normalize2(this.holes[i],false)}this.holes.sort()};jsts.geom.Polygon.prototype.normalize2=function(ring,clockwise){if(ring.isEmpty()){return}var uniqueCoordinates=ring.points.slice(0,ring.points.length-1);var minCoordinate=jsts.geom.CoordinateArrays.minCoordinate(ring.points);jsts.geom.CoordinateArrays.scroll(uniqueCoordinates,minCoordinate);ring.points=uniqueCoordinates.concat();ring.points[uniqueCoordinates.length]=uniqueCoordinates[0];if(jsts.algorithm.CGAlgorithms.isCCW(ring.points)===clockwise){ring.points.reverse()}};jsts.geom.Polygon.prototype.getGeometryType=function(){return"Polygon"};jsts.geom.Polygon.prototype.CLASS_NAME="jsts.geom.Polygon"})();(function(){var Geometry=jsts.geom.Geometry;var TreeSet=javascript.util.TreeSet;var Arrays=javascript.util.Arrays;jsts.geom.GeometryCollection=function(geometries,factory){this.geometries=geometries||[];this.factory=factory};jsts.geom.GeometryCollection.prototype=new Geometry;jsts.geom.GeometryCollection.constructor=jsts.geom.GeometryCollection;jsts.geom.GeometryCollection.prototype.isEmpty=function(){for(var i=0,len=this.geometries.length;i<len;i++){var geometry=this.getGeometryN(i);if(!geometry.isEmpty()){return false}}return true};jsts.geom.GeometryCollection.prototype.getArea=function(){var area=0;for(var i=0,len=this.geometries.length;i<len;i++){area+=this.getGeometryN(i).getArea()}return area};jsts.geom.GeometryCollection.prototype.getLength=function(){var length=0;for(var i=0,len=this.geometries.length;i<len;i++){length+=this.getGeometryN(i).getLength()}return length};jsts.geom.GeometryCollection.prototype.getCoordinate=function(){if(this.isEmpty())return null;return this.getGeometryN(0).getCoordinate()};jsts.geom.GeometryCollection.prototype.getCoordinates=function(){var coordinates=[];var k=-1;for(var i=0,len=this.geometries.length;i<len;i++){var geometry=this.getGeometryN(i);var childCoordinates=geometry.getCoordinates();for(var j=0;j<childCoordinates.length;j++){k++;coordinates[k]=childCoordinates[j]}}return coordinates};jsts.geom.GeometryCollection.prototype.getNumGeometries=function(){return this.geometries.length};jsts.geom.GeometryCollection.prototype.getGeometryN=function(n){var geometry=this.geometries[n];if(geometry instanceof jsts.geom.Coordinate){geometry=new jsts.geom.Point(geometry)}return geometry};jsts.geom.GeometryCollection.prototype.getNumPoints=function(n){var numPoints=0;for(var i=0;i<this.geometries.length;i++){numPoints+=this.geometries[i].getNumPoints()}return numPoints};jsts.geom.GeometryCollection.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}if(this.geometries.length!==other.geometries.length){return false}for(var i=0,len=this.geometries.length;i<len;i++){var geometry=this.getGeometryN(i);if(!geometry.equalsExact(other.getGeometryN(i),tolerance)){return false}}return true};jsts.geom.GeometryCollection.prototype.clone=function(){var geometries=[];for(var i=0,len=this.geometries.length;i<len;i++){geometries.push(this.geometries[i].clone())}return this.factory.createGeometryCollection(geometries)};jsts.geom.GeometryCollection.prototype.normalize=function(){for(var i=0,len=this.geometries.length;i<len;i++){this.getGeometryN(i).normalize()}this.geometries.sort()};jsts.geom.GeometryCollection.prototype.compareToSameClass=function(o){var theseElements=new TreeSet(Arrays.asList(this.geometries));var otherElements=new TreeSet(Arrays.asList(o.geometries));return this.compare(theseElements,otherElements)};jsts.geom.GeometryCollection.prototype.apply=function(filter){if(filter instanceof jsts.geom.GeometryFilter||filter instanceof jsts.geom.GeometryComponentFilter){filter.filter(this);for(var i=0,len=this.geometries.length;i<len;i++){this.getGeometryN(i).apply(filter)}}else if(filter instanceof jsts.geom.CoordinateFilter){for(var i=0,len=this.geometries.length;i<len;i++){this.getGeometryN(i).apply(filter)}}else if(filter instanceof jsts.geom.CoordinateSequenceFilter){this.apply2.apply(this,arguments)}};jsts.geom.GeometryCollection.prototype.apply2=function(filter){if(this.geometries.length==0)return;for(var i=0;i<this.geometries.length;i++){this.geometries[i].apply(filter);if(filter.isDone()){break}}if(filter.isGeometryChanged()){}};jsts.geom.GeometryCollection.prototype.getDimension=function(){var dimension=jsts.geom.Dimension.FALSE;for(var i=0,len=this.geometries.length;i<len;i++){var geometry=this.getGeometryN(i);dimension=Math.max(dimension,geometry.getDimension())}return dimension};jsts.geom.GeometryCollection.prototype.computeEnvelopeInternal=function(){var envelope=new jsts.geom.Envelope;for(var i=0,len=this.geometries.length;i<len;i++){var geometry=this.getGeometryN(i);envelope.expandToInclude(geometry.getEnvelopeInternal())}return envelope};jsts.geom.GeometryCollection.prototype.CLASS_NAME="jsts.geom.GeometryCollection"})();jsts.algorithm.Centroid=function(geometry){this.areaBasePt=null;this.triangleCent3=new jsts.geom.Coordinate;this.areasum2=0;this.cg3=new jsts.geom.Coordinate;this.lineCentSum=new jsts.geom.Coordinate;this.totalLength=0;this.ptCount=0;this.ptCentSum=new jsts.geom.Coordinate;this.add(geometry)};jsts.algorithm.Centroid.getCentroid=function(geometry){var cent=new jsts.algorithm.Centroid(geometry);return cent.getCentroid()};jsts.algorithm.Centroid.centroid3=function(p1,p2,p3,c){c.x=p1.x+p2.x+p3.x;c.y=p1.y+p2.y+p3.y};jsts.algorithm.Centroid.area2=function(p1,p2,p3){return(p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y)};jsts.algorithm.Centroid.prototype.add=function(geom){if(geom.isEmpty()){return}if(geom instanceof jsts.geom.Point){this.addPoint(geom.getCoordinate())}else if(geom instanceof jsts.geom.LineString){this.addLineSegments(geom.getCoordinates())}else if(geom instanceof jsts.geom.Polygon){this.addPolygon(geom)}else if(geom instanceof jsts.geom.GeometryCollection){for(var i=0;i<geom.getNumGeometries();i++){this.add(geom.getGeometryN(i))}}};jsts.algorithm.Centroid.prototype.getCentroid=function(){var cent=new jsts.geom.Coordinate;if(Math.abs(this.areasum2)>0){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;i<poly.getNumInteriorRing();i++){this.addHole(poly.getInteriorRingN(i).getCoordinates())}};jsts.algorithm.Centroid.prototype.addShell=function(pts){if(pts.length>0){this.setBasePoint(pts[0])}var isPositiveArea=!jsts.algorithm.CGAlgorithms.isCCW(pts);for(var i=0;i<pts.length-1;i++){this.addTriangle(this.areaBasePt,pts[i],pts[i+1],isPositiveArea)}this.addLineSegments(pts)};jsts.algorithm.Centroid.prototype.addHole=function(pts){var isPositiveArea=jsts.algorithm.CGAlgorithms.isCCW(pts);for(var i=0;i<pts.length-1;i++){this.addTriangle(this.areaBasePt,pts[i],pts[i+1],isPositiveArea)}this.addLineSegments(pts)};jsts.algorithm.Centroid.prototype.addTriangle=function(p0,p1,p2,isPositiveArea){var sign=isPositiveArea?1:-1;jsts.algorithm.Centroid.centroid3(p0,p1,p2,this.triangleCent3);var area2=jsts.algorithm.Centroid.area2(p0,p1,p2);this.cg3.x+=sign*area2*this.triangleCent3.x;this.cg3.y+=sign*area2*this.triangleCent3.y;this.areasum2+=sign*area2};jsts.algorithm.Centroid.prototype.addLineSegments=function(pts){var lineLen=0;for(var i=0;i<pts.length-1;i++){var segmentLen=pts[i].distance(pts[i+1]);if(segmentLen===0){continue}lineLen+=segmentLen;var midx=(pts[i].x+pts[i+1].x)/2;this.lineCentSum.x+=segmentLen*midx;var midy=(pts[i].y+pts[i+1].y)/2;this.lineCentSum.y+=segmentLen*midy}this.totalLength+=lineLen;if(lineLen===0&&pts.length>0){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<testPts.length;i++){var testPt=testPts[i];if(!isInList(testPt,pts))return testPt}return null};EdgeRing.isInList=function(pt,pts){for(var i=0;i<pts.length;i++){if(pt.equals(pts[i]))return true}return false};EdgeRing.prototype.factory=null;EdgeRing.prototype.deList=null;EdgeRing.prototype.ring=null;EdgeRing.prototype.ringPts=null;EdgeRing.prototype.holes=null;EdgeRing.prototype.add=function(de){this.deList.add(de)};EdgeRing.prototype.isHole=function(){var ring=this.getRing();return jsts.algorithm.CGAlgorithms.isCCW(ring.getCoordinates())};EdgeRing.prototype.addHole=function(hole){if(this.holes==null)this.holes=new javascript.util.ArrayList;this.holes.add(hole)};EdgeRing.prototype.getPolygon=function(){var holeLR=null;if(this.holes!=null){holeLR=[];for(var i=0;i<this.holes.size();i++){holeLR[i]=this.holes.get(i)}}var poly=this.factory.createPolygon(this.ring,holeLR);return poly};EdgeRing.prototype.isValid=function(){this.getCoordinates();if(this.ringPts.length<=3)return false;this.getRing();return this.ring.isValid()};EdgeRing.prototype.getCoordinates=function(){if(this.ringPts==null){var coordList=new jsts.geom.CoordinateList;for(var i=this.deList.iterator();i.hasNext();){var de=i.next();var edge=de.getEdge();EdgeRing.addEdge(edge.getLine().getCoordinates(),de.getEdgeDirection(),coordList)}this.ringPts=coordList.toCoordinateArray()}return this.ringPts};EdgeRing.prototype.getLineString=function(){this.getCoordinates();return this.factory.createLineString(this.ringPts)};EdgeRing.prototype.getRing=function(){if(this.ring!=null)return this.ring;this.getCoordinates();if(this.ringPts.length<3)console.log(this.ringPts);try{this.ring=this.factory.createLinearRing(this.ringPts)}catch(ex){console.log(this.ringPts)}return this.ring};EdgeRing.addEdge=function(coords,isForward,coordList){if(isForward){for(var i=0;i<coords.length;i++){coordList.add(coords[i],false)}}else{for(var i=coords.length-1;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.quadrant<e.quadrant)return-1;return jsts.algorithm.CGAlgorithms.computeOrientation(e.p0,e.p1,this.p1)};jsts.planargraph.DirectedEdge=DirectedEdge})();(function(){var DirectedEdge=jsts.planargraph.DirectedEdge;var PolygonizeDirectedEdge=function(from,to,directionPt,edgeDirection){DirectedEdge.apply(this,arguments)};PolygonizeDirectedEdge.prototype=new DirectedEdge;PolygonizeDirectedEdge.prototype.edgeRing=null;PolygonizeDirectedEdge.prototype.next=null;PolygonizeDirectedEdge.prototype.label=-1;PolygonizeDirectedEdge.prototype.getLabel=function(){return this.label};PolygonizeDirectedEdge.prototype.setLabel=function(label){this.label=label};PolygonizeDirectedEdge.prototype.getNext=function(){return this.next};PolygonizeDirectedEdge.prototype.setNext=function(next){this.next=next};PolygonizeDirectedEdge.prototype.isInRing=function(){return this.edgeRing!=null};PolygonizeDirectedEdge.prototype.setRing=function(edgeRing){this.edgeRing=edgeRing};jsts.operation.polygonize.PolygonizeDirectedEdge=PolygonizeDirectedEdge})();(function(){var ArrayList=javascript.util.ArrayList;var DirectedEdgeStar=function(){this.outEdges=new ArrayList};DirectedEdgeStar.prototype.outEdges=null;DirectedEdgeStar.prototype.sorted=false;DirectedEdgeStar.prototype.add=function(de){this.outEdges.add(de);this.sorted=false};DirectedEdgeStar.prototype.remove=function(de){this.outEdges.remove(de)};DirectedEdgeStar.prototype.iterator=function(){this.sortEdges();return this.outEdges.iterator()};DirectedEdgeStar.prototype.getDegree=function(){return this.outEdges.size()};DirectedEdgeStar.prototype.getCoordinate=function(){var it=iterator();if(!it.hasNext())return null;var e=it.next();return e.getCoordinate()};DirectedEdgeStar.prototype.getEdges=function(){this.sortEdges();return this.outEdges};DirectedEdgeStar.prototype.sortEdges=function(){if(!this.sorted){var array=this.outEdges.toArray();array.sort(function(a,b){return a.compareTo(b)});this.outEdges=javascript.util.Arrays.asList(array);this.sorted=true}};DirectedEdgeStar.prototype.getIndex=function(edge){if(edge instanceof jsts.planargraph.DirectedEdge){return this.getIndex2(edge)}else if(typeof edge==="number"){return this.getIndex3(edge)}this.sortEdges();for(var i=0;i<this.outEdges.size();i++){var de=this.outEdges.get(i);if(de.getEdge()==edge)return i}return-1};DirectedEdgeStar.prototype.getIndex2=function(dirEdge){this.sortEdges();for(var i=0;i<this.outEdges.size();i++){var de=this.outEdges.get(i);if(de==dirEdge)return i}return-1};DirectedEdgeStar.prototype.getIndex3=function(i){var modi=toInt(i%this.outEdges.size());if(modi<0)modi+=this.outEdges.size();return modi};DirectedEdgeStar.prototype.getNextEdge=function(dirEdge){var i=this.getIndex(dirEdge);return this.outEdges.get(getIndex(i+1))};DirectedEdgeStar.prototype.getNextCWEdge=function(dirEdge){var i=this.getIndex(dirEdge);return this.outEdges.get(getIndex(i-1))};jsts.planargraph.DirectedEdgeStar=DirectedEdgeStar})();(function(){var GraphComponent=jsts.planargraph.GraphComponent;var DirectedEdgeStar=jsts.planargraph.DirectedEdgeStar;var Node=function(pt,deStar){this.pt=pt;this.deStar=deStar||new DirectedEdgeStar};Node.prototype=new GraphComponent;Node.getEdgesBetween=function(node0,node1){var edges0=DirectedEdge.toEdges(node0.getOutEdges().getEdges());var commonEdges=new javascript.util.HashSet(edges0);var edges1=DirectedEdge.toEdges(node1.getOutEdges().getEdges());commonEdges.retainAll(edges1);return commonEdges};Node.prototype.pt=null;Node.prototype.deStar=null;Node.prototype.getCoordinate=function(){return this.pt};Node.prototype.addOutEdge=function(de){this.deStar.add(de)};Node.prototype.getOutEdges=function(){return this.deStar};Node.prototype.getDegree=function(){return this.deStar.getDegree()};Node.prototype.getIndex=function(edge){return this.deStar.getIndex(edge)};Node.prototype.remove=function(de){if(de===undefined){return this.remove2()}this.deStar.remove(de)};Node.prototype.remove2=function(){this.pt=null};Node.prototype.isRemoved=function(){return this.pt==null};jsts.planargraph.Node=Node})();(function(){var NodeMap=function(){this.nodeMap=new javascript.util.TreeMap};NodeMap.prototype.nodeMap=null;NodeMap.prototype.add=function(n){this.nodeMap.put(n.getCoordinate(),n);return n};NodeMap.prototype.remove=function(pt){return this.nodeMap.remove(pt)};NodeMap.prototype.find=function(coord){return this.nodeMap.get(coord)};NodeMap.prototype.iterator=function(){return this.nodeMap.values().iterator()};NodeMap.prototype.values=function(){return this.nodeMap.values()};jsts.planargraph.NodeMap=NodeMap})();(function(){var ArrayList=javascript.util.ArrayList;var PlanarGraph=function(){this.edges=new javascript.util.HashSet;this.dirEdges=new javascript.util.HashSet;this.nodeMap=new jsts.planargraph.NodeMap};PlanarGraph.prototype.edges=null;PlanarGraph.prototype.dirEdges=null;PlanarGraph.prototype.nodeMap=null;PlanarGraph.prototype.findNode=function(pt){return this.nodeMap.find(pt)};PlanarGraph.prototype.add=function(node){if(node instanceof jsts.planargraph.Edge){return this.add2(node)}else if(node instanceof jsts.planargraph.DirectedEdge){return this.add3(node)}this.nodeMap.add(node)};PlanarGraph.prototype.add2=function(edge){this.edges.add(edge);this.add(edge.getDirEdge(0));this.add(edge.getDirEdge(1))};PlanarGraph.prototype.add3=function(dirEdge){this.dirEdges.add(dirEdge)};PlanarGraph.prototype.nodeIterator=function(){return this.nodeMap.iterator()};PlanarGraph.prototype.contains=function(e){if(e instanceof jsts.planargraph.DirectedEdge){return this.contains2(e)}return this.edges.contains(e)};PlanarGraph.prototype.contains2=function(de){return this.dirEdges.contains(de)};PlanarGraph.prototype.getNodes=function(){return this.nodeMap.values()};PlanarGraph.prototype.dirEdgeIterator=function(){return this.dirEdges.iterator()};PlanarGraph.prototype.edgeIterator=function(){return this.edges.iterator()};PlanarGraph.prototype.getEdges=function(){return this.edges};PlanarGraph.prototype.remove=function(edge){if(edge instanceof jsts.planargraph.DirectedEdge){return this.remove2(edge)}this.remove(edge.getDirEdge(0));this.remove(edge.getDirEdge(1));this.edges.remove(edge);this.edge.remove()};PlanarGraph.prototype.remove2=function(de){if(de instanceof jsts.planargraph.Node){return this.remove3(de)}var sym=de.getSym();if(sym!=null)sym.setSym(null);de.getFromNode().remove(de);de.remove();this.dirEdges.remove(de)};PlanarGraph.prototype.remove3=function(node){var outEdges=node.getOutEdges().getEdges();for(var i=outEdges.iterator();i.hasNext();){var de=i.next();var sym=de.getSym();if(sym!=null)this.remove(sym);this.dirEdges.remove(de);var edge=de.getEdge();if(edge!=null){this.edges.remove(edge)}}this.nodeMap.remove(node.getCoordinate());node.remove()};PlanarGraph.prototype.findNodesOfDegree=function(degree){var nodesFound=new ArrayList;for(var i=this.nodeIterator();i.hasNext();){
var node=i.next();if(node.getDegree()==degree)nodesFound.add(node)}return nodesFound};jsts.planargraph.PlanarGraph=PlanarGraph})();(function(){var ArrayList=javascript.util.ArrayList;var Stack=javascript.util.Stack;var HashSet=javascript.util.HashSet;var Assert=jsts.util.Assert;var EdgeRing=jsts.operation.polygonize.EdgeRing;var PolygonizeEdge=jsts.operation.polygonize.PolygonizeEdge;var PolygonizeDirectedEdge=jsts.operation.polygonize.PolygonizeDirectedEdge;var PlanarGraph=jsts.planargraph.PlanarGraph;var Node=jsts.planargraph.Node;var PolygonizeGraph=function(factory){PlanarGraph.apply(this);this.factory=factory};PolygonizeGraph.prototype=new PlanarGraph;PolygonizeGraph.getDegreeNonDeleted=function(node){var edges=node.getOutEdges().getEdges();var degree=0;for(var i=edges.iterator();i.hasNext();){var de=i.next();if(!de.isMarked())degree++}return degree};PolygonizeGraph.getDegree=function(node,label){var edges=node.getOutEdges().getEdges();var degree=0;for(var i=edges.iterator();i.hasNext();){var de=i.next();if(de.getLabel()==label)degree++}return degree};PolygonizeGraph.deleteAllEdges=function(node){var edges=node.getOutEdges().getEdges();for(var i=edges.iterator();i.hasNext();){var de=i.next();de.setMarked(true);var sym=de.getSym();if(sym!=null)sym.setMarked(true)}};PolygonizeGraph.prototype.factory=null;PolygonizeGraph.prototype.addEdge=function(line){if(line.isEmpty()){return}var linePts=jsts.geom.CoordinateArrays.removeRepeatedPoints(line.getCoordinates());if(linePts.length<2){return}var startPt=linePts[0];var endPt=linePts[linePts.length-1];var nStart=this.getNode(startPt);var nEnd=this.getNode(endPt);var de0=new PolygonizeDirectedEdge(nStart,nEnd,linePts[1],true);var de1=new PolygonizeDirectedEdge(nEnd,nStart,linePts[linePts.length-2],false);var edge=new PolygonizeEdge(line);edge.setDirectedEdges(de0,de1);this.add(edge)};PolygonizeGraph.prototype.getNode=function(pt){var node=this.findNode(pt);if(node==null){node=new Node(pt);this.add(node)}return node};PolygonizeGraph.prototype.computeNextCWEdges=function(){for(var iNode=this.nodeIterator();iNode.hasNext();){var node=iNode.next();PolygonizeGraph.computeNextCWEdges(node)}};PolygonizeGraph.prototype.convertMaximalToMinimalEdgeRings=function(ringEdges){for(var i=ringEdges.iterator();i.hasNext();){var de=i.next();var label=de.getLabel();var intNodes=PolygonizeGraph.findIntersectionNodes(de,label);if(intNodes==null)continue;for(var iNode=intNodes.iterator();iNode.hasNext();){var node=iNode.next();PolygonizeGraph.computeNextCCWEdges(node,label)}}};PolygonizeGraph.findIntersectionNodes=function(startDE,label){var de=startDE;var intNodes=null;do{var node=de.getFromNode();if(PolygonizeGraph.getDegree(node,label)>1){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.max<this.min)};jsts.index.strtree.Interval.prototype.equals=function(o){if(!(o instanceof jsts.index.strtree.Interval)){return false}other=o;return this.min===other.min&&this.max===other.max};jsts.geom.GeometryFactory=function(precisionModel){this.precisionModel=precisionModel||new jsts.geom.PrecisionModel};jsts.geom.GeometryFactory.prototype.precisionModel=null;jsts.geom.GeometryFactory.prototype.getPrecisionModel=function(){return this.precisionModel};jsts.geom.GeometryFactory.prototype.createPoint=function(coordinate){var point=new jsts.geom.Point(coordinate,this);return point};jsts.geom.GeometryFactory.prototype.createLineString=function(coordinates){var lineString=new jsts.geom.LineString(coordinates,this);return lineString};jsts.geom.GeometryFactory.prototype.createLinearRing=function(coordinates){var linearRing=new jsts.geom.LinearRing(coordinates,this);return linearRing};jsts.geom.GeometryFactory.prototype.createPolygon=function(shell,holes){var polygon=new jsts.geom.Polygon(shell,holes,this);return polygon};jsts.geom.GeometryFactory.prototype.createMultiPoint=function(points){if(points&&points[0]instanceof jsts.geom.Coordinate){var converted=[];var i;for(i=0;i<points.length;i++){converted.push(this.createPoint(points[i]))}points=converted}return new jsts.geom.MultiPoint(points,this)};jsts.geom.GeometryFactory.prototype.createMultiLineString=function(lineStrings){return new jsts.geom.MultiLineString(lineStrings,this)};jsts.geom.GeometryFactory.prototype.createMultiPolygon=function(polygons){return new jsts.geom.MultiPolygon(polygons,this)};jsts.geom.GeometryFactory.prototype.buildGeometry=function(geomList){var geomClass=null;var isHeterogeneous=false;var hasGeometryCollection=false;for(var i=geomList.iterator();i.hasNext();){var geom=i.next();var partClass=geom.CLASS_NAME;if(geomClass===null){geomClass=partClass}if(!(partClass===geomClass)){isHeterogeneous=true}if(geom.isGeometryCollectionBase())hasGeometryCollection=true}if(geomClass===null){return this.createGeometryCollection(null)}if(isHeterogeneous||hasGeometryCollection){return this.createGeometryCollection(geomList.toArray())}var geom0=geomList.get(0);var isCollection=geomList.size()>1;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;i<this.location.length;i++){this.location[i]=gl.location[i]}}}else if(typeof arguments[0]==="number"){var on=arguments[0];this.init(1);this.location[jsts.geomgraph.Position.ON]=on}else if(arguments[0]instanceof Array){var location=arguments[0];this.init(location.length)}};jsts.geomgraph.TopologyLocation.prototype.location=null;jsts.geomgraph.TopologyLocation.prototype.init=function(size){this.location[size-1]=null;this.setAllLocations(jsts.geom.Location.NONE)};jsts.geomgraph.TopologyLocation.prototype.get=function(posIndex){if(posIndex<this.location.length)return this.location[posIndex];return jsts.geom.Location.NONE};jsts.geomgraph.TopologyLocation.prototype.isNull=function(){for(var i=0;i<this.location.length;i++){if(this.location[i]!==jsts.geom.Location.NONE)return false}return true};jsts.geomgraph.TopologyLocation.prototype.isAnyNull=function(){for(var i=0;i<this.location.length;i++){if(this.location[i]===jsts.geom.Location.NONE)return true}return false};jsts.geomgraph.TopologyLocation.prototype.isEqualOnSide=function(le,locIndex){return this.location[locIndex]==le.location[locIndex]};jsts.geomgraph.TopologyLocation.prototype.isArea=function(){return this.location.length>1};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;i<this.location.length;i++){this.location[i]=locValue}};jsts.geomgraph.TopologyLocation.prototype.setAllLocationsIfNull=function(locValue){for(var i=0;i<this.location.length;i++){if(this.location[i]===jsts.geom.Location.NONE)this.location[i]=locValue}};jsts.geomgraph.TopologyLocation.prototype.setLocation=function(locIndex,locValue){if(locValue!==undefined){this.location[locIndex]=locValue}else{this.setLocation(jsts.geomgraph.Position.ON,locIndex)}};jsts.geomgraph.TopologyLocation.prototype.getLocations=function(){return location};jsts.geomgraph.TopologyLocation.prototype.setLocations=function(on,left,right){this.location[jsts.geomgraph.Position.ON]=on;this.location[jsts.geomgraph.Position.LEFT]=left;this.location[jsts.geomgraph.Position.RIGHT]=right};jsts.geomgraph.TopologyLocation.prototype.allPositionsEqual=function(loc){for(var i=0;i<this.location.length;i++){if(this.location[i]!==loc)return false}return true};jsts.geomgraph.TopologyLocation.prototype.merge=function(gl){if(gl.location.length>this.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;i<this.location.length;i++){if(this.location[i]===jsts.geom.Location.NONE&&i<gl.location.length)this.location[i]=gl.location[i]}};jsts.geomgraph.Label=function(){this.elt=[];var geomIndex,onLoc,leftLoc,lbl,rightLoc;if(arguments.length===4){geomIndex=arguments[0];onLoc=arguments[1];leftLoc=arguments[2];rightLoc=arguments[3];this.elt[0]=new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE,jsts.geom.Location.NONE,jsts.geom.Location.NONE);this.elt[1]=new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE,jsts.geom.Location.NONE,jsts.geom.Location.NONE);this.elt[geomIndex].setLocations(onLoc,leftLoc,rightLoc)}else if(arguments.length===3){onLoc=arguments[0];leftLoc=arguments[1];rightLoc=arguments[2];this.elt[0]=new jsts.geomgraph.TopologyLocation(onLoc,leftLoc,rightLoc);this.elt[1]=new jsts.geomgraph.TopologyLocation(onLoc,leftLoc,rightLoc)}else if(arguments.length===2){geomIndex=arguments[0];onLoc=arguments[1];this.elt[0]=new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE);this.elt[1]=new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE);this.elt[geomIndex].setLocation(onLoc)}else if(arguments[0]instanceof jsts.geomgraph.Label){lbl=arguments[0];this.elt[0]=new jsts.geomgraph.TopologyLocation(lbl.elt[0]);this.elt[1]=new jsts.geomgraph.TopologyLocation(lbl.elt[1])}else if(typeof arguments[0]==="number"){onLoc=arguments[0];this.elt[0]=new jsts.geomgraph.TopologyLocation(onLoc);this.elt[1]=new jsts.geomgraph.TopologyLocation(onLoc)}};jsts.geomgraph.Label.toLineLabel=function(label){var i,lineLabel=new jsts.geomgraph.Label(jsts.geom.Location.NONE);for(i=0;i<2;i++){lineLabel.setLocation(i,label.getLocation(i))}return lineLabel};jsts.geomgraph.Label.prototype.elt=null;jsts.geomgraph.Label.prototype.flip=function(){this.elt[0].flip();this.elt[1].flip()};jsts.geomgraph.Label.prototype.getLocation=function(geomIndex,posIndex){if(arguments.length==1){return this.getLocation2.apply(this,arguments)}return this.elt[geomIndex].get(posIndex)};jsts.geomgraph.Label.prototype.getLocation2=function(geomIndex){return this.elt[geomIndex].get(jsts.geomgraph.Position.ON)};jsts.geomgraph.Label.prototype.setLocation=function(geomIndex,posIndex,location){if(arguments.length==2){this.setLocation2.apply(this,arguments);return}this.elt[geomIndex].setLocation(posIndex,location)};jsts.geomgraph.Label.prototype.setLocation2=function(geomIndex,location){this.elt[geomIndex].setLocation(jsts.geomgraph.Position.ON,location)};jsts.geomgraph.Label.prototype.setAllLocations=function(geomIndex,location){this.elt[geomIndex].setAllLocations(location)};jsts.geomgraph.Label.prototype.setAllLocationsIfNull=function(geomIndex,location){if(arguments.length==1){this.setAllLocationsIfNull2.apply(this,arguments);return}this.elt[geomIndex].setAllLocationsIfNull(location)};jsts.geomgraph.Label.prototype.setAllLocationsIfNull2=function(location){this.setAllLocationsIfNull(0,location);this.setAllLocationsIfNull(1,location)};jsts.geomgraph.Label.prototype.merge=function(lbl){var i;for(i=0;i<2;i++){if(this.elt[i]===null&&lbl.elt[i]!==null){this.elt[i]=new jsts.geomgraph.TopologyLocation(lbl.elt[i])}else{this.elt[i].merge(lbl.elt[i])}}};jsts.geomgraph.Label.prototype.getGeometryCount=function(){var count=0;if(!this.elt[0].isNull()){count++}if(!this.elt[1].isNull()){count++}return count};jsts.geomgraph.Label.prototype.isNull=function(geomIndex){return this.elt[geomIndex].isNull()};jsts.geomgraph.Label.prototype.isAnyNull=function(geomIndex){return this.elt[geomIndex].isAnyNull()};jsts.geomgraph.Label.prototype.isArea=function(){if(arguments.length==1){return this.isArea2(arguments[0])}return this.elt[0].isArea()||this.elt[1].isArea()};jsts.geomgraph.Label.prototype.isArea2=function(geomIndex){return this.elt[geomIndex].isArea()};jsts.geomgraph.Label.prototype.isLine=function(geomIndex){return this.elt[geomIndex].isLine()};jsts.geomgraph.Label.prototype.isEqualOnSide=function(lbl,side){return this.elt[0].isEqualOnSide(lbl.elt[0],side)&&this.elt[1].isEqualOnSide(lbl.elt[1],side)};jsts.geomgraph.Label.prototype.allPositionsEqual=function(geomIndex,loc){return this.elt[geomIndex].allPositionsEqual(loc)};jsts.geomgraph.Label.prototype.toLine=function(geomIndex){if(this.elt[geomIndex].isArea()){this.elt[geomIndex]=new jsts.geomgraph.TopologyLocation(this.elt[geomIndex].location[0])}};jsts.geomgraph.EdgeRing=function(start,geometryFactory){this.edges=[];this.pts=[];this.holes=[];this.label=new jsts.geomgraph.Label(jsts.geom.Location.NONE);this.geometryFactory=geometryFactory;if(start){this.computePoints(start);this.computeRing()}};jsts.geomgraph.EdgeRing.prototype.startDe=null;jsts.geomgraph.EdgeRing.prototype.maxNodeDegree=-1;jsts.geomgraph.EdgeRing.prototype.edges=null;jsts.geomgraph.EdgeRing.prototype.pts=null;jsts.geomgraph.EdgeRing.prototype.label=null;jsts.geomgraph.EdgeRing.prototype.ring=null;jsts.geomgraph.EdgeRing.prototype._isHole=null;jsts.geomgraph.EdgeRing.prototype.shell=null;jsts.geomgraph.EdgeRing.prototype.holes=null;jsts.geomgraph.EdgeRing.prototype.geometryFactory=null;jsts.geomgraph.EdgeRing.prototype.isIsolated=function(){return this.label.getGeometryCount()==1};jsts.geomgraph.EdgeRing.prototype.isHole=function(){return this._isHole};jsts.geomgraph.EdgeRing.prototype.getCoordinate=function(i){return this.pts[i]};jsts.geomgraph.EdgeRing.prototype.getLinearRing=function(){return this.ring};jsts.geomgraph.EdgeRing.prototype.getLabel=function(){return this.label};jsts.geomgraph.EdgeRing.prototype.isShell=function(){return this.shell===null};jsts.geomgraph.EdgeRing.prototype.getShell=function(){return this.shell};jsts.geomgraph.EdgeRing.prototype.setShell=function(shell){this.shell=shell;if(shell!==null)shell.addHole(this)};jsts.geomgraph.EdgeRing.prototype.addHole=function(ring){this.holes.push(ring)};jsts.geomgraph.EdgeRing.prototype.toPolygon=function(geometryFactory){var holeLR=[];for(var i=0;i<this.holes.length;i++){holeLR[i]=this.holes[i].getLinearRing()}var poly=this.geometryFactory.createPolygon(this.getLinearRing(),holeLR);return poly};jsts.geomgraph.EdgeRing.prototype.computeRing=function(){if(this.ring!==null)return;var coord=[];for(var i=0;i<this.pts.length;i++){coord[i]=this.pts[i]}this.ring=this.geometryFactory.createLinearRing(coord);this._isHole=jsts.algorithm.CGAlgorithms.isCCW(this.ring.getCoordinates())};jsts.geomgraph.EdgeRing.prototype.getNext=function(de){throw new jsts.error.AbstractInvocationError};jsts.geomgraph.EdgeRing.prototype.setEdgeRing=function(de,er){throw new jsts.error.AbstractInvocationError};jsts.geomgraph.EdgeRing.prototype.getEdges=function(){return this.edges};jsts.geomgraph.EdgeRing.prototype.computePoints=function(start){this.startDe=start;var de=start;var isFirstEdge=true;do{if(de===null)throw new jsts.error.TopologyError("Found null DirectedEdge");if(de.getEdgeRing()===this)throw new jsts.error.TopologyError("Directed Edge visited twice during ring-building at "+de.getCoordinate());this.edges.push(de);var label=de.getLabel();jsts.util.Assert.isTrue(label.isArea());this.mergeLabel(label);this.addPoints(de.getEdge(),de.isForward(),isFirstEdge);isFirstEdge=false;this.setEdgeRing(de,this);de=this.getNext(de)}while(de!==this.startDe)};jsts.geomgraph.EdgeRing.prototype.getMaxNodeDegree=function(){if(this.maxNodeDegree<0)this.computeMaxNodeDegree();return this.maxNodeDegree};jsts.geomgraph.EdgeRing.prototype.computeMaxNodeDegree=function(){this.maxNodeDegree=0;var de=this.startDe;do{var node=de.getNode();var degree=node.getEdges().getOutgoingDegree(this);if(degree>this.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<edgePts.length;i++){this.pts.push(edgePts[i])}}else{var startIndex=edgePts.length-2;if(isFirstEdge)startIndex=edgePts.length-1;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;i<this.holes.length;i++){var hole=this.holes[i];if(hole.containsPoint(p))return false}return true};(function(){jsts.geom.LinearRing=function(points,factory){jsts.geom.LineString.apply(this,arguments)};jsts.geom.LinearRing.prototype=new jsts.geom.LineString;jsts.geom.LinearRing.constructor=jsts.geom.LinearRing;jsts.geom.LinearRing.prototype.getBoundaryDimension=function(){return jsts.geom.Dimension.FALSE};jsts.geom.LinearRing.prototype.isSimple=function(){return true};jsts.geom.LinearRing.prototype.getGeometryType=function(){return"LinearRing"};jsts.geom.LinearRing.MINIMUM_VALID_SIZE=4;jsts.geom.LinearRing.prototype.CLASS_NAME="jsts.geom.LinearRing"})();jsts.index.strtree.Boundable=function(){};jsts.index.strtree.Boundable.prototype.getBounds=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractNode=function(level){this.level=level;this.childBoundables=[]};jsts.index.strtree.AbstractNode.prototype=new jsts.index.strtree.Boundable;jsts.index.strtree.AbstractNode.constructor=jsts.index.strtree.AbstractNode;jsts.index.strtree.AbstractNode.prototype.childBoundables=null;jsts.index.strtree.AbstractNode.prototype.bounds=null;jsts.index.strtree.AbstractNode.prototype.level=null;jsts.index.strtree.AbstractNode.prototype.getChildBoundables=function(){return this.childBoundables};jsts.index.strtree.AbstractNode.prototype.computeBounds=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractNode.prototype.getBounds=function(){if(this.bounds===null){this.bounds=this.computeBounds()}return this.bounds};jsts.index.strtree.AbstractNode.prototype.getLevel=function(){return this.level};jsts.index.strtree.AbstractNode.prototype.addChildBoundable=function(childBoundable){this.childBoundables.push(childBoundable)};(function(){jsts.noding.Noder=function(){};jsts.noding.Noder.prototype.computeNodes=jsts.abstractFunc;jsts.noding.Noder.prototype.getNodedSubstrings=jsts.abstractFunc})();(function(){var Noder=jsts.noding.Noder;jsts.noding.SinglePassNoder=function(){};jsts.noding.SinglePassNoder.prototype=new Noder;jsts.noding.SinglePassNoder.constructor=jsts.noding.SinglePassNoder;jsts.noding.SinglePassNoder.prototype.segInt=null;jsts.noding.SinglePassNoder.prototype.setSegmentIntersector=function(segInt){this.segInt=segInt}})();jsts.index.SpatialIndex=function(){};jsts.index.SpatialIndex.prototype.insert=function(itemEnv,item){throw new jsts.error.AbstractMethodInvocationError};jsts.index.SpatialIndex.prototype.query=function(searchEnv,visitor){throw new jsts.error.AbstractMethodInvocationError};jsts.index.SpatialIndex.prototype.remove=function(itemEnv,item){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractSTRtree=function(nodeCapacity){if(nodeCapacity===undefined)return;this.itemBoundables=[];jsts.util.Assert.isTrue(nodeCapacity>1,"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;i<childBoundables.length;i++){sortedChildBoundables.push(childBoundables[i])}sortedChildBoundables.sort(this.getComparator());for(var i=0;i<sortedChildBoundables.length;i++){var childBoundable=sortedChildBoundables[i];if(this.lastNode(parentBoundables).getChildBoundables().length===this.getNodeCapacity()){parentBoundables.push(this.createNode(newLevel))}this.lastNode(parentBoundables).addChildBoundable(childBoundable)}return parentBoundables};jsts.index.strtree.AbstractSTRtree.prototype.lastNode=function(nodes){return nodes[nodes.length-1]};jsts.index.strtree.AbstractSTRtree.prototype.compareDoubles=function(a,b){return a>b?1:a<b?-1:0};jsts.index.strtree.AbstractSTRtree.prototype.createHigherLevels=function(boundablesOfALevel,level){jsts.util.Assert.isTrue(!(boundablesOfALevel.length===0));var parentBoundables=this.createParentBoundables(boundablesOfALevel,level+1);if(parentBoundables.length===1){return parentBoundables[0]}return this.createHigherLevels(parentBoundables,level+1)};jsts.index.strtree.AbstractSTRtree.prototype.getRoot=function(){if(!this.built)this.build();return this.root};jsts.index.strtree.AbstractSTRtree.prototype.getNodeCapacity=function(){return this.nodeCapacity};jsts.index.strtree.AbstractSTRtree.prototype.size=function(){if(arguments.length===1){return this.size2(arguments[0])}if(!this.built){this.build()}if(this.itemBoundables.length===0){return 0}return this.size2(root)};jsts.index.strtree.AbstractSTRtree.prototype.size2=function(node){var size=0;var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(childBoundable instanceof jsts.index.strtree.AbstractNode){size+=this.size(childBoundable)}else if(childBoundable instanceof jsts.index.strtree.ItemBoundable){size+=1}}return size};jsts.index.strtree.AbstractSTRtree.prototype.depth=function(){if(arguments.length===1){return this.depth2(arguments[0])}if(!this.built){this.build()}if(this.itemBoundables.length===0){return 0}return this.depth2(root)};jsts.index.strtree.AbstractSTRtree.prototype.depth2=function(){var maxChildDepth=0;var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(childBoundable instanceof jsts.index.strtree.AbstractNode){var childDepth=this.depth(childBoundable);if(childDepth>maxChildDepth)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;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(!this.getIntersectsOp().intersects(childBoundable.getBounds(),searchBounds)){continue}if(childBoundable instanceof jsts.index.strtree.AbstractNode){this.query3(searchBounds,childBoundable,matches)}else if(childBoundable instanceof jsts.index.strtree.ItemBoundable){matches.push(childBoundable.getItem())}else{jsts.util.Assert.shouldNeverReachHere()}}};jsts.index.strtree.AbstractSTRtree.prototype.query4=function(searchBounds,node,visitor){
var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(!this.getIntersectsOp().intersects(childBoundable.getBounds(),searchBounds)){continue}if(childBoundable instanceof jsts.index.strtree.AbstractNode){this.query4(searchBounds,childBoundable,visitor)}else if(childBoundable instanceof jsts.index.strtree.ItemBoundable){visitor.visitItem(childBoundable.getItem())}else{jsts.util.Assert.shouldNeverReachHere()}}};jsts.index.strtree.AbstractSTRtree.prototype.getIntersectsOp=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.AbstractSTRtree.prototype.itemsTree=function(){if(arguments.length===1){return this.itemsTree2.apply(this,arguments)}if(!this.built){this.build()}var valuesTree=this.itemsTree2(this.root);if(valuesTree===null)return[];return valuesTree};jsts.index.strtree.AbstractSTRtree.prototype.itemsTree2=function(node){var valuesTreeForNode=[];var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(childBoundable instanceof jsts.index.strtree.AbstractNode){var valuesTreeForChild=this.itemsTree(childBoundable);if(valuesTreeForChild!=null)valuesTreeForNode.push(valuesTreeForChild)}else if(childBoundable instanceof jsts.index.strtree.ItemBoundable){valuesTreeForNode.push(childBoundable.getItem())}else{jsts.util.Assert.shouldNeverReachHere()}}if(valuesTreeForNode.length<=0)return null;return valuesTreeForNode};jsts.index.strtree.AbstractSTRtree.prototype.remove=function(searchBounds,item){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)){return this.remove2(searchBounds,this.root,item)}return false};jsts.index.strtree.AbstractSTRtree.prototype.remove2=function(searchBounds,node,item){var found=this.removeItem(node,item);if(found)return true;var childToPrune=null;var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(!this.getIntersectsOp().intersects(childBoundable.getBounds(),searchBounds)){continue}if(childBoundable instanceof jsts.index.strtree.AbstractNode){found=this.remove(searchBounds,childBoundable,item);if(found){childToPrune=childBoundable;break}}}if(childToPrune!=null){if(childToPrune.getChildBoundables().length===0){childBoundables.splice(childBoundables.indexOf(childToPrune),1)}}return found};jsts.index.strtree.AbstractSTRtree.prototype.removeItem=function(node,item){var childToRemove=null;var childBoundables=node.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(childBoundable instanceof jsts.index.strtree.ItemBoundable){if(childBoundable.getItem()===item)childToRemove=childBoundable}}if(childToRemove!==null){childBoundables.splice(childBoundables.indexOf(childToRemove),1);return true}return false};jsts.index.strtree.AbstractSTRtree.prototype.boundablesAtLevel=function(level){if(arguments.length>1){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;i<childBoundables.length;i++){var boundable=childBoundables[i];if(boundable instanceof jsts.index.strtree.AbstractNode){this.boundablesAtLevel(level,boundable,boundables)}else{jsts.util.Assert.isTrue(boundable instanceof jsts.index.strtree.ItemBoundable);if(level===-1){boundables.add(boundable)}}}return};jsts.index.strtree.AbstractSTRtree.prototype.getComparator=function(){throw new jsts.error.AbstractMethodInvocationError};jsts.index.strtree.STRtree=function(nodeCapacity){nodeCapacity=nodeCapacity||jsts.index.strtree.STRtree.DEFAULT_NODE_CAPACITY;jsts.index.strtree.AbstractSTRtree.call(this,nodeCapacity)};jsts.index.strtree.STRtree.prototype=new jsts.index.strtree.AbstractSTRtree;jsts.index.strtree.STRtree.constructor=jsts.index.strtree.STRtree;jsts.index.strtree.STRtree.prototype.xComparator=function(o1,o2){return jsts.index.strtree.AbstractSTRtree.prototype.compareDoubles(jsts.index.strtree.STRtree.prototype.centreX(o1.getBounds()),jsts.index.strtree.STRtree.prototype.centreX(o2.getBounds()))};jsts.index.strtree.STRtree.prototype.yComparator=function(o1,o2){return jsts.index.strtree.AbstractSTRtree.prototype.compareDoubles(jsts.index.strtree.STRtree.prototype.centreY(o1.getBounds()),jsts.index.strtree.STRtree.prototype.centreY(o2.getBounds()))};jsts.index.strtree.STRtree.prototype.centreX=function(e){return jsts.index.strtree.STRtree.prototype.avg(e.getMinX(),e.getMaxX())};jsts.index.strtree.STRtree.prototype.centreY=function(e){return jsts.index.strtree.STRtree.prototype.avg(e.getMinY(),e.getMaxY())};jsts.index.strtree.STRtree.prototype.avg=function(a,b){return(a+b)/2};jsts.index.strtree.STRtree.prototype.intersectsOp={intersects:function(aBounds,bBounds){return aBounds.intersects(bBounds)}};jsts.index.strtree.STRtree.prototype.createParentBoundables=function(childBoundables,newLevel){jsts.util.Assert.isTrue(!(childBoundables.length===0));var minLeafCount=Math.ceil(childBoundables.length/this.getNodeCapacity());var sortedChildBoundables=[];for(var i=0;i<childBoundables.length;i++){sortedChildBoundables.push(childBoundables[i])}sortedChildBoundables.sort(this.xComparator);var verticalSlices=this.verticalSlices(sortedChildBoundables,Math.ceil(Math.sqrt(minLeafCount)));return this.createParentBoundablesFromVerticalSlices(verticalSlices,newLevel)};jsts.index.strtree.STRtree.prototype.createParentBoundablesFromVerticalSlices=function(verticalSlices,newLevel){jsts.util.Assert.isTrue(verticalSlices.length>0);var parentBoundables=[];for(var i=0;i<verticalSlices.length;i++){parentBoundables=parentBoundables.concat(this.createParentBoundablesFromVerticalSlice(verticalSlices[i],newLevel))}return parentBoundables};jsts.index.strtree.STRtree.prototype.createParentBoundablesFromVerticalSlice=function(childBoundables,newLevel){return jsts.index.strtree.AbstractSTRtree.prototype.createParentBoundables.call(this,childBoundables,newLevel)};jsts.index.strtree.STRtree.prototype.verticalSlices=function(childBoundables,sliceCount){var sliceCapacity=Math.ceil(childBoundables.length/sliceCount);var slices=[];var i=0,boundablesAddedToSlice,childBoundable;for(var j=0;j<sliceCount;j++){slices[j]=[];boundablesAddedToSlice=0;while(i<childBoundables.length&&boundablesAddedToSlice<sliceCapacity){childBoundable=childBoundables[i++];slices[j].push(childBoundable);boundablesAddedToSlice++}}return slices};jsts.index.strtree.STRtree.DEFAULT_NODE_CAPACITY=10;jsts.index.strtree.STRtree.prototype.createNode=function(level){var abstractNode=new jsts.index.strtree.AbstractNode(level);abstractNode.computeBounds=function(){var bounds=null;var childBoundables=this.getChildBoundables();for(var i=0;i<childBoundables.length;i++){var childBoundable=childBoundables[i];if(bounds===null){bounds=new jsts.geom.Envelope(childBoundable.getBounds())}else{bounds.expandToInclude(childBoundable.getBounds())}}return bounds};return abstractNode};jsts.index.strtree.STRtree.prototype.getIntersectsOp=function(){return this.intersectsOp};jsts.index.strtree.STRtree.prototype.insert=function(itemEnv,item){if(itemEnv.isNull()){return}jsts.index.strtree.AbstractSTRtree.prototype.insert.call(this,itemEnv,item)};jsts.index.strtree.STRtree.prototype.query=function(searchEnv,visitor){return jsts.index.strtree.AbstractSTRtree.prototype.query.apply(this,arguments)};jsts.index.strtree.STRtree.prototype.remove=function(itemEnv,item){return jsts.index.strtree.AbstractSTRtree.prototype.remove.call(this,itemEnv,item)};jsts.index.strtree.STRtree.prototype.size=function(){return jsts.index.strtree.AbstractSTRtree.prototype.size.call(this)};jsts.index.strtree.STRtree.prototype.depth=function(){return jsts.index.strtree.AbstractSTRtree.prototype.depth.call(this)};jsts.index.strtree.STRtree.prototype.getComparator=function(){return this.yComparator};jsts.index.strtree.STRtree.prototype.nearestNeighbour=function(itemDist){var bp=new jsts.index.strtree.BoundablePair(this.getRoot(),this.getRoot(),itemDist);return this.nearestNeighbour4(bp)};jsts.index.strtree.STRtree.prototype.nearestNeighbour2=function(env,item,itemDist){var bnd=new jsts.index.strtree.ItemBoundable(env,item);var bp=new jsts.index.strtree.BoundablePair(this.getRoot(),bnd,itemDist);return this.nearestNeighbour4(bp)[0]};jsts.index.strtree.STRtree.prototype.nearestNeighbour3=function(tree,itemDist){var bp=new jsts.index.strtree.BoundablePair(this.getRoot(),tree.getRoot(),itemDist);return this.nearestNeighbour4(bp)};jsts.index.strtree.STRtree.prototype.nearestNeighbour4=function(initBndPair){return this.nearestNeighbour5(initBndPair,Double.POSITIVE_INFINITY)};jsts.index.strtree.STRtree.prototype.nearestNeighbour5=function(initBndPair,maxDistance){var distanceLowerBound=maxDistance;var minPair=null;var priQ=[];priQ.push(initBndPair);while(!priQ.isEmpty()&&distanceLowerBound>0){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<li.getIntersectionNum();i++){this.addIntersection(li,segmentIndex,geomIndex,i)}};jsts.noding.NodedSegmentString.prototype.addIntersection=function(li,segmentIndex,geomIndex,intIndex){if(li instanceof jsts.geom.Coordinate){this.addIntersection2.apply(this,arguments);return}var intPt=new jsts.geom.Coordinate(li.getIntersection(intIndex));this.addIntersection2(intPt,segmentIndex)};jsts.noding.NodedSegmentString.prototype.addIntersection2=function(intPt,segmentIndex){this.addIntersectionNode(intPt,segmentIndex)};jsts.noding.NodedSegmentString.prototype.addIntersectionNode=function(intPt,segmentIndex){var normalizedSegmentIndex=segmentIndex;var nextSegIndex=normalizedSegmentIndex+1;if(nextSegIndex<this.pts.length){var nextPt=this.pts[nextSegIndex];if(intPt.equals2D(nextPt)){normalizedSegmentIndex=nextSegIndex}}var ei=this.nodeList.add(intPt,normalizedSegmentIndex);return ei};jsts.noding.NodedSegmentString.prototype.toString=function(){var geometryFactory=new jsts.geom.GeometryFactory;return(new jsts.io.WKTWriter).write(geometryFactory.createLineString(this.pts))};jsts.index.chain.MonotoneChainBuilder=function(){};jsts.index.chain.MonotoneChainBuilder.toIntArray=function(list){var array=[];for(var i=0;i<list.length;i++){array[i]=list[i]}return array};jsts.index.chain.MonotoneChainBuilder.getChains=function(pts){if(arguments.length===2){return jsts.index.chain.MonotoneChainBuilder.getChains2.apply(this,arguments)}return jsts.index.chain.MonotoneChainBuilder.getChains2(pts,null)};jsts.index.chain.MonotoneChainBuilder.getChains2=function(pts,context){var mcList=[];var startIndex=jsts.index.chain.MonotoneChainBuilder.getChainStartIndices(pts);for(var i=0;i<startIndex.length-1;i++){var mc=new jsts.index.chain.MonotoneChain(pts,startIndex[i],startIndex[i+1],context);mcList.push(mc)}return mcList};jsts.index.chain.MonotoneChainBuilder.getChainStartIndices=function(pts){var start=0;var startIndexList=[];startIndexList.push(start);do{var last=jsts.index.chain.MonotoneChainBuilder.findChainEnd(pts,start);startIndexList.push(last);start=last}while(start<pts.length-1);var startIndex=jsts.index.chain.MonotoneChainBuilder.toIntArray(startIndexList);return startIndex};jsts.index.chain.MonotoneChainBuilder.findChainEnd=function(pts,start){var safeStart=start;while(safeStart<pts.length-1&&pts[safeStart].equals2D(pts[safeStart+1])){safeStart++}if(safeStart>=pts.length-1){return pts.length-1}var chainQuad=jsts.geomgraph.Quadrant.quadrant(pts[safeStart],pts[safeStart+1]);var last=start+1;while(last<pts.length){if(!pts[last-1].equals2D(pts[last])){var quad=jsts.geomgraph.Quadrant.quadrant(pts[last-1],pts[last]);if(quad!==chainQuad)break}last++}return last-1};jsts.algorithm.LineIntersector=function(){this.inputLines=[[],[]];this.intPt=[null,null];this.pa=this.intPt[0];this.pb=this.intPt[1];this.result=jsts.algorithm.LineIntersector.NO_INTERSECTION};jsts.algorithm.LineIntersector.NO_INTERSECTION=0;jsts.algorithm.LineIntersector.POINT_INTERSECTION=1;jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION=2;jsts.algorithm.LineIntersector.prototype.setPrecisionModel=function(precisionModel){this.precisionModel=precisionModel};jsts.algorithm.LineIntersector.prototype.getEndpoint=function(segmentIndex,ptIndex){return this.inputLines[segmentIndex][ptIndex]};jsts.algorithm.LineIntersector.computeEdgeDistance=function(p,p0,p1){var dx=Math.abs(p1.x-p0.x);var dy=Math.abs(p1.y-p0.y);var dist=-1;if(p.equals(p0)){dist=0}else if(p.equals(p1)){if(dx>dy){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;i<this.result;i++){if(this.intPt[i].equals2D(pt)){return true}}return false};jsts.algorithm.LineIntersector.prototype.isInteriorIntersection=function(){if(arguments.length===1){return this.isInteriorIntersection2.apply(this,arguments)}if(this.isInteriorIntersection(0)){return true}if(this.isInteriorIntersection(1)){return true}return false};jsts.algorithm.LineIntersector.prototype.isInteriorIntersection2=function(inputLineIndex){var i;for(i=0;i<this.result;i++){if(!(this.intPt[i].equals2D(this.inputLines[inputLineIndex][0])||this.intPt[i].equals2D(this.inputLines[inputLineIndex][1]))){return true}}return false};jsts.algorithm.LineIntersector.prototype.isProper=function(){return this.hasIntersection()&&this._isProper};jsts.algorithm.LineIntersector.prototype.getIntersectionAlongSegment=function(segmentIndex,intIndex){this.computeIntLineIndex();return this.intPt[intLineIndex[segmentIndex][intIndex]]};jsts.algorithm.LineIntersector.prototype.getIndexAlongSegment=function(segmentIndex,intIndex){this.computeIntLineIndex();return this.intLineIndex[segmentIndex][intIndex]};jsts.algorithm.LineIntersector.prototype.computeIntLineIndex=function(segmentIndex){var dist0=this.getEdgeDistance(segmentIndex,0);var dist1=this.getEdgeDistance(segmentIndex,1);if(dist0>dist1){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.x<n01.x?n00.x:n01.x;var minY0=n00.y<n01.y?n00.y:n01.y;var maxX0=n00.x>n01.x?n00.x:n01.x;var maxY0=n00.y>n01.y?n00.y:n01.y;var minX1=n10.x<n11.x?n10.x:n11.x;var minY1=n10.y<n11.y?n10.y:n11.y;var maxX1=n10.x>n11.x?n10.x:n11.x;var maxY1=n10.y>n11.y?n10.y:n11.y;var intMinX=minX0>minX1?minX0:minX1;var intMaxX=maxX0<maxX1?maxX0:maxX1;var intMinY=minY0>minY1?minY0:minY1;var intMaxY=maxY0<maxY1?maxY0:maxY1;var intMidX=(intMinX+intMaxX)/2;var intMidY=(intMinY+intMaxY)/2;normPt.x=intMidX;normPt.y=intMidY;n00.x-=normPt.x;n00.y-=normPt.y;n01.x-=normPt.x;n01.y-=normPt.y;n10.x-=normPt.x;n10.y-=normPt.y;n11.x-=normPt.x;n11.y-=normPt.y};jsts.algorithm.RobustLineIntersector.prototype.smallestInAbsValue=function(x1,x2,x3,x4){var x=x1;var xabs=Math.abs(x);if(Math.abs(x2)<xabs){x=x2;xabs=Math.abs(x2)}if(Math.abs(x3)<xabs){x=x3;xabs=Math.abs(x3)}if(Math.abs(x4)<xabs){x=x4}return x};jsts.algorithm.RobustLineIntersector.prototype.isInSegmentEnvelopes=function(intPt){var env0=new jsts.geom.Envelope(this.inputLines[0][0],this.inputLines[0][1]);var env1=new jsts.geom.Envelope(this.inputLines[1][0],this.inputLines[1][1]);return env0.contains(intPt)&&env1.contains(intPt)};jsts.algorithm.HCoordinate=function(){this.x=0;this.y=0;this.w=1;if(arguments.length===1){this.initFrom1Coordinate(arguments[0])}else if(arguments.length===2&&arguments[0]instanceof jsts.geom.Coordinate){this.initFrom2Coordinates(arguments[0],arguments[1])}else if(arguments.length===2&&arguments[0]instanceof jsts.algorithm.HCoordinate){this.initFrom2HCoordinates(arguments[0],arguments[1])}else if(arguments.length===2){this.initFromXY(arguments[0],arguments[1])}else if(arguments.length===3){this.initFromXYW(arguments[0],arguments[1],arguments[2])}else if(arguments.length===4){this.initFromXYW(arguments[0],arguments[1],arguments[2],arguments[3])}};jsts.algorithm.HCoordinate.intersection=function(p1,p2,q1,q2){var px,py,pw,qx,qy,qw,x,y,w,xInt,yInt;px=p1.y-p2.y;py=p2.x-p1.x;pw=p1.x*p2.y-p2.x*p1.y;qx=q1.y-q2.y;qy=q2.x-q1.x;qw=q1.x*q2.y-q2.x*q1.y;x=py*qw-qy*pw;y=qx*pw-px*qw;w=px*qy-qx*py;xInt=x/w;yInt=y/w;if(!isFinite(xInt)||!isFinite(yInt)){throw new jsts.error.NotRepresentableError}return new jsts.geom.Coordinate(xInt,yInt)};jsts.algorithm.HCoordinate.prototype.initFrom1Coordinate=function(p){this.x=p.x;this.y=p.y;this.w=1};jsts.algorithm.HCoordinate.prototype.initFrom2Coordinates=function(p1,p2){this.x=p1.y-p2.y;this.y=p2.x-p1.x;this.w=p1.x*p2.y-p2.x*p1.y};jsts.algorithm.HCoordinate.prototype.initFrom2HCoordinates=function(p1,p2){this.x=p1.y*p2.w-p2.y*p1.w;this.y=p2.x*p1.w-p1.x*p2.w;this.w=p1.x*p2.y-p2.x*p1.y};jsts.algorithm.HCoordinate.prototype.initFromXYW=function(x,y,w){this.x=x;this.y=y;this.w=w};jsts.algorithm.HCoordinate.prototype.initFromXY=function(x,y){this.x=x;this.y=y;this.w=1};jsts.algorithm.HCoordinate.prototype.initFrom4Coordinates=function(p1,p2,q1,q2){var px,py,pw,qx,qy,qw;px=p1.y-p2.y;py=p2.x-p1.x;pw=p1.x*p2.y-p2.x*p1.y;qx=q1.y-q2.y;qy=q2.x-q1.x;qw=q1.x*q2.y-q2.x*q1.y;this.x=py*qw-qy*pw;this.y=qx*pw-px*qw;this.w=px*qy-qx*py};jsts.algorithm.HCoordinate.prototype.getX=function(){var a=this.x/this.w;if(!isFinite(a)){throw new jsts.error.NotRepresentableError}return a};jsts.algorithm.HCoordinate.prototype.getY=function(){var a=this.y/this.w;if(!isFinite(a)){throw new jsts.error.NotRepresentableError}return a};jsts.algorithm.HCoordinate.prototype.getCoordinate=function(){var p=new jsts.geom.Coordinate;p.x=this.getX();p.y=this.getY();return p};jsts.geom.LineSegment=function(){if(arguments.length===0){this.p0=new jsts.geom.Coordinate;this.p1=new jsts.geom.Coordinate}else if(arguments.length===1){this.p0=arguments[0].p0;this.p1=arguments[0].p1}else if(arguments.length===2){this.p0=arguments[0];this.p1=arguments[1]}else if(arguments.length===4){this.p0=new jsts.geom.Coordinate(arguments[0],arguments[1]);this.p1=new jsts.geom.Coordinate(arguments[2],arguments[3])}};jsts.geom.LineSegment.prototype.p0=null;jsts.geom.LineSegment.prototype.p1=null;jsts.geom.LineSegment.midPoint=function(p0,p1){return new jsts.geom.Coordinate((p0.x+p1.x)/2,(p0.y+p1.y)/2)};jsts.geom.LineSegment.prototype.getCoordinate=function(i){if(i===0)return this.p0;return this.p1};jsts.geom.LineSegment.prototype.getLength=function(){return this.p0.distance(this.p1)};jsts.geom.LineSegment.prototype.isHorizontal=function(){return this.p0.y===this.p1.y};jsts.geom.LineSegment.prototype.isVertical=function(){return this.p0.x===this.p1.x};jsts.geom.LineSegment.prototype.orientationIndex=function(arg){if(arg instanceof jsts.geom.LineSegment){return this.orientationIndex1(arg)}else if(arg instanceof jsts.geom.Coordinate){return this.orientationIndex2(arg)}};jsts.geom.LineSegment.prototype.orientationIndex1=function(seg){var orient0=jsts.algorithm.CGAlgorithms.orientationIndex(this.p0,this.p1,seg.p0);var orient1=jsts.algorithm.CGAlgorithms.orientationIndex(this.p0,this.p1,seg.p1);if(orient0>=0&&orient1>=0){return Math.max(orient0,orient1)}if(orient0<=0&&orient1<=0){return Math.max(orient0,orient1)}return 0};jsts.geom.LineSegment.prototype.orientationIndex2=function(p){return jsts.algorithm.CGAlgorithms.orientationIndex(this.p0,this.p1,p)};jsts.geom.LineSegment.prototype.reverse=function(){var temp=this.p0;this.p0=this.p1;this.p1=temp};jsts.geom.LineSegment.prototype.normalize=function(){if(this.p1.compareTo(this.p0)<0)this.reverse()};jsts.geom.LineSegment.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)};jsts.geom.LineSegment.prototype.midPoint=function(){return jsts.geom.LineSegment.midPoint(this.p0,this.p1)};jsts.geom.LineSegment.prototype.distance=function(arg){if(arg instanceof jsts.geom.LineSegment){return this.distance1(arg)}else if(arg instanceof jsts.geom.Coordinate){return this.distance2(arg)}};jsts.geom.LineSegment.prototype.distance1=function(ls){return jsts.algorithm.CGAlgorithms.distanceLineLine(this.p0,this.p1,ls.p0,ls.p1)};jsts.geom.LineSegment.prototype.distance2=function(p){return jsts.algorithm.CGAlgorithms.distancePointLine(p,this.p0,this.p1)};jsts.geom.LineSegment.prototype.pointAlong=function(segmentLengthFraction){var coord=new jsts.geom.Coordinate;coord.x=this.p0.x+segmentLengthFraction*(this.p1.x-this.p0.x);coord.y=this.p0.y+segmentLengthFraction*(this.p1.y-this.p0.y);return coord};jsts.geom.LineSegment.prototype.pointAlongOffset=function(segmentLengthFraction,offsetDistance){var segx=this.p0.x+segmentLengthFraction*(this.p1.x-this.p0.x);var segy=this.p0.y+segmentLengthFraction*(this.p1.y-this.p0.y);var dx=this.p1.x-this.p0.x;var dy=this.p1.y-this.p0.y;var len=Math.sqrt(dx*dx+dy*dy);var ux=0;var uy=0;if(offsetDistance!==0){if(len<=0){throw"Cannot compute offset from zero-length line segment"}ux=offsetDistance*dx/len;uy=offsetDistance*dy/len}var offsetx=segx-uy;var offsety=segy+ux;var coord=new jsts.geom.Coordinate(offsetx,offsety);return coord};jsts.geom.LineSegment.prototype.projectionFactor=function(p){if(p.equals(this.p0))return 0;if(p.equals(this.p1))return 1;var dx=this.p1.x-this.p0.x;var dy=this.p1.y-this.p0.y;var len2=dx*dx+dy*dy;var r=((p.x-this.p0.x)*dx+(p.y-this.p0.y)*dy)/len2;return r};jsts.geom.LineSegment.prototype.segmentFraction=function(inputPt){var segFrac=this.projectionFactor(inputPt);if(segFrac<0){segFrac=0}else if(segFrac>1||isNaN(segFrac)){segFrac=1}return segFrac};jsts.geom.LineSegment.prototype.project=function(arg){
if(arg instanceof jsts.geom.Coordinate){return this.project1(arg)}else if(arg instanceof jsts.geom.LineSegment){return this.project2(arg)}};jsts.geom.LineSegment.prototype.project1=function(p){if(p.equals(this.p0)||p.equals(this.p1)){return new jsts.geom.Coordinate(p)}var r=this.projectionFactor(p);var coord=new jsts.geom.Coordinate;coord.x=this.p0.x+r*(this.p1.x-this.p0.x);coord.y=this.p0.y+r*(this.p1.y-this.p0.y);return coord};jsts.geom.LineSegment.prototype.project2=function(seg){var pf0=this.projectionFactor(seg.p0);var pf1=this.projectionFactor(seg.p1);if(pf0>=1&&pf1>=1)return null;if(pf0<=0&&pf1<=0)return null;var newp0=this.project(seg.p0);if(pf0<0)newp0=p0;if(pf0>1)newp0=p1;var newp1=this.project(seg.p1);if(pf1<0)newp1=p0;if(pf1>1)newp1=p1;return new jsts.geom.LineSegment(newp0,newp1)};jsts.geom.LineSegment.prototype.closestPoint=function(p){var factor=this.projectionFactor(p);if(factor>0&&factor<1){return this.project(p)}var dist0=this.p0.distance(p);var dist1=this.p1.distance(p);if(dist0<dist1)return this.p0;return this.p1};jsts.geom.LineSegment.prototype.closestPoints=function(line){var intPt=this.intersection(line);if(intPt!==null){return[intPt,intPt]}var closestPt=[];var minDistance=Number.MAX_VALUE;var dist;var close00=this.closestPoint(line.p0);minDistance=close00.distance(line.p0);closestPt[0]=close00;closestPt[1]=line.p0;var close01=this.closestPoint(line.p1);dist=close01.distance(line.p1);if(dist<minDistance){minDistance=dist;closestPt[0]=close01;closestPt[1]=line.p1}var close10=line.closestPoint(this.p0);dist=close10.distance(this.p0);if(dist<minDistance){minDistance=dist;closestPt[0]=this.p0;closestPt[1]=close10}var close11=line.closestPoint(this.p1);dist=close11.distance(this.p1);if(dist<minDistance){minDistance=dist;closestPt[0]=this.p1;closestPt[1]=close11}return closestPt};jsts.geom.LineSegment.prototype.intersection=function(line){var li=new jsts.algorithm.RobustLineIntersector;li.computeIntersection(this.p0,this.p1,line.p0,line.p1);if(li.hasIntersection())return li.getIntersection(0);return null};jsts.geom.LineSegment.prototype.setCoordinates=function(ls){if(ls instanceof jsts.geom.Coordinate){this.setCoordinates2.apply(this,arguments);return}this.setCoordinates2(ls.p0,ls.p1)};jsts.geom.LineSegment.prototype.setCoordinates2=function(p0,p1){this.p0.x=p0.x;this.p0.y=p0.y;this.p1.x=p1.x;this.p1.y=p1.y};jsts.geom.LineSegment.prototype.distancePerpendicular=function(p){return jsts.algorithm.CGAlgorithms.distancePointLinePerpendicular(p,this.p0,this.p1)};jsts.geom.LineSegment.prototype.lineIntersection=function(line){try{var intPt=jsts.algorithm.HCoordinate.intersection(this.p0,this.p1,line.p0,line.p1);return intPt}catch(ex){}return null};jsts.geom.LineSegment.prototype.toGeometry=function(geomFactory){return geomFactory.createLineString([this.p0,this.p1])};jsts.geom.LineSegment.prototype.equals=function(o){if(!(o instanceof jsts.geom.LineSegment)){return false}return this.p0.equals(o.p0)&&this.p1.equals(o.p1)};jsts.geom.LineSegment.prototype.compareTo=function(o){var comp0=this.p0.compareTo(o.p0);if(comp0!==0)return comp0;return this.p1.compareTo(o.p1)};jsts.geom.LineSegment.prototype.equalsTopo=function(other){return this.p0.equals(other.p0)&&this.p1.equals(other.p1)||this.p0.equals(other.p1)&&this.p1.equals(other.p0)};jsts.geom.LineSegment.prototype.toString=function(){return"LINESTRING("+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"};jsts.index.chain.MonotoneChainOverlapAction=function(){this.tempEnv1=new jsts.geom.Envelope;this.tempEnv2=new jsts.geom.Envelope;this.overlapSeg1=new jsts.geom.LineSegment;this.overlapSeg2=new jsts.geom.LineSegment};jsts.index.chain.MonotoneChainOverlapAction.prototype.tempEnv1=null;jsts.index.chain.MonotoneChainOverlapAction.prototype.tempEnv2=null;jsts.index.chain.MonotoneChainOverlapAction.prototype.overlapSeg1=null;jsts.index.chain.MonotoneChainOverlapAction.prototype.overlapSeg2=null;jsts.index.chain.MonotoneChainOverlapAction.prototype.overlap=function(mc1,start1,mc2,start2){this.mc1.getLineSegment(start1,this.overlapSeg1);this.mc2.getLineSegment(start2,this.overlapSeg2);this.overlap2(this.overlapSeg1,this.overlapSeg2)};jsts.index.chain.MonotoneChainOverlapAction.prototype.overlap2=function(seg1,seg2){};(function(){var MonotoneChainOverlapAction=jsts.index.chain.MonotoneChainOverlapAction;var SinglePassNoder=jsts.noding.SinglePassNoder;var STRtree=jsts.index.strtree.STRtree;var NodedSegmentString=jsts.noding.NodedSegmentString;var MonotoneChainBuilder=jsts.index.chain.MonotoneChainBuilder;var SegmentOverlapAction=function(si){this.si=si};SegmentOverlapAction.prototype=new MonotoneChainOverlapAction;SegmentOverlapAction.constructor=SegmentOverlapAction;SegmentOverlapAction.prototype.si=null;SegmentOverlapAction.prototype.overlap=function(mc1,start1,mc2,start2){var ss1=mc1.getContext();var ss2=mc2.getContext();this.si.processIntersections(ss1,start1,ss2,start2)};jsts.noding.MCIndexNoder=function(){this.monoChains=[];this.index=new STRtree};jsts.noding.MCIndexNoder.prototype=new SinglePassNoder;jsts.noding.MCIndexNoder.constructor=jsts.noding.MCIndexNoder;jsts.noding.MCIndexNoder.prototype.monoChains=null;jsts.noding.MCIndexNoder.prototype.index=null;jsts.noding.MCIndexNoder.prototype.idCounter=0;jsts.noding.MCIndexNoder.prototype.nodedSegStrings=null;jsts.noding.MCIndexNoder.prototype.nOverlaps=0;jsts.noding.MCIndexNoder.prototype.getMonotoneChains=function(){return this.monoChains};jsts.noding.MCIndexNoder.prototype.getIndex=function(){return this.index};jsts.noding.MCIndexNoder.prototype.getNodedSubstrings=function(){return NodedSegmentString.getNodedSubstrings(this.nodedSegStrings)};jsts.noding.MCIndexNoder.prototype.computeNodes=function(inputSegStrings){this.nodedSegStrings=inputSegStrings;for(var i=inputSegStrings.iterator();i.hasNext();){this.add(i.next())}this.intersectChains()};jsts.noding.MCIndexNoder.prototype.intersectChains=function(){var overlapAction=new SegmentOverlapAction(this.segInt);for(var i=0;i<this.monoChains.length;i++){var queryChain=this.monoChains[i];var overlapChains=this.index.query(queryChain.getEnvelope());for(var j=0;j<overlapChains.length;j++){var testChain=overlapChains[j];if(testChain.getId()>queryChain.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;i<segChains.length;i++){var mc=segChains[i];mc.setId(this.idCounter++);this.index.insert(mc.getEnvelope(),mc);this.monoChains.push(mc)}}})();jsts.simplify.LineSegmentIndex=function(){this.index=new jsts.index.quadtree.Quadtree};jsts.simplify.LineSegmentIndex.prototype.index=null;jsts.simplify.LineSegmentIndex.prototype.add=function(line){if(line instanceof jsts.geom.LineSegment){this.add2(line);return}var segs=line.getSegments();for(var i=0;i<segs.length;i++){var seg=segs[i];this.add2(seg)}};jsts.simplify.LineSegmentIndex.prototype.add2=function(seg){this.index.insert(new jsts.geom.Envelope(seg.p0,seg.p1),seg)};jsts.simplify.LineSegmentIndex.prototype.remove=function(seg){this.index.remove(new jsts.geom.Envelope(seg.p0,seg.p1),seg)};jsts.simplify.LineSegmentIndex.prototype.query=function(querySeg){var env=new jsts.geom.Envelope(querySeg.p0,querySeg.p1);var visitor=new jsts.simplify.LineSegmentIndex.LineSegmentVisitor(querySeg);this.index.query(env,visitor);var itemsFound=visitor.getItems();return itemsFound};jsts.simplify.LineSegmentIndex.LineSegmentVisitor=function(querySeg){this.items=[];this.querySeg=querySeg};jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype=new jsts.index.ItemVisitor;jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.querySeg=null;jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.items=null;jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.visitItem=function(item){var seg=item;if(jsts.geom.Envelope.intersects(seg.p0,seg.p1,this.querySeg.p0,this.querySeg.p1))this.items.push(item)};jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.getItems=function(){return this.items};jsts.geomgraph.EdgeEndStar=function(){this.edgeMap=new javascript.util.TreeMap;this.edgeList=null;this.ptInAreaLocation=[jsts.geom.Location.NONE,jsts.geom.Location.NONE]};jsts.geomgraph.EdgeEndStar.prototype.edgeMap=null;jsts.geomgraph.EdgeEndStar.prototype.edgeList=null;jsts.geomgraph.EdgeEndStar.prototype.ptInAreaLocation=null;jsts.geomgraph.EdgeEndStar.prototype.insert=function(e){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.EdgeEndStar.prototype.insertEdgeEnd=function(e,obj){this.edgeMap.put(e,obj);this.edgeList=null};jsts.geomgraph.EdgeEndStar.prototype.getCoordinate=function(){var it=this.iterator();if(!it.hasNext())return null;var e=it.next();return e.getCoordinate()};jsts.geomgraph.EdgeEndStar.prototype.getDegree=function(){return this.edgeMap.size()};jsts.geomgraph.EdgeEndStar.prototype.iterator=function(){return this.getEdges().iterator()};jsts.geomgraph.EdgeEndStar.prototype.getEdges=function(){if(this.edgeList===null){this.edgeList=new javascript.util.ArrayList(this.edgeMap.values())}return this.edgeList};jsts.geomgraph.EdgeEndStar.prototype.getNextCW=function(ee){this.getEdges();var i=this.edgeList.indexOf(ee);var iNextCW=i-1;if(i===0)iNextCW=this.edgeList.length-1;return this.edgeList[iNextCW]};jsts.geomgraph.EdgeEndStar.prototype.computeLabelling=function(geomGraph){this.computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());this.propagateSideLabels(0);this.propagateSideLabels(1);var hasDimensionalCollapseEdge=[false,false];for(var it=this.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();for(var geomi=0;geomi<2;geomi++){if(label.isLine(geomi)&&label.getLocation(geomi)===jsts.geom.Location.BOUNDARY)hasDimensionalCollapseEdge[geomi]=true}}for(var it=this.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();for(var geomi=0;geomi<2;geomi++){if(label.isAnyNull(geomi)){var loc=jsts.geom.Location.NONE;if(hasDimensionalCollapseEdge[geomi]){loc=jsts.geom.Location.EXTERIOR}else{var p=e.getCoordinate();loc=this.getLocation(geomi,p,geomGraph)}label.setAllLocationsIfNull(geomi,loc)}}}};jsts.geomgraph.EdgeEndStar.prototype.computeEdgeEndLabels=function(boundaryNodeRule){for(var it=this.iterator();it.hasNext();){var ee=it.next();ee.computeLabel(boundaryNodeRule)}};jsts.geomgraph.EdgeEndStar.prototype.getLocation=function(geomIndex,p,geom){if(this.ptInAreaLocation[geomIndex]===jsts.geom.Location.NONE){this.ptInAreaLocation[geomIndex]=jsts.algorithm.locate.SimplePointInAreaLocator.locate(p,geom[geomIndex].getGeometry())}return this.ptInAreaLocation[geomIndex]};jsts.geomgraph.EdgeEndStar.prototype.isAreaLabelsConsistent=function(geomGraph){this.computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());return this.checkAreaLabelsConsistent(0)};jsts.geomgraph.EdgeEndStar.prototype.checkAreaLabelsConsistent=function(geomIndex){var edges=this.getEdges();if(edges.size()<=0)return true;var lastEdgeIndex=edges.size()-1;var startLabel=edges.get(lastEdgeIndex).getLabel();var startLoc=startLabel.getLocation(geomIndex,jsts.geomgraph.Position.LEFT);jsts.util.Assert.isTrue(startLoc!=jsts.geom.Location.NONE,"Found unlabelled area edge");var currLoc=startLoc;for(var it=this.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();jsts.util.Assert.isTrue(label.isArea(geomIndex),"Found non-area edge");var leftLoc=label.getLocation(geomIndex,jsts.geomgraph.Position.LEFT);var rightLoc=label.getLocation(geomIndex,jsts.geomgraph.Position.RIGHT);if(leftLoc===rightLoc){return false}if(rightLoc!==currLoc){return false}currLoc=leftLoc}return true};jsts.geomgraph.EdgeEndStar.prototype.propagateSideLabels=function(geomIndex){var startLoc=jsts.geom.Location.NONE;for(var it=this.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();if(label.isArea(geomIndex)&&label.getLocation(geomIndex,jsts.geomgraph.Position.LEFT)!==jsts.geom.Location.NONE)startLoc=label.getLocation(geomIndex,jsts.geomgraph.Position.LEFT)}if(startLoc===jsts.geom.Location.NONE)return;var currLoc=startLoc;for(var it=this.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();if(label.getLocation(geomIndex,jsts.geomgraph.Position.ON)===jsts.geom.Location.NONE)label.setLocation(geomIndex,jsts.geomgraph.Position.ON,currLoc);if(label.isArea(geomIndex)){var leftLoc=label.getLocation(geomIndex,jsts.geomgraph.Position.LEFT);var rightLoc=label.getLocation(geomIndex,jsts.geomgraph.Position.RIGHT);if(rightLoc!==jsts.geom.Location.NONE){if(rightLoc!==currLoc)throw new jsts.error.TopologyError("side location conflict",e.getCoordinate());if(leftLoc===jsts.geom.Location.NONE){jsts.util.Assert.shouldNeverReachHere("found single null side (at "+e.getCoordinate()+")")}currLoc=leftLoc}else{jsts.util.Assert.isTrue(label.getLocation(geomIndex,jsts.geomgraph.Position.LEFT)===jsts.geom.Location.NONE,"found single null side");label.setLocation(geomIndex,jsts.geomgraph.Position.RIGHT,currLoc);label.setLocation(geomIndex,jsts.geomgraph.Position.LEFT,currLoc)}}}};jsts.geomgraph.EdgeEndStar.prototype.findIndex=function(eSearch){this.iterator();for(var i=0;i<this.edgeList.size();i++){var e=this.edgeList.get(i);if(e===eSearch)return i}return-1};jsts.operation.relate.EdgeEndBundleStar=function(){jsts.geomgraph.EdgeEndStar.apply(this,arguments)};jsts.operation.relate.EdgeEndBundleStar.prototype=new jsts.geomgraph.EdgeEndStar;jsts.operation.relate.EdgeEndBundleStar.prototype.insert=function(e){var eb=this.edgeMap.get(e);if(eb===null){eb=new jsts.operation.relate.EdgeEndBundle(e);this.insertEdgeEnd(e,eb)}else{eb.insert(e)}};jsts.operation.relate.EdgeEndBundleStar.prototype.updateIM=function(im){for(var it=this.iterator();it.hasNext();){var esb=it.next();esb.updateIM(im)}};jsts.index.ArrayListVisitor=function(){this.items=[]};jsts.index.ArrayListVisitor.prototype.visitItem=function(item){this.items.push(item)};jsts.index.ArrayListVisitor.prototype.getItems=function(){return this.items};jsts.algorithm.distance.DistanceToPoint=function(){};jsts.algorithm.distance.DistanceToPoint.computeDistance=function(geom,pt,ptDist){if(geom instanceof jsts.geom.LineString){jsts.algorithm.distance.DistanceToPoint.computeDistance2(geom,pt,ptDist)}else if(geom instanceof jsts.geom.Polygon){jsts.algorithm.distance.DistanceToPoint.computeDistance4(geom,pt,ptDist)}else if(geom instanceof jsts.geom.GeometryCollection){var gc=geom;for(var i=0;i<gc.getNumGeometries();i++){var g=gc.getGeometryN(i);jsts.algorithm.distance.DistanceToPoint.computeDistance(g,pt,ptDist)}}else{ptDist.setMinimum(geom.getCoordinate(),pt)}};jsts.algorithm.distance.DistanceToPoint.computeDistance2=function(line,pt,ptDist){var tempSegment=new jsts.geom.LineSegment;var coords=line.getCoordinates();for(var i=0;i<coords.length-1;i++){tempSegment.setCoordinates(coords[i],coords[i+1]);var closestPt=tempSegment.closestPoint(pt);ptDist.setMinimum(closestPt,pt)}};jsts.algorithm.distance.DistanceToPoint.computeDistance3=function(segment,pt,ptDist){var closestPt=segment.closestPoint(pt);ptDist.setMinimum(closestPt,pt)};jsts.algorithm.distance.DistanceToPoint.computeDistance4=function(poly,pt,ptDist){jsts.algorithm.distance.DistanceToPoint.computeDistance2(poly.getExteriorRing(),pt,ptDist);for(var i=0;i<poly.getNumInteriorRing();i++){jsts.algorithm.distance.DistanceToPoint.computeDistance2(poly.getInteriorRingN(i),pt,ptDist)}};jsts.index.strtree.ItemBoundable=function(bounds,item){this.bounds=bounds;this.item=item};jsts.index.strtree.ItemBoundable.prototype=new jsts.index.strtree.Boundable;jsts.index.strtree.ItemBoundable.constructor=jsts.index.strtree.ItemBoundable;jsts.index.strtree.ItemBoundable.prototype.bounds=null;jsts.index.strtree.ItemBoundable.prototype.item=null;jsts.index.strtree.ItemBoundable.prototype.getBounds=function(){return this.bounds};jsts.index.strtree.ItemBoundable.prototype.getItem=function(){return this.item};(function(){var ArrayList=javascript.util.ArrayList;var TreeMap=javascript.util.TreeMap;jsts.geomgraph.EdgeList=function(){this.edges=new ArrayList;this.ocaMap=new TreeMap};jsts.geomgraph.EdgeList.prototype.edges=null;jsts.geomgraph.EdgeList.prototype.ocaMap=null;jsts.geomgraph.EdgeList.prototype.add=function(e){this.edges.add(e);var oca=new jsts.noding.OrientedCoordinateArray(e.getCoordinates());this.ocaMap.put(oca,e)};jsts.geomgraph.EdgeList.prototype.addAll=function(edgeColl){for(var i=edgeColl.iterator();i.hasNext();){this.add(i.next())}};jsts.geomgraph.EdgeList.prototype.getEdges=function(){return this.edges};jsts.geomgraph.EdgeList.prototype.findEqualEdge=function(e){var oca=new jsts.noding.OrientedCoordinateArray(e.getCoordinates());var matchEdge=this.ocaMap.get(oca);return matchEdge};jsts.geomgraph.EdgeList.prototype.getEdges=function(){return this.edges};jsts.geomgraph.EdgeList.prototype.iterator=function(){return this.edges.iterator()};jsts.geomgraph.EdgeList.prototype.get=function(i){return this.edges.get(i)};jsts.geomgraph.EdgeList.prototype.findEdgeIndex=function(e){for(var i=0;i<this.edges.size();i++){if(this.edges.get(i).equals(e))return i}return-1}})();jsts.operation.IsSimpleOp=function(geom){this.geom=geom};jsts.operation.IsSimpleOp.prototype.geom=null;jsts.operation.IsSimpleOp.prototype.isClosedEndpointsInInterior=true;jsts.operation.IsSimpleOp.prototype.nonSimpleLocation=null;jsts.operation.IsSimpleOp.prototype.IsSimpleOp=function(geom){this.geom=geom};jsts.operation.IsSimpleOp.prototype.isSimple=function(){this.nonSimpleLocation=null;if(this.geom instanceof jsts.geom.LineString){return this.isSimpleLinearGeometry(this.geom)}if(this.geom instanceof jsts.geom.MultiLineString){return this.isSimpleLinearGeometry(this.geom)}if(this.geom instanceof jsts.geom.MultiPoint){return this.isSimpleMultiPoint(this.geom)}return true};jsts.operation.IsSimpleOp.prototype.isSimpleMultiPoint=function(mp){if(mp.isEmpty())return true;var points=[];for(var i=0;i<mp.getNumGeometries();i++){var pt=mp.getGeometryN(i);var p=pt.getCoordinate();for(var j=0;j<points.length;j++){var point=points[j];if(p.equals2D(point)){this.nonSimpleLocation=p;return false}}points.push(p)}return true};jsts.operation.IsSimpleOp.prototype.isSimpleLinearGeometry=function(geom){if(geom.isEmpty())return true;var graph=new jsts.geomgraph.GeometryGraph(0,geom);var li=new jsts.algorithm.RobustLineIntersector;var si=graph.computeSelfNodes(li,true);if(!si.hasIntersection())return true;if(si.hasProperIntersection()){this.nonSimpleLocation=si.getProperIntersectionPoint();return false}if(this.hasNonEndpointIntersection(graph))return false;if(this.isClosedEndpointsInInterior){if(this.hasClosedEndpointIntersection(graph))return false}return true};jsts.operation.IsSimpleOp.prototype.hasNonEndpointIntersection=function(graph){for(var i=graph.getEdgeIterator();i.hasNext();){var e=i.next();var maxSegmentIndex=e.getMaximumSegmentIndex();for(var eiIt=e.getEdgeIntersectionList().iterator();eiIt.hasNext();){var ei=eiIt.next();if(!ei.isEndPoint(maxSegmentIndex)){this.nonSimpleLocation=ei.getCoordinate();return true}}}return false};jsts.operation.IsSimpleOp.prototype.hasClosedEndpointIntersection=function(graph){var endPoints=new javascript.util.TreeMap;for(var i=graph.getEdgeIterator();i.hasNext();){var e=i.next();var maxSegmentIndex=e.getMaximumSegmentIndex();var isClosed=e.isClosed();var p0=e.getCoordinate(0);this.addEndpoint(endPoints,p0,isClosed);var p1=e.getCoordinate(e.getNumPoints()-1);this.addEndpoint(endPoints,p1,isClosed)}for(var i=endPoints.values().iterator();i.hasNext();){var eiInfo=i.next();if(eiInfo.isClosed&&eiInfo.degree!=2){this.nonSimpleLocation=eiInfo.getCoordinate();return true}}return false};jsts.operation.IsSimpleOp.EndpointInfo=function(pt){this.pt=pt;this.isClosed=false;this.degree=0};jsts.operation.IsSimpleOp.EndpointInfo.prototype.pt=null;jsts.operation.IsSimpleOp.EndpointInfo.prototype.isClosed=null;jsts.operation.IsSimpleOp.EndpointInfo.prototype.degree=null;jsts.operation.IsSimpleOp.EndpointInfo.prototype.getCoordinate=function(){return this.pt};jsts.operation.IsSimpleOp.EndpointInfo.prototype.addEndpoint=function(isClosed){this.degree++;this.isClosed=this.isClosed||isClosed};jsts.operation.IsSimpleOp.prototype.addEndpoint=function(endPoints,p,isClosed){var eiInfo=endPoints.get(p);if(eiInfo===null){eiInfo=new jsts.operation.IsSimpleOp.EndpointInfo(p);endPoints.put(p,eiInfo)}eiInfo.addEndpoint(isClosed)};(function(){var LineStringSnapper=function(){this.snapTolerance=0;this.seg=new jsts.geom.LineSegment;this.allowSnappingToSourceVertices=false;this.isClosed=false;this.srcPts=[];if(arguments[0]instanceof jsts.geom.LineString){this.initFromLine.apply(this,arguments)}else{this.initFromPoints.apply(this,arguments)}};LineStringSnapper.prototype.initFromLine=function(srcLine,snapTolerance){this.initFromPoints(srcLine.getCoordinates(),snapTolerance)};LineStringSnapper.prototype.initFromPoints=function(srcPts,snapTolerance){this.srcPts=srcPts;this.isClosed=this.calcIsClosed(srcPts);this.snapTolerance=snapTolerance};LineStringSnapper.prototype.setAllowSnappingToSourceVertices=function(allowSnappingToSourceVertices){this.allowSnappingToSourceVertices=allowSnappingToSourceVertices};LineStringSnapper.prototype.calcIsClosed=function(pts){if(pts.length<=1){return false}return pts[0].equals(pts[pts.length-1])};LineStringSnapper.prototype.snapTo=function(snapPts){var coordList=new jsts.geom.CoordinateList(this.srcPts);this.snapVertices(coordList,snapPts);this.snapSegments(coordList,snapPts);return coordList.toCoordinateArray()};LineStringSnapper.prototype.snapVertices=function(srcCoords,snapPts){var end=this.isClosed?srcCoords.size()-1:srcCoords.size(),i=0,srcPt,snapVert;for(i;i<end;i++){srcPt=srcCoords.get(i);snapVert=this.findSnapForVertex(srcPt,snapPts);if(snapVert!==null){srcCoords.set(i,new jsts.geom.Coordinate(snapVert));if(i===0&&this.isClosed)srcCoords.set(srcCoords.size()-1,new jsts.geom.Coordinate(snapVert))}}};LineStringSnapper.prototype.findSnapForVertex=function(pt,snapPts){var i=0,il=snapPts.length;for(i=0;i<il;i++){if(pt.equals(snapPts[i])){return null}if(pt.distance(snapPts[i])<this.snapTolerance){return snapPts[i]}}return null};LineStringSnapper.prototype.snapSegments=function(srcCoords,snapPts){if(snapPts.length===0){return}var distinctPtCount=snapPts.length,i,snapPt,index;if(snapPts.length>1&&snapPts[0].equals2D(snapPts[snapPts.length-1])){distinctPtCount=snapPts.length-1}i=0;for(i;i<distinctPtCount;i++){snapPt=snapPts[i];index=this.findSegmentIndexToSnap(snapPt,srcCoords);if(index>=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;i<srcCoords.size()-1;i++){this.seg.p0=srcCoords.get(i);this.seg.p1=srcCoords.get(i+1);if(this.seg.p0.equals(snapPt)||this.seg.p1.equals(snapPt)){if(this.allowSnappingToSourceVertices){continue}else{return-1}}dist=this.seg.distance(snapPt);if(dist<this.snapTolerance&&dist<minDist){minDist=dist;snapIndex=i}}return snapIndex};jsts.operation.overlay.snap.LineStringSnapper=LineStringSnapper})();(function(){var ArrayList=javascript.util.ArrayList;var GeometryComponentFilter=jsts.geom.GeometryComponentFilter;var LineString=jsts.geom.LineString;var EdgeRing=jsts.operation.polygonize.EdgeRing;var PolygonizeGraph=jsts.operation.polygonize.PolygonizeGraph;var Polygonizer=function(){var that=this;var LineStringAdder=function(){};LineStringAdder.prototype=new GeometryComponentFilter;LineStringAdder.prototype.filter=function(g){if(g instanceof LineString)that.add(g)};this.lineStringAdder=new LineStringAdder;this.dangles=new ArrayList;this.cutEdges=new ArrayList;this.invalidRingLines=new ArrayList};Polygonizer.prototype.lineStringAdder=null;Polygonizer.prototype.graph=null;Polygonizer.prototype.dangles=null;Polygonizer.prototype.cutEdges=null;Polygonizer.prototype.invalidRingLines=null;Polygonizer.prototype.holeList=null;Polygonizer.prototype.shellList=null;Polygonizer.prototype.polyList=null;Polygonizer.prototype.add=function(geomList){if(geomList instanceof jsts.geom.LineString){return this.add3(geomList)}else if(geomList instanceof jsts.geom.Geometry){return this.add2(geomList)}for(var i=geomList.iterator();i.hasNext();){var geometry=i.next();this.add2(geometry)}};Polygonizer.prototype.add2=function(g){g.apply(this.lineStringAdder)};Polygonizer.prototype.add3=function(line){if(this.graph==null)this.graph=new PolygonizeGraph(line.getFactory());this.graph.addEdge(line)};Polygonizer.prototype.getPolygons=function(){this.polygonize();return this.polyList};Polygonizer.prototype.getDangles=function(){this.polygonize();return this.dangles};Polygonizer.prototype.getCutEdges=function(){this.polygonize();return this.cutEdges};Polygonizer.prototype.getInvalidRingLines=function(){this.polygonize();return this.invalidRingLines};Polygonizer.prototype.polygonize=function(){if(this.polyList!=null)return;this.polyList=new ArrayList;if(this.graph==null)return;this.dangles=this.graph.deleteDangles();this.cutEdges=this.graph.deleteCutEdges();var edgeRingList=this.graph.getEdgeRings();var validEdgeRingList=new ArrayList;this.invalidRingLines=new ArrayList;this.findValidRings(edgeRingList,validEdgeRingList,this.invalidRingLines);this.findShellsAndHoles(validEdgeRingList);Polygonizer.assignHolesToShells(this.holeList,this.shellList);this.polyList=new ArrayList;for(var i=this.shellList.iterator();i.hasNext();){var er=i.next();this.polyList.add(er.getPolygon())}};Polygonizer.prototype.findValidRings=function(edgeRingList,validEdgeRingList,invalidRingList){for(var i=edgeRingList.iterator();i.hasNext();){var er=i.next();if(er.isValid())validEdgeRingList.add(er);else invalidRingList.add(er.getLineString())}};Polygonizer.prototype.findShellsAndHoles=function(edgeRingList){this.holeList=new ArrayList;this.shellList=new ArrayList;for(var i=edgeRingList.iterator();i.hasNext();){var er=i.next();if(er.isHole())this.holeList.add(er);else this.shellList.add(er)}};Polygonizer.assignHolesToShells=function(holeList,shellList){for(var i=holeList.iterator();i.hasNext();){var holeER=i.next();Polygonizer.assignHoleToShell(holeER,shellList)}};Polygonizer.assignHoleToShell=function(holeER,shellList){var shell=EdgeRing.findEdgeRingContaining(holeER,shellList);if(shell!=null)shell.addHole(holeER.getRing())};jsts.operation.polygonize.Polygonizer=Polygonizer})();(function(){var ArrayList=javascript.util.ArrayList;var GeometryTransformer=function(){};GeometryTransformer.prototype.inputGeom=null;GeometryTransformer.prototype.factory=null;GeometryTransformer.prototype.pruneEmptyGeometry=true;GeometryTransformer.prototype.preserveGeometryCollectionType=true;GeometryTransformer.prototype.preserveCollections=false;GeometryTransformer.prototype.reserveType=false;GeometryTransformer.prototype.getInputGeometry=function(){return this.inputGeom};GeometryTransformer.prototype.transform=function(inputGeom){this.inputGeom=inputGeom;this.factory=inputGeom.getFactory();if(inputGeom instanceof jsts.geom.Point)return this.transformPoint(inputGeom,null);if(inputGeom instanceof jsts.geom.MultiPoint)return this.transformMultiPoint(inputGeom,null);if(inputGeom instanceof jsts.geom.LinearRing)return this.transformLinearRing(inputGeom,null);if(inputGeom instanceof jsts.geom.LineString)return this.transformLineString(inputGeom,null);if(inputGeom instanceof jsts.geom.MultiLineString)return this.transformMultiLineString(inputGeom,null);if(inputGeom instanceof jsts.geom.Polygon)return this.transformPolygon(inputGeom,null);if(inputGeom instanceof jsts.geom.MultiPolygon)return this.transformMultiPolygon(inputGeom,null);if(inputGeom instanceof jsts.geom.GeometryCollection)return this.transformGeometryCollection(inputGeom,null);throw new jsts.error.IllegalArgumentException("Unknown Geometry subtype: "+inputGeom.getClass().getName())};GeometryTransformer.prototype.createCoordinateSequence=function(coords){return this.factory.getCoordinateSequenceFactory().create(coords)};GeometryTransformer.prototype.copy=function(seq){return seq.clone()};GeometryTransformer.prototype.transformCoordinates=function(coords,parent){return this.copy(coords)};GeometryTransformer.prototype.transformPoint=function(geom,parent){return this.factory.createPoint(this.transformCoordinates(geom.getCoordinateSequence(),geom))};GeometryTransformer.prototype.transformMultiPoint=function(geom,parent){var transGeomList=new ArrayList;for(var i=0;i<geom.getNumGeometries();i++){var transformGeom=this.transformPoint(geom.getGeometryN(i),geom);if(transformGeom==null)continue;if(transformGeom.isEmpty())continue;transGeomList.add(transformGeom)}return this.factory.buildGeometry(transGeomList)};GeometryTransformer.prototype.transformLinearRing=function(geom,parent){var seq=this.transformCoordinates(geom.getCoordinateSequence(),geom);var seqSize=seq.length;if(seqSize>0&&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;i<geom.getNumGeometries();i++){var transformGeom=this.transformLineString(geom.getGeometryN(i),geom);if(transformGeom==null)continue;if(transformGeom.isEmpty())continue;transGeomList.add(transformGeom)}return this.factory.buildGeometry(transGeomList)};GeometryTransformer.prototype.transformPolygon=function(geom,parent){var isAllValidLinearRings=true;var shell=this.transformLinearRing(geom.getExteriorRing(),geom);if(shell==null||!(shell instanceof jsts.geom.LinearRing)||shell.isEmpty())isAllValidLinearRings=false;var holes=new ArrayList;for(var i=0;i<geom.getNumInteriorRing();i++){var hole=this.transformLinearRing(geom.getInteriorRingN(i),geom);if(hole==null||hole.isEmpty()){continue}if(!(hole instanceof jsts.geom.LinearRing))isAllValidLinearRings=false;holes.add(hole)}if(isAllValidLinearRings)return this.factory.createPolygon(shell,holes.toArray());else{var components=new ArrayList;if(shell!=null)components.add(shell);components.addAll(holes);return this.factory.buildGeometry(components)}};GeometryTransformer.prototype.transformMultiPolygon=function(geom,parent){var transGeomList=new ArrayList;for(var i=0;i<geom.getNumGeometries();i++){var transformGeom=this.transformPolygon(geom.getGeometryN(i),geom);if(transformGeom==null)continue;if(transformGeom.isEmpty())continue;transGeomList.add(transformGeom)}return this.factory.buildGeometry(transGeomList)};GeometryTransformer.prototype.transformGeometryCollection=function(geom,parent){var transGeomList=new ArrayList;for(var i=0;i<geom.getNumGeometries();i++){var transformGeom=this.transform(geom.getGeometryN(i));if(transformGeom==null)continue;if(this.pruneEmptyGeometry&&transformGeom.isEmpty())continue;transGeomList.add(transformGeom)}if(this.preserveGeometryCollectionType)return this.factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));return this.factory.buildGeometry(transGeomList)};jsts.geom.util.GeometryTransformer=GeometryTransformer})();(function(){var LineStringSnapper=jsts.operation.overlay.snap.LineStringSnapper;var PrecisionModel=jsts.geom.PrecisionModel;var TreeSet=javascript.util.TreeSet;var SnapTransformer=function(snapTolerance,snapPts,isSelfSnap){this.snapTolerance=snapTolerance;this.snapPts=snapPts;this.isSelfSnap=isSelfSnap||false};SnapTransformer.prototype=new jsts.geom.util.GeometryTransformer;SnapTransformer.prototype.snapTolerance=null;SnapTransformer.prototype.snapPts=null;SnapTransformer.prototype.isSelfSnap=false;SnapTransformer.prototype.transformCoordinates=function(coords,parent){var srcPts=coords;var newPts=this.snapLine(srcPts,this.snapPts);return newPts};SnapTransformer.prototype.snapLine=function(srcPts,snapPts){var snapper=new LineStringSnapper(srcPts,this.snapTolerance);
snapper.setAllowSnappingToSourceVertices(this.isSelfSnap);return snapper.snapTo(snapPts)};var GeometrySnapper=function(srcGeom){this.srcGeom=srcGeom};GeometrySnapper.SNAP_PRECISION_FACTOR=1e-9;GeometrySnapper.computeOverlaySnapTolerance=function(g){if(arguments.length===2){return GeometrySnapper.computeOverlaySnapTolerance2.apply(this,arguments)}var snapTolerance=this.computeSizeBasedSnapTolerance(g);var pm=g.getPrecisionModel();if(pm.getType()==PrecisionModel.FIXED){var fixedSnapTol=1/pm.getScale()*2/1.415;if(fixedSnapTol>snapTolerance)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;i<pts.length;i++){ptSet.add(pts[i])}return ptSet.toArray()};GeometrySnapper.prototype.computeSnapTolerance=function(ringPts){var minSegLen=this.computeMinimumSegmentLength(ringPts);var snapTol=minSegLen/10;return snapTol};GeometrySnapper.prototype.computeMinimumSegmentLength=function(pts){var minSegLen=Number.MAX_VALUE;for(var i=0;i<pts.length-1;i++){var segLen=pts[i].distance(pts[i+1]);if(segLen<minSegLen)minSegLen=segLen}return minSegLen};jsts.operation.overlay.snap.GeometrySnapper=GeometrySnapper})();jsts.algorithm.PointLocator=function(boundaryRule){this.boundaryRule=boundaryRule?boundaryRule:jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE};jsts.algorithm.PointLocator.prototype.boundaryRule=null;jsts.algorithm.PointLocator.prototype.isIn=null;jsts.algorithm.PointLocator.prototype.numBoundaries=null;jsts.algorithm.PointLocator.prototype.intersects=function(p,geom){return this.locate(p,geom)!==jsts.geom.Location.EXTERIOR};jsts.algorithm.PointLocator.prototype.locate=function(p,geom){if(geom.isEmpty())return jsts.geom.Location.EXTERIOR;if(geom instanceof jsts.geom.Point){return this.locate2(p,geom)}else if(geom instanceof jsts.geom.LineString){return this.locate3(p,geom)}else if(geom instanceof jsts.geom.Polygon){return this.locate4(p,geom)}this.isIn=false;this.numBoundaries=0;this.computeLocation(p,geom);if(this.boundaryRule.isInBoundary(this.numBoundaries))return jsts.geom.Location.BOUNDARY;if(this.numBoundaries>0||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;i<ml.getNumGeometries();i++){var l=ml.getGeometryN(i);this.updateLocationInfo(this.locate(p,l))}}else if(geom instanceof jsts.geom.MultiPolygon){var mpoly=geom;for(var i=0;i<mpoly.getNumGeometries();i++){var poly=mpoly.getGeometryN(i);this.updateLocationInfo(this.locate(p,poly))}}else if(geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.GeometryCollection){for(var i=0;i<geom.getNumGeometries();i++){var part=geom.getGeometryN(i);if(part!==geom){this.computeLocation(p,part)}}}};jsts.algorithm.PointLocator.prototype.updateLocationInfo=function(loc){if(loc===jsts.geom.Location.INTERIOR)this.isIn=true;if(loc===jsts.geom.Location.BOUNDARY)this.numBoundaries++};jsts.algorithm.PointLocator.prototype.locate2=function(p,pt){var ptCoord=pt.getCoordinate();if(ptCoord.equals2D(p))return jsts.geom.Location.INTERIOR;return jsts.geom.Location.EXTERIOR};jsts.algorithm.PointLocator.prototype.locate3=function(p,l){if(!l.getEnvelopeInternal().intersects(p))return jsts.geom.Location.EXTERIOR;var pt=l.getCoordinates();if(!l.isClosed()){if(p.equals(pt[0])||p.equals(pt[pt.length-1])){return jsts.geom.Location.BOUNDARY}}if(jsts.algorithm.CGAlgorithms.isOnLine(p,pt))return jsts.geom.Location.INTERIOR;return jsts.geom.Location.EXTERIOR};jsts.algorithm.PointLocator.prototype.locateInPolygonRing=function(p,ring){if(!ring.getEnvelopeInternal().intersects(p))return jsts.geom.Location.EXTERIOR;return jsts.algorithm.CGAlgorithms.locatePointInRing(p,ring.getCoordinates())};jsts.algorithm.PointLocator.prototype.locate4=function(p,poly){if(poly.isEmpty())return jsts.geom.Location.EXTERIOR;var shell=poly.getExteriorRing();var shellLoc=this.locateInPolygonRing(p,shell);if(shellLoc===jsts.geom.Location.EXTERIOR)return jsts.geom.Location.EXTERIOR;if(shellLoc===jsts.geom.Location.BOUNDARY)return jsts.geom.Location.BOUNDARY;for(var i=0;i<poly.getNumInteriorRing();i++){var hole=poly.getInteriorRingN(i);var holeLoc=this.locateInPolygonRing(p,hole);if(holeLoc===jsts.geom.Location.INTERIOR)return jsts.geom.Location.EXTERIOR;if(holeLoc===jsts.geom.Location.BOUNDARY)return jsts.geom.Location.BOUNDARY}return jsts.geom.Location.INTERIOR};(function(){var Location=jsts.geom.Location;var ArrayList=javascript.util.ArrayList;var TreeMap=javascript.util.TreeMap;jsts.geomgraph.NodeMap=function(nodeFactory){this.nodeMap=new TreeMap;this.nodeFact=nodeFactory};jsts.geomgraph.NodeMap.prototype.nodeMap=null;jsts.geomgraph.NodeMap.prototype.nodeFact=null;jsts.geomgraph.NodeMap.prototype.addNode=function(arg){var node,coord;if(arg instanceof jsts.geom.Coordinate){coord=arg;node=this.nodeMap.get(coord);if(node===null){node=this.nodeFact.createNode(coord);this.nodeMap.put(coord,node)}return node}else if(arg instanceof jsts.geomgraph.Node){var n=arg;coord=n.getCoordinate();node=this.nodeMap.get(coord);if(node===null){this.nodeMap.put(coord,n);return n}node.mergeLabel(n);return node}};jsts.geomgraph.NodeMap.prototype.add=function(e){var p=e.getCoordinate();var n=this.addNode(p);n.add(e)};jsts.geomgraph.NodeMap.prototype.find=function(coord){return this.nodeMap.get(coord)};jsts.geomgraph.NodeMap.prototype.values=function(){return this.nodeMap.values()};jsts.geomgraph.NodeMap.prototype.iterator=function(){return this.values().iterator()};jsts.geomgraph.NodeMap.prototype.getBoundaryNodes=function(geomIndex){var bdyNodes=new ArrayList;for(var i=this.iterator();i.hasNext();){var node=i.next();if(node.getLabel().getLocation(geomIndex)===Location.BOUNDARY){bdyNodes.add(node)}}return bdyNodes}})();(function(){var ArrayList=javascript.util.ArrayList;jsts.geomgraph.PlanarGraph=function(nodeFactory){this.edges=new ArrayList;this.edgeEndList=new ArrayList;this.nodes=new jsts.geomgraph.NodeMap(nodeFactory||new jsts.geomgraph.NodeFactory)};jsts.geomgraph.PlanarGraph.prototype.edges=null;jsts.geomgraph.PlanarGraph.prototype.nodes=null;jsts.geomgraph.PlanarGraph.prototype.edgeEndList=null;jsts.geomgraph.PlanarGraph.linkResultDirectedEdges=function(nodes){for(var nodeit=nodes.iterator();nodeit.hasNext();){var node=nodeit.next();node.getEdges().linkResultDirectedEdges()}};jsts.geomgraph.PlanarGraph.prototype.getEdgeIterator=function(){return this.edges.iterator()};jsts.geomgraph.PlanarGraph.prototype.getEdgeEnds=function(){return this.edgeEndList};jsts.geomgraph.PlanarGraph.prototype.isBoundaryNode=function(geomIndex,coord){var node=this.nodes.find(coord);if(node===null)return false;var label=node.getLabel();if(label!==null&&label.getLocation(geomIndex)===jsts.geom.Location.BOUNDARY)return true;return false};jsts.geomgraph.PlanarGraph.prototype.insertEdge=function(e){this.edges.add(e)};jsts.geomgraph.PlanarGraph.prototype.add=function(e){this.nodes.add(e);this.edgeEndList.add(e)};jsts.geomgraph.PlanarGraph.prototype.getNodeIterator=function(){return this.nodes.iterator()};jsts.geomgraph.PlanarGraph.prototype.getNodes=function(){return this.nodes.values()};jsts.geomgraph.PlanarGraph.prototype.addNode=function(node){return this.nodes.addNode(node)};jsts.geomgraph.PlanarGraph.prototype.addEdges=function(edgesToAdd){for(var it=edgesToAdd.iterator();it.hasNext();){var e=it.next();this.edges.add(e);var de1=new jsts.geomgraph.DirectedEdge(e,true);var de2=new jsts.geomgraph.DirectedEdge(e,false);de1.setSym(de2);de2.setSym(de1);this.add(de1);this.add(de2)}};jsts.geomgraph.PlanarGraph.prototype.linkResultDirectedEdges=function(){for(var nodeit=this.nodes.iterator();nodeit.hasNext();){var node=nodeit.next();node.getEdges().linkResultDirectedEdges()}};jsts.geomgraph.PlanarGraph.prototype.findEdgeInSameDirection=function(p0,p1){var i=0,il=this.edges.size(),e,eCoord;for(i;i<il;i++){e=this.edges.get(i);eCoord=e.getCoordinates();if(this.matchInSameDirection(p0,p1,eCoord[0],eCoord[1])){return e}if(this.matchInSameDirection(p0,p1,eCoord[eCoord.length-1],eCoord[eCoord.length-2])){return e}}return null};jsts.geomgraph.PlanarGraph.prototype.matchInSameDirection=function(p0,p1,ep0,ep1){if(!p0.equals(ep0)){return false}if(jsts.algorithm.CGAlgorithms.computeOrientation(p0,p1,ep1)===jsts.algorithm.CGAlgorithms.COLLINEAR&&jsts.geomgraph.Quadrant.quadrant(p0,p1)===jsts.geomgraph.Quadrant.quadrant(ep0,ep1)){return true}return false};jsts.geomgraph.PlanarGraph.prototype.findEdgeEnd=function(e){for(var i=this.getEdgeEnds().iterator();i.hasNext();){var ee=i.next();if(ee.getEdge()===e){return ee}}return null}})();jsts.noding.SegmentIntersector=function(){};jsts.noding.SegmentIntersector.prototype.processIntersections=jsts.abstractFunc;jsts.noding.SegmentIntersector.prototype.isDone=jsts.abstractFunc;(function(){var SegmentIntersector=jsts.noding.SegmentIntersector;var ArrayList=javascript.util.ArrayList;jsts.noding.InteriorIntersectionFinder=function(li){this.li=li;this.intersections=new ArrayList;this.interiorIntersection=null};jsts.noding.InteriorIntersectionFinder.prototype=new SegmentIntersector;jsts.noding.InteriorIntersectionFinder.constructor=jsts.noding.InteriorIntersectionFinder;jsts.noding.InteriorIntersectionFinder.prototype.findAllIntersections=false;jsts.noding.InteriorIntersectionFinder.prototype.isCheckEndSegmentsOnly=false;jsts.noding.InteriorIntersectionFinder.prototype.li=null;jsts.noding.InteriorIntersectionFinder.prototype.interiorIntersection=null;jsts.noding.InteriorIntersectionFinder.prototype.intSegments=null;jsts.noding.InteriorIntersectionFinder.prototype.intersections=null;jsts.noding.InteriorIntersectionFinder.prototype.setFindAllIntersections=function(findAllIntersections){this.findAllIntersections=findAllIntersections};jsts.noding.InteriorIntersectionFinder.prototype.getIntersections=function(){return intersections};jsts.noding.InteriorIntersectionFinder.prototype.setCheckEndSegmentsOnly=function(isCheckEndSegmentsOnly){this.isCheckEndSegmentsOnly=isCheckEndSegmentsOnly};jsts.noding.InteriorIntersectionFinder.prototype.hasIntersection=function(){return this.interiorIntersection!=null};jsts.noding.InteriorIntersectionFinder.prototype.getInteriorIntersection=function(){return this.interiorIntersection};jsts.noding.InteriorIntersectionFinder.prototype.getIntersectionSegments=function(){return this.intSegments};jsts.noding.InteriorIntersectionFinder.prototype.processIntersections=function(e0,segIndex0,e1,segIndex1){if(this.hasIntersection())return;if(e0==e1&&segIndex0==segIndex1)return;if(this.isCheckEndSegmentsOnly){var isEndSegPresent=this.isEndSegment(e0,segIndex0)||isEndSegment(e1,segIndex1);if(!isEndSegPresent)return}var p00=e0.getCoordinates()[segIndex0];var p01=e0.getCoordinates()[segIndex0+1];var p10=e1.getCoordinates()[segIndex1];var p11=e1.getCoordinates()[segIndex1+1];this.li.computeIntersection(p00,p01,p10,p11);if(this.li.hasIntersection()){if(this.li.isInteriorIntersection()){this.intSegments=[];this.intSegments[0]=p00;this.intSegments[1]=p01;this.intSegments[2]=p10;this.intSegments[3]=p11;this.interiorIntersection=this.li.getIntersection(0);this.intersections.add(this.interiorIntersection)}}};jsts.noding.InteriorIntersectionFinder.prototype.isEndSegment=function(segStr,index){if(index==0)return true;if(index>=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;i<maxEdgeRings.length;i++){var er=maxEdgeRings[i];if(er.getMaxNodeDegree()>2){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<minEdgeRings.length;i++){var er=minEdgeRings[i];if(!er.isHole()){shell=er;shellCount++}}jsts.util.Assert.isTrue(shellCount<=1,"found two shells in MinimalEdgeRing list");return shell};jsts.operation.overlay.PolygonBuilder.prototype.placePolygonHoles=function(shell,minEdgeRings){for(var i=0;i<minEdgeRings.length;i++){var er=minEdgeRings[i];if(er.isHole()){er.setShell(shell)}}};jsts.operation.overlay.PolygonBuilder.prototype.sortShellsAndHoles=function(edgeRings,shellList,freeHoleList){for(var i=0;i<edgeRings.length;i++){var er=edgeRings[i];if(er.isHole()){freeHoleList.push(er)}else{shellList.push(er)}}};jsts.operation.overlay.PolygonBuilder.prototype.placeFreeHoles=function(shellList,freeHoleList){for(var i=0;i<freeHoleList.length;i++){var hole=freeHoleList[i];if(hole.getShell()==null){var shell=this.findEdgeRingContaining(hole,shellList);if(shell===null)throw new jsts.error.TopologyError("unable to assign hole to a shell",hole.getCoordinate(0));hole.setShell(shell)}}};jsts.operation.overlay.PolygonBuilder.prototype.findEdgeRingContaining=function(testEr,shellList){var testRing=testEr.getLinearRing();var testEnv=testRing.getEnvelopeInternal();var testPt=testRing.getCoordinateN(0);var minShell=null;var minEnv=null;for(var i=0;i<shellList.length;i++){var tryShell=shellList[i];var tryRing=tryShell.getLinearRing();var tryEnv=tryRing.getEnvelopeInternal();if(minShell!==null)minEnv=minShell.getLinearRing().getEnvelopeInternal();var isContained=false;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};jsts.operation.overlay.PolygonBuilder.prototype.computePolygons=function(shellList){var resultPolyList=new javascript.util.ArrayList;for(var i=0;i<shellList.length;i++){var er=shellList[i];var poly=er.toPolygon(this.geometryFactory);resultPolyList.add(poly)}return resultPolyList};jsts.operation.overlay.PolygonBuilder.prototype.containsPoint=function(p){for(var i=0;i<this.shellList.length;i++){var er=this.shellList[i];if(er.containsPoint(p))return true}return false};(function(){var Assert=jsts.util.Assert;var ArrayList=javascript.util.ArrayList;var LineBuilder=function(op,geometryFactory,ptLocator){this.lineEdgesList=new ArrayList;this.resultLineList=new ArrayList;this.op=op;this.geometryFactory=geometryFactory;this.ptLocator=ptLocator};LineBuilder.prototype.op=null;LineBuilder.prototype.geometryFactory=null;LineBuilder.prototype.ptLocator=null;LineBuilder.prototype.lineEdgesList=null;LineBuilder.prototype.resultLineList=null;LineBuilder.prototype.build=function(opCode){this.findCoveredLineEdges();this.collectLines(opCode);this.buildLines(opCode);return this.resultLineList};LineBuilder.prototype.findCoveredLineEdges=function(){for(var nodeit=this.op.getGraph().getNodes().iterator();nodeit.hasNext();){var node=nodeit.next();node.getEdges().findCoveredLineEdges()}for(var it=this.op.getGraph().getEdgeEnds().iterator();it.hasNext();){var de=it.next();var e=de.getEdge();if(de.isLineEdge()&&!e.isCoveredSet()){var isCovered=this.op.isCoveredByA(de.getCoordinate());e.setCovered(isCovered)}}};LineBuilder.prototype.collectLines=function(opCode){for(var it=this.op.getGraph().getEdgeEnds().iterator();it.hasNext();){var de=it.next();this.collectLineEdge(de,opCode,this.lineEdgesList);this.collectBoundaryTouchEdge(de,opCode,this.lineEdgesList)}};LineBuilder.prototype.collectLineEdge=function(de,opCode,edges){var label=de.getLabel();var e=de.getEdge();if(de.isLineEdge()){if(!de.isVisited()&&jsts.operation.overlay.OverlayOp.isResultOfOp(label,opCode)&&!e.isCovered()){edges.add(e);de.setVisitedEdge(true)}}};LineBuilder.prototype.collectBoundaryTouchEdge=function(de,opCode,edges){var label=de.getLabel();if(de.isLineEdge())return;if(de.isVisited())return;if(de.isInteriorAreaEdge())return;if(de.getEdge().isInResult())return;Assert.isTrue(!(de.isInResult()||de.getSym().isInResult())||!de.getEdge().isInResult());if(jsts.operation.overlay.OverlayOp.isResultOfOp(label,opCode)&&opCode===jsts.operation.overlay.OverlayOp.INTERSECTION){edges.add(de.getEdge());de.setVisitedEdge(true)}};LineBuilder.prototype.buildLines=function(opCode){for(var it=this.lineEdgesList.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();var line=this.geometryFactory.createLineString(e.getCoordinates());this.resultLineList.add(line);e.setInResult(true)}};LineBuilder.prototype.labelIsolatedLines=function(edgesList){for(var it=edgesList.iterator();it.hasNext();){var e=it.next();var label=e.getLabel();if(e.isIsolated()){if(label.isNull(0))this.labelIsolatedLine(e,0);else this.labelIsolatedLine(e,1)}}};LineBuilder.prototype.labelIsolatedLine=function(e,targetIndex){var loc=ptLocator.locate(e.getCoordinate(),op.getArgGeometry(targetIndex));e.getLabel().setLocation(targetIndex,loc)};jsts.operation.overlay.LineBuilder=LineBuilder})();(function(){var ArrayList=javascript.util.ArrayList;var PointBuilder=function(op,geometryFactory,ptLocator){this.resultPointList=new ArrayList;this.op=op;this.geometryFactory=geometryFactory};PointBuilder.prototype.op=null;PointBuilder.prototype.geometryFactory=null;PointBuilder.prototype.resultPointList=null;PointBuilder.prototype.build=function(opCode){this.extractNonCoveredResultNodes(opCode);return this.resultPointList};PointBuilder.prototype.extractNonCoveredResultNodes=function(opCode){for(var nodeit=this.op.getGraph().getNodes().iterator();nodeit.hasNext();){var n=nodeit.next();if(n.isInResult())continue;if(n.isIncidentEdgeInResult())continue;if(n.getEdges().getDegree()===0||opCode===jsts.operation.overlay.OverlayOp.INTERSECTION){var label=n.getLabel();if(jsts.operation.overlay.OverlayOp.isResultOfOp(label,opCode)){this.filterCoveredNodeToPoint(n)}}}};PointBuilder.prototype.filterCoveredNodeToPoint=function(n){var coord=n.getCoordinate();if(!this.op.isCoveredByLA(coord)){var pt=this.geometryFactory.createPoint(coord);this.resultPointList.add(pt)}};jsts.operation.overlay.PointBuilder=PointBuilder})();(function(){var PointLocator=jsts.algorithm.PointLocator;var Location=jsts.geom.Location;var EdgeList=jsts.geomgraph.EdgeList;var Label=jsts.geomgraph.Label;var PlanarGraph=jsts.geomgraph.PlanarGraph;var Position=jsts.geomgraph.Position;var EdgeNodingValidator=jsts.geomgraph.EdgeNodingValidator;var GeometryGraphOperation=jsts.operation.GeometryGraphOperation;var OverlayNodeFactory=jsts.operation.overlay.OverlayNodeFactory;var PolygonBuilder=jsts.operation.overlay.PolygonBuilder;var LineBuilder=jsts.operation.overlay.LineBuilder;var PointBuilder=jsts.operation.overlay.PointBuilder;var Assert=jsts.util.Assert;var ArrayList=javascript.util.ArrayList;jsts.operation.overlay.OverlayOp=function(g0,g1){this.ptLocator=new PointLocator;this.edgeList=new EdgeList;this.resultPolyList=new ArrayList;this.resultLineList=new ArrayList;this.resultPointList=new ArrayList;GeometryGraphOperation.call(this,g0,g1);this.graph=new PlanarGraph(new OverlayNodeFactory);this.geomFact=g0.getFactory()};jsts.operation.overlay.OverlayOp.prototype=new GeometryGraphOperation;jsts.operation.overlay.OverlayOp.constructor=jsts.operation.overlay.OverlayOp;jsts.operation.overlay.OverlayOp.INTERSECTION=1;jsts.operation.overlay.OverlayOp.UNION=2;jsts.operation.overlay.OverlayOp.DIFFERENCE=3;jsts.operation.overlay.OverlayOp.SYMDIFFERENCE=4;jsts.operation.overlay.OverlayOp.overlayOp=function(geom0,geom1,opCode){var gov=new jsts.operation.overlay.OverlayOp(geom0,geom1);var geomOv=gov.getResultGeometry(opCode);return geomOv};jsts.operation.overlay.OverlayOp.isResultOfOp=function(label,opCode){if(arguments.length===3){return jsts.operation.overlay.OverlayOp.isResultOfOp2.apply(this,arguments)}var loc0=label.getLocation(0);var loc1=label.getLocation(1);return jsts.operation.overlay.OverlayOp.isResultOfOp2(loc0,loc1,opCode)};jsts.operation.overlay.OverlayOp.isResultOfOp2=function(loc0,loc1,opCode){if(loc0==Location.BOUNDARY)loc0=Location.INTERIOR;if(loc1==Location.BOUNDARY)loc1=Location.INTERIOR;switch(opCode){case jsts.operation.overlay.OverlayOp.INTERSECTION:return loc0==Location.INTERIOR&&loc1==Location.INTERIOR;case jsts.operation.overlay.OverlayOp.UNION:return loc0==Location.INTERIOR||loc1==Location.INTERIOR;case jsts.operation.overlay.OverlayOp.DIFFERENCE:return loc0==Location.INTERIOR&&loc1!=Location.INTERIOR;case jsts.operation.overlay.OverlayOp.SYMDIFFERENCE:return loc0==Location.INTERIOR&&loc1!=Location.INTERIOR||loc0!=Location.INTERIOR&&loc1==Location.INTERIOR}return false};jsts.operation.overlay.OverlayOp.prototype.ptLocator=null;jsts.operation.overlay.OverlayOp.prototype.geomFact=null;jsts.operation.overlay.OverlayOp.prototype.resultGeom=null;jsts.operation.overlay.OverlayOp.prototype.graph=null;jsts.operation.overlay.OverlayOp.prototype.edgeList=null;jsts.operation.overlay.OverlayOp.prototype.resultPolyList=null;jsts.operation.overlay.OverlayOp.prototype.resultLineList=null;jsts.operation.overlay.OverlayOp.prototype.resultPointList=null;jsts.operation.overlay.OverlayOp.prototype.getResultGeometry=function(funcCode){this.computeOverlay(funcCode);return this.resultGeom};jsts.operation.overlay.OverlayOp.prototype.getGraph=function(){return this.graph};jsts.operation.overlay.OverlayOp.prototype.computeOverlay=function(opCode){this.copyPoints(0);this.copyPoints(1);this.arg[0].computeSelfNodes(this.li,false);this.arg[1].computeSelfNodes(this.li,false);this.arg[0].computeEdgeIntersections(this.arg[1],this.li,true);var baseSplitEdges=new ArrayList;this.arg[0].computeSplitEdges(baseSplitEdges);this.arg[1].computeSplitEdges(baseSplitEdges);var splitEdges=baseSplitEdges;this.insertUniqueEdges(baseSplitEdges);this.computeLabelsFromDepths();this.replaceCollapsedEdges();EdgeNodingValidator.checkValid(this.edgeList.getEdges());this.graph.addEdges(this.edgeList.getEdges());this.computeLabelling();this.labelIncompleteNodes();this.findResultAreaEdges(opCode);this.cancelDuplicateResultEdges();var polyBuilder=new PolygonBuilder(this.geomFact);polyBuilder.add(this.graph);this.resultPolyList=polyBuilder.getPolygons();var lineBuilder=new LineBuilder(this,this.geomFact,this.ptLocator);this.resultLineList=lineBuilder.build(opCode);var pointBuilder=new PointBuilder(this,this.geomFact,this.ptLocator);this.resultPointList=pointBuilder.build(opCode);this.resultGeom=this.computeGeometry(this.resultPointList,this.resultLineList,this.resultPolyList,opCode)};jsts.operation.overlay.OverlayOp.prototype.insertUniqueEdges=function(edges){for(var i=edges.iterator();i.hasNext();){var e=i.next();this.insertUniqueEdge(e)}};jsts.operation.overlay.OverlayOp.prototype.insertUniqueEdge=function(e){var existingEdge=this.edgeList.findEqualEdge(e);if(existingEdge!==null){var existingLabel=existingEdge.getLabel();var labelToMerge=e.getLabel();if(!existingEdge.isPointwiseEqual(e)){labelToMerge=new Label(e.getLabel());labelToMerge.flip()}var depth=existingEdge.getDepth();if(depth.isNull()){depth.add(existingLabel)}depth.add(labelToMerge);existingLabel.merge(labelToMerge)}else{this.edgeList.add(e)}};jsts.operation.overlay.OverlayOp.prototype.computeLabelsFromDepths=function(){for(var it=this.edgeList.iterator();it.hasNext();){var e=it.next();var lbl=e.getLabel();var depth=e.getDepth();if(!depth.isNull()){depth.normalize();for(var i=0;i<2;i++){if(!lbl.isNull(i)&&lbl.isArea()&&!depth.isNull(i)){if(depth.getDelta(i)==0){lbl.toLine(i)}else{Assert.isTrue(!depth.isNull(i,Position.LEFT),"depth of LEFT side has not been initialized");
lbl.setLocation(i,Position.LEFT,depth.getLocation(i,Position.LEFT));Assert.isTrue(!depth.isNull(i,Position.RIGHT),"depth of RIGHT side has not been initialized");lbl.setLocation(i,Position.RIGHT,depth.getLocation(i,Position.RIGHT))}}}}}};jsts.operation.overlay.OverlayOp.prototype.replaceCollapsedEdges=function(){var newEdges=new ArrayList;for(var it=this.edgeList.iterator();it.hasNext();){var e=it.next();if(e.isCollapsed()){it.remove();newEdges.add(e.getCollapsedEdge())}}this.edgeList.addAll(newEdges)};jsts.operation.overlay.OverlayOp.prototype.copyPoints=function(argIndex){for(var i=this.arg[argIndex].getNodeIterator();i.hasNext();){var graphNode=i.next();var newNode=this.graph.addNode(graphNode.getCoordinate());newNode.setLabel(argIndex,graphNode.getLabel().getLocation(argIndex))}};jsts.operation.overlay.OverlayOp.prototype.computeLabelling=function(){for(var nodeit=this.graph.getNodes().iterator();nodeit.hasNext();){var node=nodeit.next();node.getEdges().computeLabelling(this.arg)}this.mergeSymLabels();this.updateNodeLabelling()};jsts.operation.overlay.OverlayOp.prototype.mergeSymLabels=function(){for(var nodeit=this.graph.getNodes().iterator();nodeit.hasNext();){var node=nodeit.next();node.getEdges().mergeSymLabels()}};jsts.operation.overlay.OverlayOp.prototype.updateNodeLabelling=function(){for(var nodeit=this.graph.getNodes().iterator();nodeit.hasNext();){var node=nodeit.next();var lbl=node.getEdges().getLabel();node.getLabel().merge(lbl)}};jsts.operation.overlay.OverlayOp.prototype.labelIncompleteNodes=function(){var nodeCount=0;for(var ni=this.graph.getNodes().iterator();ni.hasNext();){var n=ni.next();var label=n.getLabel();if(n.isIsolated()){nodeCount++;if(label.isNull(0))this.labelIncompleteNode(n,0);else this.labelIncompleteNode(n,1)}n.getEdges().updateLabelling(label)}};jsts.operation.overlay.OverlayOp.prototype.labelIncompleteNode=function(n,targetIndex){var loc=this.ptLocator.locate(n.getCoordinate(),this.arg[targetIndex].getGeometry());n.getLabel().setLocation(targetIndex,loc)};jsts.operation.overlay.OverlayOp.prototype.findResultAreaEdges=function(opCode){for(var it=this.graph.getEdgeEnds().iterator();it.hasNext();){var de=it.next();var label=de.getLabel();if(label.isArea()&&!de.isInteriorAreaEdge()&&jsts.operation.overlay.OverlayOp.isResultOfOp(label.getLocation(0,Position.RIGHT),label.getLocation(1,Position.RIGHT),opCode)){de.setInResult(true)}}};jsts.operation.overlay.OverlayOp.prototype.cancelDuplicateResultEdges=function(){for(var it=this.graph.getEdgeEnds().iterator();it.hasNext();){var de=it.next();var sym=de.getSym();if(de.isInResult()&&sym.isInResult()){de.setInResult(false);sym.setInResult(false)}}};jsts.operation.overlay.OverlayOp.prototype.isCoveredByLA=function(coord){if(this.isCovered(coord,this.resultLineList))return true;if(this.isCovered(coord,this.resultPolyList))return true;return false};jsts.operation.overlay.OverlayOp.prototype.isCoveredByA=function(coord){if(this.isCovered(coord,this.resultPolyList))return true;return false};jsts.operation.overlay.OverlayOp.prototype.isCovered=function(coord,geomList){for(var it=geomList.iterator();it.hasNext();){var geom=it.next();var loc=this.ptLocator.locate(coord,geom);if(loc!=Location.EXTERIOR)return true}return false};jsts.operation.overlay.OverlayOp.prototype.computeGeometry=function(resultPointList,resultLineList,resultPolyList,opcode){var geomList=new ArrayList;geomList.addAll(resultPointList);geomList.addAll(resultLineList);geomList.addAll(resultPolyList);return this.geomFact.buildGeometry(geomList)};jsts.operation.overlay.OverlayOp.prototype.createEmptyResult=function(opCode){var result=null;switch(resultDimension(opCode,this.arg[0].getGeometry(),this.arg[1].getGeometry())){case-1:result=geomFact.createGeometryCollection();break;case 0:result=geomFact.createPoint(null);break;case 1:result=geomFact.createLineString(null);break;case 2:result=geomFact.createPolygon(null,null);break}return result};jsts.operation.overlay.OverlayOp.prototype.resultDimension=function(opCode,g0,g1){var dim0=g0.getDimension();var dim1=g1.getDimension();var resultDimension=-1;switch(opCode){case jsts.operation.overlay.OverlayOp.INTERSECTION:resultDimension=Math.min(dim0,dim1);break;case jsts.operation.overlay.OverlayOp.UNION:resultDimension=Math.max(dim0,dim1);break;case jsts.operation.overlay.OverlayOp.DIFFERENCE:resultDimension=dim0;break;case jsts.operation.overlay.OverlayOp.SYMDIFFERENCE:resultDimension=Math.max(dim0,dim1);break}return resultDimension}})();(function(){var OverlayOp=jsts.operation.overlay.OverlayOp;var GeometrySnapper=jsts.operation.overlay.snap.GeometrySnapper;var SnapOverlayOp=function(g1,g2){this.geom=[];this.geom[0]=g1;this.geom[1]=g2;this.computeSnapTolerance()};SnapOverlayOp.overlayOp=function(g0,g1,opCode){var op=new SnapOverlayOp(g0,g1);return op.getResultGeometry(opCode)};SnapOverlayOp.intersection=function(g0,g1){return this.overlayOp(g0,g1,OverlayOp.INTERSECTION)};SnapOverlayOp.union=function(g0,g1){return this.overlayOp(g0,g1,OverlayOp.UNION)};SnapOverlayOp.difference=function(g0,g1){return overlayOp(g0,g1,OverlayOp.DIFFERENCE)};SnapOverlayOp.symDifference=function(g0,g1){return overlayOp(g0,g1,OverlayOp.SYMDIFFERENCE)};SnapOverlayOp.prototype.geom=null;SnapOverlayOp.prototype.snapTolerance=null;SnapOverlayOp.prototype.computeSnapTolerance=function(){this.snapTolerance=GeometrySnapper.computeOverlaySnapTolerance(this.geom[0],this.geom[1])};SnapOverlayOp.prototype.getResultGeometry=function(opCode){var prepGeom=this.snap(this.geom);var result=OverlayOp.overlayOp(prepGeom[0],prepGeom[1],opCode);return this.prepareResult(result)};SnapOverlayOp.prototype.selfSnap=function(geom){var snapper0=new GeometrySnapper(geom);var snapGeom=snapper0.snapTo(geom,this.snapTolerance);return snapGeom};SnapOverlayOp.prototype.snap=function(geom){var remGeom=geom;var snapGeom=GeometrySnapper.snap(remGeom[0],remGeom[1],this.snapTolerance);return snapGeom};SnapOverlayOp.prototype.prepareResult=function(geom){return geom};SnapOverlayOp.prototype.cbr=null;SnapOverlayOp.prototype.removeCommonBits=function(geom){this.cbr=new jsts.precision.CommonBitsRemover;this.cbr.add(this.geom[0]);this.cbr.add(this.geom[1]);var remGeom=[];remGeom[0]=cbr.removeCommonBits(this.geom[0].clone());remGeom[1]=cbr.removeCommonBits(this.geom[1].clone());return remGeom};jsts.operation.overlay.snap.SnapOverlayOp=SnapOverlayOp})();jsts.geomgraph.index.EdgeSetIntersector=function(){};jsts.geomgraph.index.EdgeSetIntersector.prototype.computeIntersections=function(edges,si,testAllSegments){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.index.EdgeSetIntersector.prototype.computeIntersections2=function(edges0,edges1,si){throw new jsts.error.AbstractMethodInvocationError};jsts.geomgraph.index.SimpleMCSweepLineIntersector=function(){this.events=[]};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype=new jsts.geomgraph.index.EdgeSetIntersector;jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.events=null;jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.nOverlaps=0;jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.computeIntersections=function(edges,si,testAllSegments){if(si instanceof javascript.util.List){this.computeIntersections2.apply(this,arguments);return}if(testAllSegments){this.addList2(edges,null)}else{this.addList(edges)}this.computeIntersections3(si)};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.computeIntersections2=function(edges0,edges1,si){this.addList2(edges0,edges0);this.addList2(edges1,edges1);this.computeIntersections3(si)};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.add=function(edge,edgeSet){if(edge instanceof javascript.util.List){this.addList.apply(this,arguments);return}var mce=edge.getMonotoneChainEdge();var startIndex=mce.getStartIndexes();for(var i=0;i<startIndex.length-1;i++){var mc=new jsts.geomgraph.index.MonotoneChain(mce,i);var insertEvent=new jsts.geomgraph.index.SweepLineEvent(mce.getMinX(i),mc,edgeSet);this.events.push(insertEvent);this.events.push(new jsts.geomgraph.index.SweepLineEvent(mce.getMaxX(i),insertEvent))}};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.addList=function(edges){for(var i=edges.iterator();i.hasNext();){var edge=i.next();this.add(edge,edge)}};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.addList2=function(edges,edgeSet){for(var i=edges.iterator();i.hasNext();){var edge=i.next();this.add(edge,edgeSet)}};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.prepareEvents=function(){this.events.sort(function(a,b){return a.compareTo(b)});for(var i=0;i<this.events.length;i++){var ev=this.events[i];if(ev.isDelete()){ev.getInsertEvent().setDeleteEventIndex(i)}}};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.computeIntersections3=function(si){this.nOverlaps=0;this.prepareEvents();for(var i=0;i<this.events.length;i++){var ev=this.events[i];if(ev.isInsert()){this.processOverlaps(i,ev.getDeleteEventIndex(),ev,si)}}};jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype.processOverlaps=function(start,end,ev0,si){var mc0=ev0.getObject();for(var i=start;i<end;i++){var ev1=this.events[i];if(ev1.isInsert()){var mc1=ev1.getObject();if(!ev0.isSameLabel(ev1)){mc0.computeIntersections(mc1,si);this.nOverlaps++}}}};jsts.algorithm.locate.SimplePointInAreaLocator=function(geom){this.geom=geom};jsts.algorithm.locate.SimplePointInAreaLocator.locate=function(p,geom){if(geom.isEmpty())return jsts.geom.Location.EXTERIOR;if(jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint(p,geom))return jsts.geom.Location.INTERIOR;return jsts.geom.Location.EXTERIOR};jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint=function(p,geom){if(geom instanceof jsts.geom.Polygon){return jsts.algorithm.locate.SimplePointInAreaLocator.containsPointInPolygon(p,geom)}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.MultiLineString||geom instanceof jsts.geom.MultiPolygon){for(var i=0;i<geom.geometries.length;i++){var g2=geom.geometries[i];if(g2!==geom)if(jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint(p,g2))return true}}return false};jsts.algorithm.locate.SimplePointInAreaLocator.containsPointInPolygon=function(p,poly){if(poly.isEmpty())return false;var shell=poly.getExteriorRing();if(!jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing(p,shell))return false;for(var i=0;i<poly.getNumInteriorRing();i++){var hole=poly.getInteriorRingN(i);if(jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing(p,hole))return false}return true};jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing=function(p,ring){if(!ring.getEnvelopeInternal().intersects(p))return false;return jsts.algorithm.CGAlgorithms.isPointInRing(p,ring.getCoordinates())};jsts.algorithm.locate.SimplePointInAreaLocator.prototype.geom=null;jsts.algorithm.locate.SimplePointInAreaLocator.prototype.locate=function(p){return jsts.algorithm.locate.SimplePointInAreaLocator.locate(p,geom)};(function(){var Location=jsts.geom.Location;var Position=jsts.geomgraph.Position;var EdgeEndStar=jsts.geomgraph.EdgeEndStar;var Assert=jsts.util.Assert;jsts.geomgraph.DirectedEdgeStar=function(){jsts.geomgraph.EdgeEndStar.call(this)};jsts.geomgraph.DirectedEdgeStar.prototype=new EdgeEndStar;jsts.geomgraph.DirectedEdgeStar.constructor=jsts.geomgraph.DirectedEdgeStar;jsts.geomgraph.DirectedEdgeStar.prototype.resultAreaEdgeList=null;jsts.geomgraph.DirectedEdgeStar.prototype.label=null;jsts.geomgraph.DirectedEdgeStar.prototype.insert=function(ee){var de=ee;this.insertEdgeEnd(de,de)};jsts.geomgraph.DirectedEdgeStar.prototype.getLabel=function(){return this.label};jsts.geomgraph.DirectedEdgeStar.prototype.getOutgoingDegree=function(){var degree=0;for(var it=this.iterator();it.hasNext();){var de=it.next();if(de.isInResult())degree++}return degree};jsts.geomgraph.DirectedEdgeStar.prototype.getOutgoingDegree=function(er){var degree=0;for(var it=this.iterator();it.hasNext();){var de=it.next();if(de.getEdgeRing()===er)degree++}return degree};jsts.geomgraph.DirectedEdgeStar.prototype.getRightmostEdge=function(){var edges=this.getEdges();var size=edges.size();if(size<1)return null;var de0=edges.get(0);if(size==1)return de0;var deLast=edges.get(size-1);var quad0=de0.getQuadrant();var quad1=deLast.getQuadrant();if(jsts.geomgraph.Quadrant.isNorthern(quad0)&&jsts.geomgraph.Quadrant.isNorthern(quad1))return de0;else if(!jsts.geomgraph.Quadrant.isNorthern(quad0)&&!jsts.geomgraph.Quadrant.isNorthern(quad1))return deLast;else{var nonHorizontalEdge=null;if(de0.getDy()!=0)return de0;else if(deLast.getDy()!=0)return deLast}Assert.shouldNeverReachHere("found two horizontal edges incident on node");return null};jsts.geomgraph.DirectedEdgeStar.prototype.computeLabelling=function(geom){EdgeEndStar.prototype.computeLabelling.call(this,geom);this.label=new jsts.geomgraph.Label(Location.NONE);for(var it=this.iterator();it.hasNext();){var ee=it.next();var e=ee.getEdge();var eLabel=e.getLabel();for(var i=0;i<2;i++){var eLoc=eLabel.getLocation(i);if(eLoc===Location.INTERIOR||eLoc===Location.BOUNDARY)this.label.setLocation(i,Location.INTERIOR)}}};jsts.geomgraph.DirectedEdgeStar.prototype.mergeSymLabels=function(){for(var it=this.iterator();it.hasNext();){var de=it.next();var label=de.getLabel();label.merge(de.getSym().getLabel())}};jsts.geomgraph.DirectedEdgeStar.prototype.updateLabelling=function(nodeLabel){for(var it=this.iterator();it.hasNext();){var de=it.next();var label=de.getLabel();label.setAllLocationsIfNull(0,nodeLabel.getLocation(0));label.setAllLocationsIfNull(1,nodeLabel.getLocation(1))}};jsts.geomgraph.DirectedEdgeStar.prototype.getResultAreaEdges=function(){if(this.resultAreaEdgeList!==null)return this.resultAreaEdgeList;this.resultAreaEdgeList=new javascript.util.ArrayList;for(var it=this.iterator();it.hasNext();){var de=it.next();if(de.isInResult()||de.getSym().isInResult())this.resultAreaEdgeList.add(de)}return this.resultAreaEdgeList};jsts.geomgraph.DirectedEdgeStar.prototype.SCANNING_FOR_INCOMING=1;jsts.geomgraph.DirectedEdgeStar.prototype.LINKING_TO_OUTGOING=2;jsts.geomgraph.DirectedEdgeStar.prototype.linkResultDirectedEdges=function(){this.getResultAreaEdges();var firstOut=null;var incoming=null;var state=this.SCANNING_FOR_INCOMING;for(var i=0;i<this.resultAreaEdgeList.size();i++){var nextOut=this.resultAreaEdgeList.get(i);var nextIn=nextOut.getSym();if(!nextOut.getLabel().isArea())continue;if(firstOut===null&&nextOut.isInResult())firstOut=nextOut;switch(state){case this.SCANNING_FOR_INCOMING:if(!nextIn.isInResult())continue;incoming=nextIn;state=this.LINKING_TO_OUTGOING;break;case this.LINKING_TO_OUTGOING:if(!nextOut.isInResult())continue;incoming.setNext(nextOut);state=this.SCANNING_FOR_INCOMING;break}}if(state===this.LINKING_TO_OUTGOING){if(firstOut===null)throw new jsts.error.TopologyError("no outgoing dirEdge found",this.getCoordinate());Assert.isTrue(firstOut.isInResult(),"unable to link last incoming dirEdge");incoming.setNext(firstOut)}};jsts.geomgraph.DirectedEdgeStar.prototype.linkMinimalDirectedEdges=function(er){var firstOut=null;var incoming=null;var state=this.SCANNING_FOR_INCOMING;for(var i=this.resultAreaEdgeList.size()-1;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;i<endIndex;i++){var nextDe=this.edgeList.get(i);var label=nextDe.getLabel();nextDe.setEdgeDepths(Position.RIGHT,currDepth);currDepth=nextDe.getDepth(Position.LEFT)}return currDepth}})();jsts.algorithm.CentroidLine=function(){this.centSum=new jsts.geom.Coordinate};jsts.algorithm.CentroidLine.prototype.centSum=null;jsts.algorithm.CentroidLine.prototype.totalLength=0;jsts.algorithm.CentroidLine.prototype.add=function(geom){if(geom instanceof Array){this.add2.apply(this,arguments);return}if(geom instanceof jsts.geom.LineString){this.add(geom.getCoordinates())}else if(geom instanceof jsts.geom.Polygon){var poly=geom;this.add(poly.getExteriorRing().getCoordinates());for(var i=0;i<poly.getNumInteriorRing();i++){this.add(poly.getInteriorRingN(i).getCoordinates())}}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.MultiLineString||geom instanceof jsts.geom.MultiPolygon){var gc=geom;for(var i=0;i<gc.getNumGeometries();i++){this.add(gc.getGeometryN(i))}}};jsts.algorithm.CentroidLine.prototype.getCentroid=function(){var cent=new jsts.geom.Coordinate;cent.x=this.centSum.x/this.totalLength;cent.y=this.centSum.y/this.totalLength;return cent};jsts.algorithm.CentroidLine.prototype.add2=function(pts){for(var i=0;i<pts.length-1;i++){var segmentLen=pts[i].distance(pts[i+1]);this.totalLength+=segmentLen;var midx=(pts[i].x+pts[i+1].x)/2;this.centSum.x+=segmentLen*midx;var midy=(pts[i].y+pts[i+1].y)/2;this.centSum.y+=segmentLen*midy}};jsts.index.IntervalSize=function(){};jsts.index.IntervalSize.MIN_BINARY_EXPONENT=-50;jsts.index.IntervalSize.isZeroWidth=function(min,max){var width=max-min;if(width===0){return true}var maxAbs,scaledInterval,level;maxAbs=Math.max(Math.abs(min),Math.abs(max));scaledInterval=width/maxAbs;level=jsts.index.DoubleBits.exponent(scaledInterval);return level<=jsts.index.IntervalSize.MIN_BINARY_EXPONENT};jsts.geomgraph.index.SimpleEdgeSetIntersector=function(){};jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype=new jsts.geomgraph.index.EdgeSetIntersector;jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.nOverlaps=0;jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersections=function(edges,si,testAllSegments){if(si instanceof javascript.util.List){this.computeIntersections2.apply(this,arguments);return}this.nOverlaps=0;for(var i0=edges.iterator();i0.hasNext();){var edge0=i0.next();for(var i1=edges.iterator();i1.hasNext();){var edge1=i1.next();if(testAllSegments||edge0!=edge1)this.computeIntersects(edge0,edge1,si)}}};jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersections2=function(edges0,edges1,si){this.nOverlaps=0;for(var i0=edges0.iterator();i0.hasNext();){var edge0=i0.next();for(var i1=edges1.iterator();i1.hasNext();){var edge1=i1.next();this.computeIntersects(edge0,edge1,si)}}};jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersects=function(e0,e1,si){var pts0=e0.getCoordinates();var pts1=e1.getCoordinates();var i0,i1;for(i0=0;i0<pts0.length-1;i0++){for(i1=0;i1<pts1.length-1;i1++){si.addIntersections(e0,i0,e1,i1)}}};jsts.geomgraph.Edge=function(pts,label){this.pts=pts;this.label=label;this.eiList=new jsts.geomgraph.EdgeIntersectionList(this);this.depth=new jsts.geomgraph.Depth};jsts.geomgraph.Edge.prototype=new jsts.geomgraph.GraphComponent;jsts.geomgraph.Edge.constructor=jsts.geomgraph.Edge;jsts.geomgraph.Edge.updateIM=function(label,im){im.setAtLeastIfValid(label.getLocation(0,jsts.geomgraph.Position.ON),label.getLocation(1,jsts.geomgraph.Position.ON),1);if(label.isArea()){im.setAtLeastIfValid(label.getLocation(0,jsts.geomgraph.Position.LEFT),label.getLocation(1,jsts.geomgraph.Position.LEFT),2);im.setAtLeastIfValid(label.getLocation(0,jsts.geomgraph.Position.RIGHT),label.getLocation(1,jsts.geomgraph.Position.RIGHT),2)}};jsts.geomgraph.Edge.prototype.pts=null;jsts.geomgraph.Edge.prototype.env=null;jsts.geomgraph.Edge.prototype.name=null;jsts.geomgraph.Edge.prototype.mce=null;jsts.geomgraph.Edge.prototype._isIsolated=true;jsts.geomgraph.Edge.prototype.depth=null;jsts.geomgraph.Edge.prototype.depthDelta=0;jsts.geomgraph.Edge.prototype.eiList=null;jsts.geomgraph.Edge.prototype.getNumPoints=function(){return this.pts.length};jsts.geomgraph.Edge.prototype.getEnvelope=function(){if(this.env===null){this.env=new jsts.geom.Envelope;for(var i=0;i<this.pts.length;i++){this.env.expandToInclude(pts[i])}}return env};jsts.geomgraph.Edge.prototype.getDepth=function(){return this.depth};jsts.geomgraph.Edge.prototype.getDepthDelta=function(){return this.depthDelta};jsts.geomgraph.Edge.prototype.setDepthDelta=function(depthDelta){this.depthDelta=depthDelta};jsts.geomgraph.Edge.prototype.getCoordinates=function(){return this.pts};jsts.geomgraph.Edge.prototype.getCoordinate=function(i){if(i===undefined){if(this.pts.length>0){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<li.getIntersectionNum();i++){this.addIntersection(li,segmentIndex,geomIndex,i)}};jsts.geomgraph.Edge.prototype.addIntersection=function(li,segmentIndex,geomIndex,intIndex){var intPt=new jsts.geom.Coordinate(li.getIntersection(intIndex));var normalizedSegmentIndex=segmentIndex;var dist=li.getEdgeDistance(geomIndex,intIndex);var nextSegIndex=normalizedSegmentIndex+1;if(nextSegIndex<this.pts.length){var nextPt=this.pts[nextSegIndex];if(intPt.equals2D(nextPt)){normalizedSegmentIndex=nextSegIndex;dist=0}}var ei=this.eiList.add(intPt,normalizedSegmentIndex,dist)};jsts.geomgraph.Edge.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1};jsts.geomgraph.Edge.prototype.getEdgeIntersectionList=function(){return this.eiList};jsts.geomgraph.Edge.prototype.getMonotoneChainEdge=function(){if(this.mce==null){this.mce=new jsts.geomgraph.index.MonotoneChainEdge(this)}return this.mce};jsts.geomgraph.Edge.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])};jsts.geomgraph.Edge.prototype.isCollapsed=function(){if(!this.label.isArea())return false;if(this.pts.length!=3)return false;if(this.pts[0].equals(this.pts[2]))return true;return false};jsts.geomgraph.Edge.prototype.getCollapsedEdge=function(){var newPts=[];newPts[0]=this.pts[0];newPts[1]=this.pts[1];var newe=new jsts.geomgraph.Edge(newPts,jsts.geomgraph.Label.toLineLabel(this.label));return newe};jsts.geomgraph.Edge.prototype.computeIM=function(im){jsts.geomgraph.Edge.updateIM(this.label,im)};jsts.geomgraph.Edge.prototype.isPointwiseEqual=function(e){if(this.pts.length!=e.pts.length)return false;for(var i=0;i<this.pts.length;i++){if(!this.pts[i].equals2D(e.pts[i])){return false}}return true};jsts.noding.Octant=function(){throw jsts.error.AbstractMethodInvocationError()};jsts.noding.Octant.octant=function(dx,dy){if(dx instanceof jsts.geom.Coordinate){return jsts.noding.Octant.octant2.apply(this,arguments)}if(dx===0&&dy===0)throw new jsts.error.IllegalArgumentError("Cannot compute the octant for point ( "+dx+", "+dy+" )");var adx=Math.abs(dx);var ady=Math.abs(dy);if(dx>=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();i<l;i++){var elem=this.g0.getGeometryN(i);this.interacts0[i]=this.computeInteracting(elem)}}else{var interactsWithAny=false;for(var i=0,l=g1.getNumGeometries();i<l;i++){var elem1=this.g1.getGeometryN(i);var interacts=elem1.getEnvelopeInternal().intersects(elem0.getEnvelopeInternal());if(interacts){this.interacts1[i]=true;interactsWithAny=true}}return interactsWithAny}};jsts.operation.union.UnionInteracting.prototype.extractElements=function(geom,interacts,isInteracting){var extractedGeoms=[];for(var i=0,l=geom.getNumGeometries();i<l;i++){var elem=geom.getGeometryN(i);if(interacts[i]===isInteracting){extractedGeoms.push(elem)}}return this.geomFactory.buildGeometry(extractedGeoms)};jsts.triangulate.quadedge.TrianglePredicate=function(){};jsts.triangulate.quadedge.TrianglePredicate.isInCircleNonRobust=function(a,b,c,p){var isInCircle=(a.x*a.x+a.y*a.y)*jsts.triangulate.quadedge.TrianglePredicate.triArea(b,c,p)-(b.x*b.x+b.y*b.y)*jsts.triangulate.quadedge.TrianglePredicate.triArea(a,c,p)+(c.x*c.x+c.y*c.y)*jsts.triangulate.quadedge.TrianglePredicate.triArea(a,b,p)-(p.x*p.x+p.y*p.y)*jsts.triangulate.quadedge.TrianglePredicate.triArea(a,b,c)>0;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();i<l;i++){var point=this.pointGeom.getGeometryN(i);var coord=point.getCoordinate();var loc=locator.locate(coord,this.otherGeom);if(loc===jsts.geom.Location.EXTERIOR){var include=true;for(var j=exteriorCoords.length;i--;){if(exteriorCoords[j].equals(coord)){include=false;break}}if(include){exteriorCoords.push(coord)}}}exteriorCoords.sort(function(x,y){return x.compareTo(y)});if(exteriorCoords.length===0){return this.otherGeom}var ptComp=null;var coords=jsts.geom.CoordinateArrays.toCoordinateArray(exteriorCoords);if(coords.length===1){ptComp=this.geomFact.createPoint(coords[0])}else{ptComp=this.geomFact.createMultiPoint(coords)}return jsts.geom.util.GeometryCombiner.combine(ptComp,this.otherGeom)};jsts.noding.IntersectionFinderAdder=function(li){this.li=li;this.interiorIntersections=new javascript.util.ArrayList};jsts.noding.IntersectionFinderAdder.prototype=new jsts.noding.SegmentIntersector;jsts.noding.IntersectionFinderAdder.constructor=jsts.noding.IntersectionFinderAdder;jsts.noding.IntersectionFinderAdder.prototype.li=null;jsts.noding.IntersectionFinderAdder.prototype.interiorIntersections=null;jsts.noding.IntersectionFinderAdder.prototype.getInteriorIntersections=function(){return this.interiorIntersections};jsts.noding.IntersectionFinderAdder.prototype.processIntersections=function(e0,segIndex0,e1,segIndex1){if(e0===e1&&segIndex0===segIndex1)return;var p00=e0.getCoordinates()[segIndex0];var p01=e0.getCoordinates()[segIndex0+1];var p10=e1.getCoordinates()[segIndex1];var p11=e1.getCoordinates()[segIndex1+1];this.li.computeIntersection(p00,p01,p10,p11);if(this.li.hasIntersection()){if(this.li.isInteriorIntersection()){for(var intIndex=0;intIndex<this.li.getIntersectionNum();intIndex++){this.interiorIntersections.add(this.li.getIntersection(intIndex))}e0.addIntersections(this.li,segIndex0,0);e1.addIntersections(this.li,segIndex1,1)}}};jsts.noding.IntersectionFinderAdder.prototype.isDone=function(){return false};jsts.noding.snapround.MCIndexSnapRounder=function(pm){this.pm=pm;this.li=new jsts.algorithm.RobustLineIntersector;this.li.setPrecisionModel(pm);this.scaleFactor=pm.getScale()};jsts.noding.snapround.MCIndexSnapRounder.prototype=new jsts.noding.Noder;jsts.noding.snapround.MCIndexSnapRounder.constructor=jsts.noding.snapround.MCIndexSnapRounder;jsts.noding.snapround.MCIndexSnapRounder.prototype.pm=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.li=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.scaleFactor=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.noder=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.pointSnapper=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.nodedSegStrings=null;jsts.noding.snapround.MCIndexSnapRounder.prototype.getNodedSubstrings=function(){return jsts.noding.NodedSegmentString.getNodedSubstrings(this.nodedSegStrings)};jsts.noding.snapround.MCIndexSnapRounder.prototype.computeNodes=function(inputSegmentStrings){this.nodedSegStrings=inputSegmentStrings;this.noder=new jsts.noding.MCIndexNoder;this.pointSnapper=new jsts.noding.snapround.MCIndexPointSnapper(this.noder.getIndex());this.snapRound(inputSegmentStrings,this.li)};jsts.noding.snapround.MCIndexSnapRounder.prototype.snapRound=function(segStrings,li){var intersections=this.findInteriorIntersections(segStrings,li);this.computeIntersectionSnaps(intersections);this.computeVertexSnaps(segStrings)};jsts.noding.snapround.MCIndexSnapRounder.prototype.findInteriorIntersections=function(segStrings,li){var intFinderAdder=new jsts.noding.IntersectionFinderAdder(li);this.noder.setSegmentIntersector(intFinderAdder);this.noder.computeNodes(segStrings);return intFinderAdder.getInteriorIntersections()};jsts.noding.snapround.MCIndexSnapRounder.prototype.computeIntersectionSnaps=function(snapPts){for(var it=snapPts.iterator();it.hasNext();){var snapPt=it.next();var hotPixel=new jsts.noding.snapround.HotPixel(snapPt,this.scaleFactor,this.li);this.pointSnapper.snap(hotPixel)}};jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps=function(edges){if(edges instanceof jsts.noding.NodedSegmentString){this.computeVertexSnaps2.apply(this,arguments);return}for(var i0=edges.iterator();i0.hasNext();){var edge0=i0.next();this.computeVertexSnaps(edge0)}};jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps2=function(e){var pts0=e.getCoordinates();for(var i=0;i<pts0.length-1;i++){var hotPixel=new jsts.noding.snapround.HotPixel(pts0[i],this.scaleFactor,this.li);var isNodeAdded=this.pointSnapper.snap(hotPixel,e,i);if(isNodeAdded){e.addIntersection(pts0[i],i)}}};jsts.operation.valid.ConnectedInteriorTester=function(geomGraph){this.geomGraph=geomGraph;this.geometryFactory=new jsts.geom.GeometryFactory;this.disconnectedRingcoord=null};jsts.operation.valid.ConnectedInteriorTester.findDifferentPoint=function(coord,pt){var i=0,il=coord.length;for(i;i<il;i++){if(!coord[i].equals(pt))return coord[i]}return null};jsts.operation.valid.ConnectedInteriorTester.prototype.getCoordinate=function(){return this.disconnectedRingcoord};jsts.operation.valid.ConnectedInteriorTester.prototype.isInteriorsConnected=function(){var splitEdges=new javascript.util.ArrayList;this.geomGraph.computeSplitEdges(splitEdges);var graph=new jsts.geomgraph.PlanarGraph(new jsts.operation.overlay.OverlayNodeFactory);graph.addEdges(splitEdges);this.setInteriorEdgesInResult(graph);graph.linkResultDirectedEdges();var edgeRings=this.buildEdgeRings(graph.getEdgeEnds());this.visitShellInteriors(this.geomGraph.getGeometry(),graph);return!this.hasUnvisitedShellEdge(edgeRings)};jsts.operation.valid.ConnectedInteriorTester.prototype.setInteriorEdgesInResult=function(graph){var it=graph.getEdgeEnds().iterator(),de;while(it.hasNext()){de=it.next();if(de.getLabel().getLocation(0,jsts.geomgraph.Position.RIGHT)==jsts.geom.Location.INTERIOR){de.setInResult(true)}}};jsts.operation.valid.ConnectedInteriorTester.prototype.buildEdgeRings=function(dirEdges){var edgeRings=new javascript.util.ArrayList;for(var it=dirEdges.iterator();it.hasNext();){var de=it.next();if(de.isInResult()&&de.getEdgeRing()==null){var er=new jsts.operation.overlay.MaximalEdgeRing(de,this.geometryFactory);er.linkDirectedEdgesForMinimalEdgeRings();var minEdgeRings=er.buildMinimalRings();var i=0,il=minEdgeRings.length;for(i;i<il;i++){edgeRings.add(minEdgeRings[i])}}}return edgeRings};jsts.operation.valid.ConnectedInteriorTester.prototype.visitShellInteriors=function(g,graph){if(g instanceof jsts.geom.Polygon){var p=g;this.visitInteriorRing(p.getExteriorRing(),graph)}if(g instanceof jsts.geom.MultiPolygon){var mp=g;for(var i=0;i<mp.getNumGeometries();i++){var p=mp.getGeometryN(i);this.visitInteriorRing(p.getExteriorRing(),graph)}}};jsts.operation.valid.ConnectedInteriorTester.prototype.visitInteriorRing=function(ring,graph){var pts=ring.getCoordinates();var pt0=pts[0];var pt1=jsts.operation.valid.ConnectedInteriorTester.findDifferentPoint(pts,pt0);var e=graph.findEdgeInSameDirection(pt0,pt1);var de=graph.findEdgeEnd(e);var intDe=null;if(de.getLabel().getLocation(0,jsts.geomgraph.Position.RIGHT)==jsts.geom.Location.INTERIOR){intDe=de}else if(de.getSym().getLabel().getLocation(0,jsts.geomgraph.Position.RIGHT)==jsts.geom.Location.INTERIOR){intDe=de.getSym()}this.visitLinkedDirectedEdges(intDe)};jsts.operation.valid.ConnectedInteriorTester.prototype.visitLinkedDirectedEdges=function(start){var startDe=start;var de=start;do{de.setVisited(true);de=de.getNext()}while(de!=startDe)};jsts.operation.valid.ConnectedInteriorTester.prototype.hasUnvisitedShellEdge=function(edgeRings){for(var i=0;i<edgeRings.size();i++){var er=edgeRings.get(i);if(er.isHole()){continue}var edges=er.getEdges();var de=edges[0];if(de.getLabel().getLocation(0,jsts.geomgraph.Position.RIGHT)!=jsts.geom.Location.INTERIOR){continue}for(var j=0;j<edges.length;j++){de=edges[j];if(!de.isVisited()){disconnectedRingcoord=de.getCoordinate();return true}}}return false};jsts.algorithm.InteriorPointLine=function(geometry){this.centroid;this.minDistance=Number.MAX_VALUE;this.interiorPoint=null;this.centroid=geometry.getCentroid().getCoordinate();this.addInterior(geometry);if(this.interiorPoint==null){this.addEndpoints(geometry)}};jsts.algorithm.InteriorPointLine.prototype.getInteriorPoint=function(){return this.interiorPoint};jsts.algorithm.InteriorPointLine.prototype.addInterior=function(geometry){if(geometry instanceof jsts.geom.LineString){this.addInteriorCoord(geometry.getCoordinates())}else if(geometry instanceof jsts.geom.GeometryCollection){for(var i=0;i<geometry.getNumGeometries();i++){this.addInterior(geometry.getGeometryN(i))}}};jsts.algorithm.InteriorPointLine.prototype.addInteriorCoord=function(pts){for(var i=1;i<pts.length-1;i++){this.add(pts[i])}};jsts.algorithm.InteriorPointLine.prototype.addEndpoints=function(geometry){if(geometry instanceof jsts.geom.LineString){this.addEndpointsCoord(geometry.getCoordinates())}else if(geometry instanceof jsts.geom.GeometryCollection){for(var i=0;i<geometry.getNumGeometries();i++){this.addEndpoints(geometry.getGeometryN(i))}}};jsts.algorithm.InteriorPointLine.prototype.addEndpointsCoord=function(pts){this.add(pts[0]);this.add(pts[pts.length-1])};jsts.algorithm.InteriorPointLine.prototype.add=function(point){var dist=point.distance(this.centroid);if(dist<this.minDistance){this.interiorPoint=new jsts.geom.Coordinate(point);this.minDistance=dist}};jsts.index.chain.MonotoneChainSelectAction=function(){this.tempEnv1=new jsts.geom.Envelope;this.selectedSegment=new jsts.geom.LineSegment};jsts.index.chain.MonotoneChainSelectAction.prototype.tempEnv1=null;jsts.index.chain.MonotoneChainSelectAction.prototype.selectedSegment=null;jsts.index.chain.MonotoneChainSelectAction.prototype.select=function(mc,start){mc.getLineSegment(start,this.selectedSegment);this.select2(this.selectedSegment)};jsts.index.chain.MonotoneChainSelectAction.prototype.select2=function(seg){};jsts.algorithm.MCPointInRing=function(ring){this.ring=ring;this.tree=null;this.crossings=0;this.interval=new jsts.index.bintree.Interval;this.buildIndex()};jsts.algorithm.MCPointInRing.MCSelecter=function(p,parent){this.parent=parent;this.p=p};jsts.algorithm.MCPointInRing.MCSelecter.prototype=new jsts.index.chain.MonotoneChainSelectAction;jsts.algorithm.MCPointInRing.MCSelecter.prototype.constructor=jsts.algorithm.MCPointInRing.MCSelecter;jsts.algorithm.MCPointInRing.MCSelecter.prototype.select2=function(ls){this.parent.testLineSegment.apply(this.parent,[this.p,ls])};jsts.algorithm.MCPointInRing.prototype.buildIndex=function(){this.tree=new jsts.index.bintree.Bintree;var pts=jsts.geom.CoordinateArrays.removeRepeatedPoints(this.ring.getCoordinates());var mcList=jsts.index.chain.MonotoneChainBuilder.getChains(pts);for(var i=0;i<mcList.length;i++){var mc=mcList[i];var mcEnv=mc.getEnvelope();this.interval.min=mcEnv.getMinY();this.interval.max=mcEnv.getMaxY();this.tree.insert(this.interval,mc)}};jsts.algorithm.MCPointInRing.prototype.isInside=function(pt){this.crossings=0;var rayEnv=new jsts.geom.Envelope(-Number.MAX_VALUE,Number.MAX_VALUE,pt.y,pt.y);this.interval.min=pt.y;this.interval.max=pt.y;var segs=this.tree.query(this.interval);var mcSelecter=new jsts.algorithm.MCPointInRing.MCSelecter(pt,this);for(var i=segs.iterator();i.hasNext();){var mc=i.next();this.testMonotoneChain(rayEnv,mcSelecter,mc)}if(this.crossings%2==1){return true}return false};jsts.algorithm.MCPointInRing.prototype.testMonotoneChain=function(rayEnv,mcSelecter,mc){mc.select(rayEnv,mcSelecter)};jsts.algorithm.MCPointInRing.prototype.testLineSegment=function(p,seg){var xInt,x1,y1,x2,y2,p1,p2;p1=seg.p0;p2=seg.p1;x1=p1.x-p.x;y1=p1.y-p.y;x2=p2.x-p.x;y2=p2.y-p.y;if(y1>0&&y2<=0||y2>0&&y1<=0){xInt=jsts.algorithm.RobustDeterminant.signOfDet2x2(x1,y1,x2,y2)/(y2-y1);if(0<xInt){this.crossings++}}};jsts.operation.valid.TopologyValidationError=function(errorType,pt){this.errorType=errorType;this.pt=null;if(pt!=null){this.pt=pt.clone()}};jsts.operation.valid.TopologyValidationError.HOLE_OUTSIDE_SHELL=2;jsts.operation.valid.TopologyValidationError.NESTED_HOLES=3;jsts.operation.valid.TopologyValidationError.DISCONNECTED_INTERIOR=4;jsts.operation.valid.TopologyValidationError.SELF_INTERSECTION=5;jsts.operation.valid.TopologyValidationError.RING_SELF_INTERSECTION=6;jsts.operation.valid.TopologyValidationError.NESTED_SHELLS=7;jsts.operation.valid.TopologyValidationError.DUPLICATE_RINGS=8;jsts.operation.valid.TopologyValidationError.TOO_FEW_POINTS=9;jsts.operation.valid.TopologyValidationError.INVALID_COORDINATE=10;jsts.operation.valid.TopologyValidationError.RING_NOT_CLOSED=11;jsts.operation.valid.TopologyValidationError.prototype.errMsg=["Topology Validation Error","Repeated Point","Hole lies outside shell","Holes are nested","Interior is disconnected","Self-intersection","Ring Self-intersection","Nested shells","Duplicate Rings","Too few distinct points in geometry component","Invalid Coordinate","Ring is not closed"];jsts.operation.valid.TopologyValidationError.prototype.getCoordinate=function(){return this.pt};jsts.operation.valid.TopologyValidationError.prototype.getErrorType=function(){return this.errorType};jsts.operation.valid.TopologyValidationError.prototype.getMessage=function(){return this.errMsg[this.errorType]};jsts.operation.valid.TopologyValidationError.prototype.toString=function(){var locStr="";if(this.pt!=null){locStr=" at or near point "+this.pt;return this.getMessage()+locStr}return locStr};(function(){jsts.geom.MultiPolygon=function(geometries,factory){this.geometries=geometries||[];this.factory=factory};jsts.geom.MultiPolygon.prototype=new jsts.geom.GeometryCollection;jsts.geom.MultiPolygon.constructor=jsts.geom.MultiPolygon;jsts.geom.MultiPolygon.prototype.getBoundary=function(){if(this.isEmpty()){return this.getFactory().createMultiLineString(null)}var allRings=[];for(var i=0;i<this.geometries.length;i++){var polygon=this.geometries[i];var rings=polygon.getBoundary();for(var j=0;j<rings.getNumGeometries();j++){allRings.push(rings.getGeometryN(j))}}return this.getFactory().createMultiLineString(allRings)};jsts.geom.MultiPolygon.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}return jsts.geom.GeometryCollection.prototype.equalsExact.call(this,other,tolerance)};jsts.geom.MultiPolygon.prototype.CLASS_NAME="jsts.geom.MultiPolygon"})();jsts.geom.CoordinateSequenceFilter=function(){};jsts.geom.CoordinateSequenceFilter.prototype.filter=jsts.abstractFunc;jsts.geom.CoordinateSequenceFilter.prototype.isDone=jsts.abstractFunc;jsts.geom.CoordinateSequenceFilter.prototype.isGeometryChanged=jsts.abstractFunc;(function(){var Interval=function(){this.min=0;this.max=0;if(arguments.length===1){var interval=arguments[0];this.init(interval.min,interval.max)}else if(arguments.length===2){this.init(arguments[0],arguments[1])}};Interval.prototype.init=function(min,max){this.min=min;this.max=max;if(min>max){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.min<this.min){this.min=interval.min}};Interval.prototype.overlaps=function(){if(arguments.length===1){return this.overlapsInterval.apply(this,arguments)}else{return this.overlapsMinMax.apply(this,arguments)}};Interval.prototype.overlapsInterval=function(interval){return this.overlaps(interval.min,interval.max)};Interval.prototype.overlapsMinMax=function(min,max){if(this.min>max||this.max<min){return false}return true};Interval.prototype.contains=function(){var interval;if(arguments[0]instanceof jsts.index.bintree.Interval){interval=arguments[0];return this.containsMinMax(interval.min,interval.max)}else if(arguments.length===1){return this.containsPoint(arguments[0])}else{return this.containsMinMax(arguments[0],arguments[1])}};Interval.prototype.containsMinMax=function(min,max){return min>=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<<NumW/4-1}Expo=Math.pow(2,ExW)-1;Mant=0}}if(!Bin){Expo={32:127,64:1023}[NumW];Mant=Math.abs(Qty);while(Mant>=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;i<this.subgraphs.length;i++){var bsg=this.subgraphs[i];var env=bsg.getEnvelope();if(stabbingRayLeftPt.y<env.getMinY()||stabbingRayLeftPt.y>env.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;i<pts.length-1;i++){this.seg.p0=pts[i];this.seg.p1=pts[i+1];if(this.seg.p0.y>this.seg.p1.y)this.seg.reverse();var maxx=Math.max(this.seg.p0.x,this.seg.p1.x);if(maxx<stabbingRayLeftPt.x)continue;if(this.seg.isHorizontal())continue;if(stabbingRayLeftPt.y<this.seg.p0.y||stabbingRayLeftPt.y>this.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.maxx<segMinx||this.minx>segMaxx||this.maxy<segMiny||this.miny>segMaxy;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(lastIndex<this.inputLine.length){var isMiddleVertexDeleted=false;if(this.isDeletable(index,midIndex,lastIndex,this.distanceTol)){this.isDeleted[midIndex]=jsts.operation.buffer.BufferInputLineSimplifier.DELETE;isMiddleVertexDeleted=true;isChanged=true}if(isMiddleVertexDeleted)index=lastIndex;else index=midIndex;midIndex=this.findNextNonDeletedIndex(index);lastIndex=this.findNextNonDeletedIndex(midIndex)}return isChanged};jsts.operation.buffer.BufferInputLineSimplifier.prototype.findNextNonDeletedIndex=function(index){var next=index+1;while(next<this.inputLine.length&&this.isDeleted[next]===jsts.operation.buffer.BufferInputLineSimplifier.DELETE)next++;return next};jsts.operation.buffer.BufferInputLineSimplifier.prototype.collapseLine=function(){var coordList=[];for(var i=0;i<this.inputLine.length;i++){if(this.isDeleted[i]!==jsts.operation.buffer.BufferInputLineSimplifier.DELETE)coordList.push(this.inputLine[i])}return coordList};jsts.operation.buffer.BufferInputLineSimplifier.prototype.isDeletable=function(i0,i1,i2,distanceTol){var p0=this.inputLine[i0];var p1=this.inputLine[i1];var p2=this.inputLine[i2];if(!this.isConcave(p0,p1,p2))return false;if(!this.isShallow(p0,p1,p2,distanceTol))return false;return this.isShallowSampled(p0,p1,i0,i2,distanceTol)};jsts.operation.buffer.BufferInputLineSimplifier.prototype.isShallowConcavity=function(p0,p1,p2,distanceTol){var orientation=jsts.algorithm.CGAlgorithms.computeOrientation(p0,p1,p2);var isAngleToSimplify=orientation===this.angleOrientation;if(!isAngleToSimplify)return false;var dist=jsts.algorithm.CGAlgorithms.distancePointLine(p1,p0,p2);return dist<distanceTol};jsts.operation.buffer.BufferInputLineSimplifier.NUM_PTS_TO_CHECK=10;jsts.operation.buffer.BufferInputLineSimplifier.prototype.isShallowSampled=function(p0,p2,i0,i2,distanceTol){var inc=parseInt((i2-i0)/jsts.operation.buffer.BufferInputLineSimplifier.NUM_PTS_TO_CHECK);if(inc<=0)inc=1;for(var i=i0;i<i2;i+=inc){if(!this.isShallow(p0,p2,this.inputLine[i],distanceTol))return false}return true};jsts.operation.buffer.BufferInputLineSimplifier.prototype.isShallow=function(p0,p1,p2,distanceTol){var dist=jsts.algorithm.CGAlgorithms.distancePointLine(p1,p0,p2);return dist<distanceTol};jsts.operation.buffer.BufferInputLineSimplifier.prototype.isConcave=function(p0,p1,p2){var orientation=jsts.algorithm.CGAlgorithms.computeOrientation(p0,p1,p2);var isConcave=orientation===this.angleOrientation;return isConcave};jsts.geomgraph.index.SweepLineEvent=function(x,obj,label){if(!(obj instanceof jsts.geomgraph.index.SweepLineEvent)){this.eventType=jsts.geomgraph.index.SweepLineEvent.INSERT;this.label=label;this.xValue=x;this.obj=obj;return}this.eventType=jsts.geomgraph.index.SweepLineEvent.DELETE;this.xValue=x;this.insertEvent=obj};jsts.geomgraph.index.SweepLineEvent.INSERT=1;jsts.geomgraph.index.SweepLineEvent.DELETE=2;jsts.geomgraph.index.SweepLineEvent.prototype.label=null;jsts.geomgraph.index.SweepLineEvent.prototype.xValue=null;jsts.geomgraph.index.SweepLineEvent.prototype.eventType=null;jsts.geomgraph.index.SweepLineEvent.prototype.insertEvent=null;jsts.geomgraph.index.SweepLineEvent.prototype.deleteEventIndex=null;jsts.geomgraph.index.SweepLineEvent.prototype.obj=null;jsts.geomgraph.index.SweepLineEvent.prototype.isInsert=function(){return this.eventType==jsts.geomgraph.index.SweepLineEvent.INSERT};jsts.geomgraph.index.SweepLineEvent.prototype.isDelete=function(){return this.eventType==jsts.geomgraph.index.SweepLineEvent.DELETE};jsts.geomgraph.index.SweepLineEvent.prototype.getInsertEvent=function(){return this.insertEvent};jsts.geomgraph.index.SweepLineEvent.prototype.getDeleteEventIndex=function(){return this.deleteEventIndex};jsts.geomgraph.index.SweepLineEvent.prototype.setDeleteEventIndex=function(deleteEventIndex){this.deleteEventIndex=deleteEventIndex};jsts.geomgraph.index.SweepLineEvent.prototype.getObject=function(){return this.obj};jsts.geomgraph.index.SweepLineEvent.prototype.isSameLabel=function(ev){if(this.label==null){return false}return this.label==ev.label};jsts.geomgraph.index.SweepLineEvent.prototype.compareTo=function(pe){if(this.xValue<pe.xValue){return-1}if(this.xValue>pe.xValue){return 1}if(this.eventType<pe.eventType){return-1}if(this.eventType>pe.eventType){return 1}
return 0};jsts.geom.CoordinateList=function(coord,allowRepeated){this.array=[];allowRepeated=allowRepeated===undefined?true:allowRepeated;if(coord!==undefined){this.add(coord,allowRepeated)}};jsts.geom.CoordinateList.prototype=new javascript.util.ArrayList;jsts.geom.CoordinateList.prototype.iterator=null;jsts.geom.CoordinateList.prototype.remove=null;jsts.geom.CoordinateList.prototype.get=function(i){return this.array[i]};jsts.geom.CoordinateList.prototype.set=function(i,e){var o=this.array[i];this.array[i]=e;return o};jsts.geom.CoordinateList.prototype.size=function(){return this.array.length};jsts.geom.CoordinateList.prototype.add=function(){if(arguments.length>1){return this.addCoordinates.apply(this,arguments)}else{return this.array.push(arguments[0])}};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<coord.length;i++){this.addCoordinate(coord[i],allowRepeated)}}else{for(var i=coord.length-1;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=index<this.size()-1?index+1:-1;if(after!==-1&&this.get(after).equals2D(coord)){return}}this.array.splice(index,0,coord)};jsts.geom.CoordinateList.prototype.closeRing=function(){if(this.size()>0){this.addCoordinate(new jsts.geom.Coordinate(this.get(0)),false)}};jsts.geom.CoordinateList.prototype.toArray=function(){return this.array};jsts.geom.CoordinateList.prototype.toCoordinateArray=function(){return this.array};jsts.operation.buffer.OffsetSegmentGenerator=function(precisionModel,bufParams,distance){this.seg0=new jsts.geom.LineSegment;this.seg1=new jsts.geom.LineSegment;this.offset0=new jsts.geom.LineSegment;this.offset1=new jsts.geom.LineSegment;this.precisionModel=precisionModel;this.bufParams=bufParams;this.li=new jsts.algorithm.RobustLineIntersector;this.filletAngleQuantum=Math.PI/2/bufParams.getQuadrantSegments();if(this.bufParams.getQuadrantSegments()>=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)<this.distance*jsts.operation.buffer.OffsetSegmentGenerator.OFFSET_SEGMENT_SEPARATION_FACTOR){this.segList.addPt(this.offset0.p1);return}if(this.bufParams.getJoinStyle()===jsts.operation.buffer.BufferParameters.JOIN_MITRE){this.addMitreJoin(this.s1,this.offset0,this.offset1,this.distance)}else if(this.bufParams.getJoinStyle()===jsts.operation.buffer.BufferParameters.JOIN_BEVEL){this.addBevelJoin(this.offset0,this.offset1)}else{if(addStartPoint)this.segList.addPt(this.offset0.p1);this.addFillet(this.s1,this.offset0.p1,this.offset1.p0,orientation,this.distance);this.segList.addPt(this.offset1.p0)}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.addInsideTurn=function(orientation,addStartPoint){this.li.computeIntersection(this.offset0.p0,this.offset0.p1,this.offset1.p0,this.offset1.p1);if(this.li.hasIntersection()){this.segList.addPt(this.li.getIntersection(0))}else{this.hasNarrowConcaveAngle=true;if(this.offset0.p1.distance(this.offset1.p0)<this.distance*jsts.operation.buffer.OffsetSegmentGenerator.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR){this.segList.addPt(this.offset0.p1)}else{this.segList.addPt(this.offset0.p1);if(this.closingSegLengthFactor>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(currAngle<totalAngle){var angle=startAngle+directionFactor*currAngle;pt.x=p.x+radius*Math.cos(angle);pt.y=p.y+radius*Math.sin(angle);this.segList.addPt(pt);currAngle+=currAngleInc}};jsts.operation.buffer.OffsetSegmentGenerator.prototype.createCircle=function(p){var pt=new jsts.geom.Coordinate(p.x+this.distance,p.y);this.segList.addPt(pt);this.addFillet(p,0,2*Math.PI,-1,this.distance);this.segList.closeRing()};jsts.operation.buffer.OffsetSegmentGenerator.prototype.createSquare=function(p){this.segList.addPt(new jsts.geom.Coordinate(p.x+distance,p.y+distance));this.segList.addPt(new jsts.geom.Coordinate(p.x+distance,p.y-distance));this.segList.addPt(new jsts.geom.Coordinate(p.x-distance,p.y-distance));this.segList.addPt(new jsts.geom.Coordinate(p.x-distance,p.y+distance));this.segList.closeRing()};jsts.operation.overlay.MaximalEdgeRing=function(start,geometryFactory){jsts.geomgraph.EdgeRing.call(this,start,geometryFactory)};jsts.operation.overlay.MaximalEdgeRing.prototype=new jsts.geomgraph.EdgeRing;jsts.operation.overlay.MaximalEdgeRing.constructor=jsts.operation.overlay.MaximalEdgeRing;jsts.operation.overlay.MaximalEdgeRing.prototype.getNext=function(de){return de.getNext()};jsts.operation.overlay.MaximalEdgeRing.prototype.setEdgeRing=function(de,er){de.setEdgeRing(er)};jsts.operation.overlay.MaximalEdgeRing.prototype.linkDirectedEdgesForMinimalEdgeRings=function(){var de=this.startDe;do{var node=de.getNode();node.getEdges().linkMinimalDirectedEdges(this);de=de.getNext()}while(de!=this.startDe)};jsts.operation.overlay.MaximalEdgeRing.prototype.buildMinimalRings=function(){var minEdgeRings=[];var de=this.startDe;do{if(de.getMinEdgeRing()===null){var minEr=new jsts.operation.overlay.MinimalEdgeRing(de,this.geometryFactory);minEdgeRings.push(minEr)}de=de.getNext()}while(de!=this.startDe);return minEdgeRings};jsts.algorithm.CentroidPoint=function(){this.centSum=new jsts.geom.Coordinate};jsts.algorithm.CentroidPoint.prototype.ptCount=0;jsts.algorithm.CentroidPoint.prototype.centSum=null;jsts.algorithm.CentroidPoint.prototype.add=function(geom){if(geom instanceof jsts.geom.Point){this.add2(geom.getCoordinate())}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPoint||geom instanceof jsts.geom.MultiLineString||geom instanceof jsts.geom.MultiPolygon){var gc=geom;for(var i=0;i<gc.getNumGeometries();i++){this.add(gc.getGeometryN(i))}}};jsts.algorithm.CentroidPoint.prototype.add2=function(pt){this.ptCount+=1;this.centSum.x+=pt.x;this.centSum.y+=pt.y};jsts.algorithm.CentroidPoint.prototype.getCentroid=function(){var cent=new jsts.geom.Coordinate;cent.x=this.centSum.x/this.ptCount;cent.y=this.centSum.y/this.ptCount;return cent};jsts.operation.distance.ConnectedElementLocationFilter=function(locations){this.locations=locations};jsts.operation.distance.ConnectedElementLocationFilter.prototype=new jsts.geom.GeometryFilter;jsts.operation.distance.ConnectedElementLocationFilter.prototype.locations=null;jsts.operation.distance.ConnectedElementLocationFilter.getLocations=function(geom){var locations=[];geom.apply(new jsts.operation.distance.ConnectedElementLocationFilter(locations));return locations};jsts.operation.distance.ConnectedElementLocationFilter.prototype.filter=function(geom){if(geom instanceof jsts.geom.Point||geom instanceof jsts.geom.LineString||geom instanceof jsts.geom.Polygon)this.locations.push(new jsts.operation.distance.GeometryLocation(geom,0,geom.getCoordinate()))};jsts.geomgraph.index.MonotoneChainEdge=function(e){this.e=e;this.pts=e.getCoordinates();var mcb=new jsts.geomgraph.index.MonotoneChainIndexer;this.startIndex=mcb.getChainStartIndices(this.pts)};jsts.geomgraph.index.MonotoneChainEdge.prototype.e=null;jsts.geomgraph.index.MonotoneChainEdge.prototype.pts=null;jsts.geomgraph.index.MonotoneChainEdge.prototype.startIndex=null;jsts.geomgraph.index.MonotoneChainEdge.prototype.env1=new jsts.geom.Envelope;jsts.geomgraph.index.MonotoneChainEdge.prototype.env2=new jsts.geom.Envelope;jsts.geomgraph.index.MonotoneChainEdge.prototype.getCoordinates=function(){return this.pts};jsts.geomgraph.index.MonotoneChainEdge.prototype.getStartIndexes=function(){return this.startIndex};jsts.geomgraph.index.MonotoneChainEdge.prototype.getMinX=function(chainIndex){var x1=this.pts[this.startIndex[chainIndex]].x;var x2=this.pts[this.startIndex[chainIndex+1]].x;if(x1<x2){return x1}return x2};jsts.geomgraph.index.MonotoneChainEdge.prototype.getMaxX=function(chainIndex){var x1=this.pts[this.startIndex[chainIndex]].x;var x2=this.pts[this.startIndex[chainIndex+1]].x;if(x1>x2){return x1}return x2};jsts.geomgraph.index.MonotoneChainEdge.prototype.computeIntersects=function(mce,si){for(var i=0;i<this.startIndex.length-1;i++){for(var j=0;j<mce.startIndex.length-1;j++){this.computeIntersectsForChain(i,mce,j,si)}}};jsts.geomgraph.index.MonotoneChainEdge.prototype.computeIntersectsForChain=function(chainIndex0,mce,chainIndex1,si){this.computeIntersectsForChain2(this.startIndex[chainIndex0],this.startIndex[chainIndex0+1],mce,mce.startIndex[chainIndex1],mce.startIndex[chainIndex1+1],si)};jsts.geomgraph.index.MonotoneChainEdge.prototype.computeIntersectsForChain2=function(start0,end0,mce,start1,end1,ei){var p00=this.pts[start0];var p01=this.pts[end0];var p10=mce.pts[start1];var p11=mce.pts[end1];if(end0-start0==1&&end1-start1==1){ei.addIntersections(this.e,start0,mce.e,start1);return}this.env1.init(p00,p01);this.env2.init(p10,p11);if(!this.env1.intersects(this.env2)){return}var mid0=Math.floor((start0+end0)/2);var mid1=Math.floor((start1+end1)/2);if(start0<mid0){if(start1<mid1){this.computeIntersectsForChain2(start0,mid0,mce,start1,mid1,ei)}if(mid1<end1){this.computeIntersectsForChain2(start0,mid0,mce,mid1,end1,ei)}}if(mid0<end0){if(start1<mid1){this.computeIntersectsForChain2(mid0,end0,mce,start1,mid1,ei)}if(mid1<end1){this.computeIntersectsForChain2(mid0,end0,mce,mid1,end1,ei)}}};(function(){var ArrayList=javascript.util.ArrayList;jsts.operation.relate.EdgeEndBuilder=function(){};jsts.operation.relate.EdgeEndBuilder.prototype.computeEdgeEnds=function(edges){if(arguments.length==2){this.computeEdgeEnds2.apply(this,arguments);return}var l=new ArrayList;for(var i=edges;i.hasNext();){var e=i.next();this.computeEdgeEnds2(e,l)}return l};jsts.operation.relate.EdgeEndBuilder.prototype.computeEdgeEnds2=function(edge,l){var eiList=edge.getEdgeIntersectionList();eiList.addEndpoints();var it=eiList.iterator();var eiPrev=null;var eiCurr=null;if(!it.hasNext())return;var eiNext=it.next();do{eiPrev=eiCurr;eiCurr=eiNext;eiNext=null;if(it.hasNext())eiNext=it.next();if(eiCurr!==null){this.createEdgeEndForPrev(edge,l,eiCurr,eiPrev);this.createEdgeEndForNext(edge,l,eiCurr,eiNext)}}while(eiCurr!==null)};jsts.operation.relate.EdgeEndBuilder.prototype.createEdgeEndForPrev=function(edge,l,eiCurr,eiPrev){var iPrev=eiCurr.segmentIndex;if(eiCurr.dist===0){if(iPrev===0)return;iPrev--}var pPrev=edge.getCoordinate(iPrev);if(eiPrev!==null&&eiPrev.segmentIndex>=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(){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(op<oq){return-1}if(op>oq){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;i<polyPts.length;i++){reducedSet.add(polyPts[i])}for(var i=0;i<inputPts.length;i++){if(!CGAlgorithms.isPointInRing(inputPts[i],polyPts)){reducedSet.add(inputPts[i])}}var reducedPts=reducedSet.toArray();if(reducedPts.length<3)return this.padArray3(reducedPts);return reducedPts};jsts.algorithm.ConvexHull.prototype.padArray3=function(pts){var pad=[];for(var i=0;i<pad.length;i++){if(i<pts.length){pad[i]=pts[i]}else pad[i]=pts[0]}return pad};jsts.algorithm.ConvexHull.prototype.preSort=function(pts){var t;for(var i=1;i<pts.length;i++){if(pts[i].y<pts[0].y||pts[i].y==pts[0].y&&pts[i].x<pts[0].x){t=pts[0];pts[0]=pts[i];pts[i]=t}}Arrays.sort(pts,1,pts.length,new RadialComparator(pts[0]));return pts};jsts.algorithm.ConvexHull.prototype.grahamScan=function(c){var p;var ps=new Stack;p=ps.push(c[0]);p=ps.push(c[1]);p=ps.push(c[2]);for(var i=3;i<c.length;i++){p=ps.pop();while(!ps.empty()&&CGAlgorithms.computeOrientation(ps.peek(),p,c[i])>0){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;i<inputPts.length;i++){if(inputPts[i].x<pts[0].x){pts[0]=inputPts[i]}if(inputPts[i].x-inputPts[i].y<pts[1].x-pts[1].y){pts[1]=inputPts[i]}if(inputPts[i].y>pts[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<pts[6].y){pts[6]=inputPts[i]}if(inputPts[i].x+inputPts[i].y<pts[7].x+pts[7].y){pts[7]=inputPts[i]}}return pts};jsts.algorithm.ConvexHull.prototype.lineOrPolygon=function(coordinates){coordinates=this.cleanRing(coordinates);if(coordinates.length==3){return this.geomFactory.createLineString([coordinates[0],coordinates[1]])}var linearRing=this.geomFactory.createLinearRing(coordinates);return this.geomFactory.createPolygon(linearRing,null)};jsts.algorithm.ConvexHull.prototype.cleanRing=function(original){Assert.equals(original[0],original[original.length-1]);var cleanedRing=new ArrayList;var previousDistinctCoordinate=null;for(var i=0;i<=original.length-2;i++){var currentCoordinate=original[i];var nextCoordinate=original[i+1];if(currentCoordinate.equals(nextCoordinate)){continue}if(previousDistinctCoordinate!=null&&this.isBetween(previousDistinctCoordinate,currentCoordinate,nextCoordinate)){continue}cleanedRing.add(currentCoordinate);previousDistinctCoordinate=currentCoordinate}cleanedRing.add(original[original.length-1]);var cleanedRingCoordinates=[];return cleanedRing.toArray(cleanedRingCoordinates)}})();jsts.algorithm.MinimumDiameter=function(inputGeom,isConvex){this.convexHullPts=null;this.minBaseSeg=new jsts.geom.LineSegment;this.minWidthPt=null;this.minPtIndex=0;this.minWidth=0;jsts.algorithm.MinimumDiameter.inputGeom=inputGeom;jsts.algorithm.MinimumDiameter.isConvex=isConvex||false};jsts.algorithm.MinimumDiameter.inputGeom=null;jsts.algorithm.MinimumDiameter.isConvex=false;jsts.algorithm.MinimumDiameter.nextIndex=function(pts,index){index++;if(index>=pts.length){index=0}return index};jsts.algorithm.MinimumDiameter.computeC=function(a,b,p){return a*p.y-b*p.x};jsts.algorithm.MinimumDiameter.computeSegmentForLine=function(a,b,c){var p0;var p1;if(Math.abs(b)>Math.abs(a)){p0=new jsts.geom.Coordinate(0,c/b);p1=new jsts.geom.Coordinate(1,c/b-a/b)}else{p0=new jsts.geom.Coordinate(c/a,0);p1=new jsts.geom.Coordinate(c/a-b/a,1)}return new jsts.geom.LineSegment(p0,p1)};jsts.algorithm.MinimumDiameter.prototype.getLength=function(){this.computeMinimumDiameter();return this.minWidth};jsts.algorithm.MinimumDiameter.prototype.getWidthCoordinate=function(){this.computeMinimumDiameter();return this.minWidthPt};jsts.algorithm.MinimumDiameter.prototype.getSupportingSegment=function(){this.computeMinimumDiameter();var coord=[this.minBaseSeg.p0,this.minBaseSeg.p1];return jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createLineString(coord)};jsts.algorithm.MinimumDiameter.prototype.getDiameter=function(){this.computeMinimumDiameter();if(this.minWidthPt===null){return jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createLineString(null)}var basePt=this.minBaseSeg.project(this.minWidthPt);return jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createLineString([basePt,this.minWidthPt])};jsts.algorithm.MinimumDiameter.prototype.computeMinimumDiameter=function(){if(this.minWidthPt!==null){return}if(jsts.algorithm.MinimumDiameter.isConvex)this.computeWidthConvex(jsts.algorithm.MinimumDiameter.inputGeom);else{var convexGeom=new jsts.algorithm.ConvexHull(jsts.algorithm.MinimumDiameter.inputGeom).getConvexHull();this.computeWidthConvex(convexGeom)}};jsts.algorithm.MinimumDiameter.prototype.computeWidthConvex=function(convexGeom){if(convexGeom instanceof jsts.geom.Polygon){this.convexHullPts=convexGeom.getExteriorRing().getCoordinates()}else{this.convexHullPts=convexGeom.getCoordinates()}if(this.convexHullPts.length===0){this.minWidth=0;this.minWidthPt=null;this.minBaseSeg=null}else if(this.convexHullPts.length===1){this.minWidth=0;this.minWidthPt=this.convexHullPts[0];this.minBaseSeg.p0=this.convexHullPts[0];this.minBaseSeg.p1=this.convexHullPts[0]}else if(this.convexHullPts.length===2||this.convexHullPts.length===3){this.minWidth=0;this.minWidthPt=this.convexHullPts[0];this.minBaseSeg.p0=this.convexHullPts[0];this.minBaseSeg.p1=this.convexHullPts[1]}else{this.computeConvexRingMinDiameter(this.convexHullPts)}};jsts.algorithm.MinimumDiameter.prototype.computeConvexRingMinDiameter=function(pts){this.minWidth=Number.MAX_VALUE;var currMaxIndex=1;var seg=new jsts.geom.LineSegment;for(var i=0;i<pts.length-1;i++){seg.p0=pts[i];seg.p1=pts[i+1];currMaxIndex=this.findMaxPerpDistance(pts,seg,currMaxIndex)}};jsts.algorithm.MinimumDiameter.prototype.findMaxPerpDistance=function(pts,seg,startIndex){var maxPerpDistance=seg.distancePerpendicular(pts[startIndex]);var nextPerpDistance=maxPerpDistance;var maxIndex=startIndex;var nextIndex=maxIndex;while(nextPerpDistance>=maxPerpDistance){maxPerpDistance=nextPerpDistance;maxIndex=nextIndex;nextIndex=jsts.algorithm.MinimumDiameter.nextIndex(pts,maxIndex);nextPerpDistance=seg.distancePerpendicular(pts[nextIndex])}if(maxPerpDistance<this.minWidth){this.minPtIndex=maxIndex;this.minWidth=maxPerpDistance;this.minWidthPt=pts[this.minPtIndex];this.minBaseSeg=new jsts.geom.LineSegment(seg)}return maxIndex};jsts.algorithm.MinimumDiameter.prototype.getMinimumRectangle=function(){this.computeMinimumDiameter();if(this.minWidth===0){if(this.minBaseSeg.p0.equals2D(this.minBaseSeg.p1)){return jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createPoint(this.minBaseSeg.p0)}return this.minBaseSeg.toGeometry(jsts.algorithm.MinimumDiameter.inputGeom.getFactory())}var dx=this.minBaseSeg.p1.x-this.minBaseSeg.p0.x;var dy=this.minBaseSeg.p1.y-this.minBaseSeg.p0.y;var minPara=Number.MAX_VALUE;var maxPara=-Number.MAX_VALUE;var minPerp=Number.MAX_VALUE;var maxPerp=-Number.MAX_VALUE;for(var i=0;i<this.convexHullPts.length;i++){var paraC=jsts.algorithm.MinimumDiameter.computeC(dx,dy,this.convexHullPts[i]);if(paraC>maxPara)maxPara=paraC;if(paraC<minPara)minPara=paraC;var perpC=jsts.algorithm.MinimumDiameter.computeC(-dy,dx,this.convexHullPts[i]);if(perpC>maxPerp)maxPerp=perpC;if(perpC<minPerp)minPerp=perpC}var maxPerpLine=jsts.algorithm.MinimumDiameter.computeSegmentForLine(-dx,-dy,maxPerp);
var minPerpLine=jsts.algorithm.MinimumDiameter.computeSegmentForLine(-dx,-dy,minPerp);var maxParaLine=jsts.algorithm.MinimumDiameter.computeSegmentForLine(-dy,dx,maxPara);var minParaLine=jsts.algorithm.MinimumDiameter.computeSegmentForLine(-dy,dx,minPara);var p0=maxParaLine.lineIntersection(maxPerpLine);var p1=minParaLine.lineIntersection(maxPerpLine);var p2=minParaLine.lineIntersection(minPerpLine);var p3=maxParaLine.lineIntersection(minPerpLine);var shell=jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createLinearRing([p0,p1,p2,p3,p0]);return jsts.algorithm.MinimumDiameter.inputGeom.getFactory().createPolygon(shell,null)};(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;i<obj.features.length;++i){featureCollection.features.push(this.read(obj.features[i]))}}if(obj.bbox){featureCollection.bbox=this.parse.bbox.apply(this,[obj.bbox])}return featureCollection},coordinates:function(array){var coordinates=[];for(var i=0;i<array.length;++i){var sub=array[i];coordinates.push(new jsts.geom.Coordinate(sub[0],sub[1]))}return coordinates},bbox:function(array){return this.geometryFactory.createLinearRing([new jsts.geom.Coordinate(array[0],array[1]),new jsts.geom.Coordinate(array[2],array[1]),new jsts.geom.Coordinate(array[2],array[3]),new jsts.geom.Coordinate(array[0],array[3]),new jsts.geom.Coordinate(array[0],array[1])])},Point:function(array){var coordinate=new jsts.geom.Coordinate(array[0],array[1]);return this.geometryFactory.createPoint(coordinate)},MultiPoint:function(array){var points=[];for(var i=0;i<array.length;++i){points.push(this.parse.Point.apply(this,[array[i]]))}return this.geometryFactory.createMultiPoint(points)},LineString:function(array){var coordinates=this.parse.coordinates.apply(this,[array]);return this.geometryFactory.createLineString(coordinates)},MultiLineString:function(array){var lineStrings=[];for(var i=0;i<array.length;++i){lineStrings.push(this.parse.LineString.apply(this,[array[i]]))}return this.geometryFactory.createMultiLineString(lineStrings)},Polygon:function(array){var shellCoordinates=this.parse.coordinates.apply(this,[array[0]]);var shell=this.geometryFactory.createLinearRing(shellCoordinates);var holes=[];for(var i=1;i<array.length;++i){var hole=array[i];var coordinates=this.parse.coordinates.apply(this,[hole]);var linearRing=this.geometryFactory.createLinearRing(coordinates);holes.push(linearRing)}return this.geometryFactory.createPolygon(shell,holes)},MultiPolygon:function(array){var polygons=[];for(var i=0;i<array.length;++i){var polygon=array[i];polygons.push(this.parse.Polygon.apply(this,[polygon]))}return this.geometryFactory.createMultiPolygon(polygons)},GeometryCollection:function(array){var geometries=[];for(var i=0;i<array.length;++i){var geometry=array[i];geometries.push(this.read(geometry))}return this.geometryFactory.createGeometryCollection(geometries)}};jsts.io.GeoJSONParser.prototype.write=function(geometry){var type=geometry.CLASS_NAME.slice(10);if(!this.extract[type]){throw new Error("Geometry is not supported")}return this.extract[type].apply(this,[geometry])};jsts.io.GeoJSONParser.prototype.extract={coordinate:function(coordinate){return[coordinate.x,coordinate.y]},Point:function(point){var array=this.extract.coordinate.apply(this,[point.coordinate]);return{type:"Point",coordinates:array}},MultiPoint:function(multipoint){var array=[];for(var i=0;i<multipoint.geometries.length;++i){var point=multipoint.geometries[i];var geoJson=this.extract.Point.apply(this,[point]);array.push(geoJson.coordinates)}return{type:"MultiPoint",coordinates:array}},LineString:function(linestring){var array=[];for(var i=0;i<linestring.points.length;++i){var coordinate=linestring.points[i];array.push(this.extract.coordinate.apply(this,[coordinate]))}return{type:"LineString",coordinates:array}},MultiLineString:function(multilinestring){var array=[];for(var i=0;i<multilinestring.geometries.length;++i){var linestring=multilinestring.geometries[i];var geoJson=this.extract.LineString.apply(this,[linestring]);array.push(geoJson.coordinates)}return{type:"MultiLineString",coordinates:array}},Polygon:function(polygon){var array=[];var shellGeoJson=this.extract.LineString.apply(this,[polygon.shell]);array.push(shellGeoJson.coordinates);for(var i=0;i<polygon.holes.length;++i){var hole=polygon.holes[i];var holeGeoJson=this.extract.LineString.apply(this,[hole]);array.push(holeGeoJson.coordinates)}return{type:"Polygon",coordinates:array}},MultiPolygon:function(multipolygon){var array=[];for(var i=0;i<multipolygon.geometries.length;++i){var polygon=multipolygon.geometries[i];var geoJson=this.extract.Polygon.apply(this,[polygon]);array.push(geoJson.coordinates)}return{type:"MultiPolygon",coordinates:array}},GeometryCollection:function(collection){var array=[];for(var i=0;i<collection.geometries.length;++i){var geometry=collection.geometries[i];var type=geometry.CLASS_NAME.slice(10);array.push(this.extract[type].apply(this,[geometry]))}return{type:"GeometryCollection",geometries:array}}}})();jsts.triangulate.quadedge.Vertex=function(){if(arguments.length===1){this.initFromCoordinate(arguments[0])}else{this.initFromXY(arguments[0],arguments[1])}};jsts.triangulate.quadedge.Vertex.LEFT=0;jsts.triangulate.quadedge.Vertex.RIGHT=1;jsts.triangulate.quadedge.Vertex.BEYOND=2;jsts.triangulate.quadedge.Vertex.BEHIND=3;jsts.triangulate.quadedge.Vertex.BETWEEN=4;jsts.triangulate.quadedge.Vertex.ORIGIN=5;jsts.triangulate.quadedge.Vertex.DESTINATION=6;jsts.triangulate.quadedge.Vertex.prototype.initFromXY=function(x,y){this.p=new jsts.geom.Coordinate(x,y)};jsts.triangulate.quadedge.Vertex.prototype.initFromCoordinate=function(_p){this.p=new jsts.geom.Coordinate(_p)};jsts.triangulate.quadedge.Vertex.prototype.getX=function(){return this.p.x};jsts.triangulate.quadedge.Vertex.prototype.getY=function(){return this.p.y};jsts.triangulate.quadedge.Vertex.prototype.getZ=function(){return this.p.z};jsts.triangulate.quadedge.Vertex.prototype.setZ=function(z){this.p.z=z};jsts.triangulate.quadedge.Vertex.prototype.getCoordinate=function(){return this.p};jsts.triangulate.quadedge.Vertex.prototype.toString=function(){return"POINT ("+this.p.x+" "+this.p.y+")"};jsts.triangulate.quadedge.Vertex.prototype.equals=function(){if(arguments.length===1){return this.equalsExact(arguments[0])}else{return this.equalsWithTolerance(arguments[0],arguments[1])}};jsts.triangulate.quadedge.Vertex.prototype.equalsExact=function(other){return this.p.x===other.getX()&&this.p.y===other.getY()};jsts.triangulate.quadedge.Vertex.prototype.equalsWithTolerance=function(other,tolerance){return this.p.distance(other.getCoordinate())<tolerance};jsts.triangulate.quadedge.Vertex.prototype.classify=function(p0,p1){var p2,a,b,sa;p2=this;a=p1.sub(p0);b=p2.sub(p0);sa=a.crossProduct(b);if(sa>0){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()<b.magn()){return jsts.triangulate.quadedge.Vertex.BEYOND}if(p0.equals(p2)){return jsts.triangulate.quadedge.Vertex.ORIGIN}if(p1.equals(p2)){return jsts.triangulate.quadedge.Vertex.DESTINATION}return jsts.triangulate.quadedge.Vertex.BETWEEN};jsts.triangulate.quadedge.Vertex.prototype.crossProduct=function(v){return this.p.x*v.getY()-this.p.y*v.getX()};jsts.triangulate.quadedge.Vertex.prototype.dot=function(v){return this.p.x*v.getX()+this.p.y*v.getY()};jsts.triangulate.quadedge.Vertex.prototype.times=function(c){return new jsts.triangulate.quadedge.Vertex(c*this.p.x,c*this.p.y)};jsts.triangulate.quadedge.Vertex.prototype.sum=function(v){return new jsts.triangulate.quadedge.Vertex(this.p.x+v.getX(),this.p.y+v.getY())};jsts.triangulate.quadedge.Vertex.prototype.sub=function(v){return new jsts.triangulate.quadedge.Vertex(this.p.x-v.getX(),this.p.y-v.getY())};jsts.triangulate.quadedge.Vertex.prototype.magn=function(){return Math.sqrt(this.p.x*this.p.x+this.p.y*this.p.y)};jsts.triangulate.quadedge.Vertex.prototype.cross=function(){return new Vertex(this.p.y,-this.p.x)};jsts.triangulate.quadedge.Vertex.prototype.isInCircle=function(a,b,c){return jsts.triangulate.quadedge.TrianglePredicate.isInCircleRobust(a.p,b.p,c.p,this.p)};jsts.triangulate.quadedge.Vertex.prototype.isCCW=function(b,c){return(b.p.x-this.p.x)*(c.p.y-this.p.y)-(b.p.y-this.p.y)*(c.p.x-this.p.x)>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<edgeLength){edgeLength=el}el=this.distance(c,this);if(el<edgeLength){edgeLength=el}return radius/edgeLength};jsts.triangulate.quadedge.Vertex.prototype.midPoint=function(a){var xm,ym;xm=(this.p.x+a.getX())/2;ym=(this.p.y+a.getY())/2;return new jsts.triangulate.quadedge.Vertex(xm,ym)};jsts.triangulate.quadedge.Vertex.prototype.circleCenter=function(b,c){var a,cab,cbc,hcc,cc;a=new jsts.triangulate.quadedge.Vertex(this.getX(),this.getY());cab=this.bisector(a,b);cbc=this.bisector(b,c);hcc=new jsts.algorithm.HCoordinate(cab,cbc);cc=null;try{cc=new jsts.triangulate.quadedge.Vertex(hcc.getX(),hcc.getY())}catch(err){}return cc};jsts.operation.valid.IsValidOp=function(parentGeometry){this.parentGeometry=parentGeometry;this.isSelfTouchingRingFormingHoleValid=false;this.validErr=null};jsts.operation.valid.IsValidOp.isValid=function(arg){if(arguments[0]instanceof jsts.geom.Coordinate){if(isNaN(arg.x)){return false}if(!isFinite(arg.x)&&!isNaN(arg.x)){return false}if(isNaN(arg.y)){return false}if(!isFinite(arg.y)&&!isNaN(arg.y)){return false}return true}else{var isValidOp=new jsts.operation.valid.IsValidOp(arg);return isValidOp.isValid()}};jsts.operation.valid.IsValidOp.findPtNotNode=function(testCoords,searchRing,graph){var searchEdge=graph.findEdge(searchRing);var eiList=searchEdge.getEdgeIntersectionList();for(var i=0;i<testCoords.length;i++){var pt=testCoords[i];if(!eiList.isIntersection(pt)){return pt}}return null};jsts.operation.valid.IsValidOp.prototype.setSelfTouchingRingFormingHoleValid=function(isValid){this.isSelfTouchingRingFormingHoleValid=isValid};jsts.operation.valid.IsValidOp.prototype.isValid=function(){this.checkValid(this.parentGeometry);return this.validErr==null};jsts.operation.valid.IsValidOp.prototype.getValidationError=function(){this.checkValid(this.parentGeometry);return this.validErr};jsts.operation.valid.IsValidOp.prototype.checkValid=function(g){this.validErr=null;if(g.isEmpty()){return}if(g instanceof jsts.geom.Point){this.checkValidPoint(g)}else if(g instanceof jsts.geom.MultiPoint){this.checkValidMultiPoint(g)}else if(g instanceof jsts.geom.LinearRing){this.checkValidLinearRing(g)}else if(g instanceof jsts.geom.LineString){this.checkValidLineString(g)}else if(g instanceof jsts.geom.Polygon){this.checkValidPolygon(g)}else if(g instanceof jsts.geom.MultiPolygon){this.checkValidMultiPolygon(g)}else if(g instanceof jsts.geom.GeometryCollection){this.checkValidGeometryCollection(g)}else{throw g.constructor}};jsts.operation.valid.IsValidOp.prototype.checkValidPoint=function(g){this.checkInvalidCoordinates(g.getCoordinates())};jsts.operation.valid.IsValidOp.prototype.checkValidMultiPoint=function(g){this.checkInvalidCoordinates(g.getCoordinates())};jsts.operation.valid.IsValidOp.prototype.checkValidLineString=function(g){this.checkInvalidCoordinates(g.getCoordinates());if(this.validErr!=null){return}var graph=new jsts.geomgraph.GeometryGraph(0,g);this.checkTooFewPoints(graph)};jsts.operation.valid.IsValidOp.prototype.checkValidLinearRing=function(g){this.checkInvalidCoordinates(g.getCoordinates());if(this.validErr!=null){return}this.checkClosedRing(g);if(this.validErr!=null){return}var graph=new jsts.geomgraph.GeometryGraph(0,g);this.checkTooFewPoints(graph);if(this.validErr!=null){return}var li=new jsts.algorithm.RobustLineIntersector;graph.computeSelfNodes(li,true);this.checkNoSelfIntersectingRings(graph)};jsts.operation.valid.IsValidOp.prototype.checkValidPolygon=function(g){this.checkInvalidCoordinates(g);if(this.validErr!=null){return}this.checkClosedRings(g);if(this.validErr!=null){return}var graph=new jsts.geomgraph.GeometryGraph(0,g);this.checkTooFewPoints(graph);if(this.validErr!=null){return}this.checkConsistentArea(graph);if(this.validErr!=null){return}if(!this.isSelfTouchingRingFormingHoleValid){this.checkNoSelfIntersectingRings(graph);if(this.validErr!=null){return}}this.checkHolesInShell(g,graph);if(this.validErr!=null){return}this.checkHolesNotNested(g,graph);if(this.validErr!=null){return}this.checkConnectedInteriors(graph)};jsts.operation.valid.IsValidOp.prototype.checkValidMultiPolygon=function(g){var il=g.getNumGeometries();for(var i=0;i<il;i++){var p=g.getGeometryN(i);this.checkInvalidCoordinates(p);if(this.validErr!=null){return}this.checkClosedRings(p);if(this.validErr!=null){return}}var graph=new jsts.geomgraph.GeometryGraph(0,g);this.checkTooFewPoints(graph);if(this.validErr!=null){return}this.checkConsistentArea(graph);if(this.validErr!=null){return}if(!this.isSelfTouchingRingFormingHoleValid){this.checkNoSelfIntersectingRings(graph);if(this.validErr!=null){return}}for(var i=0;i<g.getNumGeometries();i++){var p=g.getGeometryN(i);this.checkHolesInShell(p,graph);if(this.validErr!=null){return}}for(var i=0;i<g.getNumGeometries();i++){var p=g.getGeometryN(i);this.checkHolesNotNested(p,graph);if(this.validErr!=null){return}}this.checkShellsNotNested(g,graph);if(this.validErr!=null){return}this.checkConnectedInteriors(graph)};jsts.operation.valid.IsValidOp.prototype.checkValidGeometryCollection=function(gc){for(var i=0;i<gc.getNumGeometries();i++){var g=gc.getGeometryN(i);this.checkValid(g);if(this.validErr!=null){return}}};jsts.operation.valid.IsValidOp.prototype.checkInvalidCoordinates=function(arg){if(arg instanceof jsts.geom.Polygon){var poly=arg;this.checkInvalidCoordinates(poly.getExteriorRing().getCoordinates());if(this.validErr!=null){return}for(var i=0;i<poly.getNumInteriorRing();i++){this.checkInvalidCoordinates(poly.getInteriorRingN(i).getCoordinates());if(this.validErr!=null){return}}}else{var coords=arg;for(var i=0;i<coords.length;i++){if(!jsts.operation.valid.IsValidOp.isValid(coords[i])){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.INVALID_COORDINATE,coords[i]);return}}}};jsts.operation.valid.IsValidOp.prototype.checkClosedRings=function(poly){this.checkClosedRing(poly.getExteriorRing());if(this.validErr!=null){return}for(var i=0;i<poly.getNumInteriorRing();i++){this.checkClosedRing(poly.getInteriorRingN(i));if(this.validErr!=null){return}}};jsts.operation.valid.IsValidOp.prototype.checkClosedRing=function(ring){if(!ring.isClosed()){var pt=null;if(ring.getNumPoints()>=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;i<p.getNumInteriorRing();i++){var hole=p.getInteriorRingN(i);var holePt=jsts.operation.valid.IsValidOp.findPtNotNode(hole.getCoordinates(),shell,graph);if(holePt==null){return}var outside=!pir.isInside(holePt);if(outside){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.HOLE_OUTSIDE_SHELL,holePt);return}}};jsts.operation.valid.IsValidOp.prototype.checkHolesNotNested=function(p,graph){var nestedTester=new jsts.operation.valid.IndexedNestedRingTester(graph);for(var i=0;i<p.getNumInteriorRing();i++){var innerHole=p.getInteriorRingN(i);nestedTester.add(innerHole)}var isNonNested=nestedTester.isNonNested();if(!isNonNested){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.NESTED_HOLES,nestedTester.getNestedPoint())}};jsts.operation.valid.IsValidOp.prototype.checkShellsNotNested=function(mp,graph){for(var i=0;i<mp.getNumGeometries();i++){var p=mp.getGeometryN(i);var shell=p.getExteriorRing();for(var j=0;j<mp.getNumGeometries();j++){if(i==j){continue}var p2=mp.getGeometryN(j);this.checkShellNotNested(shell,p2,graph);if(this.validErr!=null){return}}}};jsts.operation.valid.IsValidOp.prototype.checkShellNotNested=function(shell,p,graph){var shellPts=shell.getCoordinates();var polyShell=p.getExteriorRing();var polyPts=polyShell.getCoordinates();var shellPt=jsts.operation.valid.IsValidOp.findPtNotNode(shellPts,polyShell,graph);if(shellPt==null){return}var insidePolyShell=jsts.algorithm.CGAlgorithms.isPointInRing(shellPt,polyPts);if(!insidePolyShell){return}if(p.getNumInteriorRing()<=0){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.NESTED_SHELLS,shellPt);return}var badNestedPt=null;for(var i=0;i<p.getNumInteriorRing();i++){var hole=p.getInteriorRingN(i);badNestedPt=this.checkShellInsideHole(shell,hole,graph);if(badNestedPt==null){return}}this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.NESTED_SHELLS,badNestedPt)};jsts.operation.valid.IsValidOp.prototype.checkShellInsideHole=function(shell,hole,graph){var shellPts=shell.getCoordinates();var holePts=hole.getCoordinates();var shellPt=jsts.operation.valid.IsValidOp.findPtNotNode(shellPts,hole,graph);if(shellPt!=null){var insideHole=jsts.algorithm.CGAlgorithms.isPointInRing(shellPt,holePts);if(!insideHole){return shellPt}}var holePt=jsts.operation.valid.IsValidOp.findPtNotNode(holePts,shell,graph);if(holePt!=null){var insideShell=jsts.algorithm.CGAlgorithms.isPointInRing(holePt,shellPts);if(insideShell){return holePt}return null}jsts.util.Assert.shouldNeverReachHere("points in shell and hole appear to be equal");return null};jsts.operation.valid.IsValidOp.prototype.checkConnectedInteriors=function(graph){var cit=new jsts.operation.valid.ConnectedInteriorTester(graph);if(!cit.isInteriorsConnected()){this.validErr=new jsts.operation.valid.TopologyValidationError(jsts.operation.valid.TopologyValidationError.DISCONNECTED_INTERIOR,cit.getCoordinate())}};jsts.algorithm.RobustDeterminant=function(){};jsts.algorithm.RobustDeterminant.signOfDet2x2=function(x1,y1,x2,y2){var sign,swap,k,count;count=0;sign=1;if(x1===0||y2===0){if(y1===0||x2===0){return 0}else if(y1>0){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(0<y1){if(0<y2){if(y1>y2){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){if(-y1<=y2){sign=-sign;x1=-x1;y1=-y1}else{swap=-x1;x1=x2;x2=swap;swap=-y1;y1=y2;y2=swap}}else{if(y1>=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(0<x1){if(0<x2){if(x1>x2){return sign}}else{return sign}}else{if(0<x2){return-sign}else{if(x1>=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(y1<y2+y2){return sign}}else{if(y1>y2+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(y2<y1+y1){return-sign}}else{if(y2>y1+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;i<il;i++){visitor.visitItem(this.items[i])}};jsts.index.quadtree.NodeBase.prototype.depth=function(){var maxSubDepth=0,i=0,sqd;for(i;i<4;i++){if(this.subnode[i]!==null){sqd=this.subnode[i].depth();if(sqd>maxSubDepth){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.quadrant<e.quadrant)return-1;return jsts.algorithm.CGAlgorithms.computeOrientation(e.p0,e.p1,this.p1)};jsts.geomgraph.EdgeEnd.prototype.computeLabel=function(boundaryNodeRule){}})();jsts.operation.buffer.RightmostEdgeFinder=function(){};jsts.operation.buffer.RightmostEdgeFinder.prototype.minIndex=-1;jsts.operation.buffer.RightmostEdgeFinder.prototype.minCoord=null;jsts.operation.buffer.RightmostEdgeFinder.prototype.minDe=null;jsts.operation.buffer.RightmostEdgeFinder.prototype.orientedDe=null;jsts.operation.buffer.RightmostEdgeFinder.prototype.getEdge=function(){return this.orientedDe};jsts.operation.buffer.RightmostEdgeFinder.prototype.getCoordinate=function(){return this.minCoord};jsts.operation.buffer.RightmostEdgeFinder.prototype.findEdge=function(dirEdgeList){for(var i=dirEdgeList.iterator();i.hasNext();){var de=i.next();if(!de.isForward())continue;this.checkForRightmostCoordinate(de)}jsts.util.Assert.isTrue(this.minIndex!==0||this.minCoord.equals(this.minDe.getCoordinate()),"inconsistency in rightmost processing");if(this.minIndex===0){this.findRightmostEdgeAtNode()}else{this.findRightmostEdgeAtVertex()}this.orientedDe=this.minDe;var rightmostSide=this.getRightmostSide(this.minDe,this.minIndex);if(rightmostSide==jsts.geomgraph.Position.LEFT){this.orientedDe=this.minDe.getSym()}};jsts.operation.buffer.RightmostEdgeFinder.prototype.findRightmostEdgeAtNode=function(){var node=this.minDe.getNode();var star=node.getEdges();this.minDe=star.getRightmostEdge();if(!this.minDe.isForward()){this.minDe=this.minDe.getSym();this.minIndex=this.minDe.getEdge().getCoordinates().length-1}};jsts.operation.buffer.RightmostEdgeFinder.prototype.findRightmostEdgeAtVertex=function(){var pts=this.minDe.getEdge().getCoordinates();jsts.util.Assert.isTrue(this.minIndex>0&&this.minIndex<pts.length,"rightmost point expected to be interior vertex of edge");var pPrev=pts[this.minIndex-1];var pNext=pts[this.minIndex+1];var orientation=jsts.algorithm.CGAlgorithms.computeOrientation(this.minCoord,pNext,pPrev);var usePrev=false;if(pPrev.y<this.minCoord.y&&pNext.y<this.minCoord.y&&orientation===jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE){usePrev=true}else if(pPrev.y>this.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;i<coord.length-1;i++){if(this.minCoord===null||coord[i].x>this.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].y<coord[i+1].y)pos=jsts.geomgraph.Position.RIGHT;return pos};(function(){jsts.triangulate.IncrementalDelaunayTriangulator=function(subdiv){this.subdiv=subdiv;this.isUsingTolerance=subdiv.getTolerance()>0};jsts.triangulate.IncrementalDelaunayTriangulator.prototype.insertSites=function(vertices){var i=0,il=vertices.length,v;for(i;i<il;i++){v=vertices[i];this.insertSite(v)}};jsts.triangulate.IncrementalDelaunayTriangulator.prototype.insertSite=function(v){var e,base,startEdge,t;e=this.subdiv.locate(v);if(this.subdiv.isVertexOfEdge(e,v)){return e}else if(this.subdiv.isOnEdge(e,v.getCoordinate())){e=e.oPrev();this.subdiv.delete_jsts(e.oNext())}base=this.subdiv.makeEdge(e.orig(),v);jsts.triangulate.quadedge.QuadEdge.splice(base,e);startEdge=base;do{base=this.subdiv.connect(e,base.sym());e=base.oPrev()}while(e.lNext()!=startEdge);do{t=e.oPrev();if(t.dest().rightOf(e)&&v.isInCircle(e.orig(),t.dest(),e.dest())){jsts.triangulate.quadedge.QuadEdge.swap(e);e=e.oPrev()}else if(e.oNext()==startEdge){return base}else{e=e.oNext().lPrev()}}while(true)}})();jsts.algorithm.CentroidArea=function(){this.basePt=null;this.triangleCent3=new jsts.geom.Coordinate;this.centSum=new jsts.geom.Coordinate;this.cg3=new jsts.geom.Coordinate};jsts.algorithm.CentroidArea.prototype.basePt=null;jsts.algorithm.CentroidArea.prototype.triangleCent3=null;jsts.algorithm.CentroidArea.prototype.areasum2=0;jsts.algorithm.CentroidArea.prototype.cg3=null;jsts.algorithm.CentroidArea.prototype.centSum=null;jsts.algorithm.CentroidArea.prototype.totalLength=0;jsts.algorithm.CentroidArea.prototype.add=function(geom){if(geom instanceof jsts.geom.Polygon){var poly=geom;this.setBasePoint(poly.getExteriorRing().getCoordinateN(0));this.add3(poly)}else if(geom instanceof jsts.geom.GeometryCollection||geom instanceof jsts.geom.MultiPolygon){var gc=geom;for(var i=0;i<gc.getNumGeometries();i++){this.add(gc.getGeometryN(i))}}else if(geom instanceof Array){this.add2(geom)}};jsts.algorithm.CentroidArea.prototype.add2=function(ring){this.setBasePoint(ring[0]);this.addShell(ring)};jsts.algorithm.CentroidArea.prototype.getCentroid=function(){var cent=new jsts.geom.Coordinate;if(Math.abs(this.areasum2)>0){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;i<poly.getNumInteriorRing();i++){this.addHole(poly.getInteriorRingN(i).getCoordinates())}};jsts.algorithm.CentroidArea.prototype.addShell=function(pts){var isPositiveArea=!jsts.algorithm.CGAlgorithms.isCCW(pts);for(var i=0;i<pts.length-1;i++){this.addTriangle(this.basePt,pts[i],pts[i+1],isPositiveArea)}this.addLinearSegments(pts)};jsts.algorithm.CentroidArea.prototype.addHole=function(pts){var isPositiveArea=jsts.algorithm.CGAlgorithms.isCCW(pts);for(var i=0;i<pts.length-1;i++){this.addTriangle(this.basePt,pts[i],pts[i+1],isPositiveArea)}this.addLinearSegments(pts)};jsts.algorithm.CentroidArea.prototype.addTriangle=function(p0,p1,p2,isPositiveArea){var sign=isPositiveArea?1:-1;jsts.algorithm.CentroidArea.centroid3(p0,p1,p2,this.triangleCent3);var area2=jsts.algorithm.CentroidArea.area2(p0,p1,p2);this.cg3.x+=sign*area2*this.triangleCent3.x;this.cg3.y+=sign*area2*this.triangleCent3.y;this.areasum2+=sign*area2};jsts.algorithm.CentroidArea.centroid3=function(p1,p2,p3,c){c.x=p1.x+p2.x+p3.x;c.y=p1.y+p2.y+p3.y;return};jsts.algorithm.CentroidArea.area2=function(p1,p2,p3){return(p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y)};jsts.algorithm.CentroidArea.prototype.addLinearSegments=function(pts){for(var i=0;i<pts.length-1;i++){var segmentLen=pts[i].distance(pts[i+1]);this.totalLength+=segmentLen;var midx=(pts[i].x+pts[i+1].x)/2;this.centSum.x+=segmentLen*midx;var midy=(pts[i].y+pts[i+1].y)/2;this.centSum.y+=segmentLen*midy}};jsts.geomgraph.index.SweepLineSegment=function(edge,ptIndex){this.edge=edge;this.ptIndex=ptIndex;this.pts=edge.getCoordinates()};jsts.geomgraph.index.SweepLineSegment.prototype.edge=null;jsts.geomgraph.index.SweepLineSegment.prototype.pts=null;jsts.geomgraph.index.SweepLineSegment.prototype.ptIndex=null;jsts.geomgraph.index.SweepLineSegment.prototype.getMinX=function(){var x1=this.pts[this.ptIndex].x;var x2=this.pts[this.ptIndex+1].x;if(x1<x2){return x1}return x2};jsts.geomgraph.index.SweepLineSegment.prototype.getMaxX=function(){var x1=this.pts[this.ptIndex].x;var x2=this.pts[this.ptIndex+1].x;if(x1>x2){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<pts.length-1);var startIndex=jsts.geomgraph.index.MonotoneChainIndexer.toIntArray(startIndexList);return startIndex};jsts.geomgraph.index.MonotoneChainIndexer.prototype.findChainEnd=function(pts,start){var chainQuad=jsts.geomgraph.Quadrant.quadrant(pts[start],pts[start+1]);var last=start+1;while(last<pts.length){var quad=jsts.geomgraph.Quadrant.quadrant(pts[last-1],pts[last]);if(quad!=chainQuad){break}last++}return last-1};jsts.noding.IntersectionAdder=function(li){this.li=li};jsts.noding.IntersectionAdder.prototype=new jsts.noding.SegmentIntersector;jsts.noding.IntersectionAdder.constructor=jsts.noding.IntersectionAdder;jsts.noding.IntersectionAdder.isAdjacentSegments=function(i1,i2){return Math.abs(i1-i2)===1};jsts.noding.IntersectionAdder.prototype._hasIntersection=false;jsts.noding.IntersectionAdder.prototype.hasProper=false;jsts.noding.IntersectionAdder.prototype.hasProperInterior=false;jsts.noding.IntersectionAdder.prototype.hasInterior=false;jsts.noding.IntersectionAdder.prototype.properIntersectionPoint=null;jsts.noding.IntersectionAdder.prototype.li=null;jsts.noding.IntersectionAdder.prototype.isSelfIntersection=null;jsts.noding.IntersectionAdder.prototype.numIntersections=0;jsts.noding.IntersectionAdder.prototype.numInteriorIntersections=0;jsts.noding.IntersectionAdder.prototype.numProperIntersections=0;jsts.noding.IntersectionAdder.prototype.numTests=0;jsts.noding.IntersectionAdder.prototype.getLineIntersector=function(){return this.li};jsts.noding.IntersectionAdder.prototype.getProperIntersectionPoint=function(){return this.properIntersectionPoint};jsts.noding.IntersectionAdder.prototype.hasIntersection=function(){return this._hasIntersection};jsts.noding.IntersectionAdder.prototype.hasProperIntersection=function(){return this.hasProper};jsts.noding.IntersectionAdder.prototype.hasProperInteriorIntersection=function(){return this.hasProperInterior};jsts.noding.IntersectionAdder.prototype.hasInteriorIntersection=function(){return this.hasInterior};jsts.noding.IntersectionAdder.prototype.isTrivialIntersection=function(e0,segIndex0,e1,segIndex1){if(e0==e1){if(this.li.getIntersectionNum()==1){if(jsts.noding.IntersectionAdder.isAdjacentSegments(segIndex0,segIndex1))return true;if(e0.isClosed()){var maxSegIndex=e0.size()-1;if(segIndex0===0&&segIndex1===maxSegIndex||segIndex1===0&&segIndex0===maxSegIndex){return true}}}}return false};jsts.noding.IntersectionAdder.prototype.processIntersections=function(e0,segIndex0,e1,segIndex1){if(e0===e1&&segIndex0===segIndex1)return;this.numTests++;var p00=e0.getCoordinates()[segIndex0];var p01=e0.getCoordinates()[segIndex0+1];var p10=e1.getCoordinates()[segIndex1];var p11=e1.getCoordinates()[segIndex1+1];this.li.computeIntersection(p00,p01,p10,p11);if(this.li.hasIntersection()){this.numIntersections++;if(this.li.isInteriorIntersection()){this.numInteriorIntersections++;this.hasInterior=true}if(!this.isTrivialIntersection(e0,segIndex0,e1,segIndex1)){this._hasIntersection=true;e0.addIntersections(this.li,segIndex0,0);e1.addIntersections(this.li,segIndex1,1);if(this.li.isProper()){this.numProperIntersections++;this.hasProper=true;this.hasProperInterior=true}}}};jsts.noding.IntersectionAdder.prototype.isDone=function(){return false};jsts.operation.union.CascadedPolygonUnion=function(polys){this.inputPolys=polys};jsts.operation.union.CascadedPolygonUnion.union=function(polys){var op=new jsts.operation.union.CascadedPolygonUnion(polys);return op.union()};jsts.operation.union.CascadedPolygonUnion.prototype.inputPolys;jsts.operation.union.CascadedPolygonUnion.prototype.geomFactory=null;jsts.operation.union.CascadedPolygonUnion.prototype.STRTREE_NODE_CAPACITY=4;jsts.operation.union.CascadedPolygonUnion.prototype.union=function(){if(this.inputPolys.length===0){return null}this.geomFactory=this.inputPolys[0].getFactory();var index=new jsts.index.strtree.STRtree(this.STRTREE_NODE_CAPACITY);for(var i=0,l=this.inputPolys.length;i<l;i++){var item=this.inputPolys[i];index.insert(item.getEnvelopeInternal(),item)}var itemTree=index.itemsTree();var unionAll=this.unionTree(itemTree);return unionAll};jsts.operation.union.CascadedPolygonUnion.prototype.unionTree=function(geomTree){var geoms=this.reduceToGeometries(geomTree);var union=this.binaryUnion(geoms);return union};jsts.operation.union.CascadedPolygonUnion.prototype.binaryUnion=function(geoms,start,end){start=start||0;end=end||geoms.length;if(end-start<=1){var g0=this.getGeometry(geoms,start);return this.unionSafe(g0,null)}else if(end-start===2){return this.unionSafe(this.getGeometry(geoms,start),this.getGeometry(geoms,start+1))}else{var mid=parseInt((end+start)/2);var g0=this.binaryUnion(geoms,start,mid);var g1=this.binaryUnion(geoms,mid,end);return this.unionSafe(g0,g1)}};jsts.operation.union.CascadedPolygonUnion.prototype.getGeometry=function(list,index){if(index>=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<l;i++){var o=geomTree[i],geom=null;if(o instanceof Array){geom=this.unionTree(o)}else if(o instanceof jsts.geom.Geometry){geom=o}geoms.push(geom)}return geoms};jsts.operation.union.CascadedPolygonUnion.prototype.unionSafe=function(g0,g1){if(g0===null&&g1===null){return null}if(g0===null){return g1.clone()}if(g1===null){return g0.clone()}return this.unionOptimized(g0,g1)};jsts.operation.union.CascadedPolygonUnion.prototype.unionOptimized=function(g0,g1){var g0Env=g0.getEnvelopeInternal(),g1Env=g1.getEnvelopeInternal();if(!g0Env.intersects(g1Env)){var combo=jsts.geom.util.GeometryCombiner.combine(g0,g1);return combo}if(g0.getNumGeometries<=1&&g1.getNumGeometries<=1){return this.unionActual(g0,g1)}var commonEnv=g0Env.intersection(g1Env);return this.unionUsingEnvelopeIntersection(g0,g1,commonEnv)};jsts.operation.union.CascadedPolygonUnion.prototype.unionUsingEnvelopeIntersection=function(g0,g1,common){var disjointPolys=new javascript.util.ArrayList;var g0Int=this.extractByEnvelope(common,g0,disjointPolys);var g1Int=this.extractByEnvelope(common,g1,disjointPolys);var union=this.unionActual(g0Int,g1Int);disjointPolys.add(union);var overallUnion=jsts.geom.util.GeometryCombiner.combine(disjointPolys);return overallUnion};jsts.operation.union.CascadedPolygonUnion.prototype.extractByEnvelope=function(env,geom,disjointGeoms){var intersectingGeoms=new javascript.util.ArrayList;for(var i=0;i<geom.getNumGeometries();i++){var elem=geom.getGeometryN(i);if(elem.getEnvelopeInternal().intersects(env)){intersectingGeoms.add(elem)}else{disjointGeoms.add(elem)}}return this.geomFactory.buildGeometry(intersectingGeoms)};jsts.operation.union.CascadedPolygonUnion.prototype.unionActual=function(g0,g1){return g0.union(g1)};(function(){jsts.geom.MultiPoint=function(points,factory){this.geometries=points||[];this.factory=factory};jsts.geom.MultiPoint.prototype=new jsts.geom.GeometryCollection;jsts.geom.MultiPoint.constructor=jsts.geom.MultiPoint;jsts.geom.MultiPoint.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)};jsts.geom.MultiPoint.prototype.getGeometryN=function(n){return this.geometries[n]};jsts.geom.MultiPoint.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}return jsts.geom.GeometryCollection.prototype.equalsExact.call(this,other,tolerance)};jsts.geom.MultiPoint.prototype.CLASS_NAME="jsts.geom.MultiPoint"})();jsts.operation.buffer.OffsetCurveBuilder=function(precisionModel,bufParams){this.precisionModel=precisionModel;this.bufParams=bufParams};jsts.operation.buffer.OffsetCurveBuilder.prototype.distance=0;jsts.operation.buffer.OffsetCurveBuilder.prototype.precisionModel=null;jsts.operation.buffer.OffsetCurveBuilder.prototype.bufParams=null;jsts.operation.buffer.OffsetCurveBuilder.prototype.getBufferParameters=function(){return this.bufParams};jsts.operation.buffer.OffsetCurveBuilder.prototype.getLineCurve=function(inputPts,distance){this.distance=distance;if(this.distance<0&&!this.bufParams.isSingleSided())return null;if(this.distance==0)return null;var posDistance=Math.abs(this.distance);var segGen=this.getSegGen(posDistance);if(inputPts.length<=1){this.computePointCurve(inputPts[0],segGen)}else{if(this.bufParams.isSingleSided()){var isRightSide=distance<0;this.computeSingleSidedBufferCurve(inputPts,isRightSide,segGen)}else this.computeLineBufferCurve(inputPts,segGen)}var lineCoord=segGen.getCoordinates();return lineCoord};jsts.operation.buffer.OffsetCurveBuilder.prototype.getRingCurve=function(inputPts,side,distance){this.distance=distance;if(inputPts.length<=2)return this.getLineCurve(inputPts,distance);if(this.distance==0){return jsts.operation.buffer.OffsetCurveBuilder.copyCoordinates(inputPts)}var segGen=this.getSegGen(this.distance);this.computeRingBufferCurve(inputPts,side,segGen);return segGen.getCoordinates()};jsts.operation.buffer.OffsetCurveBuilder.prototype.getOffsetCurve=function(inputPts,distance){this.distance=distance;if(this.distance===0)return null;var isRightSide=this.distance<0;var posDistance=Math.abs(this.distance);var segGen=this.getSegGen(posDistance);if(inputPts.length<=1){this.computePointCurve(inputPts[0],segGen)}else{this.computeOffsetCurve(inputPts,isRightSide,segGen)}var curvePts=segGen.getCoordinates();if(isRightSide)curvePts.reverse();return curvePts};jsts.operation.buffer.OffsetCurveBuilder.copyCoordinates=function(pts){var copy=[];for(var i=0;i<pts.length;i++){copy.push(pts[i].clone())}return copy};jsts.operation.buffer.OffsetCurveBuilder.prototype.getSegGen=function(distance){return new jsts.operation.buffer.OffsetSegmentGenerator(this.precisionModel,this.bufParams,distance)};jsts.operation.buffer.OffsetCurveBuilder.SIMPLIFY_FACTOR=100;jsts.operation.buffer.OffsetCurveBuilder.simplifyTolerance=function(bufDistance){return bufDistance/jsts.operation.buffer.OffsetCurveBuilder.SIMPLIFY_FACTOR};jsts.operation.buffer.OffsetCurveBuilder.prototype.computePointCurve=function(pt,segGen){switch(this.bufParams.getEndCapStyle()){case jsts.operation.buffer.BufferParameters.CAP_ROUND:segGen.createCircle(pt);break;case jsts.operation.buffer.BufferParameters.CAP_SQUARE:segGen.createSquare(pt);break}};jsts.operation.buffer.OffsetCurveBuilder.prototype.computeLineBufferCurve=function(inputPts,segGen){var distTol=jsts.operation.buffer.OffsetCurveBuilder.simplifyTolerance(this.distance);var simp1=jsts.operation.buffer.BufferInputLineSimplifier.simplify(inputPts,distTol);var n1=simp1.length-1;segGen.initSideSegments(simp1[0],simp1[1],jsts.geomgraph.Position.LEFT);for(var i=2;i<=n1;i++){segGen.addNextSegment(simp1[i],true)}segGen.addLastSegment();segGen.addLineEndCap(simp1[n1-1],simp1[n1]);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);for(var i=n2-2;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;i<il;i++){if(this.subnode[i]!==null){this.subnode[i].addAllItems(items)}}return items};NodeBase.prototype.addAllItemsFromOverlapping=function(interval,resultItems){if(interval!==null&&!this.isSearchMatch(interval)){return}resultItems.addAll(this.items);if(this.subnode[0]!==null){this.subnode[0].addAllItemsFromOverlapping(interval,resultItems)}if(this.subnode[1]!==null){this.subnode[1].addAllItemsFromOverlapping(interval,resultItems)}};NodeBase.prototype.remove=function(itemInterval,item){if(!this.isSearchMatch(itemInterval)){return false}var found=false,i=0,il=2;for(i;i<il;i++){if(this.subnode[i]!==null){found=this.subnode[i].remove(itemInterval,item);if(found){if(this.subnode[i].isPrunable()){this.subnode[i]=null}break}}}if(found){return found}found=this.items.remove(item);return found};NodeBase.prototype.isPrunable=function(){return!(this.hasChildren()||this.hasItems())};NodeBase.prototype.hasChildren=function(){var i=0,il=2;for(i;i<il;i++){if(this.subnode[i]!==null){return true}}return false};NodeBase.prototype.hasItems=function(){return!this.items.isEmpty()};NodeBase.prototype.depth=function(){var maxSubDepth=0,i=0,il=2,sqd;for(i;i<il;i++){if(this.subnode[i]!==null){sqd=this.subnode[i].depth();if(sqd>maxSubDepth){maxSubDepth=sqd}}}return maxSubDepth+1};NodeBase.prototype.size=function(){var subSize=0,i=0,il=2;for(i;i<il;i++){if(this.subnode[i]!==null){subSize+=this.subnode[i].size()}}return subSize+this.items.size()};NodeBase.prototype.nodeSize=function(){var subSize=0,i=0,il=2;for(i;i<il;i++){if(this.subnode[i]!==null){subSize+=this.subnode[i].nodeSize()}}return subSize+1};jsts.index.bintree.NodeBase=NodeBase})();(function(){var NodeBase=jsts.index.bintree.NodeBase;var Key=jsts.index.bintree.Key;var Interval=jsts.index.bintree.Interval;var Node=function(interval,level){this.items=new javascript.util.ArrayList;this.subnode=[null,null];this.interval=interval;this.level=level;this.centre=(interval.getMin()+interval.getMax())/2};Node.prototype=new NodeBase;Node.constructor=Node;Node.createNode=function(itemInterval){var key,node;key=new Key(itemInterval);node=new Node(key.getInterval(),key.getLevel());return node};Node.createExpanded=function(node,addInterval){var expandInt,largerNode;expandInt=new Interval(addInterval);if(node!==null){expandInt.expandToInclude(node.interval)}largerNode=Node.createNode(expandInt);if(node!==null){largerNode.insert(node)}return largerNode};Node.prototype.getInterval=function(){return this.interval};Node.prototype.isSearchMatch=function(itemInterval){return itemInterval.overlaps(this.interval)};Node.prototype.getNode=function(searchInterval){var subnodeIndex=NodeBase.getSubnodeIndex(searchInterval,this.centre),node;if(subnodeIndex!=-1){node=this.getSubnode(subnodeIndex);return node.getNode(searchInterval)}else{return this}};Node.prototype.find=function(searchInterval){var subnodeIndex=NodeBase.getSubnodeIndex(searchInterval,this.centre),node;if(subnodeIndex===-1){return this}if(this.subnode[subnodeIndex]!==null){node=this.subnode[subnodeIndex];return node.find(searchInterval)}return this};Node.prototype.insert=function(node){var index=NodeBase.getSubnodeIndex(node.interval,this.centre),childNode;if(node.level===this.level-1){this.subnode[index]=node}else{childNode=this.createSubnode(index);childNode.insert(node);this.subnode[index]=childNode}};Node.prototype.getSubnode=function(index){if(this.subnode[index]===null){this.subnode[index]=this.createSubnode(index)}return this.subnode[index]};Node.prototype.createSubnode=function(index){var min,max,subInt,node;min=0;max=0;switch(index){case 0:min=this.interval.getMin();max=this.centre;break;case 1:min=this.centre;max=this.interval.getMax();break}subInt=new Interval(min,max);node=new Node(subInt,this.level-1);return node};jsts.index.bintree.Node=Node})();(function(){var Node=jsts.index.bintree.Node;var NodeBase=jsts.index.bintree.NodeBase;var Root=function(){this.subnode=[null,null];this.items=new javascript.util.ArrayList};Root.prototype=new jsts.index.bintree.NodeBase;Root.constructor=Root;Root.origin=0;Root.prototype.insert=function(itemInterval,item){var index=NodeBase.getSubnodeIndex(itemInterval,Root.origin),node,largerNode;if(index===-1){this.add(item);return}node=this.subnode[index];if(node===null||!node.getInterval().contains(itemInterval)){largerNode=Node.createExpanded(node,itemInterval);this.subnode[index]=largerNode}this.insertContained(this.subnode[index],itemInterval,item)};Root.prototype.insertContained=function(tree,itemInterval,item){var isZeroArea,node;isZeroArea=jsts.index.IntervalSize.isZeroWidth(itemInterval.getMin(),itemInterval.getMax());node=isZeroArea?tree.find(itemInterval):tree.getNode(itemInterval);node.add(item)};Root.prototype.isSearchMatch=function(interval){return true};jsts.index.bintree.Root=Root})();jsts.geomgraph.Quadrant=function(){};jsts.geomgraph.Quadrant.NE=0;jsts.geomgraph.Quadrant.NW=1;jsts.geomgraph.Quadrant.SW=2;jsts.geomgraph.Quadrant.SE=3;jsts.geomgraph.Quadrant.quadrant=function(dx,dy){if(dx instanceof jsts.geom.Coordinate){return jsts.geomgraph.Quadrant.quadrant2.apply(this,arguments);
}if(dx===0&&dy===0)throw new jsts.error.IllegalArgumentError("Cannot compute the quadrant for point ( "+dx+", "+dy+" )");if(dx>=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=quad1<quad2?quad1:quad2;var max=quad1>quad2?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;i<locs.length;i++){var loc=locs[i];for(var j=0;j<polys.length;j++){this.computeContainmentDistance4(loc,polys[j],locPtPoly);if(this.minDistance<=this.terminateDistance)return}}};jsts.operation.distance.DistanceOp.prototype.computeContainmentDistance4=function(ptLoc,poly,locPtPoly){var pt=ptLoc.getCoordinate();if(jsts.geom.Location.EXTERIOR!==this.ptLocator.locate(pt,poly)){this.minDistance=0;locPtPoly[0]=ptLoc;locPtPoly[1]=new jsts.operation.distance.GeometryLocation(poly,pt);return}};jsts.operation.distance.DistanceOp.prototype.computeFacetDistance=function(){var locGeom=[];var lines0=jsts.geom.util.LinearComponentExtracter.getLines(this.geom[0]);var lines1=jsts.geom.util.LinearComponentExtracter.getLines(this.geom[1]);var pts0=jsts.geom.util.PointExtracter.getPoints(this.geom[0]);var pts1=jsts.geom.util.PointExtracter.getPoints(this.geom[1]);this.computeMinDistanceLines(lines0,lines1,locGeom);this.updateMinDistance(locGeom,false);if(this.minDistance<=this.terminateDistance)return;locGeom[0]=null;locGeom[1]=null;this.computeMinDistanceLinesPoints(lines0,pts1,locGeom);this.updateMinDistance(locGeom,false);if(this.minDistance<=this.terminateDistance)return;locGeom[0]=null;locGeom[1]=null;this.computeMinDistanceLinesPoints(lines1,pts0,locGeom);this.updateMinDistance(locGeom,true);if(this.minDistance<=this.terminateDistance)return;locGeom[0]=null;locGeom[1]=null;this.computeMinDistancePoints(pts0,pts1,locGeom);this.updateMinDistance(locGeom,false)};jsts.operation.distance.DistanceOp.prototype.computeMinDistanceLines=function(lines0,lines1,locGeom){for(var i=0;i<lines0.length;i++){var line0=lines0[i];for(var j=0;j<lines1.length;j++){var line1=lines1[j];this.computeMinDistance(line0,line1,locGeom);if(this.minDistance<=this.terminateDistance)return}}};jsts.operation.distance.DistanceOp.prototype.computeMinDistancePoints=function(points0,points1,locGeom){for(var i=0;i<points0.length;i++){var pt0=points0[i];for(var j=0;j<points1.length;j++){var pt1=points1[j];var dist=pt0.getCoordinate().distance(pt1.getCoordinate());if(dist<this.minDistance){this.minDistance=dist;locGeom[0]=new jsts.operation.distance.GeometryLocation(pt0,0,pt0.getCoordinate());locGeom[1]=new jsts.operation.distance.GeometryLocation(pt1,0,pt1.getCoordinate())}if(this.minDistance<=this.terminateDistance)return}}};jsts.operation.distance.DistanceOp.prototype.computeMinDistanceLinesPoints=function(lines,points,locGeom){for(var i=0;i<lines.length;i++){var line=lines[i];for(var j=0;j<points.length;j++){var pt=points[j];this.computeMinDistance(line,pt,locGeom);if(this.minDistance<=this.terminateDistance)return}}};jsts.operation.distance.DistanceOp.prototype.computeMinDistance2=function(line0,line1,locGeom){if(line1 instanceof jsts.geom.Point){this.computeMinDistance3(line0,line1,locGeom);return}if(line0.getEnvelopeInternal().distance(line1.getEnvelopeInternal())>this.minDistance){return}var coord0=line0.getCoordinates();var coord1=line1.getCoordinates();for(var i=0;i<coord0.length-1;i++){for(var j=0;j<coord1.length-1;j++){var dist=jsts.algorithm.CGAlgorithms.distanceLineLine(coord0[i],coord0[i+1],coord1[j],coord1[j+1]);if(dist<this.minDistance){this.minDistance=dist;var seg0=new jsts.geom.LineSegment(coord0[i],coord0[i+1]);var seg1=new jsts.geom.LineSegment(coord1[j],coord1[j+1]);var closestPt=seg0.closestPoints(seg1);locGeom[0]=new jsts.operation.distance.GeometryLocation(line0,i,closestPt[0]);locGeom[1]=new jsts.operation.distance.GeometryLocation(line1,j,closestPt[1])}if(this.minDistance<=this.terminateDistance){return}}}};jsts.operation.distance.DistanceOp.prototype.computeMinDistance3=function(line,pt,locGeom){if(line.getEnvelopeInternal().distance(pt.getEnvelopeInternal())>this.minDistance){return}var coord0=line.getCoordinates();var coord=pt.getCoordinate();for(var i=0;i<coord0.length-1;i++){var dist=jsts.algorithm.CGAlgorithms.distancePointLine(coord,coord0[i],coord0[i+1]);if(dist<this.minDistance){this.minDistance=dist;var seg=new jsts.geom.LineSegment(coord0[i],coord0[i+1]);var segClosestPoint=seg.closestPoint(coord);locGeom[0]=new jsts.operation.distance.GeometryLocation(line,i,segClosestPoint);locGeom[1]=new jsts.operation.distance.GeometryLocation(pt,0,coord)}if(this.minDistance<=this.terminateDistance){return}}};jsts.index.strtree.SIRtree=function(nodeCapacity){nodeCapacity=nodeCapacity||10;jsts.index.strtree.AbstractSTRtree.call(this,nodeCapacity)};jsts.index.strtree.SIRtree.prototype=new jsts.index.strtree.AbstractSTRtree;jsts.index.strtree.SIRtree.constructor=jsts.index.strtree.SIRtree;jsts.index.strtree.SIRtree.prototype.comperator={compare:function(o1,o2){return o1.getBounds().getCentre()-o2.getBounds().getCentre()}};jsts.index.strtree.SIRtree.prototype.intersectionOp={intersects:function(aBounds,bBounds){return aBounds.intersects(bBounds)}};jsts.index.strtree.SIRtree.prototype.createNode=function(level){var AbstractNode=function(level){jsts.index.strtree.AbstractNode.apply(this,arguments)};AbstractNode.prototype=new jsts.index.strtree.AbstractNode;AbstractNode.constructor=AbstractNode;AbstractNode.prototype.computeBounds=function(){var bounds=null,childBoundables=this.getChildBoundables(),childBoundable;for(var i=0,l=childBoundables.length;i<l;i++){childBoundable=childBoundables[i];if(bounds===null){bounds=new jsts.index.strtree.Interval(childBoundable.getBounds())}else{bounds.expandToInclude(childBoundable.getBounds())}}return bounds};return AbstractNode};jsts.index.strtree.SIRtree.prototype.insert=function(x1,x2,item){jsts.index.strtree.AbstractSTRtree.prototype.insert(new jsts.index.strtree.Interval(Math.min(x1,x2),Math.max(x1,x2)),item)};jsts.index.strtree.SIRtree.prototype.query=function(x1,x2){x2=x2||x1;jsts.index.strtree.AbstractSTRtree.prototype.query(new jsts.index.strtree.Interval(Math.min(x1,x2),Math.max(x1,x2)))};jsts.index.strtree.SIRtree.prototype.getIntersectsOp=function(){return this.intersectionOp};jsts.index.strtree.SIRtree.prototype.getComparator=function(){return this.comperator};jsts.simplify.DouglasPeuckerSimplifier=function(inputGeom){this.inputGeom=inputGeom;this.isEnsureValidTopology=true};jsts.simplify.DouglasPeuckerSimplifier.prototype.inputGeom=null;jsts.simplify.DouglasPeuckerSimplifier.prototype.distanceTolerance=null;jsts.simplify.DouglasPeuckerSimplifier.prototype.isEnsureValidTopology=null;jsts.simplify.DouglasPeuckerSimplifier.simplify=function(geom,distanceTolerance){var tss=new jsts.simplify.DouglasPeuckerSimplifier(geom);tss.setDistanceTolerance(distanceTolerance);return tss.getResultGeometry()};jsts.simplify.DouglasPeuckerSimplifier.prototype.setDistanceTolerance=function(distanceTolerance){if(distanceTolerance<0){throw"Tolerance must be non-negative"}this.distanceTolerance=distanceTolerance};jsts.simplify.DouglasPeuckerSimplifier.prototype.setEnsureValid=function(isEnsureValidTopology){this.isEnsureValidTopology=isEnsureValidTopology};jsts.simplify.DouglasPeuckerSimplifier.prototype.getResultGeometry=function(){if(this.inputGeom.isEmpty()){return this.inputGeom.clone()}return new jsts.simplify.DPTransformer(this.distanceTolerance,this.isEnsureValidTopology).transform(this.inputGeom)};(function(){jsts.operation.predicate.RectangleContains=function(rectangle){this.rectEnv=rectangle.getEnvelopeInternal()};jsts.operation.predicate.RectangleContains.contains=function(rectangle,b){var rc=new jsts.operation.predicate.RectangleContains(rectangle);return rc.contains(b)};jsts.operation.predicate.RectangleContains.prototype.rectEnv=null;jsts.operation.predicate.RectangleContains.prototype.contains=function(geom){if(!this.rectEnv.contains(geom.getEnvelopeInternal()))return false;if(this.isContainedInBoundary(geom))return false;return true};jsts.operation.predicate.RectangleContains.prototype.isContainedInBoundary=function(geom){if(geom instanceof jsts.geom.Polygon)return false;if(geom instanceof jsts.geom.Point)return this.isPointContainedInBoundary(geom.getCoordinate());if(geom instanceof jsts.geom.LineString)return this.isLineStringContainedInBoundary(geom);for(var i=0;i<geom.getNumGeometries();i++){var comp=geom.getGeometryN(i);if(!this.isContainedInBoundary(comp))return false}return true};jsts.operation.predicate.RectangleContains.prototype.isPointContainedInBoundary=function(pt){return pt.x==this.rectEnv.getMinX()||pt.x==this.rectEnv.getMaxX()||pt.y==this.rectEnv.getMinY()||pt.y==this.rectEnv.getMaxY()};jsts.operation.predicate.RectangleContains.prototype.isLineStringContainedInBoundary=function(line){var seq=line.getCoordinateSequence();for(var i=0;i<seq.length-1;i++){var p0=seq[i];var p1=seq[i+1];if(!this.isLineSegmentContainedInBoundary(p0,p1))return false}return true};jsts.operation.predicate.RectangleContains.prototype.isLineSegmentContainedInBoundary=function(p0,p1){if(p0.equals(p1))return this.isPointContainedInBoundary(p0);if(p0.x==p1.x){if(p0.x==this.rectEnv.getMinX()||p0.x==this.rectEnv.getMaxX())return true}else if(p0.y==p1.y){if(p0.y==this.rectEnv.getMinY()||p0.y==this.rectEnv.getMaxY())return true}return false}})();(function(){var Location=jsts.geom.Location;var Position=jsts.geomgraph.Position;jsts.geomgraph.Depth=function(){this.depth=[[],[]];for(var i=0;i<2;i++){for(var j=0;j<3;j++){this.depth[i][j]=jsts.geomgraph.Depth.NULL_VALUE}}};jsts.geomgraph.Depth.NULL_VALUE=-1;jsts.geomgraph.Depth.depthAtLocation=function(location){if(location===Location.EXTERIOR)return 0;if(location===Location.INTERIOR)return 1;return jsts.geomgraph.Depth.NULL_VALUE};jsts.geomgraph.Depth.prototype.depth=null;jsts.geomgraph.Depth.prototype.getDepth=function(geomIndex,posIndex){return this.depth[geomIndex][posIndex]};jsts.geomgraph.Depth.prototype.setDepth=function(geomIndex,posIndex,depthValue){this.depth[geomIndex][posIndex]=depthValue};jsts.geomgraph.Depth.prototype.getLocation=function(geomIndex,posIndex){if(this.depth[geomIndex][posIndex]<=0)return Location.EXTERIOR;return Location.INTERIOR};jsts.geomgraph.Depth.prototype.add=function(geomIndex,posIndex,location){if(location===Location.INTERIOR)this.depth[geomIndex][posIndex]++};jsts.geomgraph.Depth.prototype.isNull=function(){if(arguments.length>0){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)minDepth=this.depth[i][2];if(minDepth<0)minDepth=0;for(var j=1;j<3;j++){var newValue=0;if(this.depth[i][j]>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)};(function(){var Location=jsts.geom.Location;jsts.operation.relate.RelateNodeGraph=function(){this.nodes=new jsts.geomgraph.NodeMap(new jsts.operation.relate.RelateNodeFactory)};jsts.operation.relate.RelateNodeGraph.prototype.nodes=null;jsts.operation.relate.RelateNodeGraph.prototype.build=function(geomGraph){this.computeIntersectionNodes(geomGraph,0);this.copyNodesAndLabels(geomGraph,0);var eeBuilder=new jsts.operation.relate.EdgeEndBuilder;var eeList=eeBuilder.computeEdgeEnds(geomGraph.getEdgeIterator());this.insertEdgeEnds(eeList)};jsts.operation.relate.RelateNodeGraph.prototype.computeIntersectionNodes=function(geomGraph,argIndex){for(var edgeIt=geomGraph.getEdgeIterator();edgeIt.hasNext();){var e=edgeIt.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.RelateNodeGraph.prototype.copyNodesAndLabels=function(geomGraph,argIndex){for(var nodeIt=geomGraph.getNodeIterator();nodeIt.hasNext();){var graphNode=nodeIt.next();var newNode=this.nodes.addNode(graphNode.getCoordinate());newNode.setLabel(argIndex,graphNode.getLabel().getLocation(argIndex))}};jsts.operation.relate.RelateNodeGraph.prototype.insertEdgeEnds=function(ee){for(var i=ee.iterator();i.hasNext();){var e=i.next();this.nodes.add(e)}};jsts.operation.relate.RelateNodeGraph.prototype.getNodeIterator=function(){return this.nodes.iterator()}})();jsts.geomgraph.index.SimpleSweepLineIntersector=function(){};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype=new jsts.geomgraph.index.EdgeSetIntersector;jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.events=[];jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.nOverlaps=null;jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.computeIntersections=function(edges,si,testAllSegments){if(si instanceof javascript.util.List){this.computeIntersections2.apply(this,arguments);return}if(testAllSegments){this.add(edges,null)}else{this.add(edges)}this.computeIntersections3(si)};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.computeIntersections2=function(edges0,edges1,si){this.add(edges0,edges0);this.add(edges1,edges1);this.computeIntersections3(si)};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.add=function(edge,edgeSet){if(edge instanceof javascript.util.List){this.add2.apply(this,arguments);return}var pts=edge.getCoordinates();for(var i=0;i<pts.length-1;i++){var ss=new jsts.geomgraph.index.SweepLineSegment(edge,i);var insertEvent=new jsts.geomgraph.index.SweepLineEvent(ss.getMinX(),ss,edgeSet);this.events.push(insertEvent);this.events.push(new jsts.geomgraph.index.SweepLineEvent(ss.getMaxX(),insertEvent))}};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.add2=function(edges,edgeSet){for(var i=edges.iterator();i.hasNext();){var edge=i.next();if(edgeSet){this.add(edge,edgeSet)}else{this.add(edge,edge)}}};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.prepareEvents=function(){this.events.sort(function(a,b){return a.compareTo(b)});for(var i=0;i<this.events.length;i++){var ev=this.events[i];if(ev.isDelete()){ev.getInsertEvent().setDeleteEventIndex(i)}}};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.computeIntersections3=function(si){this.nOverlaps=0;this.prepareEvents();for(var i=0;i<this.events.length;i++){var ev=this.events[i];if(ev.isInsert()){this.processOverlaps(i,ev.getDeleteEventIndex(),ev,si)}}};jsts.geomgraph.index.SimpleSweepLineIntersector.prototype.processOverlaps=function(start,end,ev0,si){var ss0=ev0.getObject();for(var i=start;i<end;i++){var ev1=this.events[i];if(ev1.isInsert()){var ss1=ev1.getObject();if(!ev0.isSameLabel(ev1)){ss0.computeIntersections(ss1,si);this.nOverlaps++}}}};jsts.triangulate.VoronoiDiagramBuilder=function(){this.siteCoords=null;this.tolerance=0;this.subdiv=null;this.clipEnv=null;this.diagramEnv=null};jsts.triangulate.VoronoiDiagramBuilder.prototype.setSites=function(){var arg=arguments[0];if(arg instanceof jsts.geom.Geometry||arg instanceof jsts.geom.Coordinate||arg instanceof jsts.geom.Point||arg instanceof jsts.geom.MultiPoint||arg instanceof jsts.geom.LineString||arg instanceof jsts.geom.MultiLineString||arg instanceof jsts.geom.LinearRing||arg instanceof jsts.geom.Polygon||arg instanceof jsts.geom.MultiPolygon){this.setSitesByGeometry(arg)}else{this.setSitesByArray(arg)}};jsts.triangulate.VoronoiDiagramBuilder.prototype.setSitesByGeometry=function(geom){this.siteCoords=jsts.triangulate.DelaunayTriangulationBuilder.extractUniqueCoordinates(geom)};jsts.triangulate.VoronoiDiagramBuilder.prototype.setSitesByArray=function(coords){this.siteCoords=jsts.triangulate.DelaunayTriangulationBuilder.unique(coords)};jsts.triangulate.VoronoiDiagramBuilder.prototype.setClipEnvelope=function(clipEnv){this.clipEnv=clipEnv};jsts.triangulate.VoronoiDiagramBuilder.prototype.setTolerance=function(tolerance){this.tolerance=tolerance};jsts.triangulate.VoronoiDiagramBuilder.prototype.create=function(){if(this.subdiv!==null){return}var siteEnv,expandBy,vertices,triangulator;siteEnv=jsts.triangulate.DelaunayTriangulationBuilder.envelope(this.siteCoords);this.diagramEnv=siteEnv;expandBy=Math.max(this.diagramEnv.getWidth(),this.diagramEnv.getHeight());this.diagramEnv.expandBy(expandBy);if(this.clipEnv!==null){this.diagramEnv.expandToInclude(this.clipEnv)}vertices=jsts.triangulate.DelaunayTriangulationBuilder.toVertices(this.siteCoords);this.subdiv=new jsts.triangulate.quadedge.QuadEdgeSubdivision(siteEnv,this.tolerance);triangulator=new jsts.triangulate.IncrementalDelaunayTriangulator(this.subdiv);triangulator.insertSites(vertices)};jsts.triangulate.VoronoiDiagramBuilder.prototype.getSubdivision=function(){this.create();return this.subdiv};jsts.triangulate.VoronoiDiagramBuilder.prototype.getDiagram=function(geomFact){this.create();var polys=this.subdiv.getVoronoiDiagram(geomFact);return this.clipGeometryCollection(polys,this.diagramEnv)};jsts.triangulate.VoronoiDiagramBuilder.prototype.clipGeometryCollection=function(geom,clipEnv){var clipPoly,clipped,i,il,g,result;clipPoly=geom.getFactory().toGeometry(clipEnv);clipped=[];i=0,il=geom.getNumGeometries();for(i;i<il;i++){g=geom.getGeometryN(i);result=null;if(clipEnv.contains(g.getEnvelopeInternal())){result=g}else if(clipEnv.intersects(g.getEnvelopeInternal())){result=clipPoly.intersection(g)}if(result!==null&&!result.isEmpty()){clipped.push(result)}}return geom.getFactory().createGeometryCollection(clipped)};jsts.operation.valid.IndexedNestedRingTester=function(graph){this.graph=graph;this.rings=new javascript.util.ArrayList;this.totalEnv=new jsts.geom.Envelope;this.index=null;this.nestedPt=null};jsts.operation.valid.IndexedNestedRingTester.prototype.getNestedPoint=function(){return this.nestedPt};jsts.operation.valid.IndexedNestedRingTester.prototype.add=function(ring){this.rings.add(ring);this.totalEnv.expandToInclude(ring.getEnvelopeInternal())};jsts.operation.valid.IndexedNestedRingTester.prototype.isNonNested=function(){
this.buildIndex();for(var i=0;i<this.rings.size();i++){var innerRing=this.rings.get(i);var innerRingPts=innerRing.getCoordinates();var results=this.index.query(innerRing.getEnvelopeInternal());for(var j=0;j<results.length;j++){var searchRing=results[j];var searchRingPts=searchRing.getCoordinates();if(innerRing==searchRing){continue}if(!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())){continue}var innerRingPt=jsts.operation.valid.IsValidOp.findPtNotNode(innerRingPts,searchRing,this.graph);if(innerRingPt==null){continue}var isInside=jsts.algorithm.CGAlgorithms.isPointInRing(innerRingPt,searchRingPts);if(isInside){this.nestedPt=innerRingPt;return false}}}return true};jsts.operation.valid.IndexedNestedRingTester.prototype.buildIndex=function(){this.index=new jsts.index.strtree.STRtree;for(var i=0;i<this.rings.size();i++){var ring=this.rings.get(i);var env=ring.getEnvelopeInternal();this.index.insert(env,ring)}};jsts.geomgraph.index.MonotoneChain=function(mce,chainIndex){this.mce=mce;this.chainIndex=chainIndex};jsts.geomgraph.index.MonotoneChain.prototype.mce=null;jsts.geomgraph.index.MonotoneChain.prototype.chainIndex=null;jsts.geomgraph.index.MonotoneChain.prototype.computeIntersections=function(mc,si){this.mce.computeIntersectsForChain(this.chainIndex,mc.mce,mc.chainIndex,si)};jsts.noding.SegmentNode=function(segString,coord,segmentIndex,segmentOctant){this.segString=segString;this.coord=new jsts.geom.Coordinate(coord);this.segmentIndex=segmentIndex;this.segmentOctant=segmentOctant;this._isInterior=!coord.equals2D(segString.getCoordinate(segmentIndex))};jsts.noding.SegmentNode.prototype.segString=null;jsts.noding.SegmentNode.prototype.coord=null;jsts.noding.SegmentNode.prototype.segmentIndex=null;jsts.noding.SegmentNode.prototype.segmentOctant=null;jsts.noding.SegmentNode.prototype._isInterior=null;jsts.noding.SegmentNode.prototype.getCoordinate=function(){return this.coord};jsts.noding.SegmentNode.prototype.isInterior=function(){return this._isInterior};jsts.noding.SegmentNode.prototype.isEndPoint=function(maxSegmentIndex){if(this.segmentIndex===0&&!this._isInterior)return true;if(this.segmentIndex===this.maxSegmentIndex)return true;return false};jsts.noding.SegmentNode.prototype.compareTo=function(obj){var other=obj;if(this.segmentIndex<other.segmentIndex)return-1;if(this.segmentIndex>other.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;i<lineString.components.length;i++){coordinates.push(new jsts.geom.Coordinate(lineString.components[i].x,lineString.components[i].y))}return this.geometryFactory.createLineString(coordinates)};jsts.io.OpenLayersParser.prototype.convertFromLinearRing=function(linearRing){var i;var coordinates=[];for(i=0;i<linearRing.components.length;i++){coordinates.push(new jsts.geom.Coordinate(linearRing.components[i].x,linearRing.components[i].y))}return this.geometryFactory.createLinearRing(coordinates)};jsts.io.OpenLayersParser.prototype.convertFromPolygon=function(polygon){var i;var shell=null;var holes=[];for(i=0;i<polygon.components.length;i++){var linearRing=this.convertFromLinearRing(polygon.components[i]);if(i===0){shell=linearRing}else{holes.push(linearRing)}}return this.geometryFactory.createPolygon(shell,holes)};jsts.io.OpenLayersParser.prototype.convertFromMultiPoint=function(multiPoint){var i;var points=[];for(i=0;i<multiPoint.components.length;i++){points.push(this.convertFromPoint(multiPoint.components[i]))}return this.geometryFactory.createMultiPoint(points)};jsts.io.OpenLayersParser.prototype.convertFromMultiLineString=function(multiLineString){var i;var lineStrings=[];for(i=0;i<multiLineString.components.length;i++){lineStrings.push(this.convertFromLineString(multiLineString.components[i]))}return this.geometryFactory.createMultiLineString(lineStrings)};jsts.io.OpenLayersParser.prototype.convertFromMultiPolygon=function(multiPolygon){var i;var polygons=[];for(i=0;i<multiPolygon.components.length;i++){polygons.push(this.convertFromPolygon(multiPolygon.components[i]))}return this.geometryFactory.createMultiPolygon(polygons)};jsts.io.OpenLayersParser.prototype.convertFromCollection=function(collection){var i;var geometries=[];for(i=0;i<collection.components.length;i++){geometries.push(this.read(collection.components[i]))}return this.geometryFactory.createGeometryCollection(geometries)};jsts.io.OpenLayersParser.prototype.write=function(geometry){if(geometry.CLASS_NAME==="jsts.geom.Point"){return this.convertToPoint(geometry.coordinate)}else if(geometry.CLASS_NAME==="jsts.geom.LineString"){return this.convertToLineString(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.LinearRing"){return this.convertToLinearRing(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.Polygon"){return this.convertToPolygon(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.MultiPoint"){return this.convertToMultiPoint(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.MultiLineString"){return this.convertToMultiLineString(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.MultiPolygon"){return this.convertToMultiPolygon(geometry)}else if(geometry.CLASS_NAME==="jsts.geom.GeometryCollection"){return this.convertToCollection(geometry)}};jsts.io.OpenLayersParser.prototype.convertToPoint=function(coordinate){return new OpenLayers.Geometry.Point(coordinate.x,coordinate.y)};jsts.io.OpenLayersParser.prototype.convertToLineString=function(lineString){var i;var points=[];for(i=0;i<lineString.points.length;i++){var coordinate=lineString.points[i];points.push(this.convertToPoint(coordinate))}return new OpenLayers.Geometry.LineString(points)};jsts.io.OpenLayersParser.prototype.convertToLinearRing=function(linearRing){var i;var points=[];for(i=0;i<linearRing.points.length;i++){var coordinate=linearRing.points[i];points.push(this.convertToPoint(coordinate))}return new OpenLayers.Geometry.LinearRing(points)};jsts.io.OpenLayersParser.prototype.convertToPolygon=function(polygon){var i;var rings=[];rings.push(this.convertToLinearRing(polygon.shell));for(i=0;i<polygon.holes.length;i++){var ring=polygon.holes[i];rings.push(this.convertToLinearRing(ring))}return new OpenLayers.Geometry.Polygon(rings)};jsts.io.OpenLayersParser.prototype.convertToMultiPoint=function(multiPoint){var i;var points=[];for(i=0;i<multiPoint.geometries.length;i++){var coordinate=multiPoint.geometries[i].coordinate;points.push(new OpenLayers.Geometry.Point(coordinate.x,coordinate.y))}return new OpenLayers.Geometry.MultiPoint(points)};jsts.io.OpenLayersParser.prototype.convertToMultiLineString=function(multiLineString){var i;var lineStrings=[];for(i=0;i<multiLineString.geometries.length;i++){lineStrings.push(this.convertToLineString(multiLineString.geometries[i]))}return new OpenLayers.Geometry.MultiLineString(lineStrings)};jsts.io.OpenLayersParser.prototype.convertToMultiPolygon=function(multiPolygon){var i;var polygons=[];for(i=0;i<multiPolygon.geometries.length;i++){polygons.push(this.convertToPolygon(multiPolygon.geometries[i]))}return new OpenLayers.Geometry.MultiPolygon(polygons)};jsts.io.OpenLayersParser.prototype.convertToCollection=function(geometryCollection){var i;var geometries=[];for(i=0;i<geometryCollection.geometries.length;i++){var geometry=geometryCollection.geometries[i];var geometryOpenLayers=this.write(geometry);geometries.push(geometryOpenLayers)}return new OpenLayers.Geometry.Collection(geometries)};jsts.index.quadtree.Quadtree=function(){this.root=new jsts.index.quadtree.Root;this.minExtent=1};jsts.index.quadtree.Quadtree.ensureExtent=function(itemEnv,minExtent){var minx,maxx,miny,maxy;minx=itemEnv.getMinX();maxx=itemEnv.getMaxX();miny=itemEnv.getMinY();maxy=itemEnv.getMaxY();if(minx!==maxx&&miny!==maxy){return itemEnv}if(minx===maxx){minx=minx-minExtent/2;maxx=minx+minExtent/2}if(miny===maxy){miny=miny-minExtent/2;maxy=miny+minExtent/2}return new jsts.geom.Envelope(minx,maxx,miny,maxy)};jsts.index.quadtree.Quadtree.prototype.depth=function(){return this.root.depth()};jsts.index.quadtree.Quadtree.prototype.size=function(){return this.root.size()};jsts.index.quadtree.Quadtree.prototype.insert=function(itemEnv,item){this.collectStats(itemEnv);var insertEnv=jsts.index.quadtree.Quadtree.ensureExtent(itemEnv,this.minExtent);this.root.insert(insertEnv,item)};jsts.index.quadtree.Quadtree.prototype.remove=function(itemEnv,item){var posEnv=jsts.index.quadtree.Quadtree.ensureExtent(itemEnv,this.minExtent);return this.root.remove(posEnv,item)};jsts.index.quadtree.Quadtree.prototype.query=function(){if(arguments.length===1){return jsts.index.quadtree.Quadtree.prototype.queryByEnvelope.apply(this,arguments)}else{jsts.index.quadtree.Quadtree.prototype.queryWithVisitor.apply(this,arguments)}};jsts.index.quadtree.Quadtree.prototype.queryByEnvelope=function(searchEnv){var visitor=new jsts.index.ArrayListVisitor;this.query(searchEnv,visitor);return visitor.getItems()};jsts.index.quadtree.Quadtree.prototype.queryWithVisitor=function(searchEnv,visitor){this.root.visit(searchEnv,visitor)};jsts.index.quadtree.Quadtree.prototype.queryAll=function(){var foundItems=[];foundItems=this.root.addAllItems(foundItems);return foundItems};jsts.index.quadtree.Quadtree.prototype.collectStats=function(itemEnv){var delX=itemEnv.getWidth();if(delX<this.minExtent&&delX>0){this.minExtent=delX}var delY=itemEnv.getHeight();if(delY<this.minExtent&&delY>0){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.copyDeep=function(){if(arguments.length===1){return jsts.geom.CoordinateArrays.copyDeep1(arguments[0])}else if(arguments.length===5){jsts.geom.CoordinateArrays.copyDeep2(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}};jsts.geom.CoordinateArrays.copyDeep1=function(coordinates){var copy=[];for(var i=0;i<coordinates.length;i++){copy[i]=new jsts.geom.Coordinate(coordinates[i])}return copy};jsts.geom.CoordinateArrays.copyDeep2=function(src,srcStart,dest,destStart,length){for(var i=0;i<length;i++){dest[destStart+i]=new jsts.geom.Coordinate(src[srcStart+i])}};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;i<coord.length;i++){if(coord[i-1].equals(coord[i])){return true}}return false};jsts.geom.CoordinateArrays.ptNotInList=function(testPts,pts){for(var i=0;i<testPts.length;i++){var testPt=testPts[i];if(jsts.geom.CoordinateArrays.indexOf(testPt,pts)<0)return testPt}return null};jsts.geom.CoordinateArrays.increasingDirection=function(pts){for(var i=0;i<parseInt(pts.length/2);i++){var j=pts.length-1-i;var comp=pts[i].compareTo(pts[j]);if(comp!=0)return comp}return 1};jsts.geom.CoordinateArrays.minCoordinate=function(coordinates){var minCoord=null;for(var i=0;i<coordinates.length;i++){if(minCoord===null||minCoord.compareTo(coordinates[i])>0){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;i<newCoordinates.length;i++){coordinates[i]=newCoordinates[i]}};jsts.geom.CoordinateArrays.indexOf=function(coordinate,coordinates){for(var i=0;i<coordinates.length;i++){if(coordinate.equals(coordinates[i])){return i}}return-1};jsts.operation.overlay.MinimalEdgeRing=function(start,geometryFactory){jsts.geomgraph.EdgeRing.call(this,start,geometryFactory)};jsts.operation.overlay.MinimalEdgeRing.prototype=new jsts.geomgraph.EdgeRing;jsts.operation.overlay.MinimalEdgeRing.constructor=jsts.operation.overlay.MinimalEdgeRing;jsts.operation.overlay.MinimalEdgeRing.prototype.getNext=function(de){return de.getNextMin()};jsts.operation.overlay.MinimalEdgeRing.prototype.setEdgeRing=function(de,er){de.setMinEdgeRing(er)};jsts.triangulate.DelaunayTriangulationBuilder=function(){this.siteCoords=null;this.tolerance=0;this.subdiv=null};jsts.triangulate.DelaunayTriangulationBuilder.extractUniqueCoordinates=function(geom){if(geom===undefined||geom===null){return new jsts.geom.CoordinateList([],false).toArray()}var coords=geom.getCoordinates();return jsts.triangulate.DelaunayTriangulationBuilder.unique(coords)};jsts.triangulate.DelaunayTriangulationBuilder.unique=function(coords){coords.sort(function(a,b){return a.compareTo(b)});var coordList=new jsts.geom.CoordinateList(coords,false);return coordList.toArray()};jsts.triangulate.DelaunayTriangulationBuilder.toVertices=function(coords){var verts=new Array(coords.length),i=0,il=coords.length,coord;for(i;i<il;i++){coord=coords[i];verts[i]=new jsts.triangulate.quadedge.Vertex(coord)}return verts};jsts.triangulate.DelaunayTriangulationBuilder.envelope=function(coords){var env=new jsts.geom.Envelope,i=0,il=coords.length;for(i;i<il;i++){env.expandToInclude(coords[i])}return env};jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSites=function(){var arg=arguments[0];if(arg instanceof jsts.geom.Geometry||arg instanceof jsts.geom.Coordinate||arg instanceof jsts.geom.Point||arg instanceof jsts.geom.MultiPoint||arg instanceof jsts.geom.LineString||arg instanceof jsts.geom.MultiLineString||arg instanceof jsts.geom.LinearRing||arg instanceof jsts.geom.Polygon||arg instanceof jsts.geom.MultiPolygon){this.setSitesFromGeometry(arg)}else{this.setSitesFromCollection(arg)}};jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSitesFromGeometry=function(geom){this.siteCoords=jsts.triangulate.DelaunayTriangulationBuilder.extractUniqueCoordinates(geom)};jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSitesFromCollection=function(coords){this.siteCoords=jsts.triangulate.DelaunayTriangulationBuilder.unique(coords)};jsts.triangulate.DelaunayTriangulationBuilder.prototype.setTolerance=function(tolerance){this.tolerance=tolerance};jsts.triangulate.DelaunayTriangulationBuilder.prototype.create=function(){if(this.subdiv===null){var siteEnv,vertices,triangulator;siteEnv=jsts.triangulate.DelaunayTriangulationBuilder.envelope(this.siteCoords);vertices=jsts.triangulate.DelaunayTriangulationBuilder.toVertices(this.siteCoords);this.subdiv=new jsts.triangulate.quadedge.QuadEdgeSubdivision(siteEnv,this.tolerance);triangulator=new jsts.triangulate.IncrementalDelaunayTriangulator(this.subdiv);triangulator.insertSites(vertices)}};jsts.triangulate.DelaunayTriangulationBuilder.prototype.getSubdivision=function(){this.create();return this.subdiv};jsts.triangulate.DelaunayTriangulationBuilder.prototype.getEdges=function(geomFact){this.create();return this.subdiv.getEdges(geomFact)};jsts.triangulate.DelaunayTriangulationBuilder.prototype.getTriangles=function(geomFact){this.create();return this.subdiv.getTriangles(geomFact)};jsts.algorithm.RayCrossingCounter=function(p){this.p=p};jsts.algorithm.RayCrossingCounter.locatePointInRing=function(p,ring){var counter=new jsts.algorithm.RayCrossingCounter(p);for(var i=1;i<ring.length;i++){var p1=ring[i];var p2=ring[i-1];counter.countSegment(p1,p2);if(counter.isOnSegment())return counter.getLocation()}return counter.getLocation()};jsts.algorithm.RayCrossingCounter.prototype.p=null;jsts.algorithm.RayCrossingCounter.prototype.crossingCount=0;jsts.algorithm.RayCrossingCounter.prototype.isPointOnSegment=false;jsts.algorithm.RayCrossingCounter.prototype.countSegment=function(p1,p2){if(p1.x<this.p.x&&p2.x<this.p.x)return;if(this.p.x==p2.x&&this.p.y===p2.y){this.isPointOnSegment=true;return}if(p1.y===this.p.y&&p2.y===this.p.y){var minx=p1.x;var maxx=p2.x;if(minx>maxx){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(y2<y1)xIntSign=-xIntSign;if(xIntSign>0){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;i<mLine.getNumGeometries();i++){line=mLine.getGeometryN(i);if(line.getNumPoints()==0)continue;this.addEndpoint(line.getCoordinateN(0));this.addEndpoint(line.getCoordinateN(line.getNumPoints()-1))}for(i=0;i<this.endpoints.length;i++){endpoint=this.endpoints[i];if(this.bnRule.isInBoundary(endpoint.count)){bdyPts.push(endpoint.coordinate)}}return bdyPts};jsts.operation.BoundaryOp.prototype.addEndpoint=function(pt){var i,endpoint,found=false;for(i=0;i<this.endpoints.length;i++){endpoint=this.endpoints[i];if(endpoint.coordinate.equals(pt)){found=true;break}}if(!found){endpoint={};endpoint.coordinate=pt;endpoint.count=0;this.endpoints.push(endpoint)}endpoint.count++};jsts.operation.BoundaryOp.prototype.boundaryLineString=function(line){if(this.geom.isEmpty()){return this.getEmptyMultiPoint()}if(line.isClosed()){var closedEndpointOnBoundary=this.bnRule.isInBoundary(2);if(closedEndpointOnBoundary){return line.getStartPoint()}else{return this.geomFact.createMultiPoint(null)}}return this.geomFact.createMultiPoint([line.getStartPoint(),line.getEndPoint()])};jsts.operation.buffer.OffsetCurveSetBuilder=function(inputGeom,distance,curveBuilder){this.inputGeom=inputGeom;this.distance=distance;this.curveBuilder=curveBuilder;this.curveList=new javascript.util.ArrayList};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.inputGeom=null;jsts.operation.buffer.OffsetCurveSetBuilder.prototype.distance=null;jsts.operation.buffer.OffsetCurveSetBuilder.prototype.curveBuilder=null;jsts.operation.buffer.OffsetCurveSetBuilder.prototype.curveList=null;jsts.operation.buffer.OffsetCurveSetBuilder.prototype.getCurves=function(){this.add(this.inputGeom);return this.curveList};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addCurve=function(coord,leftLoc,rightLoc){if(coord==null||coord.length<2)return;var e=new jsts.noding.NodedSegmentString(coord,new jsts.geomgraph.Label(0,jsts.geom.Location.BOUNDARY,leftLoc,rightLoc));this.curveList.add(e)};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.add=function(g){if(g.isEmpty())return;if(g instanceof jsts.geom.Polygon)this.addPolygon(g);else if(g instanceof jsts.geom.LineString)this.addLineString(g);else if(g instanceof jsts.geom.Point)this.addPoint(g);else if(g instanceof jsts.geom.MultiPoint)this.addCollection(g);else if(g instanceof jsts.geom.MultiLineString)this.addCollection(g);else if(g instanceof jsts.geom.MultiPolygon)this.addCollection(g);else if(g instanceof jsts.geom.GeometryCollection)this.addCollection(g);else throw new jsts.error.IllegalArgumentError};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addCollection=function(gc){for(var i=0;i<gc.getNumGeometries();i++){var g=gc.getGeometryN(i);this.add(g)}};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addPoint=function(p){if(this.distance<=0)return;var coord=p.getCoordinates();var curve=this.curveBuilder.getLineCurve(coord,this.distance);this.addCurve(curve,jsts.geom.Location.EXTERIOR,jsts.geom.Location.INTERIOR)};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addLineString=function(line){if(this.distance<=0&&!this.curveBuilder.getBufferParameters().isSingleSided())return;var coord=jsts.geom.CoordinateArrays.removeRepeatedPoints(line.getCoordinates());var curve=this.curveBuilder.getLineCurve(coord,this.distance);this.addCurve(curve,jsts.geom.Location.EXTERIOR,jsts.geom.Location.INTERIOR)};jsts.operation.buffer.OffsetCurveSetBuilder.prototype.addPolygon=function(p){var offsetDistance=this.distance;var offsetSide=jsts.geomgraph.Position.LEFT;if(this.distance<0){offsetDistance=-this.distance;offsetSide=jsts.geomgraph.Position.RIGHT}var shell=p.getExteriorRing();var shellCoord=jsts.geom.CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());if(this.distance<0&&this.isErodedCompletely(shell,this.distance))return;if(this.distance<=0&&shellCoord.length<3)return;this.addPolygonRing(shellCoord,offsetDistance,offsetSide,jsts.geom.Location.EXTERIOR,jsts.geom.Location.INTERIOR);for(var i=0;i<p.getNumInteriorRing();i++){var hole=p.getInteriorRingN(i);var holeCoord=jsts.geom.CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());if(this.distance>0&&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)return;var leftLoc=cwLeftLoc;var rightLoc=cwRightLoc;if(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<Math.abs(bufferDistance)};jsts.operation.buffer.BufferSubgraph=function(){this.dirEdgeList=new javascript.util.ArrayList;this.nodes=new javascript.util.ArrayList;this.finder=new jsts.operation.buffer.RightmostEdgeFinder};jsts.operation.buffer.BufferSubgraph.prototype.finder=null;jsts.operation.buffer.BufferSubgraph.prototype.dirEdgeList=null;jsts.operation.buffer.BufferSubgraph.prototype.nodes=null;jsts.operation.buffer.BufferSubgraph.prototype.rightMostCoord=null;jsts.operation.buffer.BufferSubgraph.prototype.env=null;jsts.operation.buffer.BufferSubgraph.prototype.getDirectedEdges=function(){return this.dirEdgeList};jsts.operation.buffer.BufferSubgraph.prototype.getNodes=function(){return this.nodes};jsts.operation.buffer.BufferSubgraph.prototype.getEnvelope=function(){if(this.env===null){var edgeEnv=new jsts.geom.Envelope;for(var it=this.dirEdgeList.iterator();it.hasNext();){var dirEdge=it.next();var pts=dirEdge.getEdge().getCoordinates();for(var j=0;j<pts.length-1;j++){edgeEnv.expandToInclude(pts[j])}}this.env=edgeEnv}return this.env};jsts.operation.buffer.BufferSubgraph.prototype.getRightmostCoordinate=function(){return this.rightMostCoord};jsts.operation.buffer.BufferSubgraph.prototype.create=function(node){this.addReachable(node);this.finder.findEdge(this.dirEdgeList);this.rightMostCoord=this.finder.getCoordinate()};jsts.operation.buffer.BufferSubgraph.prototype.addReachable=function(startNode){var nodeStack=[];nodeStack.push(startNode);while(nodeStack.length!==0){var node=nodeStack.pop();this.add(node,nodeStack)}};jsts.operation.buffer.BufferSubgraph.prototype.add=function(node,nodeStack){node.setVisited(true);this.nodes.add(node);for(var i=node.getEdges().iterator();i.hasNext();){var de=i.next();this.dirEdgeList.add(de);var sym=de.getSym();var symNode=sym.getNode();if(!symNode.isVisited())nodeStack.push(symNode)}};jsts.operation.buffer.BufferSubgraph.prototype.clearVisitedEdges=function(){for(var it=this.dirEdgeList.iterator();it.hasNext();){var de=it.next();de.setVisited(false)}};jsts.operation.buffer.BufferSubgraph.prototype.computeDepth=function(outsideDepth){this.clearVisitedEdges();var de=this.finder.getEdge();var n=de.getNode();var label=de.getLabel();de.setEdgeDepths(jsts.geomgraph.Position.RIGHT,outsideDepth);this.copySymDepths(de);this.computeDepths(de)};jsts.operation.buffer.BufferSubgraph.prototype.computeDepths=function(startEdge){var nodesVisited=[];var nodeQueue=[];var startNode=startEdge.getNode();nodeQueue.push(startNode);nodesVisited.push(startNode);startEdge.setVisited(true);while(nodeQueue.length!==0){var n=nodeQueue.shift();nodesVisited.push(n);this.computeNodeDepth(n);for(var i=n.getEdges().iterator();i.hasNext();){var de=i.next();var sym=de.getSym();if(sym.isVisited())continue;var adjNode=sym.getNode();if(nodesVisited.indexOf(adjNode)===-1){nodeQueue.push(adjNode);nodesVisited.push(adjNode)}}}};jsts.operation.buffer.BufferSubgraph.prototype.computeNodeDepth=function(n){var startEdge=null;for(var i=n.getEdges().iterator();i.hasNext();){var de=i.next();if(de.isVisited()||de.getSym().isVisited()){startEdge=de;break}}if(startEdge==null)throw new jsts.error.TopologyError("unable to find edge to compute depths at "+n.getCoordinate());n.getEdges().computeDepths(startEdge);for(var i=n.getEdges().iterator();i.hasNext();){var de=i.next();de.setVisited(true);this.copySymDepths(de)}};jsts.operation.buffer.BufferSubgraph.prototype.copySymDepths=function(de){var sym=de.getSym();sym.setDepth(jsts.geomgraph.Position.LEFT,de.getDepth(jsts.geomgraph.Position.RIGHT));sym.setDepth(jsts.geomgraph.Position.RIGHT,de.getDepth(jsts.geomgraph.Position.LEFT))};jsts.operation.buffer.BufferSubgraph.prototype.findResultEdges=function(){for(var it=this.dirEdgeList.iterator();it.hasNext();){var de=it.next();if(de.getDepth(jsts.geomgraph.Position.RIGHT)>=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.x<graph.rightMostCoord.x){return-1}if(this.rightMostCoord.x>graph.rightMostCoord.x){return 1}return 0};jsts.simplify.DPTransformer=function(distanceTolerance,isEnsureValidTopology){this.distanceTolerance=distanceTolerance;this.isEnsureValidTopology=isEnsureValidTopology};jsts.simplify.DPTransformer.prototype=new jsts.geom.util.GeometryTransformer;jsts.simplify.DPTransformer.prototype.distanceTolerance=null;jsts.simplify.DPTransformer.prototype.isEnsureValidTopology=null;jsts.simplify.DPTransformer.prototype.transformCoordinates=function(coords,parent){var inputPts=coords;var newPts=null;if(inputPts.length==0){newPts=[]}else{newPts=jsts.simplify.DouglasPeuckerLineSimplifier.simplify(inputPts,this.distanceTolerance)}return newPts};jsts.simplify.DPTransformer.prototype.transformPolygon=function(geom,parent){if(geom.isEmpty()){return null}var rawGeom=jsts.geom.util.GeometryTransformer.prototype.transformPolygon.apply(this,arguments);if(parent instanceof jsts.geom.MultiPolygon){return rawGeom}return this.createValidArea(rawGeom)};jsts.simplify.DPTransformer.prototype.transformLinearRing=function(geom,parent){var removeDegenerateRings=parent instanceof jsts.geom.Polygon;
var simpResult=jsts.geom.util.GeometryTransformer.prototype.transformLinearRing.apply(this,arguments);if(removeDegenerateRings&&!(simpResult instanceof jsts.geom.LinearRing)){return null}return simpResult};jsts.simplify.DPTransformer.prototype.transformMultiPolygon=function(geom,parent){var rawGeom=jsts.geom.util.GeometryTransformer.prototype.transformMultiPolygon.apply(this,arguments);return this.createValidArea(rawGeom)};jsts.simplify.DPTransformer.prototype.createValidArea=function(rawAreaGeom){if(this.isEnsureValidTopology){return rawAreaGeom.buffer(0)}return rawAreaGeom};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;i<geometry.getNumGeometries();i++){this.add(geometry.getGeometryN(i))}}};jsts.algorithm.InteriorPointPoint.prototype.addPoint=function(point){var dist=point.distance(this.centroid);if(dist<this.minDistance){this.interiorPoint=new jsts.geom.Coordinate(point);this.minDistance=dist}};jsts.algorithm.InteriorPointPoint.prototype.getInteriorPoint=function(){return this.interiorPoint};(function(){jsts.geom.MultiLineString=function(geometries,factory){this.geometries=geometries||[];this.factory=factory};jsts.geom.MultiLineString.prototype=new jsts.geom.GeometryCollection;jsts.geom.MultiLineString.constructor=jsts.geom.MultiLineString;jsts.geom.MultiLineString.prototype.getBoundary=function(){return new jsts.operation.BoundaryOp(this).getBoundary()};jsts.geom.MultiLineString.prototype.equalsExact=function(other,tolerance){if(!this.isEquivalentClass(other)){return false}return jsts.geom.GeometryCollection.prototype.equalsExact.call(this,other,tolerance)};jsts.geom.MultiLineString.prototype.CLASS_NAME="jsts.geom.MultiLineString"})();(function(){var Interval=jsts.index.bintree.Interval;var Root=jsts.index.bintree.Root;var Bintree=function(){this.root=new Root;this.minExtent=1};Bintree.ensureExtent=function(itemInterval,minExtent){var min,max;min=itemInterval.getMin();max=itemInterval.getMax();if(min!==max){return itemInterval}if(min===max){min=min-minExtent/2;max=min+minExtent/2}return new Interval(min,max)};Bintree.prototype.depth=function(){if(this.root!==null){return this.root.depth()}return 0};Bintree.prototype.size=function(){if(this.root!==null){return this.root.size()}return 0};Bintree.prototype.nodeSize=function(){if(this.root!==null){return this.root.nodeSize()}return 0};Bintree.prototype.insert=function(itemInterval,item){this.collectStats(itemInterval);var insertInterval=Bintree.ensureExtent(itemInterval,this.minExtent);this.root.insert(insertInterval,item)};Bintree.prototype.remove=function(itemInterval,item){var insertInterval=Bintree.ensureExtent(itemInterval,this.minExtent);return this.root.remove(insertInterval,item)};Bintree.prototype.iterator=function(){var foundItems=new javascript.util.ArrayList;this.root.addAllItems(foundItems);return foundItems.iterator()};Bintree.prototype.query=function(){if(arguments.length===2){this.queryAndAdd(arguments[0],arguments[1])}else{var x=arguments[0];if(!x instanceof Interval){x=new Interval(x,x)}return this.queryInterval(x)}};Bintree.prototype.queryInterval=function(interval){var foundItems=new javascript.util.ArrayList;this.query(interval,foundItems);return foundItems};Bintree.prototype.queryAndAdd=function(interval,foundItems){this.root.addAllItemsFromOverlapping(interval,foundItems)};Bintree.prototype.collectStats=function(interval){var del=interval.getWidth();if(del<this.minExtent&&del>0){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;i<geometry.getNumGeometries();i++){this.add(geometry.getGeometryN(i))}}};jsts.algorithm.InteriorPointArea.prototype.addPolygon=function(geometry){if(geometry.isEmpty()){return}var intPt;var width=0;var bisector=this.horizontalBisector(geometry);if(bisector.getLength()==0){width=0;intPt=bisector.getCoordinate()}else{var intersections=bisector.intersection(geometry);var widestIntersection=this.widestGeometry(intersections);width=widestIntersection.getEnvelopeInternal().getWidth();intPt=this.centre(widestIntersection.getEnvelopeInternal())}if(this.interiorPoint==null||width>this.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;i<gc.getNumGeometries();i++){if(gc.getGeometryN(i).getEnvelopeInternal().getWidth()>widestGeometry.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;i<this.poly.getNumInteriorRing();i++){this.process(this.poly.getInteriorRingN(i))}var bisectY=jsts.algorithm.InteriorPointArea.avg(this.hiY,this.loY);return bisectY};jsts.algorithm.SafeBisectorFinder.prototype.process=function(line){var seq=line.getCoordinateSequence();for(var i=0;i<seq.length;i++){var y=seq[i].y;this.updateInterval(y)}};jsts.algorithm.SafeBisectorFinder.prototype.updateInterval=function(y){if(y<=this.centreY){if(y>this.loY){this.loY=y}}else if(y>this.centreY){if(y<this.hiY){this.hiY=y}}};jsts.operation.buffer.BufferParameters=function(quadrantSegments,endCapStyle,joinStyle,mitreLimit){if(quadrantSegments)this.setQuadrantSegments(quadrantSegments);if(endCapStyle)this.setEndCapStyle(endCapStyle);if(joinStyle)this.setJoinStyle(joinStyle);if(mitreLimit)this.setMitreLimit(mitreLimit)};jsts.operation.buffer.BufferParameters.CAP_ROUND=1;jsts.operation.buffer.BufferParameters.CAP_FLAT=2;jsts.operation.buffer.BufferParameters.CAP_SQUARE=3;jsts.operation.buffer.BufferParameters.JOIN_ROUND=1;jsts.operation.buffer.BufferParameters.JOIN_MITRE=2;jsts.operation.buffer.BufferParameters.JOIN_BEVEL=3;jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS=8;jsts.operation.buffer.BufferParameters.DEFAULT_MITRE_LIMIT=5;jsts.operation.buffer.BufferParameters.prototype.quadrantSegments=jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS;jsts.operation.buffer.BufferParameters.prototype.endCapStyle=jsts.operation.buffer.BufferParameters.CAP_ROUND;jsts.operation.buffer.BufferParameters.prototype.joinStyle=jsts.operation.buffer.BufferParameters.JOIN_ROUND;jsts.operation.buffer.BufferParameters.prototype.mitreLimit=jsts.operation.buffer.BufferParameters.DEFAULT_MITRE_LIMIT;jsts.operation.buffer.BufferParameters.prototype._isSingleSided=false;jsts.operation.buffer.BufferParameters.prototype.getQuadrantSegments=function(){return this.quadrantSegments};jsts.operation.buffer.BufferParameters.prototype.setQuadrantSegments=function(quadrantSegments){this.quadrantSegments=quadrantSegments};jsts.operation.buffer.BufferParameters.prototype.setQuadrantSegments=function(quadSegs){this.quadrantSegments=quadSegs;if(this.quadrantSegments===0)this.joinStyle=jsts.operation.buffer.BufferParameters.JOIN_BEVEL;if(this.quadrantSegments<0){this.joinStyle=jsts.operation.buffer.BufferParameters.JOIN_MITRE;this.mitreLimit=Math.abs(this.quadrantSegments)}if(quadSegs<=0){this.quadrantSegments=1}if(this.joinStyle!==jsts.operation.buffer.BufferParameters.JOIN_ROUND){this.quadrantSegments=jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS}};jsts.operation.buffer.BufferParameters.bufferDistanceError=function(quadSegs){var alpha=Math.PI/2/quadSegs;return 1-Math.cos(alpha/2)};jsts.operation.buffer.BufferParameters.prototype.getEndCapStyle=function(){return this.endCapStyle};jsts.operation.buffer.BufferParameters.prototype.setEndCapStyle=function(endCapStyle){this.endCapStyle=endCapStyle};jsts.operation.buffer.BufferParameters.prototype.getJoinStyle=function(){return this.joinStyle};jsts.operation.buffer.BufferParameters.prototype.setJoinStyle=function(joinStyle){this.joinStyle=joinStyle};jsts.operation.buffer.BufferParameters.prototype.getMitreLimit=function(){return this.mitreLimit};jsts.operation.buffer.BufferParameters.prototype.setMitreLimit=function(mitreLimit){this.mitreLimit=mitreLimit};jsts.operation.buffer.BufferParameters.prototype.setSingleSided=function(isSingleSided){this._isSingleSided=isSingleSided};jsts.operation.buffer.BufferParameters.prototype.isSingleSided=function(){return this._isSingleSided};(function(){jsts.geom.util.ShortCircuitedGeometryVisitor=function(){};jsts.geom.util.ShortCircuitedGeometryVisitor.prototype.isDone=false;jsts.geom.util.ShortCircuitedGeometryVisitor.prototype.applyTo=function(geom){for(var i=0;i<geom.getNumGeometries()&&!this.isDone;i++){var element=geom.getGeometryN(i);if(!(element instanceof jsts.geom.GeometryCollection)){this.visit(element);if(this.isDone()){this.isDone=true;return}}else this.applyTo(element)}};jsts.geom.util.ShortCircuitedGeometryVisitor.prototype.visit=function(element){};jsts.geom.util.ShortCircuitedGeometryVisitor.prototype.isDone=function(){}})();(function(){var EnvelopeIntersectsVisitor=function(rectEnv){this.rectEnv=rectEnv};EnvelopeIntersectsVisitor.prototype=new jsts.geom.util.ShortCircuitedGeometryVisitor;EnvelopeIntersectsVisitor.constructor=EnvelopeIntersectsVisitor;EnvelopeIntersectsVisitor.prototype.rectEnv=null;EnvelopeIntersectsVisitor.prototype.intersects=false;EnvelopeIntersectsVisitor.prototype.intersects=function(){return this.intersects};EnvelopeIntersectsVisitor.prototype.visit=function(element){var elementEnv=element.getEnvelopeInternal();if(!this.rectEnv.intersects(elementEnv)){return}if(this.rectEnv.contains(elementEnv)){this.intersects=true;return}if(elementEnv.getMinX()>=rectEnv.getMinX()&&elementEnv.getMaxX()<=rectEnv.getMaxX()){this.intersects=true;return}if(elementEnv.getMinY()>=rectEnv.getMinY()&&elementEnv.getMaxY()<=rectEnv.getMaxY()){this.intersects=true;return}};EnvelopeIntersectsVisitor.prototype.isDone=function(){return this.intersects==true};var GeometryContainsPointVisitor=function(rectangle){this.rectSeq=rectangle.getExteriorRing().getCoordinateSequence();this.rectEnv=rectangle.getEnvelopeInternal()};GeometryContainsPointVisitor.prototype=new jsts.geom.util.ShortCircuitedGeometryVisitor;GeometryContainsPointVisitor.constructor=GeometryContainsPointVisitor;GeometryContainsPointVisitor.prototype.rectSeq=null;GeometryContainsPointVisitor.prototype.rectEnv=null;GeometryContainsPointVisitor.prototype.containsPoint=false;GeometryContainsPointVisitor.prototype.containsPoint=function(){return this.containsPoint};GeometryContainsPointVisitor.prototype.visit=function(geom){if(!(geom instanceof jsts.geom.Polygon))return;var elementEnv=geom.getEnvelopeInternal();if(!this.rectEnv.intersects(elementEnv))return;var rectPt=new jsts.geom.Coordinate;for(var i=0;i<4;i++){this.rectSeq.getCoordinate(i,rectPt);if(!elementEnv.contains(rectPt))continue;if(SimplePointInAreaLocator.containsPointInPolygon(rectPt,geom)){this.containsPoint=true;return}}};GeometryContainsPointVisitor.prototype.isDone=function(){return this.containsPoint==true};var RectangleIntersectsSegmentVisitor=function(rectangle){this.rectEnv=rectangle.getEnvelopeInternal();this.rectIntersector=new RectangleLineIntersector(rectEnv)};RectangleIntersectsSegmentVisitor.prototype=new jsts.geom.util.ShortCircuitedGeometryVisitor;RectangleIntersectsSegmentVisitor.constructor=RectangleIntersectsSegmentVisitor;RectangleIntersectsSegmentVisitor.prototype.rectEnv=null;RectangleIntersectsSegmentVisitor.prototype.rectIntersector=null;RectangleIntersectsSegmentVisitor.prototype.hasIntersection=false;RectangleIntersectsSegmentVisitor.prototype.p0=null;RectangleIntersectsSegmentVisitor.prototype.p1=null;RectangleIntersectsSegmentVisitor.prototype.intersects=function(){return this.hasIntersection};RectangleIntersectsSegmentVisitor.prototype.visit=function(geom){var elementEnv=geom.getEnvelopeInternal();if(!this.rectEnv.intersects(elementEnv))return;var lines=LinearComponentExtracter.getLines(geom);this.checkIntersectionWithLineStrings(lines)};RectangleIntersectsSegmentVisitor.prototype.checkIntersectionWithLineStrings=function(lines){for(var i=lines.iterator();i.hasNext();){var testLine=i.next();this.checkIntersectionWithSegments(testLine);if(this.hasIntersection)return}};RectangleIntersectsSegmentVisitor.prototype.checkIntersectionWithSegments=function(testLine){var seq1=testLine.getCoordinateSequence();for(var j=1;j<seq1.length;j++){this.p0=seq1[j-1];this.p1=seq1[j];if(rectIntersector.intersects(p0,p1)){this.hasIntersection=true;return}}};RectangleIntersectsSegmentVisitor.prototype.isDone=function(){return this.hasIntersection==true};jsts.operation.predicate.RectangleIntersects=function(rectangle){this.rectangle=rectangle;this.rectEnv=rectangle.getEnvelopeInternal()};jsts.operation.predicate.RectangleIntersects.intersects=function(rectangle,b){var rp=new jsts.operation.predicate.RectangleIntersects(rectangle);return rp.intersects(b)};jsts.operation.predicate.RectangleIntersects.prototype.rectangle=null;jsts.operation.predicate.RectangleIntersects.prototype.rectEnv=null;jsts.operation.predicate.RectangleIntersects.prototype.intersects=function(geom){if(!this.rectEnv.intersects(geom.getEnvelopeInternal()))return false;var visitor=new EnvelopeIntersectsVisitor(this.rectEnv);visitor.applyTo(geom);if(visitor.intersects())return true;var ecpVisitor=new GeometryContainsPointVisitor(rectangle);ecpVisitor.applyTo(geom);if(ecpVisitor.containsPoint())return true;var riVisitor=new RectangleIntersectsSegmentVisitor(rectangle);riVisitor.applyTo(geom);if(riVisitor.intersects())return true;return false}})();jsts.operation.buffer.BufferBuilder=function(bufParams){this.bufParams=bufParams;this.edgeList=new jsts.geomgraph.EdgeList};jsts.operation.buffer.BufferBuilder.depthDelta=function(label){var lLoc=label.getLocation(0,jsts.geomgraph.Position.LEFT);var rLoc=label.getLocation(0,jsts.geomgraph.Position.RIGHT);if(lLoc===jsts.geom.Location.INTERIOR&&rLoc===jsts.geom.Location.EXTERIOR)return 1;else if(lLoc===jsts.geom.Location.EXTERIOR&&rLoc===jsts.geom.Location.INTERIOR)return-1;return 0};jsts.operation.buffer.BufferBuilder.prototype.bufParams=null;jsts.operation.buffer.BufferBuilder.prototype.workingPrecisionModel=null;jsts.operation.buffer.BufferBuilder.prototype.workingNoder=null;jsts.operation.buffer.BufferBuilder.prototype.geomFact=null;jsts.operation.buffer.BufferBuilder.prototype.graph=null;jsts.operation.buffer.BufferBuilder.prototype.edgeList=null;jsts.operation.buffer.BufferBuilder.prototype.setWorkingPrecisionModel=function(pm){this.workingPrecisionModel=pm};jsts.operation.buffer.BufferBuilder.prototype.setNoder=function(noder){this.workingNoder=noder};jsts.operation.buffer.BufferBuilder.prototype.buffer=function(g,distance){var precisionModel=this.workingPrecisionModel;if(precisionModel===null)precisionModel=g.getPrecisionModel();this.geomFact=g.getFactory();var curveBuilder=new jsts.operation.buffer.OffsetCurveBuilder(precisionModel,this.bufParams);var curveSetBuilder=new jsts.operation.buffer.OffsetCurveSetBuilder(g,distance,curveBuilder);var bufferSegStrList=curveSetBuilder.getCurves();if(bufferSegStrList.size()<=0){return this.createEmptyResultGeometry()}this.computeNodedEdges(bufferSegStrList,precisionModel);this.graph=new jsts.geomgraph.PlanarGraph(new jsts.operation.overlay.OverlayNodeFactory);this.graph.addEdges(this.edgeList.getEdges());var subgraphList=this.createSubgraphs(this.graph);var polyBuilder=new jsts.operation.overlay.PolygonBuilder(this.geomFact);this.buildSubgraphs(subgraphList,polyBuilder);var resultPolyList=polyBuilder.getPolygons();if(resultPolyList.size()<=0){return this.createEmptyResultGeometry()}var resultGeom=this.geomFact.buildGeometry(resultPolyList);return resultGeom};jsts.operation.buffer.BufferBuilder.prototype.getNoder=function(precisionModel){if(this.workingNoder!==null)return this.workingNoder;var noder=new jsts.noding.MCIndexNoder;var li=new jsts.algorithm.RobustLineIntersector;li.setPrecisionModel(precisionModel);noder.setSegmentIntersector(new jsts.noding.IntersectionAdder(li));return noder};jsts.operation.buffer.BufferBuilder.prototype.computeNodedEdges=function(bufferSegStrList,precisionModel){var noder=this.getNoder(precisionModel);noder.computeNodes(bufferSegStrList);var nodedSegStrings=noder.getNodedSubstrings();for(var i=nodedSegStrings.iterator();i.hasNext();){var segStr=i.next();var oldLabel=segStr.getData();var edge=new jsts.geomgraph.Edge(segStr.getCoordinates(),new jsts.geomgraph.Label(oldLabel));this.insertUniqueEdge(edge)}};jsts.operation.buffer.BufferBuilder.prototype.insertUniqueEdge=function(e){var existingEdge=this.edgeList.findEqualEdge(e);if(existingEdge!=null){var existingLabel=existingEdge.getLabel();var labelToMerge=e.getLabel();if(!existingEdge.isPointwiseEqual(e)){labelToMerge=new jsts.geomgraph.Label(e.getLabel());labelToMerge.flip()}existingLabel.merge(labelToMerge);var mergeDelta=jsts.operation.buffer.BufferBuilder.depthDelta(labelToMerge);var existingDelta=existingEdge.getDepthDelta();var newDelta=existingDelta+mergeDelta;existingEdge.setDepthDelta(newDelta)}else{this.edgeList.add(e);e.setDepthDelta(jsts.operation.buffer.BufferBuilder.depthDelta(e.getLabel()))}};jsts.operation.buffer.BufferBuilder.prototype.createSubgraphs=function(graph){var subgraphList=[];for(var i=graph.getNodes().iterator();i.hasNext();){var node=i.next();if(!node.isVisited()){var subgraph=new jsts.operation.buffer.BufferSubgraph;subgraph.create(node);subgraphList.push(subgraph)}}var compare=function(a,b){return a.compareTo(b)};subgraphList.sort(compare);subgraphList.reverse();return subgraphList};jsts.operation.buffer.BufferBuilder.prototype.buildSubgraphs=function(subgraphList,polyBuilder){var processedGraphs=[];for(var i=0;i<subgraphList.length;i++){var subgraph=subgraphList[i];var p=subgraph.getRightmostCoordinate();var locater=new jsts.operation.buffer.SubgraphDepthLocater(processedGraphs);var outsideDepth=locater.getDepth(p);subgraph.computeDepth(outsideDepth);subgraph.findResultEdges();processedGraphs.push(subgraph);polyBuilder.add(subgraph.getDirectedEdges(),subgraph.getNodes())}};jsts.operation.buffer.BufferBuilder.convertSegStrings=function(it){var fact=new jsts.geom.GeometryFactory;var lines=new javascript.util.ArrayList;while(it.hasNext()){var ss=it.next();var line=fact.createLineString(ss.getCoordinates());lines.add(line)}return fact.buildGeometry(lines)};jsts.operation.buffer.BufferBuilder.prototype.createEmptyResultGeometry=function(){var emptyGeom=this.geomFact.createPolygon(null,null);return emptyGeom};jsts.noding.SegmentPointComparator=function(){};jsts.noding.SegmentPointComparator.compare=function(octant,p0,p1){if(p0.equals2D(p1))return 0;var xSign=jsts.noding.SegmentPointComparator.relativeSign(p0.x,p1.x);var ySign=jsts.noding.SegmentPointComparator.relativeSign(p0.y,p1.y);switch(octant){case 0:return jsts.noding.SegmentPointComparator.compareValue(xSign,ySign);case 1:return jsts.noding.SegmentPointComparator.compareValue(ySign,xSign);case 2:return jsts.noding.SegmentPointComparator.compareValue(ySign,-xSign);case 3:return jsts.noding.SegmentPointComparator.compareValue(-xSign,ySign);case 4:return jsts.noding.SegmentPointComparator.compareValue(-xSign,-ySign);case 5:return jsts.noding.SegmentPointComparator.compareValue(-ySign,-xSign);case 6:return jsts.noding.SegmentPointComparator.compareValue(-ySign,xSign);case 7:return jsts.noding.SegmentPointComparator.compareValue(xSign,-ySign)}return 0};jsts.noding.SegmentPointComparator.relativeSign=function(x0,x1){if(x0<x1)return-1;if(x0>x1)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<mid){this.computeSelect2(searchEnv,start0,mid,mcs)}if(mid<end0){this.computeSelect2(searchEnv,mid,end0,mcs)}};jsts.index.chain.MonotoneChain.prototype.computeOverlaps=function(mc,mco){if(arguments.length===6){return this.computeOverlaps2.apply(this,arguments)}this.computeOverlaps2(this.start,this.end,mc,mc.start,mc.end,mco)};jsts.index.chain.MonotoneChain.prototype.computeOverlaps2=function(start0,end0,mc,start1,end1,mco){var p00=this.pts[start0];var p01=this.pts[end0];var p10=mc.pts[start1];var p11=mc.pts[end1];if(end0-start0===1&&end1-start1===1){mco.overlap(this,start0,mc,start1);return}mco.tempEnv1.init(p00,p01);mco.tempEnv2.init(p10,p11);if(!mco.tempEnv1.intersects(mco.tempEnv2))return;var mid0=parseInt((start0+end0)/2);var mid1=parseInt((start1+end1)/2);if(start0<mid0){if(start1<mid1)this.computeOverlaps2(start0,mid0,mc,start1,mid1,mco);if(mid1<end1)this.computeOverlaps2(start0,mid0,mc,mid1,end1,mco)}if(mid0<end0){if(start1<mid1)this.computeOverlaps2(mid0,end0,mc,start1,mid1,mco);if(mid1<end1)this.computeOverlaps2(mid0,end0,mc,mid1,end1,mco)}};(function(){var Location=jsts.geom.Location;var Dimension=jsts.geom.Dimension;jsts.geom.IntersectionMatrix=function(elements){var other=elements;if(elements===undefined||elements===null){this.matrix=[[],[],[]];this.setAll(Dimension.FALSE)}else if(typeof elements==="string"){this.set(elements)}else if(other instanceof jsts.geom.IntersectionMatrix){this.matrix[Location.INTERIOR][Location.INTERIOR]=other.matrix[Location.INTERIOR][Location.INTERIOR];this.matrix[Location.INTERIOR][Location.BOUNDARY]=other.matrix[Location.INTERIOR][Location.BOUNDARY];this.matrix[Location.INTERIOR][Location.EXTERIOR]=other.matrix[Location.INTERIOR][Location.EXTERIOR];this.matrix[Location.BOUNDARY][Location.INTERIOR]=other.matrix[Location.BOUNDARY][Location.INTERIOR];this.matrix[Location.BOUNDARY][Location.BOUNDARY]=other.matrix[Location.BOUNDARY][Location.BOUNDARY];this.matrix[Location.BOUNDARY][Location.EXTERIOR]=other.matrix[Location.BOUNDARY][Location.EXTERIOR];this.matrix[Location.EXTERIOR][Location.INTERIOR]=other.matrix[Location.EXTERIOR][Location.INTERIOR];this.matrix[Location.EXTERIOR][Location.BOUNDARY]=other.matrix[Location.EXTERIOR][Location.BOUNDARY];this.matrix[Location.EXTERIOR][Location.EXTERIOR]=other.matrix[Location.EXTERIOR][Location.EXTERIOR];
}};jsts.geom.IntersectionMatrix.prototype.matrix=null;jsts.geom.IntersectionMatrix.prototype.add=function(im){var i,j;for(i=0;i<3;i++){for(j=0;j<3;j++){this.setAtLeast(i,j,im.get(i,j))}}};jsts.geom.IntersectionMatrix.matches=function(actualDimensionValue,requiredDimensionSymbol){if(typeof actualDimensionValue==="string"){return jsts.geom.IntersectionMatrix.matches2.call(this,arguments)}if(requiredDimensionSymbol==="*"){return true}if(requiredDimensionSymbol==="T"&&(actualDimensionValue>=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<dimensionSymbols.length();i++){var row=i/3;var col=i%3;this.matrix[row][col]=Dimension.toDimensionValue(dimensionSymbols.charAt(i))}};jsts.geom.IntersectionMatrix.prototype.setAtLeast=function(row,column,minimumDimensionValue){if(arguments.length===1){this.setAtLeast2(arguments[0]);return}if(this.matrix[row][column]<minimumDimensionValue){this.matrix[row][column]=minimumDimensionValue}};jsts.geom.IntersectionMatrix.prototype.setAtLeastIfValid=function(row,column,minimumDimensionValue){if(row>=0&&column>=0){this.setAtLeast(row,column,minimumDimensionValue)}};jsts.geom.IntersectionMatrix.prototype.setAtLeast2=function(minimumDimensionSymbols){var i;for(i=0;i<minimumDimensionSymbols.length;i++){var row=parseInt(i/3);var col=parseInt(i%3);this.setAtLeast(row,col,jsts.geom.Dimension.toDimensionValue(minimumDimensionSymbols.charAt(i)))}};jsts.geom.IntersectionMatrix.prototype.setAll=function(dimensionValue){var ai,bi;for(ai=0;ai<3;ai++){for(bi=0;bi<3;bi++){this.matrix[ai][bi]=dimensionValue}}};jsts.geom.IntersectionMatrix.prototype.get=function(row,column){return this.matrix[row][column]};jsts.geom.IntersectionMatrix.prototype.isDisjoint=function(){return this.matrix[Location.INTERIOR][Location.INTERIOR]===Dimension.FALSE&&this.matrix[Location.INTERIOR][Location.BOUNDARY]===Dimension.FALSE&&this.matrix[Location.BOUNDARY][Location.INTERIOR]===Dimension.FALSE&&this.matrix[Location.BOUNDARY][Location.BOUNDARY]===Dimension.FALSE};jsts.geom.IntersectionMatrix.prototype.isIntersects=function(){return!this.isDisjoint()};jsts.geom.IntersectionMatrix.prototype.isTouches=function(dimensionOfGeometryA,dimensionOfGeometryB){if(dimensionOfGeometryA>dimensionOfGeometryB){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;i<collapsedVertexIndexes.length;i++){var vertexIndex=collapsedVertexIndexes[i];this.add(this.edge.getCoordinate(vertexIndex),vertexIndex)}};jsts.noding.SegmentNodeList.prototype.findCollapsesFromExistingVertices=function(collapsedVertexIndexes){for(var i=0;i<this.edge.size()-2;i++){var p0=this.edge.getCoordinate(i);var p1=this.edge.getCoordinate(i+1);var p2=this.edge.getCoordinate(i+2);if(p0.equals2D(p2)){collapsedVertexIndexes.push(i+1)}}};jsts.noding.SegmentNodeList.prototype.findCollapsesFromInsertedNodes=function(collapsedVertexIndexes){var collapsedVertexIndex=[null];var it=this.iterator();var eiPrev=it.next();while(it.hasNext()){var ei=it.next();var isCollapsed=this.findCollapseIndex(eiPrev,ei,collapsedVertexIndex);if(isCollapsed)collapsedVertexIndexes.push(collapsedVertexIndex[0]);eiPrev=ei}};jsts.noding.SegmentNodeList.prototype.findCollapseIndex=function(ei0,ei1,collapsedVertexIndex){if(!ei0.coord.equals2D(ei1.coord))return false;var numVerticesBetween=ei1.segmentIndex-ei0.segmentIndex;if(!ei1.isInterior()){numVerticesBetween--}if(numVerticesBetween===1){collapsedVertexIndex[0]=ei0.segmentIndex+1;return true}return false};jsts.noding.SegmentNodeList.prototype.addSplitEdges=function(edgeList){this.addEndpoints();this.addCollapsedNodes();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.noding.SegmentNodeList.prototype.checkSplitEdgesCorrectness=function(splitEdges){var edgePts=edge.getCoordinates();var split0=splitEdges[0];var pt0=split0.getCoordinate(0);if(!pt0.equals2D(edgePts[0]))throw new Error("bad split edge start point at "+pt0);var splitn=splitEdges[splitEdges.length-1];var splitnPts=splitn.getCoordinates();var ptn=splitnPts[splitnPts.length-1];if(!ptn.equals2D(edgePts[edgePts.length-1]))throw new Error("bad split edge end point at "+ptn)};jsts.noding.SegmentNodeList.prototype.createSplitEdge=function(ei0,ei1){var npts=ei1.segmentIndex-ei0.segmentIndex+2;var lastSegStartPt=this.edge.getCoordinate(ei1.segmentIndex);var useIntPt1=ei1.isInterior()||!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.getCoordinate(i)}if(useIntPt1)pts[ipt]=ei1.coord;return new jsts.noding.NodedSegmentString(pts,this.edge.getData())};jsts.io.WKTWriter=function(){this.parser=new jsts.io.WKTParser(this.geometryFactory)};jsts.io.WKTWriter.prototype.write=function(geometry){var wkt=this.parser.write(geometry);return wkt};jsts.io.WKTWriter.toLineString=function(p0,p1){if(arguments.length!==2){throw new jsts.error.NotImplementedError}return"LINESTRING ( "+p0.x+" "+p0.y+", "+p1.x+" "+p1.y+" )"};jsts.io.WKTReader=function(geometryFactory){this.geometryFactory=geometryFactory||new jsts.geom.GeometryFactory;this.precisionModel=this.geometryFactory.getPrecisionModel();this.parser=new jsts.io.WKTParser(this.geometryFactory)};jsts.io.WKTReader.prototype.read=function(wkt){var geometry=this.parser.read(wkt);if(this.precisionModel.getType()===jsts.geom.PrecisionModel.FIXED){this.reducePrecision(geometry)}return geometry};jsts.io.WKTReader.prototype.reducePrecision=function(geometry){var i,len;if(geometry.coordinate){this.precisionModel.makePrecise(geometry.coordinate)}else if(geometry.points){for(i=0,len=geometry.points.length;i<len;i++){this.precisionModel.makePrecise(geometry.points[i])}}else if(geometry.geometries){for(i=0,len=geometry.geometries.length;i<len;i++){this.reducePrecision(geometry.geometries[i])}}};jsts.triangulate.quadedge.QuadEdgeSubdivision=function(env,tolerance){this.tolerance=tolerance;this.edgeCoincidenceTolerance=tolerance/jsts.triangulate.quadedge.QuadEdgeSubdivision.EDGE_COINCIDENCE_TOL_FACTOR;this.visitedKey=0;this.quadEdges=[];this.startingEdge;this.tolerance;this.edgeCoincidenceTolerance;this.frameEnv;this.locator=null;this.seg=new jsts.geom.LineSegment;this.triEdges=new Array(3);this.frameVertex=new Array(3);this.createFrame(env);this.startingEdge=this.initSubdiv();this.locator=new jsts.triangulate.quadedge.LastFoundQuadEdgeLocator(this)};jsts.triangulate.quadedge.QuadEdgeSubdivision.EDGE_COINCIDENCE_TOL_FACTOR=1e3;jsts.triangulate.quadedge.QuadEdgeSubdivision.getTriangleEdges=function(startQE,triEdge){triEdge[0]=startQE;triEdge[1]=triEdge[0].lNext();triEdge[2]=triEdge[1].lNext();if(triEdge[2].lNext()!=triEdge[0]){throw new jsts.IllegalArgumentError("Edges do not form a triangle")}};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.createFrame=function(env){var deltaX,deltaY,offset;deltaX=env.getWidth();deltaY=env.getHeight();offset=0;if(deltaX>deltaY){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 dist<this.edgeCoincidenceTolerance};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.isVertexOfEdge=function(e,v){if(v.equals(e.orig(),this.tolerance)||v.equals(e.dest(),this.tolerance)){return true}return false};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getVertices=function(includeFrame){var vertices=[],i,il,qe,v,vd;i=0,il=this.quadEdges.length;for(i;i<il;i++){qe=this.quadEdges[i];v=qe.orig();if(includeFrame||!this.isFrameVertex(v)){vertices.push(v)}vd=qe.dest();if(includeFrame||!this.isFrameVertex(vd)){vertices.push(vd)}}return vertices};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getVertexUniqueEdges=function(includeFrame){var edges,visitedVertices,i,il,qe,v,qd,vd;edges=[];visitedVertices=[];i=0,il=this.quadEdges.length;for(i;i<il;i++){qe=this.quadEdges[i];v=qe.orig();if(visitedVertices.indexOf(v)===-1){visitedVertices.push(v);if(includeFrame||!this.isFrameVertex(v)){edges.push(qe)}}qd=qe.sym();vd=qd.orig();if(visitedVertices.indexOf(vd)===-1){visitedVertices.push(vd);if(includeFrame||!this.isFrameVertex(vd)){edges.push(qd)}}}return edges};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getPrimaryEdges=function(includeFrame){this.visitedKey++;var edges,edgeStack,visitedEdges,edge,priQE;edges=[];edgeStack=[];edgeStack.push(this.startingEdge);visitedEdges=[];while(edgeStack.length>0){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;i<il;i++){qe=quadEdges[i];coords=[];coords[0]=qe.orig().getCoordinate();coords[1]=qe.dest().getCoordinate();edges[i]=geomFact.createLineString(coords)}return geomFact.createMultiLineString(edges)};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getTriangles=function(geomFact){var triPtsList,tris,triPt,i,il;triPtsList=this.getTriangleCoordinates(false);tris=new Array(triPtsList.length);i=0,il=triPtsList.length;for(i;i<il;i++){triPt=triPtsList[i];tris[i]=geomFact.createPolygon(geomFact.createLinearRing(triPt,null))}return geomFact.createGeometryCollection(tris)};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getVoronoiDiagram=function(geomFact){var vorCells=this.getVoronoiCellPolygons(geomFact);return geomFact.createGeometryCollection(vorCells)};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getVoronoiCellPolygons=function(geomFact){this.visitTriangles(new jsts.triangulate.quadedge.TriangleCircumcentreVisitor,true);var cells,edges,i,il,qe;cells=[];edges=this.getVertexUniqueEdges(false);i=0,il=edges.length;for(i;i<il;i++){qe=edges[i];cells.push(this.getVoronoiCellPolygon(qe,geomFact))}return cells};jsts.triangulate.quadedge.QuadEdgeSubdivision.prototype.getVoronoiCellPolygon=function(qe,geomFact){var cellPts,startQe,cc,coordList,cellPoly,v;cellPts=[];startQE=qe;do{cc=qe.rot.orig().getCoordinate();cellPts.push(cc);qe=qe.oPrev()}while(qe!==startQE);coordList=new jsts.geom.CoordinateList([],false);coordList.add(cellPts,false);coordList.closeRing();if(coordList.size()<4){coordList.add(coordList.get(coordList.size()-1),true)}cellPoly=geomFact.createPolygon(geomFact.createLinearRing(coordList.toArray()),null);v=startQE.orig();return cellPoly};jsts.triangulate.quadedge.TriangleCircumcentreVisitor=function(){};jsts.triangulate.quadedge.TriangleCircumcentreVisitor.prototype.visit=function(triEdges){var a,b,c,cc,ccVertex,i;a=triEdges[0].orig().getCoordinate();b=triEdges[1].orig().getCoordinate();c=triEdges[2].orig().getCoordinate();cc=jsts.geom.Triangle.circumcentre(a,b,c);ccVertex=new jsts.triangulate.quadedge.Vertex(cc);i=0;for(i;i<3;i++){triEdges[i].rot.setOrig(ccVertex)}};jsts.triangulate.quadedge.TriangleEdgesListVisitor=function(){this.triList=[]};jsts.triangulate.quadedge.TriangleEdgesListVisitor.prototype.visit=function(triEdges){var clone=triEdges.concat();this.triList.push(clone)};jsts.triangulate.quadedge.TriangleEdgesListVisitor.prototype.getTriangleEdges=function(){return this.triList};jsts.triangulate.quadedge.TriangleVertexListVisitor=function(){this.triList=[]};jsts.triangulate.quadedge.TriangleVertexListVisitor.prototype.visit=function(triEdges){var vertices=[];vertices.push(trieEdges[0].orig());vertices.push(trieEdges[1].orig());vertices.push(trieEdges[2].orig());this.triList.push(vertices)};jsts.triangulate.quadedge.TriangleVertexListVisitor.prototype.getTriangleVertices=function(){return this.triList};jsts.triangulate.quadedge.TriangleCoordinatesVisitor=function(){this.coordList=new jsts.geom.CoordinateList([],false);this.triCoords=[]};jsts.triangulate.quadedge.TriangleCoordinatesVisitor.prototype.visit=function(triEdges){this.coordList=new jsts.geom.CoordinateList([],false);var i=0,v,pts;for(i;i<3;i++){v=triEdges[i].orig();this.coordList.add(v.getCoordinate())}if(this.coordList.size()>0){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;i<this.edgeEnds.length;i++){var e=this.edgeEnds[i];if(e.getLabel().isArea())isArea=true}if(isArea)this.label=new jsts.geomgraph.Label(jsts.geom.Location.NONE,jsts.geom.Location.NONE,jsts.geom.Location.NONE);else this.label=new jsts.geomgraph.Label(jsts.geom.Location.NONE);for(var i=0;i<2;i++){this.computeLabelOn(i,boundaryNodeRule);if(isArea)this.computeLabelSides(i)}};jsts.operation.relate.EdgeEndBundle.prototype.computeLabelOn=function(geomIndex,boundaryNodeRule){var boundaryCount=0;var foundInterior=false;for(var i=0;i<this.edgeEnds.length;i++){var e=this.edgeEnds[i];var loc=e.getLabel().getLocation(geomIndex);if(loc==jsts.geom.Location.BOUNDARY)boundaryCount++;if(loc==jsts.geom.Location.INTERIOR)foundInterior=true}var loc=jsts.geom.Location.NONE;if(foundInterior)loc=jsts.geom.Location.INTERIOR;if(boundaryCount>0){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;i<this.edgeEnds.length;i++){var e=this.edgeEnds[i];if(e.getLabel().isArea()){var loc=e.getLabel().getLocation(geomIndex,side);if(loc===jsts.geom.Location.INTERIOR){this.label.setLocation(geomIndex,side,jsts.geom.Location.INTERIOR);return}else if(loc===jsts.geom.Location.EXTERIOR)this.label.setLocation(geomIndex,side,jsts.geom.Location.EXTERIOR)}}};jsts.operation.relate.EdgeEndBundle.prototype.updateIM=function(im){jsts.geomgraph.Edge.updateIM(this.label,im)};jsts.index.kdtree.KdTree=function(tolerance){var tol=0;if(tolerance!==undefined){tol=tolerance}this.root=null;this.last=null;this.numberOfNodes=0;this.tolerance=tol};jsts.index.kdtree.KdTree.prototype.insert=function(){if(arguments.length===1){return this.insertCoordinate.apply(this,arguments[0])}else{return this.insertWithData.apply(this,arguments[0],arguments[1])}};jsts.index.kdtree.KdTree.prototype.insertCoordinate=function(p){return this.insertWithData(p,null)};jsts.index.kdtree.KdTree.prototype.insertWithData=function(p,data){if(this.root===null){this.root=new jsts.index.kdtree.KdNode(p,data);return this.root}var currentNode=this.root,leafNode=this.root,isOddLevel=true,isLessThan=true;while(currentNode!==last){if(isOddLevel){isLessThan=p.x<currentNode.getX()}else{isLessThan=p.y<currentNode.getY()}leafNode=currentNode;if(isLessThan){currentNode=currentNode.getLeft()}else{currentNode=currentNode.getRight()}if(currentNode!==null){var isInTolerance=p.distance(currentNode.getCoordinate())<=this.tolerance;if(isInTolerance){currentNode.increment();return currentNode}}isOddLevel=!isOddLevel}this.numberOfNodes=numberOfNodes+1;var node=new jsts.index.kdtree.KdNode(p,data);node.setLeft(this.last);node.setRight(this.last);if(isLessThan){leafNode.setLeft(node)}else{leafNode.setRight(node)}return node};jsts.index.kdtree.KdTree.prototype.queryNode=function(currentNode,bottomNode,queryEnv,odd,result){if(currentNode===bottomNode){return}var min,max,discriminant;if(odd){min=queryEnv.getMinX();max=queryEnv.getMaxX();discriminant=currentNode.getX()}else{min=queryEnv.getMinY();max=queryEnv.getMaxY();discriminant=currentNode.getY()}var searchLeft=min<discriminant;var searchRight=discriminant<=max;if(searchLeft){this.queryNode(currentNode.getLeft(),bottomNode,queryEnv,!odd,result);
}if(queryEnv.contains(currentNode.getCoordinate())){result.add(currentNode)}if(searchRight){this.queryNode(currentNode.getRight(),bottomNode,queryEnv,!odd,result)}};jsts.index.kdtree.KdTree.prototype.query=function(){if(arguments.length===1){return this.queryByEnvelope.apply(this,arguments[0])}else{return this.queryWithArray.apply(this,arguments[0],arguments[1])}};jsts.index.kdtree.KdTree.prototype.queryByEnvelope=function(queryEnv){var result=[];this.queryNode(this.root,this.last,queryEnv,true,result);return result};jsts.index.kdtree.KdTree.prototype.queryWithArray=function(queryEnv,result){this.queryNode(this.root,this.last,queryEnv,true,result)};jsts.geom.Triangle=function(p0,p1,p2){this.p0=p0;this.p1=p1;this.p2=p2};jsts.geom.Triangle.isAcute=function(a,b,c){if(!jsts.algorithm.Angle.isAcute(a,b,c)){return false}if(!jsts.algorithm.Angle.isAcute(b,c,a)){return false}if(!jsts.algorithm.Angle.isAcute(c,a,b)){return false}return true};jsts.geom.Triangle.perpendicularBisector=function(a,b){var dx,dy,l1,l2;dx=b.x-a.x;dy=b.y-a.y;l1=new jsts.algorithm.HCoordinate(a.x+dx/2,a.y+dy/2,1);l2=new jsts.algorithm.HCoordinate(a.x-dy+dx/2,a.y+dx+dy/2,1);return new jsts.algorithm.HCoordinate(l1,l2)};jsts.geom.Triangle.circumcentre=function(a,b,c){var cx,cy,ax,ay,bx,by,denom,numx,numy,ccx,ccy;cx=c.x;cy=c.y;ax=a.x-cx;ay=a.y-cy;bx=b.x-cx;by=b.y-cy;denom=2*jsts.geom.Triangle.det(ax,ay,bx,by);numx=jsts.geom.Triangle.det(ay,ax*ax+ay*ay,by,bx*bx+by*by);numy=jsts.geom.Triangle.det(ax,ax*ax+ay*ay,bx,bx*bx+by*by);ccx=cx-numx/denom;ccy=cy+numy/denom;return new jsts.geom.Coordinate(ccx,ccy)};jsts.geom.Triangle.det=function(m00,m01,m10,m11){return m00*m11-m01*m10};jsts.geom.Triangle.inCentre=function(a,b,c){var len0,len1,len2,circum,inCentreX,inCentreY;len0=b.distance(c);len1=a.distance(c);len2=a.distance(b);circum=len0+len1+len2;inCentreX=(len0*a.x+len1*b.x+len2*c.x)/circum;inCentreY=(len0*a.y+len1*b.y+len2*c.y)/circum;return new jsts.geom.Coordinate(inCentreX,inCentreY)};jsts.geom.Triangle.centroid=function(a,b,c){var x,y;x=(a.x+b.x+c.x)/3;y=(a.y+b.y+c.y)/3;return new jsts.geom.Coordinate(x,y)};jsts.geom.Triangle.longestSideLength=function(a,b,c){var lenAB,lenBC,lenCA,maxLen;lenAB=a.distance(b);lenBC=b.distance(c);lenCA=c.distance(a);maxLen=lenAB;if(lenBC>maxLen){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;i<n;i++){avg.x+=pts[i].x;avg.y+=pts[i].y}if(n>0){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;i<pts.length;i++){dist=p.distance(pts[i]);if(dist<minDist){minDist=dist;result=pts[i]}}return result};jsts.operation.buffer.BufferOp=function(g,bufParams){this.argGeom=g;this.bufParams=bufParams?bufParams:new jsts.operation.buffer.BufferParameters};jsts.operation.buffer.BufferOp.MAX_PRECISION_DIGITS=12;jsts.operation.buffer.BufferOp.precisionScaleFactor=function(g,distance,maxPrecisionDigits){var env=g.getEnvelopeInternal();var envSize=Math.max(env.getHeight(),env.getWidth());var expandByDistance=distance>0?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)};(function(){var Location=jsts.geom.Location;var Position=jsts.geomgraph.Position;var Assert=jsts.util.Assert;jsts.geomgraph.GeometryGraph=function(argIndex,parentGeom,boundaryNodeRule){jsts.geomgraph.PlanarGraph.call(this);this.lineEdgeMap=new javascript.util.HashMap;this.ptLocator=new jsts.algorithm.PointLocator;this.argIndex=argIndex;this.parentGeom=parentGeom;this.boundaryNodeRule=boundaryNodeRule||jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;if(parentGeom!==null){this.add(parentGeom)}};jsts.geomgraph.GeometryGraph.prototype=new jsts.geomgraph.PlanarGraph;jsts.geomgraph.GeometryGraph.constructor=jsts.geomgraph.GeometryGraph;jsts.geomgraph.GeometryGraph.prototype.createEdgeSetIntersector=function(){return new jsts.geomgraph.index.SimpleMCSweepLineIntersector};jsts.geomgraph.GeometryGraph.determineBoundary=function(boundaryNodeRule,boundaryCount){return boundaryNodeRule.isInBoundary(boundaryCount)?Location.BOUNDARY:Location.INTERIOR};jsts.geomgraph.GeometryGraph.prototype.parentGeom=null;jsts.geomgraph.GeometryGraph.prototype.lineEdgeMap=null;jsts.geomgraph.GeometryGraph.prototype.boundaryNodeRule=null;jsts.geomgraph.GeometryGraph.prototype.useBoundaryDeterminationRule=true;jsts.geomgraph.GeometryGraph.prototype.argIndex=null;jsts.geomgraph.GeometryGraph.prototype.boundaryNodes=null;jsts.geomgraph.GeometryGraph.prototype.hasTooFewPoints=false;jsts.geomgraph.GeometryGraph.prototype.invalidPoint=null;jsts.geomgraph.GeometryGraph.prototype.areaPtLocator=null;jsts.geomgraph.GeometryGraph.prototype.ptLocator=null;jsts.geomgraph.GeometryGraph.prototype.getGeometry=function(){return this.parentGeom};jsts.geomgraph.GeometryGraph.prototype.getBoundaryNodes=function(){if(this.boundaryNodes===null)this.boundaryNodes=this.nodes.getBoundaryNodes(this.argIndex);return this.boundaryNodes};jsts.geomgraph.GeometryGraph.prototype.getBoundaryNodeRule=function(){return this.boundaryNodeRule};jsts.geomgraph.GeometryGraph.prototype.findEdge=function(line){return this.lineEdgeMap.get(line)};jsts.geomgraph.GeometryGraph.prototype.computeSplitEdges=function(edgelist){for(var i=this.edges.iterator();i.hasNext();){var e=i.next();e.eiList.addSplitEdges(edgelist)}};jsts.geomgraph.GeometryGraph.prototype.add=function(g){if(g.isEmpty()){return}if(g instanceof jsts.geom.MultiPolygon)this.useBoundaryDeterminationRule=false;if(g instanceof jsts.geom.Polygon)this.addPolygon(g);else if(g instanceof jsts.geom.LineString)this.addLineString(g);else if(g instanceof jsts.geom.Point)this.addPoint(g);else if(g instanceof jsts.geom.MultiPoint)this.addCollection(g);else if(g instanceof jsts.geom.MultiLineString)this.addCollection(g);else if(g instanceof jsts.geom.MultiPolygon)this.addCollection(g);else if(g instanceof jsts.geom.GeometryCollection)this.addCollection(g);else throw new jsts.error.IllegalArgumentError("Geometry type not supported.")};jsts.geomgraph.GeometryGraph.prototype.addCollection=function(gc){for(var i=0;i<gc.getNumGeometries();i++){var g=gc.getGeometryN(i);this.add(g)}};jsts.geomgraph.GeometryGraph.prototype.addEdge=function(e){this.insertEdge(e);var coord=e.getCoordinates();this.insertPoint(this.argIndex,coord[0],Location.BOUNDARY);this.insertPoint(this.argIndex,coord[coord.length-1],Location.BOUNDARY)};jsts.geomgraph.GeometryGraph.prototype.addPoint=function(p){var coord=p.getCoordinate();this.insertPoint(this.argIndex,coord,Location.INTERIOR)};jsts.geomgraph.GeometryGraph.prototype.addLineString=function(line){var coord=jsts.geom.CoordinateArrays.removeRepeatedPoints(line.getCoordinates());if(coord.length<2){this.hasTooFewPoints=true;this.invalidPoint=coords[0];return}var e=new jsts.geomgraph.Edge(coord,new jsts.geomgraph.Label(this.argIndex,Location.INTERIOR));this.lineEdgeMap.put(line,e);this.insertEdge(e);Assert.isTrue(coord.length>=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<p.getNumInteriorRing();i++){var hole=p.getInteriorRingN(i);this.addPolygonRing(hole,Location.INTERIOR,Location.EXTERIOR)}};jsts.geomgraph.GeometryGraph.prototype.computeEdgeIntersections=function(g,li,includeProper){var si=new jsts.geomgraph.index.SegmentIntersector(li,includeProper,true);si.setBoundaryNodes(this.getBoundaryNodes(),g.getBoundaryNodes());var esi=this.createEdgeSetIntersector();esi.computeIntersections(this.edges,g.edges,si);return si};jsts.geomgraph.GeometryGraph.prototype.computeSelfNodes=function(li,computeRingSelfNodes){var si=new jsts.geomgraph.index.SegmentIntersector(li,true,false);var esi=this.createEdgeSetIntersector();if(!computeRingSelfNodes&&(this.parentGeom instanceof jsts.geom.LinearRing||this.parentGeom instanceof jsts.geom.Polygon||this.parentGeom instanceof jsts.geom.MultiPolygon)){esi.computeIntersections(this.edges,si,false)}else{esi.computeIntersections(this.edges,si,true)}this.addSelfIntersectionNodes(this.argIndex);return si};jsts.geomgraph.GeometryGraph.prototype.insertPoint=function(argIndex,coord,onLocation){var n=this.nodes.addNode(coord);var lbl=n.getLabel();if(lbl==null){n.label=new jsts.geomgraph.Label(argIndex,onLocation)}else lbl.setLocation(argIndex,onLocation)};jsts.geomgraph.GeometryGraph.prototype.insertBoundaryPoint=function(argIndex,coord){var n=this.nodes.addNode(coord);var lbl=n.getLabel();var boundaryCount=1;var loc=Location.NONE;if(lbl!==null)loc=lbl.getLocation(argIndex,Position.ON);if(loc===Location.BOUNDARY)boundaryCount++;var newLoc=jsts.geomgraph.GeometryGraph.determineBoundary(this.boundaryNodeRule,boundaryCount);lbl.setLocation(argIndex,newLoc)};jsts.geomgraph.GeometryGraph.prototype.addSelfIntersectionNodes=function(argIndex){for(var i=this.edges.iterator();i.hasNext();){var e=i.next();var eLoc=e.getLabel().getLocation(argIndex);for(var eiIt=e.eiList.iterator();eiIt.hasNext();){var ei=eiIt.next();this.addSelfIntersectionNode(argIndex,ei.coord,eLoc)}}};jsts.geomgraph.GeometryGraph.prototype.addSelfIntersectionNode=function(argIndex,coord,loc){if(this.isBoundaryNode(argIndex,coord))return;if(loc===Location.BOUNDARY&&this.useBoundaryDeterminationRule)this.insertBoundaryPoint(argIndex,coord);else this.insertPoint(argIndex,coord,loc)};jsts.geomgraph.GeometryGraph.prototype.getInvalidPoint=function(){return this.invalidPoint}})();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<pt.length;i++){this.addPt(pt[i])}}else{for(var i=pt.length-1;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<this.minimimVertexDistance)return true;return false};jsts.operation.buffer.OffsetSegmentString.prototype.closeRing=function(){if(this.ptList.length<1)return;var startPt=new jsts.geom.Coordinate(this.ptList[0]);var lastPt=this.ptList[this.ptList.length-1];var last2Pt=null;if(this.ptList.length>=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(dist<this.distance)this.initialize(p0,p1,dist)};(function(){var PointPairDistance=jsts.algorithm.distance.PointPairDistance;var DistanceToPoint=jsts.algorithm.distance.DistanceToPoint;var MaxPointDistanceFilter=function(geom){this.maxPtDist=new PointPairDistance;this.minPtDist=new PointPairDistance;this.euclideanDist=new DistanceToPoint;this.geom=geom};MaxPointDistanceFilter.prototype=new jsts.geom.CoordinateFilter;MaxPointDistanceFilter.prototype.maxPtDist=new PointPairDistance;MaxPointDistanceFilter.prototype.minPtDist=new PointPairDistance;MaxPointDistanceFilter.prototype.euclideanDist=new DistanceToPoint;MaxPointDistanceFilter.prototype.geom;MaxPointDistanceFilter.prototype.filter=function(pt){this.minPtDist.initialize();DistanceToPoint.computeDistance(this.geom,pt,this.minPtDist);this.maxPtDist.setMaximum(this.minPtDist)};MaxPointDistanceFilter.prototype.getMaxPointDistance=function(){return this.maxPtDist};var MaxDensifiedByFractionDistanceFilter=function(geom,fraction){this.maxPtDist=new PointPairDistance;this.minPtDist=new PointPairDistance;this.geom=geom;this.numSubSegs=Math.round(1/fraction)};MaxDensifiedByFractionDistanceFilter.prototype=new jsts.geom.CoordinateSequenceFilter;MaxDensifiedByFractionDistanceFilter.prototype.maxPtDist=new PointPairDistance;MaxDensifiedByFractionDistanceFilter.prototype.minPtDist=new PointPairDistance;MaxDensifiedByFractionDistanceFilter.prototype.geom;MaxDensifiedByFractionDistanceFilter.prototype.numSubSegs=0;MaxDensifiedByFractionDistanceFilter.prototype.filter=function(seq,index){if(index==0)return;var p0=seq[index-1];var p1=seq[index];var delx=(p1.x-p0.x)/this.numSubSegs;var dely=(p1.y-p0.y)/this.numSubSegs;for(var i=0;i<this.numSubSegs;i++){var x=p0.x+i*delx;var y=p0.y+i*dely;var pt=new jsts.geom.Coordinate(x,y);this.minPtDist.initialize();DistanceToPoint.computeDistance(this.geom,pt,this.minPtDist);this.maxPtDist.setMaximum(this.minPtDist)}};MaxDensifiedByFractionDistanceFilter.prototype.isGeometryChanged=function(){return false};MaxDensifiedByFractionDistanceFilter.prototype.isDone=function(){return false};MaxDensifiedByFractionDistanceFilter.prototype.getMaxPointDistance=function(){return this.maxPtDist};jsts.algorithm.distance.DiscreteHausdorffDistance=function(g0,g1){this.g0=g0;this.g1=g1;this.ptDist=new jsts.algorithm.distance.PointPairDistance};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.g0=null;jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.g1=null;jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.ptDist=null;jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.densifyFrac=0;jsts.algorithm.distance.DiscreteHausdorffDistance.distance=function(g0,g1,densifyFrac){var dist=new jsts.algorithm.distance.DiscreteHausdorffDistance(g0,g1);if(densifyFrac!==undefined)dist.setDensifyFraction(densifyFrac);return dist.distance()};jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.setDensifyFraction=function(densifyFrac){if(densifyFrac>1||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())}}})();jsts.algorithm.MinimumBoundingCircle=function(geom){this.input=null;this.extremalPts=null;this.centre=null;this.radius=0;this.input=geom};jsts.algorithm.MinimumBoundingCircle.prototype.getCircle=function(){this.compute();if(this.centre===null){return this.input.getFactory().createPolygon(null,null)}var centrePoint=this.input.getFactory().createPoint(this.centre);if(this.radius===0){return centrePoint}return centrePoint.buffer(this.radius)};jsts.algorithm.MinimumBoundingCircle.prototype.getExtremalPoints=function(){this.compute();return this.extremalPts};jsts.algorithm.MinimumBoundingCircle.prototype.getCentre=function(){this.compute();return this.centre};jsts.algorithm.MinimumBoundingCircle.prototype.getRadius=function(){this.compute();return this.radius};jsts.algorithm.MinimumBoundingCircle.prototype.computeCentre=function(){switch(this.extremalPts.length){case 0:this.centre=null;break;case 1:this.centre=this.extremalPts[0];break;case 2:this.centre=new jsts.geom.Coordinate((this.extremalPts[0].x+this.extremalPts[1].x)/2,(this.extremalPts[0].y+this.extremalPts[1].y)/2);break;case 3:this.centre=jsts.geom.Triangle.circumcentre(this.extremalPts[0],this.extremalPts[1],this.extremalPts[2]);break}};jsts.algorithm.MinimumBoundingCircle.prototype.compute=function(){if(this.extremalPts!==null){return}this.computeCirclePoints();this.computeCentre();if(this.centre!==null){this.radius=this.centre.distance(this.extremalPts[0])}};jsts.algorithm.MinimumBoundingCircle.prototype.computeCirclePoints=function(){if(this.input.isEmpty()){this.extremalPts=[];return}var pts;if(this.input.getNumPoints()===1){pts=this.input.getCoordinates();this.extremalPts=[new jsts.geom.Coordinate(pts[0])];return}var convexHull=this.input.convexHull();var hullPts=convexHull.getCoordinates();pts=hullPts;if(hullPts[0].equals2D(hullPts[hullPts.length-1])){pts=[];jsts.geom.CoordinateArrays.copyDeep(hullPts,0,pts,0,hullPts.length-1)}if(pts.length<=2){this.extremalPts=jsts.geom.CoordinateArrays.copyDeep(pts);return}var P=jsts.algorithm.MinimumBoundingCircle.lowestPoint(pts);var Q=jsts.algorithm.MinimumBoundingCircle.pointWitMinAngleWithX(pts,P);for(var i=0;i<pts.length;i++){var R=jsts.algorithm.MinimumBoundingCircle.pointWithMinAngleWithSegment(pts,P,Q);if(jsts.algorithm.Angle.isObtuse(P,R,Q)){this.extremalPts=[new jsts.geom.Coordinate(P),new jsts.geom.Coordinate(Q)];return}if(jsts.algorithm.Angle.isObtuse(R,P,Q)){P=R;continue}if(jsts.algorithm.Angle.isObtuse(R,Q,P)){Q=R;continue}this.extremalPts=[new jsts.geom.Coordinate(P),new jsts.geom.Coordinate(Q),new jsts.geom.Coordinate(R)];return}throw new Error("Logic failure in Minimum Bounding Circle algorithm!")};jsts.algorithm.MinimumBoundingCircle.lowestPoint=function(pts){var min=pts[0];for(var i=1;i<pts.length;i++){if(pts[i].y<min.y){min=pts[i]}}return min};jsts.algorithm.MinimumBoundingCircle.pointWitMinAngleWithX=function(pts,P){var minSin=Number.MAX_VALUE;var minAngPt=null;for(var i=0;i<pts.length;i++){var p=pts[i];if(p===P)continue;var dx=p.x-P.x;var dy=p.y-P.y;if(dy<0)dy=-dy;var len=Math.sqrt(dx*dx+dy*dy);var sin=dy/len;if(sin<minSin){minSin=sin;minAngPt=p}}return minAngPt};jsts.algorithm.MinimumBoundingCircle.pointWithMinAngleWithSegment=function(pts,P,Q){var minAng=Number.MAX_VALUE;var minAngPt=null;for(var i=0;i<pts.length;i++){var p=pts[i];if(p===P)continue;if(p===Q)continue;var ang=jsts.algorithm.Angle.angleBetween(P,p,Q);if(ang<minAng){minAng=ang;minAngPt=p}}return minAngPt};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;i<pts.length;i++){roundPts[i]=new jsts.geom.Coordinate(Math.round((pts[i].x-this.offsetX)*this.scaleFactor),Math.round((pts[i].y-this.offsetY)*this.scaleFactor))}var roundPtsNoDup=jsts.geom.CoordinateArrays.removeRepeatedPoints(roundPts);return roundPtsNoDup};jsts.noding.ScaledNoder.prototype.rescale=function(segStrings){if(segStrings instanceof Array){this.rescale2(segStrings);return}for(var i=segStrings.iterator();i.hasNext();){var ss=i.next();this.rescale(ss.getCoordinates())}};jsts.noding.ScaledNoder.prototype.rescale2=function(pts){for(var i=0;i<pts.length;i++){pts[i].x=pts[i].x/this.scaleFactor+this.offsetX;pts[i].y=pts[i].y/this.scaleFactor+this.offsetY}};(function(){var ArrayList=javascript.util.ArrayList;jsts.geomgraph.index.SegmentIntersector=function(li,includeProper,recordIsolated){this.li=li;this.includeProper=includeProper;this.recordIsolated=recordIsolated};jsts.geomgraph.index.SegmentIntersector.isAdjacentSegments=function(i1,i2){return Math.abs(i1-i2)===1};jsts.geomgraph.index.SegmentIntersector.prototype._hasIntersection=false;jsts.geomgraph.index.SegmentIntersector.prototype.hasProper=false;jsts.geomgraph.index.SegmentIntersector.prototype.hasProperInterior=false;jsts.geomgraph.index.SegmentIntersector.prototype.properIntersectionPoint=null;jsts.geomgraph.index.SegmentIntersector.prototype.li=null;jsts.geomgraph.index.SegmentIntersector.prototype.includeProper=null;jsts.geomgraph.index.SegmentIntersector.prototype.recordIsolated=null;jsts.geomgraph.index.SegmentIntersector.prototype.isSelfIntersection=null;jsts.geomgraph.index.SegmentIntersector.prototype.numIntersections=0;jsts.geomgraph.index.SegmentIntersector.prototype.numTests=0;jsts.geomgraph.index.SegmentIntersector.prototype.bdyNodes=null;jsts.geomgraph.index.SegmentIntersector.prototype.setBoundaryNodes=function(bdyNodes0,bdyNodes1){this.bdyNodes=[];this.bdyNodes[0]=bdyNodes0;this.bdyNodes[1]=bdyNodes1};jsts.geomgraph.index.SegmentIntersector.prototype.getProperIntersectionPoint=function(){return this.properIntersectionPoint};jsts.geomgraph.index.SegmentIntersector.prototype.hasIntersection=function(){return this._hasIntersection};jsts.geomgraph.index.SegmentIntersector.prototype.hasProperIntersection=function(){return this.hasProper};jsts.geomgraph.index.SegmentIntersector.prototype.hasProperInteriorIntersection=function(){return this.hasProperInterior};jsts.geomgraph.index.SegmentIntersector.prototype.isTrivialIntersection=function(e0,segIndex0,e1,segIndex1){if(e0===e1){if(this.li.getIntersectionNum()===1){if(jsts.geomgraph.index.SegmentIntersector.isAdjacentSegments(segIndex0,segIndex1))return true;if(e0.isClosed()){var maxSegIndex=e0.getNumPoints()-1;if(segIndex0===0&&segIndex1===maxSegIndex||segIndex1===0&&segIndex0===maxSegIndex){return true}}}}return false};jsts.geomgraph.index.SegmentIntersector.prototype.addIntersections=function(e0,segIndex0,e1,segIndex1){if(e0===e1&&segIndex0===segIndex1)return;this.numTests++;var p00=e0.getCoordinates()[segIndex0];var p01=e0.getCoordinates()[segIndex0+1];var p10=e1.getCoordinates()[segIndex1];var p11=e1.getCoordinates()[segIndex1+1];this.li.computeIntersection(p00,p01,p10,p11);if(this.li.hasIntersection()){if(this.recordIsolated){e0.setIsolated(false);e1.setIsolated(false)}this.numIntersections++;if(!this.isTrivialIntersection(e0,segIndex0,e1,segIndex1)){this._hasIntersection=true;
if(this.includeProper||!this.li.isProper()){e0.addIntersections(this.li,segIndex0,0);e1.addIntersections(this.li,segIndex1,1)}if(this.li.isProper()){this.properIntersectionPoint=this.li.getIntersection(0).clone();this.hasProper=true;if(!this.isBoundaryPoint(this.li,this.bdyNodes))this.hasProperInterior=true}}}};jsts.geomgraph.index.SegmentIntersector.prototype.isBoundaryPoint=function(li,bdyNodes){if(bdyNodes===null)return false;if(bdyNodes instanceof Array){if(this.isBoundaryPoint(li,bdyNodes[0]))return true;if(this.isBoundaryPoint(li,bdyNodes[1]))return true;return false}else{for(var i=bdyNodes.iterator();i.hasNext();){var node=i.next();var pt=node.getCoordinate();if(li.isIntersection(pt))return true}return false}}})()},{}],18:[function(require,module,exports){(function(global){(function(){var e=this;function f(a,b){var c=a.split("."),d=e;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var t;c.length&&(t=c.shift());)c.length||void 0===b?d=d[t]?d[t]:d[t]={}:d[t]=b}function g(a,b){function c(){}c.prototype=b.prototype;a.q=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.p=function(a,c,O){var M=Array.prototype.slice.call(arguments,2);return b.prototype[c].apply(a,M)}}function h(a){this.message=a||""}g(h,Error);f("javascript.util.EmptyStackException",h);h.prototype.name="EmptyStackException";function k(a){this.message=a||""}g(k,Error);f("javascript.util.IndexOutOfBoundsException",k);k.prototype.name="IndexOutOfBoundsException";function l(){}f("javascript.util.Iterator",l);l.prototype.hasNext=l.prototype.c;l.prototype.next=l.prototype.next;l.prototype.remove=l.prototype.remove;function m(){}f("javascript.util.Collection",m);function n(){}g(n,m);f("javascript.util.List",n);function p(){}f("javascript.util.Map",p);function q(a){this.message=a||""}g(q,Error);f("javascript.util.NoSuchElementException",q);q.prototype.name="NoSuchElementException";function r(a){this.message=a||""}g(r,Error);r.prototype.name="OperationNotSupported";function s(a){this.a=[];a instanceof m&&this.e(a)}g(s,n);f("javascript.util.ArrayList",s);s.prototype.a=null;s.prototype.add=function(a){this.a.push(a);return!0};s.prototype.add=s.prototype.add;s.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};s.prototype.addAll=s.prototype.e;s.prototype.set=function(a,b){var c=this.a[a];this.a[a]=b;return c};s.prototype.set=s.prototype.set;s.prototype.f=function(){return new u(this)};s.prototype.iterator=s.prototype.f;s.prototype.get=function(a){if(0>a||a>=this.size())throw new k;return this.a[a]};s.prototype.get=s.prototype.get;s.prototype.g=function(){return 0===this.a.length};s.prototype.isEmpty=s.prototype.g;s.prototype.size=function(){return this.a.length};s.prototype.size=s.prototype.size;s.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};s.prototype.toArray=s.prototype.h;s.prototype.remove=function(a){for(var b=!1,c=0,d=this.a.length;c<d;c++)if(this.a[c]===a){this.a.splice(c,1);b=!0;break}return b};s.prototype.remove=s.prototype.remove;function u(a){this.j=a}f("$jscomp.scope.Iterator_",u);u.prototype.j=null;u.prototype.b=0;u.prototype.next=function(){if(this.b===this.j.size())throw new q;return this.j.get(this.b++)};u.prototype.next=u.prototype.next;u.prototype.c=function(){return this.b<this.j.size()?!0:!1};u.prototype.hasNext=u.prototype.c;u.prototype.remove=function(){throw new r};u.prototype.remove=u.prototype.remove;function v(){}f("javascript.util.Arrays",v);v.sort=function(){var a=arguments[0],b,c,d;if(1===arguments.length)a.sort();else if(2===arguments.length)c=arguments[1],d=function(a,b){return c.compare(a,b)},a.sort(d);else if(3===arguments.length)for(b=a.slice(arguments[1],arguments[2]),b.sort(),d=a.slice(0,arguments[1]).concat(b,a.slice(arguments[2],a.length)),a.splice(0,a.length),b=0;b<d.length;b++)a.push(d[b]);else if(4===arguments.length)for(b=a.slice(arguments[1],arguments[2]),c=arguments[3],d=function(a,b){return c.compare(a,b)},b.sort(d),d=a.slice(0,arguments[1]).concat(b,a.slice(arguments[2],a.length)),a.splice(0,a.length),b=0;b<d.length;b++)a.push(d[b])};v.asList=function(a){for(var b=new s,c=0,d=a.length;c<d;c++)b.add(a[c]);return b};function w(){this.i={}}g(w,p);f("javascript.util.HashMap",w);w.prototype.i=null;w.prototype.get=function(a){return this.i[a]||null};w.prototype.get=w.prototype.get;w.prototype.put=function(a,b){return this.i[a]=b};w.prototype.put=w.prototype.put;w.prototype.m=function(){var a=new s,b;for(b in this.i)this.i.hasOwnProperty(b)&&a.add(this.i[b]);return a};w.prototype.values=w.prototype.m;w.prototype.size=function(){return this.m().size()};w.prototype.size=w.prototype.size;function x(){}g(x,m);f("javascript.util.Set",x);function y(a){this.a=[];a instanceof m&&this.e(a)}g(y,x);f("javascript.util.HashSet",y);y.prototype.a=null;y.prototype.contains=function(a){for(var b=0,c=this.a.length;b<c;b++)if(this.a[b]===a)return!0;return!1};y.prototype.contains=y.prototype.contains;y.prototype.add=function(a){if(this.contains(a))return!1;this.a.push(a);return!0};y.prototype.add=y.prototype.add;y.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};y.prototype.addAll=y.prototype.e;y.prototype.remove=function(){throw new r};y.prototype.remove=y.prototype.remove;y.prototype.size=function(){return this.a.length};y.prototype.g=function(){return 0===this.a.length};y.prototype.isEmpty=y.prototype.g;y.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};y.prototype.toArray=y.prototype.h;y.prototype.f=function(){return new z(this)};y.prototype.iterator=y.prototype.f;function z(a){this.k=a}f("$jscomp.scope.Iterator_$1",z);z.prototype.k=null;z.prototype.b=0;z.prototype.next=function(){if(this.b===this.k.size())throw new q;return this.k.a[this.b++]};z.prototype.next=z.prototype.next;z.prototype.c=function(){return this.b<this.k.size()?!0:!1};z.prototype.hasNext=z.prototype.c;z.prototype.remove=function(){throw new r};z.prototype.remove=z.prototype.remove;function A(){}g(A,p);f("javascript.util.SortedMap",A);function B(){}g(B,x);f("javascript.util.SortedSet",B);function C(){this.a=[]}g(C,n);f("javascript.util.Stack",C);C.prototype.a=null;C.prototype.push=function(a){this.a.push(a);return a};C.prototype.push=C.prototype.push;C.prototype.pop=function(){if(0===this.a.length)throw new h;return this.a.pop()};C.prototype.pop=C.prototype.pop;C.prototype.o=function(){if(0===this.a.length)throw new h;return this.a[this.a.length-1]};C.prototype.peek=C.prototype.o;C.prototype.empty=function(){return 0===this.a.length?!0:!1};C.prototype.empty=C.prototype.empty;C.prototype.g=function(){return this.empty()};C.prototype.isEmpty=C.prototype.g;C.prototype.search=function(a){return this.a.indexOf(a)};C.prototype.search=C.prototype.search;C.prototype.size=function(){return this.a.length};C.prototype.size=C.prototype.size;C.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};C.prototype.toArray=C.prototype.h;function D(a){return null==a?null:a.parent}function E(a,b){null!==a&&(a.color=b)}function F(a){return null==a?null:a.left}function G(a){return null==a?null:a.right}function H(){this.d=null;this.n=0}g(H,A);f("javascript.util.TreeMap",H);H.prototype.get=function(a){for(var b=this.d;null!==b;){var c=a.compareTo(b.key);if(0>c)b=b.left;else if(0<c)b=b.right;else return b.value}return null};H.prototype.get=H.prototype.get;H.prototype.put=function(a,b){if(null===this.d)return this.d={key:a,value:b,left:null,right:null,parent:null,color:0},this.n=1,null;var c=this.d,d,t;do if(d=c,t=a.compareTo(c.key),0>t)c=c.left;else if(0<t)c=c.right;else return d=c.value,c.value=b,d;while(null!==c);c={key:a,left:null,right:null,value:b,parent:d,color:0};0>t?d.left=c:d.right=c;for(c.color=1;null!=c&&c!=this.d&&1==c.parent.color;)D(c)==F(D(D(c)))?(d=G(D(D(c))),1==(null==d?0:d.color)?(E(D(c),0),E(d,0),E(D(D(c)),1),c=D(D(c))):(c==G(D(c))&&(c=D(c),I(this,c)),E(D(c),0),E(D(D(c)),1),J(this,D(D(c))))):(d=F(D(D(c))),1==(null==d?0:d.color)?(E(D(c),0),E(d,0),E(D(D(c)),1),c=D(D(c))):(c==F(D(c))&&(c=D(c),J(this,c)),E(D(c),0),E(D(D(c)),1),I(this,D(D(c)))));this.d.color=0;this.n++;return null};H.prototype.put=H.prototype.put;H.prototype.m=function(){var a=new s,b;b=this.d;if(null!=b)for(;null!=b.left;)b=b.left;if(null!==b)for(a.add(b.value);null!==(b=K(b));)a.add(b.value);return a};H.prototype.values=H.prototype.m;function I(a,b){if(null!=b){var c=b.right;b.right=c.left;null!=c.left&&(c.left.parent=b);c.parent=b.parent;null==b.parent?a.d=c:b.parent.left==b?b.parent.left=c:b.parent.right=c;c.left=b;b.parent=c}}function J(a,b){if(null!=b){var c=b.left;b.left=c.right;null!=c.right&&(c.right.parent=b);c.parent=b.parent;null==b.parent?a.d=c:b.parent.right==b?b.parent.right=c:b.parent.left=c;c.right=b;b.parent=c}}function K(a){if(null===a)return null;if(null!==a.right)for(var b=a.right;null!==b.left;)b=b.left;else for(b=a.parent;null!==b&&a===b.right;)a=b,b=b.parent;return b}H.prototype.size=function(){return this.n};H.prototype.size=H.prototype.size;function L(a){this.a=[];a instanceof m&&this.e(a)}g(L,B);f("javascript.util.TreeSet",L);L.prototype.a=null;L.prototype.contains=function(a){for(var b=0,c=this.a.length;b<c;b++)if(0===this.a[b].compareTo(a))return!0;return!1};L.prototype.contains=L.prototype.contains;L.prototype.add=function(a){if(this.contains(a))return!1;for(var b=0,c=this.a.length;b<c;b++)if(1===this.a[b].compareTo(a))return this.a.splice(b,0,a),!0;this.a.push(a);return!0};L.prototype.add=L.prototype.add;L.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};L.prototype.addAll=L.prototype.e;L.prototype.remove=function(){throw new r};L.prototype.remove=L.prototype.remove;L.prototype.size=function(){return this.a.length};L.prototype.size=L.prototype.size;L.prototype.g=function(){return 0===this.a.length};L.prototype.isEmpty=L.prototype.g;L.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};L.prototype.toArray=L.prototype.h;L.prototype.f=function(){return new N(this)};L.prototype.iterator=L.prototype.f;function N(a){this.l=a}f("$jscomp.scope.Iterator_$2",N);N.prototype.l=null;N.prototype.b=0;N.prototype.next=function(){if(this.b===this.l.size())throw new q;return this.l.a[this.b++]};N.prototype.next=N.prototype.next;N.prototype.c=function(){return this.b<this.l.size()?!0:!1};N.prototype.hasNext=N.prototype.c;N.prototype.remove=function(){throw new r};N.prototype.remove=N.prototype.remove;"undefined"!==typeof global&&(global.javascript={},global.javascript.util={},global.javascript.util.ArrayList=s,global.javascript.util.Arrays=v,global.javascript.util.Collection=m,global.javascript.util.EmptyStackException=h,global.javascript.util.HashMap=w,global.javascript.util.HashSet=y,global.javascript.util.IndexOutOfBoundsException=k,global.javascript.util.Iterator=l,global.javascript.util.List=n,global.javascript.util.Map=p,global.javascript.util.NoSuchElementException=q,global.javascript.util.OperationNotSupported=r,global.javascript.util.Set=x,global.javascript.util.SortedMap=A,global.javascript.util.SortedSet=B,global.javascript.util.Stack=C,global.javascript.util.TreeMap=H,global.javascript.util.TreeSet=L)}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],19:[function(require,module,exports){require("./dist/javascript.util-node.min.js")},{"./dist/javascript.util-node.min.js":18}],20:[function(require,module,exports){var extent=require("turf-extent"),point=require("turf-point");module.exports=function(layer,done){var ext=extent(layer);var x=(ext[0]+ext[2])/2;var y=(ext[1]+ext[3])/2;return point([x,y])}},{"turf-extent":69,"turf-point":101}],21:[function(require,module,exports){var each=require("turf-meta").coordEach;var point=require("turf-point");module.exports=function(features){var xSum=0,ySum=0,len=0;each(features,function(coord){xSum+=coord[0];ySum+=coord[1];len++},true);return point([xSum/len,ySum/len])}},{"turf-meta":22,"turf-point":101}],22:[function(require,module,exports){function coordEach(layer,callback,excludeWrapCoord){var i,j,k,g,geometry,stopG,coords,geometryMaybeCollection,wrapShrink=0,isGeometryCollection,isFeatureCollection=layer.type==="FeatureCollection",isFeature=layer.type==="Feature",stop=isFeatureCollection?layer.features.length:1;for(i=0;i<stop;i++){geometryMaybeCollection=isFeatureCollection?layer.features[i].geometry:isFeature?layer.geometry:layer;isGeometryCollection=geometryMaybeCollection.type==="GeometryCollection";stopG=isGeometryCollection?geometryMaybeCollection.geometries.length:1;for(g=0;g<stopG;g++){geometry=isGeometryCollection?geometryMaybeCollection.geometries[g]:geometryMaybeCollection;coords=geometry.coordinates;wrapShrink=excludeWrapCoord&&(geometry.type==="Polygon"||geometry.type==="MultiPolygon")?1:0;if(geometry.type==="Point"){callback(coords)}else if(geometry.type==="LineString"||geometry.type==="MultiPoint"){for(j=0;j<coords.length;j++)callback(coords[j])}else if(geometry.type==="Polygon"||geometry.type==="MultiLineString"){for(j=0;j<coords.length;j++)for(k=0;k<coords[j].length-wrapShrink;k++)callback(coords[j][k])}else if(geometry.type==="MultiPolygon"){for(j=0;j<coords.length;j++)for(k=0;k<coords[j].length;k++)for(l=0;l<coords[j][k].length-wrapShrink;l++)callback(coords[j][k][l])}else{throw new Error("Unknown Geometry Type")}}}}module.exports.coordEach=coordEach;function coordReduce(layer,callback,memo,excludeWrapCoord){coordEach(layer,function(coord){memo=callback(memo,coord)},excludeWrapCoord);return memo}module.exports.coordReduce=coordReduce;function propEach(layer,callback){var i;switch(layer.type){case"FeatureCollection":features=layer.features;for(i=0;i<layer.features.length;i++){callback(layer.features[i].properties)}break;case"Feature":callback(layer.properties);break}}module.exports.propEach=propEach;function propReduce(layer,callback,memo){propEach(layer,function(prop){memo=callback(memo,prop)});return memo}module.exports.propReduce=propReduce},{}],23:[function(require,module,exports){module.exports=function(fc){var type=fc.features[0].geometry.type;var geometries=fc.features.map(function(f){return f.geometry});switch(type){case"Point":return{type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:pluckCoods(geometries)}};case"LineString":return{type:"Feature",properties:{},geometry:{type:"MultiLineString",coordinates:pluckCoods(geometries)}};case"Polygon":return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:pluckCoods(geometries)}};default:return fc}};function pluckCoods(multi){return multi.map(function(geom){return geom.coordinates})}},{}],24:[function(require,module,exports){var t={};t.tin=require("turf-tin");t.merge=require("turf-merge");t.distance=require("turf-distance");t.point=require("turf-point");module.exports=function(points,maxEdge,units){if(typeof maxEdge!=="number")throw new Error("maxEdge parameter is required");if(typeof units!=="string")throw new Error("units parameter is required");var tinPolys=t.tin(points);var filteredPolys=tinPolys.features.filter(filterTriangles);tinPolys.features=filteredPolys;function filterTriangles(triangle){var pt1=t.point(triangle.geometry.coordinates[0][0]);var pt2=t.point(triangle.geometry.coordinates[0][1]);var pt3=t.point(triangle.geometry.coordinates[0][2]);var dist1=t.distance(pt1,pt2,units);var dist2=t.distance(pt2,pt3,units);var dist3=t.distance(pt1,pt3,units);return dist1<=maxEdge&&dist2<=maxEdge&&dist3<=maxEdge}return t.merge(tinPolys)}},{"turf-distance":59,"turf-merge":92,"turf-point":101,"turf-tin":117}],25:[function(require,module,exports){var each=require("turf-meta").coordEach,convexHull=require("convex-hull"),polygon=require("turf-polygon");module.exports=function(fc){var points=[];each(fc,function(coord){points.push(coord)});var hull=convexHull(points);var ring=[];for(var i=0;i<hull.length;i++){ring.push(points[hull[i][0]])}ring.push(points[hull[hull.length-1][1]]);return polygon([ring])}},{"convex-hull":26,"turf-meta":54,"turf-polygon":102}],26:[function(require,module,exports){"use strict";var convexHull1d=require("./lib/ch1d");var convexHull2d=require("./lib/ch2d");var convexHullnd=require("./lib/chnd");module.exports=convexHull;function convexHull(points){var n=points.length;if(n===0){return[]}else if(n===1){return[[0]]}var d=points[0].length;if(d===0){return[]}else if(d===1){return convexHull1d(points)}else if(d===2){return convexHull2d(points)}return convexHullnd(points,d)}},{"./lib/ch1d":27,"./lib/ch2d":28,"./lib/chnd":29}],27:[function(require,module,exports){"use strict";module.exports=convexHull1d;function convexHull1d(points){var lo=0;var hi=0;for(var i=1;i<points.length;++i){if(points[i][0]<points[lo][0]){lo=i}if(points[i][0]>points[hi][0]){hi=i}}if(lo<hi){return[[lo],[hi]]}else if(lo>hi){return[[hi],[lo]]}else{return[[lo]]}}},{}],28:[function(require,module,exports){"use strict";module.exports=convexHull2D;var monotoneHull=require("monotone-convex-hull-2d");function convexHull2D(points){var hull=monotoneHull(points);var h=hull.length;if(h<=2){return[]}var edges=new Array(h);var a=hull[h-1];for(var i=0;i<h;++i){var b=hull[i];edges[i]=[a,b];a=b}return edges}},{"monotone-convex-hull-2d":47}],29:[function(require,module,exports){"use strict";module.exports=convexHullnD;var ich=require("incremental-convex-hull");var aff=require("affine-hull");function permute(points,front){var n=points.length;var npoints=new Array(n);for(var i=0;i<front.length;++i){npoints[i]=points[front[i]]}var ptr=front.length;for(var i=0;i<n;++i){if(front.indexOf(i)<0){npoints[ptr++]=points[i]}}return npoints}function invPermute(cells,front){var nc=cells.length;var nf=front.length;for(var i=0;i<nc;++i){var c=cells[i];for(var j=0;j<c.length;++j){var x=c[j];if(x<nf){c[j]=front[x]}else{x=x-nf;for(var k=0;k<nf;++k){if(x>=front[k]){x+=1}}c[j]=x}}}return cells}function convexHullnD(points,d){try{return ich(points,true)}catch(e){var ah=aff(points);if(ah.length<=d){return[]}var npoints=permute(points,ah);var nhull=ich(npoints,true);return invPermute(nhull,ah)}}},{"affine-hull":30,"incremental-convex-hull":37}],30:[function(require,module,exports){"use strict";module.exports=affineHull;var orient=require("robust-orientation");function linearlyIndependent(points,d){var nhull=new Array(d+1);for(var i=0;i<points.length;++i){nhull[i]=points[i]}for(var i=0;i<=points.length;++i){for(var j=points.length;j<=d;++j){var x=new Array(d);for(var k=0;k<d;++k){x[k]=Math.pow(j+1-i,k)}nhull[j]=x}var o=orient.apply(void 0,nhull);if(o){return true}}return false}function affineHull(points){var n=points.length;if(n===0){return[]}if(n===1){return[0]}var d=points[0].length;var frame=[points[0]];var index=[0];for(var i=1;i<n;++i){frame.push(points[i]);if(!linearlyIndependent(frame,d)){frame.pop();continue}index.push(i);if(index.length===d+1){return index}}return index}},{"robust-orientation":36}],31:[function(require,module,exports){"use strict";module.exports=fastTwoSum;function fastTwoSum(a,b,result){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;if(result){result[0]=ar+br;result[1]=x;return result}return[ar+br,x]}},{}],32:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var twoSum=require("two-sum");module.exports=scaleLinearExpansion;function scaleLinearExpansion(e,scale){var n=e.length;if(n===1){var ts=twoProduct(e[0],scale);if(ts[0]){return ts}return[ts[1]]}var g=new Array(2*n);var q=[.1,.1];var t=[.1,.1];var count=0;twoProduct(e[0],scale,q);if(q[0]){g[count++]=q[0]}for(var i=1;i<n;++i){twoProduct(e[i],scale,t);var pq=q[1];twoSum(pq,t[0],q);if(q[0]){g[count++]=q[0]}var a=t[1];var b=q[1];var x=a+b;var bv=x-a;var y=b-bv;q[1]=x;if(y){g[count++]=y}}if(q[1]){g[count++]=q[1]}if(count===0){g[count++]=0}g.length=count;return g}},{"two-product":35,"two-sum":31}],33:[function(require,module,exports){"use strict";module.exports=robustSubtract;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function robustSubtract(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],-f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=-f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=-f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],34:[function(require,module,exports){"use strict";module.exports=linearExpansionSum;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function linearExpansionSum(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],35:[function(require,module,exports){"use strict";module.exports=twoProduct;var SPLITTER=+(Math.pow(2,27)+1);function twoProduct(a,b,result){var x=a*b;var c=SPLITTER*a;var abig=c-a;var ahi=c-abig;var alo=a-ahi;var d=SPLITTER*b;var bbig=d-b;var bhi=d-bbig;var blo=b-bhi;var err1=x-ahi*bhi;var err2=err1-alo*bhi;var err3=err2-ahi*blo;var y=alo*blo-err3;if(result){result[0]=y;result[1]=x;return result}return[y,x]}},{}],36:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var robustSum=require("robust-sum");var robustScale=require("robust-scale");var robustSubtract=require("robust-subtract");var NUM_EXPAND=5;var EPSILON=1.1102230246251565e-16;var ERRBOUND3=(3+16*EPSILON)*EPSILON;var ERRBOUND4=(7+56*EPSILON)*EPSILON;function cofactor(m,c){var result=new Array(m.length-1);for(var i=1;i<m.length;++i){var r=result[i-1]=new Array(m.length-1);for(var j=0,k=0;j<m.length;++j){if(j===c){continue}r[k++]=m[i][j]}}return result}function matrix(n){var result=new Array(n);for(var i=0;i<n;++i){result[i]=new Array(n);for(var j=0;j<n;++j){result[i][j]=["m",j,"[",n-i-1,"]"].join("")}}return result}function sign(n){if(n&1){return"-"}return""}function generateSum(expr){if(expr.length===1){return expr[0]}else if(expr.length===2){return["sum(",expr[0],",",expr[1],")"].join("")}else{var m=expr.length>>1;return["sum(",generateSum(expr.slice(0,m)),",",generateSum(expr.slice(m)),")"].join("")}}function determinant(m){if(m.length===2){return[["sum(prod(",m[0][0],",",m[1][1],"),prod(-",m[0][1],",",m[1][0],"))"].join("")]}else{var expr=[];for(var i=0;i<m.length;++i){expr.push(["scale(",generateSum(determinant(cofactor(m,i))),",",sign(i),m[0][i],")"].join(""))}return expr}}function orientation(n){var pos=[];var neg=[];var m=matrix(n);var args=[];for(var i=0;i<n;++i){if((i&1)===0){pos.push.apply(pos,determinant(cofactor(m,i)))}else{neg.push.apply(neg,determinant(cofactor(m,i)))}args.push("m"+i)}var posExpr=generateSum(pos);var negExpr=generateSum(neg);var funcName="orientation"+n+"Exact";var code=["function ",funcName,"(",args.join(),"){var p=",posExpr,",n=",negExpr,",d=sub(p,n);return d[d.length-1];};return ",funcName].join("");var proc=new Function("sum","prod","scale","sub",code);return proc(robustSum,twoProduct,robustScale,robustSubtract)}var orientation3Exact=orientation(3);var orientation4Exact=orientation(4);var CACHED=[function orientation0(){return 0},function orientation1(){return 0},function orientation2(a,b){return b[0]-a[0]},function orientation3(a,b,c){var l=(a[1]-c[1])*(b[0]-c[0]);var r=(a[0]-c[0])*(b[1]-c[1]);var det=l-r;var s;if(l>0){if(r<=0){return det}else{s=l+r}}else if(l<0){if(r>=0){return det}else{s=-(l+r)}}else{return det}var tol=ERRBOUND3*s;if(det>=tol||det<=-tol){return det}return orientation3Exact(a,b,c)},function orientation4(a,b,c,d){var adx=a[0]-d[0];var bdx=b[0]-d[0];var cdx=c[0]-d[0];var ady=a[1]-d[1];var bdy=b[1]-d[1];var cdy=c[1]-d[1];var adz=a[2]-d[2];var bdz=b[2]-d[2];var cdz=c[2]-d[2];var bdxcdy=bdx*cdy;var cdxbdy=cdx*bdy;var cdxady=cdx*ady;var adxcdy=adx*cdy;var adxbdy=adx*bdy;var bdxady=bdx*ady;var det=adz*(bdxcdy-cdxbdy)+bdz*(cdxady-adxcdy)+cdz*(adxbdy-bdxady);var permanent=(Math.abs(bdxcdy)+Math.abs(cdxbdy))*Math.abs(adz)+(Math.abs(cdxady)+Math.abs(adxcdy))*Math.abs(bdz)+(Math.abs(adxbdy)+Math.abs(bdxady))*Math.abs(cdz);var tol=ERRBOUND4*permanent;if(det>tol||-det>tol){return det}return orientation4Exact(a,b,c,d)}];function slowOrient(args){var proc=CACHED[args.length];if(!proc){proc=CACHED[args.length]=orientation(args.length)}return proc.apply(undefined,args)}function generateOrientationProc(){while(CACHED.length<=NUM_EXPAND){CACHED.push(orientation(CACHED.length))}var args=[];var procArgs=["slow"];for(var i=0;i<=NUM_EXPAND;++i){args.push("a"+i);procArgs.push("o"+i)}var code=["function getOrientation(",args.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(var i=2;i<=NUM_EXPAND;++i){code.push("case ",i,":return o",i,"(",args.slice(0,i).join(),");")}code.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation");procArgs.push(code.join(""));var proc=Function.apply(undefined,procArgs);module.exports=proc.apply(undefined,[slowOrient].concat(CACHED));for(var i=0;i<=NUM_EXPAND;++i){module.exports[i]=CACHED[i]}}generateOrientationProc()},{"robust-scale":32,"robust-subtract":33,"robust-sum":34,"two-product":35}],37:[function(require,module,exports){"use strict";module.exports=incrementalConvexHull;var orient=require("robust-orientation");var compareCell=require("simplicial-complex").compareCells;function compareInt(a,b){return a-b}function Simplex(vertices,adjacent,boundary){this.vertices=vertices;this.adjacent=adjacent;this.boundary=boundary;this.lastVisited=-1}Simplex.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1];this.vertices[1]=t;var u=this.adjacent[0];this.adjacent[0]=this.adjacent[1];this.adjacent[1]=u};function GlueFacet(vertices,cell,index){this.vertices=vertices;this.cell=cell;this.index=index}function compareGlue(a,b){return compareCell(a.vertices,b.vertices)}function bakeOrient(d){var code=["function orient(){var tuple=this.tuple;return test("];for(var i=0;i<=d;++i){if(i>0){code.push(",")}code.push("tuple[",i,"]")}code.push(")}return orient");var proc=new Function("test",code.join(""));var test=orient[d+1];if(!test){test=orient}return proc(test)}var BAKED=[];function Triangulation(dimension,vertices,simplices){this.dimension=dimension;this.vertices=vertices;this.simplices=simplices;this.interior=simplices.filter(function(c){return!c.boundary});this.tuple=new Array(dimension+1);for(var i=0;i<=dimension;++i){this.tuple[i]=this.vertices[i]}var o=BAKED[dimension];if(!o){o=BAKED[dimension]=bakeOrient(dimension)}this.orient=o}var proto=Triangulation.prototype;proto.handleBoundaryDegeneracy=function(cell,point){var d=this.dimension;var n=this.vertices.length-1;var tuple=this.tuple;var verts=this.vertices;var toVisit=[cell];cell.lastVisited=-n;while(toVisit.length>0){cell=toVisit.pop();var cellVerts=cell.vertices;var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited<=-n){continue}var nv=neighbor.vertices;for(var j=0;j<=d;++j){var vv=nv[j];if(vv<0){tuple[j]=point}else{tuple[j]=verts[vv]}}var o=this.orient();if(o>0){return neighbor}neighbor.lastVisited=-n;if(o===0){toVisit.push(neighbor)}}}return null};proto.walk=function(point,random){var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;var initIndex=random?this.interior.length*Math.random()|0:this.interior.length-1;var cell=this.interior[initIndex];outerLoop:while(!cell.boundary){var cellVerts=cell.vertices;var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){tuple[i]=verts[cellVerts[i]]}cell.lastVisited=n;for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(neighbor.lastVisited>=n){continue}var prev=tuple[i];tuple[i]=point;var o=this.orient();tuple[i]=prev;if(o<0){cell=neighbor;continue outerLoop}else{if(!neighbor.boundary){neighbor.lastVisited=n}else{neighbor.lastVisited=-n}}}return}return cell};proto.addPeaks=function(point,cell){var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;var interior=this.interior;var simplices=this.simplices;var tovisit=[cell];cell.lastVisited=n;cell.vertices[cell.vertices.indexOf(-1)]=n;cell.boundary=false;interior.push(cell);var glueFacets=[];while(tovisit.length>0){var cell=tovisit.pop();var cellVerts=cell.vertices;var cellAdj=cell.adjacent;var indexOfN=cellVerts.indexOf(n);if(indexOfN<0){continue}for(var i=0;i<=d;++i){if(i===indexOfN){continue}var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited>=n){continue}var nv=neighbor.vertices;if(neighbor.lastVisited!==-n){var indexOfNeg1=0;for(var j=0;j<=d;++j){if(nv[j]<0){indexOfNeg1=j;tuple[j]=point}else{tuple[j]=verts[nv[j]]}}var o=this.orient();if(o>0){nv[indexOfNeg1]=n;neighbor.boundary=false;interior.push(neighbor);tovisit.push(neighbor);neighbor.lastVisited=n;continue}else{neighbor.lastVisited=-n}}var na=neighbor.adjacent;var vverts=cellVerts.slice();var vadj=cellAdj.slice();var ncell=new Simplex(vverts,vadj,true);simplices.push(ncell);var opposite=na.indexOf(cell);if(opposite<0){continue}na[opposite]=ncell;vadj[indexOfN]=neighbor;vverts[i]=-1;vadj[i]=cell;cellAdj[i]=ncell;ncell.flip();for(var j=0;j<=d;++j){var uu=vverts[j];if(uu<0||uu===n){continue}var nface=new Array(d-1);var nptr=0;for(var k=0;k<=d;++k){var vv=vverts[k];if(vv<0||k===j){continue}nface[nptr++]=vv}glueFacets.push(new GlueFacet(nface,ncell,j))}}}glueFacets.sort(compareGlue);for(var i=0;i+1<glueFacets.length;i+=2){var a=glueFacets[i];var b=glueFacets[i+1];var ai=a.index;var bi=b.index;if(ai<0||bi<0){continue}a.cell.adjacent[a.index]=b.cell;b.cell.adjacent[b.index]=a.cell}};proto.insert=function(point,random){var verts=this.vertices;verts.push(point);var cell=this.walk(point,random);if(!cell){return}var d=this.dimension;var tuple=this.tuple;for(var i=0;i<=d;++i){var vv=cell.vertices[i];if(vv<0){tuple[i]=point}else{tuple[i]=verts[vv]}}var o=this.orient(tuple);if(o<0){return}else if(o===0){cell=this.handleBoundaryDegeneracy(cell,point);if(!cell){return}}this.addPeaks(point,cell);
};proto.boundary=function(){var d=this.dimension;var boundary=[];var cells=this.simplices;var nc=cells.length;for(var i=0;i<nc;++i){var c=cells[i];if(c.boundary){var bcell=new Array(d);var cv=c.vertices;var ptr=0;var parity=0;for(var j=0;j<=d;++j){if(cv[j]>=0){bcell[ptr++]=cv[j]}else{parity=j&1}}if(parity===(d&1)){var t=bcell[0];bcell[0]=bcell[1];bcell[1]=t}boundary.push(bcell)}}return boundary};function incrementalConvexHull(points,randomSearch){var n=points.length;if(n===0){throw new Error("Must have at least d+1 points")}var d=points[0].length;if(n<=d){throw new Error("Must input at least d+1 points")}var initialSimplex=points.slice(0,d+1);var o=orient.apply(void 0,initialSimplex);if(o===0){throw new Error("Input not in general position")}var initialCoords=new Array(d+1);for(var i=0;i<=d;++i){initialCoords[i]=i}if(o<0){initialCoords[0]=1;initialCoords[1]=0}var initialCell=new Simplex(initialCoords,new Array(d+1),false);var boundary=initialCell.adjacent;var list=new Array(d+2);for(var i=0;i<=d;++i){var verts=initialCoords.slice();for(var j=0;j<=d;++j){if(j===i){verts[j]=-1}}var t=verts[0];verts[0]=verts[1];verts[1]=t;var cell=new Simplex(verts,new Array(d+1),true);boundary[i]=cell;list[i]=cell}list[d+1]=initialCell;for(var i=0;i<=d;++i){var verts=boundary[i].vertices;var adj=boundary[i].adjacent;for(var j=0;j<=d;++j){var v=verts[j];if(v<0){adj[j]=initialCell;continue}for(var k=0;k<=d;++k){if(boundary[k].vertices.indexOf(v)<0){adj[j]=boundary[k]}}}}var triangles=new Triangulation(d,initialSimplex,list);var useRandom=!!randomSearch;for(var i=d+1;i<n;++i){triangles.insert(points[i],useRandom)}return triangles.boundary()}},{"robust-orientation":43,"simplicial-complex":46}],38:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],39:[function(require,module,exports){arguments[4][32][0].apply(exports,arguments)},{dup:32,"two-product":42,"two-sum":38}],40:[function(require,module,exports){arguments[4][33][0].apply(exports,arguments)},{dup:33}],41:[function(require,module,exports){arguments[4][34][0].apply(exports,arguments)},{dup:34}],42:[function(require,module,exports){arguments[4][35][0].apply(exports,arguments)},{dup:35}],43:[function(require,module,exports){arguments[4][36][0].apply(exports,arguments)},{dup:36,"robust-scale":39,"robust-subtract":40,"robust-sum":41,"two-product":42}],44:[function(require,module,exports){"use strict";"use restrict";var INT_BITS=32;exports.INT_BITS=INT_BITS;exports.INT_MAX=2147483647;exports.INT_MIN=-1<<INT_BITS-1;exports.sign=function(v){return(v>0)-(v<0)};exports.abs=function(v){var mask=v>>INT_BITS-1;return(v^mask)-mask};exports.min=function(x,y){return y^(x^y)&-(x<y)};exports.max=function(x,y){return x^(x^y)&-(x<y)};exports.isPow2=function(v){return!(v&v-1)&&!!v};exports.log2=function(v){var r,shift;r=(v>65535)<<4;v>>>=r;shift=(v>255)<<3;v>>>=shift;r|=shift;shift=(v>15)<<2;v>>>=shift;r|=shift;shift=(v>3)<<1;v>>>=shift;r|=shift;return r|v>>1};exports.log10=function(v){return v>=1e9?9:v>=1e8?8:v>=1e7?7:v>=1e6?6:v>=1e5?5:v>=1e4?4:v>=1e3?3:v>=100?2:v>=10?1:0};exports.popCount=function(v){v=v-(v>>>1&1431655765);v=(v&858993459)+(v>>>2&858993459);return(v+(v>>>4)&252645135)*16843009>>>24};function countTrailingZeros(v){var c=32;v&=-v;if(v)c--;if(v&65535)c-=16;if(v&16711935)c-=8;if(v&252645135)c-=4;if(v&858993459)c-=2;if(v&1431655765)c-=1;return c}exports.countTrailingZeros=countTrailingZeros;exports.nextPow2=function(v){v+=v===0;--v;v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v+1};exports.prevPow2=function(v){v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v-(v>>>1)};exports.parity=function(v){v^=v>>>16;v^=v>>>8;v^=v>>>4;v&=15;return 27030>>>v&1};var REVERSE_TABLE=new Array(256);(function(tab){for(var i=0;i<256;++i){var v=i,r=i,s=7;for(v>>>=1;v;v>>>=1){r<<=1;r|=v&1;--s}tab[i]=r<<s&255}})(REVERSE_TABLE);exports.reverse=function(v){return REVERSE_TABLE[v&255]<<24|REVERSE_TABLE[v>>>8&255]<<16|REVERSE_TABLE[v>>>16&255]<<8|REVERSE_TABLE[v>>>24&255]};exports.interleave2=function(x,y){x&=65535;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y&=65535;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1};exports.deinterleave2=function(v,n){v=v>>>n&1431655765;v=(v|v>>>1)&858993459;v=(v|v>>>2)&252645135;v=(v|v>>>4)&16711935;v=(v|v>>>16)&65535;return v<<16>>16};exports.interleave3=function(x,y,z){x&=1023;x=(x|x<<16)&4278190335;x=(x|x<<8)&251719695;x=(x|x<<4)&3272356035;x=(x|x<<2)&1227133513;y&=1023;y=(y|y<<16)&4278190335;y=(y|y<<8)&251719695;y=(y|y<<4)&3272356035;y=(y|y<<2)&1227133513;x|=y<<1;z&=1023;z=(z|z<<16)&4278190335;z=(z|z<<8)&251719695;z=(z|z<<4)&3272356035;z=(z|z<<2)&1227133513;return x|z<<2};exports.deinterleave3=function(v,n){v=v>>>n&1227133513;v=(v|v>>>2)&3272356035;v=(v|v>>>4)&251719695;v=(v|v>>>8)&4278190335;v=(v|v>>>16)&1023;return v<<22>>22};exports.nextCombination=function(v){var t=v|v-1;return t+1|(~t&-~t)-1>>>countTrailingZeros(v)+1}},{}],45:[function(require,module,exports){"use strict";"use restrict";module.exports=UnionFind;function UnionFind(count){this.roots=new Array(count);this.ranks=new Array(count);for(var i=0;i<count;++i){this.roots[i]=i;this.ranks[i]=0}}var proto=UnionFind.prototype;Object.defineProperty(proto,"length",{get:function(){return this.roots.length}});proto.makeSet=function(){var n=this.roots.length;this.roots.push(n);this.ranks.push(0);return n};proto.find=function(x){var x0=x;var roots=this.roots;while(roots[x]!==x){x=roots[x]}while(roots[x0]!==x){var y=roots[x0];roots[x0]=x;x0=y}return x};proto.link=function(x,y){var xr=this.find(x),yr=this.find(y);if(xr===yr){return}var ranks=this.ranks,roots=this.roots,xd=ranks[xr],yd=ranks[yr];if(xd<yd){roots[xr]=yr}else if(yd<xd){roots[yr]=xr}else{roots[yr]=xr;++ranks[xr]}}},{}],46:[function(require,module,exports){"use strict";"use restrict";var bits=require("bit-twiddle"),UnionFind=require("union-find");function dimension(cells){var d=0,max=Math.max;for(var i=0,il=cells.length;i<il;++i){d=max(d,cells[i].length)}return d-1}exports.dimension=dimension;function countVertices(cells){var vc=-1,max=Math.max;for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,jl=c.length;j<jl;++j){vc=max(vc,c[j])}}return vc+1}exports.countVertices=countVertices;function cloneCells(cells){var ncells=new Array(cells.length);for(var i=0,il=cells.length;i<il;++i){ncells[i]=cells[i].slice(0)}return ncells}exports.cloneCells=cloneCells;function compareCells(a,b){var n=a.length,t=a.length-b.length,min=Math.min;if(t){return t}switch(n){case 0:return 0;case 1:return a[0]-b[0];case 2:var d=a[0]+a[1]-b[0]-b[1];if(d){return d}return min(a[0],a[1])-min(b[0],b[1]);case 3:var l1=a[0]+a[1],m1=b[0]+b[1];d=l1+a[2]-(m1+b[2]);if(d){return d}var l0=min(a[0],a[1]),m0=min(b[0],b[1]),d=min(l0,a[2])-min(m0,b[2]);if(d){return d}return min(l0+a[2],l1)-min(m0+b[2],m1);default:var as=a.slice(0);as.sort();var bs=b.slice(0);bs.sort();for(var i=0;i<n;++i){t=as[i]-bs[i];if(t){return t}}return 0}}exports.compareCells=compareCells;function compareZipped(a,b){return compareCells(a[0],b[0])}function normalize(cells,attr){if(attr){var len=cells.length;var zipped=new Array(len);for(var i=0;i<len;++i){zipped[i]=[cells[i],attr[i]]}zipped.sort(compareZipped);for(var i=0;i<len;++i){cells[i]=zipped[i][0];attr[i]=zipped[i][1]}return cells}else{cells.sort(compareCells);return cells}}exports.normalize=normalize;function unique(cells){if(cells.length===0){return[]}var ptr=1,len=cells.length;for(var i=1;i<len;++i){var a=cells[i];if(compareCells(a,cells[i-1])){if(i===ptr){ptr++;continue}cells[ptr++]=a}}cells.length=ptr;return cells}exports.unique=unique;function findCell(cells,c){var lo=0,hi=cells.length-1,r=-1;while(lo<=hi){var mid=lo+hi>>1,s=compareCells(cells[mid],c);if(s<=0){if(s===0){r=mid}lo=mid+1}else if(s>0){hi=mid-1}}return r}exports.findCell=findCell;function incidence(from_cells,to_cells){var index=new Array(from_cells.length);for(var i=0,il=index.length;i<il;++i){index[i]=[]}var b=[];for(var i=0,n=to_cells.length;i<n;++i){var c=to_cells[i];var cl=c.length;for(var k=1,kn=1<<cl;k<kn;++k){b.length=bits.popCount(k);var l=0;for(var j=0;j<cl;++j){if(k&1<<j){b[l++]=c[j]}}var idx=findCell(from_cells,b);if(idx<0){continue}while(true){index[idx++].push(i);if(idx>=from_cells.length||compareCells(from_cells[idx],b)!==0){break}}}}return index}exports.incidence=incidence;function dual(cells,vertex_count){if(!vertex_count){return incidence(unique(skeleton(cells,0)),cells,0)}var res=new Array(vertex_count);for(var i=0;i<vertex_count;++i){res[i]=[]}for(var i=0,len=cells.length;i<len;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){res[c[j]].push(i)}}return res}exports.dual=dual;function explode(cells){var result=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i],cl=c.length|0;for(var j=1,jl=1<<cl;j<jl;++j){var b=[];for(var k=0;k<cl;++k){if(j>>>k&1){b.push(c[k])}}result.push(b)}}return normalize(result)}exports.explode=explode;function skeleton(cells,n){if(n<0){return[]}var result=[],k0=(1<<n+1)-1;for(var i=0;i<cells.length;++i){var c=cells[i];for(var k=k0;k<1<<c.length;k=bits.nextCombination(k)){var b=new Array(n+1),l=0;for(var j=0;j<c.length;++j){if(k&1<<j){b[l++]=c[j]}}result.push(b)}}return normalize(result)}exports.skeleton=skeleton;function boundary(cells){var res=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){var b=new Array(c.length-1);for(var k=0,l=0;k<cl;++k){if(k!==j){b[l++]=c[k]}}res.push(b)}}return normalize(res)}exports.boundary=boundary;function connectedComponents_dense(cells,vertex_count){var labels=new UnionFind(vertex_count);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){for(var k=j+1;k<c.length;++k){labels.link(c[j],c[k])}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(cells[i][0]);if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents_sparse(cells){var vertices=unique(normalize(skeleton(cells,0))),labels=new UnionFind(vertices.length);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){var vj=findCell(vertices,[c[j]]);for(var k=j+1;k<c.length;++k){labels.link(vj,findCell(vertices,[c[k]]))}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(findCell(vertices,[cells[i][0]]));if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents(cells,vertex_count){if(vertex_count){return connectedComponents_dense(cells,vertex_count)}return connectedComponents_sparse(cells)}exports.connectedComponents=connectedComponents},{"bit-twiddle":44,"union-find":45}],47:[function(require,module,exports){"use strict";module.exports=monotoneConvexHull2D;var orient=require("robust-orientation")[3];function monotoneConvexHull2D(points){var n=points.length;if(n<3){var result=new Array(n);for(var i=0;i<n;++i){result[i]=i}if(n===2&&points[0][0]===points[1][0]&&points[0][1]===points[1][1]){return[0]}return result}var sorted=new Array(n);for(var i=0;i<n;++i){sorted[i]=i}sorted.sort(function(a,b){var d=points[a][0]-points[b][0];if(d){return d}return points[a][1]-points[b][1]});var lower=[sorted[0],sorted[1]];var upper=[sorted[0],sorted[1]];for(var i=2;i<n;++i){var idx=sorted[i];var p=points[idx];var m=lower.length;while(m>1&&orient(points[lower[m-2]],points[lower[m-1]],p)<=0){m-=1;lower.pop()}lower.push(idx);m=upper.length;while(m>1&&orient(points[upper[m-2]],points[upper[m-1]],p)>=0){m-=1;upper.pop()}upper.push(idx)}var result=new Array(upper.length+lower.length-2);var ptr=0;for(var i=0,nl=lower.length;i<nl;++i){result[ptr++]=lower[i]}for(var j=upper.length-2;j>0;--j){result[ptr++]=upper[j]}return result}},{"robust-orientation":53}],48:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],49:[function(require,module,exports){arguments[4][32][0].apply(exports,arguments)},{dup:32,"two-product":52,"two-sum":48}],50:[function(require,module,exports){arguments[4][33][0].apply(exports,arguments)},{dup:33}],51:[function(require,module,exports){arguments[4][34][0].apply(exports,arguments)},{dup:34}],52:[function(require,module,exports){arguments[4][35][0].apply(exports,arguments)},{dup:35}],53:[function(require,module,exports){arguments[4][36][0].apply(exports,arguments)},{dup:36,"robust-scale":49,"robust-subtract":50,"robust-sum":51,"two-product":52}],54:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{dup:22}],55:[function(require,module,exports){var inside=require("turf-inside");module.exports=function(polyFC,ptFC,outField,done){for(var i=0;i<polyFC.features.length;i++){var poly=polyFC.features[i];if(!poly.properties)poly.properties={};var values=0;for(var j=0;j<ptFC.features.length;j++){var pt=ptFC.features[j];if(inside(pt,poly)){values++}}poly.properties[outField]=values}return polyFC}},{"turf-inside":75}],56:[function(require,module,exports){var point=require("turf-point");module.exports=function(point1,distance,bearing,units){var coordinates1=point1.geometry.coordinates;var longitude1=toRad(coordinates1[0]);var latitude1=toRad(coordinates1[1]);var bearing_rad=toRad(bearing);var R=0;switch(units){case"miles":R=3960;break;case"kilometers":R=6373;break;case"degrees":R=57.2957795;break;case"radians":R=1;break}var latitude2=Math.asin(Math.sin(latitude1)*Math.cos(distance/R)+Math.cos(latitude1)*Math.sin(distance/R)*Math.cos(bearing_rad));var longitude2=longitude1+Math.atan2(Math.sin(bearing_rad)*Math.sin(distance/R)*Math.cos(latitude1),Math.cos(distance/R)-Math.sin(latitude1)*Math.sin(latitude2));return point([toDeg(longitude2),toDeg(latitude2)])};function toRad(degree){return degree*Math.PI/180}function toDeg(rad){return rad*180/Math.PI}},{"turf-point":101}],57:[function(require,module,exports){var ss=require("simple-statistics");var inside=require("turf-inside");module.exports=function(polyFC,ptFC,inField,outField,done){polyFC.features.forEach(function(poly){if(!poly.properties){poly.properties={}}var values=[];ptFC.features.forEach(function(pt){if(inside(pt,poly)){values.push(pt.properties[inField])}});poly.properties[outField]=ss.standard_deviation(values)});return polyFC}},{"simple-statistics":58,"turf-inside":75}],58:[function(require,module,exports){(function(){var ss={};if(typeof module!=="undefined"){module.exports=ss}else{this.ss=ss}function linear_regression(){var linreg={},data=[];linreg.data=function(x){if(!arguments.length)return data;data=x.slice();return linreg};linreg.mb=function(){var m,b;var data_length=data.length;if(data_length===1){m=0;b=data[0][1]}else{var sum_x=0,sum_y=0,sum_xx=0,sum_xy=0;var point,x,y;for(var i=0;i<data_length;i++){point=data[i];x=point[0];y=point[1];sum_x+=x;sum_y+=y;sum_xx+=x*x;sum_xy+=x*y}m=(data_length*sum_xy-sum_x*sum_y)/(data_length*sum_xx-sum_x*sum_x);b=sum_y/data_length-m*sum_x/data_length}return{m:m,b:b}};linreg.m=function(){return linreg.mb().m};linreg.b=function(){return linreg.mb().b};linreg.line=function(){var mb=linreg.mb(),m=mb.m,b=mb.b;return function(x){return b+m*x}};return linreg}function r_squared(data,f){if(data.length<2)return 1;var sum=0,average;for(var i=0;i<data.length;i++){sum+=data[i][1]}average=sum/data.length;var sum_of_squares=0;for(var j=0;j<data.length;j++){sum_of_squares+=Math.pow(average-data[j][1],2)}var err=0;for(var k=0;k<data.length;k++){err+=Math.pow(data[k][1]-f(data[k][0]),2)}return 1-err/sum_of_squares}function bayesian(){var bayes_model={},total_count=0,data={};bayes_model.train=function(item,category){if(!data[category])data[category]={};for(var k in item){var v=item[k];if(data[category][k]===undefined)data[category][k]={};if(data[category][k][v]===undefined)data[category][k][v]=0;data[category][k][item[k]]++}total_count++};bayes_model.score=function(item){var odds={},category;for(var k in item){var v=item[k];for(category in data){if(odds[category]===undefined)odds[category]={};if(data[category][k]){odds[category][k+"_"+v]=(data[category][k][v]||0)/total_count}else{odds[category][k+"_"+v]=0}}}var odds_sums={};for(category in odds){for(var combination in odds[category]){if(odds_sums[category]===undefined)odds_sums[category]=0;odds_sums[category]+=odds[category][combination]}}return odds_sums};return bayes_model}function sum(x){var value=0;for(var i=0;i<x.length;i++){value+=x[i]}return value}function mean(x){if(x.length===0)return null;return sum(x)/x.length}function geometric_mean(x){if(x.length===0)return null;var value=1;for(var i=0;i<x.length;i++){if(x[i]<=0)return null;value*=x[i]}return Math.pow(value,1/x.length)}function harmonic_mean(x){if(x.length===0)return null;var reciprocal_sum=0;for(var i=0;i<x.length;i++){if(x[i]<=0)return null;reciprocal_sum+=1/x[i]}return x.length/reciprocal_sum}function root_mean_square(x){if(x.length===0)return null;var sum_of_squares=0;for(var i=0;i<x.length;i++){sum_of_squares+=Math.pow(x[i],2)}return Math.sqrt(sum_of_squares/x.length)}function min(x){var value;for(var i=0;i<x.length;i++){if(x[i]<value||value===undefined)value=x[i]}return value}function max(x){var value;for(var i=0;i<x.length;i++){if(x[i]>value||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;i<x.length;i++){deviations.push(Math.pow(x[i]-mean_value,2))}return mean(deviations)}function standard_deviation(x){if(x.length===0)return null;return Math.sqrt(variance(x))}function sum_nth_power_deviations(x,n){var mean_value=mean(x),sum=0;for(var i=0;i<x.length;i++){sum+=Math.pow(x[i]-mean_value,n)}return sum}function sample_variance(x){if(x.length<=1)return null;var sum_squared_deviations_value=sum_nth_power_deviations(x,2);return sum_squared_deviations_value/(x.length-1)}function sample_standard_deviation(x){if(x.length<=1)return null;return Math.sqrt(sample_variance(x))}function sample_covariance(x,y){if(x.length<=1||x.length!=y.length){return null}var xmean=mean(x),ymean=mean(y),sum=0;for(var i=0;i<x.length;i++){sum+=(x[i]-xmean)*(y[i]-ymean)}return sum/(x.length-1)}function sample_correlation(x,y){var cov=sample_covariance(x,y),xstd=sample_standard_deviation(x),ystd=sample_standard_deviation(y);if(cov===null||xstd===null||ystd===null){return null}return cov/xstd/ystd}function median(x){if(x.length===0)return null;var sorted=x.slice().sort(function(a,b){return a-b});if(sorted.length%2===1){return sorted[(sorted.length-1)/2]}else{var a=sorted[sorted.length/2-1];var b=sorted[sorted.length/2];return(a+b)/2}}function mode(x){if(x.length===0)return null;else if(x.length===1)return x[0];var sorted=x.slice().sort(function(a,b){return a-b});var last=sorted[0],value,max_seen=0,seen_this=1;for(var i=1;i<sorted.length+1;i++){if(sorted[i]!==last){if(seen_this>max_seen){max_seen=seen_this;value=last}seen_this=1;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 chunk(sample,chunkSize){var output=[];if(chunkSize<=0){return null}for(var start=0;start<sample.length;start+=chunkSize){output.push(sample.slice(start,start+chunkSize))}return output}function shuffle_in_place(sample,randomSource){randomSource=randomSource||Math.random;var length=sample.length;var temporary;var index;while(length>0){index=Math.floor(randomSource()*length--);temporary=sample[length];sample[length]=sample[index];sample[index]=temporary}return sample}function shuffle(sample,randomSource){sample=sample.slice();return shuffle_in_place(sample.slice(),randomSource)}function sample(array,n,randomSource){var shuffled=shuffle(array,randomSource);return shuffled.slice(0,n)}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;i<p.length;i++){results[i]=quantile_sorted(sorted,p[i])}return results}else{return quantile_sorted(sorted,p)}}function quantile_sorted(sample,p){var idx=sample.length*p;if(p<0||p>1){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<x.length;i++){median_absolute_deviations.push(Math.abs(x[i]-median_value))}return median(median_absolute_deviations)}function jenksMatrices(data,n_classes){var lower_class_limits=[],variance_combinations=[],i,j,variance=0;for(i=0;i<data.length+1;i++){var tmp1=[],tmp2=[];for(j=0;j<n_classes+1;j++){tmp1.push(0);tmp2.push(0)}lower_class_limits.push(tmp1);variance_combinations.push(tmp2)}for(i=1;i<n_classes+1;i++){lower_class_limits[1][i]=1;variance_combinations[1][i]=0;for(j=2;j<data.length+1;j++){variance_combinations[j][i]=Infinity}}for(var l=2;l<data.length+1;l++){var sum=0,sum_squares=0,w=0,i4=0;for(var m=1;m<l+1;m++){var lower_class_limit=l-m+1,val=data[lower_class_limit-1];w++;sum+=val;sum_squares+=val*val;variance=sum_squares-sum*sum/w;i4=lower_class_limit-1;if(i4!==0){for(j=2;j<n_classes+1;j++){if(variance_combinations[l][j]>=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,kclass=[],countNum=n_classes;kclass[n_classes]=data[data.length-1];while(countNum>0){kclass[countNum-1]=data[lower_class_limits[k][countNum]-1];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 error_function(x){var t=1/(1+.5*Math.abs(x));var tau=t*Math.exp(-Math.pow(x,2)-1.26551223+1.00002368*t+.37409196*Math.pow(t,2)+.09678418*Math.pow(t,3)-.18628806*Math.pow(t,4)+.27886807*Math.pow(t,5)-1.13520398*Math.pow(t,6)+1.48851587*Math.pow(t,7)-.82215223*Math.pow(t,8)+.17087277*Math.pow(t,9));if(x>=0){return 1-tau}else{return tau-1}}function cumulative_std_normal_probability(z){var absZ=Math.abs(z),index=Math.min(Math.round(absZ*100),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}var epsilon=1e-4;function factorial(n){if(n<0){return null}var accumulator=1;for(var i=2;i<=n;i++){accumulator*=i}return accumulator}function bernoulli_distribution(p){if(p<0||p>1){return null}return binomial_distribution(1,p)}function binomial_distribution(trials,probability){if(probability<0||probability>1||trials<=0||trials%1!==0){return null}function probability_mass(x,trials,probability){return factorial(trials)/(factorial(x)*factorial(trials-x))*(Math.pow(probability,x)*Math.pow(1-probability,trials-x))}var x=0,cumulative_probability=0,cells={};do{cells[x]=probability_mass(x,trials,probability);cumulative_probability+=cells[x];x++}while(cumulative_probability<1-epsilon);return cells}function poisson_distribution(lambda){if(lambda<=0){return null}var x=0,cumulative_probability=0,cells={};function probability_mass(x,lambda){return Math.pow(Math.E,-lambda)*Math.pow(lambda,x)/factorial(x)}do{cells[x]=probability_mass(x,lambda);cumulative_probability+=cells[x];x++}while(cumulative_probability<1-epsilon);return cells}var chi_squared_distribution_table={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}};function chi_squared_goodness_of_fit(data,distribution_type,significance){var input_mean=mean(data),chi_squared=0,degrees_of_freedom,c=1,hypothesized_distribution=distribution_type(input_mean),observed_frequencies=[],expected_frequencies=[],k;for(var i=0;i<data.length;i++){if(observed_frequencies[data[i]]===undefined){observed_frequencies[data[i]]=0}observed_frequencies[data[i]]++}for(i=0;i<observed_frequencies.length;i++){if(observed_frequencies[i]===undefined){observed_frequencies[i]=0}}for(k in hypothesized_distribution){if(k in observed_frequencies){expected_frequencies[k]=hypothesized_distribution[k]*data.length}}for(k=expected_frequencies.length-1;k>=0;k--){if(expected_frequencies[k]<3){expected_frequencies[k-1]+=expected_frequencies[k];expected_frequencies.pop();observed_frequencies[k-1]+=observed_frequencies[k];observed_frequencies.pop()}}for(k=0;k<observed_frequencies.length;k++){chi_squared+=Math.pow(observed_frequencies[k]-expected_frequencies[k],2)/expected_frequencies[k]}degrees_of_freedom=observed_frequencies.length-c-1;return chi_squared_distribution_table[degrees_of_freedom][significance]<chi_squared}function mixin(array){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","root_mean_square"];function wrap(method){return function(){var args=Array.prototype.slice.apply(arguments);args.unshift(this);return ss[method].apply(ss,args)}}var extending;if(array){extending=array.slice()}else{extending=Array.prototype}for(var i=0;i<arrayMethods.length;i++){Object.defineProperty(extending,arrayMethods[i],{value:wrap(arrayMethods[i]),configurable:true,enumerable:false,writable:true})}return extending}ss.linear_regression=linear_regression;ss.standard_deviation=standard_deviation;ss.r_squared=r_squared;ss.median=median;ss.mean=mean;ss.mode=mode;ss.min=min;ss.max=max;ss.sum=sum;ss.quantile=quantile;ss.quantile_sorted=quantile_sorted;ss.iqr=iqr;ss.mad=mad;ss.chunk=chunk;ss.shuffle=shuffle;ss.shuffle_in_place=shuffle_in_place;ss.sample=sample;ss.sample_covariance=sample_covariance;ss.sample_correlation=sample_correlation;ss.sample_variance=sample_variance;ss.sample_standard_deviation=sample_standard_deviation;ss.sample_skewness=sample_skewness;ss.geometric_mean=geometric_mean;ss.harmonic_mean=harmonic_mean;ss.root_mean_square=root_mean_square;ss.variance=variance;ss.t_test=t_test;ss.t_test_two_sample=t_test_two_sample;ss.jenksMatrices=jenksMatrices;ss.jenksBreaks=jenksBreaks;ss.jenks=jenks;ss.bayesian=bayesian;ss.epsilon=epsilon;ss.factorial=factorial;ss.bernoulli_distribution=bernoulli_distribution;ss.binomial_distribution=binomial_distribution;ss.poisson_distribution=poisson_distribution;ss.chi_squared_goodness_of_fit=chi_squared_goodness_of_fit;ss.z_score=z_score;ss.cumulative_std_normal_probability=cumulative_std_normal_probability;ss.standard_normal_table=standard_normal_table;ss.error_function=error_function;ss.average=mean;ss.interquartile_range=iqr;ss.mixin=mixin;ss.median_absolute_deviation=mad;ss.rms=root_mean_square;ss.erf=error_function})(this)},{}],59:[function(require,module,exports){var invariant=require("turf-invariant");module.exports=function(point1,point2,units){invariant.featureOf(point1,"Point","distance");invariant.featureOf(point2,"Point","distance");var coordinates1=point1.geometry.coordinates;var coordinates2=point2.geometry.coordinates;var dLat=toRad(coordinates2[1]-coordinates1[1]);var dLon=toRad(coordinates2[0]-coordinates1[0]);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;switch(units){case"miles":R=3960;break;case"kilometers":R=6373;break;case"degrees":R=57.2957795;break;case"radians":R=1;break;case undefined:R=6373;break;default:throw new Error('unknown option given to "units"')}var distance=R*c;return distance};function toRad(degree){return degree*Math.PI/180}},{"turf-invariant":60}],60:[function(require,module,exports){module.exports.geojsonType=geojsonType;module.exports.collectionOf=collectionOf;module.exports.featureOf=featureOf;function geojsonType(value,type,name){if(!type||!name)throw new Error("type and name required");if(!value||value.type!==type){throw new Error("Invalid input to "+name+": must be a "+type+", given "+value.type)}}function featureOf(value,type,name){if(!name)throw new Error(".featureOf() requires a name");if(!value||value.type!=="Feature"||!value.geometry){throw new Error("Invalid input to "+name+", Feature with geometry required")}if(!value.geometry||value.geometry.type!==type){throw new Error("Invalid input to "+name+": must be a "+type+", given "+value.geometry.type)}}function collectionOf(value,type,name){if(!name)throw new Error(".collectionOf() requires a name");if(!value||value.type!=="FeatureCollection"){throw new Error("Invalid input to "+name+", FeatureCollection required")}for(var i=0;i<value.features.length;i++){var feature=value.features[i];if(!feature||feature.type!=="Feature"||!feature.geometry){throw new Error("Invalid input to "+name+", Feature with geometry required")}if(!feature.geometry||feature.geometry.type!==type){throw new Error("Invalid input to "+name+": must be a "+type+", given "+feature.geometry.type)}}}},{}],61:[function(require,module,exports){var extent=require("turf-extent");var bboxPolygon=require("turf-bbox-polygon");module.exports=function(features,done){var bbox=extent(features);var poly=bboxPolygon(bbox);return poly}},{"turf-bbox-polygon":11,"turf-extent":69}],62:[function(require,module,exports){var jsts=require("jsts");module.exports=function(p1,p2,done){var poly1=JSON.parse(JSON.stringify(p1));var poly2=JSON.parse(JSON.stringify(p2));if(poly1.type!=="Feature"){poly1={type:"Feature",properties:{},geometry:poly1}}if(poly2.type!=="Feature"){poly2={type:"Feature",properties:{},geometry: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);poly1.geometry=erased;if(poly1.geometry.type==="GeometryCollection"&&poly1.geometry.geometries.length===0){return}else{return{type:"Feature",properties:poly1.properties,geometry:erased}}}},{jsts:63}],63:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{"./lib/jsts":64,dup:16,"javascript.util":66}],64:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17}],65:[function(require,module,exports){(function(global){(function(){var e=this;function f(a,b){var c=a.split("."),d=e;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var t;c.length&&(t=c.shift());)c.length||void 0===b?d=d[t]?d[t]:d[t]={}:d[t]=b}function g(a,b){function c(){}c.prototype=b.prototype;a.q=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.p=function(a,c,O){var M=Array.prototype.slice.call(arguments,2);return b.prototype[c].apply(a,M)}}function h(a){this.message=a||""}g(h,Error);f("javascript.util.EmptyStackException",h);h.prototype.name="EmptyStackException";function k(a){this.message=a||""}g(k,Error);f("javascript.util.IndexOutOfBoundsException",k);k.prototype.name="IndexOutOfBoundsException";function l(){}f("javascript.util.Iterator",l);l.prototype.hasNext=l.prototype.c;l.prototype.next=l.prototype.next;l.prototype.remove=l.prototype.remove;function m(){}f("javascript.util.Collection",m);function n(){}g(n,m);f("javascript.util.List",n);function p(){}f("javascript.util.Map",p);function q(a){this.message=a||""}g(q,Error);f("javascript.util.NoSuchElementException",q);q.prototype.name="NoSuchElementException";function r(a){this.message=a||""}g(r,Error);r.prototype.name="OperationNotSupported";function s(a){this.a=[];a instanceof m&&this.e(a)}g(s,n);f("javascript.util.ArrayList",s);s.prototype.a=null;s.prototype.add=function(a){this.a.push(a);return!0};s.prototype.add=s.prototype.add;s.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};s.prototype.addAll=s.prototype.e;s.prototype.set=function(a,b){var c=this.a[a];this.a[a]=b;return c};s.prototype.set=s.prototype.set;s.prototype.f=function(){return new u(this)};s.prototype.iterator=s.prototype.f;s.prototype.get=function(a){if(0>a||a>=this.size())throw new k;return this.a[a]};s.prototype.get=s.prototype.get;s.prototype.g=function(){return 0===this.a.length};s.prototype.isEmpty=s.prototype.g;s.prototype.size=function(){return this.a.length};s.prototype.size=s.prototype.size;s.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};s.prototype.toArray=s.prototype.h;s.prototype.remove=function(a){for(var b=!1,c=0,d=this.a.length;c<d;c++)if(this.a[c]===a){this.a.splice(c,1);b=!0;break}return b};s.prototype.remove=s.prototype.remove;function u(a){this.j=a}f("$jscomp.scope.Iterator_",u);u.prototype.j=null;u.prototype.b=0;u.prototype.next=function(){if(this.b===this.j.size())throw new q;return this.j.get(this.b++)};u.prototype.next=u.prototype.next;u.prototype.c=function(){return this.b<this.j.size()?!0:!1};u.prototype.hasNext=u.prototype.c;u.prototype.remove=function(){throw new r};u.prototype.remove=u.prototype.remove;function v(){}f("javascript.util.Arrays",v);v.sort=function(){var a=arguments[0],b,c,d;if(1===arguments.length)a.sort();else if(2===arguments.length)c=arguments[1],d=function(a,b){return c.compare(a,b)},a.sort(d);else if(3===arguments.length)for(b=a.slice(arguments[1],arguments[2]),b.sort(),d=a.slice(0,arguments[1]).concat(b,a.slice(arguments[2],a.length)),a.splice(0,a.length),b=0;b<d.length;b++)a.push(d[b]);else if(4===arguments.length)for(b=a.slice(arguments[1],arguments[2]),c=arguments[3],d=function(a,b){return c.compare(a,b)},b.sort(d),d=a.slice(0,arguments[1]).concat(b,a.slice(arguments[2],a.length)),a.splice(0,a.length),b=0;b<d.length;b++)a.push(d[b])};v.asList=function(a){for(var b=new s,c=0,d=a.length;c<d;c++)b.add(a[c]);return b};function w(){this.i={}}g(w,p);f("javascript.util.HashMap",w);w.prototype.i=null;w.prototype.get=function(a){return this.i[a]||null};w.prototype.get=w.prototype.get;w.prototype.put=function(a,b){return this.i[a]=b};w.prototype.put=w.prototype.put;w.prototype.m=function(){var a=new s,b;for(b in this.i)this.i.hasOwnProperty(b)&&a.add(this.i[b]);return a};w.prototype.values=w.prototype.m;w.prototype.size=function(){return this.m().size()};w.prototype.size=w.prototype.size;function x(){}g(x,m);f("javascript.util.Set",x);function y(a){this.a=[];a instanceof m&&this.e(a)}g(y,x);f("javascript.util.HashSet",y);y.prototype.a=null;y.prototype.contains=function(a){for(var b=0,c=this.a.length;b<c;b++)if(this.a[b]===a)return!0;return!1};y.prototype.contains=y.prototype.contains;y.prototype.add=function(a){if(this.contains(a))return!1;this.a.push(a);return!0};y.prototype.add=y.prototype.add;y.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};y.prototype.addAll=y.prototype.e;y.prototype.remove=function(){throw new r};y.prototype.remove=y.prototype.remove;y.prototype.size=function(){return this.a.length};y.prototype.g=function(){return 0===this.a.length};y.prototype.isEmpty=y.prototype.g;y.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};y.prototype.toArray=y.prototype.h;y.prototype.f=function(){return new z(this)};y.prototype.iterator=y.prototype.f;function z(a){this.k=a}f("$jscomp.scope.Iterator_$1",z);z.prototype.k=null;z.prototype.b=0;z.prototype.next=function(){if(this.b===this.k.size())throw new q;return this.k.a[this.b++]};z.prototype.next=z.prototype.next;z.prototype.c=function(){return this.b<this.k.size()?!0:!1};z.prototype.hasNext=z.prototype.c;z.prototype.remove=function(){throw new r};z.prototype.remove=z.prototype.remove;function A(){}g(A,p);f("javascript.util.SortedMap",A);function B(){}g(B,x);f("javascript.util.SortedSet",B);function C(){this.a=[]}g(C,n);f("javascript.util.Stack",C);C.prototype.a=null;C.prototype.push=function(a){this.a.push(a);return a};C.prototype.push=C.prototype.push;C.prototype.pop=function(){if(0===this.a.length)throw new h;return this.a.pop()};C.prototype.pop=C.prototype.pop;C.prototype.o=function(){if(0===this.a.length)throw new h;return this.a[this.a.length-1]};C.prototype.peek=C.prototype.o;C.prototype.empty=function(){return 0===this.a.length?!0:!1};C.prototype.empty=C.prototype.empty;C.prototype.g=function(){return this.empty()};C.prototype.isEmpty=C.prototype.g;C.prototype.search=function(a){return this.a.indexOf(a)};C.prototype.search=C.prototype.search;C.prototype.size=function(){return this.a.length};C.prototype.size=C.prototype.size;C.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};C.prototype.toArray=C.prototype.h;function D(a){return null==a?null:a.parent}function E(a,b){null!==a&&(a.color=b)}function F(a){return null==a?null:a.left}function G(a){return null==a?null:a.right}function H(){this.d=null;this.n=0}g(H,A);f("javascript.util.TreeMap",H);H.prototype.get=function(a){for(var b=this.d;null!==b;){var c=a.compareTo(b.key);if(0>c)b=b.left;else if(0<c)b=b.right;else return b.value}return null};H.prototype.get=H.prototype.get;H.prototype.put=function(a,b){if(null===this.d)return this.d={key:a,value:b,left:null,right:null,parent:null,color:0},this.n=1,null;var c=this.d,d,t;do if(d=c,t=a.compareTo(c.key),0>t)c=c.left;else if(0<t)c=c.right;else return d=c.value,c.value=b,d;while(null!==c);c={key:a,left:null,right:null,value:b,parent:d,color:0};0>t?d.left=c:d.right=c;for(c.color=1;null!=c&&c!=this.d&&1==c.parent.color;)D(c)==F(D(D(c)))?(d=G(D(D(c))),1==(null==d?0:d.color)?(E(D(c),0),E(d,0),E(D(D(c)),1),c=D(D(c))):(c==G(D(c))&&(c=D(c),I(this,c)),E(D(c),0),E(D(D(c)),1),J(this,D(D(c))))):(d=F(D(D(c))),1==(null==d?0:d.color)?(E(D(c),0),E(d,0),E(D(D(c)),1),c=D(D(c))):(c==F(D(c))&&(c=D(c),J(this,c)),E(D(c),0),E(D(D(c)),1),I(this,D(D(c)))));this.d.color=0;this.n++;return null};H.prototype.put=H.prototype.put;H.prototype.m=function(){var a=new s,b;b=this.d;if(null!=b)for(;null!=b.left;)b=b.left;if(null!==b)for(a.add(b.value);null!==(b=K(b));)a.add(b.value);return a};H.prototype.values=H.prototype.m;function I(a,b){if(null!=b){var c=b.right;b.right=c.left;null!=c.left&&(c.left.parent=b);c.parent=b.parent;null==b.parent?a.d=c:b.parent.left==b?b.parent.left=c:b.parent.right=c;c.left=b;b.parent=c}}function J(a,b){if(null!=b){var c=b.left;b.left=c.right;null!=c.right&&(c.right.parent=b);c.parent=b.parent;null==b.parent?a.d=c:b.parent.right==b?b.parent.right=c:b.parent.left=c;c.right=b;b.parent=c}}function K(a){if(null===a)return null;if(null!==a.right)for(var b=a.right;null!==b.left;)b=b.left;else for(b=a.parent;null!==b&&a===b.right;)a=b,b=b.parent;return b}H.prototype.size=function(){return this.n};H.prototype.size=H.prototype.size;function L(a){this.a=[];a instanceof m&&this.e(a)}g(L,B);f("javascript.util.TreeSet",L);L.prototype.a=null;L.prototype.contains=function(a){for(var b=0,c=this.a.length;b<c;b++)if(0===this.a[b].compareTo(a))return!0;return!1};L.prototype.contains=L.prototype.contains;L.prototype.add=function(a){if(this.contains(a))return!1;for(var b=0,c=this.a.length;b<c;b++)if(1===this.a[b].compareTo(a))return this.a.splice(b,0,a),!0;this.a.push(a);return!0};L.prototype.add=L.prototype.add;L.prototype.e=function(a){for(a=a.f();a.c();)this.add(a.next());return!0};L.prototype.addAll=L.prototype.e;L.prototype.remove=function(){throw new r};L.prototype.remove=L.prototype.remove;L.prototype.size=function(){return this.a.length};L.prototype.size=L.prototype.size;L.prototype.g=function(){return 0===this.a.length};L.prototype.isEmpty=L.prototype.g;L.prototype.h=function(){for(var a=[],b=0,c=this.a.length;b<c;b++)a.push(this.a[b]);return a};L.prototype.toArray=L.prototype.h;L.prototype.f=function(){return new N(this)};L.prototype.iterator=L.prototype.f;function N(a){this.l=a}f("$jscomp.scope.Iterator_$2",N);N.prototype.l=null;N.prototype.b=0;N.prototype.next=function(){if(this.b===this.l.size())throw new q;return this.l.a[this.b++]};N.prototype.next=N.prototype.next;N.prototype.c=function(){return this.b<this.l.size()?!0:!1};N.prototype.hasNext=N.prototype.c;N.prototype.remove=function(){throw new r};N.prototype.remove=N.prototype.remove;"undefined"!==typeof global&&(global.javascript={},global.javascript.util={},global.javascript.util.ArrayList=s,global.javascript.util.Arrays=v,global.javascript.util.Collection=m,global.javascript.util.EmptyStackException=h,global.javascript.util.HashMap=w,global.javascript.util.HashSet=y,global.javascript.util.IndexOutOfBoundsException=k,global.javascript.util.Iterator=l,global.javascript.util.List=n,global.javascript.util.Map=p,global.javascript.util.NoSuchElementException=q,global.javascript.util.OperationNotSupported=r,global.javascript.util.Set=x,global.javascript.util.SortedMap=A,global.javascript.util.SortedSet=B,global.javascript.util.Stack=C,global.javascript.util.TreeMap=H,global.javascript.util.TreeSet=L)}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],66:[function(require,module,exports){arguments[4][19][0].apply(exports,arguments)},{"./dist/javascript.util-node.min.js":65,dup:19}],67:[function(require,module,exports){var featureCollection=require("turf-featurecollection");var each=require("turf-meta").coordEach;var point=require("turf-point");module.exports=function(layer){var points=[];each(layer,function(coord){points.push(point(coord))});return featureCollection(points)}},{"turf-featurecollection":71,"turf-meta":68,"turf-point":101}],68:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{dup:22}],69:[function(require,module,exports){var each=require("turf-meta").coordEach;module.exports=function(layer){var extent=[Infinity,Infinity,-Infinity,-Infinity];each(layer,function(coord){if(extent[0]>coord[0])extent[0]=coord[0];if(extent[1]>coord[1])extent[1]=coord[1];if(extent[2]<coord[0])extent[2]=coord[0];if(extent[3]<coord[1])extent[3]=coord[1]});return extent}},{"turf-meta":70}],70:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{dup:22}],71:[function(require,module,exports){module.exports=function(features){return{type:"FeatureCollection",features:features}}},{}],72:[function(require,module,exports){var featureCollection=require("turf-featurecollection");module.exports=function(collection,key,val){var newFC=featureCollection([]);for(var i=0;i<collection.features.length;i++){if(collection.features[i].properties[key]===val){newFC.features.push(collection.features[i])}}return newFC}},{"turf-featurecollection":71}],73:[function(require,module,exports){module.exports=flipAny;function flipAny(_){var input=JSON.parse(JSON.stringify(_));switch(input.type){case"FeatureCollection":for(var i=0;i<input.features.length;i++)flipGeometry(input.features[i].geometry);return input;case"Feature":flipGeometry(input.geometry);return input;default:flipGeometry(input);return input}}function flipGeometry(geometry){var coords=geometry.coordinates;switch(geometry.type){case"Point":flip0(coords);break;case"LineString":case"MultiPoint":flip1(coords);break;case"Polygon":case"MultiLineString":flip2(coords);break;case"MultiPolygon":flip3(coords);break;case"GeometryCollection":geometry.geometries.forEach(flipGeometry);break}}function flip0(coord){coord.reverse()}function flip1(coords){for(var i=0;i<coords.length;i++)coords[i].reverse()}function flip2(coords){for(var i=0;i<coords.length;i++)for(var j=0;j<coords[i].length;j++)coords[i][j].reverse()}function flip3(coords){for(var i=0;i<coords.length;i++)for(var j=0;j<coords[i].length;j++)for(var k=0;k<coords[i][j].length;k++)coords[i][j][k].reverse()}},{}],74:[function(require,module,exports){var point=require("turf-point");var polygon=require("turf-polygon");var distance=require("turf-distance");var featurecollection=require("turf-featurecollection");var cosines=[];var sines=[];for(var i=0;i<6;i++){var angle=2*Math.PI/6*i;cosines.push(Math.cos(angle));sines.push(Math.sin(angle))}module.exports=function hexgrid(bbox,cell,units){var xFraction=cell/distance(point([bbox[0],bbox[1]]),point([bbox[2],bbox[1]]),units);var cellWidth=xFraction*(bbox[2]-bbox[0]);var yFraction=cell/distance(point([bbox[0],bbox[1]]),point([bbox[0],bbox[3]]),units);var cellHeight=yFraction*(bbox[3]-bbox[1]);var radius=cellWidth/2;var hex_width=radius*2;var hex_height=Math.sqrt(3)/2*hex_width;var box_width=bbox[2]-bbox[0];var box_height=bbox[3]-bbox[1];var x_interval=3/4*hex_width;var y_interval=hex_height;var x_span=box_width/(hex_width-radius/2);var x_count=Math.ceil(x_span);if(Math.round(x_span)===x_count){x_count++}var x_adjust=(x_count*x_interval-radius/2-box_width)/2-radius/2;var y_count=Math.ceil(box_height/hex_height);var y_adjust=(box_height-y_count*hex_height)/2;var hasOffsetY=y_count*hex_height-box_height>hex_height/2;if(hasOffsetY){y_adjust-=hex_height/4}var fc=featurecollection([]);for(var x=0;x<x_count;x++){for(var y=0;y<=y_count;y++){var isOdd=x%2===1;if(y===0&&isOdd){continue}if(y===0&&hasOffsetY){continue}var center_x=x*x_interval+bbox[0]-x_adjust;var center_y=y*y_interval+bbox[1]+y_adjust;if(isOdd){center_y-=hex_height/2}fc.features.push(hexagon([center_x,center_y],radius))}}return fc};function hexagon(center,radius){var vertices=[];for(var i=0;i<6;i++){var x=center[0]+radius*cosines[i];var y=center[1]+radius*sines[i];vertices.push([x,y])}vertices.push(vertices[0]);return polygon([vertices])}},{"turf-distance":59,"turf-featurecollection":71,"turf-point":101,"turf-polygon":102}],75:[function(require,module,exports){module.exports=function(point,polygon){var polys=polygon.geometry.coordinates;var pt=[point.geometry.coordinates[0],point.geometry.coordinates[1]];if(polygon.geometry.type==="Polygon")polys=[polys];var insidePoly=false;var i=0;while(i<polys.length&&!insidePoly){if(inRing(pt,polys[i][0])){var inHole=false;var k=1;while(k<polys[i].length&&!inHole){if(inRing(pt,polys[i][k])){inHole=true}k++}if(!inHole)insidePoly=true}i++}return insidePoly};function inRing(pt,ring){var isInside=false;for(var i=0,j=ring.length-1;i<ring.length;j=i++){var xi=ring[i][0],yi=ring[i][1];var xj=ring[j][0],yj=ring[j][1];var intersect=yi>pt[1]!=yj>pt[1]&&pt[0]<(xj-xi)*(pt[1]-yi)/(yj-yi)+xi;if(intersect)isInside=!isInside}return isInside}},{}],76:[function(require,module,exports){var jsts=require("jsts");var featurecollection=require("turf-featurecollection");module.exports=function(poly1,poly2){var geom1;if(poly1.type==="Feature")geom1=poly1.geometry;else geom1=poly1;if(poly2.type==="Feature")geom2=poly2.geometry;else geom2=poly2;var reader=new jsts.io.GeoJSONReader;var a=reader.read(JSON.stringify(geom1));var b=reader.read(JSON.stringify(geom2));var intersection=a.intersection(b);var parser=new jsts.io.GeoJSONParser;intersection=parser.write(intersection);if(intersection.type==="GeometryCollection"&&intersection.geometries.length===0){return}else{return{type:"Feature",properties:{},geometry:intersection}}}},{jsts:77,"turf-featurecollection":71}],77:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{"./lib/jsts":78,dup:16,"javascript.util":80}],78:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17}],79:[function(require,module,exports){(function(global){(function(){var e=this;function f(a,b){var c=a.split("."),d=e;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var t;c.length&&(t=c.shift());)c.length||void 0===b?d=d[t]?d[t]:d[t]={}:d[t]=b}function g(a,b){function c(){}c.prototype=b.prototype;a.q=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.p=function(a,c,O){var M=Array.prototype.slice.call(arguments,2);return b.prototype[c].apply(a,M)}}function h(a){this.message=a||""}g(h,Error);f("javascript.util.EmptyStackException",h);h.prototype.name="EmptyStackException";function k(a){this.message=a||""}g(k,Error);f("javascript.util.IndexOutOfBoundsException",k);k.prototype.name="IndexOutOfBoundsException";function l(){}f("javascript.util.Iterator",l);l.prototype.hasNext=l.prototype.c;l.prototype.next=l.prototype.next;l.prototype.remove=l.prototype.remove;function m(){}f("javascript.util.Collection",m);function n(){}g(n,m);f("javascript.util.List",n);function p(){}f("javascript.util.Map",p);functio
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment