ekylibre-cartography 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/README.md +3 -0
 - data/Rakefile +10 -0
 - data/app/assets/javascripts/cartography.coffee +535 -0
 - data/app/assets/javascripts/cartography/base.coffee +11 -0
 - data/app/assets/javascripts/cartography/controls.coffee +463 -0
 - data/app/assets/javascripts/cartography/events.coffee +36 -0
 - data/app/assets/javascripts/cartography/layers.coffee +127 -0
 - data/app/assets/javascripts/cartography/layers/simple.coffee +37 -0
 - data/app/assets/javascripts/cartography/leaflet/controls.coffee +420 -0
 - data/app/assets/javascripts/cartography/leaflet/handlers.coffee +461 -0
 - data/app/assets/javascripts/cartography/leaflet/i18n.coffee +31 -0
 - data/app/assets/javascripts/cartography/leaflet/layers.coffee +60 -0
 - data/app/assets/javascripts/cartography/leaflet/toolbars.coffee +450 -0
 - data/app/assets/javascripts/cartography/patches.js +8 -0
 - data/app/assets/javascripts/cartography/util.coffee +18 -0
 - data/app/assets/javascripts/main.js +18 -0
 - data/app/assets/stylesheets/cartography.css +86 -0
 - data/app/helpers/cartography_helper.rb +55 -0
 - data/lib/cartography.rb +1 -0
 - data/lib/cartography/engine.rb +11 -0
 - data/lib/cartography/version.rb +3 -0
 - data/vendor/assets/components/d3-array/dist/d3-array.js +590 -0
 - data/vendor/assets/components/d3-array/dist/d3-array.min.js +2 -0
 - data/vendor/assets/components/geojson-equality/dist/geojson-equality.js +295 -0
 - data/vendor/assets/components/geojson-equality/dist/geojson-equality.js.map +21 -0
 - data/vendor/assets/components/geojson-equality/dist/geojson-equality.min.js +1 -0
 - data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.css +29 -0
 - data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.js +269 -0
 - data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.css +1 -0
 - data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.js +8 -0
 - data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.css +0 -0
 - data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.js +48026 -0
 - data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.css +326 -0
 - data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.js +4653 -0
 - data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.map +1 -0
 - data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.css +10 -0
 - data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.js +10 -0
 - data/vendor/assets/components/leaflet-geographicutil/dist/leaflet.geographicutil.js +3220 -0
 - data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.css +30 -0
 - data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.js +3764 -0
 - data/vendor/assets/components/leaflet/dist/leaflet-src.js +13609 -0
 - data/vendor/assets/components/leaflet/dist/leaflet-src.js.map +1 -0
 - data/vendor/assets/components/leaflet/dist/leaflet-src.map +1 -0
 - data/vendor/assets/components/leaflet/dist/leaflet.css +632 -0
 - data/vendor/assets/components/leaflet/dist/leaflet.js +5 -0
 - data/vendor/assets/components/leaflet/dist/leaflet.js.map +1 -0
 - data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.min.js +9 -0
 - data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js +1716 -0
 - data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js.map +1 -0
 - data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.js +279 -0
 - data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.min.js +1 -0
 - data/vendor/assets/components/rtree/dist/rtree.js +911 -0
 - data/vendor/assets/components/rtree/dist/rtree.min.js +1 -0
 - data/vendor/assets/components/splaytree/dist/splay.es6.js +765 -0
 - data/vendor/assets/components/splaytree/dist/splay.es6.js.map +1 -0
 - data/vendor/assets/components/splaytree/dist/splay.js +797 -0
 - data/vendor/assets/components/splaytree/dist/splay.js.map +1 -0
 - metadata +156 -0
 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1eA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5RA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\n * Leaflet.draw assumes that you have already included the Leaflet library.\n */\nL.drawVersion = \"0.4.12\";\n/**\n * @class L.Draw\n * @aka Draw\n *\n *\n * To add the draw toolbar set the option drawControl: true in the map options.\n *\n * @example\n * ```js\n *      var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\n *\n *      L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\n *          attribution: '© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors'\n *      }).addTo(map);\n * ```\n *\n * ### Adding the edit toolbar\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\n *\n * ```js\n *      var map = L.map('map').setView([51.505, -0.09], 13);\n *\n *      L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\n *          attribution: '© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors'\n *      }).addTo(map);\n *\n *      // FeatureGroup is to store editable layers\n *      var drawnItems = new L.FeatureGroup();\n *      map.addLayer(drawnItems);\n *\n *      var drawControl = new L.Control.Draw({\n *          edit: {\n *              featureGroup: drawnItems\n *          }\n *      });\n *      map.addControl(drawControl);\n * ```\n *\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\n */\nL.Draw = {};\n\n/**\n * @class L.drawLocal\n * @aka L.drawLocal\n *\n * The core toolbar class of the API — it is used to create the toolbar ui\n *\n * @example\n * ```js\n *      var modifiedDraw = L.drawLocal.extend({\n *          draw: {\n *              toolbar: {\n *                  buttons: {\n *                      polygon: 'Draw an awesome polygon'\n *                  }\n *              }\n *          }\n *      });\n * ```\n *\n * The default state for the control is the draw toolbar just below the zoom control.\n *  This will allow map users to draw vectors and markers.\n *  **Please note the edit toolbar is not enabled by default.**\n */\nL.drawLocal = {\n\t// format: {\n\t// \tnumeric: {\n\t// \t\tdelimiters: {\n\t// \t\t\tthousands: ',',\n\t// \t\t\tdecimal: '.'\n\t// \t\t}\n\t// \t}\n\t// },\n\tdraw: {\n\t\ttoolbar: {\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\n\t\t\t// ex: actions.undo  or actions.cancel\n\t\t\tactions: {\n\t\t\t\ttitle: 'Cancel drawing',\n\t\t\t\ttext: 'Cancel'\n\t\t\t},\n\t\t\tfinish: {\n\t\t\t\ttitle: 'Finish drawing',\n\t\t\t\ttext: 'Finish'\n\t\t\t},\n\t\t\tundo: {\n\t\t\t\ttitle: 'Delete last point drawn',\n\t\t\t\ttext: 'Delete last point'\n\t\t\t},\n\t\t\tbuttons: {\n\t\t\t\tpolyline: 'Draw a polyline',\n\t\t\t\tpolygon: 'Draw a polygon',\n\t\t\t\trectangle: 'Draw a rectangle',\n\t\t\t\tcircle: 'Draw a circle',\n\t\t\t\tmarker: 'Draw a marker',\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\n\t\t\t}\n\t\t},\n\t\thandlers: {\n\t\t\tcircle: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\n\t\t\t\t},\n\t\t\t\tradius: 'Radius'\n\t\t\t},\n\t\t\tcirclemarker: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click map to place circle marker.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tmarker: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click map to place marker.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tpolygon: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click to start drawing shape.',\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\n\t\t\t\t\tend: 'Click first point to close this shape.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tpolyline: {\n\t\t\t\terror: '<strong>Error:</strong> shape edges cannot cross!',\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click to start drawing line.',\n\t\t\t\t\tcont: 'Click to continue drawing line.',\n\t\t\t\t\tend: 'Click last point to finish line.'\n\t\t\t\t}\n\t\t\t},\n\t\t\trectangle: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tsimpleshape: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tedit: {\n\t\ttoolbar: {\n\t\t\tactions: {\n\t\t\t\tsave: {\n\t\t\t\t\ttitle: 'Save changes',\n\t\t\t\t\ttext: 'Save'\n\t\t\t\t},\n\t\t\t\tcancel: {\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\n\t\t\t\t\ttext: 'Cancel'\n\t\t\t\t},\n\t\t\t\tclearAll:{\n\t\t\t\t\ttitle: 'Clear all layers',\n\t\t\t\t\ttext: 'Clear All'\n\t\t\t\t}\n\t\t\t},\n\t\t\tbuttons: {\n\t\t\t\tedit: 'Edit layers',\n\t\t\t\teditDisabled: 'No layers to edit',\n\t\t\t\tremove: 'Delete layers',\n\t\t\t\tremoveDisabled: 'No layers to delete'\n\t\t\t}\n\t\t},\n\t\thandlers: {\n\t\t\tedit: {\n\t\t\t\ttooltip: {\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tremove: {\n\t\t\t\ttooltip: {\n\t\t\t\t\ttext: 'Click on a feature to remove.'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n","/**\n * ### Events\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\n * actions users can initiate. The following events will be triggered on the map:\n *\n * @class L.Draw.Event\n * @aka Draw.Event\n *\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\n *\n * @example\n * ```js\n * map.on(L.Draw.Event.CREATED; function (e) {\n *    var type = e.layerType,\n *        layer = e.layer;\n *\n *    if (type === 'marker') {\n *        // Do marker specific actions\n *    }\n *\n *    // Do whatever else you need to. (save to db; add to map etc)\n *    map.addLayer(layer);\n *});\n * ```\n */\nL.Draw.Event = {};\n/**\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\n *\n * Layer that was just created.\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\n * Triggered when a new vector or marker has been created.\n *\n */\nL.Draw.Event.CREATED = 'draw:created';\n\n/**\n * @event draw:edited: LayerGroup\n *\n * List of all layers just edited on the map.\n *\n *\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\n *\n * @example\n * ```js\n *      map.on('draw:edited', function (e) {\n     *          var layers = e.layers;\n     *          layers.eachLayer(function (layer) {\n     *              //do whatever you want; most likely save back to db\n     *          });\n     *      });\n * ```\n */\nL.Draw.Event.EDITED = 'draw:edited';\n\n/**\n * @event draw:deleted: LayerGroup\n *\n * List of all layers just removed from the map.\n *\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\n */\nL.Draw.Event.DELETED = 'draw:deleted';\n\n/**\n * @event draw:drawstart: String\n *\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\n *\n * Triggered when the user has chosen to draw a particular vector or marker.\n */\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\n\n/**\n * @event draw:drawstop: String\n *\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\n *\n * Triggered when the user has finished a particular vector or marker.\n */\n\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\n\n/**\n * @event draw:drawvertex: LayerGroup\n *\n * List of all layers just being added from the map.\n *\n * Triggered when a vertex is created on a polyline or polygon.\n */\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\n\n/**\n * @event draw:editstart: String\n *\n * The type of edit this is. One of: `edit`\n *\n * Triggered when the user starts edit mode by clicking the edit tool button.\n */\n\nL.Draw.Event.EDITSTART = 'draw:editstart';\n\n/**\n * @event draw:editmove: ILayer\n *\n *  Layer that was just moved.\n *\n * Triggered as the user moves a rectangle; circle or marker.\n */\nL.Draw.Event.EDITMOVE = 'draw:editmove';\n\n/**\n * @event draw:editresize: ILayer\n *\n * Layer that was just moved.\n *\n * Triggered as the user resizes a rectangle or circle.\n */\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\n\n/**\n * @event draw:editvertex: LayerGroup\n *\n * List of all layers just being edited from the map.\n *\n * Triggered when a vertex is edited on a polyline or polygon.\n */\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\n\n/**\n * @event draw:editstop: String\n *\n * The type of edit this is. One of: `edit`\n *\n * Triggered when the user has finshed editing (edit mode) and saves edits.\n */\nL.Draw.Event.EDITSTOP = 'draw:editstop';\n\n/**\n * @event draw:deletestart: String\n *\n * The type of edit this is. One of: `remove`\n *\n * Triggered when the user starts remove mode by clicking the remove tool button.\n */\nL.Draw.Event.DELETESTART = 'draw:deletestart';\n\n/**\n * @event draw:deletestop: String\n *\n * The type of edit this is. One of: `remove`\n *\n * Triggered when the user has finished removing shapes (remove mode) and saves.\n */\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\n","L.Draw = L.Draw || {};\n\n/**\n * @class L.Draw.Feature\n * @aka Draw.Feature\n */\nL.Draw.Feature = L.Handler.extend({\n\tincludes: L.Mixin.Events,\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tthis._map = map;\n\t\tthis._container = map._container;\n\t\tthis._overlayPane = map._panes.overlayPane;\n\t\tthis._popupPane = map._panes.popupPane;\n\n\t\t// Merge default shapeOptions options with custom shapeOptions\n\t\tif (options && options.shapeOptions) {\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\n\t\t}\n\t\tL.setOptions(this, options);\n\t},\n\n\t// @method enable(): void\n\t// Enables this handler\n\tenable: function () {\n\t\tif (this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Handler.prototype.enable.call(this);\n\n\t\tthis.fire('enabled', { handler: this.type });\n\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, { layerType: this.type });\n\t},\n\n\t// @method disable(): void\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Handler.prototype.disable.call(this);\n\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, { layerType: this.type });\n\n\t\tthis.fire('disabled', { handler: this.type });\n\t},\n\n\t// @method addHooks(): void\n\t// Add's event listeners to this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tL.DomUtil.disableTextSelection();\n\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Removes event listeners from this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\tL.DomUtil.enableTextSelection();\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\n\t\t}\n\t},\n\n\t// @method setOptions(object): void\n\t// Sets new options to this handler\n\tsetOptions: function (options) {\n\t\tL.setOptions(this, options);\n\t},\n\n\t_fireCreatedEvent: function (layer) {\n\t\tthis._map.fire(L.Draw.Event.CREATED, { layer: layer, layerType: this.type });\n\t},\n\n\t// Cancel drawing when the escape key is pressed\n\t_cancelDrawing: function (e) {\n\t\tif (e.keyCode === 27) {\n\t\t\tthis._map.fire('draw:canceled', { layerType: this.type });\n\t\t\tthis.disable();\n\t\t}\n\t}\n});\n","/**\n * @class L.Draw.Polyline\n * @aka Draw.Polyline\n * @inherits L.Draw.Feature\n */\nL.Draw.Polyline = L.Draw.Feature.extend({\n\tstatics: {\n\t\tTYPE: 'polyline'\n\t},\n\n\tPoly: L.Polyline,\n\n\toptions: {\n\t\tallowIntersection: true,\n\t\trepeatMode: false,\n\t\tdrawError: {\n\t\t\tcolor: '#b00b00',\n\t\t\ttimeout: 2500\n\t\t},\n\t\ticon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\n\t\t}),\n\t\ttouchIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\n\t\t}),\n\t\tguidelineDistance: 20,\n\t\tmaxGuideLineLength: 4000,\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: false,\n\t\t\tclickable: true\n\t\t},\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\n\t\tshowLength: true, // Whether to display distance in the tooltip\n    zIndexOffset: 2000, // This should be > than the highest z-index any map layers\n    factor: 1 // To change distance calculation\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.icon = this.options.touchIcon;\n\t\t}\n\n\t\t// Need to set this here to ensure the correct message is used.\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\n\n\t\t// Merge default drawError options with custom options\n\t\tif (options && options.drawError) {\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\n\t\t}\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Polyline.TYPE;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\t\tif (this._map) {\n\t\t\tthis._markers = [];\n\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t\tthis._map.addLayer(this._markerGroup);\n\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\n\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\n\n\t\t\t// Make a transparent marker that will used to catch click events. These click\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\n\t\t\t// while drawing.\n\t\t\tif (!this._mouseMarker) {\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\n\t\t\t\t\ticon: L.divIcon({\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\n\t\t\t\t\t\ticonAnchor: [20, 20],\n\t\t\t\t\t\ticonSize: [40, 40]\n\t\t\t\t\t}),\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._mouseMarker\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\n\t\t\t\t.addTo(this._map);\n\n\t\t\tthis._map\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\n\t\t\t\t.on('touchstart', this._onTouch, this)\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\n\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\n\t\tthis._clearHideErrorTimeout();\n\n\t\tthis._cleanUpShape();\n\n\t\t// remove markers from map\n\t\tthis._map.removeLayer(this._markerGroup);\n\t\tdelete this._markerGroup;\n\t\tdelete this._markers;\n\n\t\tthis._map.removeLayer(this._poly);\n\t\tdelete this._poly;\n\n\t\tthis._mouseMarker\n\t\t\t.off('mousedown', this._onMouseDown, this)\n\t\t\t.off('mouseout', this._onMouseOut, this)\n\t\t\t.off('mouseup', this._onMouseUp, this)\n\t\t\t.off('mousemove', this._onMouseMove, this);\n\t\tthis._map.removeLayer(this._mouseMarker);\n\t\tdelete this._mouseMarker;\n\n\t\t// clean up DOM\n\t\tthis._clearGuides();\n\n\t\tthis._map\n\t\t\t.off('mouseup', this._onMouseUp, this)\n\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\n\t\t\t.off('zoomend', this._onZoomEnd, this)\n\t\t\t.off('touchstart', this._onTouch, this)\n\t\t\t.off('click', this._onTouch, this);\n\t},\n\n\t// @method deleteLastVertex(): void\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\n\tdeleteLastVertex: function () {\n\t\tif (this._markers.length <= 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar lastMarker = this._markers.pop(),\n\t\t\tpoly = this._poly,\n\t\t\t// Replaces .spliceLatLngs()\n\t\t\tlatlngs = poly.getLatLngs(),\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\n\t\tthis._poly.setLatLngs(latlngs);\n\n\t\tthis._markerGroup.removeLayer(lastMarker);\n\n\t\tif (poly.getLatLngs().length < 2) {\n\t\t\tthis._map.removeLayer(poly);\n\t\t}\n\n\t\tthis._vertexChanged(latlng, false);\n\t},\n\n\t// @method addVertex(): void\n\t// Add a vertex to the end of the polyline\n\taddVertex: function (latlng) {\n\t\tvar markersLength = this._markers.length;\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\n\t\t\tthis._showErrorTooltip();\n\t\t\treturn;\n\t\t}\n\t\telse if (this._errorShown) {\n\t\t\tthis._hideErrorTooltip();\n\t\t}\n\n\t\tthis._markers.push(this._createMarker(latlng));\n\n\t\tthis._poly.addLatLng(latlng);\n\n\t\tif (this._poly.getLatLngs().length === 2) {\n\t\t\tthis._map.addLayer(this._poly);\n\t\t}\n\n\t\tthis._vertexChanged(latlng, true);\n\t},\n\n\t// @method completeShape(): void\n\t// Closes the polyline between the first and last points\n\tcompleteShape: function () {\n\t\tif (this._markers.length <= 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._fireCreatedEvent();\n\t\tthis.disable();\n\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t_finishShape: function () {\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\n\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\n\t\t\tthis._showErrorTooltip();\n\t\t\treturn;\n\t\t}\n\n\t\tthis._fireCreatedEvent();\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t// Called to verify the shape is valid when the user tries to finish it\n\t// Return false if the shape is not valid\n\t_shapeIsValid: function () {\n\t\treturn true;\n\t},\n\n\t_onZoomEnd: function () {\n\t\tif (this._markers !== null) {\n\t\t\tthis._updateGuide();\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\n\n\t\t// Save latlng\n\t\t// should this be moved to _updateGuide() ?\n\t\tthis._currentLatLng = latlng;\n\n\t\tthis._updateTooltip(latlng);\n\n\t\t// Update the guide line\n\t\tthis._updateGuide(newPos);\n\n\t\t// Update the mouse marker position\n\t\tthis._mouseMarker.setLatLng(latlng);\n\n\t\tL.DomEvent.preventDefault(e.originalEvent);\n\t},\n\n\t_vertexChanged: function (latlng, added) {\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, { layers: this._markerGroup });\n\t\tthis._updateFinishHandler();\n\n\t\tthis._updateRunningMeasure(latlng, added);\n\n\t\tthis._clearGuides();\n\n\t\tthis._updateTooltip();\n\t},\n\n\t_onMouseDown: function (e) {\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\n\t\t\tthis._onMouseMove(e);\n\t\t\tthis._clickHandled = true;\n\t\t\tthis._disableNewMarkers();\n\t\t\tvar originalEvent = e.originalEvent;\n\t\t\tvar clientX = originalEvent.clientX;\n\t\t\tvar clientY = originalEvent.clientY;\n\t\t\tthis._startPoint.call(this, clientX, clientY);\n\t\t}\n\t},\n\n\t_startPoint: function (clientX, clientY) {\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\n\t},\n\n\t_onMouseUp: function (e) {\n\t\tvar originalEvent = e.originalEvent;\n\t\tvar clientX = originalEvent.clientX;\n\t\tvar clientY = originalEvent.clientY;\n\t\tthis._endPoint.call(this, clientX, clientY, e);\n\t\tthis._clickHandled = null;\n\t},\n\n\t_endPoint: function (clientX, clientY, e) {\n\t\tif (this._mouseDownOrigin) {\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\n\t\t\tif (lastPtDistance < 10 && L.Browser.touch) {\n\t\t\t\tthis._finishShape();\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\n\t\t\t\tthis.addVertex(e.latlng);\n\t\t\t}\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\n\t\t}\n\t\tthis._mouseDownOrigin = null;\n\t},\n\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\n\t// causing unwanted behavior\n\t_onTouch: function (e) {\n\t\tvar originalEvent = e.originalEvent;\n\t\tvar clientX;\n\t\tvar clientY;\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\n\t\t\tclientX = originalEvent.touches[0].clientX;\n\t\t\tclientY = originalEvent.touches[0].clientY;\n\t\t\tthis._disableNewMarkers();\n\t\t\tthis._touchHandled = true;\n\t\t\tthis._startPoint.call(this, clientX, clientY);\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\n\t\t\tthis._touchHandled = null;\n\t\t}\n\t\tthis._clickHandled = null;\n\t},\n\n\t_onMouseOut: function () {\n\t\tif (this._tooltip) {\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\n\t\t}\n\t},\n\n\t// calculate if we are currently within close enough distance\n\t// of the closing point (first point for shapes, last point for lines)\n\t// this is semi-ugly code but the only reliable way i found to get the job done\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\n\t_calculateFinishDistance: function (potentialLatLng) {\n\t\tvar lastPtDistance\n\t\tif (this._markers.length > 0) {\n\t\t\t\tvar finishMarker;\n\t\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\n\t\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\n\t\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\n\t\t\t\t\tfinishMarker = this._markers[0];\n\t\t\t\t} else {\n\t\t\t\t\treturn Infinity;\n\t\t\t\t}\n\t\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\n\t\t\t\t\ticon: this.options.icon,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\n\t\t\t\t});\n\t\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\n\t\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\n\t\t\t} else {\n\t\t\t\tlastPtDistance = Infinity;\n\t\t\t}\n\t\t\treturn lastPtDistance;\n\t},\n\n\t_updateFinishHandler: function () {\n\t\tvar markerCount = this._markers.length;\n\t\t// The last marker should have a click handler to close the polyline\n\t\tif (markerCount > 1) {\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\n\t\t}\n\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\n\t\tif (markerCount > 2) {\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng) {\n\t\tvar marker = new L.Marker(latlng, {\n\t\t\ticon: this.options.icon,\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\n\t\t});\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_updateGuide: function (newPos) {\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\n\n\t\tif (markerCount > 0) {\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\n\n\t\t\t// draw the guide line\n\t\t\tthis._clearGuides();\n\t\t\tthis._drawGuide(\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\n\t\t\t\tnewPos\n\t\t\t);\n\t\t}\n\t},\n\n\t_updateTooltip: function (latLng) {\n\t\tvar text = this._getTooltipText();\n\n\t\tif (latLng) {\n\t\t\tthis._tooltip.updatePosition(latLng);\n\t\t}\n\n\t\tif (!this._errorShown) {\n\t\t\tthis._tooltip.updateContent(text);\n\t\t}\n\t},\n\n\t_drawGuide: function (pointA, pointB) {\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\n\t\t\tguidelineDistance = this.options.guidelineDistance,\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\n\t\t\t// Only draw a guideline with a max length\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\n\t\t\tfraction,\n\t\t\tdashPoint,\n\t\t\tdash;\n\n\t\t//create the guides container if we haven't yet\n\t\tif (!this._guidesContainer) {\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\n\t\t}\n\n\t\t//draw a dash every GuildeLineDistance\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\n\t\t\t//work out fraction along line we are\n\t\t\tfraction = i / length;\n\n\t\t\t//calculate new x,y point\n\t\t\tdashPoint = {\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\n\t\t\t};\n\n\t\t\t//add guide dash to guide container\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\n\t\t\tdash.style.backgroundColor =\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\n\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\n\t\t}\n\t},\n\n\t_updateGuideColor: function (color) {\n\t\tif (this._guidesContainer) {\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\n\t\t\t}\n\t\t}\n\t},\n\n\t// removes all child elements (guide dashes) from the guides container\n\t_clearGuides: function () {\n\t\tif (this._guidesContainer) {\n\t\t\twhile (this._guidesContainer.firstChild) {\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar showLength = this.options.showLength,\n\t\t\tlabelText, distanceStr;\n\t\tif (L.Browser.touch) {\n\t\t\tshowLength = false; // if there's a better place to put this, feel free to move it\n\t\t}\n\t\tif (this._markers.length === 0) {\n\t\t\tlabelText = {\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\n\t\t\t};\n\t\t} else {\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\n\n\t\t\tif (this._markers.length === 1) {\n\t\t\t\tlabelText = {\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\n\t\t\t\t\tsubtext: distanceStr\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tlabelText = {\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\n\t\t\t\t\tsubtext: distanceStr\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn labelText;\n\t},\n\n\t_updateRunningMeasure: function (latlng, added) {\n\t\tvar markersLength = this._markers.length,\n\t\t\tpreviousMarkerIndex, distance;\n\n\t\tif (this._markers.length === 1) {\n\t\t\tthis._measurementRunningTotal = 0;\n\t\t} else {\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\n\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\n\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\n\t\t}\n\t},\n\n\t_getMeasurementString: function () {\n\t\tvar currentLatLng = this._currentLatLng,\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\n\t\t\tdistance;\n\n\t\t// calculate the distance from the last fixed point to the mouse position\n\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0 ;\n\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\n\t},\n\n\t_showErrorTooltip: function () {\n\t\tthis._errorShown = true;\n\n\t\t// Update tooltip\n\t\tthis._tooltip\n\t\t\t.showAsError()\n\t\t\t.updateContent({ text: this.options.drawError.message });\n\n\t\t// Update shape\n\t\tthis._updateGuideColor(this.options.drawError.color);\n\t\tthis._poly.setStyle({ color: this.options.drawError.color });\n\n\t\t// Hide the error after 2 seconds\n\t\tthis._clearHideErrorTimeout();\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\n\t},\n\n\t_hideErrorTooltip: function () {\n\t\tthis._errorShown = false;\n\n\t\tthis._clearHideErrorTimeout();\n\n\t\t// Revert tooltip\n\t\tthis._tooltip\n\t\t\t.removeError()\n\t\t\t.updateContent(this._getTooltipText());\n\n\t\t// Revert shape\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\n\t\tthis._poly.setStyle({ color: this.options.shapeOptions.color });\n\t},\n\n\t_clearHideErrorTimeout: function () {\n\t\tif (this._hideErrorTimeout) {\n\t\t\tclearTimeout(this._hideErrorTimeout);\n\t\t\tthis._hideErrorTimeout = null;\n\t\t}\n\t},\n\n\t// disable new markers temporarily;\n\t// this is to prevent duplicated touch/click events in some browsers\n\t_disableNewMarkers: function () {\n\t\tthis._disableMarkers = true;\n\t},\n\n\t// see _disableNewMarkers\n\t_enableNewMarkers: function () {\n\t\tsetTimeout(function() {\n\t\t\tthis._disableMarkers = false;\n\t\t}.bind(this), 50);\n\t},\n\n\t_cleanUpShape: function () {\n\t\tif (this._markers.length > 1) {\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\n\t}\n});\n","/**\n * @class L.Draw.Polygon\n * @aka Draw.Polygon\n * @inherits L.Draw.Polyline\n */\nL.Draw.Polygon = L.Draw.Polyline.extend({\n\tstatics: {\n\t\tTYPE: 'polygon'\n\t},\n\n\tPoly: L.Polygon,\n\n\toptions: {\n\t\tshowArea: false,\n\t\tshowLength: false,\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tclickable: true\n\t\t},\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\n\t\t// Also defines the units to use for the metric system as an array of\n\t\t// strings (e.g. `['ha', 'm']`).\n\t\tmetric: true,\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\n\t\tprecision: {}\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Polygon.TYPE;\n\t},\n\n\t_updateFinishHandler: function () {\n\t\tvar markerCount = this._markers.length;\n\n\t\t// The first marker should have a click handler to close the polygon\n\t\tif (markerCount === 1) {\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\n\t\t}\n\n\t\t// Add and update the double click handler\n\t\tif (markerCount > 2) {\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\n\t\t\t// Only need to remove handler if has been added before\n\t\t\tif (markerCount > 3) {\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar text, subtext;\n\n\t\tif (this._markers.length === 0) {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\n\t\t} else if (this._markers.length < 3) {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\n\t\t\tsubtext = this._getMeasurementString();\n\t\t} else {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\n\t\t\tsubtext = this._getMeasurementString();\n\t\t}\n\n\t\treturn {\n\t\t\ttext: text,\n\t\t\tsubtext: subtext\n\t\t};\n\t},\n\n\t_getMeasurementString: function () {\n\t\tvar area = this._area,\n\t\t\tmeasurementString = '';\n\n\n\t\tif (!area && !this.options.showLength) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (this.options.showLength) {\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\n\t\t}\n\n\t\tif (area) {\n\t\t\tmeasurementString += '<br>' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\n\t\t}\n\n\t\treturn measurementString;\n\t},\n\n\t_shapeIsValid: function () {\n\t\treturn this._markers.length >= 3;\n\t},\n\n\t_vertexChanged: function (latlng, added) {\n\t\tvar latLngs;\n\n\t\t// Check to see if we should show the area\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\n\t\t\tlatLngs = this._poly.getLatLngs();\n\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\n\t\t}\n\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\n\t},\n\n\t_cleanUpShape: function () {\n\t\tvar markerCount = this._markers.length;\n\n\t\tif (markerCount > 0) {\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\n\n\t\t\tif (markerCount > 2) {\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\n\t\t\t}\n\t\t}\n\t}\n});\n","L.SimpleShape = {};\n/**\n * @class L.Draw.SimpleShape\n * @aka Draw.SimpleShape\n * @inherits L.Draw.Feature\n */\nL.Draw.SimpleShape = L.Draw.Feature.extend({\n\toptions: {\n\t\trepeatMode: false\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\t\tif (this._map) {\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\n\n\t\t\tif (this._mapDraggable) {\n\t\t\t\tthis._map.dragging.disable();\n\t\t\t}\n\n\t\t\t//TODO refactor: move cursor to styles\n\t\t\tthis._container.style.cursor = 'crosshair';\n\n\t\t\tthis._tooltip.updateContent({ text: this._initialLabelText });\n\n\t\t\tthis._map\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\t\tif (this._map) {\n\t\t\tif (this._mapDraggable) {\n\t\t\t\tthis._map.dragging.enable();\n\t\t\t}\n\n\t\t\t//TODO refactor: move cursor to styles\n\t\t\tthis._container.style.cursor = '';\n\n\t\t\tthis._map\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\n\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\n\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\n\t\t\tif (this._shape) {\n\t\t\t\tthis._map.removeLayer(this._shape);\n\t\t\t\tdelete this._shape;\n\t\t\t}\n\t\t}\n\t\tthis._isDrawing = false;\n\t},\n\n\t_getTooltipText: function () {\n\t\treturn {\n\t\t\ttext: this._endLabelText\n\t\t};\n\t},\n\n\t_onMouseDown: function (e) {\n\t\tthis._isDrawing = true;\n\t\tthis._startLatLng = e.latlng;\n\n\t\tL.DomEvent\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\n\t\t\t.preventDefault(e.originalEvent);\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tif (this._isDrawing) {\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\n\t\t\tthis._drawShape(latlng);\n\t\t}\n\t},\n\n\t_onMouseUp: function () {\n\t\tif (this._shape) {\n\t\t\tthis._fireCreatedEvent();\n\t\t}\n\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t}\n});","/**\n * @class L.Draw.Rectangle\n * @aka Draw.Rectangle\n * @inherits L.Draw.SimpleShape\n */\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\n\tstatics: {\n\t\tTYPE: 'rectangle'\n\t},\n\n\toptions: {\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tshowArea: true,\n\t\t\tclickable: true\n\t\t},\n\t\tmetric: true // Whether to use the metric measurement system or imperial\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Rectangle.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\n\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\n\t},\n    \n\t// @method disable(): void\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._isCurrentlyTwoClickDrawing = false;\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\n\t},\n    \n\t_onMouseUp: function (e) {\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t// Make sure closing click is on map\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\n\t},\n    \n\t_drawShape: function (latlng) {\n\t\tif (!this._shape) {\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\n\t\t\tthis._map.addLayer(this._shape);\n\t\t} else {\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\n\t\t\tshape = this._shape,\n\t\t\tshowArea = this.options.showArea,\n\t\t\tlatLngs, area, subtext;\n\n\t\tif (shape) {\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : ''\n\t\t}\n\n\t\treturn {\n\t\t\ttext: tooltipText.text,\n\t\t\tsubtext: subtext\n\t\t};\n\t}\n});\n\nfunction _hasAncestor (el, cls) {\n\twhile ((el = el.parentElement) && !el.classList.contains(cls));\n\treturn el;\n}\n","/**\n * @class L.Draw.Marker\n * @aka Draw.Marker\n * @inherits L.Draw.Feature\n */\nL.Draw.Marker = L.Draw.Feature.extend({\n\tstatics: {\n\t\tTYPE: 'marker'\n\t},\n\n\toptions: {\n\t\ticon: new L.Icon.Default(),\n\t\trepeatMode: false,\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Marker.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\n\t\tif (this._map) {\n\t\t\tthis._tooltip.updateContent({ text: this._initialLabelText });\n\n\t\t\t// Same mouseMarker as in Draw.Polyline\n\t\t\tif (!this._mouseMarker) {\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\n\t\t\t\t\ticon: L.divIcon({\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\n\t\t\t\t\t\ticonAnchor: [20, 20],\n\t\t\t\t\t\ticonSize: [40, 40]\n\t\t\t\t\t}),\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._mouseMarker\n\t\t\t\t.on('click', this._onClick, this)\n\t\t\t\t.addTo(this._map);\n\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\n\t\t\tthis._map.on('click', this._onTouch, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\n\t\tif (this._map) {\n\t\t\tif (this._marker) {\n\t\t\t\tthis._marker.off('click', this._onClick, this);\n\t\t\t\tthis._map\n\t\t\t\t\t.off('click', this._onClick, this)\n\t\t\t\t\t.off('click', this._onTouch, this)\n\t\t\t\t\t.removeLayer(this._marker);\n\t\t\t\tdelete this._marker;\n\t\t\t}\n\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\n\t\t\tthis._map.removeLayer(this._mouseMarker);\n\t\t\tdelete this._mouseMarker;\n\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tthis._mouseMarker.setLatLng(latlng);\n\n\t\tif (!this._marker) {\n\t\t\tthis._marker = this._createMarker(latlng);\n\t\t\t// Bind to both marker and map to make sure we get the click event.\n\t\t\tthis._marker.on('click', this._onClick, this);\n\t\t\tthis._map\n\t\t\t\t.on('click', this._onClick, this)\n\t\t\t\t.addLayer(this._marker);\n\t\t}\n\t\telse {\n\t\t\tlatlng = this._mouseMarker.getLatLng();\n\t\t\tthis._marker.setLatLng(latlng);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng) {\n\t\treturn new L.Marker(latlng, {\n\t\t\ticon: this.options.icon,\n\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t});\n\t},\n\n\t_onClick: function () {\n\t\tthis._fireCreatedEvent();\n\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t_onTouch: function (e) {\n\t\t// called on click & tap, only really does any thing on tap\n\t\tthis._onMouseMove(e); // creates & places marker\n\t\tthis._onClick(); // permanently places marker & ends interaction\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), { icon: this.options.icon });\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\n\t}\n});\n","/**\n * @class L.Draw.CircleMarker\n * @aka Draw.CircleMarker\n * @inherits L.Draw.Marker\n */\nL.Draw.CircleMarker = L.Draw.Marker.extend({\n\tstatics: {\n\t\tTYPE: 'circlemarker'\n\t},\n\n\toptions: {\n\t\tstroke: true,\n\t\tcolor: '#3388ff',\n\t\tweight: 4,\n\t\topacity: 0.5,\n\t\tfill: true,\n\t\tfillColor: null, //same as color by default\n\t\tfillOpacity: 0.2,\n\t\tclickable: true,\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\n\t_fireCreatedEvent: function () {\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\n\t},\n\n\t_createMarker: function (latlng) {\n\t\treturn new L.CircleMarker(latlng, this.options);\n\t}\n});\n","/**\n * @class L.Draw.Circle\n * @aka Draw.Circle\n * @inherits L.Draw.SimpleShape\n */\nL.Draw.Circle = L.Draw.SimpleShape.extend({\n\tstatics: {\n\t\tTYPE: 'circle'\n\t},\n\n\toptions: {\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tclickable: true\n\t\t},\n\t\tshowRadius: true,\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\n\t\tfeet: true, // When not metric, use feet instead of yards for display\n\t\tnautic: false // When not metric, not feet use nautic mile for display\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Circle.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\n\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\n\t},\n\n\t_drawShape: function (latlng) {\n    var distance = this._map.distance(this._startLatLng, latlng);\n\t\tif (!this._shape) {\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\n\t\t\tthis._map.addLayer(this._shape);\n\t\t} else {\n\t\t\tthis._shape.setRadius(distance);\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng,\n\t\t\tshowRadius = this.options.showRadius,\n\t\t\tuseMetric = this.options.metric,\n\t\t\tradius;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tif (this._isDrawing) {\n\t\t\tthis._drawShape(latlng);\n\n\t\t\t// Get the new radius (rounded to 1 dp)\n\t\t\tradius = this._shape.getRadius().toFixed(1);\n\n\t\t\tvar subtext = '';\n\t\t\tif (showRadius) {\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\n\t\t\t\t\t\t  L.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\n\t\t\t}\n\t\t\tthis._tooltip.updateContent({\n\t\t\t\ttext: this._endLabelText,\n\t\t\t\tsubtext: subtext\n\t\t\t});\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n\n/**\n * @class L.Edit.Marker\n * @aka Edit.Marker\n */\nL.Edit.Marker = L.Handler.extend({\n\t// @method initialize(): void\n\tinitialize: function (marker, options) {\n\t\tthis._marker = marker;\n\t\tL.setOptions(this, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar marker = this._marker;\n\n\t\tmarker.dragging.enable();\n\t\tmarker.on('dragend', this._onDragEnd, marker);\n\t\tthis._toggleMarkerHighlight();\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tvar marker = this._marker;\n\n\t\tmarker.dragging.disable();\n\t\tmarker.off('dragend', this._onDragEnd, marker);\n\t\tthis._toggleMarkerHighlight();\n\t},\n\n\t_onDragEnd: function (e) {\n\t\tvar layer = e.target;\n\t\tlayer.edited = true;\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, { layer: layer });\n\t},\n\n\t_toggleMarkerHighlight: function () {\n\t\tvar icon = this._marker._icon;\n\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\n\t\t// is a chance that a marker doesn't.\n\t\tif (!icon) {\n\t\t\treturn;\n\t\t}\n\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\n\t\ticon.style.display = 'none';\n\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\n\t\t\t// Offset as the border will make the icon move.\n\t\t\tthis._offsetMarker(icon, -4);\n\n\t\t} else {\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\n\t\t\t// Offset as the border will make the icon move.\n\t\t\tthis._offsetMarker(icon, 4);\n\t\t}\n\n\t\ticon.style.display = '';\n\t},\n\n\t_offsetMarker: function (icon, offset) {\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\n\n\t\ticon.style.marginTop = iconMarginTop + 'px';\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\n\t}\n});\n\nL.Marker.addInitHook(function () {\n\tif (L.Edit.Marker) {\n\t\tthis.editing = new L.Edit.Marker(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n\n/**\n * @class L.Edit.Polyline\n * @aka L.Edit.Poly\n * @aka Edit.Poly\n */\nL.Edit.Poly = L.Handler.extend({\n\toptions: {},\n\n\t// @method initialize(): void\n\tinitialize: function (poly, options) {\n\n\t\tthis.latlngs = [poly._latlngs];\n\t\tif (poly._holes) {\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\n\t\t}\n\n\t\tthis._poly = poly;\n\t\tL.setOptions(this, options);\n\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\n\t},\n\n\t// Compatibility method to normalize Poly* objects\n\t// between 0.7.x and 1.0+\n\t_defaultShape: function () {\n\t\tif (!L.Polyline._flat) {\n\t\t\treturn this._poly._latlngs;\n\t\t}\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\n\t},\n\n\t_eachVertexHandler: function (callback) {\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\n\t\t\tcallback(this._verticesHandlers[i]);\n\t\t}\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tthis._initHandlers();\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.addHooks();\n\t\t});\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.removeHooks();\n\t\t});\n\t},\n\n\t// @method updateMarkers(): void\n\t// Fire an update for each vertex handler\n\tupdateMarkers: function () {\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.updateMarkers();\n\t\t});\n\t},\n\n\t_initHandlers: function () {\n\t\tthis._verticesHandlers = [];\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this.options));\n\t\t}\n\t},\n\n\t_updateLatLngs: function (e) {\n\t\tthis.latlngs = [e.layer._latlngs];\n\t\tif (e.layer._holes) {\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\n\t\t}\n\t}\n\n});\n\n/**\n * @class L.Edit.PolyVerticesEdit\n * @aka Edit.PolyVerticesEdit\n */\nL.Edit.PolyVerticesEdit = L.Handler.extend({\n\toptions: {\n\t\ticon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\n\t\t}),\n\t\ttouchIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\n\t\t}),\n\t\tdrawError: {\n\t\t\tcolor: '#b00b00',\n\t\t\ttimeout: 1000\n\t\t}\n\n\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (poly, latlngs, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.icon = this.options.touchIcon;\n\t\t}\n\t\tthis._poly = poly;\n\n\t\tif (options && options.drawError) {\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\n\t\t}\n\n\t\tthis._latlngs = latlngs;\n\n\t\tL.setOptions(this, options);\n\t},\n\n\t// Compatibility method to normalize Poly* objects\n\t// between 0.7.x and 1.0+\n\t_defaultShape: function () {\n\t\tif (!L.Polyline._flat) {\n\t\t\treturn this._latlngs;\n\t\t}\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tvar poly = this._poly;\n\n\t\tif (!(poly instanceof L.Polygon)) {\n\t\t\tpoly.options.fill = false;\n\t\t\tif (poly.options.editing) {\n\t\t\t\tpoly.options.editing.fill = false;\n\t\t\t}\n\t\t}\n\n\t\tpoly.setStyle(poly.options.editing);\n\n\t\tif (this._poly._map) {\n\n\t\t\tthis._map = this._poly._map; // Set map\n\n\t\t\tif (!this._markerGroup) {\n\t\t\t\tthis._initMarkers();\n\t\t\t}\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tvar poly = this._poly;\n\n\t\tpoly.setStyle(poly.options.original);\n\n\t\tif (poly._map) {\n\t\t\tpoly._map.removeLayer(this._markerGroup);\n\t\t\tdelete this._markerGroup;\n\t\t\tdelete this._markers;\n\t\t}\n\t},\n\n\t// @method updateMarkers(): void\n\t// Clear markers and update their location\n\tupdateMarkers: function () {\n\t\tthis._markerGroup.clearLayers();\n\t\tthis._initMarkers();\n\t},\n\n\t_initMarkers: function () {\n\t\tif (!this._markerGroup) {\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t}\n\t\tthis._markers = [];\n\n\t\tvar latlngs = this._defaultShape(),\n\t\t\ti, j, len, marker;\n\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\n\n\t\t\tmarker = this._createMarker(latlngs[i], i);\n\t\t\tmarker.on('click', this._onMarkerClick, this);\n\t\t\tthis._markers.push(marker);\n\t\t}\n\n\t\tvar markerLeft, markerRight;\n\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tmarkerLeft = this._markers[j];\n\t\t\tmarkerRight = this._markers[i];\n\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng, index) {\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\n\t\tvar marker = new L.Marker.Touch(latlng, {\n\t\t\tdraggable: true,\n\t\t\ticon: this.options.icon,\n\t\t});\n\n\t\tmarker._origLatLng = latlng;\n\t\tmarker._index = index;\n\n\t\tmarker\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\n\t\t\t.on('drag', this._onMarkerDrag, this)\n\t\t\t.on('dragend', this._fireEdit, this)\n\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t.on('touchend', this._fireEdit, this)\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_onMarkerDragStart: function () {\n\t\tthis._poly.fire('editstart');\n\t},\n\n\t_spliceLatLngs: function () {\n\t\tvar latlngs = this._defaultShape();\n\t\tvar removed = [].splice.apply(latlngs, arguments);\n\t\tthis._poly._convertLatLngs(latlngs, true);\n\t\tthis._poly.redraw();\n\t\treturn removed;\n\t},\n\n\t_removeMarker: function (marker) {\n\t\tvar i = marker._index;\n\n\t\tthis._markerGroup.removeLayer(marker);\n\t\tthis._markers.splice(i, 1);\n\t\tthis._spliceLatLngs(i, 1);\n\t\tthis._updateIndexes(i, -1);\n\n\t\tmarker\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\n\t\t\t.off('drag', this._onMarkerDrag, this)\n\t\t\t.off('dragend', this._fireEdit, this)\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\n\t\t\t.off('touchend', this._fireEdit, this)\n\t\t\t.off('click', this._onMarkerClick, this)\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\n\t},\n\n\t_fireEdit: function () {\n\t\tthis._poly.edited = true;\n\t\tthis._poly.fire('edit');\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, { layers: this._markerGroup, poly: this._poly });\n\t},\n\n\t_onMarkerDrag: function (e) {\n\t\tvar marker = e.target;\n\t\tvar poly = this._poly;\n\n\t\tL.extend(marker._origLatLng, marker._latlng);\n\n\t\tif (marker._middleLeft) {\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\n\t\t}\n\n\t\tif (poly.options.poly) {\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\n\n\t\t\t// If we don't allow intersections and the polygon intersects\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\n\n\t\t\t\tvar originalColor = poly.options.color;\n\t\t\t\tpoly.setStyle({ color: this.options.drawError.color });\n\n\t\t\t\t// Manually trigger 'dragend' behavior on marker we are about to remove\n\t\t\t\t// WORKAROUND: introduced in 1.0.0-rc2, may be related to #4484\n\t\t\t\tif (L.version.indexOf('0.7') !== 0) {\n\t\t\t\t\tmarker.dragging._draggable._onUp(e);\n\t\t\t\t}\n\t\t\t\tthis._onMarkerClick(e); // Remove violating marker\n\t\t\t\t// FIXME: Reset the marker to it's original position (instead of remove)\n\n\t\t\t\tif (tooltip) {\n\t\t\t\t\ttooltip.updateContent({\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Reset everything back to normal after a second\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tpoly.setStyle({ color: originalColor });\n\t\t\t\t\tif (tooltip) {\n\t\t\t\t\t\ttooltip.updateContent({\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}, 1000);\n\t\t\t}\n\t\t}\n\n\t\tthis._poly.redraw();\n\t\tthis._poly.fire('editdrag');\n\t},\n\n\t_onMarkerClick: function (e) {\n\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\n\t\t\tmarker = e.target;\n\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\n\t\tif (this._defaultShape().length < minPoints) {\n\t\t\treturn;\n\t\t}\n\n\t\t// remove the marker\n\t\tthis._removeMarker(marker);\n\n\t\t// update prev/next links of adjacent markers\n\t\tthis._updatePrevNext(marker._prev, marker._next);\n\n\t\t// remove ghost markers near the removed marker\n\t\tif (marker._middleLeft) {\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\n\t\t}\n\n\t\t// create a ghost marker in place of the removed one\n\t\tif (marker._prev && marker._next) {\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\n\n\t\t} else if (!marker._prev) {\n\t\t\tmarker._next._middleLeft = null;\n\n\t\t} else if (!marker._next) {\n\t\t\tmarker._prev._middleRight = null;\n\t\t}\n\n\t\tthis._fireEdit();\n\t},\n\n\t_onTouchMove: function (e) {\n\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\n\t\t\tmarker = e.target;\n\n\t\tL.extend(marker._origLatLng, latlng);\n\n\t\tif (marker._middleLeft) {\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\n\t\t}\n\n\t\tthis._poly.redraw();\n\t\tthis.updateMarkers();\n\t},\n\n\t_updateIndexes: function (index, delta) {\n\t\tthis._markerGroup.eachLayer(function (marker) {\n\t\t\tif (marker._index > index) {\n\t\t\t\tmarker._index += delta;\n\t\t\t}\n\t\t});\n\t},\n\n\t_createMiddleMarker: function (marker1, marker2) {\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\n\t\t\tmarker = this._createMarker(latlng),\n\t\t\tonClick,\n\t\t\tonDragStart,\n\t\t\tonDragEnd;\n\n\t\tmarker.setOpacity(0.6);\n\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\n\n\t\tonDragStart = function () {\n\t\t\tmarker.off('touchmove', onDragStart, this);\n\t\t\tvar i = marker2._index;\n\n\t\t\tmarker._index = i;\n\n\t\t\tmarker\n\t\t\t\t.off('click', onClick, this)\n\t\t\t\t.on('click', this._onMarkerClick, this);\n\n\t\t\tlatlng.lat = marker.getLatLng().lat;\n\t\t\tlatlng.lng = marker.getLatLng().lng;\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\n\t\t\tthis._markers.splice(i, 0, marker);\n\n\t\t\tmarker.setOpacity(1);\n\n\t\t\tthis._updateIndexes(i, 1);\n\t\t\tmarker2._index++;\n\t\t\tthis._updatePrevNext(marker1, marker);\n\t\t\tthis._updatePrevNext(marker, marker2);\n\n\t\t\tthis._poly.fire('editstart');\n\t\t};\n\n\t\tonDragEnd = function () {\n\t\t\tmarker.off('dragstart', onDragStart, this);\n\t\t\tmarker.off('dragend', onDragEnd, this);\n\t\t\tmarker.off('touchmove', onDragStart, this);\n\n\t\t\tthis._createMiddleMarker(marker1, marker);\n\t\t\tthis._createMiddleMarker(marker, marker2);\n\t\t};\n\n\t\tonClick = function () {\n\t\t\tonDragStart.call(this);\n\t\t\tonDragEnd.call(this);\n\t\t\tthis._fireEdit();\n\t\t};\n\n\t\tmarker\n\t\t\t.on('click', onClick, this)\n\t\t\t.on('dragstart', onDragStart, this)\n\t\t\t.on('dragend', onDragEnd, this)\n\t\t\t.on('touchmove', onDragStart, this);\n\n\t\tthis._markerGroup.addLayer(marker);\n\t},\n\n\t_updatePrevNext: function (marker1, marker2) {\n\t\tif (marker1) {\n\t\t\tmarker1._next = marker2;\n\t\t}\n\t\tif (marker2) {\n\t\t\tmarker2._prev = marker1;\n\t\t}\n\t},\n\n\t_getMiddleLatLng: function (marker1, marker2) {\n\t\tvar map = this._poly._map,\n\t\t\tp1 = map.project(marker1.getLatLng()),\n\t\t\tp2 = map.project(marker2.getLatLng());\n\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\n\t}\n});\n\nL.Polyline.addInitHook(function () {\n\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\n\tif (this.editing) {\n\t\treturn;\n\t}\n\n\tif (L.Edit.Poly) {\n\n\t\tthis.editing = new L.Edit.Poly(this, this.options.poly);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n\n\tthis.on('add', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.addHooks();\n\t\t}\n\t});\n\n\tthis.on('remove', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.removeHooks();\n\t\t}\n\t});\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.SimpleShape\n * @aka Edit.SimpleShape\n */\nL.Edit.SimpleShape = L.Handler.extend({\n\toptions: {\n\t\tmoveIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\n\t\t}),\n\t\tresizeIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\n\t\t}),\n\t\ttouchMoveIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\n\t\t}),\n\t\ttouchResizeIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\n\t\t}),\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (shape, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\n\t\t}\n\n\t\tthis._shape = shape;\n\t\tL.Util.setOptions(this, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar shape = this._shape;\n\t\tif (this._shape._map) {\n\t\t\tthis._map = this._shape._map;\n\t\t\tshape.setStyle(shape.options.editing);\n\n\t\t\tif (shape._map) {\n\t\t\t\tthis._map = shape._map;\n\t\t\t\tif (!this._markerGroup) {\n\t\t\t\t\tthis._initMarkers();\n\t\t\t\t}\n\t\t\t\tthis._map.addLayer(this._markerGroup);\n\t\t\t}\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tvar shape = this._shape;\n\n\t\tshape.setStyle(shape.options.original);\n\n\t\tif (shape._map) {\n\t\t\tthis._unbindMarker(this._moveMarker);\n\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\n\t\t\t}\n\t\t\tthis._resizeMarkers = null;\n\n\t\t\tthis._map.removeLayer(this._markerGroup);\n\t\t\tdelete this._markerGroup;\n\t\t}\n\n\t\tthis._map = null;\n\t},\n\n\t// @method updateMarkers(): void\n\t// Remove the edit markers from this layer\n\tupdateMarkers: function () {\n\t\tthis._markerGroup.clearLayers();\n\t\tthis._initMarkers();\n\t},\n\n\t_initMarkers: function () {\n\t\tif (!this._markerGroup) {\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t}\n\n\t\t// Create center marker\n\t\tthis._createMoveMarker();\n\n\t\t// Create edge marker\n\t\tthis._createResizeMarker();\n\t},\n\n\t_createMoveMarker: function () {\n\t\t// Children override\n\t},\n\n\t_createResizeMarker: function () {\n\t\t// Children override\n\t},\n\n\t_createMarker: function (latlng, icon) {\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\n\t\tvar marker = new L.Marker.Touch(latlng, {\n\t\t\tdraggable: true,\n\t\t\ticon: icon,\n\t\t\tzIndexOffset: 10\n\t\t});\n\n\t\tthis._bindMarker(marker);\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_bindMarker: function (marker) {\n\t\tmarker\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\n\t\t\t.on('drag', this._onMarkerDrag, this)\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\n\t\t\t.on('touchstart', this._onTouchStart, this)\n\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t.on('touchend', this._onTouchEnd, this)\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\n\t},\n\n\t_unbindMarker: function (marker) {\n\t\tmarker\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\n\t\t\t.off('drag', this._onMarkerDrag, this)\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\n\t\t\t.off('touchstart', this._onTouchStart, this)\n\t\t\t.off('touchmove', this._onTouchMove, this)\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t.off('touchend', this._onTouchEnd, this)\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\n\t},\n\n\t_onMarkerDragStart: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(0);\n\n\t\tthis._shape.fire('editstart');\n\t},\n\n\t_fireEdit: function () {\n\t\tthis._shape.edited = true;\n\t\tthis._shape.fire('edit');\n\t},\n\n\t_onMarkerDrag: function (e) {\n\t\tvar marker = e.target,\n\t\t\tlatlng = marker.getLatLng();\n\n\t\tif (marker === this._moveMarker) {\n\t\t\tthis._move(latlng);\n\t\t} else {\n\t\t\tthis._resize(latlng);\n\t\t}\n\n\t\tthis._shape.redraw();\n\t\tthis._shape.fire('editdrag');\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(1);\n\n\t\tthis._fireEdit();\n\t},\n\n\t_onTouchStart: function (e) {\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\n\n\t\tif (typeof(this._getCorners) === 'function') {\n\t\t\t// Save a reference to the opposite point\n\t\t\tvar corners = this._getCorners(),\n\t\t\t\tmarker = e.target,\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\n\n\t\t\tmarker.setOpacity(0);\n\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\n\t\t\t// Latlng is null otherwise.\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\n\t\t}\n\n\t\tthis._shape.fire('editstart');\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\n\t\t\tmarker = e.target;\n\n\t\tif (marker === this._moveMarker) {\n\t\t\tthis._move(latlng);\n\t\t} else {\n\t\t\tthis._resize(latlng);\n\t\t}\n\n\t\tthis._shape.redraw();\n\n\t\t// prevent touchcancel in IOS\n\t\t// e.preventDefault();\n\t\treturn false;\n\t},\n\n\t_onTouchEnd: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(1);\n\t\tthis.updateMarkers();\n\t\tthis._fireEdit();\n\t},\n\n\t_move: function () {\n\t\t// Children override\n\t},\n\n\t_resize: function () {\n\t\t// Children override\n\t}\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.Rectangle\n * @aka Edit.Rectangle\n * @inherits L.Edit.SimpleShape\n */\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\n\t_createMoveMarker: function () {\n\t\tvar bounds = this._shape.getBounds(),\n\t\t\tcenter = bounds.getCenter();\n\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\n\t},\n\n\t_createResizeMarker: function () {\n\t\tvar corners = this._getCorners();\n\n\t\tthis._resizeMarkers = [];\n\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\n\t\t}\n\t},\n\n\t_onMarkerDragStart: function (e) {\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\n\n\t\t// Save a reference to the opposite point\n\t\tvar corners = this._getCorners(),\n\t\t\tmarker = e.target,\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\n\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\n\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar marker = e.target,\n\t\t\tbounds, center;\n\n\t\t// Reset move marker position to the center\n\t\tif (marker === this._moveMarker) {\n\t\t\tbounds = this._shape.getBounds();\n\t\t\tcenter = bounds.getCenter();\n\n\t\t\tmarker.setLatLng(center);\n\t\t}\n\n\t\tthis._toggleCornerMarkers(1);\n\n\t\tthis._repositionCornerMarkers();\n\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\n\t},\n\n\t_move: function (newCenter) {\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\n\t\t\tbounds = this._shape.getBounds(),\n\t\t\tcenter = bounds.getCenter(),\n\t\t\toffset, newLatLngs = [];\n\n\t\t// Offset the latlngs to the new center\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\n\t\t}\n\n\t\tthis._shape.setLatLngs(newLatLngs);\n\n\t\t// Reposition the resize markers\n\t\tthis._repositionCornerMarkers();\n\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, { layer: this._shape });\n\t},\n\n\t_resize: function (latlng) {\n\t\tvar bounds;\n\n\t\t// Update the shape based on the current position of this corner and the opposite point\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\n\n\t\t// Reposition the move marker\n\t\tbounds = this._shape.getBounds();\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\n\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, { layer: this._shape });\n\t},\n\n\t_getCorners: function () {\n\t\tvar bounds = this._shape.getBounds(),\n\t\t\tnw = bounds.getNorthWest(),\n\t\t\tne = bounds.getNorthEast(),\n\t\t\tse = bounds.getSouthEast(),\n\t\t\tsw = bounds.getSouthWest();\n\n\t\treturn [nw, ne, se, sw];\n\t},\n\n\t_toggleCornerMarkers: function (opacity) {\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\n\t\t}\n\t},\n\n\t_repositionCornerMarkers: function () {\n\t\tvar corners = this._getCorners();\n\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\n\t\t}\n\t}\n});\n\nL.Rectangle.addInitHook(function () {\n\tif (L.Edit.Rectangle) {\n\t\tthis.editing = new L.Edit.Rectangle(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.CircleMarker\n * @aka Edit.Circle\n * @inherits L.Edit.SimpleShape\n */\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\n\t_createMoveMarker: function () {\n\t\tvar center = this._shape.getLatLng();\n\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\n\t},\n\n\t_createResizeMarker: function () {\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\n\t\tthis._resizeMarkers = [];\n\t},\n\n\t_move: function (latlng) {\n\t\tif (this._resizeMarkers.length) {\n\t\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\n\t\t\t\t// Move the resize marker\n\t\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\n\t\t}\n\n\t\t// Move the circle\n\t\tthis._shape.setLatLng(latlng);\n\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, { layer: this._shape });\n\t},\n});\n\nL.CircleMarker.addInitHook(function () {\n\tif (L.Edit.CircleMarker) {\n\t\tthis.editing = new L.Edit.CircleMarker(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n\n\tthis.on('add', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.addHooks();\n\t\t}\n\t});\n\n\tthis.on('remove', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.removeHooks();\n\t\t}\n\t});\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.Circle\n * @aka Edit.Circle\n * @inherits L.Edit.CircleMarker\n */\nL.Edit.Circle = L.Edit.CircleMarker.extend({\n\n\t_createResizeMarker: function () {\n\t\tvar center = this._shape.getLatLng(),\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\n\n\t\tthis._resizeMarkers = [];\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\n\t},\n\n\t_getResizeMarkerPoint: function (latlng) {\n\t\t// From L.shape.getBounds()\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\n\t\t\tpoint = this._map.project(latlng);\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\n\t},\n\n\t_resize: function (latlng) {\n\t\tvar moveLatLng = this._moveMarker.getLatLng(),\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\n\n\t\tthis._shape.setRadius(radius);\n\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, { layer: this._shape });\n\t}\n});\n\nL.Circle.addInitHook(function () {\n\tif (L.Edit.Circle) {\n\t\tthis.editing = new L.Edit.Circle(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n\n\tthis.on('add', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.addHooks();\n\t\t}\n\t});\n\n\tthis.on('remove', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.removeHooks();\n\t\t}\n\t});\n});\n","L.Map.mergeOptions({\n\ttouchExtend: true\n});\n\n/**\n * @class L.Map.TouchExtend\n * @aka TouchExtend\n */\nL.Map.TouchExtend = L.Handler.extend({\n\n\t// @method initialize(): void\n\t// Sets TouchExtend private accessor variables\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t\tthis._container = map._container;\n\t\tthis._pane = map._panes.overlayPane;\n\t},\n\n\t// @method addHooks(): void\n\t// Adds dom listener events to the map container\n\taddHooks: function () {\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\n\t\tif (this._detectIE()) {\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\n\n\t\t} else {\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Removes dom listener events from the map container\n\tremoveHooks: function () {\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart);\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd);\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove);\n\t\tif (this._detectIE()) {\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDowm', this._onTouchStart);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel);\n\t\t} else {\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel);\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave);\n\t\t}\n\t},\n\n\t_touchEvent: function (e, type) {\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\n\t\t// _filterClick is what leaflet uses as a workaround.\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\n\t\t// its touch list.\n\t\tvar touchEvent = {};\n\t\tif (typeof e.touches !== 'undefined') {\n\t\t\tif (!e.touches.length) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttouchEvent = e.touches[0];\n\t\t} else if (e.pointerType === 'touch') {\n\t\t\ttouchEvent = e;\n\t\t\tif (!this._filterClick(e)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\n\t\tthis._map.fire(type, {\n\t\t\tlatlng: latlng,\n\t\t\tlayerPoint: layerPoint,\n\t\t\tcontainerPoint: containerPoint,\n\t\t\tpageX: touchEvent.pageX,\n\t\t\tpageY: touchEvent.pageY,\n\t\t\toriginalEvent: e\n\t\t});\n\t},\n\n\t/** Borrowed from Leaflet and modified for bool ops **/\n\t_filterClick: function (e) {\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\n\n\t\t// are they closer together than 500ms yet more than 100ms?\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\n\t\t// on the same event should be triggered far faster;\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\n\t\t\tL.DomEvent.stop(e);\n\t\t\treturn false;\n\t\t}\n\t\tL.DomEvent._lastClick = timeStamp;\n\t\treturn true;\n\t},\n\n\t_onTouchStart: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchstart';\n\t\tthis._touchEvent(e, type);\n\n\t},\n\n\t_onTouchEnd: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchend';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchCancel: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchcancel';\n\t\tif (this._detectIE()) {\n\t\t\ttype = 'pointercancel';\n\t\t}\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchLeave: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchleave';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchmove';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_detectIE: function () {\n\t\tvar ua = window.navigator.userAgent;\n\n\t\tvar msie = ua.indexOf('MSIE ');\n\t\tif (msie > 0) {\n\t\t\t// IE 10 or older => return version number\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\n\t\t}\n\n\t\tvar trident = ua.indexOf('Trident/');\n\t\tif (trident > 0) {\n\t\t\t// IE 11 => return version number\n\t\t\tvar rv = ua.indexOf('rv:');\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\n\t\t}\n\n\t\tvar edge = ua.indexOf('Edge/');\n\t\tif (edge > 0) {\n\t\t\t// IE 12 => return version number\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\n\t\t}\n\n\t\t// other browser\n\t\treturn false;\n\t}\n});\n\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\n\n\n/**\n * @class L.Marker.Touch\n * @aka Marker.Touch\n *\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\n * #TODO: find a better way of getting markers to support touch.\n */\nL.Marker.Touch = L.Marker.extend({\n\n\t_initInteraction: function () {\n\t\tif (!this.addInteractiveTarget) {\n\t\t\t// 0.7.x support\n\t\t\treturn this._initInteractionLegacy();\n\t\t}\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\n\t},\n\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\n\t// with the addition of the touch events\n\t_initInteractionLegacy: function () {\n\n\t\tif (!this.options.clickable) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\n\n\t\tvar icon = this._icon,\n\t\t\tevents = ['dblclick',\n\t\t\t\t\t  'mousedown',\n\t\t\t\t\t  'mouseover',\n\t\t\t\t\t  'mouseout',\n\t\t\t\t\t  'contextmenu',\n\t\t\t\t\t  'touchstart',\n\t\t\t\t\t  'touchend',\n\t\t\t\t\t  'touchmove'];\n\t\tif (this._detectIE) {\n\t\t\tevents.concat(['MSPointerDown',\n\t\t\t\t\t\t   'MSPointerUp',\n\t\t\t\t\t\t   'MSPointerMove',\n\t\t\t\t\t\t   'MSPointerCancel']);\n\t\t} else {\n\t\t\tevents.concat(['touchcancel']);\n\t\t}\n\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\n\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\n\t\t}\n\n\t\tif (L.Handler.MarkerDrag) {\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\n\n\t\t\tif (this.options.draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t},\n\n\t_detectIE: function () {\n\t\tvar ua = window.navigator.userAgent;\n\n\t\tvar msie = ua.indexOf('MSIE ');\n\t\tif (msie > 0) {\n\t\t\t// IE 10 or older => return version number\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\n\t\t}\n\n\t\tvar trident = ua.indexOf('Trident/');\n\t\tif (trident > 0) {\n\t\t\t// IE 11 => return version number\n\t\t\tvar rv = ua.indexOf('rv:');\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\n\t\t}\n\n\t\tvar edge = ua.indexOf('Edge/');\n\t\tif (edge > 0) {\n\t\t\t// IE 12 => return version number\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\n\t\t}\n\n\t\t// other browser\n\t\treturn false;\n\t}\n});\n","/**\n * @class L.LatLngUtil\n * @aka LatLngUtil\n */\nL.LatLngUtil = {\n\t// Clones a LatLngs[], returns [][]\n\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\n\t// Clone the latLng point or points or nested points and return an array with those points\n\tcloneLatLngs: function (latlngs) {\n\t\tvar clone = [];\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\n\t\t\t// Check for nested array (Polyline/Polygon)\n\t\t\tif (Array.isArray(latlngs[i])) {\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\n\t\t\t} else {\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\n\t\t\t}\n\t\t}\n\t\treturn clone;\n\t},\n\n\t// @method cloneLatLng(LatLng): L.LatLng\n\t// Clone the latLng and return a new LatLng object.\n\tcloneLatLng: function (latlng) {\n\t\treturn L.latLng(latlng.lat, latlng.lng);\n\t}\n};\n","(function() {\n\nvar defaultPrecision = {\n\tkm: 2,\n\tha: 2,\n\tm: 0,\n\tmi: 2,\n\tac: 2,\n\tyd: 0,\n\tft: 0,\n\tnm: 2\n};\n\n\n/**\n * @class L.GeometryUtil\n * @aka GeometryUtil\n */\nL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\n\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\n\n\t// @method geodesicArea(): number\n\tgeodesicArea: function (latLngs) {\n\t\tvar pointsCount = latLngs.length,\n\t\t\tarea = 0.0,\n\t\t\td2r = Math.PI / 180,\n\t\t\tp1, p2;\n\n\t\tif (pointsCount > 2) {\n\t\t\tfor (var i = 0; i < pointsCount; i++) {\n\t\t\t\tp1 = latLngs[i];\n\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\n\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\n\t\t\t}\n\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\n\t\t}\n\n\t\treturn Math.abs(area);\n\t},\n\n\t// @method formattedNumber(n, precision): string\n\t// Returns n in specified number format (if defined) and precision\n\tformattedNumber: function (n, precision) {\n\t\tvar formatted = parseFloat(n).toFixed(precision),\n\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\n\t\t\tdelimiters = format && format.delimiters,\n\t\t\tthousands = delimiters && delimiters.thousands,\n\t\t\tdecimal = delimiters && delimiters.decimal;\n\n\t\tif (thousands || decimal) {\n\t\t\tvar splitValue = formatted.split('.');\n\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\n\t\t\tdecimal = decimal || '.';\n\t\t\tif (splitValue.length > 1) {\n\t\t\t\tformatted = formatted + decimal + splitValue[1];\n\t\t\t}\n\t\t}\n\n\t\treturn formatted;\n\t},\n\n\t// @method readableArea(area, isMetric, precision): string\n\t// Returns a readable area string in yards or metric.\n\t// The value will be rounded as defined by the precision option object.\n\treadableArea: function (area, isMetric, precision) {\n\t\tvar areaStr,\n\t\t\tunits,\n\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\n\n\t\tif (isMetric) {\n\t\t\tunits = ['ha', 'm'];\n\t\t\ttype = typeof isMetric;\n\t\t\tif (type === 'string') {\n\t\t\t\tunits = [isMetric];\n\t\t\t} else if (type !== 'boolean') {\n\t\t\t\tunits = isMetric;\n\t\t\t}\n\n\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\n\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\n\t\t\t} else {\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\n\t\t\t}\n\t\t} else {\n\t\t\tarea /= 0.836127; // Square yards in 1 meter\n\n\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\n\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\n\t\t\t} else {\n\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\n\t\t\t}\n\t\t}\n\n\t\treturn areaStr;\n\t},\n\n\t// @method readableDistance(distance, units): string\n\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\n\t//\n\t// @alternative\n\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\n\t// Converts metric distance to distance string.\n\t// The value will be rounded as defined by the precision option object.\n\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\n\t\tvar distanceStr,\n\t\t\tunits,\n\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\n\n\t\tif (isMetric) {\n\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\n\t\t} else if (isFeet) {\n\t\t\tunits = 'feet';\n\t\t} else if (isNauticalMile) {\n\t\t\tunits = 'nauticalMile';\n\t\t} else {\n\t\t\tunits = 'yards';\n\t\t}\n\n\t\tswitch (units) {\n\t\tcase 'metric':\n\t\t\t// show metres when distance is < 1km, then show km\n\t\t\tif (distance > 1000) {\n\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\n\t\t\t} else {\n\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'feet':\n\t\t\tdistance *= 1.09361 * 3;\n\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\n\n\t\t\tbreak;\n\t\tcase 'nauticalMile':\n\t\t\tdistance *= 0.53996;\n\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\n\t\t\tbreak;\n\t\tcase 'yards':\n\t\tdefault:\n\t\t\tdistance *= 1.09361;\n\n\t\t\tif (distance > 1760) {\n\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\n\t\t\t} else {\n\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\treturn distanceStr;\n\t}\n});\n\n})();\n","/**\n * @class L.LineUtil\n * @aka Util\n * @aka L.Utils\n */\nL.Util.extend(L.LineUtil, {\n\n\t// @method segmentsIntersect(): boolean\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\n\t\t\t   this._checkCounterclockwise(p1, p2, p3) &&\n\t\t\t   this._checkCounterclockwise(p, p1, p2) !==\n\t\t\t   this._checkCounterclockwise(p, p1, p3);\n\t},\n\n\t// check to see if points are in counterclockwise order\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\n\t}\n});","/**\n * @class L.Polyline\n * @aka Polyline\n */\nL.Polyline.include({\n\n\t// @method intersects(): boolean\n\t// Check to see if this polyline has any linesegments that intersect.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tintersects: function () {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0,\n\t\t\ti, p, p1;\n\n\t\tif (this._tooFewPointsForIntersection()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (i = len - 1; i >= 3; i--) {\n\t\t\tp = points[i - 1];\n\t\t\tp1 = points[i];\n\n\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t// @method newLatLngIntersects(): boolean\n\t// Check for intersection if new latlng was added to this polyline.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tnewLatLngIntersects: function (latlng, skipFirst) {\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\n\t\tif (!this._map) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\n\t},\n\n\t// @method newPointIntersects(): boolean\n\t// Check for intersection if new point was added to this polyline.\n\t// newPoint must be a layer point.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tnewPointIntersects: function (newPoint, skipFirst) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0,\n\t\t\tlastPoint = points ? points[len - 1] : null,\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\n\t\t\tmaxIndex = len - 2;\n\n\t\tif (this._tooFewPointsForIntersection(1)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\n\t},\n\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\n\t// Cannot have intersection when < 3 line segments (< 4 points)\n\t_tooFewPointsForIntersection: function (extraPoints) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0;\n\t\t// Increment length by extraPoints if present\n\t\tlen += extraPoints || 0;\n\n\t\treturn !points || len <= 3;\n\t},\n\n\t// Checks a line segment intersections with any line segments before its predecessor.\n\t// Don't need to check the predecessor as will never intersect.\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tp2, p3;\n\n\t\tminIndex = minIndex || 0;\n\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\n\t\t\tp2 = points[j - 1];\n\t\t\tp3 = points[j];\n\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t_getProjectedPoints: function () {\n\t\tif (!this._defaultShape) {\n\t\t\treturn this._originalPoints;\n\t\t}\n\t\tvar points = [],\n\t\t\t_shape = this._defaultShape();\n\n\t\tfor (var i = 0; i < _shape.length; i++) {\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\n\t\t}\n\t\treturn points;\n\t}\n});\n","/**\n * @class L.Polygon\n * @aka Polygon\n */\nL.Polygon.include({\n\n\t// @method intersects(): boolean\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\n\tintersects: function () {\n\t\tvar polylineIntersects,\n\t\t\tpoints = this._getProjectedPoints(),\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\n\n\t\tif (this._tooFewPointsForIntersection()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\n\n\t\t// If already found an intersection don't need to check for any more.\n\t\tif (polylineIntersects) {\n\t\t\treturn true;\n\t\t}\n\n\t\tlen = points.length;\n\t\tfirstPoint = points[0];\n\t\tlastPoint = points[len - 1];\n\t\tmaxIndex = len - 2;\n\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\n\t}\n});\n","/**\n * @class L.Control.Draw\n * @aka L.Draw\n */\nL.Control.Draw = L.Control.extend({\n\n\t// Options\n\toptions: {\n\t\tposition: 'topleft',\n\t\tdraw: {},\n\t\tedit: false\n\t},\n\n\t// @method initialize(): void\n\t// Initializes draw control, toolbars from the options\n\tinitialize: function (options) {\n\t\tif (L.version < '0.7') {\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\n\t\t}\n\n\t\tL.Control.prototype.initialize.call(this, options);\n\n\t\tvar toolbar;\n\n\t\tthis._toolbars = {};\n\n\t\t// Initialize toolbars\n\t\tif (L.DrawToolbar && this.options.draw) {\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\n\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\n\n\t\t\t// Listen for when toolbar is enabled\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\n\t\t}\n\n\t\tif (L.EditToolbar && this.options.edit) {\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\n\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\n\n\t\t\t// Listen for when toolbar is enabled\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\n\t\t}\n\t\tL.toolbar = this; //set global var for editing the toolbar\n\t},\n\n\t// @method onAdd(): container\n\t// Adds the toolbar container to the map\n\tonAdd: function (map) {\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\n\t\t\taddedTopClass = false,\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\n\t\t\ttoolbarContainer;\n\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\n\n\t\t\t\tif (toolbarContainer) {\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\n\t\t\t\t\tif (!addedTopClass) {\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\n\t\t\t\t\t\t}\n\t\t\t\t\t\taddedTopClass = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn container;\n\t},\n\n\t// @method onRemove(): void\n\t// Removes the toolbars from the map toolbar container\n\tonRemove: function () {\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\n\t\t\t}\n\t\t}\n\t},\n\n\t// @method setDrawingOptions(options): void\n\t// Sets options to all toolbar instances\n\tsetDrawingOptions: function (options) {\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\n\t\t\t}\n\t\t}\n\t},\n\n\t_toolbarEnabled: function (e) {\n\t\tvar enabledToolbar = e.target;\n\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\n\t\t\t\tthis._toolbars[toolbarId].disable();\n\t\t\t}\n\t\t}\n\t}\n});\n\nL.Map.mergeOptions({\n\tdrawControlTooltips: true,\n\tdrawControl: false\n});\n\nL.Map.addInitHook(function () {\n\tif (this.options.drawControl) {\n\t\tthis.drawControl = new L.Control.Draw();\n\t\tthis.addControl(this.drawControl);\n\t}\n});\n","/**\n * @class L.Draw.Toolbar\n * @aka Toolbar\n *\n * The toolbar class of the API — it is used to create the ui\n * This will be depreciated\n *\n * @example\n *\n * ```js\n *    var toolbar = L.Toolbar();\n *    toolbar.addToolbar(map);\n * ```\n *\n * ### Disabling a toolbar\n *\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\n *\n * ```js\n *      var drawControl = new L.Control.Draw({\n *          draw: false,\n *          edit: {\n *              featureGroup: editableLayers\n *          }\n *      });\n * ```\n *\n * ### Disabling a toolbar item\n *\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\n * markers. It also turns off the ability to edit layers.\n *\n * ```js\n *      var drawControl = new L.Control.Draw({\n *          draw: {\n *              polygon: false,\n *              marker: false\n *          },\n *          edit: {\n *              featureGroup: editableLayers,\n *              edit: false\n *          }\n *      });\n * ```\n */\nL.Toolbar = L.Class.extend({\n\tincludes: [L.Mixin.Events],\n\n\t// @section Methods for modifying the toolbar\n\n\t// @method initialize(options): void\n\t// Toolbar constructor\n\tinitialize: function (options) {\n\t\tL.setOptions(this, options);\n\n\t\tthis._modes = {};\n\t\tthis._actionButtons = [];\n\t\tthis._activeMode = null;\n\t},\n\n\t// @method enabled(): boolean\n\t// Gets a true/false of whether the toolbar is enabled\n\tenabled: function () {\n\t\treturn this._activeMode !== null;\n\t},\n\n\t// @method disable(): void\n\t// Disables the toolbar\n\tdisable: function () {\n\t\tif (!this.enabled()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._activeMode.handler.disable();\n\t},\n\n\t// @method addToolbar(map): L.DomUtil\n\t// Adds the toolbar to the map and returns the toolbar dom element\n\taddToolbar: function (map) {\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\n\t\t\tbuttonIndex = 0,\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\n\t\t\tmodeHandlers = this.getModeHandlers(map),\n\t\t\ti;\n\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\n\t\tthis._map = map;\n\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\n\t\t\tif (modeHandlers[i].enabled) {\n\t\t\t\tthis._initModeHandler(\n\t\t\t\t\tmodeHandlers[i].handler,\n\t\t\t\t\tthis._toolbarContainer,\n\t\t\t\t\tbuttonIndex++,\n\t\t\t\t\tbuttonClassPrefix,\n\t\t\t\t\tmodeHandlers[i].title\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// if no buttons were added, do not add the toolbar\n\t\tif (!buttonIndex) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\n\t\tthis._lastButtonIndex = --buttonIndex;\n\n\t\t// Create empty actions part of the toolbar\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\n\n\t\t// Add draw and cancel containers to the control container\n\t\tcontainer.appendChild(this._toolbarContainer);\n\t\tcontainer.appendChild(this._actionsContainer);\n\n\t\treturn container;\n\t},\n\n\t// @method removeToolbar(): void\n\t// Removes the toolbar and drops the handler event listeners\n\tremoveToolbar: function () {\n\t\t// Dispose each handler\n\t\tfor (var handlerId in this._modes) {\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\n\t\t\t\t// Unbind handler button\n\t\t\t\tthis._disposeButton(\n\t\t\t\t\tthis._modes[handlerId].button,\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\n\t\t\t\t\tthis._modes[handlerId].handler\n\t\t\t\t);\n\n\t\t\t\t// Make sure is disabled\n\t\t\t\tthis._modes[handlerId].handler.disable();\n\n\t\t\t\t// Unbind handler\n\t\t\t\tthis._modes[handlerId].handler\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\n\t\t\t}\n\t\t}\n\t\tthis._modes = {};\n\n\t\t// Dispose the actions toolbar\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\n\t\t\tthis._disposeButton(\n\t\t\t\tthis._actionButtons[i].button,\n\t\t\t\tthis._actionButtons[i].callback,\n\t\t\t\tthis\n\t\t\t);\n\t\t}\n\t\tthis._actionButtons = [];\n\t\tthis._actionsContainer = null;\n\t},\n\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\n\t\tvar type = handler.type;\n\n\t\tthis._modes[type] = {};\n\n\t\tthis._modes[type].handler = handler;\n\n\t\tthis._modes[type].button = this._createButton({\n\t\t\ttype: type,\n\t\t\ttitle: buttonTitle,\n\t\t\tclassName: classNamePredix + '-' + type,\n\t\t\tcontainer: container,\n\t\t\tcallback: this._modes[type].handler.enable,\n\t\t\tcontext: this._modes[type].handler\n\t\t});\n\n\t\tthis._modes[type].buttonIndex = buttonIndex;\n\n\t\tthis._modes[type].handler\n\t\t\t.on('enabled', this._handlerActivated, this)\n\t\t\t.on('disabled', this._handlerDeactivated, this);\n\t},\n\n\t/* Detect iOS based on browser User Agent, based on:\n\t * http://stackoverflow.com/a/9039885 */\n\t_detectIOS: function () {\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\n\t\treturn iOS;\n\t},\n\n\t_createButton: function (options) {\n\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\n\t\t// Screen reader tag\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\n\n\t\tlink.href = '#';\n\t\tlink.appendChild(sr);\n\n\t\tif (options.title) {\n\t\t\tlink.title = options.title;\n\t\t\tsr.innerHTML = options.title;\n\t\t}\n\n\t\tif (options.text) {\n\t\t\tlink.innerHTML = options.text;\n\t\t\tsr.innerHTML = options.text;\n\t\t}\n\n\t\t/* iOS does not use click events */\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\n\n\t\tL.DomEvent\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\n\n\t\treturn link;\n\t},\n\n\t_disposeButton: function (button, callback) {\n\t\t/* iOS does not use click events */\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\n\n\t\tL.DomEvent\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\n\t\t\t.off(button, buttonEvent, callback);\n\t},\n\n\t_handlerActivated: function (e) {\n\t\t// Disable active mode (if present)\n\t\tthis.disable();\n\n\t\t// Cache new active feature\n\t\tthis._activeMode = this._modes[e.handler];\n\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\n\n\t\tthis._showActionsToolbar();\n\n\t\tthis.fire('enable');\n\t},\n\n\t_handlerDeactivated: function () {\n\t\tthis._hideActionsToolbar();\n\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\n\n\t\tthis._activeMode = null;\n\n\t\tthis.fire('disable');\n\t},\n\n\t_createActions: function (handler) {\n\t\tvar container = this._actionsContainer,\n\t\t\tbuttons = this.getActions(handler),\n\t\t\tl = buttons.length,\n\t\t\tli, di, dl, button;\n\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\n\t\t}\n\t\tthis._actionButtons = [];\n\n\t\t// Remove all old buttons\n\t\twhile (container.firstChild) {\n\t\t\tcontainer.removeChild(container.firstChild);\n\t\t}\n\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tli = L.DomUtil.create('li', '', container);\n\n\t\t\tbutton = this._createButton({\n\t\t\t\ttitle: buttons[i].title,\n\t\t\t\ttext: buttons[i].text,\n\t\t\t\tcontainer: li,\n\t\t\t\tcallback: buttons[i].callback,\n\t\t\t\tcontext: buttons[i].context\n\t\t\t});\n\n\t\t\tthis._actionButtons.push({\n\t\t\t\tbutton: button,\n\t\t\t\tcallback: buttons[i].callback\n\t\t\t});\n\t\t}\n\t},\n\n\t_showActionsToolbar: function () {\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\n\t\t\tlastButtonIndex = this._lastButtonIndex,\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\n\n\t\t// Recreate action buttons on every click\n\t\tthis._createActions(this._activeMode.handler);\n\n\t\t// Correctly position the cancel button\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\n\n\t\tif (buttonIndex === 0) {\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\n\t\t}\n\n\t\tif (buttonIndex === lastButtonIndex) {\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\n\t\t}\n\n\t\tthis._actionsContainer.style.display = 'block';\n\t},\n\n\t_hideActionsToolbar: function () {\n\t\tthis._actionsContainer.style.display = 'none';\n\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\n\t}\n});\n","L.Draw = L.Draw || {};\n/**\n * @class L.Draw.Tooltip\n * @aka Tooltip\n *\n * The tooltip class — it is used to display the tooltip while drawing\n * This will be depreciated\n *\n * @example\n *\n * ```js\n *    var tooltip = L.Draw.Tooltip();\n * ```\n *\n */\nL.Draw.Tooltip = L.Class.extend({\n\n\t// @section Methods for modifying draw state\n\n\t// @method initialize(map): void\n\t// Tooltip constructor\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t\tthis._popupPane = map._panes.popupPane;\n\t\tthis._visible = false;\n\n\t\tthis._container = map.options.drawControlTooltips ?\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\n\t\tthis._singleLineLabel = false;\n\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\n\t},\n\n\t// @method dispose(): void\n\t// Remove Tooltip DOM and unbind events\n\tdispose: function () {\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\n\n\t\tif (this._container) {\n\t\t\tthis._popupPane.removeChild(this._container);\n\t\t\tthis._container = null;\n\t\t}\n\t},\n\n\t// @method updateContent(labelText): this\n\t// Changes the tooltip text to string in function call\n\tupdateContent: function (labelText) {\n\t\tif (!this._container) {\n\t\t\treturn this;\n\t\t}\n\t\tlabelText.subtext = labelText.subtext || '';\n\n\t\t// update the vertical position (only if changed)\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\n\t\t\tthis._singleLineLabel = true;\n\t\t}\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\n\t\t\tthis._singleLineLabel = false;\n\t\t}\n\n\t\tthis._container.innerHTML =\n\t\t\t(labelText.subtext.length > 0 ?\n\t\t\t'<span class=\"leaflet-draw-tooltip-subtext\">' + labelText.subtext + '</span>' + '<br />' : '') +\n\t\t\t'<span>' + labelText.text + '</span>';\n\n\t\tif (!labelText.text && !labelText.subtext) {\n\t\t\tthis._visible = false;\n\t\t\tthis._container.style.visibility = 'hidden';\n\t\t} else {\n\t\t\tthis._visible = true;\n\t\t\tthis._container.style.visibility = 'inherit';\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method updatePosition(latlng): this\n\t// Changes the location of the tooltip\n\tupdatePosition: function (latlng) {\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\n\t\t\ttooltipContainer = this._container;\n\n\t\tif (this._container) {\n\t\t\tif (this._visible) {\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\n\t\t\t}\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method showAsError(): this\n\t// Applies error class to tooltip\n\tshowAsError: function () {\n\t\tif (this._container) {\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method removeError(): this\n\t// Removes the error class from the tooltip\n\tremoveError: function () {\n\t\tif (this._container) {\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\n\t\t}\n\t\treturn this;\n\t},\n\n\t_onMouseOut: function () {\n\t\tif (this._container) {\n\t\t\tthis._container.style.visibility = 'hidden';\n\t\t}\n\t}\n});\n","/**\n * @class L.DrawToolbar\n * @aka Toolbar\n */\nL.DrawToolbar = L.Toolbar.extend({\n\n\tstatics: {\n\t\tTYPE: 'draw'\n\t},\n\n\toptions: {\n\t\tpolyline: {},\n\t\tpolygon: {},\n\t\trectangle: {},\n\t\tcircle: {},\n\t\tmarker: {},\n\t\tcirclemarker: {}\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (options) {\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\n\t\tfor (var type in this.options) {\n\t\t\tif (this.options.hasOwnProperty(type)) {\n\t\t\t\tif (options[type]) {\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\n\t\tL.Toolbar.prototype.initialize.call(this, options);\n\t},\n\n\t// @method getModeHandlers(): object\n\t// Get mode handlers information\n\tgetModeHandlers: function (map) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: this.options.polyline,\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.polygon,\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.rectangle,\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.circle,\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.marker,\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.circlemarker,\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method getActions(): object\n\t// Get action information\n\tgetActions: function (handler) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: handler.completeShape,\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\n\t\t\t\tcallback: handler.completeShape,\n\t\t\t\tcontext: handler\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: handler.deleteLastVertex,\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\n\t\t\t\tcallback: handler.deleteLastVertex,\n\t\t\t\tcontext: handler\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\n\t\t\t\tcallback: this.disable,\n\t\t\t\tcontext: this\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method setOptions(): void\n\t// Sets the options to the toolbar\n\tsetOptions: function (options) {\n\t\tL.setOptions(this, options);\n\n\t\tfor (var type in this._modes) {\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\n\t\t\t}\n\t\t}\n\t}\n});\n","/*L.Map.mergeOptions({\n editControl: true\n });*/\n/**\n * @class L.EditToolbar\n * @aka EditToolbar\n */\nL.EditToolbar = L.Toolbar.extend({\n\tstatics: {\n\t\tTYPE: 'edit'\n\t},\n\n\toptions: {\n\t\tedit: {\n\t\t\tselectedPathOptions: {\n\t\t\t\tdashArray: '10, 10',\n\n\t\t\t\tfill: true,\n\t\t\t\tfillColor: '#fe57a1',\n\t\t\t\tfillOpacity: 0.1,\n\n\t\t\t\t// Whether to user the existing layers color\n\t\t\t\tmaintainColor: false\n\t\t\t}\n\t\t},\n\t\tremove: {},\n\t\tpoly: null,\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (options) {\n\t\t// Need to set this manually since null is an acceptable value here\n\t\tif (options.edit) {\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\n\t\t\t}\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\n\t\t}\n\n\t\tif (options.remove) {\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\n\t\t}\n\n\t\tif (options.poly) {\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\n\t\t}\n\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\n\t\tL.Toolbar.prototype.initialize.call(this, options);\n\n\t\tthis._selectedFeatureCount = 0;\n\t},\n\n\t// @method getModeHandlers(): object\n\t// Get mode handlers information\n\tgetModeHandlers: function (map) {\n\t\tvar featureGroup = this.options.featureGroup;\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: this.options.edit,\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\n\t\t\t\t\tfeatureGroup: featureGroup,\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\n\t\t\t\t\tpoly: this.options.poly\n\t\t\t\t}),\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.remove,\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\n\t\t\t\t\tfeatureGroup: featureGroup\n\t\t\t\t}),\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method getActions(): object\n\t// Get actions information\n\tgetActions: function (handler) {\n\t\tvar actions = [\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\n\t\t\t\tcallback: this._save,\n\t\t\t\tcontext: this\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\n\t\t\t\tcallback: this.disable,\n\t\t\t\tcontext: this\n\t\t\t}\n\t\t];\n\n\t\tif (handler.removeAllLayers) {\n\t\t\t actions.push({\n                 title: L.drawLocal.edit.toolbar.actions.clearAll.title,\n                 text: L.drawLocal.edit.toolbar.actions.clearAll.text,\n                 callback: this._clearAllLayers,\n                 context: this\n             });\n\t\t}\n\n\t\treturn actions;\n\t},\n\n\t// @method addToolbar(map): L.DomUtil\n\t// Adds the toolbar to the map\n\taddToolbar: function (map) {\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\n\n\t\tthis._checkDisabled();\n\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\n\n\t\treturn container;\n\t},\n\n\t// @method removeToolbar(): void\n\t// Removes the toolbar from the map\n\tremoveToolbar: function () {\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\n\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\n\t},\n\n\t// @method disable(): void\n\t// Disables the toolbar\n\tdisable: function () {\n\t\tif (!this.enabled()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._activeMode.handler.revertLayers();\n\n\t\tL.Toolbar.prototype.disable.call(this);\n\t},\n\n\t_save: function () {\n\t\tthis._activeMode.handler.save();\n\t\tif (this._activeMode) {\n\t\t\tthis._activeMode.handler.disable();\n\t\t}\n\t},\n\n\t_clearAllLayers:function(){\n\t\tthis._activeMode.handler.removeAllLayers();\n\t\tif (this._activeMode) {\n\t\t\tthis._activeMode.handler.disable();\n\t\t}\n\t},\n\n\t_checkDisabled: function () {\n\t\tvar featureGroup = this.options.featureGroup,\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\n\t\t\tbutton;\n\n\t\tif (this.options.edit) {\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\n\n\t\t\tif (hasLayers) {\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\n\t\t\t} else {\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\n\t\t\t}\n\n\t\t\tbutton.setAttribute(\n\t\t\t\t'title',\n\t\t\t\thasLayers ?\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\n\t\t\t);\n\t\t}\n\n\t\tif (this.options.remove) {\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\n\n\t\t\tif (hasLayers) {\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\n\t\t\t} else {\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\n\t\t\t}\n\n\t\t\tbutton.setAttribute(\n\t\t\t\t'title',\n\t\t\t\thasLayers ?\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\n\t\t\t);\n\t\t}\n\t}\n});\n","/**\n * @class L.EditToolbar.Edit\n * @aka EditToolbar.Edit\n */\nL.EditToolbar.Edit = L.Handler.extend({\n\tstatics: {\n\t\tTYPE: 'edit'\n\t},\n\n\tincludes: L.Mixin.Events,\n\n\t// @method intialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Handler.prototype.initialize.call(this, map);\n\n\t\tL.setOptions(this, options);\n\n\t\t// Store the selectable layer group for ease of access\n\t\tthis._featureGroup = options.featureGroup;\n\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\n\t\t}\n\n\t\tthis._uneditedLayerProps = {};\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\n\t},\n\n\t// @method enable(): void\n\t// Enable the edit toolbar\n\tenable: function () {\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\n\t\t\treturn;\n\t\t}\n\t\tthis.fire('enabled', { handler: this.type });\n\t\t//this disable other handlers\n\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, { handler: this.type });\n\t\t//allow drawLayer to be updated before beginning edition.\n\n\t\tL.Handler.prototype.enable.call(this);\n\t\tthis._featureGroup\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\n\t},\n\n\t// @method disable(): void\n\t// Disable the edit toolbar\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._featureGroup\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\n\t\tL.Handler.prototype.disable.call(this);\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, { handler: this.type });\n\t\tthis.fire('disabled', { handler: this.type });\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks for this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\t\t\tthis._tooltip.updateContent({\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t\t});\n\n\t\t\t// Quickly access the tooltip to update for intersection checking\n\t\t\tmap._editTooltip = this._tooltip;\n\n\t\t\tthis._updateTooltip();\n\n\t\t\tthis._map\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks for this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\t// Clean up selected layers.\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\n\n\t\t\t// Clear the backups of the original layers\n\t\t\tthis._uneditedLayerProps = {};\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tthis._map\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\n\t\t}\n\t},\n\n\t// @method revertLayers(): void\n\t// Revert each layer's geometry changes\n\trevertLayers: function () {\n\t\tthis._featureGroup.eachLayer(function (layer) {\n\t\t\tthis._revertLayer(layer);\n\t\t}, this);\n\t},\n\n\t// @method save(): void\n\t// Save the layer geometries\n\tsave: function () {\n\t\tvar editedLayers = new L.LayerGroup();\n\t\tthis._featureGroup.eachLayer(function (layer) {\n\t\t\tif (layer.edited) {\n\t\t\t\teditedLayers.addLayer(layer);\n\t\t\t\tlayer.edited = false;\n\t\t\t}\n\t\t});\n\t\tthis._map.fire(L.Draw.Event.EDITED, { layers: editedLayers });\n\t},\n\n\t_backupLayer: function (layer) {\n\t\tvar id = L.Util.stamp(layer);\n\n\t\tif (!this._uneditedLayerProps[id]) {\n\t\t\t// Polyline, Polygon or Rectangle\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\n\t\t\t\t};\n\t\t\t} else if (layer instanceof L.Circle) {\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\n\t\t\t\t\tradius: layer.getRadius()\n\t\t\t\t};\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\treturn ({\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t});\n\t},\n\n\t_updateTooltip: function () {\n\t\tthis._tooltip.updateContent(this._getTooltipText());\n\t},\n\n\t_revertLayer: function (layer) {\n\t\tvar id = L.Util.stamp(layer);\n\t\tlayer.edited = false;\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\n\t\t\t// Polyline, Polygon or Rectangle\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\n\t\t\t} else if (layer instanceof L.Circle) {\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\n\t\t\t}\n\n\t\t\tlayer.fire('revert-edited', { layer: layer });\n\t\t}\n\t},\n\n\t_enableLayerEdit: function (e) {\n\t\tvar layer = e.layer || e.target || e,\n\t\t\tpathOptions, poly;\n\n\t\t// Back up this layer (if haven't before)\n\t\tthis._backupLayer(layer);\n\n\t\tif (this.options.poly) {\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\n\t\t\tlayer.options.poly = poly;\n\t\t}\n\n\t\t// Set different style for editing mode\n\t\tif (this.options.selectedPathOptions) {\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\n\n\t\t\t// Use the existing color of the layer\n\t\t\tif (pathOptions.maintainColor) {\n\t\t\t\tpathOptions.color = layer.options.color;\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\n\t\t\t}\n\n\t\t\tlayer.options.original = L.extend({}, layer.options);\n\t\t\tlayer.options.editing = pathOptions;\n\n\t\t}\n\n\t\tif (layer instanceof L.Marker) {\n\t\t\tif (layer.editing) {\n\t\t\t\tlayer.editing.enable();\n\t\t\t}\n\t\t\tlayer.dragging.enable();\n\t\t\tlayer\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\n\t\t} else {\n\t\t\tlayer.editing.enable();\n\t\t}\n\t},\n\n\t_disableLayerEdit: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.edited = false;\n\t\tif (layer.editing) {\n\t\t\tlayer.editing.disable();\n\t\t}\n\n\t\tdelete layer.options.editing;\n\t\tdelete layer.options.original;\n\t\t// Reset layer styles to that of before select\n\t\tif (this._selectedPathOptions) {\n\t\t\tif (layer instanceof L.Marker) {\n\t\t\t\tthis._toggleMarkerHighlight(layer);\n\t\t\t} else {\n\t\t\t\t// reset the layer style to what is was before being selected\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\n\t\t\t\t// remove the cached options for the layer object\n\t\t\t\tdelete layer.options.previousOptions;\n\t\t\t}\n\t\t}\n\n\t\tif (layer instanceof L.Marker) {\n\t\t\tlayer.dragging.disable();\n\t\t\tlayer\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\n\t\t} else {\n\t\t\tlayer.editing.disable();\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tthis._tooltip.updatePosition(e.latlng);\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar layer = e.target;\n\t\tlayer.edited = true;\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, { layer: layer });\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\te.target.setLatLng(latlng);\n\t},\n\n\t_hasAvailableLayers: function () {\n\t\treturn this._featureGroup.getLayers().length !== 0;\n\t}\n});\n","/**\n * @class L.EditToolbar.Delete\n * @aka EditToolbar.Delete\n */\nL.EditToolbar.Delete = L.Handler.extend({\n\tstatics: {\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\n\t},\n\n\tincludes: L.Mixin.Events,\n\n\t// @method intialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Handler.prototype.initialize.call(this, map);\n\n\t\tL.Util.setOptions(this, options);\n\n\t\t// Store the selectable layer group for ease of access\n\t\tthis._deletableLayers = this.options.featureGroup;\n\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\n\t\t}\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\n\t},\n\n\t// @method enable(): void\n\t// Enable the delete toolbar\n\tenable: function () {\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\n\t\t\treturn;\n\t\t}\n\t\tthis.fire('enabled', { handler: this.type });\n\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, { handler: this.type });\n\n\t\tL.Handler.prototype.enable.call(this);\n\n\t\tthis._deletableLayers\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\n\t},\n\n\t// @method disable(): void\n\t// Disable the delete toolbar\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._deletableLayers\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\n\n\t\tL.Handler.prototype.disable.call(this);\n\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, { handler: this.type });\n\n\t\tthis.fire('disabled', { handler: this.type });\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\n\t\t\tthis._deletedLayers = new L.LayerGroup();\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\t\t\tthis._tooltip.updateContent({ text: L.drawLocal.edit.handlers.remove.tooltip.text });\n\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\n\t\t\tthis._deletedLayers = null;\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t// @method revertLayers(): void\n\t// Revert the deleted layers back to their prior state.\n\trevertLayers: function () {\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\n\t\tthis._deletedLayers.eachLayer(function (layer) {\n\t\t\tthis._deletableLayers.addLayer(layer);\n\t\t\tlayer.fire('revert-deleted', { layer: layer });\n\t\t}, this);\n\t},\n\n\t// @method save(): void\n\t// Save deleted layers\n\tsave: function () {\n\t\tthis._map.fire(L.Draw.Event.DELETED, { layers: this._deletedLayers });\n\t},\n\n\t// @method removeAllLayers(): void\n\t// Remove all delateable layers\n\tremoveAllLayers: function(){\n\t\t// Iterate of the delateable layers and add remove them\n\t\tthis._deletableLayers.eachLayer(function (layer) {\n\t\t\tthis._removeLayer({layer:layer});\n\t\t}, this);\n\t\tthis.save();\n\t},\n\n\t_enableLayerDelete: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.on('click', this._removeLayer, this);\n\t},\n\n\t_disableLayerDelete: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.off('click', this._removeLayer, this);\n\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\n\t\tthis._deletedLayers.removeLayer(layer);\n\t},\n\n\t_removeLayer: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tthis._deletableLayers.removeLayer(layer);\n\n\t\tthis._deletedLayers.addLayer(layer);\n\n\t\tlayer.fire('deleted');\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tthis._tooltip.updatePosition(e.latlng);\n\t},\n\n\t_hasAvailableLayers: function () {\n\t\treturn this._deletableLayers.getLayers().length !== 0;\n\t}\n});\n"]}
         
     | 
| 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            .leaflet-draw-section{position:relative}.leaflet-draw-toolbar{margin-top:12px}.leaflet-draw-toolbar-top{margin-top:0}.leaflet-draw-toolbar-notop a:first-child{border-top-right-radius:0}.leaflet-draw-toolbar-nobottom a:last-child{border-bottom-right-radius:0}.leaflet-draw-toolbar a{background-image:url('images/spritesheet.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg');background-repeat:no-repeat;background-size:300px 30px;background-clip:padding-box}.leaflet-retina .leaflet-draw-toolbar a{background-image:url('images/spritesheet-2x.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg')}
         
     | 
| 
      
 2 
     | 
    
         
            +
            .leaflet-draw a{display:block;text-align:center;text-decoration:none}.leaflet-draw a .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.leaflet-draw-actions{display:none;list-style:none;margin:0;padding:0;position:absolute;left:26px;top:0;white-space:nowrap}.leaflet-touch .leaflet-draw-actions{left:32px}.leaflet-right .leaflet-draw-actions{right:26px;left:auto}.leaflet-touch .leaflet-right .leaflet-draw-actions{right:32px;left:auto}.leaflet-draw-actions li{display:inline-block}
         
     | 
| 
      
 3 
     | 
    
         
            +
            .leaflet-draw-actions li:first-child a{border-left:0}.leaflet-draw-actions li:last-child a{-webkit-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.leaflet-right .leaflet-draw-actions li:last-child a{-webkit-border-radius:0;border-radius:0}.leaflet-right .leaflet-draw-actions li:first-child a{-webkit-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.leaflet-draw-actions a{background-color:#919187;border-left:1px solid #AAA;color:#FFF;font:11px/19px "Helvetica Neue",Arial,Helvetica,sans-serif;line-height:28px;text-decoration:none;padding-left:10px;padding-right:10px;height:28px}
         
     | 
| 
      
 4 
     | 
    
         
            +
            .leaflet-touch .leaflet-draw-actions a{font-size:12px;line-height:30px;height:30px}.leaflet-draw-actions-bottom{margin-top:0}.leaflet-draw-actions-top{margin-top:1px}.leaflet-draw-actions-top a,.leaflet-draw-actions-bottom a{height:27px;line-height:27px}.leaflet-draw-actions a:hover{background-color:#a0a098}.leaflet-draw-actions-top.leaflet-draw-actions-bottom a{height:26px;line-height:26px}.leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:-2px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:0 -1px}
         
     | 
| 
      
 5 
     | 
    
         
            +
            .leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-31px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-29px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-62px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-60px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-92px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-90px -1px}
         
     | 
| 
      
 6 
     | 
    
         
            +
            .leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-122px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-120px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-273px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-271px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-152px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-150px -1px}
         
     | 
| 
      
 7 
     | 
    
         
            +
            .leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-182px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-180px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-212px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-210px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-242px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-240px -2px}
         
     | 
| 
      
 8 
     | 
    
         
            +
            .leaflet-mouse-marker{background-color:#fff;cursor:crosshair}.leaflet-draw-tooltip{background:#363636;background:rgba(0,0,0,0.5);border:1px solid transparent;-webkit-border-radius:4px;border-radius:4px;color:#fff;font:12px/18px "Helvetica Neue",Arial,Helvetica,sans-serif;margin-left:20px;margin-top:-21px;padding:4px 8px;position:absolute;visibility:hidden;white-space:nowrap;z-index:6}.leaflet-draw-tooltip:before{border-right:6px solid black;border-right-color:rgba(0,0,0,0.5);border-top:6px solid transparent;border-bottom:6px solid transparent;content:"";position:absolute;top:7px;left:-7px}
         
     | 
| 
      
 9 
     | 
    
         
            +
            .leaflet-error-draw-tooltip{background-color:#f2dede;border:1px solid #e6b6bd;color:#b94a48}.leaflet-error-draw-tooltip:before{border-right-color:#e6b6bd}.leaflet-draw-tooltip-single{margin-top:-12px}.leaflet-draw-tooltip-subtext{color:#f8d5e4}.leaflet-draw-guide-dash{font-size:1%;opacity:.6;position:absolute;width:5px;height:5px}.leaflet-edit-marker-selected{background-color:rgba(254,87,161,0.1);border:4px dashed rgba(254,87,161,0.6);-webkit-border-radius:4px;border-radius:4px;box-sizing:content-box}
         
     | 
| 
      
 10 
     | 
    
         
            +
            .leaflet-edit-move{cursor:move}.leaflet-edit-resize{cursor:pointer}.leaflet-oldie .leaflet-draw-toolbar{border:1px solid #999}
         
     | 
| 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2 
     | 
    
         
            +
             Leaflet.draw 0.4.12, a plugin that adds drawing and editing tools to Leaflet powered maps.
         
     | 
| 
      
 3 
     | 
    
         
            +
             (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             https://github.com/Leaflet/Leaflet.draw
         
     | 
| 
      
 6 
     | 
    
         
            +
             http://leafletjs.com
         
     | 
| 
      
 7 
     | 
    
         
            +
             */
         
     | 
| 
      
 8 
     | 
    
         
            +
            !function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="0.4.12",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"<strong>Error:</strong> shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({includes:L.Mixin.Events,initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("mousedown",this._onMouseDown,this).off("mouseout",this._onMouseOut,this).off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mouseup",this._onMouseUp,this).off("mousemove",this._onMouseMove,this).off("zoomlevelschange",this._onZoomEnd,this).off("zoomend",this._onZoomEnd,this).off("touchstart",this._onTouch,this).off("click",this._onTouch,this)},deleteLastVertex:function(){if(!(this._markers.length<=1)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var n=L.point(e,i).distanceTo(this._mouseDownOrigin);this._calculateFinishDistance(o.latlng)<10&&L.Browser.touch?this._finishShape():Math.abs(n)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),n=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),a=this._map.latLngToContainerPoint(n.getLatLng());e=o.distanceTo(a)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,n,a=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=a>r?a-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l<a;l+=this.options.guidelineDistance)i=l/a,o={x:Math.floor(t.x*(1-i)+i*e.x),y:Math.floor(t.y*(1-i)+i*e.y)},n=L.DomUtil.create("div","leaflet-draw-guide-dash",this._guidesContainer),n.style.backgroundColor=this._errorShown?this.options.drawError.color:this.options.shapeOptions.color,L.DomUtil.setPosition(n,o)},_updateGuideColor:function(t){if(this._guidesContainer)for(var e=0,i=this._guidesContainer.childNodes.length;e<i;e++)this._guidesContainer.childNodes[e].style.backgroundColor=t},_clearGuides:function(){if(this._guidesContainer)for(;this._guidesContainer.firstChild;)this._guidesContainer.removeChild(this._guidesContainer.firstChild)},_getTooltipText:function(){var t,e,i=this.options.showLength;return L.Browser.touch&&(i=!1),0===this._markers.length?t={text:L.drawLocal.draw.handlers.polyline.tooltip.start}:(e=i?this._getMeasurementString():"",t=1===this._markers.length?{text:L.drawLocal.draw.handlers.polyline.tooltip.cont,subtext:e}:{text:L.drawLocal.draw.handlers.polyline.tooltip.end,subtext:e}),t},_updateRunningMeasure:function(t,e){var i,o,n=this._markers.length;1===this._markers.length?this._measurementRunningTotal=0:(i=n-(e?2:1),o=this._map.distance(t,this._markers[i].getLatLng())*(this.options.factor||1),this._measurementRunningTotal+=o*(e?1:-1))},_getMeasurementString:function(){var t,e=this._currentLatLng,i=this._markers[this._markers.length-1].getLatLng();return t=i&&e?this._measurementRunningTotal+this._map.distance(e,i)*(this.options.factor||1):this._measurementRunningTotal||0,L.GeometryUtil.readableDistance(t,this.options.metric,this.options.feet,this.options.nautic,this.options.precision)},_showErrorTooltip:function(){this._errorShown=!0,this._tooltip.showAsError().updateContent({text:this.options.drawError.message}),this._updateGuideColor(this.options.drawError.color),this._poly.setStyle({color:this.options.drawError.color}),this._clearHideErrorTimeout(),this._hideErrorTimeout=setTimeout(L.Util.bind(this._hideErrorTooltip,this),this.options.drawError.timeout)},_hideErrorTooltip:function(){this._errorShown=!1,this._clearHideErrorTimeout(),this._tooltip.removeError().updateContent(this._getTooltipText()),this._updateGuideColor(this.options.shapeOptions.color),this._poly.setStyle({color:this.options.shapeOptions.color})},_clearHideErrorTimeout:function(){this._hideErrorTimeout&&(clearTimeout(this._hideErrorTimeout),this._hideErrorTimeout=null)},_disableNewMarkers:function(){this._disableMarkers=!0},_enableNewMarkers:function(){setTimeout(function(){this._disableMarkers=!1}.bind(this),50)},_cleanUpShape:function(){this._markers.length>1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+="<br>"+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this).on("touchstart",this._onMouseDown,this).on("touchmove",this._onMouseMove,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this).off("touchstart",this._onMouseDown,this).off("touchmove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,showArea:!0,clickable:!0},metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),n=this._shape,a=this.options.showArea;return n&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=a?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onTouch,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._marker&&(this._marker.off("click",this._onClick,this),this._map.off("click",this._onClick,this).off("click",this._onTouch,this).removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,n=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var a="";o&&(a=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,n,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:a})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({options:{},initialize:function(t,e){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,L.setOptions(this,e),this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;e<this._verticesHandlers.length;e++)t(this._verticesHandlers[e])},addHooks:function(){this._initHandlers(),this._eachVertexHandler(function(t){t.addHooks()})},removeHooks:function(){this._eachVertexHandler(function(t){t.removeHooks()})},updateMarkers:function(){this._eachVertexHandler(function(t){t.updateMarkers()})},_initHandlers:function(){this._verticesHandlers=[];for(var t=0;t<this.latlngs.length;t++)this._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly,this.latlngs[t],this.options))},_updateLatLngs:function(t){this.latlngs=[t.layer._latlngs],t.layer._holes&&(this.latlngs=this.latlngs.concat(t.layer._holes))}}),L.Edit.PolyVerticesEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),drawError:{color:"#b00b00",timeout:1e3}},initialize:function(t,e,i){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this._poly=t,i&&i.drawError&&(i.drawError=L.Util.extend({},this.options.drawError,i.drawError)),this._latlngs=e,L.setOptions(this,i)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._latlngs)?this._latlngs:this._latlngs[0]:this._latlngs},addHooks:function(){var t=this._poly;t instanceof L.Polygon||(t.options.fill=!1,t.options.editing&&(t.options.editing.fill=!1)),t.setStyle(t.options.editing),this._poly._map&&(this._map=this._poly._map,this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){var t=this._poly;t.setStyle(t.options.original),t._map&&(t._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new L.LayerGroup),this._markers=[];var t,e,i,o,n=this._defaultShape();for(t=0,i=n.length;t<i;t++)o=this._createMarker(n[t],t),o.on("click",this._onMarkerClick,this),this._markers.push(o);var a,s;for(t=0,e=i-1;t<i;e=t++)(0!==t||L.Polygon&&this._poly instanceof L.Polygon)&&(a=this._markers[e],s=this._markers[t],this._createMiddleMarker(a,s),this._updatePrevNext(a,s))},_createMarker:function(t,e){var i=new L.Marker.Touch(t,{draggable:!0,icon:this.options.icon});return i._origLatLng=t,i._index=e,i.on("dragstart",this._onMarkerDragStart,this).on("drag",this._onMarkerDrag,this).on("dragend",this._fireEdit,this).on("touchmove",this._onTouchMove,this).on("touchend",this._fireEdit,this).on("MSPointerMove",this._onTouchMove,this).on("MSPointerUp",this._fireEdit,this),this._markerGroup.addLayer(i),i},_onMarkerDragStart:function(){this._poly.fire("editstart")},_spliceLatLngs:function(){var t=this._defaultShape(),e=[].splice.apply(t,arguments);return this._poly._convertLatLngs(t,!0),this._poly.redraw(),e},_removeMarker:function(t){var e=t._index;this._markerGroup.removeLayer(t),this._markers.splice(e,1),this._spliceLatLngs(e,1),this._updateIndexes(e,-1),t.off("dragstart",this._onMarkerDragStart,this).off("drag",this._onMarkerDrag,this).off("dragend",this._fireEdit,this).off("touchmove",this._onMarkerDrag,this).off("touchend",this._fireEdit,this).off("click",this._onMarkerClick,this).off("MSPointerMove",this._onTouchMove,this).off("MSPointerUp",this._fireEdit,this)},_fireEdit:function(){this._poly.edited=!0,this._poly.fire("edit"),this._poly._map.fire(L.Draw.Event.EDITVERTEX,{layers:this._markerGroup,poly:this._poly})},_onMarkerDrag:function(t){var e=t.target,i=this._poly;if(L.extend(e._origLatLng,e._latlng),e._middleLeft&&e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev,e)),e._middleRight&&e._middleRight.setLatLng(this._getMiddleLatLng(e,e._next)),i.options.poly){var o=i._map._editTooltip;if(!i.options.poly.allowIntersection&&i.intersects()){var n=i.options.color;i.setStyle({color:this.options.drawError.color}),0!==L.version.indexOf("0.7")&&e.dragging._draggable._onUp(t),this._onMarkerClick(t),o&&o.updateContent({text:L.drawLocal.draw.handlers.polyline.error}),setTimeout(function(){i.setStyle({color:n}),o&&o.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext})},1e3)}}this._poly.redraw(),this._poly.fire("editdrag")},_onMarkerClick:function(t){var e=L.Polygon&&this._poly instanceof L.Polygon?4:3,i=t.target;this._defaultShape().length<e||(this._removeMarker(i),this._updatePrevNext(i._prev,i._next),i._middleLeft&&this._markerGroup.removeLayer(i._middleLeft),i._middleRight&&this._markerGroup.removeLayer(i._middleRight),i._prev&&i._next?this._createMiddleMarker(i._prev,i._next):i._prev?i._next||(i._prev._middleRight=null):i._next._middleLeft=null,this._fireEdit())},_onTouchMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),i=this._map.layerPointToLatLng(e),o=t.target;L.extend(o._origLatLng,i),o._middleLeft&&o._middleLeft.setLatLng(this._getMiddleLatLng(o._prev,o)),o._middleRight&&o._middleRight.setLatLng(this._getMiddleLatLng(o,o._next)),this._poly.redraw(),this.updateMarkers()},_updateIndexes:function(t,e){this._markerGroup.eachLayer(function(i){i._index>t&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,n,a=this._getMiddleLatLng(t,e),s=this._createMarker(a);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var n=e._index;s._index=n,s.off("click",i,this).on("click",this._onMarkerClick,this),a.lat=s.getLatLng().lat,a.lng=s.getLatLng().lng,this._spliceLatLngs(n,0,a),this._markers.splice(n,0,s),s.setOpacity(1),this._updateIndexes(n,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},n=function(){s.off("dragstart",o,this),s.off("dragend",n,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),n.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",n,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),n=i.project(e.getLatLng());return i.unproject(o._add(n)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this,this.options.poly),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e<i;e++)this._unbindMarker(this._resizeMarkers[e]);this._resizeMarkers=null,this._map.removeLayer(this._markerGroup),delete this._markerGroup}this._map=null},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new L.LayerGroup),this._createMoveMarker(),this._createResizeMarker()},_createMoveMarker:function(){},_createResizeMarker:function(){},_createMarker:function(t,e){var i=new L.Marker.Touch(t,{draggable:!0,icon:e,zIndexOffset:10});return this._bindMarker(i),this._markerGroup.addLayer(i),i},_bindMarker:function(t){
         
     | 
| 
      
 9 
     | 
    
         
            +
            t.on("dragstart",this._onMarkerDragStart,this).on("drag",this._onMarkerDrag,this).on("dragend",this._onMarkerDragEnd,this).on("touchstart",this._onTouchStart,this).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onTouchEnd,this).on("MSPointerUp",this._onTouchEnd,this)},_unbindMarker:function(t){t.off("dragstart",this._onMarkerDragStart,this).off("drag",this._onMarkerDrag,this).off("dragend",this._onMarkerDragEnd,this).off("touchstart",this._onTouchStart,this).off("touchmove",this._onTouchMove,this).off("MSPointerMove",this._onTouchMove,this).off("touchend",this._onTouchEnd,this).off("MSPointerUp",this._onTouchEnd,this)},_onMarkerDragStart:function(t){t.target.setOpacity(0),this._shape.fire("editstart")},_fireEdit:function(){this._shape.edited=!0,this._shape.fire("edit")},_onMarkerDrag:function(t){var e=t.target,i=e.getLatLng();e===this._moveMarker?this._move(i):this._resize(i),this._shape.redraw(),this._shape.fire("editdrag")},_onMarkerDragEnd:function(t){t.target.setOpacity(1),this._fireEdit()},_onTouchStart:function(t){if(L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,t),"function"==typeof this._getCorners){var e=this._getCorners(),i=t.target,o=i._cornerIndex;i.setOpacity(0),this._oppositeCorner=e[(o+2)%4],this._toggleCornerMarkers(0,o)}this._shape.fire("editstart")},_onTouchMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),i=this._map.layerPointToLatLng(e);return t.target===this._moveMarker?this._move(i):this._resize(i),this._shape.redraw(),!1},_onTouchEnd:function(t){t.target.setOpacity(1),this.updateMarkers(),this._fireEdit()},_move:function(){},_resize:function(){}}),L.Edit=L.Edit||{},L.Edit.Rectangle=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=this._shape.getBounds(),e=t.getCenter();this._moveMarker=this._createMarker(e,this.options.moveIcon)},_createResizeMarker:function(){var t=this._getCorners();this._resizeMarkers=[];for(var e=0,i=t.length;e<i;e++)this._resizeMarkers.push(this._createMarker(t[e],this.options.resizeIcon)),this._resizeMarkers[e]._cornerIndex=e},_onMarkerDragStart:function(t){L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,t);var e=this._getCorners(),i=t.target,o=i._cornerIndex;this._oppositeCorner=e[(o+2)%4],this._toggleCornerMarkers(0,o)},_onMarkerDragEnd:function(t){var e,i,o=t.target;o===this._moveMarker&&(e=this._shape.getBounds(),i=e.getCenter(),o.setLatLng(i)),this._toggleCornerMarkers(1),this._repositionCornerMarkers(),L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this,t)},_move:function(t){for(var e,i=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),o=this._shape.getBounds(),n=o.getCenter(),a=[],s=0,r=i.length;s<r;s++)e=[i[s].lat-n.lat,i[s].lng-n.lng],a.push([t.lat+e[0],t.lng+e[1]]);this._shape.setLatLngs(a),this._repositionCornerMarkers(),this._map.fire(L.Draw.Event.EDITMOVE,{layer:this._shape})},_resize:function(t){var e;this._shape.setBounds(L.latLngBounds(t,this._oppositeCorner)),e=this._shape.getBounds(),this._moveMarker.setLatLng(e.getCenter()),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})},_getCorners:function(){var t=this._shape.getBounds();return[t.getNorthWest(),t.getNorthEast(),t.getSouthEast(),t.getSouthWest()]},_toggleCornerMarkers:function(t){for(var e=0,i=this._resizeMarkers.length;e<i;e++)this._resizeMarkers[e].setOpacity(t)},_repositionCornerMarkers:function(){for(var t=this._getCorners(),e=0,i=this._resizeMarkers.length;e<i;e++)this._resizeMarkers[e].setLatLng(t[e])}}),L.Rectangle.addInitHook(function(){L.Edit.Rectangle&&(this.editing=new L.Edit.Rectangle(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.CircleMarker=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=this._shape.getLatLng();this._moveMarker=this._createMarker(t,this.options.moveIcon)},_createResizeMarker:function(){this._resizeMarkers=[]},_move:function(t){if(this._resizeMarkers.length){var e=this._getResizeMarkerPoint(t);this._resizeMarkers[0].setLatLng(e)}this._shape.setLatLng(t),this._map.fire(L.Draw.Event.EDITMOVE,{layer:this._shape})}}),L.CircleMarker.addInitHook(function(){L.Edit.CircleMarker&&(this.editing=new L.Edit.CircleMarker(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()})}),L.Edit=L.Edit||{},L.Edit.Circle=L.Edit.CircleMarker.extend({_createResizeMarker:function(){var t=this._shape.getLatLng(),e=this._getResizeMarkerPoint(t);this._resizeMarkers=[],this._resizeMarkers.push(this._createMarker(e,this.options.resizeIcon))},_getResizeMarkerPoint:function(t){var e=this._shape._radius*Math.cos(Math.PI/4),i=this._map.project(t);return this._map.unproject([i.x+e,i.y-e])},_resize:function(t){var e=this._moveMarker.getLatLng(),i=this._map.distance(e,t);this._shape.setRadius(i),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()})}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart),L.DomEvent.off(this._container,"touchend",this._onTouchEnd),L.DomEvent.off(this._container,"touchmove",this._onTouchMove),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDowm",this._onTouchStart),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),n=this._map.mouseEventToLayerPoint(i),a=this._map.layerPointToLatLng(n);this._map.fire(e,{latlng:a,layerPoint:n,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var n=e.indexOf("Edge/");return n>0&&parseInt(e.substring(n+5,e.indexOf(".",n)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i<e.length;i++)L.DomEvent.on(t,e[i],this._fireMouseEvent,this);L.Handler.MarkerDrag&&(this.dragging=new L.Handler.MarkerDrag(this),this.options.draggable&&this.dragging.enable())}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var n=e.indexOf("Edge/");return n>0&&parseInt(e.substring(n+5,e.indexOf(".",n)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i<o;i++)Array.isArray(t[i])?e.push(L.LatLngUtil.cloneLatLngs(t[i])):e.push(this.cloneLatLng(t[i]));return e},cloneLatLng:function(t){return L.latLng(t.lat,t.lng)}},function(){var t={km:2,ha:2,m:0,mi:2,ac:2,yd:0,ft:0,nm:2};L.GeometryUtil=L.extend(L.GeometryUtil||{},{geodesicArea:function(t){var e,i,o=t.length,n=0,a=Math.PI/180;if(o>2){for(var s=0;s<o;s++)e=t[s],i=t[(s+1)%o],n+=(i.lng-e.lng)*a*(2+Math.sin(e.lat*a)+Math.sin(i.lat*a));n=6378137*n*6378137/2}return Math.abs(n)},formattedNumber:function(t,e){var i=parseFloat(t).toFixed(e),o=L.drawLocal.format&&L.drawLocal.format.numeric,n=o&&o.delimiters,a=n&&n.thousands,s=n&&n.decimal;if(a||s){var r=i.split(".");i=a?r[0].replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+a):r[0],s=s||".",r.length>1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var n,a,o=L.Util.extend({},t,o);return i?(a=["ha","m"],type=typeof i,"string"===type?a=[i]:"boolean"!==type&&(a=i),n=e>=1e6&&-1!==a.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==a.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,n=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),n},readableDistance:function(e,i,o,n,a){var s,a=L.Util.extend({},t,a);switch(i?"string"==typeof i?i:"metric":o?"feet":n?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,a.km)+" km":L.GeometryUtil.formattedNumber(e,a.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,a.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,a.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,a.mi)+" miles":L.GeometryUtil.formattedNumber(e,a.yd)+" yd"}return s}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),n=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=n-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,n=i?i[o-1]:null,a=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(n,t,a,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var n,a,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(n=s[r-1],a=s[r],L.LineUtil.segmentsIntersect(t,e,n,a))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i<e.length;i++)t.push(this._map.latLngToLayerPoint(e[i]));return t}}),L.Polygon.include({intersects:function(){var t,e,i,o,n=this._getProjectedPoints();return!this._tooFewPointsForIntersection()&&(!!L.Polyline.prototype.intersects.call(this)||(t=n.length,e=n[0],i=n[t-1],o=t-2,this._lineSegmentsIntersectsRange(i,e,o,1)))}}),L.Control.Draw=L.Control.extend({options:{position:"topleft",draw:{},edit:!1},initialize:function(t){if(L.version<"0.7")throw new Error("Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/");L.Control.prototype.initialize.call(this,t);var e;this._toolbars={},L.DrawToolbar&&this.options.draw&&(e=new L.DrawToolbar(this.options.draw),this._toolbars[L.DrawToolbar.TYPE]=e,this._toolbars[L.DrawToolbar.TYPE].on("enable",this._toolbarEnabled,this)),L.EditToolbar&&this.options.edit&&(e=new L.EditToolbar(this.options.edit),this._toolbars[L.EditToolbar.TYPE]=e,this._toolbars[L.EditToolbar.TYPE].on("enable",this._toolbarEnabled,this)),L.toolbar=this},onAdd:function(t){var e,i=L.DomUtil.create("div","leaflet-draw"),o=!1;for(var n in this._toolbars)this._toolbars.hasOwnProperty(n)&&(e=this._toolbars[n].addToolbar(t))&&(o||(L.DomUtil.hasClass(e,"leaflet-draw-toolbar-top")||L.DomUtil.addClass(e.childNodes[0],"leaflet-draw-toolbar-top"),o=!0),i.appendChild(e));return i},onRemove:function(){for(var t in this._toolbars)this._toolbars.hasOwnProperty(t)&&this._toolbars[t].removeToolbar()},setDrawingOptions:function(t){for(var e in this._toolbars)this._toolbars[e]instanceof L.DrawToolbar&&this._toolbars[e].setOptions(t)},_toolbarEnabled:function(t){var e=t.target;for(var i in this._toolbars)this._toolbars[i]!==e&&this._toolbars[i].disable()}}),L.Map.mergeOptions({drawControlTooltips:!0,drawControl:!1}),L.Map.addInitHook(function(){this.options.drawControl&&(this.drawControl=new L.Control.Draw,this.addControl(this.drawControl))}),L.Toolbar=L.Class.extend({includes:[L.Mixin.Events],initialize:function(t){L.setOptions(this,t),this._modes={},this._actionButtons=[],this._activeMode=null},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,n=this._toolbarClass||"",a=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e<a.length;e++)a[e].enabled&&this._initModeHandler(a[e].handler,this._toolbarContainer,o++,n,a[e].title);if(o)return this._lastButtonIndex=--o,this._actionsContainer=L.DomUtil.create("ul","leaflet-draw-actions"),i.appendChild(this._toolbarContainer),i.appendChild(this._actionsContainer),i},removeToolbar:function(){for(var t in this._modes)this._modes.hasOwnProperty(t)&&(this._disposeButton(this._modes[t].button,this._modes[t].handler.enable,this._modes[t].handler),this._modes[t].handler.disable(),this._modes[t].handler.off("enabled",this._handlerActivated,this).off("disabled",this._handlerDeactivated,this));this._modes={};for(var e=0,i=this._actionButtons.length;e<i;e++)this._disposeButton(this._actionButtons[e].button,this._actionButtons[e].callback,this);this._actionButtons=[],this._actionsContainer=null},_initModeHandler:function(t,e,i,o,n){var a=t.type;this._modes[a]={},this._modes[a].handler=t,this._modes[a].button=this._createButton({type:a,title:n,className:o+"-"+a,container:e,callback:this._modes[a].handler.enable,context:this._modes[a].handler}),this._modes[a].buttonIndex=i,this._modes[a].handler.on("enabled",this._handlerActivated,this).on("disabled",this._handlerDeactivated,this)},_detectIOS:function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!t.MSStream},_createButton:function(t){var e=L.DomUtil.create("a",t.className||"",t.container),i=L.DomUtil.create("span","sr-only",t.container);e.href="#",e.appendChild(i),t.title&&(e.title=t.title,i.innerHTML=t.title),t.text&&(e.innerHTML=t.text,i.innerHTML=t.text);var o=this._detectIOS()?"touchstart":"click";return L.DomEvent.on(e,"click",L.DomEvent.stopPropagation).on(e,"mousedown",L.DomEvent.stopPropagation).on(e,"dblclick",L.DomEvent.stopPropagation).on(e,"touchstart",L.DomEvent.stopPropagation).on(e,"click",L.DomEvent.preventDefault).on(e,o,t.callback,t.context),e},_disposeButton:function(t,e){var i=this._detectIOS()?"touchstart":"click";L.DomEvent.off(t,"click",L.DomEvent.stopPropagation).off(t,"mousedown",L.DomEvent.stopPropagation).off(t,"dblclick",L.DomEvent.stopPropagation).off(t,"touchstart",L.DomEvent.stopPropagation).off(t,"click",L.DomEvent.preventDefault).off(t,i,e)},_handlerActivated:function(t){this.disable(),this._activeMode=this._modes[t.handler],L.DomUtil.addClass(this._activeMode.button,"leaflet-draw-toolbar-button-enabled"),this._showActionsToolbar(),this.fire("enable")},_handlerDeactivated:function(){this._hideActionsToolbar(),L.DomUtil.removeClass(this._activeMode.button,"leaflet-draw-toolbar-button-enabled"),this._activeMode=null,this.fire("disable")},_createActions:function(t){var e,i,o,n,a=this._actionsContainer,s=this.getActions(t),r=s.length;for(i=0,o=this._actionButtons.length;i<o;i++)this._disposeButton(this._actionButtons[i].button,this._actionButtons[i].callback);for(this._actionButtons=[];a.firstChild;)a.removeChild(a.firstChild);for(var l=0;l<r;l++)"enabled"in s[l]&&!s[l].enabled||(e=L.DomUtil.create("li","",a),n=this._createButton({title:s[l].title,text:s[l].text,container:e,callback:s[l].callback,context:s[l].context}),this._actionButtons.push({button:n,callback:s[l].callback}))},_showActionsToolbar:function(){var t=this._activeMode.buttonIndex,e=this._lastButtonIndex,i=this._activeMode.button.offsetTop-1;this._createActions(this._activeMode.handler),this._actionsContainer.style.top=i+"px",0===t&&(L.DomUtil.addClass(this._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.addClass(this._actionsContainer,"leaflet-draw-actions-top")),t===e&&(L.DomUtil.addClass(this._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.addClass(this._actionsContainer,"leaflet-draw-actions-bottom")),this._actionsContainer.style.display="block"},_hideActionsToolbar:function(){this._actionsContainer.style.display="none",L.DomUtil.removeClass(this._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.removeClass(this._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.removeClass(this._actionsContainer,"leaflet-draw-actions-top"),L.DomUtil.removeClass(this._actionsContainer,"leaflet-draw-actions-bottom")}}),L.Draw=L.Draw||{},L.Draw.Tooltip=L.Class.extend({initialize:function(t){this._map=t,this._popupPane=t._panes.popupPane,this._visible=!1,this._container=t.options.drawControlTooltips?L.DomUtil.create("div","leaflet-draw-tooltip",this._popupPane):null,this._singleLineLabel=!1,this._map.on("mouseout",this._onMouseOut,this)},dispose:function(){this._map.off("mouseout",this._onMouseOut,this),this._container&&(this._popupPane.removeChild(this._container),this._container=null)},updateContent:function(t){return this._container?(t.subtext=t.subtext||"",0!==t.subtext.length||this._singleLineLabel?t.subtext.length>0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?'<span class="leaflet-draw-tooltip-subtext">'+t.subtext+"</span><br />":"")+"<span>"+t.text+"</span>",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},includes:L.Mixin.Events,initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this).off("touchmove",this._onMouseMove,this).off("MSPointerMove",this._onMouseMove,this).off(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(),delete e.options.editing,delete e.options.original,this._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",this._onMarkerDragEnd,this).off("touchmove",this._onTouchMove,this).off("MSPointerMove",this._onTouchMove,this).off("touchend",this._onMarkerDragEnd,this).off("MSPointerUp",this._onMarkerDragEnd,this)):e.editing.disable()},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],i=this._map.mouseEventToLayerPoint(e),o=this._map.layerPointToLatLng(i);t.target.setLatLng(o)},_hasAvailableLayers:function(){return 0!==this._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},includes:L.Mixin.Events,initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DELETESTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this))},disable:function(){this._enabled&&(this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DELETESTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.LayerGroup,this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._disableLayerDelete,this),this._deletedLayers=null,this._tooltip.dispose(),this._tooltip=null,
         
     | 
| 
      
 10 
     | 
    
         
            +
            this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._deletedLayers.eachLayer(function(t){this._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})},this)},save:function(){this._map.fire(L.Draw.Event.DELETED,{layers:this._deletedLayers})},removeAllLayers:function(){this._deletableLayers.eachLayer(function(t){this._removeLayer({layer:t})},this),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==this._deletableLayers.getLayers().length}})}(window,document);
         
     | 
| 
         @@ -0,0 +1,3220 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /******/ (function(modules) { // webpackBootstrap
         
     | 
| 
      
 2 
     | 
    
         
            +
            /******/ 	// The module cache
         
     | 
| 
      
 3 
     | 
    
         
            +
            /******/ 	var installedModules = {};
         
     | 
| 
      
 4 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 5 
     | 
    
         
            +
            /******/ 	// The require function
         
     | 
| 
      
 6 
     | 
    
         
            +
            /******/ 	function __webpack_require__(moduleId) {
         
     | 
| 
      
 7 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 8 
     | 
    
         
            +
            /******/ 		// Check if module is in cache
         
     | 
| 
      
 9 
     | 
    
         
            +
            /******/ 		if(installedModules[moduleId]) {
         
     | 
| 
      
 10 
     | 
    
         
            +
            /******/ 			return installedModules[moduleId].exports;
         
     | 
| 
      
 11 
     | 
    
         
            +
            /******/ 		}
         
     | 
| 
      
 12 
     | 
    
         
            +
            /******/ 		// Create a new module (and put it into the cache)
         
     | 
| 
      
 13 
     | 
    
         
            +
            /******/ 		var module = installedModules[moduleId] = {
         
     | 
| 
      
 14 
     | 
    
         
            +
            /******/ 			i: moduleId,
         
     | 
| 
      
 15 
     | 
    
         
            +
            /******/ 			l: false,
         
     | 
| 
      
 16 
     | 
    
         
            +
            /******/ 			exports: {}
         
     | 
| 
      
 17 
     | 
    
         
            +
            /******/ 		};
         
     | 
| 
      
 18 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 19 
     | 
    
         
            +
            /******/ 		// Execute the module function
         
     | 
| 
      
 20 
     | 
    
         
            +
            /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
         
     | 
| 
      
 21 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 22 
     | 
    
         
            +
            /******/ 		// Flag the module as loaded
         
     | 
| 
      
 23 
     | 
    
         
            +
            /******/ 		module.l = true;
         
     | 
| 
      
 24 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 25 
     | 
    
         
            +
            /******/ 		// Return the exports of the module
         
     | 
| 
      
 26 
     | 
    
         
            +
            /******/ 		return module.exports;
         
     | 
| 
      
 27 
     | 
    
         
            +
            /******/ 	}
         
     | 
| 
      
 28 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 29 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 30 
     | 
    
         
            +
            /******/ 	// expose the modules object (__webpack_modules__)
         
     | 
| 
      
 31 
     | 
    
         
            +
            /******/ 	__webpack_require__.m = modules;
         
     | 
| 
      
 32 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 33 
     | 
    
         
            +
            /******/ 	// expose the module cache
         
     | 
| 
      
 34 
     | 
    
         
            +
            /******/ 	__webpack_require__.c = installedModules;
         
     | 
| 
      
 35 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 36 
     | 
    
         
            +
            /******/ 	// define getter function for harmony exports
         
     | 
| 
      
 37 
     | 
    
         
            +
            /******/ 	__webpack_require__.d = function(exports, name, getter) {
         
     | 
| 
      
 38 
     | 
    
         
            +
            /******/ 		if(!__webpack_require__.o(exports, name)) {
         
     | 
| 
      
 39 
     | 
    
         
            +
            /******/ 			Object.defineProperty(exports, name, {
         
     | 
| 
      
 40 
     | 
    
         
            +
            /******/ 				configurable: false,
         
     | 
| 
      
 41 
     | 
    
         
            +
            /******/ 				enumerable: true,
         
     | 
| 
      
 42 
     | 
    
         
            +
            /******/ 				get: getter
         
     | 
| 
      
 43 
     | 
    
         
            +
            /******/ 			});
         
     | 
| 
      
 44 
     | 
    
         
            +
            /******/ 		}
         
     | 
| 
      
 45 
     | 
    
         
            +
            /******/ 	};
         
     | 
| 
      
 46 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 47 
     | 
    
         
            +
            /******/ 	// getDefaultExport function for compatibility with non-harmony modules
         
     | 
| 
      
 48 
     | 
    
         
            +
            /******/ 	__webpack_require__.n = function(module) {
         
     | 
| 
      
 49 
     | 
    
         
            +
            /******/ 		var getter = module && module.__esModule ?
         
     | 
| 
      
 50 
     | 
    
         
            +
            /******/ 			function getDefault() { return module['default']; } :
         
     | 
| 
      
 51 
     | 
    
         
            +
            /******/ 			function getModuleExports() { return module; };
         
     | 
| 
      
 52 
     | 
    
         
            +
            /******/ 		__webpack_require__.d(getter, 'a', getter);
         
     | 
| 
      
 53 
     | 
    
         
            +
            /******/ 		return getter;
         
     | 
| 
      
 54 
     | 
    
         
            +
            /******/ 	};
         
     | 
| 
      
 55 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 56 
     | 
    
         
            +
            /******/ 	// Object.prototype.hasOwnProperty.call
         
     | 
| 
      
 57 
     | 
    
         
            +
            /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
         
     | 
| 
      
 58 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 59 
     | 
    
         
            +
            /******/ 	// __webpack_public_path__
         
     | 
| 
      
 60 
     | 
    
         
            +
            /******/ 	__webpack_require__.p = "";
         
     | 
| 
      
 61 
     | 
    
         
            +
            /******/
         
     | 
| 
      
 62 
     | 
    
         
            +
            /******/ 	// Load entry module and return exports
         
     | 
| 
      
 63 
     | 
    
         
            +
            /******/ 	return __webpack_require__(__webpack_require__.s = 0);
         
     | 
| 
      
 64 
     | 
    
         
            +
            /******/ })
         
     | 
| 
      
 65 
     | 
    
         
            +
            /************************************************************************/
         
     | 
| 
      
 66 
     | 
    
         
            +
            /******/ ([
         
     | 
| 
      
 67 
     | 
    
         
            +
            /* 0 */
         
     | 
| 
      
 68 
     | 
    
         
            +
            /***/ (function(module, exports, __webpack_require__) {
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            module.exports = __webpack_require__(1);
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            /***/ }),
         
     | 
| 
      
 74 
     | 
    
         
            +
            /* 1 */
         
     | 
| 
      
 75 
     | 
    
         
            +
            /***/ (function(module, exports, __webpack_require__) {
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            var GeographicLib, L;
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            L = __webpack_require__(2);
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            GeographicLib = __webpack_require__(3);
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            L.GeographicUtil = (function() {
         
     | 
| 
      
 84 
     | 
    
         
            +
              function GeographicUtil() {}
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              GeographicUtil.Polygon = function(points, polyline) {
         
     | 
| 
      
 87 
     | 
    
         
            +
                var geod, i, j, len, len1, point, poly, poly2;
         
     | 
| 
      
 88 
     | 
    
         
            +
                if (polyline == null) {
         
     | 
| 
      
 89 
     | 
    
         
            +
                  polyline = false;
         
     | 
| 
      
 90 
     | 
    
         
            +
                }
         
     | 
| 
      
 91 
     | 
    
         
            +
                geod = GeographicLib.Geodesic.WGS84;
         
     | 
| 
      
 92 
     | 
    
         
            +
                poly = geod.Polygon(false);
         
     | 
| 
      
 93 
     | 
    
         
            +
                for (i = 0, len = points.length; i < len; i++) {
         
     | 
| 
      
 94 
     | 
    
         
            +
                  point = points[i];
         
     | 
| 
      
 95 
     | 
    
         
            +
                  poly.AddPoint(point[0], point[1]);
         
     | 
| 
      
 96 
     | 
    
         
            +
                }
         
     | 
| 
      
 97 
     | 
    
         
            +
                poly = poly.Compute(false, true);
         
     | 
| 
      
 98 
     | 
    
         
            +
                poly2 = geod.Polygon(true);
         
     | 
| 
      
 99 
     | 
    
         
            +
                for (j = 0, len1 = points.length; j < len1; j++) {
         
     | 
| 
      
 100 
     | 
    
         
            +
                  point = points[j];
         
     | 
| 
      
 101 
     | 
    
         
            +
                  poly2.AddPoint(point[0], point[1]);
         
     | 
| 
      
 102 
     | 
    
         
            +
                }
         
     | 
| 
      
 103 
     | 
    
         
            +
                poly2 = poly2.Compute(false, true);
         
     | 
| 
      
 104 
     | 
    
         
            +
                return {
         
     | 
| 
      
 105 
     | 
    
         
            +
                  extrapolatedPerimeter: poly.perimeter,
         
     | 
| 
      
 106 
     | 
    
         
            +
                  extrapolatedArea: Math.abs(poly.area),
         
     | 
| 
      
 107 
     | 
    
         
            +
                  perimeter: poly2.perimeter
         
     | 
| 
      
 108 
     | 
    
         
            +
                };
         
     | 
| 
      
 109 
     | 
    
         
            +
              };
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              GeographicUtil.distance = function(a, b) {
         
     | 
| 
      
 112 
     | 
    
         
            +
                var geod, r;
         
     | 
| 
      
 113 
     | 
    
         
            +
                geod = GeographicLib.Geodesic.WGS84;
         
     | 
| 
      
 114 
     | 
    
         
            +
                r = geod.Inverse(a[0], a[1], b[0], b[1]);
         
     | 
| 
      
 115 
     | 
    
         
            +
                return r.s12.toFixed(3);
         
     | 
| 
      
 116 
     | 
    
         
            +
              };
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              return GeographicUtil;
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            })();
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            /***/ }),
         
     | 
| 
      
 124 
     | 
    
         
            +
            /* 2 */
         
     | 
| 
      
 125 
     | 
    
         
            +
            /***/ (function(module, exports) {
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            module.exports = L;
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            /***/ }),
         
     | 
| 
      
 130 
     | 
    
         
            +
            /* 3 */
         
     | 
| 
      
 131 
     | 
    
         
            +
            /***/ (function(module, exports, __webpack_require__) {
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
            var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*
         
     | 
| 
      
 134 
     | 
    
         
            +
             * Geodesic routines from GeographicLib translated to JavaScript.  See
         
     | 
| 
      
 135 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/html/js/
         
     | 
| 
      
 136 
     | 
    
         
            +
             *
         
     | 
| 
      
 137 
     | 
    
         
            +
             * The algorithms are derived in
         
     | 
| 
      
 138 
     | 
    
         
            +
             *
         
     | 
| 
      
 139 
     | 
    
         
            +
             *    Charles F. F. Karney,
         
     | 
| 
      
 140 
     | 
    
         
            +
             *    Algorithms for geodesics, J. Geodesy 87, 43-55 (2013),
         
     | 
| 
      
 141 
     | 
    
         
            +
             *    https://doi.org/10.1007/s00190-012-0578-z
         
     | 
| 
      
 142 
     | 
    
         
            +
             *    Addenda: https://geographiclib.sourceforge.io/geod-addenda.html
         
     | 
| 
      
 143 
     | 
    
         
            +
             *
         
     | 
| 
      
 144 
     | 
    
         
            +
             * This file is the concatenation and compression of the JavaScript files in
         
     | 
| 
      
 145 
     | 
    
         
            +
             * doc/scripts/GeographicLib in the source tree for GeographicLib.
         
     | 
| 
      
 146 
     | 
    
         
            +
             *
         
     | 
| 
      
 147 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2015) <charles@karney.com> and licensed
         
     | 
| 
      
 148 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 149 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 150 
     | 
    
         
            +
             *
         
     | 
| 
      
 151 
     | 
    
         
            +
             * Version: 1.49
         
     | 
| 
      
 152 
     | 
    
         
            +
             * File inventory:
         
     | 
| 
      
 153 
     | 
    
         
            +
             *   Math.js Geodesic.js GeodesicLine.js PolygonArea.js DMS.js
         
     | 
| 
      
 154 
     | 
    
         
            +
             */
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            (function(cb) {
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
            /**************** Math.js ****************/
         
     | 
| 
      
 159 
     | 
    
         
            +
            /*
         
     | 
| 
      
 160 
     | 
    
         
            +
             * Math.js
         
     | 
| 
      
 161 
     | 
    
         
            +
             * Transcription of Math.hpp, Constants.hpp, and Accumulator.hpp into
         
     | 
| 
      
 162 
     | 
    
         
            +
             * JavaScript.
         
     | 
| 
      
 163 
     | 
    
         
            +
             *
         
     | 
| 
      
 164 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2017) <charles@karney.com> and licensed
         
     | 
| 
      
 165 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 166 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 167 
     | 
    
         
            +
             */
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            /**
         
     | 
| 
      
 170 
     | 
    
         
            +
             * @namespace GeographicLib
         
     | 
| 
      
 171 
     | 
    
         
            +
             * @description The parent namespace for the following modules:
         
     | 
| 
      
 172 
     | 
    
         
            +
             * - {@link module:GeographicLib/Geodesic GeographicLib/Geodesic} The main
         
     | 
| 
      
 173 
     | 
    
         
            +
             *   engine for solving geodesic problems via the
         
     | 
| 
      
 174 
     | 
    
         
            +
             *   {@link module:GeographicLib/Geodesic.Geodesic Geodesic} class.
         
     | 
| 
      
 175 
     | 
    
         
            +
             * - {@link module:GeographicLib/GeodesicLine GeographicLib/GeodesicLine}
         
     | 
| 
      
 176 
     | 
    
         
            +
             *   computes points along a single geodesic line via the
         
     | 
| 
      
 177 
     | 
    
         
            +
             *   {@link module:GeographicLib/GeodesicLine.GeodesicLine GeodesicLine}
         
     | 
| 
      
 178 
     | 
    
         
            +
             *   class.
         
     | 
| 
      
 179 
     | 
    
         
            +
             * - {@link module:GeographicLib/PolygonArea GeographicLib/PolygonArea}
         
     | 
| 
      
 180 
     | 
    
         
            +
             *   computes the area of a geodesic polygon via the
         
     | 
| 
      
 181 
     | 
    
         
            +
             *   {@link module:GeographicLib/PolygonArea.PolygonArea PolygonArea}
         
     | 
| 
      
 182 
     | 
    
         
            +
             *   class.
         
     | 
| 
      
 183 
     | 
    
         
            +
             * - {@link module:GeographicLib/DMS GeographicLib/DMS} handles the decoding
         
     | 
| 
      
 184 
     | 
    
         
            +
             *   and encoding of angles in degree, minutes, and seconds, via static
         
     | 
| 
      
 185 
     | 
    
         
            +
             *   functions in this module.
         
     | 
| 
      
 186 
     | 
    
         
            +
             * - {@link module:GeographicLib/Constants GeographicLib/Constants} defines
         
     | 
| 
      
 187 
     | 
    
         
            +
             *   constants specifying the version numbers and the parameters for the WGS84
         
     | 
| 
      
 188 
     | 
    
         
            +
             *   ellipsoid.
         
     | 
| 
      
 189 
     | 
    
         
            +
             *
         
     | 
| 
      
 190 
     | 
    
         
            +
             * The following modules are used internally by the package:
         
     | 
| 
      
 191 
     | 
    
         
            +
             * - {@link module:GeographicLib/Math GeographicLib/Math} defines various
         
     | 
| 
      
 192 
     | 
    
         
            +
             *   mathematical functions.
         
     | 
| 
      
 193 
     | 
    
         
            +
             * - {@link module:GeographicLib/Accumulator GeographicLib/Accumulator}
         
     | 
| 
      
 194 
     | 
    
         
            +
             *   interally used by
         
     | 
| 
      
 195 
     | 
    
         
            +
             *   {@link module:GeographicLib/PolygonArea.PolygonArea PolygonArea} (via the
         
     | 
| 
      
 196 
     | 
    
         
            +
             *   {@link module:GeographicLib/Accumulator.Accumulator Accumulator} class)
         
     | 
| 
      
 197 
     | 
    
         
            +
             *   for summing the contributions to the area of a polygon.
         
     | 
| 
      
 198 
     | 
    
         
            +
             */
         
     | 
| 
      
 199 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 200 
     | 
    
         
            +
            var GeographicLib = {};
         
     | 
| 
      
 201 
     | 
    
         
            +
            GeographicLib.Constants = {};
         
     | 
| 
      
 202 
     | 
    
         
            +
            GeographicLib.Math = {};
         
     | 
| 
      
 203 
     | 
    
         
            +
            GeographicLib.Accumulator = {};
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 206 
     | 
    
         
            +
              /**
         
     | 
| 
      
 207 
     | 
    
         
            +
               * @exports GeographicLib/Constants
         
     | 
| 
      
 208 
     | 
    
         
            +
               * @description Define constants defining the version and WGS84 parameters.
         
     | 
| 
      
 209 
     | 
    
         
            +
               */
         
     | 
| 
      
 210 
     | 
    
         
            +
              c) {
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
              /**
         
     | 
| 
      
 213 
     | 
    
         
            +
               * @constant
         
     | 
| 
      
 214 
     | 
    
         
            +
               * @summary WGS84 parameters.
         
     | 
| 
      
 215 
     | 
    
         
            +
               * @property {number} a the equatorial radius (meters).
         
     | 
| 
      
 216 
     | 
    
         
            +
               * @property {number} f the flattening.
         
     | 
| 
      
 217 
     | 
    
         
            +
               */
         
     | 
| 
      
 218 
     | 
    
         
            +
              c.WGS84 = { a: 6378137, f: 1/298.257223563 };
         
     | 
| 
      
 219 
     | 
    
         
            +
              /**
         
     | 
| 
      
 220 
     | 
    
         
            +
               * @constant
         
     | 
| 
      
 221 
     | 
    
         
            +
               * @summary an array of version numbers.
         
     | 
| 
      
 222 
     | 
    
         
            +
               * @property {number} major the major version number.
         
     | 
| 
      
 223 
     | 
    
         
            +
               * @property {number} minor the minor version number.
         
     | 
| 
      
 224 
     | 
    
         
            +
               * @property {number} patch the patch number.
         
     | 
| 
      
 225 
     | 
    
         
            +
               */
         
     | 
| 
      
 226 
     | 
    
         
            +
              c.version = { major: 1, minor: 49, patch: 0 };
         
     | 
| 
      
 227 
     | 
    
         
            +
              /**
         
     | 
| 
      
 228 
     | 
    
         
            +
               * @constant
         
     | 
| 
      
 229 
     | 
    
         
            +
               * @summary version string
         
     | 
| 
      
 230 
     | 
    
         
            +
               */
         
     | 
| 
      
 231 
     | 
    
         
            +
              c.version_string = "1.49";
         
     | 
| 
      
 232 
     | 
    
         
            +
            })(GeographicLib.Constants);
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 235 
     | 
    
         
            +
              /**
         
     | 
| 
      
 236 
     | 
    
         
            +
               * @exports GeographicLib/Math
         
     | 
| 
      
 237 
     | 
    
         
            +
               * @description Some useful mathematical constants and functions (mainly for
         
     | 
| 
      
 238 
     | 
    
         
            +
               *   internal use).
         
     | 
| 
      
 239 
     | 
    
         
            +
               */
         
     | 
| 
      
 240 
     | 
    
         
            +
              m) {
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
              /**
         
     | 
| 
      
 243 
     | 
    
         
            +
               * @summary The number of digits of precision in floating-point numbers.
         
     | 
| 
      
 244 
     | 
    
         
            +
               * @constant {number}
         
     | 
| 
      
 245 
     | 
    
         
            +
               */
         
     | 
| 
      
 246 
     | 
    
         
            +
              m.digits = 53;
         
     | 
| 
      
 247 
     | 
    
         
            +
              /**
         
     | 
| 
      
 248 
     | 
    
         
            +
               * @summary The machine epsilon.
         
     | 
| 
      
 249 
     | 
    
         
            +
               * @constant {number}
         
     | 
| 
      
 250 
     | 
    
         
            +
               */
         
     | 
| 
      
 251 
     | 
    
         
            +
              m.epsilon = Math.pow(0.5, m.digits - 1);
         
     | 
| 
      
 252 
     | 
    
         
            +
              /**
         
     | 
| 
      
 253 
     | 
    
         
            +
               * @summary The factor to convert degrees to radians.
         
     | 
| 
      
 254 
     | 
    
         
            +
               * @constant {number}
         
     | 
| 
      
 255 
     | 
    
         
            +
               */
         
     | 
| 
      
 256 
     | 
    
         
            +
              m.degree = Math.PI/180;
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
              /**
         
     | 
| 
      
 259 
     | 
    
         
            +
               * @summary Square a number.
         
     | 
| 
      
 260 
     | 
    
         
            +
               * @param {number} x the number.
         
     | 
| 
      
 261 
     | 
    
         
            +
               * @returns {number} the square.
         
     | 
| 
      
 262 
     | 
    
         
            +
               */
         
     | 
| 
      
 263 
     | 
    
         
            +
              m.sq = function(x) { return x * x; };
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
              /**
         
     | 
| 
      
 266 
     | 
    
         
            +
               * @summary The hypotenuse function.
         
     | 
| 
      
 267 
     | 
    
         
            +
               * @param {number} x the first side.
         
     | 
| 
      
 268 
     | 
    
         
            +
               * @param {number} y the second side.
         
     | 
| 
      
 269 
     | 
    
         
            +
               * @returns {number} the hypotenuse.
         
     | 
| 
      
 270 
     | 
    
         
            +
               */
         
     | 
| 
      
 271 
     | 
    
         
            +
              m.hypot = function(x, y) {
         
     | 
| 
      
 272 
     | 
    
         
            +
                var a, b;
         
     | 
| 
      
 273 
     | 
    
         
            +
                x = Math.abs(x);
         
     | 
| 
      
 274 
     | 
    
         
            +
                y = Math.abs(y);
         
     | 
| 
      
 275 
     | 
    
         
            +
                a = Math.max(x, y); b = Math.min(x, y) / (a ? a : 1);
         
     | 
| 
      
 276 
     | 
    
         
            +
                return a * Math.sqrt(1 + b * b);
         
     | 
| 
      
 277 
     | 
    
         
            +
              };
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
              /**
         
     | 
| 
      
 280 
     | 
    
         
            +
               * @summary Cube root function.
         
     | 
| 
      
 281 
     | 
    
         
            +
               * @param {number} x the argument.
         
     | 
| 
      
 282 
     | 
    
         
            +
               * @returns {number} the real cube root.
         
     | 
| 
      
 283 
     | 
    
         
            +
               */
         
     | 
| 
      
 284 
     | 
    
         
            +
              m.cbrt = function(x) {
         
     | 
| 
      
 285 
     | 
    
         
            +
                var y = Math.pow(Math.abs(x), 1/3);
         
     | 
| 
      
 286 
     | 
    
         
            +
                return x < 0 ? -y : y;
         
     | 
| 
      
 287 
     | 
    
         
            +
              };
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
              /**
         
     | 
| 
      
 290 
     | 
    
         
            +
               * @summary The log1p function.
         
     | 
| 
      
 291 
     | 
    
         
            +
               * @param {number} x the argument.
         
     | 
| 
      
 292 
     | 
    
         
            +
               * @returns {number} log(1 + x).
         
     | 
| 
      
 293 
     | 
    
         
            +
               */
         
     | 
| 
      
 294 
     | 
    
         
            +
              m.log1p = function(x) {
         
     | 
| 
      
 295 
     | 
    
         
            +
                var y = 1 + x,
         
     | 
| 
      
 296 
     | 
    
         
            +
                    z = y - 1;
         
     | 
| 
      
 297 
     | 
    
         
            +
                // Here's the explanation for this magic: y = 1 + z, exactly, and z
         
     | 
| 
      
 298 
     | 
    
         
            +
                // approx x, thus log(y)/z (which is nearly constant near z = 0) returns
         
     | 
| 
      
 299 
     | 
    
         
            +
                // a good approximation to the true log(1 + x)/x.  The multiplication x *
         
     | 
| 
      
 300 
     | 
    
         
            +
                // (log(y)/z) introduces little additional error.
         
     | 
| 
      
 301 
     | 
    
         
            +
                return z === 0 ? x : x * Math.log(y) / z;
         
     | 
| 
      
 302 
     | 
    
         
            +
              };
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
              /**
         
     | 
| 
      
 305 
     | 
    
         
            +
               * @summary Inverse hyperbolic tangent.
         
     | 
| 
      
 306 
     | 
    
         
            +
               * @param {number} x the argument.
         
     | 
| 
      
 307 
     | 
    
         
            +
               * @returns {number} tanh<sup>−1</sup> x.
         
     | 
| 
      
 308 
     | 
    
         
            +
               */
         
     | 
| 
      
 309 
     | 
    
         
            +
              m.atanh = function(x) {
         
     | 
| 
      
 310 
     | 
    
         
            +
                var y = Math.abs(x);          // Enforce odd parity
         
     | 
| 
      
 311 
     | 
    
         
            +
                y = m.log1p(2 * y/(1 - y))/2;
         
     | 
| 
      
 312 
     | 
    
         
            +
                return x < 0 ? -y : y;
         
     | 
| 
      
 313 
     | 
    
         
            +
              };
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
              /**
         
     | 
| 
      
 316 
     | 
    
         
            +
               * @summary Copy the sign.
         
     | 
| 
      
 317 
     | 
    
         
            +
               * @param {number} x gives the magitude of the result.
         
     | 
| 
      
 318 
     | 
    
         
            +
               * @param {number} y gives the sign of the result.
         
     | 
| 
      
 319 
     | 
    
         
            +
               * @returns {number} value with the magnitude of x and with the sign of y.
         
     | 
| 
      
 320 
     | 
    
         
            +
               */
         
     | 
| 
      
 321 
     | 
    
         
            +
              m.copysign = function(x, y) {
         
     | 
| 
      
 322 
     | 
    
         
            +
                return Math.abs(x) * (y < 0 || (y === 0 && 1/y < 0) ? -1 : 1);
         
     | 
| 
      
 323 
     | 
    
         
            +
              };
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
              /**
         
     | 
| 
      
 326 
     | 
    
         
            +
               * @summary An error-free sum.
         
     | 
| 
      
 327 
     | 
    
         
            +
               * @param {number} u
         
     | 
| 
      
 328 
     | 
    
         
            +
               * @param {number} v
         
     | 
| 
      
 329 
     | 
    
         
            +
               * @returns {object} sum with sum.s = round(u + v) and sum.t is u + v −
         
     | 
| 
      
 330 
     | 
    
         
            +
               *   round(u + v)
         
     | 
| 
      
 331 
     | 
    
         
            +
               */
         
     | 
| 
      
 332 
     | 
    
         
            +
              m.sum = function(u, v) {
         
     | 
| 
      
 333 
     | 
    
         
            +
                var s = u + v,
         
     | 
| 
      
 334 
     | 
    
         
            +
                    up = s - v,
         
     | 
| 
      
 335 
     | 
    
         
            +
                    vpp = s - up,
         
     | 
| 
      
 336 
     | 
    
         
            +
                    t;
         
     | 
| 
      
 337 
     | 
    
         
            +
                up -= u;
         
     | 
| 
      
 338 
     | 
    
         
            +
                vpp -= v;
         
     | 
| 
      
 339 
     | 
    
         
            +
                t = -(up + vpp);
         
     | 
| 
      
 340 
     | 
    
         
            +
                // u + v =       s      + t
         
     | 
| 
      
 341 
     | 
    
         
            +
                //       = round(u + v) + t
         
     | 
| 
      
 342 
     | 
    
         
            +
                return {s: s, t: t};
         
     | 
| 
      
 343 
     | 
    
         
            +
              };
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
              /**
         
     | 
| 
      
 346 
     | 
    
         
            +
               * @summary Evaluate a polynomial.
         
     | 
| 
      
 347 
     | 
    
         
            +
               * @param {integer} N the order of the polynomial.
         
     | 
| 
      
 348 
     | 
    
         
            +
               * @param {array} p the coefficient array (of size N + 1) (leading
         
     | 
| 
      
 349 
     | 
    
         
            +
               *   order coefficient first)
         
     | 
| 
      
 350 
     | 
    
         
            +
               * @param {number} x the variable.
         
     | 
| 
      
 351 
     | 
    
         
            +
               * @returns {number} the value of the polynomial.
         
     | 
| 
      
 352 
     | 
    
         
            +
               */
         
     | 
| 
      
 353 
     | 
    
         
            +
              m.polyval = function(N, p, s, x) {
         
     | 
| 
      
 354 
     | 
    
         
            +
                var y = N < 0 ? 0 : p[s++];
         
     | 
| 
      
 355 
     | 
    
         
            +
                while (--N >= 0) y = y * x + p[s++];
         
     | 
| 
      
 356 
     | 
    
         
            +
                return y;
         
     | 
| 
      
 357 
     | 
    
         
            +
              };
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
              /**
         
     | 
| 
      
 360 
     | 
    
         
            +
               * @summary Coarsen a value close to zero.
         
     | 
| 
      
 361 
     | 
    
         
            +
               * @param {number} x
         
     | 
| 
      
 362 
     | 
    
         
            +
               * @returns {number} the coarsened value.
         
     | 
| 
      
 363 
     | 
    
         
            +
               */
         
     | 
| 
      
 364 
     | 
    
         
            +
              m.AngRound = function(x) {
         
     | 
| 
      
 365 
     | 
    
         
            +
                // The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^57 for
         
     | 
| 
      
 366 
     | 
    
         
            +
                // reals = 0.7 pm on the earth if x is an angle in degrees.  (This is about
         
     | 
| 
      
 367 
     | 
    
         
            +
                // 1000 times more resolution than we get with angles around 90 degrees.)
         
     | 
| 
      
 368 
     | 
    
         
            +
                // We use this to avoid having to deal with near singular cases when x is
         
     | 
| 
      
 369 
     | 
    
         
            +
                // non-zero but tiny (e.g., 1.0e-200).  This converts -0 to +0; however
         
     | 
| 
      
 370 
     | 
    
         
            +
                // tiny negative numbers get converted to -0.
         
     | 
| 
      
 371 
     | 
    
         
            +
                if (x === 0) return x;
         
     | 
| 
      
 372 
     | 
    
         
            +
                var z = 1/16,
         
     | 
| 
      
 373 
     | 
    
         
            +
                    y = Math.abs(x);
         
     | 
| 
      
 374 
     | 
    
         
            +
                // The compiler mustn't "simplify" z - (z - y) to y
         
     | 
| 
      
 375 
     | 
    
         
            +
                y = y < z ? z - (z - y) : y;
         
     | 
| 
      
 376 
     | 
    
         
            +
                return x < 0 ? -y : y;
         
     | 
| 
      
 377 
     | 
    
         
            +
              };
         
     | 
| 
      
 378 
     | 
    
         
            +
             
     | 
| 
      
 379 
     | 
    
         
            +
              /**
         
     | 
| 
      
 380 
     | 
    
         
            +
               * @summary Normalize an angle.
         
     | 
| 
      
 381 
     | 
    
         
            +
               * @param {number} x the angle in degrees.
         
     | 
| 
      
 382 
     | 
    
         
            +
               * @returns {number} the angle reduced to the range (−180°,
         
     | 
| 
      
 383 
     | 
    
         
            +
               *   180°].
         
     | 
| 
      
 384 
     | 
    
         
            +
               */
         
     | 
| 
      
 385 
     | 
    
         
            +
              m.AngNormalize = function(x) {
         
     | 
| 
      
 386 
     | 
    
         
            +
                // Place angle in [-180, 180).
         
     | 
| 
      
 387 
     | 
    
         
            +
                x = x % 360;
         
     | 
| 
      
 388 
     | 
    
         
            +
                return x <= -180 ? x + 360 : (x <= 180 ? x : x - 360);
         
     | 
| 
      
 389 
     | 
    
         
            +
              };
         
     | 
| 
      
 390 
     | 
    
         
            +
             
     | 
| 
      
 391 
     | 
    
         
            +
              /**
         
     | 
| 
      
 392 
     | 
    
         
            +
               * @summary Normalize a latitude.
         
     | 
| 
      
 393 
     | 
    
         
            +
               * @param {number} x the angle in degrees.
         
     | 
| 
      
 394 
     | 
    
         
            +
               * @returns {number} x if it is in the range [−90°, 90°],
         
     | 
| 
      
 395 
     | 
    
         
            +
               *   otherwise return NaN.
         
     | 
| 
      
 396 
     | 
    
         
            +
               */
         
     | 
| 
      
 397 
     | 
    
         
            +
              m.LatFix = function(x) {
         
     | 
| 
      
 398 
     | 
    
         
            +
                // Replace angle with NaN if outside [-90, 90].
         
     | 
| 
      
 399 
     | 
    
         
            +
                return Math.abs(x) > 90 ? Number.NaN : x;
         
     | 
| 
      
 400 
     | 
    
         
            +
              };
         
     | 
| 
      
 401 
     | 
    
         
            +
             
     | 
| 
      
 402 
     | 
    
         
            +
              /**
         
     | 
| 
      
 403 
     | 
    
         
            +
               * @summary The exact difference of two angles reduced to (−180°,
         
     | 
| 
      
 404 
     | 
    
         
            +
               *   180°]
         
     | 
| 
      
 405 
     | 
    
         
            +
               * @param {number} x the first angle in degrees.
         
     | 
| 
      
 406 
     | 
    
         
            +
               * @param {number} y the second angle in degrees.
         
     | 
| 
      
 407 
     | 
    
         
            +
               * @return {object} diff the exact difference, y − x.
         
     | 
| 
      
 408 
     | 
    
         
            +
               *
         
     | 
| 
      
 409 
     | 
    
         
            +
               * This computes z = y − x exactly, reduced to (−180°,
         
     | 
| 
      
 410 
     | 
    
         
            +
               * 180°]; and then sets diff.s = d = round(z) and diff.t = e = z −
         
     | 
| 
      
 411 
     | 
    
         
            +
               * round(z).  If d = −180, then e > 0; If d = 180, then e ≤ 0.
         
     | 
| 
      
 412 
     | 
    
         
            +
               */
         
     | 
| 
      
 413 
     | 
    
         
            +
              m.AngDiff = function(x, y) {
         
     | 
| 
      
 414 
     | 
    
         
            +
                // Compute y - x and reduce to [-180,180] accurately.
         
     | 
| 
      
 415 
     | 
    
         
            +
                var r = m.sum(m.AngNormalize(-x), m.AngNormalize(y)),
         
     | 
| 
      
 416 
     | 
    
         
            +
                    d = m.AngNormalize(r.s),
         
     | 
| 
      
 417 
     | 
    
         
            +
                    t = r.t;
         
     | 
| 
      
 418 
     | 
    
         
            +
                return m.sum(d === 180 && t > 0 ? -180 : d, t);
         
     | 
| 
      
 419 
     | 
    
         
            +
              };
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
              /**
         
     | 
| 
      
 422 
     | 
    
         
            +
               * @summary Evaluate the sine and cosine function with the argument in
         
     | 
| 
      
 423 
     | 
    
         
            +
               *   degrees
         
     | 
| 
      
 424 
     | 
    
         
            +
               * @param {number} x in degrees.
         
     | 
| 
      
 425 
     | 
    
         
            +
               * @returns {object} r with r.s = sin(x) and r.c = cos(x).
         
     | 
| 
      
 426 
     | 
    
         
            +
               */
         
     | 
| 
      
 427 
     | 
    
         
            +
              m.sincosd = function(x) {
         
     | 
| 
      
 428 
     | 
    
         
            +
                // In order to minimize round-off errors, this function exactly reduces
         
     | 
| 
      
 429 
     | 
    
         
            +
                // the argument to the range [-45, 45] before converting it to radians.
         
     | 
| 
      
 430 
     | 
    
         
            +
                var r, q, s, c, sinx, cosx;
         
     | 
| 
      
 431 
     | 
    
         
            +
                r = x % 360;
         
     | 
| 
      
 432 
     | 
    
         
            +
                q = Math.floor(r / 90 + 0.5);
         
     | 
| 
      
 433 
     | 
    
         
            +
                r -= 90 * q;
         
     | 
| 
      
 434 
     | 
    
         
            +
                // now abs(r) <= 45
         
     | 
| 
      
 435 
     | 
    
         
            +
                r *= this.degree;
         
     | 
| 
      
 436 
     | 
    
         
            +
                // Possibly could call the gnu extension sincos
         
     | 
| 
      
 437 
     | 
    
         
            +
                s = Math.sin(r); c = Math.cos(r);
         
     | 
| 
      
 438 
     | 
    
         
            +
                switch (q & 3) {
         
     | 
| 
      
 439 
     | 
    
         
            +
                  case 0:  sinx =  s; cosx =  c; break;
         
     | 
| 
      
 440 
     | 
    
         
            +
                  case 1:  sinx =  c; cosx = -s; break;
         
     | 
| 
      
 441 
     | 
    
         
            +
                  case 2:  sinx = -s; cosx = -c; break;
         
     | 
| 
      
 442 
     | 
    
         
            +
                  default: sinx = -c; cosx =  s; break; // case 3
         
     | 
| 
      
 443 
     | 
    
         
            +
                }
         
     | 
| 
      
 444 
     | 
    
         
            +
                if (x !== 0) { sinx += 0; cosx += 0; }
         
     | 
| 
      
 445 
     | 
    
         
            +
                return {s: sinx, c: cosx};
         
     | 
| 
      
 446 
     | 
    
         
            +
              };
         
     | 
| 
      
 447 
     | 
    
         
            +
             
     | 
| 
      
 448 
     | 
    
         
            +
              /**
         
     | 
| 
      
 449 
     | 
    
         
            +
               * @summary Evaluate the atan2 function with the result in degrees
         
     | 
| 
      
 450 
     | 
    
         
            +
               * @param {number} y
         
     | 
| 
      
 451 
     | 
    
         
            +
               * @param {number} x
         
     | 
| 
      
 452 
     | 
    
         
            +
               * @returns atan2(y, x) in degrees, in the range (−180°
         
     | 
| 
      
 453 
     | 
    
         
            +
               *   180°].
         
     | 
| 
      
 454 
     | 
    
         
            +
               */
         
     | 
| 
      
 455 
     | 
    
         
            +
              m.atan2d = function(y, x) {
         
     | 
| 
      
 456 
     | 
    
         
            +
                // In order to minimize round-off errors, this function rearranges the
         
     | 
| 
      
 457 
     | 
    
         
            +
                // arguments so that result of atan2 is in the range [-pi/4, pi/4] before
         
     | 
| 
      
 458 
     | 
    
         
            +
                // converting it to degrees and mapping the result to the correct
         
     | 
| 
      
 459 
     | 
    
         
            +
                // quadrant.
         
     | 
| 
      
 460 
     | 
    
         
            +
                var q = 0, t, ang;
         
     | 
| 
      
 461 
     | 
    
         
            +
                if (Math.abs(y) > Math.abs(x)) { t = x; x = y; y = t; q = 2; }
         
     | 
| 
      
 462 
     | 
    
         
            +
                if (x < 0) { x = -x; ++q; }
         
     | 
| 
      
 463 
     | 
    
         
            +
                // here x >= 0 and x >= abs(y), so angle is in [-pi/4, pi/4]
         
     | 
| 
      
 464 
     | 
    
         
            +
                ang = Math.atan2(y, x) / this.degree;
         
     | 
| 
      
 465 
     | 
    
         
            +
                switch (q) {
         
     | 
| 
      
 466 
     | 
    
         
            +
                  // Note that atan2d(-0.0, 1.0) will return -0.  However, we expect that
         
     | 
| 
      
 467 
     | 
    
         
            +
                  // atan2d will not be called with y = -0.  If need be, include
         
     | 
| 
      
 468 
     | 
    
         
            +
                  //
         
     | 
| 
      
 469 
     | 
    
         
            +
                  //   case 0: ang = 0 + ang; break;
         
     | 
| 
      
 470 
     | 
    
         
            +
                  //
         
     | 
| 
      
 471 
     | 
    
         
            +
                  // and handle mpfr as in AngRound.
         
     | 
| 
      
 472 
     | 
    
         
            +
                  case 1: ang = (y >= 0 ? 180 : -180) - ang; break;
         
     | 
| 
      
 473 
     | 
    
         
            +
                  case 2: ang =  90 - ang; break;
         
     | 
| 
      
 474 
     | 
    
         
            +
                  case 3: ang = -90 + ang; break;
         
     | 
| 
      
 475 
     | 
    
         
            +
                }
         
     | 
| 
      
 476 
     | 
    
         
            +
                return ang;
         
     | 
| 
      
 477 
     | 
    
         
            +
              };
         
     | 
| 
      
 478 
     | 
    
         
            +
            })(GeographicLib.Math);
         
     | 
| 
      
 479 
     | 
    
         
            +
             
     | 
| 
      
 480 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 481 
     | 
    
         
            +
              /**
         
     | 
| 
      
 482 
     | 
    
         
            +
               * @exports GeographicLib/Accumulator
         
     | 
| 
      
 483 
     | 
    
         
            +
               * @description Accurate summation via the
         
     | 
| 
      
 484 
     | 
    
         
            +
               *   {@link module:GeographicLib/Accumulator.Accumulator Accumulator} class
         
     | 
| 
      
 485 
     | 
    
         
            +
               *   (mainly for internal use).
         
     | 
| 
      
 486 
     | 
    
         
            +
               */
         
     | 
| 
      
 487 
     | 
    
         
            +
              a, m) {
         
     | 
| 
      
 488 
     | 
    
         
            +
             
     | 
| 
      
 489 
     | 
    
         
            +
              /**
         
     | 
| 
      
 490 
     | 
    
         
            +
               * @class
         
     | 
| 
      
 491 
     | 
    
         
            +
               * @summary Accurate summation of many numbers.
         
     | 
| 
      
 492 
     | 
    
         
            +
               * @classdesc This allows many numbers to be added together with twice the
         
     | 
| 
      
 493 
     | 
    
         
            +
               *   normal precision.  In the documentation of the member functions, sum
         
     | 
| 
      
 494 
     | 
    
         
            +
               *   stands for the value currently held in the accumulator.
         
     | 
| 
      
 495 
     | 
    
         
            +
               * @param {number | Accumulator} [y = 0]  set sum = y.
         
     | 
| 
      
 496 
     | 
    
         
            +
               */
         
     | 
| 
      
 497 
     | 
    
         
            +
              a.Accumulator = function(y) {
         
     | 
| 
      
 498 
     | 
    
         
            +
                this.Set(y);
         
     | 
| 
      
 499 
     | 
    
         
            +
              };
         
     | 
| 
      
 500 
     | 
    
         
            +
             
     | 
| 
      
 501 
     | 
    
         
            +
              /**
         
     | 
| 
      
 502 
     | 
    
         
            +
               * @summary Set the accumulator to a number.
         
     | 
| 
      
 503 
     | 
    
         
            +
               * @param {number | Accumulator} [y = 0] set sum = y.
         
     | 
| 
      
 504 
     | 
    
         
            +
               */
         
     | 
| 
      
 505 
     | 
    
         
            +
              a.Accumulator.prototype.Set = function(y) {
         
     | 
| 
      
 506 
     | 
    
         
            +
                if (!y) y = 0;
         
     | 
| 
      
 507 
     | 
    
         
            +
                if (y.constructor === a.Accumulator) {
         
     | 
| 
      
 508 
     | 
    
         
            +
                  this._s = y._s;
         
     | 
| 
      
 509 
     | 
    
         
            +
                  this._t = y._t;
         
     | 
| 
      
 510 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 511 
     | 
    
         
            +
                  this._s = y;
         
     | 
| 
      
 512 
     | 
    
         
            +
                  this._t = 0;
         
     | 
| 
      
 513 
     | 
    
         
            +
                }
         
     | 
| 
      
 514 
     | 
    
         
            +
              };
         
     | 
| 
      
 515 
     | 
    
         
            +
             
     | 
| 
      
 516 
     | 
    
         
            +
              /**
         
     | 
| 
      
 517 
     | 
    
         
            +
               * @summary Add a number to the accumulator.
         
     | 
| 
      
 518 
     | 
    
         
            +
               * @param {number} [y = 0] set sum += y.
         
     | 
| 
      
 519 
     | 
    
         
            +
               */
         
     | 
| 
      
 520 
     | 
    
         
            +
              a.Accumulator.prototype.Add = function(y) {
         
     | 
| 
      
 521 
     | 
    
         
            +
                // Here's Shewchuk's solution...
         
     | 
| 
      
 522 
     | 
    
         
            +
                // Accumulate starting at least significant end
         
     | 
| 
      
 523 
     | 
    
         
            +
                var u = m.sum(y, this._t),
         
     | 
| 
      
 524 
     | 
    
         
            +
                    v = m.sum(u.s, this._s);
         
     | 
| 
      
 525 
     | 
    
         
            +
                u = u.t;
         
     | 
| 
      
 526 
     | 
    
         
            +
                this._s = v.s;
         
     | 
| 
      
 527 
     | 
    
         
            +
                this._t = v.t;
         
     | 
| 
      
 528 
     | 
    
         
            +
                // Start is _s, _t decreasing and non-adjacent.  Sum is now (s + t + u)
         
     | 
| 
      
 529 
     | 
    
         
            +
                // exactly with s, t, u non-adjacent and in decreasing order (except
         
     | 
| 
      
 530 
     | 
    
         
            +
                // for possible zeros).  The following code tries to normalize the
         
     | 
| 
      
 531 
     | 
    
         
            +
                // result.  Ideally, we want _s = round(s+t+u) and _u = round(s+t+u -
         
     | 
| 
      
 532 
     | 
    
         
            +
                // _s).  The follow does an approximate job (and maintains the
         
     | 
| 
      
 533 
     | 
    
         
            +
                // decreasing non-adjacent property).  Here are two "failures" using
         
     | 
| 
      
 534 
     | 
    
         
            +
                // 3-bit floats:
         
     | 
| 
      
 535 
     | 
    
         
            +
                //
         
     | 
| 
      
 536 
     | 
    
         
            +
                // Case 1: _s is not equal to round(s+t+u) -- off by 1 ulp
         
     | 
| 
      
 537 
     | 
    
         
            +
                // [12, -1] - 8 -> [4, 0, -1] -> [4, -1] = 3 should be [3, 0] = 3
         
     | 
| 
      
 538 
     | 
    
         
            +
                //
         
     | 
| 
      
 539 
     | 
    
         
            +
                // Case 2: _s+_t is not as close to s+t+u as it shold be
         
     | 
| 
      
 540 
     | 
    
         
            +
                // [64, 5] + 4 -> [64, 8, 1] -> [64,  8] = 72 (off by 1)
         
     | 
| 
      
 541 
     | 
    
         
            +
                //                    should be [80, -7] = 73 (exact)
         
     | 
| 
      
 542 
     | 
    
         
            +
                //
         
     | 
| 
      
 543 
     | 
    
         
            +
                // "Fixing" these problems is probably not worth the expense.  The
         
     | 
| 
      
 544 
     | 
    
         
            +
                // representation inevitably leads to small errors in the accumulated
         
     | 
| 
      
 545 
     | 
    
         
            +
                // values.  The additional errors illustrated here amount to 1 ulp of
         
     | 
| 
      
 546 
     | 
    
         
            +
                // the less significant word during each addition to the Accumulator
         
     | 
| 
      
 547 
     | 
    
         
            +
                // and an additional possible error of 1 ulp in the reported sum.
         
     | 
| 
      
 548 
     | 
    
         
            +
                //
         
     | 
| 
      
 549 
     | 
    
         
            +
                // Incidentally, the "ideal" representation described above is not
         
     | 
| 
      
 550 
     | 
    
         
            +
                // canonical, because _s = round(_s + _t) may not be true.  For
         
     | 
| 
      
 551 
     | 
    
         
            +
                // example, with 3-bit floats:
         
     | 
| 
      
 552 
     | 
    
         
            +
                //
         
     | 
| 
      
 553 
     | 
    
         
            +
                // [128, 16] + 1 -> [160, -16] -- 160 = round(145).
         
     | 
| 
      
 554 
     | 
    
         
            +
                // But [160, 0] - 16 -> [128, 16] -- 128 = round(144).
         
     | 
| 
      
 555 
     | 
    
         
            +
                //
         
     | 
| 
      
 556 
     | 
    
         
            +
                if (this._s === 0)          // This implies t == 0,
         
     | 
| 
      
 557 
     | 
    
         
            +
                  this._s = u;              // so result is u
         
     | 
| 
      
 558 
     | 
    
         
            +
                else
         
     | 
| 
      
 559 
     | 
    
         
            +
                  this._t += u;             // otherwise just accumulate u to t.
         
     | 
| 
      
 560 
     | 
    
         
            +
              };
         
     | 
| 
      
 561 
     | 
    
         
            +
             
     | 
| 
      
 562 
     | 
    
         
            +
              /**
         
     | 
| 
      
 563 
     | 
    
         
            +
               * @summary Return the result of adding a number to sum (but
         
     | 
| 
      
 564 
     | 
    
         
            +
               *   don't change sum).
         
     | 
| 
      
 565 
     | 
    
         
            +
               * @param {number} [y = 0] the number to be added to the sum.
         
     | 
| 
      
 566 
     | 
    
         
            +
               * @return sum + y.
         
     | 
| 
      
 567 
     | 
    
         
            +
               */
         
     | 
| 
      
 568 
     | 
    
         
            +
              a.Accumulator.prototype.Sum = function(y) {
         
     | 
| 
      
 569 
     | 
    
         
            +
                var b;
         
     | 
| 
      
 570 
     | 
    
         
            +
                if (!y)
         
     | 
| 
      
 571 
     | 
    
         
            +
                  return this._s;
         
     | 
| 
      
 572 
     | 
    
         
            +
                else {
         
     | 
| 
      
 573 
     | 
    
         
            +
                  b = new a.Accumulator(this);
         
     | 
| 
      
 574 
     | 
    
         
            +
                  b.Add(y);
         
     | 
| 
      
 575 
     | 
    
         
            +
                  return b._s;
         
     | 
| 
      
 576 
     | 
    
         
            +
                }
         
     | 
| 
      
 577 
     | 
    
         
            +
              };
         
     | 
| 
      
 578 
     | 
    
         
            +
             
     | 
| 
      
 579 
     | 
    
         
            +
              /**
         
     | 
| 
      
 580 
     | 
    
         
            +
               * @summary Set sum = −sum.
         
     | 
| 
      
 581 
     | 
    
         
            +
               */
         
     | 
| 
      
 582 
     | 
    
         
            +
              a.Accumulator.prototype.Negate = function() {
         
     | 
| 
      
 583 
     | 
    
         
            +
                this._s *= -1;
         
     | 
| 
      
 584 
     | 
    
         
            +
                this._t *= -1;
         
     | 
| 
      
 585 
     | 
    
         
            +
              };
         
     | 
| 
      
 586 
     | 
    
         
            +
            })(GeographicLib.Accumulator, GeographicLib.Math);
         
     | 
| 
      
 587 
     | 
    
         
            +
             
     | 
| 
      
 588 
     | 
    
         
            +
            /**************** Geodesic.js ****************/
         
     | 
| 
      
 589 
     | 
    
         
            +
            /*
         
     | 
| 
      
 590 
     | 
    
         
            +
             * Geodesic.js
         
     | 
| 
      
 591 
     | 
    
         
            +
             * Transcription of Geodesic.[ch]pp into JavaScript.
         
     | 
| 
      
 592 
     | 
    
         
            +
             *
         
     | 
| 
      
 593 
     | 
    
         
            +
             * See the documentation for the C++ class.  The conversion is a literal
         
     | 
| 
      
 594 
     | 
    
         
            +
             * conversion from C++.
         
     | 
| 
      
 595 
     | 
    
         
            +
             *
         
     | 
| 
      
 596 
     | 
    
         
            +
             * The algorithms are derived in
         
     | 
| 
      
 597 
     | 
    
         
            +
             *
         
     | 
| 
      
 598 
     | 
    
         
            +
             *    Charles F. F. Karney,
         
     | 
| 
      
 599 
     | 
    
         
            +
             *    Algorithms for geodesics, J. Geodesy 87, 43-55 (2013);
         
     | 
| 
      
 600 
     | 
    
         
            +
             *    https://doi.org/10.1007/s00190-012-0578-z
         
     | 
| 
      
 601 
     | 
    
         
            +
             *    Addenda: https://geographiclib.sourceforge.io/geod-addenda.html
         
     | 
| 
      
 602 
     | 
    
         
            +
             *
         
     | 
| 
      
 603 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2017) <charles@karney.com> and licensed
         
     | 
| 
      
 604 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 605 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 606 
     | 
    
         
            +
             */
         
     | 
| 
      
 607 
     | 
    
         
            +
             
     | 
| 
      
 608 
     | 
    
         
            +
            // Load AFTER Math.js
         
     | 
| 
      
 609 
     | 
    
         
            +
             
     | 
| 
      
 610 
     | 
    
         
            +
            GeographicLib.Geodesic = {};
         
     | 
| 
      
 611 
     | 
    
         
            +
            GeographicLib.GeodesicLine = {};
         
     | 
| 
      
 612 
     | 
    
         
            +
            GeographicLib.PolygonArea = {};
         
     | 
| 
      
 613 
     | 
    
         
            +
             
     | 
| 
      
 614 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 615 
     | 
    
         
            +
              /**
         
     | 
| 
      
 616 
     | 
    
         
            +
               * @exports GeographicLib/Geodesic
         
     | 
| 
      
 617 
     | 
    
         
            +
               * @description Solve geodesic problems via the
         
     | 
| 
      
 618 
     | 
    
         
            +
               *   {@link module:GeographicLib/Geodesic.Geodesic Geodesic} class.
         
     | 
| 
      
 619 
     | 
    
         
            +
               */
         
     | 
| 
      
 620 
     | 
    
         
            +
              g, l, p, m, c) {
         
     | 
| 
      
 621 
     | 
    
         
            +
             
     | 
| 
      
 622 
     | 
    
         
            +
              var GEOGRAPHICLIB_GEODESIC_ORDER = 6,
         
     | 
| 
      
 623 
     | 
    
         
            +
                  nA1_ = GEOGRAPHICLIB_GEODESIC_ORDER,
         
     | 
| 
      
 624 
     | 
    
         
            +
                  nA2_ = GEOGRAPHICLIB_GEODESIC_ORDER,
         
     | 
| 
      
 625 
     | 
    
         
            +
                  nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER,
         
     | 
| 
      
 626 
     | 
    
         
            +
                  nA3x_ = nA3_,
         
     | 
| 
      
 627 
     | 
    
         
            +
                  nC3x_, nC4x_,
         
     | 
| 
      
 628 
     | 
    
         
            +
                  maxit1_ = 20,
         
     | 
| 
      
 629 
     | 
    
         
            +
                  maxit2_ = maxit1_ + m.digits + 10,
         
     | 
| 
      
 630 
     | 
    
         
            +
                  tol0_ = m.epsilon,
         
     | 
| 
      
 631 
     | 
    
         
            +
                  tol1_ = 200 * tol0_,
         
     | 
| 
      
 632 
     | 
    
         
            +
                  tol2_ = Math.sqrt(tol0_),
         
     | 
| 
      
 633 
     | 
    
         
            +
                  tolb_ = tol0_ * tol1_,
         
     | 
| 
      
 634 
     | 
    
         
            +
                  xthresh_ = 1000 * tol2_,
         
     | 
| 
      
 635 
     | 
    
         
            +
                  CAP_NONE = 0,
         
     | 
| 
      
 636 
     | 
    
         
            +
                  CAP_ALL  = 0x1F,
         
     | 
| 
      
 637 
     | 
    
         
            +
                  CAP_MASK = CAP_ALL,
         
     | 
| 
      
 638 
     | 
    
         
            +
                  OUT_ALL  = 0x7F80,
         
     | 
| 
      
 639 
     | 
    
         
            +
                  astroid,
         
     | 
| 
      
 640 
     | 
    
         
            +
                  A1m1f_coeff, C1f_coeff, C1pf_coeff,
         
     | 
| 
      
 641 
     | 
    
         
            +
                  A2m1f_coeff, C2f_coeff,
         
     | 
| 
      
 642 
     | 
    
         
            +
                  A3_coeff, C3_coeff, C4_coeff;
         
     | 
| 
      
 643 
     | 
    
         
            +
             
     | 
| 
      
 644 
     | 
    
         
            +
              g.tiny_ = Math.sqrt(Number.MIN_VALUE);
         
     | 
| 
      
 645 
     | 
    
         
            +
              g.nC1_ = GEOGRAPHICLIB_GEODESIC_ORDER;
         
     | 
| 
      
 646 
     | 
    
         
            +
              g.nC1p_ = GEOGRAPHICLIB_GEODESIC_ORDER;
         
     | 
| 
      
 647 
     | 
    
         
            +
              g.nC2_ = GEOGRAPHICLIB_GEODESIC_ORDER;
         
     | 
| 
      
 648 
     | 
    
         
            +
              g.nC3_ = GEOGRAPHICLIB_GEODESIC_ORDER;
         
     | 
| 
      
 649 
     | 
    
         
            +
              g.nC4_ = GEOGRAPHICLIB_GEODESIC_ORDER;
         
     | 
| 
      
 650 
     | 
    
         
            +
              nC3x_ = (g.nC3_ * (g.nC3_ - 1)) / 2;
         
     | 
| 
      
 651 
     | 
    
         
            +
              nC4x_ = (g.nC4_ * (g.nC4_ + 1)) / 2;
         
     | 
| 
      
 652 
     | 
    
         
            +
              g.CAP_C1   = 1<<0;
         
     | 
| 
      
 653 
     | 
    
         
            +
              g.CAP_C1p  = 1<<1;
         
     | 
| 
      
 654 
     | 
    
         
            +
              g.CAP_C2   = 1<<2;
         
     | 
| 
      
 655 
     | 
    
         
            +
              g.CAP_C3   = 1<<3;
         
     | 
| 
      
 656 
     | 
    
         
            +
              g.CAP_C4   = 1<<4;
         
     | 
| 
      
 657 
     | 
    
         
            +
             
     | 
| 
      
 658 
     | 
    
         
            +
              g.NONE          = 0;
         
     | 
| 
      
 659 
     | 
    
         
            +
              g.ARC           = 1<<6;
         
     | 
| 
      
 660 
     | 
    
         
            +
              g.LATITUDE      = 1<<7  | CAP_NONE;
         
     | 
| 
      
 661 
     | 
    
         
            +
              g.LONGITUDE     = 1<<8  | g.CAP_C3;
         
     | 
| 
      
 662 
     | 
    
         
            +
              g.AZIMUTH       = 1<<9  | CAP_NONE;
         
     | 
| 
      
 663 
     | 
    
         
            +
              g.DISTANCE      = 1<<10 | g.CAP_C1;
         
     | 
| 
      
 664 
     | 
    
         
            +
              g.STANDARD      = g.LATITUDE | g.LONGITUDE | g.AZIMUTH | g.DISTANCE;
         
     | 
| 
      
 665 
     | 
    
         
            +
              g.DISTANCE_IN   = 1<<11 | g.CAP_C1 | g.CAP_C1p;
         
     | 
| 
      
 666 
     | 
    
         
            +
              g.REDUCEDLENGTH = 1<<12 | g.CAP_C1 | g.CAP_C2;
         
     | 
| 
      
 667 
     | 
    
         
            +
              g.GEODESICSCALE = 1<<13 | g.CAP_C1 | g.CAP_C2;
         
     | 
| 
      
 668 
     | 
    
         
            +
              g.AREA          = 1<<14 | g.CAP_C4;
         
     | 
| 
      
 669 
     | 
    
         
            +
              g.ALL           = OUT_ALL| CAP_ALL;
         
     | 
| 
      
 670 
     | 
    
         
            +
              g.LONG_UNROLL   = 1<<15;
         
     | 
| 
      
 671 
     | 
    
         
            +
              g.OUT_MASK      = OUT_ALL| g.LONG_UNROLL;
         
     | 
| 
      
 672 
     | 
    
         
            +
             
     | 
| 
      
 673 
     | 
    
         
            +
              g.SinCosSeries = function(sinp, sinx, cosx, c) {
         
     | 
| 
      
 674 
     | 
    
         
            +
                // Evaluate
         
     | 
| 
      
 675 
     | 
    
         
            +
                // y = sinp ? sum(c[i] * sin( 2*i    * x), i, 1, n) :
         
     | 
| 
      
 676 
     | 
    
         
            +
                //            sum(c[i] * cos((2*i+1) * x), i, 0, n-1)
         
     | 
| 
      
 677 
     | 
    
         
            +
                // using Clenshaw summation.  N.B. c[0] is unused for sin series
         
     | 
| 
      
 678 
     | 
    
         
            +
                // Approx operation count = (n + 5) mult and (2 * n + 2) add
         
     | 
| 
      
 679 
     | 
    
         
            +
                var k = c.length,           // Point to one beyond last element
         
     | 
| 
      
 680 
     | 
    
         
            +
                    n = k - (sinp ? 1 : 0),
         
     | 
| 
      
 681 
     | 
    
         
            +
                    ar = 2 * (cosx - sinx) * (cosx + sinx), // 2 * cos(2 * x)
         
     | 
| 
      
 682 
     | 
    
         
            +
                    y0 = n & 1 ? c[--k] : 0, y1 = 0;        // accumulators for sum
         
     | 
| 
      
 683 
     | 
    
         
            +
                // Now n is even
         
     | 
| 
      
 684 
     | 
    
         
            +
                n = Math.floor(n/2);
         
     | 
| 
      
 685 
     | 
    
         
            +
                while (n--) {
         
     | 
| 
      
 686 
     | 
    
         
            +
                  // Unroll loop x 2, so accumulators return to their original role
         
     | 
| 
      
 687 
     | 
    
         
            +
                  y1 = ar * y0 - y1 + c[--k];
         
     | 
| 
      
 688 
     | 
    
         
            +
                  y0 = ar * y1 - y0 + c[--k];
         
     | 
| 
      
 689 
     | 
    
         
            +
                }
         
     | 
| 
      
 690 
     | 
    
         
            +
                return (sinp ? 2 * sinx * cosx * y0 : // sin(2 * x) * y0
         
     | 
| 
      
 691 
     | 
    
         
            +
                        cosx * (y0 - y1));            // cos(x) * (y0 - y1)
         
     | 
| 
      
 692 
     | 
    
         
            +
              };
         
     | 
| 
      
 693 
     | 
    
         
            +
             
     | 
| 
      
 694 
     | 
    
         
            +
              astroid = function(x, y) {
         
     | 
| 
      
 695 
     | 
    
         
            +
                // Solve k^4+2*k^3-(x^2+y^2-1)*k^2-2*y^2*k-y^2 = 0 for positive
         
     | 
| 
      
 696 
     | 
    
         
            +
                // root k.  This solution is adapted from Geocentric::Reverse.
         
     | 
| 
      
 697 
     | 
    
         
            +
                var k,
         
     | 
| 
      
 698 
     | 
    
         
            +
                    p = m.sq(x),
         
     | 
| 
      
 699 
     | 
    
         
            +
                    q = m.sq(y),
         
     | 
| 
      
 700 
     | 
    
         
            +
                    r = (p + q - 1) / 6,
         
     | 
| 
      
 701 
     | 
    
         
            +
                    S, r2, r3, disc, u, T3, T, ang, v, uv, w;
         
     | 
| 
      
 702 
     | 
    
         
            +
                if ( !(q === 0 && r <= 0) ) {
         
     | 
| 
      
 703 
     | 
    
         
            +
                  // Avoid possible division by zero when r = 0 by multiplying
         
     | 
| 
      
 704 
     | 
    
         
            +
                  // equations for s and t by r^3 and r, resp.
         
     | 
| 
      
 705 
     | 
    
         
            +
                  S = p * q / 4;            // S = r^3 * s
         
     | 
| 
      
 706 
     | 
    
         
            +
                  r2 = m.sq(r);
         
     | 
| 
      
 707 
     | 
    
         
            +
                  r3 = r * r2;
         
     | 
| 
      
 708 
     | 
    
         
            +
                  // The discriminant of the quadratic equation for T3.  This is
         
     | 
| 
      
 709 
     | 
    
         
            +
                  // zero on the evolute curve p^(1/3)+q^(1/3) = 1
         
     | 
| 
      
 710 
     | 
    
         
            +
                  disc = S * (S + 2 * r3);
         
     | 
| 
      
 711 
     | 
    
         
            +
                  u = r;
         
     | 
| 
      
 712 
     | 
    
         
            +
                  if (disc >= 0) {
         
     | 
| 
      
 713 
     | 
    
         
            +
                    T3 = S + r3;
         
     | 
| 
      
 714 
     | 
    
         
            +
                    // Pick the sign on the sqrt to maximize abs(T3).  This
         
     | 
| 
      
 715 
     | 
    
         
            +
                    // minimizes loss of precision due to cancellation.  The
         
     | 
| 
      
 716 
     | 
    
         
            +
                    // result is unchanged because of the way the T is used
         
     | 
| 
      
 717 
     | 
    
         
            +
                    // in definition of u.
         
     | 
| 
      
 718 
     | 
    
         
            +
                    T3 += T3 < 0 ? -Math.sqrt(disc) : Math.sqrt(disc);    // T3 = (r * t)^3
         
     | 
| 
      
 719 
     | 
    
         
            +
                    // N.B. cbrt always returns the real root.  cbrt(-8) = -2.
         
     | 
| 
      
 720 
     | 
    
         
            +
                    T = m.cbrt(T3);     // T = r * t
         
     | 
| 
      
 721 
     | 
    
         
            +
                    // T can be zero; but then r2 / T -> 0.
         
     | 
| 
      
 722 
     | 
    
         
            +
                    u += T + (T !== 0 ? r2 / T : 0);
         
     | 
| 
      
 723 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 724 
     | 
    
         
            +
                    // T is complex, but the way u is defined the result is real.
         
     | 
| 
      
 725 
     | 
    
         
            +
                    ang = Math.atan2(Math.sqrt(-disc), -(S + r3));
         
     | 
| 
      
 726 
     | 
    
         
            +
                    // There are three possible cube roots.  We choose the
         
     | 
| 
      
 727 
     | 
    
         
            +
                    // root which avoids cancellation.  Note that disc < 0
         
     | 
| 
      
 728 
     | 
    
         
            +
                    // implies that r < 0.
         
     | 
| 
      
 729 
     | 
    
         
            +
                    u += 2 * r * Math.cos(ang / 3);
         
     | 
| 
      
 730 
     | 
    
         
            +
                  }
         
     | 
| 
      
 731 
     | 
    
         
            +
                  v = Math.sqrt(m.sq(u) + q);       // guaranteed positive
         
     | 
| 
      
 732 
     | 
    
         
            +
                  // Avoid loss of accuracy when u < 0.
         
     | 
| 
      
 733 
     | 
    
         
            +
                  uv = u < 0 ? q / (v - u) : u + v; // u+v, guaranteed positive
         
     | 
| 
      
 734 
     | 
    
         
            +
                  w = (uv - q) / (2 * v);           // positive?
         
     | 
| 
      
 735 
     | 
    
         
            +
                  // Rearrange expression for k to avoid loss of accuracy due to
         
     | 
| 
      
 736 
     | 
    
         
            +
                  // subtraction.  Division by 0 not possible because uv > 0, w >= 0.
         
     | 
| 
      
 737 
     | 
    
         
            +
                  k = uv / (Math.sqrt(uv + m.sq(w)) + w); // guaranteed positive
         
     | 
| 
      
 738 
     | 
    
         
            +
                } else {                                  // q == 0 && r <= 0
         
     | 
| 
      
 739 
     | 
    
         
            +
                  // y = 0 with |x| <= 1.  Handle this case directly.
         
     | 
| 
      
 740 
     | 
    
         
            +
                  // for y small, positive root is k = abs(y)/sqrt(1-x^2)
         
     | 
| 
      
 741 
     | 
    
         
            +
                  k = 0;
         
     | 
| 
      
 742 
     | 
    
         
            +
                }
         
     | 
| 
      
 743 
     | 
    
         
            +
                return k;
         
     | 
| 
      
 744 
     | 
    
         
            +
              };
         
     | 
| 
      
 745 
     | 
    
         
            +
             
     | 
| 
      
 746 
     | 
    
         
            +
              A1m1f_coeff = [
         
     | 
| 
      
 747 
     | 
    
         
            +
                // (1-eps)*A1-1, polynomial in eps2 of order 3
         
     | 
| 
      
 748 
     | 
    
         
            +
                  +1, 4, 64, 0, 256
         
     | 
| 
      
 749 
     | 
    
         
            +
              ];
         
     | 
| 
      
 750 
     | 
    
         
            +
             
     | 
| 
      
 751 
     | 
    
         
            +
              // The scale factor A1-1 = mean value of (d/dsigma)I1 - 1
         
     | 
| 
      
 752 
     | 
    
         
            +
              g.A1m1f = function(eps) {
         
     | 
| 
      
 753 
     | 
    
         
            +
                var p = Math.floor(nA1_/2),
         
     | 
| 
      
 754 
     | 
    
         
            +
                    t = m.polyval(p, A1m1f_coeff, 0, m.sq(eps)) / A1m1f_coeff[p + 1];
         
     | 
| 
      
 755 
     | 
    
         
            +
                return (t + eps) / (1 - eps);
         
     | 
| 
      
 756 
     | 
    
         
            +
              };
         
     | 
| 
      
 757 
     | 
    
         
            +
             
     | 
| 
      
 758 
     | 
    
         
            +
              C1f_coeff = [
         
     | 
| 
      
 759 
     | 
    
         
            +
                // C1[1]/eps^1, polynomial in eps2 of order 2
         
     | 
| 
      
 760 
     | 
    
         
            +
                  -1, 6, -16, 32,
         
     | 
| 
      
 761 
     | 
    
         
            +
                // C1[2]/eps^2, polynomial in eps2 of order 2
         
     | 
| 
      
 762 
     | 
    
         
            +
                  -9, 64, -128, 2048,
         
     | 
| 
      
 763 
     | 
    
         
            +
                // C1[3]/eps^3, polynomial in eps2 of order 1
         
     | 
| 
      
 764 
     | 
    
         
            +
                  +9, -16, 768,
         
     | 
| 
      
 765 
     | 
    
         
            +
                // C1[4]/eps^4, polynomial in eps2 of order 1
         
     | 
| 
      
 766 
     | 
    
         
            +
                  +3, -5, 512,
         
     | 
| 
      
 767 
     | 
    
         
            +
                // C1[5]/eps^5, polynomial in eps2 of order 0
         
     | 
| 
      
 768 
     | 
    
         
            +
                  -7, 1280,
         
     | 
| 
      
 769 
     | 
    
         
            +
                // C1[6]/eps^6, polynomial in eps2 of order 0
         
     | 
| 
      
 770 
     | 
    
         
            +
                  -7, 2048
         
     | 
| 
      
 771 
     | 
    
         
            +
              ];
         
     | 
| 
      
 772 
     | 
    
         
            +
             
     | 
| 
      
 773 
     | 
    
         
            +
              // The coefficients C1[l] in the Fourier expansion of B1
         
     | 
| 
      
 774 
     | 
    
         
            +
              g.C1f = function(eps, c) {
         
     | 
| 
      
 775 
     | 
    
         
            +
                var eps2 = m.sq(eps),
         
     | 
| 
      
 776 
     | 
    
         
            +
                    d = eps,
         
     | 
| 
      
 777 
     | 
    
         
            +
                    o = 0,
         
     | 
| 
      
 778 
     | 
    
         
            +
                    l, p;
         
     | 
| 
      
 779 
     | 
    
         
            +
                for (l = 1; l <= g.nC1_; ++l) {     // l is index of C1p[l]
         
     | 
| 
      
 780 
     | 
    
         
            +
                  p = Math.floor((g.nC1_ - l) / 2); // order of polynomial in eps^2
         
     | 
| 
      
 781 
     | 
    
         
            +
                  c[l] = d * m.polyval(p, C1f_coeff, o, eps2) / C1f_coeff[o + p + 1];
         
     | 
| 
      
 782 
     | 
    
         
            +
                  o += p + 2;
         
     | 
| 
      
 783 
     | 
    
         
            +
                  d *= eps;
         
     | 
| 
      
 784 
     | 
    
         
            +
                }
         
     | 
| 
      
 785 
     | 
    
         
            +
              };
         
     | 
| 
      
 786 
     | 
    
         
            +
             
     | 
| 
      
 787 
     | 
    
         
            +
              C1pf_coeff = [
         
     | 
| 
      
 788 
     | 
    
         
            +
                // C1p[1]/eps^1, polynomial in eps2 of order 2
         
     | 
| 
      
 789 
     | 
    
         
            +
                  +205, -432, 768, 1536,
         
     | 
| 
      
 790 
     | 
    
         
            +
                // C1p[2]/eps^2, polynomial in eps2 of order 2
         
     | 
| 
      
 791 
     | 
    
         
            +
                  +4005, -4736, 3840, 12288,
         
     | 
| 
      
 792 
     | 
    
         
            +
                // C1p[3]/eps^3, polynomial in eps2 of order 1
         
     | 
| 
      
 793 
     | 
    
         
            +
                  -225, 116, 384,
         
     | 
| 
      
 794 
     | 
    
         
            +
                // C1p[4]/eps^4, polynomial in eps2 of order 1
         
     | 
| 
      
 795 
     | 
    
         
            +
                  -7173, 2695, 7680,
         
     | 
| 
      
 796 
     | 
    
         
            +
                // C1p[5]/eps^5, polynomial in eps2 of order 0
         
     | 
| 
      
 797 
     | 
    
         
            +
                  +3467, 7680,
         
     | 
| 
      
 798 
     | 
    
         
            +
                // C1p[6]/eps^6, polynomial in eps2 of order 0
         
     | 
| 
      
 799 
     | 
    
         
            +
                  +38081, 61440
         
     | 
| 
      
 800 
     | 
    
         
            +
              ];
         
     | 
| 
      
 801 
     | 
    
         
            +
             
     | 
| 
      
 802 
     | 
    
         
            +
              // The coefficients C1p[l] in the Fourier expansion of B1p
         
     | 
| 
      
 803 
     | 
    
         
            +
              g.C1pf = function(eps, c) {
         
     | 
| 
      
 804 
     | 
    
         
            +
                var eps2 = m.sq(eps),
         
     | 
| 
      
 805 
     | 
    
         
            +
                    d = eps,
         
     | 
| 
      
 806 
     | 
    
         
            +
                    o = 0,
         
     | 
| 
      
 807 
     | 
    
         
            +
                    l, p;
         
     | 
| 
      
 808 
     | 
    
         
            +
                for (l = 1; l <= g.nC1p_; ++l) {     // l is index of C1p[l]
         
     | 
| 
      
 809 
     | 
    
         
            +
                  p = Math.floor((g.nC1p_ - l) / 2); // order of polynomial in eps^2
         
     | 
| 
      
 810 
     | 
    
         
            +
                  c[l] = d * m.polyval(p, C1pf_coeff, o, eps2) / C1pf_coeff[o + p + 1];
         
     | 
| 
      
 811 
     | 
    
         
            +
                  o += p + 2;
         
     | 
| 
      
 812 
     | 
    
         
            +
                  d *= eps;
         
     | 
| 
      
 813 
     | 
    
         
            +
                }
         
     | 
| 
      
 814 
     | 
    
         
            +
              };
         
     | 
| 
      
 815 
     | 
    
         
            +
             
     | 
| 
      
 816 
     | 
    
         
            +
              A2m1f_coeff = [
         
     | 
| 
      
 817 
     | 
    
         
            +
                // (eps+1)*A2-1, polynomial in eps2 of order 3
         
     | 
| 
      
 818 
     | 
    
         
            +
                  -11, -28, -192, 0, 256
         
     | 
| 
      
 819 
     | 
    
         
            +
              ];
         
     | 
| 
      
 820 
     | 
    
         
            +
             
     | 
| 
      
 821 
     | 
    
         
            +
              // The scale factor A2-1 = mean value of (d/dsigma)I2 - 1
         
     | 
| 
      
 822 
     | 
    
         
            +
              g.A2m1f = function(eps) {
         
     | 
| 
      
 823 
     | 
    
         
            +
                var p = Math.floor(nA2_/2),
         
     | 
| 
      
 824 
     | 
    
         
            +
                    t = m.polyval(p, A2m1f_coeff, 0, m.sq(eps)) / A2m1f_coeff[p + 1];
         
     | 
| 
      
 825 
     | 
    
         
            +
                return (t - eps) / (1 + eps);
         
     | 
| 
      
 826 
     | 
    
         
            +
              };
         
     | 
| 
      
 827 
     | 
    
         
            +
             
     | 
| 
      
 828 
     | 
    
         
            +
              C2f_coeff = [
         
     | 
| 
      
 829 
     | 
    
         
            +
                // C2[1]/eps^1, polynomial in eps2 of order 2
         
     | 
| 
      
 830 
     | 
    
         
            +
                  +1, 2, 16, 32,
         
     | 
| 
      
 831 
     | 
    
         
            +
                // C2[2]/eps^2, polynomial in eps2 of order 2
         
     | 
| 
      
 832 
     | 
    
         
            +
                  +35, 64, 384, 2048,
         
     | 
| 
      
 833 
     | 
    
         
            +
                // C2[3]/eps^3, polynomial in eps2 of order 1
         
     | 
| 
      
 834 
     | 
    
         
            +
                  +15, 80, 768,
         
     | 
| 
      
 835 
     | 
    
         
            +
                // C2[4]/eps^4, polynomial in eps2 of order 1
         
     | 
| 
      
 836 
     | 
    
         
            +
                  +7, 35, 512,
         
     | 
| 
      
 837 
     | 
    
         
            +
                // C2[5]/eps^5, polynomial in eps2 of order 0
         
     | 
| 
      
 838 
     | 
    
         
            +
                  +63, 1280,
         
     | 
| 
      
 839 
     | 
    
         
            +
                // C2[6]/eps^6, polynomial in eps2 of order 0
         
     | 
| 
      
 840 
     | 
    
         
            +
                  +77, 2048
         
     | 
| 
      
 841 
     | 
    
         
            +
              ];
         
     | 
| 
      
 842 
     | 
    
         
            +
             
     | 
| 
      
 843 
     | 
    
         
            +
              // The coefficients C2[l] in the Fourier expansion of B2
         
     | 
| 
      
 844 
     | 
    
         
            +
              g.C2f = function(eps, c) {
         
     | 
| 
      
 845 
     | 
    
         
            +
                var eps2 = m.sq(eps),
         
     | 
| 
      
 846 
     | 
    
         
            +
                    d = eps,
         
     | 
| 
      
 847 
     | 
    
         
            +
                    o = 0,
         
     | 
| 
      
 848 
     | 
    
         
            +
                    l, p;
         
     | 
| 
      
 849 
     | 
    
         
            +
                for (l = 1; l <= g.nC2_; ++l) {     // l is index of C2[l]
         
     | 
| 
      
 850 
     | 
    
         
            +
                  p = Math.floor((g.nC2_ - l) / 2); // order of polynomial in eps^2
         
     | 
| 
      
 851 
     | 
    
         
            +
                  c[l] = d * m.polyval(p, C2f_coeff, o, eps2) / C2f_coeff[o + p + 1];
         
     | 
| 
      
 852 
     | 
    
         
            +
                  o += p + 2;
         
     | 
| 
      
 853 
     | 
    
         
            +
                  d *= eps;
         
     | 
| 
      
 854 
     | 
    
         
            +
                }
         
     | 
| 
      
 855 
     | 
    
         
            +
              };
         
     | 
| 
      
 856 
     | 
    
         
            +
             
     | 
| 
      
 857 
     | 
    
         
            +
              /**
         
     | 
| 
      
 858 
     | 
    
         
            +
               * @class
         
     | 
| 
      
 859 
     | 
    
         
            +
               * @property {number} a the equatorial radius (meters).
         
     | 
| 
      
 860 
     | 
    
         
            +
               * @property {number} f the flattening.
         
     | 
| 
      
 861 
     | 
    
         
            +
               * @summary Initialize a Geodesic object for a specific ellipsoid.
         
     | 
| 
      
 862 
     | 
    
         
            +
               * @classdesc Performs geodesic calculations on an ellipsoid of revolution.
         
     | 
| 
      
 863 
     | 
    
         
            +
               *   The routines for solving the direct and inverse problems return an
         
     | 
| 
      
 864 
     | 
    
         
            +
               *   object with some of the following fields set: lat1, lon1, azi1, lat2,
         
     | 
| 
      
 865 
     | 
    
         
            +
               *   lon2, azi2, s12, a12, m12, M12, M21, S12.  See {@tutorial 2-interface},
         
     | 
| 
      
 866 
     | 
    
         
            +
               *   "The results".
         
     | 
| 
      
 867 
     | 
    
         
            +
               * @example
         
     | 
| 
      
 868 
     | 
    
         
            +
               * var GeographicLib = require("geographiclib"),
         
     | 
| 
      
 869 
     | 
    
         
            +
               *     geod = GeographicLib.Geodesic.WGS84;
         
     | 
| 
      
 870 
     | 
    
         
            +
               * var inv = geod.Inverse(1,2,3,4);
         
     | 
| 
      
 871 
     | 
    
         
            +
               * console.log("lat1 = " + inv.lat1 + ", lon1 = " + inv.lon1 +
         
     | 
| 
      
 872 
     | 
    
         
            +
               *             ", lat2 = " + inv.lat2 + ", lon2 = " + inv.lon2 +
         
     | 
| 
      
 873 
     | 
    
         
            +
               *             ",\nazi1 = " + inv.azi1 + ", azi2 = " + inv.azi2 +
         
     | 
| 
      
 874 
     | 
    
         
            +
               *             ", s12 = " + inv.s12);
         
     | 
| 
      
 875 
     | 
    
         
            +
               * @param {number} a the equatorial radius of the ellipsoid (meters).
         
     | 
| 
      
 876 
     | 
    
         
            +
               * @param {number} f the flattening of the ellipsoid.  Setting f = 0 gives
         
     | 
| 
      
 877 
     | 
    
         
            +
               *   a sphere (on which geodesics are great circles).  Negative f gives a
         
     | 
| 
      
 878 
     | 
    
         
            +
               *   prolate ellipsoid.
         
     | 
| 
      
 879 
     | 
    
         
            +
               * @throws an error if the parameters are illegal.
         
     | 
| 
      
 880 
     | 
    
         
            +
               */
         
     | 
| 
      
 881 
     | 
    
         
            +
              g.Geodesic = function(a, f) {
         
     | 
| 
      
 882 
     | 
    
         
            +
                this.a = a;
         
     | 
| 
      
 883 
     | 
    
         
            +
                this.f = f;
         
     | 
| 
      
 884 
     | 
    
         
            +
                this._f1 = 1 - this.f;
         
     | 
| 
      
 885 
     | 
    
         
            +
                this._e2 = this.f * (2 - this.f);
         
     | 
| 
      
 886 
     | 
    
         
            +
                this._ep2 = this._e2 / m.sq(this._f1); // e2 / (1 - e2)
         
     | 
| 
      
 887 
     | 
    
         
            +
                this._n = this.f / ( 2 - this.f);
         
     | 
| 
      
 888 
     | 
    
         
            +
                this._b = this.a * this._f1;
         
     | 
| 
      
 889 
     | 
    
         
            +
                // authalic radius squared
         
     | 
| 
      
 890 
     | 
    
         
            +
                this._c2 = (m.sq(this.a) + m.sq(this._b) *
         
     | 
| 
      
 891 
     | 
    
         
            +
                            (this._e2 === 0 ? 1 :
         
     | 
| 
      
 892 
     | 
    
         
            +
                             (this._e2 > 0 ? m.atanh(Math.sqrt(this._e2)) :
         
     | 
| 
      
 893 
     | 
    
         
            +
                              Math.atan(Math.sqrt(-this._e2))) /
         
     | 
| 
      
 894 
     | 
    
         
            +
                             Math.sqrt(Math.abs(this._e2))))/2;
         
     | 
| 
      
 895 
     | 
    
         
            +
                // The sig12 threshold for "really short".  Using the auxiliary sphere
         
     | 
| 
      
 896 
     | 
    
         
            +
                // solution with dnm computed at (bet1 + bet2) / 2, the relative error in
         
     | 
| 
      
 897 
     | 
    
         
            +
                // the azimuth consistency check is sig12^2 * abs(f) * min(1, 1-f/2) / 2.
         
     | 
| 
      
 898 
     | 
    
         
            +
                // (Error measured for 1/100 < b/a < 100 and abs(f) >= 1/1000.  For a given
         
     | 
| 
      
 899 
     | 
    
         
            +
                // f and sig12, the max error occurs for lines near the pole.  If the old
         
     | 
| 
      
 900 
     | 
    
         
            +
                // rule for computing dnm = (dn1 + dn2)/2 is used, then the error increases
         
     | 
| 
      
 901 
     | 
    
         
            +
                // by a factor of 2.)  Setting this equal to epsilon gives sig12 = etol2.
         
     | 
| 
      
 902 
     | 
    
         
            +
                // Here 0.1 is a safety factor (error decreased by 100) and max(0.001,
         
     | 
| 
      
 903 
     | 
    
         
            +
                // abs(f)) stops etol2 getting too large in the nearly spherical case.
         
     | 
| 
      
 904 
     | 
    
         
            +
                this._etol2 = 0.1 * tol2_ /
         
     | 
| 
      
 905 
     | 
    
         
            +
                  Math.sqrt( Math.max(0.001, Math.abs(this.f)) *
         
     | 
| 
      
 906 
     | 
    
         
            +
                             Math.min(1.0, 1 - this.f/2) / 2 );
         
     | 
| 
      
 907 
     | 
    
         
            +
                if (!(isFinite(this.a) && this.a > 0))
         
     | 
| 
      
 908 
     | 
    
         
            +
                  throw new Error("Equatorial radius is not positive");
         
     | 
| 
      
 909 
     | 
    
         
            +
                if (!(isFinite(this._b) && this._b > 0))
         
     | 
| 
      
 910 
     | 
    
         
            +
                  throw new Error("Polar semi-axis is not positive");
         
     | 
| 
      
 911 
     | 
    
         
            +
                this._A3x = new Array(nA3x_);
         
     | 
| 
      
 912 
     | 
    
         
            +
                this._C3x = new Array(nC3x_);
         
     | 
| 
      
 913 
     | 
    
         
            +
                this._C4x = new Array(nC4x_);
         
     | 
| 
      
 914 
     | 
    
         
            +
                this.A3coeff();
         
     | 
| 
      
 915 
     | 
    
         
            +
                this.C3coeff();
         
     | 
| 
      
 916 
     | 
    
         
            +
                this.C4coeff();
         
     | 
| 
      
 917 
     | 
    
         
            +
              };
         
     | 
| 
      
 918 
     | 
    
         
            +
             
     | 
| 
      
 919 
     | 
    
         
            +
              A3_coeff = [
         
     | 
| 
      
 920 
     | 
    
         
            +
                // A3, coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 921 
     | 
    
         
            +
                  -3, 128,
         
     | 
| 
      
 922 
     | 
    
         
            +
                // A3, coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 923 
     | 
    
         
            +
                  -2, -3, 64,
         
     | 
| 
      
 924 
     | 
    
         
            +
                // A3, coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 925 
     | 
    
         
            +
                  -1, -3, -1, 16,
         
     | 
| 
      
 926 
     | 
    
         
            +
                // A3, coeff of eps^2, polynomial in n of order 2
         
     | 
| 
      
 927 
     | 
    
         
            +
                  +3, -1, -2, 8,
         
     | 
| 
      
 928 
     | 
    
         
            +
                // A3, coeff of eps^1, polynomial in n of order 1
         
     | 
| 
      
 929 
     | 
    
         
            +
                  +1, -1, 2,
         
     | 
| 
      
 930 
     | 
    
         
            +
                // A3, coeff of eps^0, polynomial in n of order 0
         
     | 
| 
      
 931 
     | 
    
         
            +
                  +1, 1
         
     | 
| 
      
 932 
     | 
    
         
            +
              ];
         
     | 
| 
      
 933 
     | 
    
         
            +
             
     | 
| 
      
 934 
     | 
    
         
            +
              // The scale factor A3 = mean value of (d/dsigma)I3
         
     | 
| 
      
 935 
     | 
    
         
            +
              g.Geodesic.prototype.A3coeff = function() {
         
     | 
| 
      
 936 
     | 
    
         
            +
                var o = 0, k = 0,
         
     | 
| 
      
 937 
     | 
    
         
            +
                    j, p;
         
     | 
| 
      
 938 
     | 
    
         
            +
                for (j = nA3_ - 1; j >= 0; --j) { // coeff of eps^j
         
     | 
| 
      
 939 
     | 
    
         
            +
                  p = Math.min(nA3_ - j - 1, j);  // order of polynomial in n
         
     | 
| 
      
 940 
     | 
    
         
            +
                  this._A3x[k++] = m.polyval(p, A3_coeff, o, this._n) /
         
     | 
| 
      
 941 
     | 
    
         
            +
                    A3_coeff[o + p + 1];
         
     | 
| 
      
 942 
     | 
    
         
            +
                  o += p + 2;
         
     | 
| 
      
 943 
     | 
    
         
            +
                }
         
     | 
| 
      
 944 
     | 
    
         
            +
              };
         
     | 
| 
      
 945 
     | 
    
         
            +
             
     | 
| 
      
 946 
     | 
    
         
            +
              C3_coeff = [
         
     | 
| 
      
 947 
     | 
    
         
            +
                // C3[1], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 948 
     | 
    
         
            +
                  +3, 128,
         
     | 
| 
      
 949 
     | 
    
         
            +
                // C3[1], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 950 
     | 
    
         
            +
                  +2, 5, 128,
         
     | 
| 
      
 951 
     | 
    
         
            +
                // C3[1], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 952 
     | 
    
         
            +
                  -1, 3, 3, 64,
         
     | 
| 
      
 953 
     | 
    
         
            +
                // C3[1], coeff of eps^2, polynomial in n of order 2
         
     | 
| 
      
 954 
     | 
    
         
            +
                  -1, 0, 1, 8,
         
     | 
| 
      
 955 
     | 
    
         
            +
                // C3[1], coeff of eps^1, polynomial in n of order 1
         
     | 
| 
      
 956 
     | 
    
         
            +
                  -1, 1, 4,
         
     | 
| 
      
 957 
     | 
    
         
            +
                // C3[2], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 958 
     | 
    
         
            +
                  +5, 256,
         
     | 
| 
      
 959 
     | 
    
         
            +
                // C3[2], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 960 
     | 
    
         
            +
                  +1, 3, 128,
         
     | 
| 
      
 961 
     | 
    
         
            +
                // C3[2], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 962 
     | 
    
         
            +
                  -3, -2, 3, 64,
         
     | 
| 
      
 963 
     | 
    
         
            +
                // C3[2], coeff of eps^2, polynomial in n of order 2
         
     | 
| 
      
 964 
     | 
    
         
            +
                  +1, -3, 2, 32,
         
     | 
| 
      
 965 
     | 
    
         
            +
                // C3[3], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 966 
     | 
    
         
            +
                  +7, 512,
         
     | 
| 
      
 967 
     | 
    
         
            +
                // C3[3], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 968 
     | 
    
         
            +
                  -10, 9, 384,
         
     | 
| 
      
 969 
     | 
    
         
            +
                // C3[3], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 970 
     | 
    
         
            +
                  +5, -9, 5, 192,
         
     | 
| 
      
 971 
     | 
    
         
            +
                // C3[4], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 972 
     | 
    
         
            +
                  +7, 512,
         
     | 
| 
      
 973 
     | 
    
         
            +
                // C3[4], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 974 
     | 
    
         
            +
                  -14, 7, 512,
         
     | 
| 
      
 975 
     | 
    
         
            +
                // C3[5], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 976 
     | 
    
         
            +
                  +21, 2560
         
     | 
| 
      
 977 
     | 
    
         
            +
              ];
         
     | 
| 
      
 978 
     | 
    
         
            +
             
     | 
| 
      
 979 
     | 
    
         
            +
              // The coefficients C3[l] in the Fourier expansion of B3
         
     | 
| 
      
 980 
     | 
    
         
            +
              g.Geodesic.prototype.C3coeff = function() {
         
     | 
| 
      
 981 
     | 
    
         
            +
                var o = 0, k = 0,
         
     | 
| 
      
 982 
     | 
    
         
            +
                    l, j, p;
         
     | 
| 
      
 983 
     | 
    
         
            +
                for (l = 1; l < g.nC3_; ++l) {        // l is index of C3[l]
         
     | 
| 
      
 984 
     | 
    
         
            +
                  for (j = g.nC3_ - 1; j >= l; --j) { // coeff of eps^j
         
     | 
| 
      
 985 
     | 
    
         
            +
                    p = Math.min(g.nC3_ - j - 1, j);  // order of polynomial in n
         
     | 
| 
      
 986 
     | 
    
         
            +
                    this._C3x[k++] = m.polyval(p, C3_coeff, o, this._n) /
         
     | 
| 
      
 987 
     | 
    
         
            +
                      C3_coeff[o + p + 1];
         
     | 
| 
      
 988 
     | 
    
         
            +
                    o += p + 2;
         
     | 
| 
      
 989 
     | 
    
         
            +
                  }
         
     | 
| 
      
 990 
     | 
    
         
            +
                }
         
     | 
| 
      
 991 
     | 
    
         
            +
              };
         
     | 
| 
      
 992 
     | 
    
         
            +
             
     | 
| 
      
 993 
     | 
    
         
            +
              C4_coeff = [
         
     | 
| 
      
 994 
     | 
    
         
            +
                // C4[0], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 995 
     | 
    
         
            +
                  +97, 15015,
         
     | 
| 
      
 996 
     | 
    
         
            +
                // C4[0], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 997 
     | 
    
         
            +
                  +1088, 156, 45045,
         
     | 
| 
      
 998 
     | 
    
         
            +
                // C4[0], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 999 
     | 
    
         
            +
                  -224, -4784, 1573, 45045,
         
     | 
| 
      
 1000 
     | 
    
         
            +
                // C4[0], coeff of eps^2, polynomial in n of order 3
         
     | 
| 
      
 1001 
     | 
    
         
            +
                  -10656, 14144, -4576, -858, 45045,
         
     | 
| 
      
 1002 
     | 
    
         
            +
                // C4[0], coeff of eps^1, polynomial in n of order 4
         
     | 
| 
      
 1003 
     | 
    
         
            +
                  +64, 624, -4576, 6864, -3003, 15015,
         
     | 
| 
      
 1004 
     | 
    
         
            +
                // C4[0], coeff of eps^0, polynomial in n of order 5
         
     | 
| 
      
 1005 
     | 
    
         
            +
                  +100, 208, 572, 3432, -12012, 30030, 45045,
         
     | 
| 
      
 1006 
     | 
    
         
            +
                // C4[1], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 1007 
     | 
    
         
            +
                  +1, 9009,
         
     | 
| 
      
 1008 
     | 
    
         
            +
                // C4[1], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 1009 
     | 
    
         
            +
                  -2944, 468, 135135,
         
     | 
| 
      
 1010 
     | 
    
         
            +
                // C4[1], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 1011 
     | 
    
         
            +
                  +5792, 1040, -1287, 135135,
         
     | 
| 
      
 1012 
     | 
    
         
            +
                // C4[1], coeff of eps^2, polynomial in n of order 3
         
     | 
| 
      
 1013 
     | 
    
         
            +
                  +5952, -11648, 9152, -2574, 135135,
         
     | 
| 
      
 1014 
     | 
    
         
            +
                // C4[1], coeff of eps^1, polynomial in n of order 4
         
     | 
| 
      
 1015 
     | 
    
         
            +
                  -64, -624, 4576, -6864, 3003, 135135,
         
     | 
| 
      
 1016 
     | 
    
         
            +
                // C4[2], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 1017 
     | 
    
         
            +
                  +8, 10725,
         
     | 
| 
      
 1018 
     | 
    
         
            +
                // C4[2], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 1019 
     | 
    
         
            +
                  +1856, -936, 225225,
         
     | 
| 
      
 1020 
     | 
    
         
            +
                // C4[2], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 1021 
     | 
    
         
            +
                  -8448, 4992, -1144, 225225,
         
     | 
| 
      
 1022 
     | 
    
         
            +
                // C4[2], coeff of eps^2, polynomial in n of order 3
         
     | 
| 
      
 1023 
     | 
    
         
            +
                  -1440, 4160, -4576, 1716, 225225,
         
     | 
| 
      
 1024 
     | 
    
         
            +
                // C4[3], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 1025 
     | 
    
         
            +
                  -136, 63063,
         
     | 
| 
      
 1026 
     | 
    
         
            +
                // C4[3], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 1027 
     | 
    
         
            +
                  +1024, -208, 105105,
         
     | 
| 
      
 1028 
     | 
    
         
            +
                // C4[3], coeff of eps^3, polynomial in n of order 2
         
     | 
| 
      
 1029 
     | 
    
         
            +
                  +3584, -3328, 1144, 315315,
         
     | 
| 
      
 1030 
     | 
    
         
            +
                // C4[4], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 1031 
     | 
    
         
            +
                  -128, 135135,
         
     | 
| 
      
 1032 
     | 
    
         
            +
                // C4[4], coeff of eps^4, polynomial in n of order 1
         
     | 
| 
      
 1033 
     | 
    
         
            +
                  -2560, 832, 405405,
         
     | 
| 
      
 1034 
     | 
    
         
            +
                // C4[5], coeff of eps^5, polynomial in n of order 0
         
     | 
| 
      
 1035 
     | 
    
         
            +
                  +128, 99099
         
     | 
| 
      
 1036 
     | 
    
         
            +
              ];
         
     | 
| 
      
 1037 
     | 
    
         
            +
             
     | 
| 
      
 1038 
     | 
    
         
            +
              g.Geodesic.prototype.C4coeff = function() {
         
     | 
| 
      
 1039 
     | 
    
         
            +
                var o = 0, k = 0,
         
     | 
| 
      
 1040 
     | 
    
         
            +
                    l, j, p;
         
     | 
| 
      
 1041 
     | 
    
         
            +
                for (l = 0; l < g.nC4_; ++l) {        // l is index of C4[l]
         
     | 
| 
      
 1042 
     | 
    
         
            +
                  for (j = g.nC4_ - 1; j >= l; --j) { // coeff of eps^j
         
     | 
| 
      
 1043 
     | 
    
         
            +
                    p = g.nC4_ - j - 1;               // order of polynomial in n
         
     | 
| 
      
 1044 
     | 
    
         
            +
                    this._C4x[k++] = m.polyval(p, C4_coeff, o, this._n) /
         
     | 
| 
      
 1045 
     | 
    
         
            +
                      C4_coeff[o + p + 1];
         
     | 
| 
      
 1046 
     | 
    
         
            +
                    o += p + 2;
         
     | 
| 
      
 1047 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1048 
     | 
    
         
            +
                }
         
     | 
| 
      
 1049 
     | 
    
         
            +
              };
         
     | 
| 
      
 1050 
     | 
    
         
            +
             
     | 
| 
      
 1051 
     | 
    
         
            +
              g.Geodesic.prototype.A3f = function(eps) {
         
     | 
| 
      
 1052 
     | 
    
         
            +
                // Evaluate A3
         
     | 
| 
      
 1053 
     | 
    
         
            +
                return m.polyval(nA3x_ - 1, this._A3x, 0, eps);
         
     | 
| 
      
 1054 
     | 
    
         
            +
              };
         
     | 
| 
      
 1055 
     | 
    
         
            +
             
     | 
| 
      
 1056 
     | 
    
         
            +
              g.Geodesic.prototype.C3f = function(eps, c) {
         
     | 
| 
      
 1057 
     | 
    
         
            +
                // Evaluate C3 coeffs
         
     | 
| 
      
 1058 
     | 
    
         
            +
                // Elements c[1] thru c[nC3_ - 1] are set
         
     | 
| 
      
 1059 
     | 
    
         
            +
                var mult = 1,
         
     | 
| 
      
 1060 
     | 
    
         
            +
                    o = 0,
         
     | 
| 
      
 1061 
     | 
    
         
            +
                    l, p;
         
     | 
| 
      
 1062 
     | 
    
         
            +
                for (l = 1; l < g.nC3_; ++l) { // l is index of C3[l]
         
     | 
| 
      
 1063 
     | 
    
         
            +
                  p = g.nC3_ - l - 1;          // order of polynomial in eps
         
     | 
| 
      
 1064 
     | 
    
         
            +
                  mult *= eps;
         
     | 
| 
      
 1065 
     | 
    
         
            +
                  c[l] = mult * m.polyval(p, this._C3x, o, eps);
         
     | 
| 
      
 1066 
     | 
    
         
            +
                  o += p + 1;
         
     | 
| 
      
 1067 
     | 
    
         
            +
                }
         
     | 
| 
      
 1068 
     | 
    
         
            +
              };
         
     | 
| 
      
 1069 
     | 
    
         
            +
             
     | 
| 
      
 1070 
     | 
    
         
            +
              g.Geodesic.prototype.C4f = function(eps, c) {
         
     | 
| 
      
 1071 
     | 
    
         
            +
                // Evaluate C4 coeffs
         
     | 
| 
      
 1072 
     | 
    
         
            +
                // Elements c[0] thru c[g.nC4_ - 1] are set
         
     | 
| 
      
 1073 
     | 
    
         
            +
                var mult = 1,
         
     | 
| 
      
 1074 
     | 
    
         
            +
                    o = 0,
         
     | 
| 
      
 1075 
     | 
    
         
            +
                    l, p;
         
     | 
| 
      
 1076 
     | 
    
         
            +
                for (l = 0; l < g.nC4_; ++l) { // l is index of C4[l]
         
     | 
| 
      
 1077 
     | 
    
         
            +
                  p = g.nC4_ - l - 1;          // order of polynomial in eps
         
     | 
| 
      
 1078 
     | 
    
         
            +
                  c[l] = mult * m.polyval(p, this._C4x, o, eps);
         
     | 
| 
      
 1079 
     | 
    
         
            +
                  o += p + 1;
         
     | 
| 
      
 1080 
     | 
    
         
            +
                  mult *= eps;
         
     | 
| 
      
 1081 
     | 
    
         
            +
                }
         
     | 
| 
      
 1082 
     | 
    
         
            +
              };
         
     | 
| 
      
 1083 
     | 
    
         
            +
             
     | 
| 
      
 1084 
     | 
    
         
            +
              // return s12b, m12b, m0, M12, M21
         
     | 
| 
      
 1085 
     | 
    
         
            +
              g.Geodesic.prototype.Lengths = function(eps, sig12,
         
     | 
| 
      
 1086 
     | 
    
         
            +
                                                      ssig1, csig1, dn1, ssig2, csig2, dn2,
         
     | 
| 
      
 1087 
     | 
    
         
            +
                                                      cbet1, cbet2, outmask,
         
     | 
| 
      
 1088 
     | 
    
         
            +
                                                      C1a, C2a) {
         
     | 
| 
      
 1089 
     | 
    
         
            +
                // Return m12b = (reduced length)/_b; also calculate s12b =
         
     | 
| 
      
 1090 
     | 
    
         
            +
                // distance/_b, and m0 = coefficient of secular term in
         
     | 
| 
      
 1091 
     | 
    
         
            +
                // expression for reduced length.
         
     | 
| 
      
 1092 
     | 
    
         
            +
                outmask &= g.OUT_MASK;
         
     | 
| 
      
 1093 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 1094 
     | 
    
         
            +
                    m0x = 0, J12 = 0, A1 = 0, A2 = 0,
         
     | 
| 
      
 1095 
     | 
    
         
            +
                    B1, B2, l, csig12, t;
         
     | 
| 
      
 1096 
     | 
    
         
            +
                if (outmask & (g.DISTANCE | g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 1097 
     | 
    
         
            +
                  A1 = g.A1m1f(eps);
         
     | 
| 
      
 1098 
     | 
    
         
            +
                  g.C1f(eps, C1a);
         
     | 
| 
      
 1099 
     | 
    
         
            +
                  if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 1100 
     | 
    
         
            +
                    A2 = g.A2m1f(eps);
         
     | 
| 
      
 1101 
     | 
    
         
            +
                    g.C2f(eps, C2a);
         
     | 
| 
      
 1102 
     | 
    
         
            +
                    m0x = A1 - A2;
         
     | 
| 
      
 1103 
     | 
    
         
            +
                    A2 = 1 + A2;
         
     | 
| 
      
 1104 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1105 
     | 
    
         
            +
                  A1 = 1 + A1;
         
     | 
| 
      
 1106 
     | 
    
         
            +
                }
         
     | 
| 
      
 1107 
     | 
    
         
            +
                if (outmask & g.DISTANCE) {
         
     | 
| 
      
 1108 
     | 
    
         
            +
                  B1 = g.SinCosSeries(true, ssig2, csig2, C1a) -
         
     | 
| 
      
 1109 
     | 
    
         
            +
                    g.SinCosSeries(true, ssig1, csig1, C1a);
         
     | 
| 
      
 1110 
     | 
    
         
            +
                  // Missing a factor of _b
         
     | 
| 
      
 1111 
     | 
    
         
            +
                  vals.s12b = A1 * (sig12 + B1);
         
     | 
| 
      
 1112 
     | 
    
         
            +
                  if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 1113 
     | 
    
         
            +
                    B2 = g.SinCosSeries(true, ssig2, csig2, C2a) -
         
     | 
| 
      
 1114 
     | 
    
         
            +
                      g.SinCosSeries(true, ssig1, csig1, C2a);
         
     | 
| 
      
 1115 
     | 
    
         
            +
                    J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
         
     | 
| 
      
 1116 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1117 
     | 
    
         
            +
                } else if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 1118 
     | 
    
         
            +
                  // Assume here that nC1_ >= nC2_
         
     | 
| 
      
 1119 
     | 
    
         
            +
                  for (l = 1; l <= g.nC2_; ++l)
         
     | 
| 
      
 1120 
     | 
    
         
            +
                    C2a[l] = A1 * C1a[l] - A2 * C2a[l];
         
     | 
| 
      
 1121 
     | 
    
         
            +
                  J12 = m0x * sig12 + (g.SinCosSeries(true, ssig2, csig2, C2a) -
         
     | 
| 
      
 1122 
     | 
    
         
            +
                                       g.SinCosSeries(true, ssig1, csig1, C2a));
         
     | 
| 
      
 1123 
     | 
    
         
            +
                }
         
     | 
| 
      
 1124 
     | 
    
         
            +
                if (outmask & g.REDUCEDLENGTH) {
         
     | 
| 
      
 1125 
     | 
    
         
            +
                  vals.m0 = m0x;
         
     | 
| 
      
 1126 
     | 
    
         
            +
                  // Missing a factor of _b.
         
     | 
| 
      
 1127 
     | 
    
         
            +
                  // Add parens around (csig1 * ssig2) and (ssig1 * csig2) to ensure
         
     | 
| 
      
 1128 
     | 
    
         
            +
                  // accurate cancellation in the case of coincident points.
         
     | 
| 
      
 1129 
     | 
    
         
            +
                  vals.m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) -
         
     | 
| 
      
 1130 
     | 
    
         
            +
                    csig1 * csig2 * J12;
         
     | 
| 
      
 1131 
     | 
    
         
            +
                }
         
     | 
| 
      
 1132 
     | 
    
         
            +
                if (outmask & g.GEODESICSCALE) {
         
     | 
| 
      
 1133 
     | 
    
         
            +
                  csig12 = csig1 * csig2 + ssig1 * ssig2;
         
     | 
| 
      
 1134 
     | 
    
         
            +
                  t = this._ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
         
     | 
| 
      
 1135 
     | 
    
         
            +
                  vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
         
     | 
| 
      
 1136 
     | 
    
         
            +
                  vals.M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
         
     | 
| 
      
 1137 
     | 
    
         
            +
                }
         
     | 
| 
      
 1138 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 1139 
     | 
    
         
            +
              };
         
     | 
| 
      
 1140 
     | 
    
         
            +
             
     | 
| 
      
 1141 
     | 
    
         
            +
              // return sig12, salp1, calp1, salp2, calp2, dnm
         
     | 
| 
      
 1142 
     | 
    
         
            +
              g.Geodesic.prototype.InverseStart = function(sbet1, cbet1, dn1,
         
     | 
| 
      
 1143 
     | 
    
         
            +
                                                           sbet2, cbet2, dn2,
         
     | 
| 
      
 1144 
     | 
    
         
            +
                                                           lam12, slam12, clam12,
         
     | 
| 
      
 1145 
     | 
    
         
            +
                                                           C1a, C2a) {
         
     | 
| 
      
 1146 
     | 
    
         
            +
                // Return a starting point for Newton's method in salp1 and calp1
         
     | 
| 
      
 1147 
     | 
    
         
            +
                // (function value is -1).  If Newton's method doesn't need to be
         
     | 
| 
      
 1148 
     | 
    
         
            +
                // used, return also salp2 and calp2 and function value is sig12.
         
     | 
| 
      
 1149 
     | 
    
         
            +
                // salp2, calp2 only updated if return val >= 0.
         
     | 
| 
      
 1150 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 1151 
     | 
    
         
            +
                    // bet12 = bet2 - bet1 in [0, pi); bet12a = bet2 + bet1 in (-pi, 0]
         
     | 
| 
      
 1152 
     | 
    
         
            +
                    sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
         
     | 
| 
      
 1153 
     | 
    
         
            +
                    cbet12 = cbet2 * cbet1 + sbet2 * sbet1,
         
     | 
| 
      
 1154 
     | 
    
         
            +
                    sbet12a, shortline, omg12, sbetm2, somg12, comg12, t, ssig12, csig12,
         
     | 
| 
      
 1155 
     | 
    
         
            +
                    x, y, lamscale, betscale, k2, eps, cbet12a, bet12a, m12b, m0, nvals,
         
     | 
| 
      
 1156 
     | 
    
         
            +
                    k, omg12a, lam12x;
         
     | 
| 
      
 1157 
     | 
    
         
            +
                vals.sig12 = -1;        // Return value
         
     | 
| 
      
 1158 
     | 
    
         
            +
                // Volatile declaration needed to fix inverse cases
         
     | 
| 
      
 1159 
     | 
    
         
            +
                // 88.202499451857 0 -88.202499451857 179.981022032992859592
         
     | 
| 
      
 1160 
     | 
    
         
            +
                // 89.262080389218 0 -89.262080389218 179.992207982775375662
         
     | 
| 
      
 1161 
     | 
    
         
            +
                // 89.333123580033 0 -89.333123580032997687 179.99295812360148422
         
     | 
| 
      
 1162 
     | 
    
         
            +
                // which otherwise fail with g++ 4.4.4 x86 -O3
         
     | 
| 
      
 1163 
     | 
    
         
            +
                sbet12a = sbet2 * cbet1;
         
     | 
| 
      
 1164 
     | 
    
         
            +
                sbet12a += cbet2 * sbet1;
         
     | 
| 
      
 1165 
     | 
    
         
            +
             
     | 
| 
      
 1166 
     | 
    
         
            +
                shortline = cbet12 >= 0 && sbet12 < 0.5 && cbet2 * lam12 < 0.5;
         
     | 
| 
      
 1167 
     | 
    
         
            +
                if (shortline) {
         
     | 
| 
      
 1168 
     | 
    
         
            +
                  sbetm2 = m.sq(sbet1 + sbet2);
         
     | 
| 
      
 1169 
     | 
    
         
            +
                  // sin((bet1+bet2)/2)^2
         
     | 
| 
      
 1170 
     | 
    
         
            +
                  // =  (sbet1 + sbet2)^2 / ((sbet1 + sbet2)^2 + (cbet1 + cbet2)^2)
         
     | 
| 
      
 1171 
     | 
    
         
            +
                  sbetm2 /= sbetm2 + m.sq(cbet1 + cbet2);
         
     | 
| 
      
 1172 
     | 
    
         
            +
                  vals.dnm = Math.sqrt(1 + this._ep2 * sbetm2);
         
     | 
| 
      
 1173 
     | 
    
         
            +
                  omg12 = lam12 / (this._f1 * vals.dnm);
         
     | 
| 
      
 1174 
     | 
    
         
            +
                  somg12 = Math.sin(omg12); comg12 = Math.cos(omg12);
         
     | 
| 
      
 1175 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 1176 
     | 
    
         
            +
                  somg12 = slam12; comg12 = clam12;
         
     | 
| 
      
 1177 
     | 
    
         
            +
                }
         
     | 
| 
      
 1178 
     | 
    
         
            +
             
     | 
| 
      
 1179 
     | 
    
         
            +
                vals.salp1 = cbet2 * somg12;
         
     | 
| 
      
 1180 
     | 
    
         
            +
                vals.calp1 = comg12 >= 0 ?
         
     | 
| 
      
 1181 
     | 
    
         
            +
                  sbet12 + cbet2 * sbet1 * m.sq(somg12) / (1 + comg12) :
         
     | 
| 
      
 1182 
     | 
    
         
            +
                  sbet12a - cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
         
     | 
| 
      
 1183 
     | 
    
         
            +
             
     | 
| 
      
 1184 
     | 
    
         
            +
                ssig12 = m.hypot(vals.salp1, vals.calp1);
         
     | 
| 
      
 1185 
     | 
    
         
            +
                csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
         
     | 
| 
      
 1186 
     | 
    
         
            +
                if (shortline && ssig12 < this._etol2) {
         
     | 
| 
      
 1187 
     | 
    
         
            +
                  // really short lines
         
     | 
| 
      
 1188 
     | 
    
         
            +
                  vals.salp2 = cbet1 * somg12;
         
     | 
| 
      
 1189 
     | 
    
         
            +
                  vals.calp2 = sbet12 - cbet1 * sbet2 *
         
     | 
| 
      
 1190 
     | 
    
         
            +
                    (comg12 >= 0 ? m.sq(somg12) / (1 + comg12) : 1 - comg12);
         
     | 
| 
      
 1191 
     | 
    
         
            +
                  // norm(vals.salp2, vals.calp2);
         
     | 
| 
      
 1192 
     | 
    
         
            +
                  t = m.hypot(vals.salp2, vals.calp2); vals.salp2 /= t; vals.calp2 /= t;
         
     | 
| 
      
 1193 
     | 
    
         
            +
                  // Set return value
         
     | 
| 
      
 1194 
     | 
    
         
            +
                  vals.sig12 = Math.atan2(ssig12, csig12);
         
     | 
| 
      
 1195 
     | 
    
         
            +
                } else if (Math.abs(this._n) > 0.1 || // Skip astroid calc if too eccentric
         
     | 
| 
      
 1196 
     | 
    
         
            +
                           csig12 >= 0 ||
         
     | 
| 
      
 1197 
     | 
    
         
            +
                           ssig12 >= 6 * Math.abs(this._n) * Math.PI * m.sq(cbet1)) {
         
     | 
| 
      
 1198 
     | 
    
         
            +
                  // Nothing to do, zeroth order spherical approximation is OK
         
     | 
| 
      
 1199 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 1200 
     | 
    
         
            +
                  // Scale lam12 and bet2 to x, y coordinate system where antipodal
         
     | 
| 
      
 1201 
     | 
    
         
            +
                  // point is at origin and singular point is at y = 0, x = -1.
         
     | 
| 
      
 1202 
     | 
    
         
            +
                  lam12x = Math.atan2(-slam12, -clam12); // lam12 - pi
         
     | 
| 
      
 1203 
     | 
    
         
            +
                  if (this.f >= 0) {       // In fact f == 0 does not get here
         
     | 
| 
      
 1204 
     | 
    
         
            +
                    // x = dlong, y = dlat
         
     | 
| 
      
 1205 
     | 
    
         
            +
                    k2 = m.sq(sbet1) * this._ep2;
         
     | 
| 
      
 1206 
     | 
    
         
            +
                    eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
         
     | 
| 
      
 1207 
     | 
    
         
            +
                    lamscale = this.f * cbet1 * this.A3f(eps) * Math.PI;
         
     | 
| 
      
 1208 
     | 
    
         
            +
                    betscale = lamscale * cbet1;
         
     | 
| 
      
 1209 
     | 
    
         
            +
             
     | 
| 
      
 1210 
     | 
    
         
            +
                    x = lam12x / lamscale;
         
     | 
| 
      
 1211 
     | 
    
         
            +
                    y = sbet12a / betscale;
         
     | 
| 
      
 1212 
     | 
    
         
            +
                  } else {                  // f < 0
         
     | 
| 
      
 1213 
     | 
    
         
            +
                    // x = dlat, y = dlong
         
     | 
| 
      
 1214 
     | 
    
         
            +
                    cbet12a = cbet2 * cbet1 - sbet2 * sbet1;
         
     | 
| 
      
 1215 
     | 
    
         
            +
                    bet12a = Math.atan2(sbet12a, cbet12a);
         
     | 
| 
      
 1216 
     | 
    
         
            +
                    // In the case of lon12 = 180, this repeats a calculation made
         
     | 
| 
      
 1217 
     | 
    
         
            +
                    // in Inverse.
         
     | 
| 
      
 1218 
     | 
    
         
            +
                    nvals = this.Lengths(this._n, Math.PI + bet12a,
         
     | 
| 
      
 1219 
     | 
    
         
            +
                                         sbet1, -cbet1, dn1, sbet2, cbet2, dn2,
         
     | 
| 
      
 1220 
     | 
    
         
            +
                                         cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
         
     | 
| 
      
 1221 
     | 
    
         
            +
                    m12b = nvals.m12b; m0 = nvals.m0;
         
     | 
| 
      
 1222 
     | 
    
         
            +
                    x = -1 + m12b / (cbet1 * cbet2 * m0 * Math.PI);
         
     | 
| 
      
 1223 
     | 
    
         
            +
                    betscale = x < -0.01 ? sbet12a / x :
         
     | 
| 
      
 1224 
     | 
    
         
            +
                      -this.f * m.sq(cbet1) * Math.PI;
         
     | 
| 
      
 1225 
     | 
    
         
            +
                    lamscale = betscale / cbet1;
         
     | 
| 
      
 1226 
     | 
    
         
            +
                    y = lam12 / lamscale;
         
     | 
| 
      
 1227 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1228 
     | 
    
         
            +
             
     | 
| 
      
 1229 
     | 
    
         
            +
                  if (y > -tol1_ && x > -1 - xthresh_) {
         
     | 
| 
      
 1230 
     | 
    
         
            +
                    // strip near cut
         
     | 
| 
      
 1231 
     | 
    
         
            +
                    if (this.f >= 0) {
         
     | 
| 
      
 1232 
     | 
    
         
            +
                      vals.salp1 = Math.min(1, -x);
         
     | 
| 
      
 1233 
     | 
    
         
            +
                      vals.calp1 = -Math.sqrt(1 - m.sq(vals.salp1));
         
     | 
| 
      
 1234 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 1235 
     | 
    
         
            +
                      vals.calp1 = Math.max(x > -tol1_ ? 0 : -1, x);
         
     | 
| 
      
 1236 
     | 
    
         
            +
                      vals.salp1 = Math.sqrt(1 - m.sq(vals.calp1));
         
     | 
| 
      
 1237 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1238 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 1239 
     | 
    
         
            +
                    // Estimate alp1, by solving the astroid problem.
         
     | 
| 
      
 1240 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1241 
     | 
    
         
            +
                    // Could estimate alpha1 = theta + pi/2, directly, i.e.,
         
     | 
| 
      
 1242 
     | 
    
         
            +
                    //   calp1 = y/k; salp1 = -x/(1+k);  for f >= 0
         
     | 
| 
      
 1243 
     | 
    
         
            +
                    //   calp1 = x/(1+k); salp1 = -y/k;  for f < 0 (need to check)
         
     | 
| 
      
 1244 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1245 
     | 
    
         
            +
                    // However, it's better to estimate omg12 from astroid and use
         
     | 
| 
      
 1246 
     | 
    
         
            +
                    // spherical formula to compute alp1.  This reduces the mean number of
         
     | 
| 
      
 1247 
     | 
    
         
            +
                    // Newton iterations for astroid cases from 2.24 (min 0, max 6) to 2.12
         
     | 
| 
      
 1248 
     | 
    
         
            +
                    // (min 0 max 5).  The changes in the number of iterations are as
         
     | 
| 
      
 1249 
     | 
    
         
            +
                    // follows:
         
     | 
| 
      
 1250 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1251 
     | 
    
         
            +
                    // change percent
         
     | 
| 
      
 1252 
     | 
    
         
            +
                    //    1       5
         
     | 
| 
      
 1253 
     | 
    
         
            +
                    //    0      78
         
     | 
| 
      
 1254 
     | 
    
         
            +
                    //   -1      16
         
     | 
| 
      
 1255 
     | 
    
         
            +
                    //   -2       0.6
         
     | 
| 
      
 1256 
     | 
    
         
            +
                    //   -3       0.04
         
     | 
| 
      
 1257 
     | 
    
         
            +
                    //   -4       0.002
         
     | 
| 
      
 1258 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1259 
     | 
    
         
            +
                    // The histogram of iterations is (m = number of iterations estimating
         
     | 
| 
      
 1260 
     | 
    
         
            +
                    // alp1 directly, n = number of iterations estimating via omg12, total
         
     | 
| 
      
 1261 
     | 
    
         
            +
                    // number of trials = 148605):
         
     | 
| 
      
 1262 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1263 
     | 
    
         
            +
                    //  iter    m      n
         
     | 
| 
      
 1264 
     | 
    
         
            +
                    //    0   148    186
         
     | 
| 
      
 1265 
     | 
    
         
            +
                    //    1 13046  13845
         
     | 
| 
      
 1266 
     | 
    
         
            +
                    //    2 93315 102225
         
     | 
| 
      
 1267 
     | 
    
         
            +
                    //    3 36189  32341
         
     | 
| 
      
 1268 
     | 
    
         
            +
                    //    4  5396      7
         
     | 
| 
      
 1269 
     | 
    
         
            +
                    //    5   455      1
         
     | 
| 
      
 1270 
     | 
    
         
            +
                    //    6    56      0
         
     | 
| 
      
 1271 
     | 
    
         
            +
                    //
         
     | 
| 
      
 1272 
     | 
    
         
            +
                    // Because omg12 is near pi, estimate work with omg12a = pi - omg12
         
     | 
| 
      
 1273 
     | 
    
         
            +
                    k = astroid(x, y);
         
     | 
| 
      
 1274 
     | 
    
         
            +
                    omg12a = lamscale * ( this.f >= 0 ? -x * k/(1 + k) : -y * (1 + k)/k );
         
     | 
| 
      
 1275 
     | 
    
         
            +
                    somg12 = Math.sin(omg12a); comg12 = -Math.cos(omg12a);
         
     | 
| 
      
 1276 
     | 
    
         
            +
                    // Update spherical estimate of alp1 using omg12 instead of
         
     | 
| 
      
 1277 
     | 
    
         
            +
                    // lam12
         
     | 
| 
      
 1278 
     | 
    
         
            +
                    vals.salp1 = cbet2 * somg12;
         
     | 
| 
      
 1279 
     | 
    
         
            +
                    vals.calp1 = sbet12a -
         
     | 
| 
      
 1280 
     | 
    
         
            +
                      cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
         
     | 
| 
      
 1281 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1282 
     | 
    
         
            +
                }
         
     | 
| 
      
 1283 
     | 
    
         
            +
                // Sanity check on starting guess.  Backwards check allows NaN through.
         
     | 
| 
      
 1284 
     | 
    
         
            +
                if (!(vals.salp1 <= 0.0)) {
         
     | 
| 
      
 1285 
     | 
    
         
            +
                  // norm(vals.salp1, vals.calp1);
         
     | 
| 
      
 1286 
     | 
    
         
            +
                  t = m.hypot(vals.salp1, vals.calp1); vals.salp1 /= t; vals.calp1 /= t;
         
     | 
| 
      
 1287 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 1288 
     | 
    
         
            +
                  vals.salp1 = 1; vals.calp1 = 0;
         
     | 
| 
      
 1289 
     | 
    
         
            +
                }
         
     | 
| 
      
 1290 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 1291 
     | 
    
         
            +
              };
         
     | 
| 
      
 1292 
     | 
    
         
            +
             
     | 
| 
      
 1293 
     | 
    
         
            +
              // return lam12, salp2, calp2, sig12, ssig1, csig1, ssig2, csig2, eps,
         
     | 
| 
      
 1294 
     | 
    
         
            +
              // domg12, dlam12,
         
     | 
| 
      
 1295 
     | 
    
         
            +
              g.Geodesic.prototype.Lambda12 = function(sbet1, cbet1, dn1,
         
     | 
| 
      
 1296 
     | 
    
         
            +
                                                       sbet2, cbet2, dn2,
         
     | 
| 
      
 1297 
     | 
    
         
            +
                                                       salp1, calp1, slam120, clam120,
         
     | 
| 
      
 1298 
     | 
    
         
            +
                                                       diffp, C1a, C2a, C3a) {
         
     | 
| 
      
 1299 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 1300 
     | 
    
         
            +
                    t, salp0, calp0,
         
     | 
| 
      
 1301 
     | 
    
         
            +
                    somg1, comg1, somg2, comg2, somg12, comg12, B312, eta, k2, nvals;
         
     | 
| 
      
 1302 
     | 
    
         
            +
                if (sbet1 === 0 && calp1 === 0)
         
     | 
| 
      
 1303 
     | 
    
         
            +
                  // Break degeneracy of equatorial line.  This case has already been
         
     | 
| 
      
 1304 
     | 
    
         
            +
                  // handled.
         
     | 
| 
      
 1305 
     | 
    
         
            +
                  calp1 = -g.tiny_;
         
     | 
| 
      
 1306 
     | 
    
         
            +
             
     | 
| 
      
 1307 
     | 
    
         
            +
                // sin(alp1) * cos(bet1) = sin(alp0)
         
     | 
| 
      
 1308 
     | 
    
         
            +
                salp0 = salp1 * cbet1;
         
     | 
| 
      
 1309 
     | 
    
         
            +
                calp0 = m.hypot(calp1, salp1 * sbet1); // calp0 > 0
         
     | 
| 
      
 1310 
     | 
    
         
            +
             
     | 
| 
      
 1311 
     | 
    
         
            +
                // tan(bet1) = tan(sig1) * cos(alp1)
         
     | 
| 
      
 1312 
     | 
    
         
            +
                // tan(omg1) = sin(alp0) * tan(sig1) = tan(omg1)=tan(alp1)*sin(bet1)
         
     | 
| 
      
 1313 
     | 
    
         
            +
                vals.ssig1 = sbet1; somg1 = salp0 * sbet1;
         
     | 
| 
      
 1314 
     | 
    
         
            +
                vals.csig1 = comg1 = calp1 * cbet1;
         
     | 
| 
      
 1315 
     | 
    
         
            +
                // norm(vals.ssig1, vals.csig1);
         
     | 
| 
      
 1316 
     | 
    
         
            +
                t = m.hypot(vals.ssig1, vals.csig1); vals.ssig1 /= t; vals.csig1 /= t;
         
     | 
| 
      
 1317 
     | 
    
         
            +
                // norm(somg1, comg1); -- don't need to normalize!
         
     | 
| 
      
 1318 
     | 
    
         
            +
             
     | 
| 
      
 1319 
     | 
    
         
            +
                // Enforce symmetries in the case abs(bet2) = -bet1.  Need to be careful
         
     | 
| 
      
 1320 
     | 
    
         
            +
                // about this case, since this can yield singularities in the Newton
         
     | 
| 
      
 1321 
     | 
    
         
            +
                // iteration.
         
     | 
| 
      
 1322 
     | 
    
         
            +
                // sin(alp2) * cos(bet2) = sin(alp0)
         
     | 
| 
      
 1323 
     | 
    
         
            +
                vals.salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;
         
     | 
| 
      
 1324 
     | 
    
         
            +
                // calp2 = sqrt(1 - sq(salp2))
         
     | 
| 
      
 1325 
     | 
    
         
            +
                //       = sqrt(sq(calp0) - sq(sbet2)) / cbet2
         
     | 
| 
      
 1326 
     | 
    
         
            +
                // and subst for calp0 and rearrange to give (choose positive sqrt
         
     | 
| 
      
 1327 
     | 
    
         
            +
                // to give alp2 in [0, pi/2]).
         
     | 
| 
      
 1328 
     | 
    
         
            +
                vals.calp2 = cbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1 ?
         
     | 
| 
      
 1329 
     | 
    
         
            +
                  Math.sqrt(m.sq(calp1 * cbet1) + (cbet1 < -sbet1 ?
         
     | 
| 
      
 1330 
     | 
    
         
            +
                                                   (cbet2 - cbet1) * (cbet1 + cbet2) :
         
     | 
| 
      
 1331 
     | 
    
         
            +
                                                   (sbet1 - sbet2) * (sbet1 + sbet2))) /
         
     | 
| 
      
 1332 
     | 
    
         
            +
                  cbet2 : Math.abs(calp1);
         
     | 
| 
      
 1333 
     | 
    
         
            +
                // tan(bet2) = tan(sig2) * cos(alp2)
         
     | 
| 
      
 1334 
     | 
    
         
            +
                // tan(omg2) = sin(alp0) * tan(sig2).
         
     | 
| 
      
 1335 
     | 
    
         
            +
                vals.ssig2 = sbet2; somg2 = salp0 * sbet2;
         
     | 
| 
      
 1336 
     | 
    
         
            +
                vals.csig2 = comg2 = vals.calp2 * cbet2;
         
     | 
| 
      
 1337 
     | 
    
         
            +
                // norm(vals.ssig2, vals.csig2);
         
     | 
| 
      
 1338 
     | 
    
         
            +
                t = m.hypot(vals.ssig2, vals.csig2); vals.ssig2 /= t; vals.csig2 /= t;
         
     | 
| 
      
 1339 
     | 
    
         
            +
                // norm(somg2, comg2); -- don't need to normalize!
         
     | 
| 
      
 1340 
     | 
    
         
            +
             
     | 
| 
      
 1341 
     | 
    
         
            +
                // sig12 = sig2 - sig1, limit to [0, pi]
         
     | 
| 
      
 1342 
     | 
    
         
            +
                vals.sig12 = Math.atan2(Math.max(0, vals.csig1 * vals.ssig2 -
         
     | 
| 
      
 1343 
     | 
    
         
            +
                                                    vals.ssig1 * vals.csig2),
         
     | 
| 
      
 1344 
     | 
    
         
            +
                                                    vals.csig1 * vals.csig2 +
         
     | 
| 
      
 1345 
     | 
    
         
            +
                                                    vals.ssig1 * vals.ssig2);
         
     | 
| 
      
 1346 
     | 
    
         
            +
             
     | 
| 
      
 1347 
     | 
    
         
            +
                // omg12 = omg2 - omg1, limit to [0, pi]
         
     | 
| 
      
 1348 
     | 
    
         
            +
                somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);
         
     | 
| 
      
 1349 
     | 
    
         
            +
                comg12 =             comg1 * comg2 + somg1 * somg2;
         
     | 
| 
      
 1350 
     | 
    
         
            +
                // eta = omg12 - lam120
         
     | 
| 
      
 1351 
     | 
    
         
            +
                eta = Math.atan2(somg12 * clam120 - comg12 * slam120,
         
     | 
| 
      
 1352 
     | 
    
         
            +
                                 comg12 * clam120 + somg12 * slam120);
         
     | 
| 
      
 1353 
     | 
    
         
            +
                k2 = m.sq(calp0) * this._ep2;
         
     | 
| 
      
 1354 
     | 
    
         
            +
                vals.eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
         
     | 
| 
      
 1355 
     | 
    
         
            +
                this.C3f(vals.eps, C3a);
         
     | 
| 
      
 1356 
     | 
    
         
            +
                B312 = (g.SinCosSeries(true, vals.ssig2, vals.csig2, C3a) -
         
     | 
| 
      
 1357 
     | 
    
         
            +
                        g.SinCosSeries(true, vals.ssig1, vals.csig1, C3a));
         
     | 
| 
      
 1358 
     | 
    
         
            +
                vals.domg12 =  -this.f * this.A3f(vals.eps) * salp0 * (vals.sig12 + B312);
         
     | 
| 
      
 1359 
     | 
    
         
            +
                vals.lam12 = eta + vals.domg12;
         
     | 
| 
      
 1360 
     | 
    
         
            +
                if (diffp) {
         
     | 
| 
      
 1361 
     | 
    
         
            +
                  if (vals.calp2 === 0)
         
     | 
| 
      
 1362 
     | 
    
         
            +
                    vals.dlam12 = -2 * this._f1 * dn1 / sbet1;
         
     | 
| 
      
 1363 
     | 
    
         
            +
                  else {
         
     | 
| 
      
 1364 
     | 
    
         
            +
                    nvals = this.Lengths(vals.eps, vals.sig12,
         
     | 
| 
      
 1365 
     | 
    
         
            +
                                         vals.ssig1, vals.csig1, dn1,
         
     | 
| 
      
 1366 
     | 
    
         
            +
                                         vals.ssig2, vals.csig2, dn2,
         
     | 
| 
      
 1367 
     | 
    
         
            +
                                         cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
         
     | 
| 
      
 1368 
     | 
    
         
            +
                    vals.dlam12 = nvals.m12b;
         
     | 
| 
      
 1369 
     | 
    
         
            +
                    vals.dlam12 *= this._f1 / (vals.calp2 * cbet2);
         
     | 
| 
      
 1370 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1371 
     | 
    
         
            +
                }
         
     | 
| 
      
 1372 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 1373 
     | 
    
         
            +
              };
         
     | 
| 
      
 1374 
     | 
    
         
            +
             
     | 
| 
      
 1375 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1376 
     | 
    
         
            +
               * @summary Solve the inverse geodesic problem.
         
     | 
| 
      
 1377 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1378 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1379 
     | 
    
         
            +
               * @param {number} lat2 the latitude of the second point in degrees.
         
     | 
| 
      
 1380 
     | 
    
         
            +
               * @param {number} lon2 the longitude of the second point in degrees.
         
     | 
| 
      
 1381 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include.
         
     | 
| 
      
 1382 
     | 
    
         
            +
               * @returns {object} the requested results
         
     | 
| 
      
 1383 
     | 
    
         
            +
               * @description The lat1, lon1, lat2, lon2, and a12 fields of the result are
         
     | 
| 
      
 1384 
     | 
    
         
            +
               *   always set.  For details on the outmask parameter, see {@tutorial
         
     | 
| 
      
 1385 
     | 
    
         
            +
               *   2-interface}, "The outmask and caps parameters".
         
     | 
| 
      
 1386 
     | 
    
         
            +
               */
         
     | 
| 
      
 1387 
     | 
    
         
            +
              g.Geodesic.prototype.Inverse = function(lat1, lon1, lat2, lon2, outmask) {
         
     | 
| 
      
 1388 
     | 
    
         
            +
                var r, vals;
         
     | 
| 
      
 1389 
     | 
    
         
            +
                if (!outmask) outmask = g.STANDARD;
         
     | 
| 
      
 1390 
     | 
    
         
            +
                if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
         
     | 
| 
      
 1391 
     | 
    
         
            +
                outmask &= g.OUT_MASK;
         
     | 
| 
      
 1392 
     | 
    
         
            +
                r = this.InverseInt(lat1, lon1, lat2, lon2, outmask);
         
     | 
| 
      
 1393 
     | 
    
         
            +
                vals = r.vals;
         
     | 
| 
      
 1394 
     | 
    
         
            +
                if (outmask & g.AZIMUTH) {
         
     | 
| 
      
 1395 
     | 
    
         
            +
                  vals.azi1 = m.atan2d(r.salp1, r.calp1);
         
     | 
| 
      
 1396 
     | 
    
         
            +
                  vals.azi2 = m.atan2d(r.salp2, r.calp2);
         
     | 
| 
      
 1397 
     | 
    
         
            +
                }
         
     | 
| 
      
 1398 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 1399 
     | 
    
         
            +
              };
         
     | 
| 
      
 1400 
     | 
    
         
            +
             
     | 
| 
      
 1401 
     | 
    
         
            +
              g.Geodesic.prototype.InverseInt = function(lat1, lon1, lat2, lon2, outmask) {
         
     | 
| 
      
 1402 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 1403 
     | 
    
         
            +
                    lon12, lon12s, lonsign, t, swapp, latsign,
         
     | 
| 
      
 1404 
     | 
    
         
            +
                    sbet1, cbet1, sbet2, cbet2, s12x, m12x,
         
     | 
| 
      
 1405 
     | 
    
         
            +
                    dn1, dn2, lam12, slam12, clam12,
         
     | 
| 
      
 1406 
     | 
    
         
            +
                    sig12, calp1, salp1, calp2, salp2, C1a, C2a, C3a, meridian, nvals,
         
     | 
| 
      
 1407 
     | 
    
         
            +
                    ssig1, csig1, ssig2, csig2, eps, omg12, dnm,
         
     | 
| 
      
 1408 
     | 
    
         
            +
                    numit, salp1a, calp1a, salp1b, calp1b,
         
     | 
| 
      
 1409 
     | 
    
         
            +
                    tripn, tripb, v, dv, dalp1, sdalp1, cdalp1, nsalp1,
         
     | 
| 
      
 1410 
     | 
    
         
            +
                    lengthmask, salp0, calp0, alp12, k2, A4, C4a, B41, B42,
         
     | 
| 
      
 1411 
     | 
    
         
            +
                    somg12, comg12, domg12, dbet1, dbet2, salp12, calp12, sdomg12, cdomg12;
         
     | 
| 
      
 1412 
     | 
    
         
            +
                // Compute longitude difference (AngDiff does this carefully).  Result is
         
     | 
| 
      
 1413 
     | 
    
         
            +
                // in [-180, 180] but -180 is only for west-going geodesics.  180 is for
         
     | 
| 
      
 1414 
     | 
    
         
            +
                // east-going and meridional geodesics.
         
     | 
| 
      
 1415 
     | 
    
         
            +
                vals.lat1 = lat1 = m.LatFix(lat1); vals.lat2 = lat2 = m.LatFix(lat2);
         
     | 
| 
      
 1416 
     | 
    
         
            +
                // If really close to the equator, treat as on equator.
         
     | 
| 
      
 1417 
     | 
    
         
            +
                lat1 = m.AngRound(lat1);
         
     | 
| 
      
 1418 
     | 
    
         
            +
                lat2 = m.AngRound(lat2);
         
     | 
| 
      
 1419 
     | 
    
         
            +
                lon12 = m.AngDiff(lon1, lon2); lon12s = lon12.t; lon12 = lon12.s;
         
     | 
| 
      
 1420 
     | 
    
         
            +
                if (outmask & g.LONG_UNROLL) {
         
     | 
| 
      
 1421 
     | 
    
         
            +
                  vals.lon1 = lon1; vals.lon2 = (lon1 + lon12) + lon12s;
         
     | 
| 
      
 1422 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 1423 
     | 
    
         
            +
                  vals.lon1 = m.AngNormalize(lon1); vals.lon2 = m.AngNormalize(lon2);
         
     | 
| 
      
 1424 
     | 
    
         
            +
                }
         
     | 
| 
      
 1425 
     | 
    
         
            +
                // Make longitude difference positive.
         
     | 
| 
      
 1426 
     | 
    
         
            +
                lonsign = lon12 >= 0 ? 1 : -1;
         
     | 
| 
      
 1427 
     | 
    
         
            +
                // If very close to being on the same half-meridian, then make it so.
         
     | 
| 
      
 1428 
     | 
    
         
            +
                lon12 = lonsign * m.AngRound(lon12);
         
     | 
| 
      
 1429 
     | 
    
         
            +
                lon12s = m.AngRound((180 - lon12) - lonsign * lon12s);
         
     | 
| 
      
 1430 
     | 
    
         
            +
                lam12 = lon12 * m.degree;
         
     | 
| 
      
 1431 
     | 
    
         
            +
                t = m.sincosd(lon12 > 90 ? lon12s : lon12);
         
     | 
| 
      
 1432 
     | 
    
         
            +
                slam12 = t.s; clam12 = (lon12 > 90 ? -1 : 1) * t.c;
         
     | 
| 
      
 1433 
     | 
    
         
            +
             
     | 
| 
      
 1434 
     | 
    
         
            +
                // Swap points so that point with higher (abs) latitude is point 1
         
     | 
| 
      
 1435 
     | 
    
         
            +
                // If one latitude is a nan, then it becomes lat1.
         
     | 
| 
      
 1436 
     | 
    
         
            +
                swapp = Math.abs(lat1) < Math.abs(lat2) ? -1 : 1;
         
     | 
| 
      
 1437 
     | 
    
         
            +
                if (swapp < 0) {
         
     | 
| 
      
 1438 
     | 
    
         
            +
                  lonsign *= -1;
         
     | 
| 
      
 1439 
     | 
    
         
            +
                  t = lat1;
         
     | 
| 
      
 1440 
     | 
    
         
            +
                  lat1 = lat2;
         
     | 
| 
      
 1441 
     | 
    
         
            +
                  lat2 = t;
         
     | 
| 
      
 1442 
     | 
    
         
            +
                  // swap(lat1, lat2);
         
     | 
| 
      
 1443 
     | 
    
         
            +
                }
         
     | 
| 
      
 1444 
     | 
    
         
            +
                // Make lat1 <= 0
         
     | 
| 
      
 1445 
     | 
    
         
            +
                latsign = lat1 < 0 ? 1 : -1;
         
     | 
| 
      
 1446 
     | 
    
         
            +
                lat1 *= latsign;
         
     | 
| 
      
 1447 
     | 
    
         
            +
                lat2 *= latsign;
         
     | 
| 
      
 1448 
     | 
    
         
            +
                // Now we have
         
     | 
| 
      
 1449 
     | 
    
         
            +
                //
         
     | 
| 
      
 1450 
     | 
    
         
            +
                //     0 <= lon12 <= 180
         
     | 
| 
      
 1451 
     | 
    
         
            +
                //     -90 <= lat1 <= 0
         
     | 
| 
      
 1452 
     | 
    
         
            +
                //     lat1 <= lat2 <= -lat1
         
     | 
| 
      
 1453 
     | 
    
         
            +
                //
         
     | 
| 
      
 1454 
     | 
    
         
            +
                // longsign, swapp, latsign register the transformation to bring the
         
     | 
| 
      
 1455 
     | 
    
         
            +
                // coordinates to this canonical form.  In all cases, 1 means no change was
         
     | 
| 
      
 1456 
     | 
    
         
            +
                // made.  We make these transformations so that there are few cases to
         
     | 
| 
      
 1457 
     | 
    
         
            +
                // check, e.g., on verifying quadrants in atan2.  In addition, this
         
     | 
| 
      
 1458 
     | 
    
         
            +
                // enforces some symmetries in the results returned.
         
     | 
| 
      
 1459 
     | 
    
         
            +
             
     | 
| 
      
 1460 
     | 
    
         
            +
                t = m.sincosd(lat1); sbet1 = this._f1 * t.s; cbet1 = t.c;
         
     | 
| 
      
 1461 
     | 
    
         
            +
                // norm(sbet1, cbet1);
         
     | 
| 
      
 1462 
     | 
    
         
            +
                t = m.hypot(sbet1, cbet1); sbet1 /= t; cbet1 /= t;
         
     | 
| 
      
 1463 
     | 
    
         
            +
                // Ensure cbet1 = +epsilon at poles
         
     | 
| 
      
 1464 
     | 
    
         
            +
                cbet1 = Math.max(g.tiny_, cbet1);
         
     | 
| 
      
 1465 
     | 
    
         
            +
             
     | 
| 
      
 1466 
     | 
    
         
            +
                t = m.sincosd(lat2); sbet2 = this._f1 * t.s; cbet2 = t.c;
         
     | 
| 
      
 1467 
     | 
    
         
            +
                // norm(sbet2, cbet2);
         
     | 
| 
      
 1468 
     | 
    
         
            +
                t = m.hypot(sbet2, cbet2); sbet2 /= t; cbet2 /= t;
         
     | 
| 
      
 1469 
     | 
    
         
            +
                // Ensure cbet2 = +epsilon at poles
         
     | 
| 
      
 1470 
     | 
    
         
            +
                cbet2 = Math.max(g.tiny_, cbet2);
         
     | 
| 
      
 1471 
     | 
    
         
            +
             
     | 
| 
      
 1472 
     | 
    
         
            +
                // If cbet1 < -sbet1, then cbet2 - cbet1 is a sensitive measure of the
         
     | 
| 
      
 1473 
     | 
    
         
            +
                // |bet1| - |bet2|.  Alternatively (cbet1 >= -sbet1), abs(sbet2) + sbet1 is
         
     | 
| 
      
 1474 
     | 
    
         
            +
                // a better measure.  This logic is used in assigning calp2 in Lambda12.
         
     | 
| 
      
 1475 
     | 
    
         
            +
                // Sometimes these quantities vanish and in that case we force bet2 = +/-
         
     | 
| 
      
 1476 
     | 
    
         
            +
                // bet1 exactly.  An example where is is necessary is the inverse problem
         
     | 
| 
      
 1477 
     | 
    
         
            +
                // 48.522876735459 0 -48.52287673545898293 179.599720456223079643
         
     | 
| 
      
 1478 
     | 
    
         
            +
                // which failed with Visual Studio 10 (Release and Debug)
         
     | 
| 
      
 1479 
     | 
    
         
            +
             
     | 
| 
      
 1480 
     | 
    
         
            +
                if (cbet1 < -sbet1) {
         
     | 
| 
      
 1481 
     | 
    
         
            +
                  if (cbet2 === cbet1)
         
     | 
| 
      
 1482 
     | 
    
         
            +
                    sbet2 = sbet2 < 0 ? sbet1 : -sbet1;
         
     | 
| 
      
 1483 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 1484 
     | 
    
         
            +
                  if (Math.abs(sbet2) === -sbet1)
         
     | 
| 
      
 1485 
     | 
    
         
            +
                    cbet2 = cbet1;
         
     | 
| 
      
 1486 
     | 
    
         
            +
                }
         
     | 
| 
      
 1487 
     | 
    
         
            +
             
     | 
| 
      
 1488 
     | 
    
         
            +
                dn1 = Math.sqrt(1 + this._ep2 * m.sq(sbet1));
         
     | 
| 
      
 1489 
     | 
    
         
            +
                dn2 = Math.sqrt(1 + this._ep2 * m.sq(sbet2));
         
     | 
| 
      
 1490 
     | 
    
         
            +
             
     | 
| 
      
 1491 
     | 
    
         
            +
                // index zero elements of these arrays are unused
         
     | 
| 
      
 1492 
     | 
    
         
            +
                C1a = new Array(g.nC1_ + 1);
         
     | 
| 
      
 1493 
     | 
    
         
            +
                C2a = new Array(g.nC2_ + 1);
         
     | 
| 
      
 1494 
     | 
    
         
            +
                C3a = new Array(g.nC3_);
         
     | 
| 
      
 1495 
     | 
    
         
            +
             
     | 
| 
      
 1496 
     | 
    
         
            +
                meridian = lat1 === -90 || slam12 === 0;
         
     | 
| 
      
 1497 
     | 
    
         
            +
                if (meridian) {
         
     | 
| 
      
 1498 
     | 
    
         
            +
             
     | 
| 
      
 1499 
     | 
    
         
            +
                  // Endpoints are on a single full meridian, so the geodesic might
         
     | 
| 
      
 1500 
     | 
    
         
            +
                  // lie on a meridian.
         
     | 
| 
      
 1501 
     | 
    
         
            +
             
     | 
| 
      
 1502 
     | 
    
         
            +
                  calp1 = clam12; salp1 = slam12; // Head to the target longitude
         
     | 
| 
      
 1503 
     | 
    
         
            +
                  calp2 = 1; salp2 = 0;           // At the target we're heading north
         
     | 
| 
      
 1504 
     | 
    
         
            +
             
     | 
| 
      
 1505 
     | 
    
         
            +
                  // tan(bet) = tan(sig) * cos(alp)
         
     | 
| 
      
 1506 
     | 
    
         
            +
                  ssig1 = sbet1; csig1 = calp1 * cbet1;
         
     | 
| 
      
 1507 
     | 
    
         
            +
                  ssig2 = sbet2; csig2 = calp2 * cbet2;
         
     | 
| 
      
 1508 
     | 
    
         
            +
             
     | 
| 
      
 1509 
     | 
    
         
            +
                  // sig12 = sig2 - sig1
         
     | 
| 
      
 1510 
     | 
    
         
            +
                  sig12 = Math.atan2(Math.max(0, csig1 * ssig2 - ssig1 * csig2),
         
     | 
| 
      
 1511 
     | 
    
         
            +
                                                 csig1 * csig2 + ssig1 * ssig2);
         
     | 
| 
      
 1512 
     | 
    
         
            +
                  nvals = this.Lengths(this._n, sig12,
         
     | 
| 
      
 1513 
     | 
    
         
            +
                                       ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2,
         
     | 
| 
      
 1514 
     | 
    
         
            +
                                       outmask | g.DISTANCE | g.REDUCEDLENGTH,
         
     | 
| 
      
 1515 
     | 
    
         
            +
                                       C1a, C2a);
         
     | 
| 
      
 1516 
     | 
    
         
            +
                  s12x = nvals.s12b;
         
     | 
| 
      
 1517 
     | 
    
         
            +
                  m12x = nvals.m12b;
         
     | 
| 
      
 1518 
     | 
    
         
            +
                  // Ignore m0
         
     | 
| 
      
 1519 
     | 
    
         
            +
                  if (outmask & g.GEODESICSCALE) {
         
     | 
| 
      
 1520 
     | 
    
         
            +
                    vals.M12 = nvals.M12;
         
     | 
| 
      
 1521 
     | 
    
         
            +
                    vals.M21 = nvals.M21;
         
     | 
| 
      
 1522 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1523 
     | 
    
         
            +
                  // Add the check for sig12 since zero length geodesics might yield
         
     | 
| 
      
 1524 
     | 
    
         
            +
                  // m12 < 0.  Test case was
         
     | 
| 
      
 1525 
     | 
    
         
            +
                  //
         
     | 
| 
      
 1526 
     | 
    
         
            +
                  //    echo 20.001 0 20.001 0 | GeodSolve -i
         
     | 
| 
      
 1527 
     | 
    
         
            +
                  //
         
     | 
| 
      
 1528 
     | 
    
         
            +
                  // In fact, we will have sig12 > pi/2 for meridional geodesic
         
     | 
| 
      
 1529 
     | 
    
         
            +
                  // which is not a shortest path.
         
     | 
| 
      
 1530 
     | 
    
         
            +
                  if (sig12 < 1 || m12x >= 0) {
         
     | 
| 
      
 1531 
     | 
    
         
            +
                    // Need at least 2, to handle 90 0 90 180
         
     | 
| 
      
 1532 
     | 
    
         
            +
                    if (sig12 < 3 * g.tiny_)
         
     | 
| 
      
 1533 
     | 
    
         
            +
                      sig12 = m12x = s12x = 0;
         
     | 
| 
      
 1534 
     | 
    
         
            +
                    m12x *= this._b;
         
     | 
| 
      
 1535 
     | 
    
         
            +
                    s12x *= this._b;
         
     | 
| 
      
 1536 
     | 
    
         
            +
                    vals.a12 = sig12 / m.degree;
         
     | 
| 
      
 1537 
     | 
    
         
            +
                  } else
         
     | 
| 
      
 1538 
     | 
    
         
            +
                    // m12 < 0, i.e., prolate and too close to anti-podal
         
     | 
| 
      
 1539 
     | 
    
         
            +
                    meridian = false;
         
     | 
| 
      
 1540 
     | 
    
         
            +
                }
         
     | 
| 
      
 1541 
     | 
    
         
            +
             
     | 
| 
      
 1542 
     | 
    
         
            +
                somg12 = 2;
         
     | 
| 
      
 1543 
     | 
    
         
            +
                if (!meridian &&
         
     | 
| 
      
 1544 
     | 
    
         
            +
                    sbet1 === 0 &&           // and sbet2 == 0
         
     | 
| 
      
 1545 
     | 
    
         
            +
                    (this.f <= 0 || lon12s >= this.f * 180)) {
         
     | 
| 
      
 1546 
     | 
    
         
            +
             
     | 
| 
      
 1547 
     | 
    
         
            +
                  // Geodesic runs along equator
         
     | 
| 
      
 1548 
     | 
    
         
            +
                  calp1 = calp2 = 0; salp1 = salp2 = 1;
         
     | 
| 
      
 1549 
     | 
    
         
            +
                  s12x = this.a * lam12;
         
     | 
| 
      
 1550 
     | 
    
         
            +
                  sig12 = omg12 = lam12 / this._f1;
         
     | 
| 
      
 1551 
     | 
    
         
            +
                  m12x = this._b * Math.sin(sig12);
         
     | 
| 
      
 1552 
     | 
    
         
            +
                  if (outmask & g.GEODESICSCALE)
         
     | 
| 
      
 1553 
     | 
    
         
            +
                    vals.M12 = vals.M21 = Math.cos(sig12);
         
     | 
| 
      
 1554 
     | 
    
         
            +
                  vals.a12 = lon12 / this._f1;
         
     | 
| 
      
 1555 
     | 
    
         
            +
             
     | 
| 
      
 1556 
     | 
    
         
            +
                } else if (!meridian) {
         
     | 
| 
      
 1557 
     | 
    
         
            +
             
     | 
| 
      
 1558 
     | 
    
         
            +
                  // Now point1 and point2 belong within a hemisphere bounded by a
         
     | 
| 
      
 1559 
     | 
    
         
            +
                  // meridian and geodesic is neither meridional or equatorial.
         
     | 
| 
      
 1560 
     | 
    
         
            +
             
     | 
| 
      
 1561 
     | 
    
         
            +
                  // Figure a starting point for Newton's method
         
     | 
| 
      
 1562 
     | 
    
         
            +
                  nvals = this.InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
         
     | 
| 
      
 1563 
     | 
    
         
            +
                                            lam12, slam12, clam12, C1a, C2a);
         
     | 
| 
      
 1564 
     | 
    
         
            +
                  sig12 = nvals.sig12;
         
     | 
| 
      
 1565 
     | 
    
         
            +
                  salp1 = nvals.salp1;
         
     | 
| 
      
 1566 
     | 
    
         
            +
                  calp1 = nvals.calp1;
         
     | 
| 
      
 1567 
     | 
    
         
            +
             
     | 
| 
      
 1568 
     | 
    
         
            +
                  if (sig12 >= 0) {
         
     | 
| 
      
 1569 
     | 
    
         
            +
                    salp2 = nvals.salp2;
         
     | 
| 
      
 1570 
     | 
    
         
            +
                    calp2 = nvals.calp2;
         
     | 
| 
      
 1571 
     | 
    
         
            +
                    // Short lines (InverseStart sets salp2, calp2, dnm)
         
     | 
| 
      
 1572 
     | 
    
         
            +
             
     | 
| 
      
 1573 
     | 
    
         
            +
                    dnm = nvals.dnm;
         
     | 
| 
      
 1574 
     | 
    
         
            +
                    s12x = sig12 * this._b * dnm;
         
     | 
| 
      
 1575 
     | 
    
         
            +
                    m12x = m.sq(dnm) * this._b * Math.sin(sig12 / dnm);
         
     | 
| 
      
 1576 
     | 
    
         
            +
                    if (outmask & g.GEODESICSCALE)
         
     | 
| 
      
 1577 
     | 
    
         
            +
                      vals.M12 = vals.M21 = Math.cos(sig12 / dnm);
         
     | 
| 
      
 1578 
     | 
    
         
            +
                    vals.a12 = sig12 / m.degree;
         
     | 
| 
      
 1579 
     | 
    
         
            +
                    omg12 = lam12 / (this._f1 * dnm);
         
     | 
| 
      
 1580 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 1581 
     | 
    
         
            +
             
     | 
| 
      
 1582 
     | 
    
         
            +
                    // Newton's method.  This is a straightforward solution of f(alp1) =
         
     | 
| 
      
 1583 
     | 
    
         
            +
                    // lambda12(alp1) - lam12 = 0 with one wrinkle.  f(alp) has exactly one
         
     | 
| 
      
 1584 
     | 
    
         
            +
                    // root in the interval (0, pi) and its derivative is positive at the
         
     | 
| 
      
 1585 
     | 
    
         
            +
                    // root.  Thus f(alp) is positive for alp > alp1 and negative for alp <
         
     | 
| 
      
 1586 
     | 
    
         
            +
                    // alp1.  During the course of the iteration, a range (alp1a, alp1b) is
         
     | 
| 
      
 1587 
     | 
    
         
            +
                    // maintained which brackets the root and with each evaluation of
         
     | 
| 
      
 1588 
     | 
    
         
            +
                    // f(alp) the range is shrunk if possible.  Newton's method is
         
     | 
| 
      
 1589 
     | 
    
         
            +
                    // restarted whenever the derivative of f is negative (because the new
         
     | 
| 
      
 1590 
     | 
    
         
            +
                    // value of alp1 is then further from the solution) or if the new
         
     | 
| 
      
 1591 
     | 
    
         
            +
                    // estimate of alp1 lies outside (0,pi); in this case, the new starting
         
     | 
| 
      
 1592 
     | 
    
         
            +
                    // guess is taken to be (alp1a + alp1b) / 2.
         
     | 
| 
      
 1593 
     | 
    
         
            +
                    numit = 0;
         
     | 
| 
      
 1594 
     | 
    
         
            +
                    // Bracketing range
         
     | 
| 
      
 1595 
     | 
    
         
            +
                    salp1a = g.tiny_; calp1a = 1; salp1b = g.tiny_; calp1b = -1;
         
     | 
| 
      
 1596 
     | 
    
         
            +
                    for (tripn = false, tripb = false; numit < maxit2_; ++numit) {
         
     | 
| 
      
 1597 
     | 
    
         
            +
                      // the WGS84 test set: mean = 1.47, sd = 1.25, max = 16
         
     | 
| 
      
 1598 
     | 
    
         
            +
                      // WGS84 and random input: mean = 2.85, sd = 0.60
         
     | 
| 
      
 1599 
     | 
    
         
            +
                      nvals = this.Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2,
         
     | 
| 
      
 1600 
     | 
    
         
            +
                                            salp1, calp1, slam12, clam12, numit < maxit1_,
         
     | 
| 
      
 1601 
     | 
    
         
            +
                                            C1a, C2a, C3a);
         
     | 
| 
      
 1602 
     | 
    
         
            +
                      v = nvals.lam12;
         
     | 
| 
      
 1603 
     | 
    
         
            +
                      salp2 = nvals.salp2;
         
     | 
| 
      
 1604 
     | 
    
         
            +
                      calp2 = nvals.calp2;
         
     | 
| 
      
 1605 
     | 
    
         
            +
                      sig12 = nvals.sig12;
         
     | 
| 
      
 1606 
     | 
    
         
            +
                      ssig1 = nvals.ssig1;
         
     | 
| 
      
 1607 
     | 
    
         
            +
                      csig1 = nvals.csig1;
         
     | 
| 
      
 1608 
     | 
    
         
            +
                      ssig2 = nvals.ssig2;
         
     | 
| 
      
 1609 
     | 
    
         
            +
                      csig2 = nvals.csig2;
         
     | 
| 
      
 1610 
     | 
    
         
            +
                      eps = nvals.eps;
         
     | 
| 
      
 1611 
     | 
    
         
            +
                      domg12 = nvals.domg12;
         
     | 
| 
      
 1612 
     | 
    
         
            +
                      dv = nvals.dlam12;
         
     | 
| 
      
 1613 
     | 
    
         
            +
             
     | 
| 
      
 1614 
     | 
    
         
            +
                      // 2 * tol0 is approximately 1 ulp for a number in [0, pi].
         
     | 
| 
      
 1615 
     | 
    
         
            +
                      // Reversed test to allow escape with NaNs
         
     | 
| 
      
 1616 
     | 
    
         
            +
                      if (tripb || !(Math.abs(v) >= (tripn ? 8 : 1) * tol0_))
         
     | 
| 
      
 1617 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 1618 
     | 
    
         
            +
                      // Update bracketing values
         
     | 
| 
      
 1619 
     | 
    
         
            +
                      if (v > 0 && (numit < maxit1_ || calp1/salp1 > calp1b/salp1b)) {
         
     | 
| 
      
 1620 
     | 
    
         
            +
                        salp1b = salp1; calp1b = calp1;
         
     | 
| 
      
 1621 
     | 
    
         
            +
                      } else if (v < 0 &&
         
     | 
| 
      
 1622 
     | 
    
         
            +
                                 (numit < maxit1_ || calp1/salp1 < calp1a/salp1a)) {
         
     | 
| 
      
 1623 
     | 
    
         
            +
                        salp1a = salp1; calp1a = calp1;
         
     | 
| 
      
 1624 
     | 
    
         
            +
                      }
         
     | 
| 
      
 1625 
     | 
    
         
            +
                      if (numit < maxit1_ && dv > 0) {
         
     | 
| 
      
 1626 
     | 
    
         
            +
                        dalp1 = -v/dv;
         
     | 
| 
      
 1627 
     | 
    
         
            +
                        sdalp1 = Math.sin(dalp1); cdalp1 = Math.cos(dalp1);
         
     | 
| 
      
 1628 
     | 
    
         
            +
                        nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
         
     | 
| 
      
 1629 
     | 
    
         
            +
                        if (nsalp1 > 0 && Math.abs(dalp1) < Math.PI) {
         
     | 
| 
      
 1630 
     | 
    
         
            +
                          calp1 = calp1 * cdalp1 - salp1 * sdalp1;
         
     | 
| 
      
 1631 
     | 
    
         
            +
                          salp1 = nsalp1;
         
     | 
| 
      
 1632 
     | 
    
         
            +
                          // norm(salp1, calp1);
         
     | 
| 
      
 1633 
     | 
    
         
            +
                          t = m.hypot(salp1, calp1); salp1 /= t; calp1 /= t;
         
     | 
| 
      
 1634 
     | 
    
         
            +
                          // In some regimes we don't get quadratic convergence because
         
     | 
| 
      
 1635 
     | 
    
         
            +
                          // slope -> 0.  So use convergence conditions based on epsilon
         
     | 
| 
      
 1636 
     | 
    
         
            +
                          // instead of sqrt(epsilon).
         
     | 
| 
      
 1637 
     | 
    
         
            +
                          tripn = Math.abs(v) <= 16 * tol0_;
         
     | 
| 
      
 1638 
     | 
    
         
            +
                          continue;
         
     | 
| 
      
 1639 
     | 
    
         
            +
                        }
         
     | 
| 
      
 1640 
     | 
    
         
            +
                      }
         
     | 
| 
      
 1641 
     | 
    
         
            +
                      // Either dv was not positive or updated value was outside legal
         
     | 
| 
      
 1642 
     | 
    
         
            +
                      // range.  Use the midpoint of the bracket as the next estimate.
         
     | 
| 
      
 1643 
     | 
    
         
            +
                      // This mechanism is not needed for the WGS84 ellipsoid, but it does
         
     | 
| 
      
 1644 
     | 
    
         
            +
                      // catch problems with more eccentric ellipsoids.  Its efficacy is
         
     | 
| 
      
 1645 
     | 
    
         
            +
                      // such for the WGS84 test set with the starting guess set to alp1 =
         
     | 
| 
      
 1646 
     | 
    
         
            +
                      // 90deg:
         
     | 
| 
      
 1647 
     | 
    
         
            +
                      // the WGS84 test set: mean = 5.21, sd = 3.93, max = 24
         
     | 
| 
      
 1648 
     | 
    
         
            +
                      // WGS84 and random input: mean = 4.74, sd = 0.99
         
     | 
| 
      
 1649 
     | 
    
         
            +
                      salp1 = (salp1a + salp1b)/2;
         
     | 
| 
      
 1650 
     | 
    
         
            +
                      calp1 = (calp1a + calp1b)/2;
         
     | 
| 
      
 1651 
     | 
    
         
            +
                      // norm(salp1, calp1);
         
     | 
| 
      
 1652 
     | 
    
         
            +
                      t = m.hypot(salp1, calp1); salp1 /= t; calp1 /= t;
         
     | 
| 
      
 1653 
     | 
    
         
            +
                      tripn = false;
         
     | 
| 
      
 1654 
     | 
    
         
            +
                      tripb = (Math.abs(salp1a - salp1) + (calp1a - calp1) < tolb_ ||
         
     | 
| 
      
 1655 
     | 
    
         
            +
                               Math.abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_);
         
     | 
| 
      
 1656 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1657 
     | 
    
         
            +
                    lengthmask = outmask |
         
     | 
| 
      
 1658 
     | 
    
         
            +
                        (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE) ?
         
     | 
| 
      
 1659 
     | 
    
         
            +
                         g.DISTANCE : g.NONE);
         
     | 
| 
      
 1660 
     | 
    
         
            +
                    nvals = this.Lengths(eps, sig12,
         
     | 
| 
      
 1661 
     | 
    
         
            +
                                         ssig1, csig1, dn1, ssig2, csig2, dn2,
         
     | 
| 
      
 1662 
     | 
    
         
            +
                                         cbet1, cbet2,
         
     | 
| 
      
 1663 
     | 
    
         
            +
                                         lengthmask, C1a, C2a);
         
     | 
| 
      
 1664 
     | 
    
         
            +
                    s12x = nvals.s12b;
         
     | 
| 
      
 1665 
     | 
    
         
            +
                    m12x = nvals.m12b;
         
     | 
| 
      
 1666 
     | 
    
         
            +
                    // Ignore m0
         
     | 
| 
      
 1667 
     | 
    
         
            +
                    if (outmask & g.GEODESICSCALE) {
         
     | 
| 
      
 1668 
     | 
    
         
            +
                      vals.M12 = nvals.M12;
         
     | 
| 
      
 1669 
     | 
    
         
            +
                      vals.M21 = nvals.M21;
         
     | 
| 
      
 1670 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1671 
     | 
    
         
            +
                    m12x *= this._b;
         
     | 
| 
      
 1672 
     | 
    
         
            +
                    s12x *= this._b;
         
     | 
| 
      
 1673 
     | 
    
         
            +
                    vals.a12 = sig12 / m.degree;
         
     | 
| 
      
 1674 
     | 
    
         
            +
                    if (outmask & g.AREA) {
         
     | 
| 
      
 1675 
     | 
    
         
            +
                      // omg12 = lam12 - domg12
         
     | 
| 
      
 1676 
     | 
    
         
            +
                      sdomg12 = Math.sin(domg12); cdomg12 = Math.cos(domg12);
         
     | 
| 
      
 1677 
     | 
    
         
            +
                      somg12 = slam12 * cdomg12 - clam12 * sdomg12;
         
     | 
| 
      
 1678 
     | 
    
         
            +
                      comg12 = clam12 * cdomg12 + slam12 * sdomg12;
         
     | 
| 
      
 1679 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1680 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1681 
     | 
    
         
            +
                }
         
     | 
| 
      
 1682 
     | 
    
         
            +
             
     | 
| 
      
 1683 
     | 
    
         
            +
                if (outmask & g.DISTANCE)
         
     | 
| 
      
 1684 
     | 
    
         
            +
                  vals.s12 = 0 + s12x;      // Convert -0 to 0
         
     | 
| 
      
 1685 
     | 
    
         
            +
             
     | 
| 
      
 1686 
     | 
    
         
            +
                if (outmask & g.REDUCEDLENGTH)
         
     | 
| 
      
 1687 
     | 
    
         
            +
                  vals.m12 = 0 + m12x;      // Convert -0 to 0
         
     | 
| 
      
 1688 
     | 
    
         
            +
             
     | 
| 
      
 1689 
     | 
    
         
            +
                if (outmask & g.AREA) {
         
     | 
| 
      
 1690 
     | 
    
         
            +
                  // From Lambda12: sin(alp1) * cos(bet1) = sin(alp0)
         
     | 
| 
      
 1691 
     | 
    
         
            +
                  salp0 = salp1 * cbet1;
         
     | 
| 
      
 1692 
     | 
    
         
            +
                  calp0 = m.hypot(calp1, salp1 * sbet1); // calp0 > 0
         
     | 
| 
      
 1693 
     | 
    
         
            +
                  if (calp0 !== 0 && salp0 !== 0) {
         
     | 
| 
      
 1694 
     | 
    
         
            +
                    // From Lambda12: tan(bet) = tan(sig) * cos(alp)
         
     | 
| 
      
 1695 
     | 
    
         
            +
                    ssig1 = sbet1; csig1 = calp1 * cbet1;
         
     | 
| 
      
 1696 
     | 
    
         
            +
                    ssig2 = sbet2; csig2 = calp2 * cbet2;
         
     | 
| 
      
 1697 
     | 
    
         
            +
                    k2 = m.sq(calp0) * this._ep2;
         
     | 
| 
      
 1698 
     | 
    
         
            +
                    eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
         
     | 
| 
      
 1699 
     | 
    
         
            +
                    // Multiplier = a^2 * e^2 * cos(alpha0) * sin(alpha0).
         
     | 
| 
      
 1700 
     | 
    
         
            +
                    A4 = m.sq(this.a) * calp0 * salp0 * this._e2;
         
     | 
| 
      
 1701 
     | 
    
         
            +
                    // norm(ssig1, csig1);
         
     | 
| 
      
 1702 
     | 
    
         
            +
                    t = m.hypot(ssig1, csig1); ssig1 /= t; csig1 /= t;
         
     | 
| 
      
 1703 
     | 
    
         
            +
                    // norm(ssig2, csig2);
         
     | 
| 
      
 1704 
     | 
    
         
            +
                    t = m.hypot(ssig2, csig2); ssig2 /= t; csig2 /= t;
         
     | 
| 
      
 1705 
     | 
    
         
            +
                    C4a = new Array(g.nC4_);
         
     | 
| 
      
 1706 
     | 
    
         
            +
                    this.C4f(eps, C4a);
         
     | 
| 
      
 1707 
     | 
    
         
            +
                    B41 = g.SinCosSeries(false, ssig1, csig1, C4a);
         
     | 
| 
      
 1708 
     | 
    
         
            +
                    B42 = g.SinCosSeries(false, ssig2, csig2, C4a);
         
     | 
| 
      
 1709 
     | 
    
         
            +
                    vals.S12 = A4 * (B42 - B41);
         
     | 
| 
      
 1710 
     | 
    
         
            +
                  } else
         
     | 
| 
      
 1711 
     | 
    
         
            +
                    // Avoid problems with indeterminate sig1, sig2 on equator
         
     | 
| 
      
 1712 
     | 
    
         
            +
                    vals.S12 = 0;
         
     | 
| 
      
 1713 
     | 
    
         
            +
                  if (!meridian && somg12 > 1) {
         
     | 
| 
      
 1714 
     | 
    
         
            +
                    somg12 = Math.sin(omg12); comg12 = Math.cos(omg12);
         
     | 
| 
      
 1715 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1716 
     | 
    
         
            +
                  if (!meridian &&
         
     | 
| 
      
 1717 
     | 
    
         
            +
                      comg12 > -0.7071 &&      // Long difference not too big
         
     | 
| 
      
 1718 
     | 
    
         
            +
                      sbet2 - sbet1 < 1.75) { // Lat difference not too big
         
     | 
| 
      
 1719 
     | 
    
         
            +
                    // Use tan(Gamma/2) = tan(omg12/2)
         
     | 
| 
      
 1720 
     | 
    
         
            +
                    // * (tan(bet1/2)+tan(bet2/2))/(1+tan(bet1/2)*tan(bet2/2))
         
     | 
| 
      
 1721 
     | 
    
         
            +
                    // with tan(x/2) = sin(x)/(1+cos(x))
         
     | 
| 
      
 1722 
     | 
    
         
            +
                    domg12 = 1 + comg12; dbet1 = 1 + cbet1; dbet2 = 1 + cbet2;
         
     | 
| 
      
 1723 
     | 
    
         
            +
                    alp12 = 2 * Math.atan2( somg12 * (sbet1*dbet2 + sbet2*dbet1),
         
     | 
| 
      
 1724 
     | 
    
         
            +
                                            domg12 * (sbet1*sbet2 + dbet1*dbet2) );
         
     | 
| 
      
 1725 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 1726 
     | 
    
         
            +
                    // alp12 = alp2 - alp1, used in atan2 so no need to normalize
         
     | 
| 
      
 1727 
     | 
    
         
            +
                    salp12 = salp2 * calp1 - calp2 * salp1;
         
     | 
| 
      
 1728 
     | 
    
         
            +
                    calp12 = calp2 * calp1 + salp2 * salp1;
         
     | 
| 
      
 1729 
     | 
    
         
            +
                    // The right thing appears to happen if alp1 = +/-180 and alp2 = 0, viz
         
     | 
| 
      
 1730 
     | 
    
         
            +
                    // salp12 = -0 and alp12 = -180.  However this depends on the sign
         
     | 
| 
      
 1731 
     | 
    
         
            +
                    // being attached to 0 correctly.  The following ensures the correct
         
     | 
| 
      
 1732 
     | 
    
         
            +
                    // behavior.
         
     | 
| 
      
 1733 
     | 
    
         
            +
                    if (salp12 === 0 && calp12 < 0) {
         
     | 
| 
      
 1734 
     | 
    
         
            +
                      salp12 = g.tiny_ * calp1;
         
     | 
| 
      
 1735 
     | 
    
         
            +
                      calp12 = -1;
         
     | 
| 
      
 1736 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1737 
     | 
    
         
            +
                    alp12 = Math.atan2(salp12, calp12);
         
     | 
| 
      
 1738 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1739 
     | 
    
         
            +
                  vals.S12 += this._c2 * alp12;
         
     | 
| 
      
 1740 
     | 
    
         
            +
                  vals.S12 *= swapp * lonsign * latsign;
         
     | 
| 
      
 1741 
     | 
    
         
            +
                  // Convert -0 to 0
         
     | 
| 
      
 1742 
     | 
    
         
            +
                  vals.S12 += 0;
         
     | 
| 
      
 1743 
     | 
    
         
            +
                }
         
     | 
| 
      
 1744 
     | 
    
         
            +
             
     | 
| 
      
 1745 
     | 
    
         
            +
                // Convert calp, salp to azimuth accounting for lonsign, swapp, latsign.
         
     | 
| 
      
 1746 
     | 
    
         
            +
                if (swapp < 0) {
         
     | 
| 
      
 1747 
     | 
    
         
            +
                  t = salp1;
         
     | 
| 
      
 1748 
     | 
    
         
            +
                  salp1 = salp2;
         
     | 
| 
      
 1749 
     | 
    
         
            +
                  salp2 = t;
         
     | 
| 
      
 1750 
     | 
    
         
            +
                  // swap(salp1, salp2);
         
     | 
| 
      
 1751 
     | 
    
         
            +
                  t = calp1;
         
     | 
| 
      
 1752 
     | 
    
         
            +
                  calp1 = calp2;
         
     | 
| 
      
 1753 
     | 
    
         
            +
                  calp2 = t;
         
     | 
| 
      
 1754 
     | 
    
         
            +
                  // swap(calp1, calp2);
         
     | 
| 
      
 1755 
     | 
    
         
            +
                  if (outmask & g.GEODESICSCALE) {
         
     | 
| 
      
 1756 
     | 
    
         
            +
                    t = vals.M12;
         
     | 
| 
      
 1757 
     | 
    
         
            +
                    vals.M12 = vals.M21;
         
     | 
| 
      
 1758 
     | 
    
         
            +
                    vals.M21 = t;
         
     | 
| 
      
 1759 
     | 
    
         
            +
                    // swap(vals.M12, vals.M21);
         
     | 
| 
      
 1760 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1761 
     | 
    
         
            +
                }
         
     | 
| 
      
 1762 
     | 
    
         
            +
             
     | 
| 
      
 1763 
     | 
    
         
            +
                salp1 *= swapp * lonsign; calp1 *= swapp * latsign;
         
     | 
| 
      
 1764 
     | 
    
         
            +
                salp2 *= swapp * lonsign; calp2 *= swapp * latsign;
         
     | 
| 
      
 1765 
     | 
    
         
            +
             
     | 
| 
      
 1766 
     | 
    
         
            +
                return {vals: vals,
         
     | 
| 
      
 1767 
     | 
    
         
            +
                        salp1: salp1, calp1: calp1,
         
     | 
| 
      
 1768 
     | 
    
         
            +
                        salp2: salp2, calp2: calp2};
         
     | 
| 
      
 1769 
     | 
    
         
            +
              };
         
     | 
| 
      
 1770 
     | 
    
         
            +
             
     | 
| 
      
 1771 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1772 
     | 
    
         
            +
               * @summary Solve the general direct geodesic problem.
         
     | 
| 
      
 1773 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1774 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1775 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1776 
     | 
    
         
            +
               * @param {bool} arcmode is the next parameter an arc length?
         
     | 
| 
      
 1777 
     | 
    
         
            +
               * @param {number} s12_a12 the (arcmode ? arc length : distance) from the
         
     | 
| 
      
 1778 
     | 
    
         
            +
               *   first point to the second in (arcmode ? degrees : meters).
         
     | 
| 
      
 1779 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include.
         
     | 
| 
      
 1780 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 1781 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, and a12 fields of the result are always
         
     | 
| 
      
 1782 
     | 
    
         
            +
               *   set; s12 is included if arcmode is false.  For details on the outmask
         
     | 
| 
      
 1783 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 1784 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 1785 
     | 
    
         
            +
               */
         
     | 
| 
      
 1786 
     | 
    
         
            +
              g.Geodesic.prototype.GenDirect = function(lat1, lon1, azi1,
         
     | 
| 
      
 1787 
     | 
    
         
            +
                                                        arcmode, s12_a12, outmask) {
         
     | 
| 
      
 1788 
     | 
    
         
            +
                var line;
         
     | 
| 
      
 1789 
     | 
    
         
            +
                if (!outmask) outmask = g.STANDARD;
         
     | 
| 
      
 1790 
     | 
    
         
            +
                else if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
         
     | 
| 
      
 1791 
     | 
    
         
            +
                // Automatically supply DISTANCE_IN if necessary
         
     | 
| 
      
 1792 
     | 
    
         
            +
                if (!arcmode) outmask |= g.DISTANCE_IN;
         
     | 
| 
      
 1793 
     | 
    
         
            +
                line = new l.GeodesicLine(this, lat1, lon1, azi1, outmask);
         
     | 
| 
      
 1794 
     | 
    
         
            +
                return line.GenPosition(arcmode, s12_a12, outmask);
         
     | 
| 
      
 1795 
     | 
    
         
            +
              };
         
     | 
| 
      
 1796 
     | 
    
         
            +
             
     | 
| 
      
 1797 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1798 
     | 
    
         
            +
               * @summary Solve the direct geodesic problem.
         
     | 
| 
      
 1799 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1800 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1801 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1802 
     | 
    
         
            +
               * @param {number} s12 the distance from the first point to the second in
         
     | 
| 
      
 1803 
     | 
    
         
            +
               *   meters.
         
     | 
| 
      
 1804 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include.
         
     | 
| 
      
 1805 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 1806 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, s12, and a12 fields of the result are
         
     | 
| 
      
 1807 
     | 
    
         
            +
               *   always set.  For details on the outmask parameter, see {@tutorial
         
     | 
| 
      
 1808 
     | 
    
         
            +
               *   2-interface}, "The outmask and caps parameters".
         
     | 
| 
      
 1809 
     | 
    
         
            +
               */
         
     | 
| 
      
 1810 
     | 
    
         
            +
              g.Geodesic.prototype.Direct = function(lat1, lon1, azi1, s12, outmask) {
         
     | 
| 
      
 1811 
     | 
    
         
            +
                return this.GenDirect(lat1, lon1, azi1, false, s12, outmask);
         
     | 
| 
      
 1812 
     | 
    
         
            +
              };
         
     | 
| 
      
 1813 
     | 
    
         
            +
             
     | 
| 
      
 1814 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1815 
     | 
    
         
            +
               * @summary Solve the direct geodesic problem with arc length.
         
     | 
| 
      
 1816 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1817 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1818 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1819 
     | 
    
         
            +
               * @param {number} a12 the arc length from the first point to the second in
         
     | 
| 
      
 1820 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 1821 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include.
         
     | 
| 
      
 1822 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 1823 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, and a12 fields of the result are
         
     | 
| 
      
 1824 
     | 
    
         
            +
               *   always set.  For details on the outmask parameter, see {@tutorial
         
     | 
| 
      
 1825 
     | 
    
         
            +
               *   2-interface}, "The outmask and caps parameters".
         
     | 
| 
      
 1826 
     | 
    
         
            +
               */
         
     | 
| 
      
 1827 
     | 
    
         
            +
              g.Geodesic.prototype.ArcDirect = function(lat1, lon1, azi1, a12, outmask) {
         
     | 
| 
      
 1828 
     | 
    
         
            +
                return this.GenDirect(lat1, lon1, azi1, true, a12, outmask);
         
     | 
| 
      
 1829 
     | 
    
         
            +
              };
         
     | 
| 
      
 1830 
     | 
    
         
            +
             
     | 
| 
      
 1831 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1832 
     | 
    
         
            +
               * @summary Create a {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1833 
     | 
    
         
            +
               *   GeodesicLine} object.
         
     | 
| 
      
 1834 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1835 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1836 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1837 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 1838 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 1839 
     | 
    
         
            +
               *   include.
         
     | 
| 
      
 1840 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1841 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1842 
     | 
    
         
            +
               *   GeodesicLine} object
         
     | 
| 
      
 1843 
     | 
    
         
            +
               * @description For details on the caps parameter, see {@tutorial
         
     | 
| 
      
 1844 
     | 
    
         
            +
               *   2-interface}, "The outmask and caps parameters".
         
     | 
| 
      
 1845 
     | 
    
         
            +
               */
         
     | 
| 
      
 1846 
     | 
    
         
            +
              g.Geodesic.prototype.Line = function(lat1, lon1, azi1, caps) {
         
     | 
| 
      
 1847 
     | 
    
         
            +
                return new l.GeodesicLine(this, lat1, lon1, azi1, caps);
         
     | 
| 
      
 1848 
     | 
    
         
            +
              };
         
     | 
| 
      
 1849 
     | 
    
         
            +
             
     | 
| 
      
 1850 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1851 
     | 
    
         
            +
               * @summary Define a {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1852 
     | 
    
         
            +
               *   GeodesicLine} in terms of the direct geodesic problem specified in terms
         
     | 
| 
      
 1853 
     | 
    
         
            +
               *   of distance.
         
     | 
| 
      
 1854 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1855 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1856 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1857 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 1858 
     | 
    
         
            +
               * @param {number} s12 the distance between point 1 and point 2 (meters); it
         
     | 
| 
      
 1859 
     | 
    
         
            +
               *   can be negative.
         
     | 
| 
      
 1860 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 1861 
     | 
    
         
            +
               *   include.
         
     | 
| 
      
 1862 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1863 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1864 
     | 
    
         
            +
               *   GeodesicLine} object
         
     | 
| 
      
 1865 
     | 
    
         
            +
               * @description This function sets point 3 of the GeodesicLine to correspond
         
     | 
| 
      
 1866 
     | 
    
         
            +
               *   to point 2 of the direct geodesic problem.  For details on the caps
         
     | 
| 
      
 1867 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 1868 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 1869 
     | 
    
         
            +
               */
         
     | 
| 
      
 1870 
     | 
    
         
            +
              g.Geodesic.prototype.DirectLine = function(lat1, lon1, azi1, s12, caps) {
         
     | 
| 
      
 1871 
     | 
    
         
            +
                return this.GenDirectLine(lat1, lon1, azi1, false, s12, caps);
         
     | 
| 
      
 1872 
     | 
    
         
            +
              };
         
     | 
| 
      
 1873 
     | 
    
         
            +
             
     | 
| 
      
 1874 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1875 
     | 
    
         
            +
               * @summary Define a {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1876 
     | 
    
         
            +
               *   GeodesicLine} in terms of the direct geodesic problem specified in terms
         
     | 
| 
      
 1877 
     | 
    
         
            +
               *   of arc length.
         
     | 
| 
      
 1878 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1879 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1880 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1881 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 1882 
     | 
    
         
            +
               * @param {number} a12 the arc length between point 1 and point 2 (degrees);
         
     | 
| 
      
 1883 
     | 
    
         
            +
               *   it can be negative.
         
     | 
| 
      
 1884 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 1885 
     | 
    
         
            +
               *   include.
         
     | 
| 
      
 1886 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1887 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1888 
     | 
    
         
            +
               *   GeodesicLine} object
         
     | 
| 
      
 1889 
     | 
    
         
            +
               * @description This function sets point 3 of the GeodesicLine to correspond
         
     | 
| 
      
 1890 
     | 
    
         
            +
               *   to point 2 of the direct geodesic problem.  For details on the caps
         
     | 
| 
      
 1891 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 1892 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 1893 
     | 
    
         
            +
               */
         
     | 
| 
      
 1894 
     | 
    
         
            +
              g.Geodesic.prototype.ArcDirectLine = function(lat1, lon1, azi1, a12, caps) {
         
     | 
| 
      
 1895 
     | 
    
         
            +
                return this.GenDirectLine(lat1, lon1, azi1, true, a12, caps);
         
     | 
| 
      
 1896 
     | 
    
         
            +
              };
         
     | 
| 
      
 1897 
     | 
    
         
            +
             
     | 
| 
      
 1898 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1899 
     | 
    
         
            +
               * @summary Define a {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1900 
     | 
    
         
            +
               *   GeodesicLine} in terms of the direct geodesic problem specified in terms
         
     | 
| 
      
 1901 
     | 
    
         
            +
               *   of either distance or arc length.
         
     | 
| 
      
 1902 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1903 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1904 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 1905 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 1906 
     | 
    
         
            +
               * @param {bool} arcmode boolean flag determining the meaning of the
         
     | 
| 
      
 1907 
     | 
    
         
            +
               *   s12_a12.
         
     | 
| 
      
 1908 
     | 
    
         
            +
               * @param {number} s12_a12 if arcmode is false, this is the distance between
         
     | 
| 
      
 1909 
     | 
    
         
            +
               *   point 1 and point 2 (meters); otherwise it is the arc length between
         
     | 
| 
      
 1910 
     | 
    
         
            +
               *   point 1 and point 2 (degrees); it can be negative.
         
     | 
| 
      
 1911 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 1912 
     | 
    
         
            +
               *   include.
         
     | 
| 
      
 1913 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1914 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1915 
     | 
    
         
            +
               *   GeodesicLine} object
         
     | 
| 
      
 1916 
     | 
    
         
            +
               * @description This function sets point 3 of the GeodesicLine to correspond
         
     | 
| 
      
 1917 
     | 
    
         
            +
               *   to point 2 of the direct geodesic problem.  For details on the caps
         
     | 
| 
      
 1918 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 1919 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 1920 
     | 
    
         
            +
               */
         
     | 
| 
      
 1921 
     | 
    
         
            +
              g.Geodesic.prototype.GenDirectLine = function(lat1, lon1, azi1,
         
     | 
| 
      
 1922 
     | 
    
         
            +
                                                            arcmode, s12_a12, caps) {
         
     | 
| 
      
 1923 
     | 
    
         
            +
                var t;
         
     | 
| 
      
 1924 
     | 
    
         
            +
                if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
         
     | 
| 
      
 1925 
     | 
    
         
            +
                // Automatically supply DISTANCE_IN if necessary
         
     | 
| 
      
 1926 
     | 
    
         
            +
                if (!arcmode) caps |= g.DISTANCE_IN;
         
     | 
| 
      
 1927 
     | 
    
         
            +
                t = new l.GeodesicLine(this, lat1, lon1, azi1, caps);
         
     | 
| 
      
 1928 
     | 
    
         
            +
                t.GenSetDistance(arcmode, s12_a12);
         
     | 
| 
      
 1929 
     | 
    
         
            +
                return t;
         
     | 
| 
      
 1930 
     | 
    
         
            +
              };
         
     | 
| 
      
 1931 
     | 
    
         
            +
             
     | 
| 
      
 1932 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1933 
     | 
    
         
            +
               * @summary Define a {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1934 
     | 
    
         
            +
               *   GeodesicLine} in terms of the inverse geodesic problem.
         
     | 
| 
      
 1935 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 1936 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 1937 
     | 
    
         
            +
               * @param {number} lat2 the latitude of the second point in degrees.
         
     | 
| 
      
 1938 
     | 
    
         
            +
               * @param {number} lon2 the longitude of the second point in degrees.
         
     | 
| 
      
 1939 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 1940 
     | 
    
         
            +
               *   include.
         
     | 
| 
      
 1941 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1942 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine
         
     | 
| 
      
 1943 
     | 
    
         
            +
               *   GeodesicLine} object
         
     | 
| 
      
 1944 
     | 
    
         
            +
               * @description This function sets point 3 of the GeodesicLine to correspond
         
     | 
| 
      
 1945 
     | 
    
         
            +
               *   to point 2 of the inverse geodesic problem.  For details on the caps
         
     | 
| 
      
 1946 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 1947 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 1948 
     | 
    
         
            +
               */
         
     | 
| 
      
 1949 
     | 
    
         
            +
              g.Geodesic.prototype.InverseLine = function(lat1, lon1, lat2, lon2, caps) {
         
     | 
| 
      
 1950 
     | 
    
         
            +
                var r, t, azi1;
         
     | 
| 
      
 1951 
     | 
    
         
            +
                if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
         
     | 
| 
      
 1952 
     | 
    
         
            +
                r = this.InverseInt(lat1, lon1, lat2, lon2, g.ARC);
         
     | 
| 
      
 1953 
     | 
    
         
            +
                azi1 = m.atan2d(r.salp1, r.calp1);
         
     | 
| 
      
 1954 
     | 
    
         
            +
                // Ensure that a12 can be converted to a distance
         
     | 
| 
      
 1955 
     | 
    
         
            +
                if (caps & (g.OUT_MASK & g.DISTANCE_IN)) caps |= g.DISTANCE;
         
     | 
| 
      
 1956 
     | 
    
         
            +
                t = new l.GeodesicLine(this, lat1, lon1, azi1, caps, r.salp1, r.calp1);
         
     | 
| 
      
 1957 
     | 
    
         
            +
                t.SetArc(r.vals.a12);
         
     | 
| 
      
 1958 
     | 
    
         
            +
                return t;
         
     | 
| 
      
 1959 
     | 
    
         
            +
              };
         
     | 
| 
      
 1960 
     | 
    
         
            +
             
     | 
| 
      
 1961 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1962 
     | 
    
         
            +
               * @summary Create a {@link module:GeographicLib/PolygonArea.PolygonArea
         
     | 
| 
      
 1963 
     | 
    
         
            +
               *   PolygonArea} object.
         
     | 
| 
      
 1964 
     | 
    
         
            +
               * @param {bool} [polyline = false] if true the new PolygonArea object
         
     | 
| 
      
 1965 
     | 
    
         
            +
               *   describes a polyline instead of a polygon.
         
     | 
| 
      
 1966 
     | 
    
         
            +
               * @returns {object} the
         
     | 
| 
      
 1967 
     | 
    
         
            +
               *   {@link module:GeographicLib/PolygonArea.PolygonArea
         
     | 
| 
      
 1968 
     | 
    
         
            +
               *   PolygonArea} object
         
     | 
| 
      
 1969 
     | 
    
         
            +
               */
         
     | 
| 
      
 1970 
     | 
    
         
            +
              g.Geodesic.prototype.Polygon = function(polyline) {
         
     | 
| 
      
 1971 
     | 
    
         
            +
                return new p.PolygonArea(this, polyline);
         
     | 
| 
      
 1972 
     | 
    
         
            +
              };
         
     | 
| 
      
 1973 
     | 
    
         
            +
             
     | 
| 
      
 1974 
     | 
    
         
            +
              /**
         
     | 
| 
      
 1975 
     | 
    
         
            +
               * @summary a {@link module:GeographicLib/Geodesic.Geodesic Geodesic} object
         
     | 
| 
      
 1976 
     | 
    
         
            +
               *   initialized for the WGS84 ellipsoid.
         
     | 
| 
      
 1977 
     | 
    
         
            +
               * @constant {object}
         
     | 
| 
      
 1978 
     | 
    
         
            +
               */
         
     | 
| 
      
 1979 
     | 
    
         
            +
              g.WGS84 = new g.Geodesic(c.WGS84.a, c.WGS84.f);
         
     | 
| 
      
 1980 
     | 
    
         
            +
            })(GeographicLib.Geodesic, GeographicLib.GeodesicLine,
         
     | 
| 
      
 1981 
     | 
    
         
            +
               GeographicLib.PolygonArea, GeographicLib.Math, GeographicLib.Constants);
         
     | 
| 
      
 1982 
     | 
    
         
            +
             
     | 
| 
      
 1983 
     | 
    
         
            +
            /**************** GeodesicLine.js ****************/
         
     | 
| 
      
 1984 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1985 
     | 
    
         
            +
             * GeodesicLine.js
         
     | 
| 
      
 1986 
     | 
    
         
            +
             * Transcription of GeodesicLine.[ch]pp into JavaScript.
         
     | 
| 
      
 1987 
     | 
    
         
            +
             *
         
     | 
| 
      
 1988 
     | 
    
         
            +
             * See the documentation for the C++ class.  The conversion is a literal
         
     | 
| 
      
 1989 
     | 
    
         
            +
             * conversion from C++.
         
     | 
| 
      
 1990 
     | 
    
         
            +
             *
         
     | 
| 
      
 1991 
     | 
    
         
            +
             * The algorithms are derived in
         
     | 
| 
      
 1992 
     | 
    
         
            +
             *
         
     | 
| 
      
 1993 
     | 
    
         
            +
             *    Charles F. F. Karney,
         
     | 
| 
      
 1994 
     | 
    
         
            +
             *    Algorithms for geodesics, J. Geodesy 87, 43-55 (2013);
         
     | 
| 
      
 1995 
     | 
    
         
            +
             *    https://doi.org/10.1007/s00190-012-0578-z
         
     | 
| 
      
 1996 
     | 
    
         
            +
             *    Addenda: https://geographiclib.sourceforge.io/geod-addenda.html
         
     | 
| 
      
 1997 
     | 
    
         
            +
             *
         
     | 
| 
      
 1998 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2016) <charles@karney.com> and licensed
         
     | 
| 
      
 1999 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 2000 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 2001 
     | 
    
         
            +
             */
         
     | 
| 
      
 2002 
     | 
    
         
            +
             
     | 
| 
      
 2003 
     | 
    
         
            +
            // Load AFTER GeographicLib/Math.js, GeographicLib/Geodesic.js
         
     | 
| 
      
 2004 
     | 
    
         
            +
             
     | 
| 
      
 2005 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 2006 
     | 
    
         
            +
              g,
         
     | 
| 
      
 2007 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2008 
     | 
    
         
            +
               * @exports GeographicLib/GeodesicLine
         
     | 
| 
      
 2009 
     | 
    
         
            +
               * @description Solve geodesic problems on a single geodesic line via the
         
     | 
| 
      
 2010 
     | 
    
         
            +
               *   {@link module:GeographicLib/GeodesicLine.GeodesicLine GeodesicLine}
         
     | 
| 
      
 2011 
     | 
    
         
            +
               *   class.
         
     | 
| 
      
 2012 
     | 
    
         
            +
               */
         
     | 
| 
      
 2013 
     | 
    
         
            +
              l, m) {
         
     | 
| 
      
 2014 
     | 
    
         
            +
             
     | 
| 
      
 2015 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2016 
     | 
    
         
            +
               * @class
         
     | 
| 
      
 2017 
     | 
    
         
            +
               * @property {number} a the equatorial radius (meters).
         
     | 
| 
      
 2018 
     | 
    
         
            +
               * @property {number} f the flattening.
         
     | 
| 
      
 2019 
     | 
    
         
            +
               * @property {number} lat1 the initial latitude (degrees).
         
     | 
| 
      
 2020 
     | 
    
         
            +
               * @property {number} lon1 the initial longitude (degrees).
         
     | 
| 
      
 2021 
     | 
    
         
            +
               * @property {number} azi1 the initial azimuth (degrees).
         
     | 
| 
      
 2022 
     | 
    
         
            +
               * @property {number} salp1 the sine of the azimuth at the first point.
         
     | 
| 
      
 2023 
     | 
    
         
            +
               * @property {number} calp1 the cosine the azimuth at the first point.
         
     | 
| 
      
 2024 
     | 
    
         
            +
               * @property {number} s13 the distance to point 3 (meters).
         
     | 
| 
      
 2025 
     | 
    
         
            +
               * @property {number} a13 the arc length to point 3 (degrees).
         
     | 
| 
      
 2026 
     | 
    
         
            +
               * @property {bitmask} caps the capabilities of the object.
         
     | 
| 
      
 2027 
     | 
    
         
            +
               * @summary Initialize a GeodesicLine object.  For details on the caps
         
     | 
| 
      
 2028 
     | 
    
         
            +
               *   parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 2029 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 2030 
     | 
    
         
            +
               * @classdesc Performs geodesic calculations along a given geodesic line.
         
     | 
| 
      
 2031 
     | 
    
         
            +
               *   This object is usually instantiated by
         
     | 
| 
      
 2032 
     | 
    
         
            +
               *   {@link module:GeographicLib/Geodesic.Geodesic#Line Geodesic.Line}.
         
     | 
| 
      
 2033 
     | 
    
         
            +
               *   The methods
         
     | 
| 
      
 2034 
     | 
    
         
            +
               *   {@link module:GeographicLib/Geodesic.Geodesic#DirectLine
         
     | 
| 
      
 2035 
     | 
    
         
            +
               *   Geodesic.DirectLine} and
         
     | 
| 
      
 2036 
     | 
    
         
            +
               *   {@link module:GeographicLib/Geodesic.Geodesic#InverseLine
         
     | 
| 
      
 2037 
     | 
    
         
            +
               *   Geodesic.InverseLine} set in addition the position of a reference point
         
     | 
| 
      
 2038 
     | 
    
         
            +
               *   3.
         
     | 
| 
      
 2039 
     | 
    
         
            +
               * @param {object} geod a {@link module:GeographicLib/Geodesic.Geodesic
         
     | 
| 
      
 2040 
     | 
    
         
            +
               *   Geodesic} object.
         
     | 
| 
      
 2041 
     | 
    
         
            +
               * @param {number} lat1 the latitude of the first point in degrees.
         
     | 
| 
      
 2042 
     | 
    
         
            +
               * @param {number} lon1 the longitude of the first point in degrees.
         
     | 
| 
      
 2043 
     | 
    
         
            +
               * @param {number} azi1 the azimuth at the first point in degrees.
         
     | 
| 
      
 2044 
     | 
    
         
            +
               * @param {bitmask} [caps = STANDARD | DISTANCE_IN] which capabilities to
         
     | 
| 
      
 2045 
     | 
    
         
            +
               *   include; LATITUDE | AZIMUTH are always included.
         
     | 
| 
      
 2046 
     | 
    
         
            +
               */
         
     | 
| 
      
 2047 
     | 
    
         
            +
              l.GeodesicLine = function(geod, lat1, lon1, azi1, caps, salp1, calp1) {
         
     | 
| 
      
 2048 
     | 
    
         
            +
                var t, cbet1, sbet1, eps, s, c;
         
     | 
| 
      
 2049 
     | 
    
         
            +
                if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
         
     | 
| 
      
 2050 
     | 
    
         
            +
             
     | 
| 
      
 2051 
     | 
    
         
            +
                this.a = geod.a;
         
     | 
| 
      
 2052 
     | 
    
         
            +
                this.f = geod.f;
         
     | 
| 
      
 2053 
     | 
    
         
            +
                this._b = geod._b;
         
     | 
| 
      
 2054 
     | 
    
         
            +
                this._c2 = geod._c2;
         
     | 
| 
      
 2055 
     | 
    
         
            +
                this._f1 = geod._f1;
         
     | 
| 
      
 2056 
     | 
    
         
            +
                this.caps = caps | g.LATITUDE | g.AZIMUTH | g.LONG_UNROLL;
         
     | 
| 
      
 2057 
     | 
    
         
            +
             
     | 
| 
      
 2058 
     | 
    
         
            +
                this.lat1 = m.LatFix(lat1);
         
     | 
| 
      
 2059 
     | 
    
         
            +
                this.lon1 = lon1;
         
     | 
| 
      
 2060 
     | 
    
         
            +
                if (typeof salp1 === 'undefined' || typeof calp1 === 'undefined') {
         
     | 
| 
      
 2061 
     | 
    
         
            +
                  this.azi1 = m.AngNormalize(azi1);
         
     | 
| 
      
 2062 
     | 
    
         
            +
                  t = m.sincosd(m.AngRound(this.azi1)); this.salp1 = t.s; this.calp1 = t.c;
         
     | 
| 
      
 2063 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2064 
     | 
    
         
            +
                  this.azi1 = azi1; this.salp1 = salp1; this.calp1 = calp1;
         
     | 
| 
      
 2065 
     | 
    
         
            +
                }
         
     | 
| 
      
 2066 
     | 
    
         
            +
                t = m.sincosd(m.AngRound(this.lat1)); sbet1 = this._f1 * t.s; cbet1 = t.c;
         
     | 
| 
      
 2067 
     | 
    
         
            +
                // norm(sbet1, cbet1);
         
     | 
| 
      
 2068 
     | 
    
         
            +
                t = m.hypot(sbet1, cbet1); sbet1 /= t; cbet1 /= t;
         
     | 
| 
      
 2069 
     | 
    
         
            +
                // Ensure cbet1 = +epsilon at poles
         
     | 
| 
      
 2070 
     | 
    
         
            +
                cbet1 = Math.max(g.tiny_, cbet1);
         
     | 
| 
      
 2071 
     | 
    
         
            +
                this._dn1 = Math.sqrt(1 + geod._ep2 * m.sq(sbet1));
         
     | 
| 
      
 2072 
     | 
    
         
            +
             
     | 
| 
      
 2073 
     | 
    
         
            +
                // Evaluate alp0 from sin(alp1) * cos(bet1) = sin(alp0),
         
     | 
| 
      
 2074 
     | 
    
         
            +
                this._salp0 = this.salp1 * cbet1; // alp0 in [0, pi/2 - |bet1|]
         
     | 
| 
      
 2075 
     | 
    
         
            +
                // Alt: calp0 = hypot(sbet1, calp1 * cbet1).  The following
         
     | 
| 
      
 2076 
     | 
    
         
            +
                // is slightly better (consider the case salp1 = 0).
         
     | 
| 
      
 2077 
     | 
    
         
            +
                this._calp0 = m.hypot(this.calp1, this.salp1 * sbet1);
         
     | 
| 
      
 2078 
     | 
    
         
            +
                // Evaluate sig with tan(bet1) = tan(sig1) * cos(alp1).
         
     | 
| 
      
 2079 
     | 
    
         
            +
                // sig = 0 is nearest northward crossing of equator.
         
     | 
| 
      
 2080 
     | 
    
         
            +
                // With bet1 = 0, alp1 = pi/2, we have sig1 = 0 (equatorial line).
         
     | 
| 
      
 2081 
     | 
    
         
            +
                // With bet1 =  pi/2, alp1 = -pi, sig1 =  pi/2
         
     | 
| 
      
 2082 
     | 
    
         
            +
                // With bet1 = -pi/2, alp1 =  0 , sig1 = -pi/2
         
     | 
| 
      
 2083 
     | 
    
         
            +
                // Evaluate omg1 with tan(omg1) = sin(alp0) * tan(sig1).
         
     | 
| 
      
 2084 
     | 
    
         
            +
                // With alp0 in (0, pi/2], quadrants for sig and omg coincide.
         
     | 
| 
      
 2085 
     | 
    
         
            +
                // No atan2(0,0) ambiguity at poles since cbet1 = +epsilon.
         
     | 
| 
      
 2086 
     | 
    
         
            +
                // With alp0 = 0, omg1 = 0 for alp1 = 0, omg1 = pi for alp1 = pi.
         
     | 
| 
      
 2087 
     | 
    
         
            +
                this._ssig1 = sbet1; this._somg1 = this._salp0 * sbet1;
         
     | 
| 
      
 2088 
     | 
    
         
            +
                this._csig1 = this._comg1 =
         
     | 
| 
      
 2089 
     | 
    
         
            +
                  sbet1 !== 0 || this.calp1 !== 0 ? cbet1 * this.calp1 : 1;
         
     | 
| 
      
 2090 
     | 
    
         
            +
                // norm(this._ssig1, this._csig1); // sig1 in (-pi, pi]
         
     | 
| 
      
 2091 
     | 
    
         
            +
                t = m.hypot(this._ssig1, this._csig1);
         
     | 
| 
      
 2092 
     | 
    
         
            +
                this._ssig1 /= t; this._csig1 /= t;
         
     | 
| 
      
 2093 
     | 
    
         
            +
                // norm(this._somg1, this._comg1); -- don't need to normalize!
         
     | 
| 
      
 2094 
     | 
    
         
            +
             
     | 
| 
      
 2095 
     | 
    
         
            +
                this._k2 = m.sq(this._calp0) * geod._ep2;
         
     | 
| 
      
 2096 
     | 
    
         
            +
                eps = this._k2 / (2 * (1 + Math.sqrt(1 + this._k2)) + this._k2);
         
     | 
| 
      
 2097 
     | 
    
         
            +
             
     | 
| 
      
 2098 
     | 
    
         
            +
                if (this.caps & g.CAP_C1) {
         
     | 
| 
      
 2099 
     | 
    
         
            +
                  this._A1m1 = g.A1m1f(eps);
         
     | 
| 
      
 2100 
     | 
    
         
            +
                  this._C1a = new Array(g.nC1_ + 1);
         
     | 
| 
      
 2101 
     | 
    
         
            +
                  g.C1f(eps, this._C1a);
         
     | 
| 
      
 2102 
     | 
    
         
            +
                  this._B11 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C1a);
         
     | 
| 
      
 2103 
     | 
    
         
            +
                  s = Math.sin(this._B11); c = Math.cos(this._B11);
         
     | 
| 
      
 2104 
     | 
    
         
            +
                  // tau1 = sig1 + B11
         
     | 
| 
      
 2105 
     | 
    
         
            +
                  this._stau1 = this._ssig1 * c + this._csig1 * s;
         
     | 
| 
      
 2106 
     | 
    
         
            +
                  this._ctau1 = this._csig1 * c - this._ssig1 * s;
         
     | 
| 
      
 2107 
     | 
    
         
            +
                  // Not necessary because C1pa reverts C1a
         
     | 
| 
      
 2108 
     | 
    
         
            +
                  //    _B11 = -SinCosSeries(true, _stau1, _ctau1, _C1pa);
         
     | 
| 
      
 2109 
     | 
    
         
            +
                }
         
     | 
| 
      
 2110 
     | 
    
         
            +
             
     | 
| 
      
 2111 
     | 
    
         
            +
                if (this.caps & g.CAP_C1p) {
         
     | 
| 
      
 2112 
     | 
    
         
            +
                  this._C1pa = new Array(g.nC1p_ + 1);
         
     | 
| 
      
 2113 
     | 
    
         
            +
                  g.C1pf(eps, this._C1pa);
         
     | 
| 
      
 2114 
     | 
    
         
            +
                }
         
     | 
| 
      
 2115 
     | 
    
         
            +
             
     | 
| 
      
 2116 
     | 
    
         
            +
                if (this.caps & g.CAP_C2) {
         
     | 
| 
      
 2117 
     | 
    
         
            +
                  this._A2m1 = g.A2m1f(eps);
         
     | 
| 
      
 2118 
     | 
    
         
            +
                  this._C2a = new Array(g.nC2_ + 1);
         
     | 
| 
      
 2119 
     | 
    
         
            +
                  g.C2f(eps, this._C2a);
         
     | 
| 
      
 2120 
     | 
    
         
            +
                  this._B21 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C2a);
         
     | 
| 
      
 2121 
     | 
    
         
            +
                }
         
     | 
| 
      
 2122 
     | 
    
         
            +
             
     | 
| 
      
 2123 
     | 
    
         
            +
                if (this.caps & g.CAP_C3) {
         
     | 
| 
      
 2124 
     | 
    
         
            +
                  this._C3a = new Array(g.nC3_);
         
     | 
| 
      
 2125 
     | 
    
         
            +
                  geod.C3f(eps, this._C3a);
         
     | 
| 
      
 2126 
     | 
    
         
            +
                  this._A3c = -this.f * this._salp0 * geod.A3f(eps);
         
     | 
| 
      
 2127 
     | 
    
         
            +
                  this._B31 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C3a);
         
     | 
| 
      
 2128 
     | 
    
         
            +
                }
         
     | 
| 
      
 2129 
     | 
    
         
            +
             
     | 
| 
      
 2130 
     | 
    
         
            +
                if (this.caps & g.CAP_C4) {
         
     | 
| 
      
 2131 
     | 
    
         
            +
                  this._C4a = new Array(g.nC4_); // all the elements of _C4a are used
         
     | 
| 
      
 2132 
     | 
    
         
            +
                  geod.C4f(eps, this._C4a);
         
     | 
| 
      
 2133 
     | 
    
         
            +
                  // Multiplier = a^2 * e^2 * cos(alpha0) * sin(alpha0)
         
     | 
| 
      
 2134 
     | 
    
         
            +
                  this._A4 = m.sq(this.a) * this._calp0 * this._salp0 * geod._e2;
         
     | 
| 
      
 2135 
     | 
    
         
            +
                  this._B41 = g.SinCosSeries(false, this._ssig1, this._csig1, this._C4a);
         
     | 
| 
      
 2136 
     | 
    
         
            +
                }
         
     | 
| 
      
 2137 
     | 
    
         
            +
             
     | 
| 
      
 2138 
     | 
    
         
            +
                this.a13 = this.s13 = Number.NaN;
         
     | 
| 
      
 2139 
     | 
    
         
            +
              };
         
     | 
| 
      
 2140 
     | 
    
         
            +
             
     | 
| 
      
 2141 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2142 
     | 
    
         
            +
               * @summary Find the position on the line (general case).
         
     | 
| 
      
 2143 
     | 
    
         
            +
               * @param {bool} arcmode is the next parameter an arc length?
         
     | 
| 
      
 2144 
     | 
    
         
            +
               * @param {number} s12_a12 the (arcmode ? arc length : distance) from the
         
     | 
| 
      
 2145 
     | 
    
         
            +
               *   first point to the second in (arcmode ? degrees : meters).
         
     | 
| 
      
 2146 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include; this is
         
     | 
| 
      
 2147 
     | 
    
         
            +
               *   subject to the capabilities of the object.
         
     | 
| 
      
 2148 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 2149 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, and a12 fields of the result are
         
     | 
| 
      
 2150 
     | 
    
         
            +
               *   always set; s12 is included if arcmode is false.  For details on the
         
     | 
| 
      
 2151 
     | 
    
         
            +
               *   outmask parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 2152 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 2153 
     | 
    
         
            +
               */
         
     | 
| 
      
 2154 
     | 
    
         
            +
              l.GeodesicLine.prototype.GenPosition = function(arcmode, s12_a12,
         
     | 
| 
      
 2155 
     | 
    
         
            +
                                                              outmask) {
         
     | 
| 
      
 2156 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 2157 
     | 
    
         
            +
                    sig12, ssig12, csig12, B12, AB1, ssig2, csig2, tau12, s, c, serr,
         
     | 
| 
      
 2158 
     | 
    
         
            +
                    omg12, lam12, lon12, E, sbet2, cbet2, somg2, comg2, salp2, calp2, dn2,
         
     | 
| 
      
 2159 
     | 
    
         
            +
                    B22, AB2, J12, t, B42, salp12, calp12;
         
     | 
| 
      
 2160 
     | 
    
         
            +
                if (!outmask) outmask = g.STANDARD;
         
     | 
| 
      
 2161 
     | 
    
         
            +
                else if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
         
     | 
| 
      
 2162 
     | 
    
         
            +
                outmask &= this.caps & g.OUT_MASK;
         
     | 
| 
      
 2163 
     | 
    
         
            +
                vals.lat1 = this.lat1; vals.azi1 = this.azi1;
         
     | 
| 
      
 2164 
     | 
    
         
            +
                vals.lon1 = outmask & g.LONG_UNROLL ?
         
     | 
| 
      
 2165 
     | 
    
         
            +
                  this.lon1 : m.AngNormalize(this.lon1);
         
     | 
| 
      
 2166 
     | 
    
         
            +
                if (arcmode)
         
     | 
| 
      
 2167 
     | 
    
         
            +
                  vals.a12 = s12_a12;
         
     | 
| 
      
 2168 
     | 
    
         
            +
                else
         
     | 
| 
      
 2169 
     | 
    
         
            +
                  vals.s12 = s12_a12;
         
     | 
| 
      
 2170 
     | 
    
         
            +
                if (!( arcmode || (this.caps & g.DISTANCE_IN & g.OUT_MASK) )) {
         
     | 
| 
      
 2171 
     | 
    
         
            +
                  // Uninitialized or impossible distance calculation requested
         
     | 
| 
      
 2172 
     | 
    
         
            +
                  vals.a12 = Number.NaN;
         
     | 
| 
      
 2173 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2174 
     | 
    
         
            +
                }
         
     | 
| 
      
 2175 
     | 
    
         
            +
             
     | 
| 
      
 2176 
     | 
    
         
            +
                // Avoid warning about uninitialized B12.
         
     | 
| 
      
 2177 
     | 
    
         
            +
                B12 = 0; AB1 = 0;
         
     | 
| 
      
 2178 
     | 
    
         
            +
                if (arcmode) {
         
     | 
| 
      
 2179 
     | 
    
         
            +
                  // Interpret s12_a12 as spherical arc length
         
     | 
| 
      
 2180 
     | 
    
         
            +
                  sig12 = s12_a12 * m.degree;
         
     | 
| 
      
 2181 
     | 
    
         
            +
                  t = m.sincosd(s12_a12); ssig12 = t.s; csig12 = t.c;
         
     | 
| 
      
 2182 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2183 
     | 
    
         
            +
                  // Interpret s12_a12 as distance
         
     | 
| 
      
 2184 
     | 
    
         
            +
                  tau12 = s12_a12 / (this._b * (1 + this._A1m1));
         
     | 
| 
      
 2185 
     | 
    
         
            +
                  s = Math.sin(tau12);
         
     | 
| 
      
 2186 
     | 
    
         
            +
                  c = Math.cos(tau12);
         
     | 
| 
      
 2187 
     | 
    
         
            +
                  // tau2 = tau1 + tau12
         
     | 
| 
      
 2188 
     | 
    
         
            +
                  B12 = -g.SinCosSeries(true,
         
     | 
| 
      
 2189 
     | 
    
         
            +
                                        this._stau1 * c + this._ctau1 * s,
         
     | 
| 
      
 2190 
     | 
    
         
            +
                                        this._ctau1 * c - this._stau1 * s,
         
     | 
| 
      
 2191 
     | 
    
         
            +
                                        this._C1pa);
         
     | 
| 
      
 2192 
     | 
    
         
            +
                  sig12 = tau12 - (B12 - this._B11);
         
     | 
| 
      
 2193 
     | 
    
         
            +
                  ssig12 = Math.sin(sig12); csig12 = Math.cos(sig12);
         
     | 
| 
      
 2194 
     | 
    
         
            +
                  if (Math.abs(this.f) > 0.01) {
         
     | 
| 
      
 2195 
     | 
    
         
            +
                    // Reverted distance series is inaccurate for |f| > 1/100, so correct
         
     | 
| 
      
 2196 
     | 
    
         
            +
                    // sig12 with 1 Newton iteration.  The following table shows the
         
     | 
| 
      
 2197 
     | 
    
         
            +
                    // approximate maximum error for a = WGS_a() and various f relative to
         
     | 
| 
      
 2198 
     | 
    
         
            +
                    // GeodesicExact.
         
     | 
| 
      
 2199 
     | 
    
         
            +
                    //     erri = the error in the inverse solution (nm)
         
     | 
| 
      
 2200 
     | 
    
         
            +
                    //     errd = the error in the direct solution (series only) (nm)
         
     | 
| 
      
 2201 
     | 
    
         
            +
                    //     errda = the error in the direct solution
         
     | 
| 
      
 2202 
     | 
    
         
            +
                    //             (series + 1 Newton) (nm)
         
     | 
| 
      
 2203 
     | 
    
         
            +
                    //
         
     | 
| 
      
 2204 
     | 
    
         
            +
                    //       f     erri  errd errda
         
     | 
| 
      
 2205 
     | 
    
         
            +
                    //     -1/5    12e6 1.2e9  69e6
         
     | 
| 
      
 2206 
     | 
    
         
            +
                    //     -1/10  123e3  12e6 765e3
         
     | 
| 
      
 2207 
     | 
    
         
            +
                    //     -1/20   1110 108e3  7155
         
     | 
| 
      
 2208 
     | 
    
         
            +
                    //     -1/50  18.63 200.9 27.12
         
     | 
| 
      
 2209 
     | 
    
         
            +
                    //     -1/100 18.63 23.78 23.37
         
     | 
| 
      
 2210 
     | 
    
         
            +
                    //     -1/150 18.63 21.05 20.26
         
     | 
| 
      
 2211 
     | 
    
         
            +
                    //      1/150 22.35 24.73 25.83
         
     | 
| 
      
 2212 
     | 
    
         
            +
                    //      1/100 22.35 25.03 25.31
         
     | 
| 
      
 2213 
     | 
    
         
            +
                    //      1/50  29.80 231.9 30.44
         
     | 
| 
      
 2214 
     | 
    
         
            +
                    //      1/20   5376 146e3  10e3
         
     | 
| 
      
 2215 
     | 
    
         
            +
                    //      1/10  829e3  22e6 1.5e6
         
     | 
| 
      
 2216 
     | 
    
         
            +
                    //      1/5   157e6 3.8e9 280e6
         
     | 
| 
      
 2217 
     | 
    
         
            +
                    ssig2 = this._ssig1 * csig12 + this._csig1 * ssig12;
         
     | 
| 
      
 2218 
     | 
    
         
            +
                    csig2 = this._csig1 * csig12 - this._ssig1 * ssig12;
         
     | 
| 
      
 2219 
     | 
    
         
            +
                    B12 = g.SinCosSeries(true, ssig2, csig2, this._C1a);
         
     | 
| 
      
 2220 
     | 
    
         
            +
                    serr = (1 + this._A1m1) * (sig12 + (B12 - this._B11)) -
         
     | 
| 
      
 2221 
     | 
    
         
            +
                      s12_a12 / this._b;
         
     | 
| 
      
 2222 
     | 
    
         
            +
                    sig12 = sig12 - serr / Math.sqrt(1 + this._k2 * m.sq(ssig2));
         
     | 
| 
      
 2223 
     | 
    
         
            +
                    ssig12 = Math.sin(sig12); csig12 = Math.cos(sig12);
         
     | 
| 
      
 2224 
     | 
    
         
            +
                    // Update B12 below
         
     | 
| 
      
 2225 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2226 
     | 
    
         
            +
                }
         
     | 
| 
      
 2227 
     | 
    
         
            +
             
     | 
| 
      
 2228 
     | 
    
         
            +
                // sig2 = sig1 + sig12
         
     | 
| 
      
 2229 
     | 
    
         
            +
                ssig2 = this._ssig1 * csig12 + this._csig1 * ssig12;
         
     | 
| 
      
 2230 
     | 
    
         
            +
                csig2 = this._csig1 * csig12 - this._ssig1 * ssig12;
         
     | 
| 
      
 2231 
     | 
    
         
            +
                dn2 = Math.sqrt(1 + this._k2 * m.sq(ssig2));
         
     | 
| 
      
 2232 
     | 
    
         
            +
                if (outmask & (g.DISTANCE | g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 2233 
     | 
    
         
            +
                  if (arcmode || Math.abs(this.f) > 0.01)
         
     | 
| 
      
 2234 
     | 
    
         
            +
                    B12 = g.SinCosSeries(true, ssig2, csig2, this._C1a);
         
     | 
| 
      
 2235 
     | 
    
         
            +
                  AB1 = (1 + this._A1m1) * (B12 - this._B11);
         
     | 
| 
      
 2236 
     | 
    
         
            +
                }
         
     | 
| 
      
 2237 
     | 
    
         
            +
                // sin(bet2) = cos(alp0) * sin(sig2)
         
     | 
| 
      
 2238 
     | 
    
         
            +
                sbet2 = this._calp0 * ssig2;
         
     | 
| 
      
 2239 
     | 
    
         
            +
                // Alt: cbet2 = hypot(csig2, salp0 * ssig2);
         
     | 
| 
      
 2240 
     | 
    
         
            +
                cbet2 = m.hypot(this._salp0, this._calp0 * csig2);
         
     | 
| 
      
 2241 
     | 
    
         
            +
                if (cbet2 === 0)
         
     | 
| 
      
 2242 
     | 
    
         
            +
                  // I.e., salp0 = 0, csig2 = 0.  Break the degeneracy in this case
         
     | 
| 
      
 2243 
     | 
    
         
            +
                  cbet2 = csig2 = g.tiny_;
         
     | 
| 
      
 2244 
     | 
    
         
            +
                // tan(alp0) = cos(sig2)*tan(alp2)
         
     | 
| 
      
 2245 
     | 
    
         
            +
                salp2 = this._salp0; calp2 = this._calp0 * csig2; // No need to normalize
         
     | 
| 
      
 2246 
     | 
    
         
            +
             
     | 
| 
      
 2247 
     | 
    
         
            +
                if (arcmode && (outmask & g.DISTANCE))
         
     | 
| 
      
 2248 
     | 
    
         
            +
                  vals.s12 = this._b * ((1 + this._A1m1) * sig12 + AB1);
         
     | 
| 
      
 2249 
     | 
    
         
            +
             
     | 
| 
      
 2250 
     | 
    
         
            +
                if (outmask & g.LONGITUDE) {
         
     | 
| 
      
 2251 
     | 
    
         
            +
                  // tan(omg2) = sin(alp0) * tan(sig2)
         
     | 
| 
      
 2252 
     | 
    
         
            +
                  somg2 = this._salp0 * ssig2; comg2 = csig2; // No need to normalize
         
     | 
| 
      
 2253 
     | 
    
         
            +
                  E = m.copysign(1, this._salp0);
         
     | 
| 
      
 2254 
     | 
    
         
            +
                  // omg12 = omg2 - omg1
         
     | 
| 
      
 2255 
     | 
    
         
            +
                  omg12 = outmask & g.LONG_UNROLL ?
         
     | 
| 
      
 2256 
     | 
    
         
            +
                    E * (sig12 -
         
     | 
| 
      
 2257 
     | 
    
         
            +
                         (Math.atan2(ssig2, csig2) -
         
     | 
| 
      
 2258 
     | 
    
         
            +
                          Math.atan2(this._ssig1, this._csig1)) +
         
     | 
| 
      
 2259 
     | 
    
         
            +
                         (Math.atan2(E * somg2, comg2) -
         
     | 
| 
      
 2260 
     | 
    
         
            +
                          Math.atan2(E * this._somg1, this._comg1))) :
         
     | 
| 
      
 2261 
     | 
    
         
            +
                    Math.atan2(somg2 * this._comg1 - comg2 * this._somg1,
         
     | 
| 
      
 2262 
     | 
    
         
            +
                                 comg2 * this._comg1 + somg2 * this._somg1);
         
     | 
| 
      
 2263 
     | 
    
         
            +
                  lam12 = omg12 + this._A3c *
         
     | 
| 
      
 2264 
     | 
    
         
            +
                    ( sig12 + (g.SinCosSeries(true, ssig2, csig2, this._C3a) -
         
     | 
| 
      
 2265 
     | 
    
         
            +
                               this._B31));
         
     | 
| 
      
 2266 
     | 
    
         
            +
                  lon12 = lam12 / m.degree;
         
     | 
| 
      
 2267 
     | 
    
         
            +
                  vals.lon2 = outmask & g.LONG_UNROLL ? this.lon1 + lon12 :
         
     | 
| 
      
 2268 
     | 
    
         
            +
                    m.AngNormalize(m.AngNormalize(this.lon1) + m.AngNormalize(lon12));
         
     | 
| 
      
 2269 
     | 
    
         
            +
                }
         
     | 
| 
      
 2270 
     | 
    
         
            +
             
     | 
| 
      
 2271 
     | 
    
         
            +
                if (outmask & g.LATITUDE)
         
     | 
| 
      
 2272 
     | 
    
         
            +
                  vals.lat2 = m.atan2d(sbet2, this._f1 * cbet2);
         
     | 
| 
      
 2273 
     | 
    
         
            +
             
     | 
| 
      
 2274 
     | 
    
         
            +
                if (outmask & g.AZIMUTH)
         
     | 
| 
      
 2275 
     | 
    
         
            +
                  vals.azi2 = m.atan2d(salp2, calp2);
         
     | 
| 
      
 2276 
     | 
    
         
            +
             
     | 
| 
      
 2277 
     | 
    
         
            +
                if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
         
     | 
| 
      
 2278 
     | 
    
         
            +
                  B22 = g.SinCosSeries(true, ssig2, csig2, this._C2a);
         
     | 
| 
      
 2279 
     | 
    
         
            +
                  AB2 = (1 + this._A2m1) * (B22 - this._B21);
         
     | 
| 
      
 2280 
     | 
    
         
            +
                  J12 = (this._A1m1 - this._A2m1) * sig12 + (AB1 - AB2);
         
     | 
| 
      
 2281 
     | 
    
         
            +
                  if (outmask & g.REDUCEDLENGTH)
         
     | 
| 
      
 2282 
     | 
    
         
            +
                    // Add parens around (_csig1 * ssig2) and (_ssig1 * csig2) to ensure
         
     | 
| 
      
 2283 
     | 
    
         
            +
                    // accurate cancellation in the case of coincident points.
         
     | 
| 
      
 2284 
     | 
    
         
            +
                    vals.m12 = this._b * ((      dn2 * (this._csig1 * ssig2) -
         
     | 
| 
      
 2285 
     | 
    
         
            +
                                           this._dn1 * (this._ssig1 * csig2)) -
         
     | 
| 
      
 2286 
     | 
    
         
            +
                                          this._csig1 * csig2 * J12);
         
     | 
| 
      
 2287 
     | 
    
         
            +
                  if (outmask & g.GEODESICSCALE) {
         
     | 
| 
      
 2288 
     | 
    
         
            +
                    t = this._k2 * (ssig2 - this._ssig1) * (ssig2 + this._ssig1) /
         
     | 
| 
      
 2289 
     | 
    
         
            +
                      (this._dn1 + dn2);
         
     | 
| 
      
 2290 
     | 
    
         
            +
                    vals.M12 = csig12 +
         
     | 
| 
      
 2291 
     | 
    
         
            +
                      (t * ssig2 - csig2 * J12) * this._ssig1 / this._dn1;
         
     | 
| 
      
 2292 
     | 
    
         
            +
                    vals.M21 = csig12 -
         
     | 
| 
      
 2293 
     | 
    
         
            +
                      (t * this._ssig1 - this._csig1 * J12) * ssig2 / dn2;
         
     | 
| 
      
 2294 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2295 
     | 
    
         
            +
                }
         
     | 
| 
      
 2296 
     | 
    
         
            +
             
     | 
| 
      
 2297 
     | 
    
         
            +
                if (outmask & g.AREA) {
         
     | 
| 
      
 2298 
     | 
    
         
            +
                  B42 = g.SinCosSeries(false, ssig2, csig2, this._C4a);
         
     | 
| 
      
 2299 
     | 
    
         
            +
                  if (this._calp0 === 0 || this._salp0 === 0) {
         
     | 
| 
      
 2300 
     | 
    
         
            +
                    // alp12 = alp2 - alp1, used in atan2 so no need to normalize
         
     | 
| 
      
 2301 
     | 
    
         
            +
                    salp12 = salp2 * this.calp1 - calp2 * this.salp1;
         
     | 
| 
      
 2302 
     | 
    
         
            +
                    calp12 = calp2 * this.calp1 + salp2 * this.salp1;
         
     | 
| 
      
 2303 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 2304 
     | 
    
         
            +
                    // tan(alp) = tan(alp0) * sec(sig)
         
     | 
| 
      
 2305 
     | 
    
         
            +
                    // tan(alp2-alp1) = (tan(alp2) -tan(alp1)) / (tan(alp2)*tan(alp1)+1)
         
     | 
| 
      
 2306 
     | 
    
         
            +
                    // = calp0 * salp0 * (csig1-csig2) / (salp0^2 + calp0^2 * csig1*csig2)
         
     | 
| 
      
 2307 
     | 
    
         
            +
                    // If csig12 > 0, write
         
     | 
| 
      
 2308 
     | 
    
         
            +
                    //   csig1 - csig2 = ssig12 * (csig1 * ssig12 / (1 + csig12) + ssig1)
         
     | 
| 
      
 2309 
     | 
    
         
            +
                    // else
         
     | 
| 
      
 2310 
     | 
    
         
            +
                    //   csig1 - csig2 = csig1 * (1 - csig12) + ssig12 * ssig1
         
     | 
| 
      
 2311 
     | 
    
         
            +
                    // No need to normalize
         
     | 
| 
      
 2312 
     | 
    
         
            +
                    salp12 = this._calp0 * this._salp0 *
         
     | 
| 
      
 2313 
     | 
    
         
            +
                      (csig12 <= 0 ? this._csig1 * (1 - csig12) + ssig12 * this._ssig1 :
         
     | 
| 
      
 2314 
     | 
    
         
            +
                       ssig12 * (this._csig1 * ssig12 / (1 + csig12) + this._ssig1));
         
     | 
| 
      
 2315 
     | 
    
         
            +
                    calp12 = m.sq(this._salp0) + m.sq(this._calp0) * this._csig1 * csig2;
         
     | 
| 
      
 2316 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2317 
     | 
    
         
            +
                  vals.S12 = this._c2 * Math.atan2(salp12, calp12) +
         
     | 
| 
      
 2318 
     | 
    
         
            +
                    this._A4 * (B42 - this._B41);
         
     | 
| 
      
 2319 
     | 
    
         
            +
                }
         
     | 
| 
      
 2320 
     | 
    
         
            +
             
     | 
| 
      
 2321 
     | 
    
         
            +
                if (!arcmode)
         
     | 
| 
      
 2322 
     | 
    
         
            +
                  vals.a12 = sig12 / m.degree;
         
     | 
| 
      
 2323 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 2324 
     | 
    
         
            +
              };
         
     | 
| 
      
 2325 
     | 
    
         
            +
             
     | 
| 
      
 2326 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2327 
     | 
    
         
            +
               * @summary Find the position on the line given s12.
         
     | 
| 
      
 2328 
     | 
    
         
            +
               * @param {number} s12 the distance from the first point to the second in
         
     | 
| 
      
 2329 
     | 
    
         
            +
               *   meters.
         
     | 
| 
      
 2330 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include; this is
         
     | 
| 
      
 2331 
     | 
    
         
            +
               *   subject to the capabilities of the object.
         
     | 
| 
      
 2332 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 2333 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, s12, and a12 fields of the result are
         
     | 
| 
      
 2334 
     | 
    
         
            +
               *   always set; s12 is included if arcmode is false.  For details on the
         
     | 
| 
      
 2335 
     | 
    
         
            +
               *   outmask parameter, see {@tutorial 2-interface}, "The outmask and caps
         
     | 
| 
      
 2336 
     | 
    
         
            +
               *   parameters".
         
     | 
| 
      
 2337 
     | 
    
         
            +
               */
         
     | 
| 
      
 2338 
     | 
    
         
            +
              l.GeodesicLine.prototype.Position = function(s12, outmask) {
         
     | 
| 
      
 2339 
     | 
    
         
            +
                return this.GenPosition(false, s12, outmask);
         
     | 
| 
      
 2340 
     | 
    
         
            +
              };
         
     | 
| 
      
 2341 
     | 
    
         
            +
             
     | 
| 
      
 2342 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2343 
     | 
    
         
            +
               * @summary Find the position on the line given a12.
         
     | 
| 
      
 2344 
     | 
    
         
            +
               * @param {number} a12 the arc length from the first point to the second in
         
     | 
| 
      
 2345 
     | 
    
         
            +
               *   degrees.
         
     | 
| 
      
 2346 
     | 
    
         
            +
               * @param {bitmask} [outmask = STANDARD] which results to include; this is
         
     | 
| 
      
 2347 
     | 
    
         
            +
               *   subject to the capabilities of the object.
         
     | 
| 
      
 2348 
     | 
    
         
            +
               * @returns {object} the requested results.
         
     | 
| 
      
 2349 
     | 
    
         
            +
               * @description The lat1, lon1, azi1, and a12 fields of the result are
         
     | 
| 
      
 2350 
     | 
    
         
            +
               *   always set.  For details on the outmask parameter, see {@tutorial
         
     | 
| 
      
 2351 
     | 
    
         
            +
               *   2-interface}, "The outmask and caps parameters".
         
     | 
| 
      
 2352 
     | 
    
         
            +
               */
         
     | 
| 
      
 2353 
     | 
    
         
            +
              l.GeodesicLine.prototype.ArcPosition = function(a12, outmask) {
         
     | 
| 
      
 2354 
     | 
    
         
            +
                return this.GenPosition(true, a12, outmask);
         
     | 
| 
      
 2355 
     | 
    
         
            +
              };
         
     | 
| 
      
 2356 
     | 
    
         
            +
             
     | 
| 
      
 2357 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2358 
     | 
    
         
            +
               * @summary Specify position of point 3 in terms of either distance or arc
         
     | 
| 
      
 2359 
     | 
    
         
            +
               *   length.
         
     | 
| 
      
 2360 
     | 
    
         
            +
               * @param {bool} arcmode boolean flag determining the meaning of the second
         
     | 
| 
      
 2361 
     | 
    
         
            +
               *   parameter; if arcmode is false, then the GeodesicLine object must have
         
     | 
| 
      
 2362 
     | 
    
         
            +
               *   been constructed with caps |= DISTANCE_IN.
         
     | 
| 
      
 2363 
     | 
    
         
            +
               * @param {number} s13_a13 if arcmode is false, this is the distance from
         
     | 
| 
      
 2364 
     | 
    
         
            +
               *   point 1 to point 3 (meters); otherwise it is the arc length from
         
     | 
| 
      
 2365 
     | 
    
         
            +
               *   point 1 to point 3 (degrees); it can be negative.
         
     | 
| 
      
 2366 
     | 
    
         
            +
               **********************************************************************/
         
     | 
| 
      
 2367 
     | 
    
         
            +
              l.GeodesicLine.prototype.GenSetDistance = function(arcmode, s13_a13) {
         
     | 
| 
      
 2368 
     | 
    
         
            +
                if (arcmode)
         
     | 
| 
      
 2369 
     | 
    
         
            +
                  this.SetArc(s13_a13);
         
     | 
| 
      
 2370 
     | 
    
         
            +
                else
         
     | 
| 
      
 2371 
     | 
    
         
            +
                  this.SetDistance(s13_a13);
         
     | 
| 
      
 2372 
     | 
    
         
            +
              };
         
     | 
| 
      
 2373 
     | 
    
         
            +
             
     | 
| 
      
 2374 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2375 
     | 
    
         
            +
               * @summary Specify position of point 3 in terms distance.
         
     | 
| 
      
 2376 
     | 
    
         
            +
               * @param {number} s13 the distance from point 1 to point 3 (meters); it
         
     | 
| 
      
 2377 
     | 
    
         
            +
               *   can be negative.
         
     | 
| 
      
 2378 
     | 
    
         
            +
               **********************************************************************/
         
     | 
| 
      
 2379 
     | 
    
         
            +
              l.GeodesicLine.prototype.SetDistance = function(s13) {
         
     | 
| 
      
 2380 
     | 
    
         
            +
                var r;
         
     | 
| 
      
 2381 
     | 
    
         
            +
                this.s13 = s13;
         
     | 
| 
      
 2382 
     | 
    
         
            +
                r = this.GenPosition(false, this.s13, g.ARC);
         
     | 
| 
      
 2383 
     | 
    
         
            +
                this.a13 = 0 + r.a12;       // the 0+ converts undefined into NaN
         
     | 
| 
      
 2384 
     | 
    
         
            +
              };
         
     | 
| 
      
 2385 
     | 
    
         
            +
             
     | 
| 
      
 2386 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2387 
     | 
    
         
            +
               * @summary Specify position of point 3 in terms of arc length.
         
     | 
| 
      
 2388 
     | 
    
         
            +
               * @param {number} a13 the arc length from point 1 to point 3 (degrees);
         
     | 
| 
      
 2389 
     | 
    
         
            +
               *   it can be negative.
         
     | 
| 
      
 2390 
     | 
    
         
            +
               **********************************************************************/
         
     | 
| 
      
 2391 
     | 
    
         
            +
              l.GeodesicLine.prototype.SetArc = function(a13) {
         
     | 
| 
      
 2392 
     | 
    
         
            +
                var r;
         
     | 
| 
      
 2393 
     | 
    
         
            +
                this.a13 = a13;
         
     | 
| 
      
 2394 
     | 
    
         
            +
                r = this.GenPosition(true, this.a13, g.DISTANCE);
         
     | 
| 
      
 2395 
     | 
    
         
            +
                this.s13 = 0 + r.s12;       // the 0+ converts undefined into NaN
         
     | 
| 
      
 2396 
     | 
    
         
            +
              };
         
     | 
| 
      
 2397 
     | 
    
         
            +
             
     | 
| 
      
 2398 
     | 
    
         
            +
            })(GeographicLib.Geodesic, GeographicLib.GeodesicLine, GeographicLib.Math);
         
     | 
| 
      
 2399 
     | 
    
         
            +
             
     | 
| 
      
 2400 
     | 
    
         
            +
            /**************** PolygonArea.js ****************/
         
     | 
| 
      
 2401 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2402 
     | 
    
         
            +
             * PolygonArea.js
         
     | 
| 
      
 2403 
     | 
    
         
            +
             * Transcription of PolygonArea.[ch]pp into JavaScript.
         
     | 
| 
      
 2404 
     | 
    
         
            +
             *
         
     | 
| 
      
 2405 
     | 
    
         
            +
             * See the documentation for the C++ class.  The conversion is a literal
         
     | 
| 
      
 2406 
     | 
    
         
            +
             * conversion from C++.
         
     | 
| 
      
 2407 
     | 
    
         
            +
             *
         
     | 
| 
      
 2408 
     | 
    
         
            +
             * The algorithms are derived in
         
     | 
| 
      
 2409 
     | 
    
         
            +
             *
         
     | 
| 
      
 2410 
     | 
    
         
            +
             *    Charles F. F. Karney,
         
     | 
| 
      
 2411 
     | 
    
         
            +
             *    Algorithms for geodesics, J. Geodesy 87, 43-55 (2013);
         
     | 
| 
      
 2412 
     | 
    
         
            +
             *    https://doi.org/10.1007/s00190-012-0578-z
         
     | 
| 
      
 2413 
     | 
    
         
            +
             *    Addenda: https://geographiclib.sourceforge.io/geod-addenda.html
         
     | 
| 
      
 2414 
     | 
    
         
            +
             *
         
     | 
| 
      
 2415 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2017) <charles@karney.com> and licensed
         
     | 
| 
      
 2416 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 2417 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 2418 
     | 
    
         
            +
             */
         
     | 
| 
      
 2419 
     | 
    
         
            +
             
     | 
| 
      
 2420 
     | 
    
         
            +
            // Load AFTER GeographicLib/Math.js and GeographicLib/Geodesic.js
         
     | 
| 
      
 2421 
     | 
    
         
            +
             
     | 
| 
      
 2422 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 2423 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2424 
     | 
    
         
            +
               * @exports GeographicLib/PolygonArea
         
     | 
| 
      
 2425 
     | 
    
         
            +
               * @description Compute the area of geodesic polygons via the
         
     | 
| 
      
 2426 
     | 
    
         
            +
               *   {@link module:GeographicLib/PolygonArea.PolygonArea PolygonArea}
         
     | 
| 
      
 2427 
     | 
    
         
            +
               *   class.
         
     | 
| 
      
 2428 
     | 
    
         
            +
               */
         
     | 
| 
      
 2429 
     | 
    
         
            +
              p, g, m, a) {
         
     | 
| 
      
 2430 
     | 
    
         
            +
             
     | 
| 
      
 2431 
     | 
    
         
            +
              var transit, transitdirect;
         
     | 
| 
      
 2432 
     | 
    
         
            +
              transit = function(lon1, lon2) {
         
     | 
| 
      
 2433 
     | 
    
         
            +
                // Return 1 or -1 if crossing prime meridian in east or west direction.
         
     | 
| 
      
 2434 
     | 
    
         
            +
                // Otherwise return zero.
         
     | 
| 
      
 2435 
     | 
    
         
            +
                var lon12, cross;
         
     | 
| 
      
 2436 
     | 
    
         
            +
                // Compute lon12 the same way as Geodesic::Inverse.
         
     | 
| 
      
 2437 
     | 
    
         
            +
                lon1 = m.AngNormalize(lon1);
         
     | 
| 
      
 2438 
     | 
    
         
            +
                lon2 = m.AngNormalize(lon2);
         
     | 
| 
      
 2439 
     | 
    
         
            +
                lon12 = m.AngDiff(lon1, lon2).s;
         
     | 
| 
      
 2440 
     | 
    
         
            +
                cross = lon1 <= 0 && lon2 > 0 && lon12 > 0 ? 1 :
         
     | 
| 
      
 2441 
     | 
    
         
            +
                  (lon2 <= 0 && lon1 > 0 && lon12 < 0 ? -1 : 0);
         
     | 
| 
      
 2442 
     | 
    
         
            +
                return cross;
         
     | 
| 
      
 2443 
     | 
    
         
            +
              };
         
     | 
| 
      
 2444 
     | 
    
         
            +
             
     | 
| 
      
 2445 
     | 
    
         
            +
              // an alternate version of transit to deal with longitudes in the direct
         
     | 
| 
      
 2446 
     | 
    
         
            +
              // problem.
         
     | 
| 
      
 2447 
     | 
    
         
            +
              transitdirect = function(lon1, lon2) {
         
     | 
| 
      
 2448 
     | 
    
         
            +
                // We want to compute exactly
         
     | 
| 
      
 2449 
     | 
    
         
            +
                //   int(floor(lon2 / 360)) - int(floor(lon1 / 360))
         
     | 
| 
      
 2450 
     | 
    
         
            +
                // Since we only need the parity of the result we can use std::remquo but
         
     | 
| 
      
 2451 
     | 
    
         
            +
                // this is buggy with g++ 4.8.3 and requires C++11.  So instead we do
         
     | 
| 
      
 2452 
     | 
    
         
            +
                lon1 = lon1 % 720.0; lon2 = lon2 % 720.0;
         
     | 
| 
      
 2453 
     | 
    
         
            +
                return ( ((lon2 >= 0 && lon2 < 360) || lon2 < -360 ? 0 : 1) -
         
     | 
| 
      
 2454 
     | 
    
         
            +
                         ((lon1 >= 0 && lon1 < 360) || lon1 < -360 ? 0 : 1) );
         
     | 
| 
      
 2455 
     | 
    
         
            +
              };
         
     | 
| 
      
 2456 
     | 
    
         
            +
             
     | 
| 
      
 2457 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2458 
     | 
    
         
            +
               * @class
         
     | 
| 
      
 2459 
     | 
    
         
            +
               * @property {number} a the equatorial radius (meters).
         
     | 
| 
      
 2460 
     | 
    
         
            +
               * @property {number} f the flattening.
         
     | 
| 
      
 2461 
     | 
    
         
            +
               * @property {bool} polyline whether the PolygonArea object describes a
         
     | 
| 
      
 2462 
     | 
    
         
            +
               *   polyline or a polygon.
         
     | 
| 
      
 2463 
     | 
    
         
            +
               * @property {number} num the number of vertices so far.
         
     | 
| 
      
 2464 
     | 
    
         
            +
               * @property {number} lat the current latitude (degrees).
         
     | 
| 
      
 2465 
     | 
    
         
            +
               * @property {number} lon the current longitude (degrees).
         
     | 
| 
      
 2466 
     | 
    
         
            +
               * @summary Initialize a PolygonArea object.
         
     | 
| 
      
 2467 
     | 
    
         
            +
               * @classdesc Computes the area and perimeter of a geodesic polygon.
         
     | 
| 
      
 2468 
     | 
    
         
            +
               *   This object is usually instantiated by
         
     | 
| 
      
 2469 
     | 
    
         
            +
               *   {@link module:GeographicLib/Geodesic.Geodesic#Polygon Geodesic.Polygon}.
         
     | 
| 
      
 2470 
     | 
    
         
            +
               * @param {object} geod a {@link module:GeographicLib/Geodesic.Geodesic
         
     | 
| 
      
 2471 
     | 
    
         
            +
               *   Geodesic} object.
         
     | 
| 
      
 2472 
     | 
    
         
            +
               * @param {bool} [polyline = false] if true the new PolygonArea object
         
     | 
| 
      
 2473 
     | 
    
         
            +
               *   describes a polyline instead of a polygon.
         
     | 
| 
      
 2474 
     | 
    
         
            +
               */
         
     | 
| 
      
 2475 
     | 
    
         
            +
              p.PolygonArea = function(geod, polyline) {
         
     | 
| 
      
 2476 
     | 
    
         
            +
                this._geod = geod;
         
     | 
| 
      
 2477 
     | 
    
         
            +
                this.a = this._geod.a;
         
     | 
| 
      
 2478 
     | 
    
         
            +
                this.f = this._geod.f;
         
     | 
| 
      
 2479 
     | 
    
         
            +
                this._area0 = 4 * Math.PI * geod._c2;
         
     | 
| 
      
 2480 
     | 
    
         
            +
                this.polyline = !polyline ? false : polyline;
         
     | 
| 
      
 2481 
     | 
    
         
            +
                this._mask = g.LATITUDE | g.LONGITUDE | g.DISTANCE |
         
     | 
| 
      
 2482 
     | 
    
         
            +
                      (this.polyline ? g.NONE : g.AREA | g.LONG_UNROLL);
         
     | 
| 
      
 2483 
     | 
    
         
            +
                if (!this.polyline)
         
     | 
| 
      
 2484 
     | 
    
         
            +
                  this._areasum = new a.Accumulator(0);
         
     | 
| 
      
 2485 
     | 
    
         
            +
                this._perimetersum = new a.Accumulator(0);
         
     | 
| 
      
 2486 
     | 
    
         
            +
                this.Clear();
         
     | 
| 
      
 2487 
     | 
    
         
            +
              };
         
     | 
| 
      
 2488 
     | 
    
         
            +
             
     | 
| 
      
 2489 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2490 
     | 
    
         
            +
               * @summary Clear the PolygonArea object, setting the number of vertices to
         
     | 
| 
      
 2491 
     | 
    
         
            +
               *   0.
         
     | 
| 
      
 2492 
     | 
    
         
            +
               */
         
     | 
| 
      
 2493 
     | 
    
         
            +
              p.PolygonArea.prototype.Clear = function() {
         
     | 
| 
      
 2494 
     | 
    
         
            +
                this.num = 0;
         
     | 
| 
      
 2495 
     | 
    
         
            +
                this._crossings = 0;
         
     | 
| 
      
 2496 
     | 
    
         
            +
                if (!this.polyline)
         
     | 
| 
      
 2497 
     | 
    
         
            +
                  this._areasum.Set(0);
         
     | 
| 
      
 2498 
     | 
    
         
            +
                this._perimetersum.Set(0);
         
     | 
| 
      
 2499 
     | 
    
         
            +
                this._lat0 = this._lon0 = this.lat = this.lon = Number.NaN;
         
     | 
| 
      
 2500 
     | 
    
         
            +
              };
         
     | 
| 
      
 2501 
     | 
    
         
            +
             
     | 
| 
      
 2502 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2503 
     | 
    
         
            +
               * @summary Add the next vertex to the polygon.
         
     | 
| 
      
 2504 
     | 
    
         
            +
               * @param {number} lat the latitude of the point (degrees).
         
     | 
| 
      
 2505 
     | 
    
         
            +
               * @param {number} lon the longitude of the point (degrees).
         
     | 
| 
      
 2506 
     | 
    
         
            +
               * @description This adds an edge from the current vertex to the new vertex.
         
     | 
| 
      
 2507 
     | 
    
         
            +
               */
         
     | 
| 
      
 2508 
     | 
    
         
            +
              p.PolygonArea.prototype.AddPoint = function(lat, lon) {
         
     | 
| 
      
 2509 
     | 
    
         
            +
                var t;
         
     | 
| 
      
 2510 
     | 
    
         
            +
                if (this.num === 0) {
         
     | 
| 
      
 2511 
     | 
    
         
            +
                  this._lat0 = this.lat = lat;
         
     | 
| 
      
 2512 
     | 
    
         
            +
                  this._lon0 = this.lon = lon;
         
     | 
| 
      
 2513 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2514 
     | 
    
         
            +
                  t = this._geod.Inverse(this.lat, this.lon, lat, lon, this._mask);
         
     | 
| 
      
 2515 
     | 
    
         
            +
                  this._perimetersum.Add(t.s12);
         
     | 
| 
      
 2516 
     | 
    
         
            +
                  if (!this.polyline) {
         
     | 
| 
      
 2517 
     | 
    
         
            +
                    this._areasum.Add(t.S12);
         
     | 
| 
      
 2518 
     | 
    
         
            +
                    this._crossings += transit(this.lon, lon);
         
     | 
| 
      
 2519 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2520 
     | 
    
         
            +
                  this.lat = lat;
         
     | 
| 
      
 2521 
     | 
    
         
            +
                  this.lon = lon;
         
     | 
| 
      
 2522 
     | 
    
         
            +
                }
         
     | 
| 
      
 2523 
     | 
    
         
            +
                ++this.num;
         
     | 
| 
      
 2524 
     | 
    
         
            +
              };
         
     | 
| 
      
 2525 
     | 
    
         
            +
             
     | 
| 
      
 2526 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2527 
     | 
    
         
            +
               * @summary Add the next edge to the polygon.
         
     | 
| 
      
 2528 
     | 
    
         
            +
               * @param {number} azi the azimuth at the current the point (degrees).
         
     | 
| 
      
 2529 
     | 
    
         
            +
               * @param {number} s the length of the edge (meters).
         
     | 
| 
      
 2530 
     | 
    
         
            +
               * @description This specifies the new vertex in terms of the edge from the
         
     | 
| 
      
 2531 
     | 
    
         
            +
               *   current vertex.
         
     | 
| 
      
 2532 
     | 
    
         
            +
               */
         
     | 
| 
      
 2533 
     | 
    
         
            +
              p.PolygonArea.prototype.AddEdge = function(azi, s) {
         
     | 
| 
      
 2534 
     | 
    
         
            +
                var t;
         
     | 
| 
      
 2535 
     | 
    
         
            +
                if (this.num) {
         
     | 
| 
      
 2536 
     | 
    
         
            +
                  t = this._geod.Direct(this.lat, this.lon, azi, s, this._mask);
         
     | 
| 
      
 2537 
     | 
    
         
            +
                  this._perimetersum.Add(s);
         
     | 
| 
      
 2538 
     | 
    
         
            +
                  if (!this.polyline) {
         
     | 
| 
      
 2539 
     | 
    
         
            +
                    this._areasum.Add(t.S12);
         
     | 
| 
      
 2540 
     | 
    
         
            +
                    this._crossings += transitdirect(this.lon, t.lon2);
         
     | 
| 
      
 2541 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2542 
     | 
    
         
            +
                  this.lat = t.lat2;
         
     | 
| 
      
 2543 
     | 
    
         
            +
                  this.lon = t.lon2;
         
     | 
| 
      
 2544 
     | 
    
         
            +
                }
         
     | 
| 
      
 2545 
     | 
    
         
            +
                ++this.num;
         
     | 
| 
      
 2546 
     | 
    
         
            +
              };
         
     | 
| 
      
 2547 
     | 
    
         
            +
             
     | 
| 
      
 2548 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2549 
     | 
    
         
            +
               * @summary Compute the perimeter and area of the polygon.
         
     | 
| 
      
 2550 
     | 
    
         
            +
               * @param {bool} reverse if true then clockwise (instead of
         
     | 
| 
      
 2551 
     | 
    
         
            +
               *   counter-clockwise) traversal counts as a positive area.
         
     | 
| 
      
 2552 
     | 
    
         
            +
               * @param {bool} sign if true then return a signed result for the area if the
         
     | 
| 
      
 2553 
     | 
    
         
            +
               *   polygon is traversed in the "wrong" direction instead of returning the
         
     | 
| 
      
 2554 
     | 
    
         
            +
               *   area for the rest of the earth.
         
     | 
| 
      
 2555 
     | 
    
         
            +
               * @returns {object} r where r.number is the number of vertices, r.perimeter
         
     | 
| 
      
 2556 
     | 
    
         
            +
               *   is the perimeter (meters), and r.area (only returned if polyline is
         
     | 
| 
      
 2557 
     | 
    
         
            +
               *   false) is the area (meters<sup>2</sup>).
         
     | 
| 
      
 2558 
     | 
    
         
            +
               * @description If the object is a polygon (and not a polygon), the perimeter
         
     | 
| 
      
 2559 
     | 
    
         
            +
               *   includes the length of a final edge connecting the current point to the
         
     | 
| 
      
 2560 
     | 
    
         
            +
               *   initial point.  If the object is a polyline, then area is nan.  More
         
     | 
| 
      
 2561 
     | 
    
         
            +
               *   points can be added to the polygon after this call.
         
     | 
| 
      
 2562 
     | 
    
         
            +
               */
         
     | 
| 
      
 2563 
     | 
    
         
            +
              p.PolygonArea.prototype.Compute = function(reverse, sign) {
         
     | 
| 
      
 2564 
     | 
    
         
            +
                var vals = {number: this.num}, t, tempsum, crossings;
         
     | 
| 
      
 2565 
     | 
    
         
            +
                if (this.num < 2) {
         
     | 
| 
      
 2566 
     | 
    
         
            +
                  vals.perimeter = 0;
         
     | 
| 
      
 2567 
     | 
    
         
            +
                  if (!this.polyline)
         
     | 
| 
      
 2568 
     | 
    
         
            +
                    vals.area = 0;
         
     | 
| 
      
 2569 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2570 
     | 
    
         
            +
                }
         
     | 
| 
      
 2571 
     | 
    
         
            +
                if (this.polyline) {
         
     | 
| 
      
 2572 
     | 
    
         
            +
                  vals.perimeter = this._perimetersum.Sum();
         
     | 
| 
      
 2573 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2574 
     | 
    
         
            +
                }
         
     | 
| 
      
 2575 
     | 
    
         
            +
                t = this._geod.Inverse(this.lat, this.lon, this._lat0, this._lon0,
         
     | 
| 
      
 2576 
     | 
    
         
            +
                                       this._mask);
         
     | 
| 
      
 2577 
     | 
    
         
            +
                vals.perimeter = this._perimetersum.Sum(t.s12);
         
     | 
| 
      
 2578 
     | 
    
         
            +
                tempsum = new a.Accumulator(this._areasum);
         
     | 
| 
      
 2579 
     | 
    
         
            +
                tempsum.Add(t.S12);
         
     | 
| 
      
 2580 
     | 
    
         
            +
                crossings = this._crossings + transit(this.lon, this._lon0);
         
     | 
| 
      
 2581 
     | 
    
         
            +
                if (crossings & 1)
         
     | 
| 
      
 2582 
     | 
    
         
            +
                  tempsum.Add( (tempsum.Sum() < 0 ? 1 : -1) * this._area0/2 );
         
     | 
| 
      
 2583 
     | 
    
         
            +
                // area is with the clockwise sense.  If !reverse convert to
         
     | 
| 
      
 2584 
     | 
    
         
            +
                // counter-clockwise convention.
         
     | 
| 
      
 2585 
     | 
    
         
            +
                if (!reverse)
         
     | 
| 
      
 2586 
     | 
    
         
            +
                  tempsum.Negate();
         
     | 
| 
      
 2587 
     | 
    
         
            +
                // If sign put area in (-area0/2, area0/2], else put area in [0, area0)
         
     | 
| 
      
 2588 
     | 
    
         
            +
                if (sign) {
         
     | 
| 
      
 2589 
     | 
    
         
            +
                  if (tempsum.Sum() > this._area0/2)
         
     | 
| 
      
 2590 
     | 
    
         
            +
                    tempsum.Add( -this._area0 );
         
     | 
| 
      
 2591 
     | 
    
         
            +
                  else if (tempsum.Sum() <= -this._area0/2)
         
     | 
| 
      
 2592 
     | 
    
         
            +
                    tempsum.Add( +this._area0 );
         
     | 
| 
      
 2593 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2594 
     | 
    
         
            +
                  if (tempsum.Sum() >= this._area0)
         
     | 
| 
      
 2595 
     | 
    
         
            +
                    tempsum.Add( -this._area0 );
         
     | 
| 
      
 2596 
     | 
    
         
            +
                  else if (tempsum < 0)
         
     | 
| 
      
 2597 
     | 
    
         
            +
                    tempsum.Add( -this._area0 );
         
     | 
| 
      
 2598 
     | 
    
         
            +
                }
         
     | 
| 
      
 2599 
     | 
    
         
            +
                vals.area = tempsum.Sum();
         
     | 
| 
      
 2600 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 2601 
     | 
    
         
            +
              };
         
     | 
| 
      
 2602 
     | 
    
         
            +
             
     | 
| 
      
 2603 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2604 
     | 
    
         
            +
               * @summary Compute the perimeter and area of the polygon with a tentative
         
     | 
| 
      
 2605 
     | 
    
         
            +
               *   new vertex.
         
     | 
| 
      
 2606 
     | 
    
         
            +
               * @param {number} lat the latitude of the point (degrees).
         
     | 
| 
      
 2607 
     | 
    
         
            +
               * @param {number} lon the longitude of the point (degrees).
         
     | 
| 
      
 2608 
     | 
    
         
            +
               * @param {bool} reverse if true then clockwise (instead of
         
     | 
| 
      
 2609 
     | 
    
         
            +
               *   counter-clockwise) traversal counts as a positive area.
         
     | 
| 
      
 2610 
     | 
    
         
            +
               * @param {bool} sign if true then return a signed result for the area if the
         
     | 
| 
      
 2611 
     | 
    
         
            +
               *   polygon is traversed in the "wrong" direction instead of returning the
         
     | 
| 
      
 2612 
     | 
    
         
            +
               * @returns {object} r where r.number is the number of vertices, r.perimeter
         
     | 
| 
      
 2613 
     | 
    
         
            +
               *   is the perimeter (meters), and r.area (only returned if polyline is
         
     | 
| 
      
 2614 
     | 
    
         
            +
               *   false) is the area (meters<sup>2</sup>).
         
     | 
| 
      
 2615 
     | 
    
         
            +
               * @description A new vertex is *not* added to the polygon.
         
     | 
| 
      
 2616 
     | 
    
         
            +
               */
         
     | 
| 
      
 2617 
     | 
    
         
            +
              p.PolygonArea.prototype.TestPoint = function(lat, lon, reverse, sign) {
         
     | 
| 
      
 2618 
     | 
    
         
            +
                var vals = {number: this.num + 1}, t, tempsum, crossings, i;
         
     | 
| 
      
 2619 
     | 
    
         
            +
                if (this.num === 0) {
         
     | 
| 
      
 2620 
     | 
    
         
            +
                  vals.perimeter = 0;
         
     | 
| 
      
 2621 
     | 
    
         
            +
                  if (!this.polyline)
         
     | 
| 
      
 2622 
     | 
    
         
            +
                    vals.area = 0;
         
     | 
| 
      
 2623 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2624 
     | 
    
         
            +
                }
         
     | 
| 
      
 2625 
     | 
    
         
            +
                vals.perimeter = this._perimetersum.Sum();
         
     | 
| 
      
 2626 
     | 
    
         
            +
                tempsum = this.polyline ? 0 : this._areasum.Sum();
         
     | 
| 
      
 2627 
     | 
    
         
            +
                crossings = this._crossings;
         
     | 
| 
      
 2628 
     | 
    
         
            +
                for (i = 0; i < (this.polyline ? 1 : 2); ++i) {
         
     | 
| 
      
 2629 
     | 
    
         
            +
                  t = this._geod.Inverse(
         
     | 
| 
      
 2630 
     | 
    
         
            +
                   i === 0 ? this.lat : lat, i === 0 ? this.lon : lon,
         
     | 
| 
      
 2631 
     | 
    
         
            +
                   i !== 0 ? this._lat0 : lat, i !== 0 ? this._lon0 : lon,
         
     | 
| 
      
 2632 
     | 
    
         
            +
                   this._mask);
         
     | 
| 
      
 2633 
     | 
    
         
            +
                  vals.perimeter += t.s12;
         
     | 
| 
      
 2634 
     | 
    
         
            +
                  if (!this.polyline) {
         
     | 
| 
      
 2635 
     | 
    
         
            +
                    tempsum += t.S12;
         
     | 
| 
      
 2636 
     | 
    
         
            +
                    crossings += transit(i === 0 ? this.lon : lon,
         
     | 
| 
      
 2637 
     | 
    
         
            +
                                           i !== 0 ? this._lon0 : lon);
         
     | 
| 
      
 2638 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2639 
     | 
    
         
            +
                }
         
     | 
| 
      
 2640 
     | 
    
         
            +
             
     | 
| 
      
 2641 
     | 
    
         
            +
                if (this.polyline)
         
     | 
| 
      
 2642 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2643 
     | 
    
         
            +
             
     | 
| 
      
 2644 
     | 
    
         
            +
                if (crossings & 1)
         
     | 
| 
      
 2645 
     | 
    
         
            +
                  tempsum += (tempsum < 0 ? 1 : -1) * this._area0/2;
         
     | 
| 
      
 2646 
     | 
    
         
            +
                // area is with the clockwise sense.  If !reverse convert to
         
     | 
| 
      
 2647 
     | 
    
         
            +
                // counter-clockwise convention.
         
     | 
| 
      
 2648 
     | 
    
         
            +
                if (!reverse)
         
     | 
| 
      
 2649 
     | 
    
         
            +
                  tempsum *= -1;
         
     | 
| 
      
 2650 
     | 
    
         
            +
                // If sign put area in (-area0/2, area0/2], else put area in [0, area0)
         
     | 
| 
      
 2651 
     | 
    
         
            +
                if (sign) {
         
     | 
| 
      
 2652 
     | 
    
         
            +
                  if (tempsum > this._area0/2)
         
     | 
| 
      
 2653 
     | 
    
         
            +
                    tempsum -= this._area0;
         
     | 
| 
      
 2654 
     | 
    
         
            +
                  else if (tempsum <= -this._area0/2)
         
     | 
| 
      
 2655 
     | 
    
         
            +
                    tempsum += this._area0;
         
     | 
| 
      
 2656 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2657 
     | 
    
         
            +
                  if (tempsum >= this._area0)
         
     | 
| 
      
 2658 
     | 
    
         
            +
                    tempsum -= this._area0;
         
     | 
| 
      
 2659 
     | 
    
         
            +
                  else if (tempsum < 0)
         
     | 
| 
      
 2660 
     | 
    
         
            +
                    tempsum += this._area0;
         
     | 
| 
      
 2661 
     | 
    
         
            +
                }
         
     | 
| 
      
 2662 
     | 
    
         
            +
                vals.area = tempsum;
         
     | 
| 
      
 2663 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 2664 
     | 
    
         
            +
              };
         
     | 
| 
      
 2665 
     | 
    
         
            +
             
     | 
| 
      
 2666 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2667 
     | 
    
         
            +
               * @summary Compute the perimeter and area of the polygon with a tentative
         
     | 
| 
      
 2668 
     | 
    
         
            +
               *   new edge.
         
     | 
| 
      
 2669 
     | 
    
         
            +
               * @param {number} azi the azimuth of the edge (degrees).
         
     | 
| 
      
 2670 
     | 
    
         
            +
               * @param {number} s the length of the edge (meters).
         
     | 
| 
      
 2671 
     | 
    
         
            +
               * @param {bool} reverse if true then clockwise (instead of
         
     | 
| 
      
 2672 
     | 
    
         
            +
               *   counter-clockwise) traversal counts as a positive area.
         
     | 
| 
      
 2673 
     | 
    
         
            +
               * @param {bool} sign if true then return a signed result for the area if the
         
     | 
| 
      
 2674 
     | 
    
         
            +
               *   polygon is traversed in the "wrong" direction instead of returning the
         
     | 
| 
      
 2675 
     | 
    
         
            +
               * @returns {object} r where r.number is the number of vertices, r.perimeter
         
     | 
| 
      
 2676 
     | 
    
         
            +
               *   is the perimeter (meters), and r.area (only returned if polyline is
         
     | 
| 
      
 2677 
     | 
    
         
            +
               *   false) is the area (meters<sup>2</sup>).
         
     | 
| 
      
 2678 
     | 
    
         
            +
               * @description A new vertex is *not* added to the polygon.
         
     | 
| 
      
 2679 
     | 
    
         
            +
               */
         
     | 
| 
      
 2680 
     | 
    
         
            +
              p.PolygonArea.prototype.TestEdge = function(azi, s, reverse, sign) {
         
     | 
| 
      
 2681 
     | 
    
         
            +
                var vals = {number: this.num ? this.num + 1 : 0}, t, tempsum, crossings;
         
     | 
| 
      
 2682 
     | 
    
         
            +
                if (this.num === 0)
         
     | 
| 
      
 2683 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2684 
     | 
    
         
            +
                vals.perimeter = this._perimetersum.Sum() + s;
         
     | 
| 
      
 2685 
     | 
    
         
            +
                if (this.polyline)
         
     | 
| 
      
 2686 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 2687 
     | 
    
         
            +
             
     | 
| 
      
 2688 
     | 
    
         
            +
                tempsum = this._areasum.Sum();
         
     | 
| 
      
 2689 
     | 
    
         
            +
                crossings = this._crossings;
         
     | 
| 
      
 2690 
     | 
    
         
            +
                t = this._geod.Direct(this.lat, this.lon, azi, s, this._mask);
         
     | 
| 
      
 2691 
     | 
    
         
            +
                tempsum += t.S12;
         
     | 
| 
      
 2692 
     | 
    
         
            +
                crossings += transitdirect(this.lon, t.lon2);
         
     | 
| 
      
 2693 
     | 
    
         
            +
                t = this._geod.Inverse(t.lat2, t.lon2, this._lat0, this._lon0, this._mask);
         
     | 
| 
      
 2694 
     | 
    
         
            +
                vals.perimeter += t.s12;
         
     | 
| 
      
 2695 
     | 
    
         
            +
                tempsum += t.S12;
         
     | 
| 
      
 2696 
     | 
    
         
            +
                crossings += transit(t.lon2, this._lon0);
         
     | 
| 
      
 2697 
     | 
    
         
            +
             
     | 
| 
      
 2698 
     | 
    
         
            +
                if (crossings & 1)
         
     | 
| 
      
 2699 
     | 
    
         
            +
                  tempsum += (tempsum < 0 ? 1 : -1) * this._area0/2;
         
     | 
| 
      
 2700 
     | 
    
         
            +
                // area is with the clockwise sense.  If !reverse convert to
         
     | 
| 
      
 2701 
     | 
    
         
            +
                // counter-clockwise convention.
         
     | 
| 
      
 2702 
     | 
    
         
            +
                if (!reverse)
         
     | 
| 
      
 2703 
     | 
    
         
            +
                  tempsum *= -1;
         
     | 
| 
      
 2704 
     | 
    
         
            +
                // If sign put area in (-area0/2, area0/2], else put area in [0, area0)
         
     | 
| 
      
 2705 
     | 
    
         
            +
                if (sign) {
         
     | 
| 
      
 2706 
     | 
    
         
            +
                  if (tempsum > this._area0/2)
         
     | 
| 
      
 2707 
     | 
    
         
            +
                    tempsum -= this._area0;
         
     | 
| 
      
 2708 
     | 
    
         
            +
                  else if (tempsum <= -this._area0/2)
         
     | 
| 
      
 2709 
     | 
    
         
            +
                    tempsum += this._area0;
         
     | 
| 
      
 2710 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2711 
     | 
    
         
            +
                  if (tempsum >= this._area0)
         
     | 
| 
      
 2712 
     | 
    
         
            +
                    tempsum -= this._area0;
         
     | 
| 
      
 2713 
     | 
    
         
            +
                  else if (tempsum < 0)
         
     | 
| 
      
 2714 
     | 
    
         
            +
                    tempsum += this._area0;
         
     | 
| 
      
 2715 
     | 
    
         
            +
                }
         
     | 
| 
      
 2716 
     | 
    
         
            +
                vals.area = tempsum;
         
     | 
| 
      
 2717 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 2718 
     | 
    
         
            +
              };
         
     | 
| 
      
 2719 
     | 
    
         
            +
             
     | 
| 
      
 2720 
     | 
    
         
            +
            })(GeographicLib.PolygonArea, GeographicLib.Geodesic,
         
     | 
| 
      
 2721 
     | 
    
         
            +
               GeographicLib.Math, GeographicLib.Accumulator);
         
     | 
| 
      
 2722 
     | 
    
         
            +
             
     | 
| 
      
 2723 
     | 
    
         
            +
            /**************** DMS.js ****************/
         
     | 
| 
      
 2724 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2725 
     | 
    
         
            +
             * DMS.js
         
     | 
| 
      
 2726 
     | 
    
         
            +
             * Transcription of DMS.[ch]pp into JavaScript.
         
     | 
| 
      
 2727 
     | 
    
         
            +
             *
         
     | 
| 
      
 2728 
     | 
    
         
            +
             * See the documentation for the C++ class.  The conversion is a literal
         
     | 
| 
      
 2729 
     | 
    
         
            +
             * conversion from C++.
         
     | 
| 
      
 2730 
     | 
    
         
            +
             *
         
     | 
| 
      
 2731 
     | 
    
         
            +
             * Copyright (c) Charles Karney (2011-2017) <charles@karney.com> and licensed
         
     | 
| 
      
 2732 
     | 
    
         
            +
             * under the MIT/X11 License.  For more information, see
         
     | 
| 
      
 2733 
     | 
    
         
            +
             * https://geographiclib.sourceforge.io/
         
     | 
| 
      
 2734 
     | 
    
         
            +
             */
         
     | 
| 
      
 2735 
     | 
    
         
            +
             
     | 
| 
      
 2736 
     | 
    
         
            +
            GeographicLib.DMS = {};
         
     | 
| 
      
 2737 
     | 
    
         
            +
             
     | 
| 
      
 2738 
     | 
    
         
            +
            (function(
         
     | 
| 
      
 2739 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2740 
     | 
    
         
            +
               * @exports GeographicLib/DMS
         
     | 
| 
      
 2741 
     | 
    
         
            +
               * @description Decode/Encode angles expressed as degrees, minutes, and
         
     | 
| 
      
 2742 
     | 
    
         
            +
               *   seconds.  This module defines several constants:
         
     | 
| 
      
 2743 
     | 
    
         
            +
               *   - hemisphere indicator (returned by
         
     | 
| 
      
 2744 
     | 
    
         
            +
               *       {@link module:GeographicLib/DMS.Decode Decode}) and a formatting
         
     | 
| 
      
 2745 
     | 
    
         
            +
               *       indicator (used by
         
     | 
| 
      
 2746 
     | 
    
         
            +
               *       {@link module:GeographicLib/DMS.Encode Encode})
         
     | 
| 
      
 2747 
     | 
    
         
            +
               *     - NONE = 0, no designator and format as plain angle;
         
     | 
| 
      
 2748 
     | 
    
         
            +
               *     - LATITUDE = 1, a N/S designator and format as latitude;
         
     | 
| 
      
 2749 
     | 
    
         
            +
               *     - LONGITUDE = 2, an E/W designator and format as longitude;
         
     | 
| 
      
 2750 
     | 
    
         
            +
               *     - AZIMUTH = 3, format as azimuth;
         
     | 
| 
      
 2751 
     | 
    
         
            +
               *   - the specification of the trailing component in
         
     | 
| 
      
 2752 
     | 
    
         
            +
               *       {@link module:GeographicLib/DMS.Encode Encode}
         
     | 
| 
      
 2753 
     | 
    
         
            +
               *     - DEGREE;
         
     | 
| 
      
 2754 
     | 
    
         
            +
               *     - MINUTE;
         
     | 
| 
      
 2755 
     | 
    
         
            +
               *     - SECOND.
         
     | 
| 
      
 2756 
     | 
    
         
            +
               */
         
     | 
| 
      
 2757 
     | 
    
         
            +
              d) {
         
     | 
| 
      
 2758 
     | 
    
         
            +
             
     | 
| 
      
 2759 
     | 
    
         
            +
              var lookup, zerofill, internalDecode, numMatch,
         
     | 
| 
      
 2760 
     | 
    
         
            +
                  hemispheres_ = "SNWE",
         
     | 
| 
      
 2761 
     | 
    
         
            +
                  signs_ = "-+",
         
     | 
| 
      
 2762 
     | 
    
         
            +
                  digits_ = "0123456789",
         
     | 
| 
      
 2763 
     | 
    
         
            +
                  dmsindicators_ = "D'\":",
         
     | 
| 
      
 2764 
     | 
    
         
            +
                  // dmsindicatorsu_ = "\u00b0\u2032\u2033"; // Unicode variants
         
     | 
| 
      
 2765 
     | 
    
         
            +
                  dmsindicatorsu_ = "\u00b0'\"", // Use degree symbol
         
     | 
| 
      
 2766 
     | 
    
         
            +
                  components_ = ["degrees", "minutes", "seconds"];
         
     | 
| 
      
 2767 
     | 
    
         
            +
              lookup = function(s, c) {
         
     | 
| 
      
 2768 
     | 
    
         
            +
                return s.indexOf(c.toUpperCase());
         
     | 
| 
      
 2769 
     | 
    
         
            +
              };
         
     | 
| 
      
 2770 
     | 
    
         
            +
              zerofill = function(s, n) {
         
     | 
| 
      
 2771 
     | 
    
         
            +
                return String("0000").substr(0, Math.max(0, Math.min(4, n-s.length))) +
         
     | 
| 
      
 2772 
     | 
    
         
            +
                  s;
         
     | 
| 
      
 2773 
     | 
    
         
            +
              };
         
     | 
| 
      
 2774 
     | 
    
         
            +
              d.NONE = 0;
         
     | 
| 
      
 2775 
     | 
    
         
            +
              d.LATITUDE = 1;
         
     | 
| 
      
 2776 
     | 
    
         
            +
              d.LONGITUDE = 2;
         
     | 
| 
      
 2777 
     | 
    
         
            +
              d.AZIMUTH = 3;
         
     | 
| 
      
 2778 
     | 
    
         
            +
              d.DEGREE = 0;
         
     | 
| 
      
 2779 
     | 
    
         
            +
              d.MINUTE = 1;
         
     | 
| 
      
 2780 
     | 
    
         
            +
              d.SECOND = 2;
         
     | 
| 
      
 2781 
     | 
    
         
            +
             
     | 
| 
      
 2782 
     | 
    
         
            +
              /**
         
     | 
| 
      
 2783 
     | 
    
         
            +
               * @summary Decode a DMS string.
         
     | 
| 
      
 2784 
     | 
    
         
            +
               * @description The interpretation of the string is given in the
         
     | 
| 
      
 2785 
     | 
    
         
            +
               *   documentation of the corresponding function, Decode(string&, flag&)
         
     | 
| 
      
 2786 
     | 
    
         
            +
               *   in the {@link
         
     | 
| 
      
 2787 
     | 
    
         
            +
               *   https://geographiclib.sourceforge.io/html/classGeographicLib_1_1DMS.html
         
     | 
| 
      
 2788 
     | 
    
         
            +
               *   C++ DMS class}
         
     | 
| 
      
 2789 
     | 
    
         
            +
               * @param {string} dms the string.
         
     | 
| 
      
 2790 
     | 
    
         
            +
               * @returns {object} r where r.val is the decoded value (degrees) and r.ind
         
     | 
| 
      
 2791 
     | 
    
         
            +
               *   is a hemisphere designator, one of NONE, LATITUDE, LONGITUDE.
         
     | 
| 
      
 2792 
     | 
    
         
            +
               * @throws an error if the string is illegal.
         
     | 
| 
      
 2793 
     | 
    
         
            +
               */
         
     | 
| 
      
 2794 
     | 
    
         
            +
              d.Decode = function(dms) {
         
     | 
| 
      
 2795 
     | 
    
         
            +
                var dmsa = dms, end,
         
     | 
| 
      
 2796 
     | 
    
         
            +
                    v = 0, i = 0, mi, pi, vals,
         
     | 
| 
      
 2797 
     | 
    
         
            +
                    ind1 = d.NONE, ind2, p, pa, pb;
         
     | 
| 
      
 2798 
     | 
    
         
            +
                dmsa = dmsa.replace(/\u00b0/g, 'd')
         
     | 
| 
      
 2799 
     | 
    
         
            +
                      .replace(/\u00ba/g, 'd')
         
     | 
| 
      
 2800 
     | 
    
         
            +
                      .replace(/\u2070/g, 'd')
         
     | 
| 
      
 2801 
     | 
    
         
            +
                      .replace(/\u02da/g, 'd')
         
     | 
| 
      
 2802 
     | 
    
         
            +
                      .replace(/\u2032/g, '\'')
         
     | 
| 
      
 2803 
     | 
    
         
            +
                      .replace(/\u00b4/g, '\'')
         
     | 
| 
      
 2804 
     | 
    
         
            +
                      .replace(/\u2019/g, '\'')
         
     | 
| 
      
 2805 
     | 
    
         
            +
                      .replace(/\u2033/g, '"')
         
     | 
| 
      
 2806 
     | 
    
         
            +
                      .replace(/\u201d/g, '"')
         
     | 
| 
      
 2807 
     | 
    
         
            +
                      .replace(/\u2212/g, '-')
         
     | 
| 
      
 2808 
     | 
    
         
            +
                      .replace(/''/g, '"')
         
     | 
| 
      
 2809 
     | 
    
         
            +
                      .trim();
         
     | 
| 
      
 2810 
     | 
    
         
            +
                end = dmsa.length;
         
     | 
| 
      
 2811 
     | 
    
         
            +
                // p is pointer to the next piece that needs decoding
         
     | 
| 
      
 2812 
     | 
    
         
            +
                for (p = 0; p < end; p = pb, ++i) {
         
     | 
| 
      
 2813 
     | 
    
         
            +
                  pa = p;
         
     | 
| 
      
 2814 
     | 
    
         
            +
                  // Skip over initial hemisphere letter (for i == 0)
         
     | 
| 
      
 2815 
     | 
    
         
            +
                  if (i === 0 && lookup(hemispheres_, dmsa.charAt(pa)) >= 0)
         
     | 
| 
      
 2816 
     | 
    
         
            +
                    ++pa;
         
     | 
| 
      
 2817 
     | 
    
         
            +
                  // Skip over initial sign (checking for it if i == 0)
         
     | 
| 
      
 2818 
     | 
    
         
            +
                  if (i > 0 || (pa < end && lookup(signs_, dmsa.charAt(pa)) >= 0))
         
     | 
| 
      
 2819 
     | 
    
         
            +
                    ++pa;
         
     | 
| 
      
 2820 
     | 
    
         
            +
                  // Find next sign
         
     | 
| 
      
 2821 
     | 
    
         
            +
                  mi = dmsa.substr(pa, end - pa).indexOf('-');
         
     | 
| 
      
 2822 
     | 
    
         
            +
                  pi = dmsa.substr(pa, end - pa).indexOf('+');
         
     | 
| 
      
 2823 
     | 
    
         
            +
                  if (mi < 0) mi = end; else mi += pa;
         
     | 
| 
      
 2824 
     | 
    
         
            +
                  if (pi < 0) pi = end; else pi += pa;
         
     | 
| 
      
 2825 
     | 
    
         
            +
                  pb = Math.min(mi, pi);
         
     | 
| 
      
 2826 
     | 
    
         
            +
                  vals = internalDecode(dmsa.substr(p, pb - p));
         
     | 
| 
      
 2827 
     | 
    
         
            +
                  v += vals.val; ind2 = vals.ind;
         
     | 
| 
      
 2828 
     | 
    
         
            +
                  if (ind1 === d.NONE)
         
     | 
| 
      
 2829 
     | 
    
         
            +
                    ind1 = ind2;
         
     | 
| 
      
 2830 
     | 
    
         
            +
                  else if (!(ind2 === d.NONE || ind1 === ind2))
         
     | 
| 
      
 2831 
     | 
    
         
            +
                    throw new Error("Incompatible hemisphere specifies in " +
         
     | 
| 
      
 2832 
     | 
    
         
            +
                                    dmsa.substr(0, pb));
         
     | 
| 
      
 2833 
     | 
    
         
            +
                }
         
     | 
| 
      
 2834 
     | 
    
         
            +
                if (i === 0)
         
     | 
| 
      
 2835 
     | 
    
         
            +
                  throw new Error("Empty or incomplete DMS string " + dmsa);
         
     | 
| 
      
 2836 
     | 
    
         
            +
                return {val: v, ind: ind1};
         
     | 
| 
      
 2837 
     | 
    
         
            +
              };
         
     | 
| 
      
 2838 
     | 
    
         
            +
             
     | 
| 
      
 2839 
     | 
    
         
            +
              internalDecode = function(dmsa) {
         
     | 
| 
      
 2840 
     | 
    
         
            +
                var vals = {}, errormsg = "",
         
     | 
| 
      
 2841 
     | 
    
         
            +
                    sign, beg, end, ind1, k,
         
     | 
| 
      
 2842 
     | 
    
         
            +
                    ipieces, fpieces, npiece,
         
     | 
| 
      
 2843 
     | 
    
         
            +
                    icurrent, fcurrent, ncurrent, p,
         
     | 
| 
      
 2844 
     | 
    
         
            +
                    pointseen,
         
     | 
| 
      
 2845 
     | 
    
         
            +
                    digcount, intcount,
         
     | 
| 
      
 2846 
     | 
    
         
            +
                    x;
         
     | 
| 
      
 2847 
     | 
    
         
            +
                do {                       // Executed once (provides the ability to break)
         
     | 
| 
      
 2848 
     | 
    
         
            +
                  sign = 1;
         
     | 
| 
      
 2849 
     | 
    
         
            +
                  beg = 0; end = dmsa.length;
         
     | 
| 
      
 2850 
     | 
    
         
            +
                  ind1 = d.NONE;
         
     | 
| 
      
 2851 
     | 
    
         
            +
                  k = -1;
         
     | 
| 
      
 2852 
     | 
    
         
            +
                  if (end > beg && (k = lookup(hemispheres_, dmsa.charAt(beg))) >= 0) {
         
     | 
| 
      
 2853 
     | 
    
         
            +
                    ind1 = (k & 2) ? d.LONGITUDE : d.LATITUDE;
         
     | 
| 
      
 2854 
     | 
    
         
            +
                    sign = (k & 1) ? 1 : -1;
         
     | 
| 
      
 2855 
     | 
    
         
            +
                    ++beg;
         
     | 
| 
      
 2856 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2857 
     | 
    
         
            +
                  if (end > beg &&
         
     | 
| 
      
 2858 
     | 
    
         
            +
                      (k = lookup(hemispheres_, dmsa.charAt(end-1))) >= 0) {
         
     | 
| 
      
 2859 
     | 
    
         
            +
                    if (k >= 0) {
         
     | 
| 
      
 2860 
     | 
    
         
            +
                      if (ind1 !== d.NONE) {
         
     | 
| 
      
 2861 
     | 
    
         
            +
                        if (dmsa.charAt(beg - 1).toUpperCase() ===
         
     | 
| 
      
 2862 
     | 
    
         
            +
                            dmsa.charAt(end - 1).toUpperCase())
         
     | 
| 
      
 2863 
     | 
    
         
            +
                          errormsg = "Repeated hemisphere indicators " +
         
     | 
| 
      
 2864 
     | 
    
         
            +
                          dmsa.charAt(beg - 1) + " in " +
         
     | 
| 
      
 2865 
     | 
    
         
            +
                          dmsa.substr(beg - 1, end - beg + 1);
         
     | 
| 
      
 2866 
     | 
    
         
            +
                        else
         
     | 
| 
      
 2867 
     | 
    
         
            +
                          errormsg = "Contradictory hemisphere indicators " +
         
     | 
| 
      
 2868 
     | 
    
         
            +
                          dmsa.charAt(beg - 1) + " and " + dmsa.charAt(end - 1) + " in " +
         
     | 
| 
      
 2869 
     | 
    
         
            +
                          dmsa.substr(beg - 1, end - beg + 1);
         
     | 
| 
      
 2870 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 2871 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2872 
     | 
    
         
            +
                      ind1 = (k & 2) ? d.LONGITUDE : d.LATITUDE;
         
     | 
| 
      
 2873 
     | 
    
         
            +
                      sign = (k & 1) ? 1 : -1;
         
     | 
| 
      
 2874 
     | 
    
         
            +
                      --end;
         
     | 
| 
      
 2875 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2876 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2877 
     | 
    
         
            +
                  if (end > beg && (k = lookup(signs_, dmsa.charAt(beg))) >= 0) {
         
     | 
| 
      
 2878 
     | 
    
         
            +
                    if (k >= 0) {
         
     | 
| 
      
 2879 
     | 
    
         
            +
                      sign *= k ? 1 : -1;
         
     | 
| 
      
 2880 
     | 
    
         
            +
                      ++beg;
         
     | 
| 
      
 2881 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2882 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2883 
     | 
    
         
            +
                  if (end === beg) {
         
     | 
| 
      
 2884 
     | 
    
         
            +
                    errormsg = "Empty or incomplete DMS string " + dmsa;
         
     | 
| 
      
 2885 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2886 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2887 
     | 
    
         
            +
                  ipieces = [0, 0, 0];
         
     | 
| 
      
 2888 
     | 
    
         
            +
                  fpieces = [0, 0, 0];
         
     | 
| 
      
 2889 
     | 
    
         
            +
                  npiece = 0;
         
     | 
| 
      
 2890 
     | 
    
         
            +
                  icurrent = 0;
         
     | 
| 
      
 2891 
     | 
    
         
            +
                  fcurrent = 0;
         
     | 
| 
      
 2892 
     | 
    
         
            +
                  ncurrent = 0;
         
     | 
| 
      
 2893 
     | 
    
         
            +
                  p = beg;
         
     | 
| 
      
 2894 
     | 
    
         
            +
                  pointseen = false;
         
     | 
| 
      
 2895 
     | 
    
         
            +
                  digcount = 0;
         
     | 
| 
      
 2896 
     | 
    
         
            +
                  intcount = 0;
         
     | 
| 
      
 2897 
     | 
    
         
            +
                  while (p < end) {
         
     | 
| 
      
 2898 
     | 
    
         
            +
                    x = dmsa.charAt(p++);
         
     | 
| 
      
 2899 
     | 
    
         
            +
                    if ((k = lookup(digits_, x)) >= 0) {
         
     | 
| 
      
 2900 
     | 
    
         
            +
                      ++ncurrent;
         
     | 
| 
      
 2901 
     | 
    
         
            +
                      if (digcount > 0) {
         
     | 
| 
      
 2902 
     | 
    
         
            +
                        ++digcount;         // Count of decimal digits
         
     | 
| 
      
 2903 
     | 
    
         
            +
                      } else {
         
     | 
| 
      
 2904 
     | 
    
         
            +
                        icurrent = 10 * icurrent + k;
         
     | 
| 
      
 2905 
     | 
    
         
            +
                        ++intcount;
         
     | 
| 
      
 2906 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2907 
     | 
    
         
            +
                    } else if (x === '.') {
         
     | 
| 
      
 2908 
     | 
    
         
            +
                      if (pointseen) {
         
     | 
| 
      
 2909 
     | 
    
         
            +
                        errormsg = "Multiple decimal points in " +
         
     | 
| 
      
 2910 
     | 
    
         
            +
                          dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2911 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 2912 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2913 
     | 
    
         
            +
                      pointseen = true;
         
     | 
| 
      
 2914 
     | 
    
         
            +
                      digcount = 1;
         
     | 
| 
      
 2915 
     | 
    
         
            +
                    } else if ((k = lookup(dmsindicators_, x)) >= 0) {
         
     | 
| 
      
 2916 
     | 
    
         
            +
                      if (k >= 3) {
         
     | 
| 
      
 2917 
     | 
    
         
            +
                        if (p === end) {
         
     | 
| 
      
 2918 
     | 
    
         
            +
                          errormsg = "Illegal for colon to appear at the end of " +
         
     | 
| 
      
 2919 
     | 
    
         
            +
                            dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2920 
     | 
    
         
            +
                          break;
         
     | 
| 
      
 2921 
     | 
    
         
            +
                        }
         
     | 
| 
      
 2922 
     | 
    
         
            +
                        k = npiece;
         
     | 
| 
      
 2923 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2924 
     | 
    
         
            +
                      if (k === npiece - 1) {
         
     | 
| 
      
 2925 
     | 
    
         
            +
                        errormsg = "Repeated " + components_[k] +
         
     | 
| 
      
 2926 
     | 
    
         
            +
                          " component in " + dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2927 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 2928 
     | 
    
         
            +
                      } else if (k < npiece) {
         
     | 
| 
      
 2929 
     | 
    
         
            +
                        errormsg = components_[k] + " component follows " +
         
     | 
| 
      
 2930 
     | 
    
         
            +
                          components_[npiece - 1] + " component in " +
         
     | 
| 
      
 2931 
     | 
    
         
            +
                          dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2932 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 2933 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2934 
     | 
    
         
            +
                      if (ncurrent === 0) {
         
     | 
| 
      
 2935 
     | 
    
         
            +
                        errormsg = "Missing numbers in " + components_[k] +
         
     | 
| 
      
 2936 
     | 
    
         
            +
                          " component of " + dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2937 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 2938 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2939 
     | 
    
         
            +
                      if (digcount > 0) {
         
     | 
| 
      
 2940 
     | 
    
         
            +
                        fcurrent = parseFloat(dmsa.substr(p - intcount - digcount - 1,
         
     | 
| 
      
 2941 
     | 
    
         
            +
                                                          intcount + digcount));
         
     | 
| 
      
 2942 
     | 
    
         
            +
                        icurrent = 0;
         
     | 
| 
      
 2943 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2944 
     | 
    
         
            +
                      ipieces[k] = icurrent;
         
     | 
| 
      
 2945 
     | 
    
         
            +
                      fpieces[k] = icurrent + fcurrent;
         
     | 
| 
      
 2946 
     | 
    
         
            +
                      if (p < end) {
         
     | 
| 
      
 2947 
     | 
    
         
            +
                        npiece = k + 1;
         
     | 
| 
      
 2948 
     | 
    
         
            +
                        icurrent = fcurrent = 0;
         
     | 
| 
      
 2949 
     | 
    
         
            +
                        ncurrent = digcount = intcount = 0;
         
     | 
| 
      
 2950 
     | 
    
         
            +
                      }
         
     | 
| 
      
 2951 
     | 
    
         
            +
                    } else if (lookup(signs_, x) >= 0) {
         
     | 
| 
      
 2952 
     | 
    
         
            +
                      errormsg = "Internal sign in DMS string " +
         
     | 
| 
      
 2953 
     | 
    
         
            +
                        dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2954 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 2955 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 2956 
     | 
    
         
            +
                      errormsg = "Illegal character " + x + " in DMS string " +
         
     | 
| 
      
 2957 
     | 
    
         
            +
                        dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2958 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 2959 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2960 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2961 
     | 
    
         
            +
                  if (errormsg.length)
         
     | 
| 
      
 2962 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2963 
     | 
    
         
            +
                  if (lookup(dmsindicators_, dmsa.charAt(p - 1)) < 0) {
         
     | 
| 
      
 2964 
     | 
    
         
            +
                    if (npiece >= 3) {
         
     | 
| 
      
 2965 
     | 
    
         
            +
                      errormsg = "Extra text following seconds in DMS string " +
         
     | 
| 
      
 2966 
     | 
    
         
            +
                        dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2967 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 2968 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2969 
     | 
    
         
            +
                    if (ncurrent === 0) {
         
     | 
| 
      
 2970 
     | 
    
         
            +
                      errormsg = "Missing numbers in trailing component of " +
         
     | 
| 
      
 2971 
     | 
    
         
            +
                        dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2972 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 2973 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2974 
     | 
    
         
            +
                    if (digcount > 0) {
         
     | 
| 
      
 2975 
     | 
    
         
            +
                      fcurrent = parseFloat(dmsa.substr(p - intcount - digcount,
         
     | 
| 
      
 2976 
     | 
    
         
            +
                                                        intcount + digcount));
         
     | 
| 
      
 2977 
     | 
    
         
            +
                      icurrent = 0;
         
     | 
| 
      
 2978 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2979 
     | 
    
         
            +
                    ipieces[npiece] = icurrent;
         
     | 
| 
      
 2980 
     | 
    
         
            +
                    fpieces[npiece] = icurrent + fcurrent;
         
     | 
| 
      
 2981 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2982 
     | 
    
         
            +
                  if (pointseen && digcount === 0) {
         
     | 
| 
      
 2983 
     | 
    
         
            +
                    errormsg = "Decimal point in non-terminal component of " +
         
     | 
| 
      
 2984 
     | 
    
         
            +
                      dmsa.substr(beg, end - beg);
         
     | 
| 
      
 2985 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2986 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2987 
     | 
    
         
            +
                  // Note that we accept 59.999999... even though it rounds to 60.
         
     | 
| 
      
 2988 
     | 
    
         
            +
                  if (ipieces[1] >= 60 || fpieces[1] > 60) {
         
     | 
| 
      
 2989 
     | 
    
         
            +
                    errormsg = "Minutes " + fpieces[1] + " not in range [0,60)";
         
     | 
| 
      
 2990 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2991 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2992 
     | 
    
         
            +
                  if (ipieces[2] >= 60 || fpieces[2] > 60) {
         
     | 
| 
      
 2993 
     | 
    
         
            +
                    errormsg = "Seconds " + fpieces[2] + " not in range [0,60)";
         
     | 
| 
      
 2994 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2995 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2996 
     | 
    
         
            +
                  vals.ind = ind1;
         
     | 
| 
      
 2997 
     | 
    
         
            +
                  // Assume check on range of result is made by calling routine (which
         
     | 
| 
      
 2998 
     | 
    
         
            +
                  // might be able to offer a better diagnostic).
         
     | 
| 
      
 2999 
     | 
    
         
            +
                  vals.val = sign *
         
     | 
| 
      
 3000 
     | 
    
         
            +
                    ( fpieces[2] ? (60*(60*fpieces[0] + fpieces[1]) + fpieces[2]) / 3600 :
         
     | 
| 
      
 3001 
     | 
    
         
            +
                      ( fpieces[1] ? (60*fpieces[0] + fpieces[1]) / 60 : fpieces[0] ) );
         
     | 
| 
      
 3002 
     | 
    
         
            +
                  return vals;
         
     | 
| 
      
 3003 
     | 
    
         
            +
                } while (false);
         
     | 
| 
      
 3004 
     | 
    
         
            +
                vals.val = numMatch(dmsa);
         
     | 
| 
      
 3005 
     | 
    
         
            +
                if (vals.val === 0)
         
     | 
| 
      
 3006 
     | 
    
         
            +
                  throw new Error(errormsg);
         
     | 
| 
      
 3007 
     | 
    
         
            +
                else
         
     | 
| 
      
 3008 
     | 
    
         
            +
                  vals.ind = d.NONE;
         
     | 
| 
      
 3009 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 3010 
     | 
    
         
            +
              };
         
     | 
| 
      
 3011 
     | 
    
         
            +
             
     | 
| 
      
 3012 
     | 
    
         
            +
              numMatch = function(s) {
         
     | 
| 
      
 3013 
     | 
    
         
            +
                var t, sign, p0, p1;
         
     | 
| 
      
 3014 
     | 
    
         
            +
                if (s.length < 3)
         
     | 
| 
      
 3015 
     | 
    
         
            +
                  return 0;
         
     | 
| 
      
 3016 
     | 
    
         
            +
                t = s.toUpperCase().replace(/0+$/, "");
         
     | 
| 
      
 3017 
     | 
    
         
            +
                sign = t.charAt(0) === '-' ? -1 : 1;
         
     | 
| 
      
 3018 
     | 
    
         
            +
                p0 = t.charAt(0) === '-' || t.charAt(0) === '+' ? 1 : 0;
         
     | 
| 
      
 3019 
     | 
    
         
            +
                p1 = t.length - 1;
         
     | 
| 
      
 3020 
     | 
    
         
            +
                if (p1 + 1 < p0 + 3)
         
     | 
| 
      
 3021 
     | 
    
         
            +
                  return 0;
         
     | 
| 
      
 3022 
     | 
    
         
            +
                // Strip off sign and trailing 0s
         
     | 
| 
      
 3023 
     | 
    
         
            +
                t = t.substr(p0, p1 + 1 - p0); // Length at least 3
         
     | 
| 
      
 3024 
     | 
    
         
            +
                if (t === "NAN" || t === "1.#QNAN" || t === "1.#SNAN" || t === "1.#IND" ||
         
     | 
| 
      
 3025 
     | 
    
         
            +
                    t === "1.#R")
         
     | 
| 
      
 3026 
     | 
    
         
            +
                  return Number.NaN;
         
     | 
| 
      
 3027 
     | 
    
         
            +
                else if (t === "INF" || t === "1.#INF")
         
     | 
| 
      
 3028 
     | 
    
         
            +
                  return sign * Number.POSITIVE_INFINITY;
         
     | 
| 
      
 3029 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 3030 
     | 
    
         
            +
              };
         
     | 
| 
      
 3031 
     | 
    
         
            +
             
     | 
| 
      
 3032 
     | 
    
         
            +
              /**
         
     | 
| 
      
 3033 
     | 
    
         
            +
               * @summary Decode two DMS strings interpreting them as a latitude/longitude
         
     | 
| 
      
 3034 
     | 
    
         
            +
               *   pair.
         
     | 
| 
      
 3035 
     | 
    
         
            +
               * @param {string} stra the first string.
         
     | 
| 
      
 3036 
     | 
    
         
            +
               * @param {string} strb the first string.
         
     | 
| 
      
 3037 
     | 
    
         
            +
               * @param {bool} [longfirst = false] if true assume then longitude is given
         
     | 
| 
      
 3038 
     | 
    
         
            +
               *   first (in the absense of any hemisphere indicators).
         
     | 
| 
      
 3039 
     | 
    
         
            +
               * @returns {object} r where r.lat is the decoded latitude and r.lon is the
         
     | 
| 
      
 3040 
     | 
    
         
            +
               *   decoded longitude (both in degrees).
         
     | 
| 
      
 3041 
     | 
    
         
            +
               * @throws an error if the strings are illegal.
         
     | 
| 
      
 3042 
     | 
    
         
            +
               */
         
     | 
| 
      
 3043 
     | 
    
         
            +
              d.DecodeLatLon = function(stra, strb, longfirst) {
         
     | 
| 
      
 3044 
     | 
    
         
            +
                var vals = {},
         
     | 
| 
      
 3045 
     | 
    
         
            +
                    valsa = d.Decode(stra),
         
     | 
| 
      
 3046 
     | 
    
         
            +
                    valsb = d.Decode(strb),
         
     | 
| 
      
 3047 
     | 
    
         
            +
                    a = valsa.val, ia = valsa.ind,
         
     | 
| 
      
 3048 
     | 
    
         
            +
                    b = valsb.val, ib = valsb.ind,
         
     | 
| 
      
 3049 
     | 
    
         
            +
                    lat, lon;
         
     | 
| 
      
 3050 
     | 
    
         
            +
                if (!longfirst) longfirst = false;
         
     | 
| 
      
 3051 
     | 
    
         
            +
                if (ia === d.NONE && ib === d.NONE) {
         
     | 
| 
      
 3052 
     | 
    
         
            +
                  // Default to lat, long unless longfirst
         
     | 
| 
      
 3053 
     | 
    
         
            +
                  ia = longfirst ? d.LONGITUDE : d.LATITUDE;
         
     | 
| 
      
 3054 
     | 
    
         
            +
                  ib = longfirst ? d.LATITUDE : d.LONGITUDE;
         
     | 
| 
      
 3055 
     | 
    
         
            +
                } else if (ia === d.NONE)
         
     | 
| 
      
 3056 
     | 
    
         
            +
                  ia = d.LATITUDE + d.LONGITUDE - ib;
         
     | 
| 
      
 3057 
     | 
    
         
            +
                else if (ib === d.NONE)
         
     | 
| 
      
 3058 
     | 
    
         
            +
                  ib = d.LATITUDE + d.LONGITUDE - ia;
         
     | 
| 
      
 3059 
     | 
    
         
            +
                if (ia === ib)
         
     | 
| 
      
 3060 
     | 
    
         
            +
                  throw new Error("Both " + stra + " and " + strb + " interpreted as " +
         
     | 
| 
      
 3061 
     | 
    
         
            +
                                  (ia === d.LATITUDE ? "latitudes" : "longitudes"));
         
     | 
| 
      
 3062 
     | 
    
         
            +
                lat = ia === d.LATITUDE ? a : b;
         
     | 
| 
      
 3063 
     | 
    
         
            +
                lon = ia === d.LATITUDE ? b : a;
         
     | 
| 
      
 3064 
     | 
    
         
            +
                if (Math.abs(lat) > 90)
         
     | 
| 
      
 3065 
     | 
    
         
            +
                  throw new Error("Latitude " + lat + " not in [-90,90]");
         
     | 
| 
      
 3066 
     | 
    
         
            +
                vals.lat = lat;
         
     | 
| 
      
 3067 
     | 
    
         
            +
                vals.lon = lon;
         
     | 
| 
      
 3068 
     | 
    
         
            +
                return vals;
         
     | 
| 
      
 3069 
     | 
    
         
            +
              };
         
     | 
| 
      
 3070 
     | 
    
         
            +
             
     | 
| 
      
 3071 
     | 
    
         
            +
              /**
         
     | 
| 
      
 3072 
     | 
    
         
            +
               * @summary Decode a DMS string interpreting it as an arc length.
         
     | 
| 
      
 3073 
     | 
    
         
            +
               * @param {string} angstr the string (this must not include a hemisphere
         
     | 
| 
      
 3074 
     | 
    
         
            +
               *   indicator).
         
     | 
| 
      
 3075 
     | 
    
         
            +
               * @returns {number} the arc length (degrees).
         
     | 
| 
      
 3076 
     | 
    
         
            +
               * @throws an error if the string is illegal.
         
     | 
| 
      
 3077 
     | 
    
         
            +
               */
         
     | 
| 
      
 3078 
     | 
    
         
            +
              d.DecodeAngle = function(angstr) {
         
     | 
| 
      
 3079 
     | 
    
         
            +
                var vals = d.Decode(angstr),
         
     | 
| 
      
 3080 
     | 
    
         
            +
                    ang = vals.val, ind = vals.ind;
         
     | 
| 
      
 3081 
     | 
    
         
            +
                if (ind !== d.NONE)
         
     | 
| 
      
 3082 
     | 
    
         
            +
                  throw new Error("Arc angle " + angstr +
         
     | 
| 
      
 3083 
     | 
    
         
            +
                                  " includes a hemisphere N/E/W/S");
         
     | 
| 
      
 3084 
     | 
    
         
            +
                return ang;
         
     | 
| 
      
 3085 
     | 
    
         
            +
              };
         
     | 
| 
      
 3086 
     | 
    
         
            +
             
     | 
| 
      
 3087 
     | 
    
         
            +
              /**
         
     | 
| 
      
 3088 
     | 
    
         
            +
               * @summary Decode a DMS string interpreting it as an azimuth.
         
     | 
| 
      
 3089 
     | 
    
         
            +
               * @param {string} azistr the string (this may include an E/W hemisphere
         
     | 
| 
      
 3090 
     | 
    
         
            +
               *   indicator).
         
     | 
| 
      
 3091 
     | 
    
         
            +
               * @returns {number} the azimuth (degrees).
         
     | 
| 
      
 3092 
     | 
    
         
            +
               * @throws an error if the string is illegal.
         
     | 
| 
      
 3093 
     | 
    
         
            +
               */
         
     | 
| 
      
 3094 
     | 
    
         
            +
              d.DecodeAzimuth = function(azistr) {
         
     | 
| 
      
 3095 
     | 
    
         
            +
                var vals = d.Decode(azistr),
         
     | 
| 
      
 3096 
     | 
    
         
            +
                    azi = vals.val, ind = vals.ind;
         
     | 
| 
      
 3097 
     | 
    
         
            +
                if (ind === d.LATITUDE)
         
     | 
| 
      
 3098 
     | 
    
         
            +
                  throw new Error("Azimuth " + azistr + " has a latitude hemisphere N/S");
         
     | 
| 
      
 3099 
     | 
    
         
            +
                return azi;
         
     | 
| 
      
 3100 
     | 
    
         
            +
              };
         
     | 
| 
      
 3101 
     | 
    
         
            +
             
     | 
| 
      
 3102 
     | 
    
         
            +
              /**
         
     | 
| 
      
 3103 
     | 
    
         
            +
               * @summary Convert angle (in degrees) into a DMS string (using °, ',
         
     | 
| 
      
 3104 
     | 
    
         
            +
               *  and ").
         
     | 
| 
      
 3105 
     | 
    
         
            +
               * @param {number} angle input angle (degrees).
         
     | 
| 
      
 3106 
     | 
    
         
            +
               * @param {number} trailing one of DEGREE, MINUTE, or SECOND to indicate
         
     | 
| 
      
 3107 
     | 
    
         
            +
               *   the trailing component of the string (this component is given as a
         
     | 
| 
      
 3108 
     | 
    
         
            +
               *   decimal number if necessary).
         
     | 
| 
      
 3109 
     | 
    
         
            +
               * @param {number} prec the number of digits after the decimal point for
         
     | 
| 
      
 3110 
     | 
    
         
            +
               *   the trailing component.
         
     | 
| 
      
 3111 
     | 
    
         
            +
               * @param {number} [ind = NONE] a formatting indicator, one of NONE,
         
     | 
| 
      
 3112 
     | 
    
         
            +
               *   LATITUDE, LONGITUDE, AZIMUTH.
         
     | 
| 
      
 3113 
     | 
    
         
            +
               * @returns {string} the resulting string formatted as follows:
         
     | 
| 
      
 3114 
     | 
    
         
            +
               *   * NONE, signed result no leading zeros on degrees except in the units
         
     | 
| 
      
 3115 
     | 
    
         
            +
               *     place, e.g., -8°03'.
         
     | 
| 
      
 3116 
     | 
    
         
            +
               *   * LATITUDE, trailing N or S hemisphere designator, no sign, pad
         
     | 
| 
      
 3117 
     | 
    
         
            +
               *     degrees to 2 digits, e.g., 08°03'S.
         
     | 
| 
      
 3118 
     | 
    
         
            +
               *   * LONGITUDE, trailing E or W hemisphere designator, no sign, pad
         
     | 
| 
      
 3119 
     | 
    
         
            +
               *     degrees to 3 digits, e.g., 008°03'W.
         
     | 
| 
      
 3120 
     | 
    
         
            +
               *   * AZIMUTH, convert to the range [0, 360°), no sign, pad degrees to
         
     | 
| 
      
 3121 
     | 
    
         
            +
               *     3 digits, e.g., 351°57'.
         
     | 
| 
      
 3122 
     | 
    
         
            +
               */
         
     | 
| 
      
 3123 
     | 
    
         
            +
              d.Encode = function(angle, trailing, prec, ind) {
         
     | 
| 
      
 3124 
     | 
    
         
            +
                // Assume check on range of input angle has been made by calling
         
     | 
| 
      
 3125 
     | 
    
         
            +
                // routine (which might be able to offer a better diagnostic).
         
     | 
| 
      
 3126 
     | 
    
         
            +
                var scale = 1, i, sign,
         
     | 
| 
      
 3127 
     | 
    
         
            +
                    idegree, fdegree, f, pieces, ip, fp, s;
         
     | 
| 
      
 3128 
     | 
    
         
            +
                if (!ind) ind = d.NONE;
         
     | 
| 
      
 3129 
     | 
    
         
            +
                if (!isFinite(angle))
         
     | 
| 
      
 3130 
     | 
    
         
            +
                  return angle < 0 ? String("-inf") :
         
     | 
| 
      
 3131 
     | 
    
         
            +
                  (angle > 0 ? String("inf") : String("nan"));
         
     | 
| 
      
 3132 
     | 
    
         
            +
             
     | 
| 
      
 3133 
     | 
    
         
            +
                // 15 - 2 * trailing = ceiling(log10(2^53/90/60^trailing)).
         
     | 
| 
      
 3134 
     | 
    
         
            +
                // This suffices to give full real precision for numbers in [-90,90]
         
     | 
| 
      
 3135 
     | 
    
         
            +
                prec = Math.min(15 - 2 * trailing, prec);
         
     | 
| 
      
 3136 
     | 
    
         
            +
                for (i = 0; i < trailing; ++i)
         
     | 
| 
      
 3137 
     | 
    
         
            +
                  scale *= 60;
         
     | 
| 
      
 3138 
     | 
    
         
            +
                for (i = 0; i < prec; ++i)
         
     | 
| 
      
 3139 
     | 
    
         
            +
                  scale *= 10;
         
     | 
| 
      
 3140 
     | 
    
         
            +
                if (ind === d.AZIMUTH)
         
     | 
| 
      
 3141 
     | 
    
         
            +
                  angle -= Math.floor(angle/360) * 360;
         
     | 
| 
      
 3142 
     | 
    
         
            +
                sign = angle < 0 ? -1 : 1;
         
     | 
| 
      
 3143 
     | 
    
         
            +
                angle *= sign;
         
     | 
| 
      
 3144 
     | 
    
         
            +
             
     | 
| 
      
 3145 
     | 
    
         
            +
                // Break off integer part to preserve precision in manipulation of
         
     | 
| 
      
 3146 
     | 
    
         
            +
                // fractional part.
         
     | 
| 
      
 3147 
     | 
    
         
            +
                idegree = Math.floor(angle);
         
     | 
| 
      
 3148 
     | 
    
         
            +
                fdegree = (angle - idegree) * scale + 0.5;
         
     | 
| 
      
 3149 
     | 
    
         
            +
                f = Math.floor(fdegree);
         
     | 
| 
      
 3150 
     | 
    
         
            +
                // Implement the "round ties to even" rule
         
     | 
| 
      
 3151 
     | 
    
         
            +
                fdegree = (f === fdegree && (f & 1) === 1) ? f - 1 : f;
         
     | 
| 
      
 3152 
     | 
    
         
            +
                fdegree /= scale;
         
     | 
| 
      
 3153 
     | 
    
         
            +
             
     | 
| 
      
 3154 
     | 
    
         
            +
                fdegree = Math.floor((angle - idegree) * scale + 0.5) / scale;
         
     | 
| 
      
 3155 
     | 
    
         
            +
                if (fdegree >= 1) {
         
     | 
| 
      
 3156 
     | 
    
         
            +
                  idegree += 1;
         
     | 
| 
      
 3157 
     | 
    
         
            +
                  fdegree -= 1;
         
     | 
| 
      
 3158 
     | 
    
         
            +
                }
         
     | 
| 
      
 3159 
     | 
    
         
            +
                pieces = [fdegree, 0, 0];
         
     | 
| 
      
 3160 
     | 
    
         
            +
                for (i = 1; i <= trailing; ++i) {
         
     | 
| 
      
 3161 
     | 
    
         
            +
                  ip = Math.floor(pieces[i - 1]);
         
     | 
| 
      
 3162 
     | 
    
         
            +
                  fp = pieces[i - 1] - ip;
         
     | 
| 
      
 3163 
     | 
    
         
            +
                  pieces[i] = fp * 60;
         
     | 
| 
      
 3164 
     | 
    
         
            +
                  pieces[i - 1] = ip;
         
     | 
| 
      
 3165 
     | 
    
         
            +
                }
         
     | 
| 
      
 3166 
     | 
    
         
            +
                pieces[0] += idegree;
         
     | 
| 
      
 3167 
     | 
    
         
            +
                s = "";
         
     | 
| 
      
 3168 
     | 
    
         
            +
                if (ind === d.NONE && sign < 0)
         
     | 
| 
      
 3169 
     | 
    
         
            +
                  s += '-';
         
     | 
| 
      
 3170 
     | 
    
         
            +
                switch (trailing) {
         
     | 
| 
      
 3171 
     | 
    
         
            +
                case d.DEGREE:
         
     | 
| 
      
 3172 
     | 
    
         
            +
                  s += zerofill(pieces[0].toFixed(prec),
         
     | 
| 
      
 3173 
     | 
    
         
            +
                                ind === d.NONE ? 0 :
         
     | 
| 
      
 3174 
     | 
    
         
            +
                                1 + Math.min(ind, 2) + prec + (prec ? 1 : 0)) +
         
     | 
| 
      
 3175 
     | 
    
         
            +
                    dmsindicatorsu_.charAt(0);
         
     | 
| 
      
 3176 
     | 
    
         
            +
                  break;
         
     | 
| 
      
 3177 
     | 
    
         
            +
                default:
         
     | 
| 
      
 3178 
     | 
    
         
            +
                  s += zerofill(pieces[0].toFixed(0),
         
     | 
| 
      
 3179 
     | 
    
         
            +
                                ind === d.NONE ? 0 : 1 + Math.min(ind, 2)) +
         
     | 
| 
      
 3180 
     | 
    
         
            +
                    dmsindicatorsu_.charAt(0);
         
     | 
| 
      
 3181 
     | 
    
         
            +
                  switch (trailing) {
         
     | 
| 
      
 3182 
     | 
    
         
            +
                  case d.MINUTE:
         
     | 
| 
      
 3183 
     | 
    
         
            +
                    s += zerofill(pieces[1].toFixed(prec), 2 + prec + (prec ? 1 : 0)) +
         
     | 
| 
      
 3184 
     | 
    
         
            +
                      dmsindicatorsu_.charAt(1);
         
     | 
| 
      
 3185 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 3186 
     | 
    
         
            +
                  case d.SECOND:
         
     | 
| 
      
 3187 
     | 
    
         
            +
                    s += zerofill(pieces[1].toFixed(0), 2) + dmsindicatorsu_.charAt(1);
         
     | 
| 
      
 3188 
     | 
    
         
            +
                    s += zerofill(pieces[2].toFixed(prec), 2 + prec + (prec ? 1 : 0)) +
         
     | 
| 
      
 3189 
     | 
    
         
            +
                      dmsindicatorsu_.charAt(2);
         
     | 
| 
      
 3190 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 3191 
     | 
    
         
            +
                  default:
         
     | 
| 
      
 3192 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 3193 
     | 
    
         
            +
                  }
         
     | 
| 
      
 3194 
     | 
    
         
            +
                }
         
     | 
| 
      
 3195 
     | 
    
         
            +
                if (ind !== d.NONE && ind !== d.AZIMUTH)
         
     | 
| 
      
 3196 
     | 
    
         
            +
                  s += hemispheres_.charAt((ind === d.LATITUDE ? 0 : 2) +
         
     | 
| 
      
 3197 
     | 
    
         
            +
                                           (sign < 0 ? 0 : 1));
         
     | 
| 
      
 3198 
     | 
    
         
            +
                return s;
         
     | 
| 
      
 3199 
     | 
    
         
            +
              };
         
     | 
| 
      
 3200 
     | 
    
         
            +
            })(GeographicLib.DMS);
         
     | 
| 
      
 3201 
     | 
    
         
            +
             
     | 
| 
      
 3202 
     | 
    
         
            +
            cb(GeographicLib);
         
     | 
| 
      
 3203 
     | 
    
         
            +
             
     | 
| 
      
 3204 
     | 
    
         
            +
            })(function(geo) {
         
     | 
| 
      
 3205 
     | 
    
         
            +
              if (typeof module === 'object' && module.exports) {
         
     | 
| 
      
 3206 
     | 
    
         
            +
                /******** support loading with node's require ********/
         
     | 
| 
      
 3207 
     | 
    
         
            +
                module.exports = geo;
         
     | 
| 
      
 3208 
     | 
    
         
            +
              } else if (true) {
         
     | 
| 
      
 3209 
     | 
    
         
            +
                /******** support loading with AMD ********/
         
     | 
| 
      
 3210 
     | 
    
         
            +
                !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { return geo; }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
         
     | 
| 
      
 3211 
     | 
    
         
            +
            				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
         
     | 
| 
      
 3212 
     | 
    
         
            +
              } else {
         
     | 
| 
      
 3213 
     | 
    
         
            +
                /******** otherwise just pollute our global namespace ********/
         
     | 
| 
      
 3214 
     | 
    
         
            +
                window.GeographicLib = geo;
         
     | 
| 
      
 3215 
     | 
    
         
            +
              }
         
     | 
| 
      
 3216 
     | 
    
         
            +
            });
         
     | 
| 
      
 3217 
     | 
    
         
            +
             
     | 
| 
      
 3218 
     | 
    
         
            +
             
     | 
| 
      
 3219 
     | 
    
         
            +
            /***/ })
         
     | 
| 
      
 3220 
     | 
    
         
            +
            /******/ ]);
         
     |