src/pyams_gis/resources/js/leaflet-gp-3.0.2.js
changeset 0 c73bb834ccbe
equal deleted inserted replaced
-1:000000000000 0:c73bb834ccbe
       
     1 /*!
       
     2  * @brief Geoportal Extension for Leaflet
       
     3  *
       
     4  * This software is released under the licence CeCILL-B (Free BSD compatible)
       
     5  * @see http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
       
     6  * @see http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
       
     7  * @see http://www.cecill.info/
       
     8  *
       
     9  * copyright CeCILL-B
       
    10  * copyright IGN
       
    11  * @author IGN
       
    12  * @version 0.8.1
       
    13  * @date 2016-12-02
       
    14  *
       
    15  */
       
    16 /*!
       
    17  * @overview es6-promise - a tiny implementation of Promises/A+.
       
    18  * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and cont  ributors (Conversion to ES6 API by Jake Archibald)
       
    19  * @license   Licensed under MIT license
       
    20  *            See https://raw.githubusercontent.com/jakearchibald/es6-promise/  master/LICENSE
       
    21  * @version   3.0.2
       
    22  */
       
    23 /*!
       
    24  * Sortable -- minimalist JavaScript library for reorderable drag-and-drop lists
       
    25  *
       
    26  * Released under MIT LICENSE
       
    27  * 
       
    28  * Copyright 2013-2016 Lebedev Konstantin <ibnRubaXa@gmail.com>
       
    29  * http://rubaxa.github.io/Sortable/
       
    30  * 
       
    31  * Permission is hereby granted, free of charge, to any person obtaining
       
    32  * a copy of this software and associated documentation files (the
       
    33  * "Software"), to deal in the Software without restriction, including
       
    34  * without limitation the rights to use, copy, modify, merge, publish,
       
    35  * distribute, sublicense, and/or sell copies of the Software, and to
       
    36  * permit persons to whom the Software is furnished to do so, subject to
       
    37  * the following conditions:
       
    38  * 
       
    39  * The above copyright notice and this permission notice shall be
       
    40  * included in all copies or substantial portions of the Software.
       
    41  * 
       
    42  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    43  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    44  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
       
    45  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
       
    46  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
       
    47  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
       
    48  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
    49  */
       
    50 /*!
       
    51  * Proj4js - Javascript reprojection library. 
       
    52  * 
       
    53  * Authors:
       
    54  * 
       
    55  * - Mike Adair madairATdmsolutions.ca
       
    56  * - Richard Greenwood richATgreenwoodmap.com
       
    57  * - Didier Richard didier.richardATign.fr
       
    58  * - Stephen Irons stephen.ironsATclear.net.nz
       
    59  * - Olivier Terral oterralATgmail.com
       
    60  * - Calvin Metcalf cmetcalfATappgeo.com
       
    61  * 
       
    62  * Copyright (c) 2014, Mike Adair, Richard Greenwood, Didier Richard, Stephen Irons, Olivier Terral and Calvin Metcalf
       
    63  * 
       
    64  *  Permission is hereby granted, free of charge, to any person obtaining a
       
    65  *  copy of this software and associated documentation files (the "Software"),
       
    66  *  to deal in the Software without restriction, including without limitation
       
    67  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
       
    68  *  and/or sell copies of the Software, and to permit persons to whom the
       
    69  *  Software is furnished to do so, subject to the following conditions:
       
    70  * 
       
    71  *  The above copyright notice and this permission notice shall be included
       
    72  *  in all copies or substantial portions of the Software.
       
    73  * 
       
    74  *  _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
       
    75  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       
    76  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
       
    77  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       
    78  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
       
    79  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
       
    80  *  DEALINGS IN THE SOFTWARE._
       
    81  * 
       
    82  */
       
    83 /*!
       
    84  * Copyright 2012-2016 Jacob Toye and Leaflet
       
    85  *
       
    86  * Permission is hereby granted, free of charge, to any person obtaining a copy
       
    87  * of this software and associated documentation files (the "Software"), to deal
       
    88  * in the Software without restriction, including without limitation the rights
       
    89  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
       
    90  * of the Software, and to permit persons to whom the Software is furnished to do
       
    91  * so, subject to the following conditions:
       
    92  *
       
    93  * The above copyright notice and this permission notice shall be included in
       
    94  * all copies or substantial portions of the Software.
       
    95  *
       
    96  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
       
    97  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
       
    98  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
       
    99  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
       
   100  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
       
   101  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
   102  */
       
   103 /*!
       
   104  * Proj4Leaflet --  Smooth Proj4js integration with Leaflet
       
   105  * 
       
   106  * Copyright (c) 2012, Kartena AB
       
   107  * All rights reserved.
       
   108  * 
       
   109  * Redistribution and use in source and binary forms, with or without
       
   110  * modification, are permitted provided that the following conditions are met:
       
   111  * 
       
   112  * 1. Redistributions of source code must retain the above copyright notice, this
       
   113  *    list of conditions and the following disclaimer.
       
   114  * 2. Redistributions in binary form must reproduce the above copyright notice,
       
   115  *    this list of conditions and the following disclaimer in the documentation
       
   116  *    and/or other materials provided with the distribution.
       
   117  * 
       
   118  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
       
   119  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
   120  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
   121  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
       
   122  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
   123  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
   124  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
   125  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
   126  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
   127  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
   128  */
       
   129 ;(function(root, factory) {
       
   130   if (typeof define === 'function' && define.amd) {
       
   131     define(['leaflet'], factory);
       
   132   } else if (typeof exports === 'object') {
       
   133     module.exports = factory(require('leaflet'));
       
   134   } else {
       
   135     root.Gp = factory(root.L);
       
   136   }
       
   137 }(this, function(leaflet) {
       
   138 
       
   139 var gp, CommonUtilsAutoLoadConfig, leafletDraw, sortable, CommonControlsLayerSwitcherDOM, LeafletControlsLayerSwitcher, CommonUtilsConfig, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, CommonControlsLocationSelectorDOM, LeafletControlsUtilsPositionFormater, LeafletControlsUtilsIconDefault, LeafletControlsLocationSelector, CommonControlsIsoDOM, LeafletControlsIsocurve, CommonControlsMousePositionDOM, proj4, proj4leaflet07x, proj4leaflet10x, LeafletCRSProj4Leaflet, CommonUtilsRegister, LeafletCRSEPSG2154, LeafletCRSEPSG27572, LeafletCRSEPSG4326, LeafletCRSCRS, LeafletControlsMousePosition, CommonControlsReverseGeocodingDOM, LeafletControlsReverseGeocoding, CommonControlsRouteDOM, LeafletControlsRoute, CommonControlsSearchEngineDOM, CommonControlsSearchEngineUtils, LeafletControlsSearchEngine, CommonControlsElevationPathDOM, LeafletControlsElevationPath, LeafletControlsLogo, LeafletControlsControls, CommonUtilsLayerUtils, LeafletLayersLayerConfig, LeafletLayersLayerEvent, LeafletLayersWMS, LeafletLayersWMTS, LeafletLayersLayers, LeafletGpPluginLeaflet;
       
   140 (function (root, factory) {
       
   141     if (true) {
       
   142         gp = function () {
       
   143             return typeof factory === 'function' ? factory() : factory;
       
   144         }();
       
   145     } else if (typeof exports === 'object') {
       
   146         module.exports = factory();
       
   147     } else {
       
   148         root.Gp = factory();
       
   149     }
       
   150 }(this, function () {
       
   151     var log4js, loggerCfg, UtilsLoggerByDefault, UtilsHelper, promise, ProtocolsXHR, UtilsMessagesResources, ExceptionsErrorService, ProtocolsJSONP, ProtocolsProtocol, ServicesDefaultUrlService, ServicesCommonService, ServicesAltiRequestModelAltiRequest, ServicesAltiRequestModelAltiElevationRequest, ServicesAltiRequestModelAltiProfilRequest, ServicesAltiRequestAltiRequestREST, FormatsWPS, ServicesAltiRequestAltiRequestWPS, ServicesAltiRequestAltiRequestFactory, FormatsXML, ServicesAltiResponseModelAltiResponse, ServicesAltiResponseModelElevation, ServicesAltiFormatsAltiResponseReader, ServicesAltiResponseAltiResponseFactory, ServicesAltiAlti, ServicesAutoConfResponseModelAutoConfResponse, ServicesAutoConfResponseModelConstraint, ServicesAutoConfResponseModelFormat, ServicesAutoConfResponseModelLayer, ServicesAutoConfResponseModelLegend, ServicesAutoConfResponseModelMetadata, ServicesAutoConfResponseModelOriginator, ServicesAutoConfResponseModelService, ServicesAutoConfResponseModelStyle, ServicesAutoConfResponseModelTerritory, ServicesAutoConfResponseModelThematic, ServicesAutoConfResponseModelTileMatrixSet, ServicesAutoConfResponseModelTileMatrix, ServicesAutoConfResponseModelTileMatrixLimit, ServicesAutoConfFormatsAutoConfResponseReader, ServicesAutoConfResponseAutoConfResponseFactory, ServicesAutoConfAutoConf, FormatsXLSRequestHeader, FormatsXLSRequest, FormatsXLSAbstractService, FormatsXLS, FormatsXLSLocationUtilityServiceModelAddress, FormatsXLSLocationUtilityServiceGeocodeFilterExtension, FormatsXLSLocationUtilityServiceGeocodeRequest, FormatsXLSLocationUtilityServiceModelPosition, FormatsXLSLocationUtilityServiceModelPreference, FormatsXLSLocationUtilityServiceReverseGeocodeRequest, FormatsXLSLocationUtilityService, ServicesGeocodeRequestGeocodeLocation, ServicesGeocodeRequestModelStreetAddress, ServicesGeocodeRequestModelPositionOfInterest, ServicesGeocodeRequestModelCadastralParcel, ServicesGeocodeRequestModelAdministratif, ServicesGeocodeRequestDirectGeocodeRequestFactory, ServicesGeocodeResponseModelGeocodeResponse, ServicesGeocodeResponseModelGeocodedLocation, ServicesGeocodeResponseModelDirectGeocodedLocation, ServicesGeocodeFormatsDirectGeocodeResponseReader, ServicesGeocodeResponseDirectGeocodeResponseFactory, ServicesGeocodeGeocode, ServicesGeocodeRequestReverseGeocodeRequestFactory, ServicesGeocodeResponseModelReverseGeocodedLocation, ServicesGeocodeFormatsReverseGeocodeResponseReader, ServicesGeocodeResponseReverseGeocodeResponseFactory, ServicesGeocodeReverseGeocode, ServicesAutoCompleteResponseModelAutoCompleteResponse, ServicesAutoCompleteResponseModelSuggestedLocation, ServicesAutoCompleteResponseAutoCompleteResponseFactory, ServicesAutoCompleteAutoComplete, FormatsXLSRouteServiceModelRoutePlan, FormatsXLSRouteServiceDetermineRouteRequest, FormatsXLSRouteServiceRouteRequestExtension, FormatsXLSRouteService, ServicesRouteRequestRouteRequestOLS, ServicesRouteRequestModelRouteParamREST, ServicesRouteRequestRouteRequestREST, ServicesRouteRequestRouteRequestFactory, FormatsWKT, ServicesRouteResponseModelRouteResponse, ServicesRouteResponseModelRouteInstruction, ServicesRouteFormatsRouteResponseRESTReader, ServicesRouteFormatsRouteResponseOLSReader, ServicesRouteResponseRouteResponseFactory, ServicesRouteRoute, ServicesProcessIsoCurveRequestModelProcessIsoCurveParam, ServicesProcessIsoCurveRequestProcessIsoCurveRequest, ServicesProcessIsoCurveResponseModelProcessIsoCurveResponse, ServicesProcessIsoCurveFormatsProcessIsoCurveResponseReader, ServicesProcessIsoCurveResponseProcessIsoCurveResponseFactory, ServicesProcessIsoCurveProcessIsoCurve, ServicesServices, Gp;
       
   152     log4js = undefined;
       
   153     loggerCfg = {
       
   154         loggers: [{
       
   155                 root: true,
       
   156                 level: 'all',
       
   157                 appenders: [{
       
   158                         type: 'Console',
       
   159                         layout: {
       
   160                             type: 'PatternLayout',
       
   161                             pattern: '%d{yyyy-MM-dd HH:mm:ss} [%p] %c - %m%n'
       
   162                         }
       
   163                     }]
       
   164             }]
       
   165     };
       
   166     UtilsLoggerByDefault = function (Log4js, Config) {
       
   167         var LoggerByDefault = {
       
   168             getLogger: function (name) {
       
   169                 Log4js.load(Config, function (error) {
       
   170                     if (error) {
       
   171                         throw error;
       
   172                     }
       
   173                 });
       
   174                 var logname = name || 'default';
       
   175                 return Log4js.getLogger(logname);
       
   176             }
       
   177         };
       
   178         return LoggerByDefault;
       
   179     }(log4js, loggerCfg);
       
   180     UtilsHelper = function () {
       
   181         var Helper = {
       
   182             normalyzeParameters: function (params) {
       
   183                 var myParams = null;
       
   184                 if (params) {
       
   185                     var tabParams = [];
       
   186                     for (var key in params) {
       
   187                         if (params.hasOwnProperty(key)) {
       
   188                             var value = params[key];
       
   189                             if (!value) {
       
   190                                 value = '';
       
   191                             }
       
   192                             tabParams.push(key + '=' + value);
       
   193                         }
       
   194                     }
       
   195                     myParams = tabParams.join('&');
       
   196                 }
       
   197                 return myParams;
       
   198             },
       
   199             normalyzeUrl: function (url, params, encode) {
       
   200                 var myUrl = url;
       
   201                 if (url) {
       
   202                     var k = url.indexOf('?');
       
   203                     if (k === -1) {
       
   204                         myUrl += '?';
       
   205                     }
       
   206                     if (k !== -1 && k !== url.length - 1) {
       
   207                         myUrl += '&';
       
   208                     }
       
   209                 }
       
   210                 if (params) {
       
   211                     if (typeof params === 'string') {
       
   212                         myUrl += params;
       
   213                     } else {
       
   214                         myUrl += this.normalyzeParameters(params);
       
   215                     }
       
   216                 }
       
   217                 if (encode) {
       
   218                     myUrl = encodeURIComponent(myUrl);
       
   219                 }
       
   220                 return myUrl;
       
   221             },
       
   222             indent: function (n, msg) {
       
   223                 var num = n || 0;
       
   224                 return new Array(num + 1).join('\t') + msg;
       
   225             }
       
   226         };
       
   227         return Helper;
       
   228     }();
       
   229     (function () {
       
   230         'use strict';
       
   231         function lib$es6$promise$utils$$objectOrFunction(x) {
       
   232             return typeof x === 'function' || typeof x === 'object' && x !== null;
       
   233         }
       
   234         function lib$es6$promise$utils$$isFunction(x) {
       
   235             return typeof x === 'function';
       
   236         }
       
   237         function lib$es6$promise$utils$$isMaybeThenable(x) {
       
   238             return typeof x === 'object' && x !== null;
       
   239         }
       
   240         var lib$es6$promise$utils$$_isArray;
       
   241         if (!Array.isArray) {
       
   242             lib$es6$promise$utils$$_isArray = function (x) {
       
   243                 return Object.prototype.toString.call(x) === '[object Array]';
       
   244             };
       
   245         } else {
       
   246             lib$es6$promise$utils$$_isArray = Array.isArray;
       
   247         }
       
   248         var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
       
   249         var lib$es6$promise$asap$$len = 0;
       
   250         var lib$es6$promise$asap$$toString = {}.toString;
       
   251         var lib$es6$promise$asap$$vertxNext;
       
   252         var lib$es6$promise$asap$$customSchedulerFn;
       
   253         var lib$es6$promise$asap$$asap = function asap(callback, arg) {
       
   254             lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
       
   255             lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
       
   256             lib$es6$promise$asap$$len += 2;
       
   257             if (lib$es6$promise$asap$$len === 2) {
       
   258                 if (lib$es6$promise$asap$$customSchedulerFn) {
       
   259                     lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
       
   260                 } else {
       
   261                     lib$es6$promise$asap$$scheduleFlush();
       
   262                 }
       
   263             }
       
   264         };
       
   265         function lib$es6$promise$asap$$setScheduler(scheduleFn) {
       
   266             lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
       
   267         }
       
   268         function lib$es6$promise$asap$$setAsap(asapFn) {
       
   269             lib$es6$promise$asap$$asap = asapFn;
       
   270         }
       
   271         var lib$es6$promise$asap$$browserWindow = typeof window !== 'undefined' ? window : undefined;
       
   272         var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
       
   273         var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
       
   274         var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
       
   275         var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
       
   276         function lib$es6$promise$asap$$useNextTick() {
       
   277             return function () {
       
   278                 process.nextTick(lib$es6$promise$asap$$flush);
       
   279             };
       
   280         }
       
   281         function lib$es6$promise$asap$$useVertxTimer() {
       
   282             return function () {
       
   283                 lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
       
   284             };
       
   285         }
       
   286         function lib$es6$promise$asap$$useMutationObserver() {
       
   287             var iterations = 0;
       
   288             var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
       
   289             var node = document.createTextNode('');
       
   290             observer.observe(node, { characterData: true });
       
   291             return function () {
       
   292                 node.data = iterations = ++iterations % 2;
       
   293             };
       
   294         }
       
   295         function lib$es6$promise$asap$$useMessageChannel() {
       
   296             var channel = new MessageChannel();
       
   297             channel.port1.onmessage = lib$es6$promise$asap$$flush;
       
   298             return function () {
       
   299                 channel.port2.postMessage(0);
       
   300             };
       
   301         }
       
   302         function lib$es6$promise$asap$$useSetTimeout() {
       
   303             return function () {
       
   304                 setTimeout(lib$es6$promise$asap$$flush, 1);
       
   305             };
       
   306         }
       
   307         var lib$es6$promise$asap$$queue = new Array(1000);
       
   308         function lib$es6$promise$asap$$flush() {
       
   309             for (var i = 0; i < lib$es6$promise$asap$$len; i += 2) {
       
   310                 var callback = lib$es6$promise$asap$$queue[i];
       
   311                 var arg = lib$es6$promise$asap$$queue[i + 1];
       
   312                 callback(arg);
       
   313                 lib$es6$promise$asap$$queue[i] = undefined;
       
   314                 lib$es6$promise$asap$$queue[i + 1] = undefined;
       
   315             }
       
   316             lib$es6$promise$asap$$len = 0;
       
   317         }
       
   318         function lib$es6$promise$asap$$attemptVertx() {
       
   319             try {
       
   320                 var r = require;
       
   321                 var vertx = r('vertx');
       
   322                 lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
       
   323                 return lib$es6$promise$asap$$useVertxTimer();
       
   324             } catch (e) {
       
   325                 return lib$es6$promise$asap$$useSetTimeout();
       
   326             }
       
   327         }
       
   328         var lib$es6$promise$asap$$scheduleFlush;
       
   329         if (lib$es6$promise$asap$$isNode) {
       
   330             lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
       
   331         } else if (lib$es6$promise$asap$$BrowserMutationObserver) {
       
   332             lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
       
   333         } else if (lib$es6$promise$asap$$isWorker) {
       
   334             lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
       
   335         } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
       
   336             lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
       
   337         } else {
       
   338             lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
       
   339         }
       
   340         function lib$es6$promise$$internal$$noop() {
       
   341         }
       
   342         var lib$es6$promise$$internal$$PENDING = void 0;
       
   343         var lib$es6$promise$$internal$$FULFILLED = 1;
       
   344         var lib$es6$promise$$internal$$REJECTED = 2;
       
   345         var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
       
   346         function lib$es6$promise$$internal$$selfFulfillment() {
       
   347             return new TypeError('You cannot resolve a promise with itself');
       
   348         }
       
   349         function lib$es6$promise$$internal$$cannotReturnOwn() {
       
   350             return new TypeError('A promises callback cannot return that same promise.');
       
   351         }
       
   352         function lib$es6$promise$$internal$$getThen(promise) {
       
   353             try {
       
   354                 return promise.then;
       
   355             } catch (error) {
       
   356                 lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
       
   357                 return lib$es6$promise$$internal$$GET_THEN_ERROR;
       
   358             }
       
   359         }
       
   360         function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
       
   361             try {
       
   362                 then.call(value, fulfillmentHandler, rejectionHandler);
       
   363             } catch (e) {
       
   364                 return e;
       
   365             }
       
   366         }
       
   367         function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
       
   368             lib$es6$promise$asap$$asap(function (promise) {
       
   369                 var sealed = false;
       
   370                 var error = lib$es6$promise$$internal$$tryThen(then, thenable, function (value) {
       
   371                     if (sealed) {
       
   372                         return;
       
   373                     }
       
   374                     sealed = true;
       
   375                     if (thenable !== value) {
       
   376                         lib$es6$promise$$internal$$resolve(promise, value);
       
   377                     } else {
       
   378                         lib$es6$promise$$internal$$fulfill(promise, value);
       
   379                     }
       
   380                 }, function (reason) {
       
   381                     if (sealed) {
       
   382                         return;
       
   383                     }
       
   384                     sealed = true;
       
   385                     lib$es6$promise$$internal$$reject(promise, reason);
       
   386                 }, 'Settle: ' + (promise._label || ' unknown promise'));
       
   387                 if (!sealed && error) {
       
   388                     sealed = true;
       
   389                     lib$es6$promise$$internal$$reject(promise, error);
       
   390                 }
       
   391             }, promise);
       
   392         }
       
   393         function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
       
   394             if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
       
   395                 lib$es6$promise$$internal$$fulfill(promise, thenable._result);
       
   396             } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
       
   397                 lib$es6$promise$$internal$$reject(promise, thenable._result);
       
   398             } else {
       
   399                 lib$es6$promise$$internal$$subscribe(thenable, undefined, function (value) {
       
   400                     lib$es6$promise$$internal$$resolve(promise, value);
       
   401                 }, function (reason) {
       
   402                     lib$es6$promise$$internal$$reject(promise, reason);
       
   403                 });
       
   404             }
       
   405         }
       
   406         function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
       
   407             if (maybeThenable.constructor === promise.constructor) {
       
   408                 lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
       
   409             } else {
       
   410                 var then = lib$es6$promise$$internal$$getThen(maybeThenable);
       
   411                 if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
       
   412                     lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
       
   413                 } else if (then === undefined) {
       
   414                     lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
       
   415                 } else if (lib$es6$promise$utils$$isFunction(then)) {
       
   416                     lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
       
   417                 } else {
       
   418                     lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
       
   419                 }
       
   420             }
       
   421         }
       
   422         function lib$es6$promise$$internal$$resolve(promise, value) {
       
   423             if (promise === value) {
       
   424                 lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
       
   425             } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
       
   426                 lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
       
   427             } else {
       
   428                 lib$es6$promise$$internal$$fulfill(promise, value);
       
   429             }
       
   430         }
       
   431         function lib$es6$promise$$internal$$publishRejection(promise) {
       
   432             if (promise._onerror) {
       
   433                 promise._onerror(promise._result);
       
   434             }
       
   435             lib$es6$promise$$internal$$publish(promise);
       
   436         }
       
   437         function lib$es6$promise$$internal$$fulfill(promise, value) {
       
   438             if (promise._state !== lib$es6$promise$$internal$$PENDING) {
       
   439                 return;
       
   440             }
       
   441             promise._result = value;
       
   442             promise._state = lib$es6$promise$$internal$$FULFILLED;
       
   443             if (promise._subscribers.length !== 0) {
       
   444                 lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
       
   445             }
       
   446         }
       
   447         function lib$es6$promise$$internal$$reject(promise, reason) {
       
   448             if (promise._state !== lib$es6$promise$$internal$$PENDING) {
       
   449                 return;
       
   450             }
       
   451             promise._state = lib$es6$promise$$internal$$REJECTED;
       
   452             promise._result = reason;
       
   453             lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
       
   454         }
       
   455         function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
       
   456             var subscribers = parent._subscribers;
       
   457             var length = subscribers.length;
       
   458             parent._onerror = null;
       
   459             subscribers[length] = child;
       
   460             subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
       
   461             subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
       
   462             if (length === 0 && parent._state) {
       
   463                 lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
       
   464             }
       
   465         }
       
   466         function lib$es6$promise$$internal$$publish(promise) {
       
   467             var subscribers = promise._subscribers;
       
   468             var settled = promise._state;
       
   469             if (subscribers.length === 0) {
       
   470                 return;
       
   471             }
       
   472             var child, callback, detail = promise._result;
       
   473             for (var i = 0; i < subscribers.length; i += 3) {
       
   474                 child = subscribers[i];
       
   475                 callback = subscribers[i + settled];
       
   476                 if (child) {
       
   477                     lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
       
   478                 } else {
       
   479                     callback(detail);
       
   480                 }
       
   481             }
       
   482             promise._subscribers.length = 0;
       
   483         }
       
   484         function lib$es6$promise$$internal$$ErrorObject() {
       
   485             this.error = null;
       
   486         }
       
   487         var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
       
   488         function lib$es6$promise$$internal$$tryCatch(callback, detail) {
       
   489             try {
       
   490                 return callback(detail);
       
   491             } catch (e) {
       
   492                 lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
       
   493                 return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
       
   494             }
       
   495         }
       
   496         function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
       
   497             var hasCallback = lib$es6$promise$utils$$isFunction(callback), value, error, succeeded, failed;
       
   498             if (hasCallback) {
       
   499                 value = lib$es6$promise$$internal$$tryCatch(callback, detail);
       
   500                 if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
       
   501                     failed = true;
       
   502                     error = value.error;
       
   503                     value = null;
       
   504                 } else {
       
   505                     succeeded = true;
       
   506                 }
       
   507                 if (promise === value) {
       
   508                     lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
       
   509                     return;
       
   510                 }
       
   511             } else {
       
   512                 value = detail;
       
   513                 succeeded = true;
       
   514             }
       
   515             if (promise._state !== lib$es6$promise$$internal$$PENDING) {
       
   516             } else if (hasCallback && succeeded) {
       
   517                 lib$es6$promise$$internal$$resolve(promise, value);
       
   518             } else if (failed) {
       
   519                 lib$es6$promise$$internal$$reject(promise, error);
       
   520             } else if (settled === lib$es6$promise$$internal$$FULFILLED) {
       
   521                 lib$es6$promise$$internal$$fulfill(promise, value);
       
   522             } else if (settled === lib$es6$promise$$internal$$REJECTED) {
       
   523                 lib$es6$promise$$internal$$reject(promise, value);
       
   524             }
       
   525         }
       
   526         function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
       
   527             try {
       
   528                 resolver(function resolvePromise(value) {
       
   529                     lib$es6$promise$$internal$$resolve(promise, value);
       
   530                 }, function rejectPromise(reason) {
       
   531                     lib$es6$promise$$internal$$reject(promise, reason);
       
   532                 });
       
   533             } catch (e) {
       
   534                 lib$es6$promise$$internal$$reject(promise, e);
       
   535             }
       
   536         }
       
   537         function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
       
   538             var enumerator = this;
       
   539             enumerator._instanceConstructor = Constructor;
       
   540             enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
       
   541             if (enumerator._validateInput(input)) {
       
   542                 enumerator._input = input;
       
   543                 enumerator.length = input.length;
       
   544                 enumerator._remaining = input.length;
       
   545                 enumerator._init();
       
   546                 if (enumerator.length === 0) {
       
   547                     lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
       
   548                 } else {
       
   549                     enumerator.length = enumerator.length || 0;
       
   550                     enumerator._enumerate();
       
   551                     if (enumerator._remaining === 0) {
       
   552                         lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
       
   553                     }
       
   554                 }
       
   555             } else {
       
   556                 lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
       
   557             }
       
   558         }
       
   559         lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function (input) {
       
   560             return lib$es6$promise$utils$$isArray(input);
       
   561         };
       
   562         lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function () {
       
   563             return new Error('Array Methods must be provided an Array');
       
   564         };
       
   565         lib$es6$promise$enumerator$$Enumerator.prototype._init = function () {
       
   566             this._result = new Array(this.length);
       
   567         };
       
   568         var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
       
   569         lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function () {
       
   570             var enumerator = this;
       
   571             var length = enumerator.length;
       
   572             var promise = enumerator.promise;
       
   573             var input = enumerator._input;
       
   574             for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
       
   575                 enumerator._eachEntry(input[i], i);
       
   576             }
       
   577         };
       
   578         lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function (entry, i) {
       
   579             var enumerator = this;
       
   580             var c = enumerator._instanceConstructor;
       
   581             if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
       
   582                 if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
       
   583                     entry._onerror = null;
       
   584                     enumerator._settledAt(entry._state, i, entry._result);
       
   585                 } else {
       
   586                     enumerator._willSettleAt(c.resolve(entry), i);
       
   587                 }
       
   588             } else {
       
   589                 enumerator._remaining--;
       
   590                 enumerator._result[i] = entry;
       
   591             }
       
   592         };
       
   593         lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function (state, i, value) {
       
   594             var enumerator = this;
       
   595             var promise = enumerator.promise;
       
   596             if (promise._state === lib$es6$promise$$internal$$PENDING) {
       
   597                 enumerator._remaining--;
       
   598                 if (state === lib$es6$promise$$internal$$REJECTED) {
       
   599                     lib$es6$promise$$internal$$reject(promise, value);
       
   600                 } else {
       
   601                     enumerator._result[i] = value;
       
   602                 }
       
   603             }
       
   604             if (enumerator._remaining === 0) {
       
   605                 lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
       
   606             }
       
   607         };
       
   608         lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function (promise, i) {
       
   609             var enumerator = this;
       
   610             lib$es6$promise$$internal$$subscribe(promise, undefined, function (value) {
       
   611                 enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
       
   612             }, function (reason) {
       
   613                 enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
       
   614             });
       
   615         };
       
   616         function lib$es6$promise$promise$all$$all(entries) {
       
   617             return new lib$es6$promise$enumerator$$default(this, entries).promise;
       
   618         }
       
   619         var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
       
   620         function lib$es6$promise$promise$race$$race(entries) {
       
   621             var Constructor = this;
       
   622             var promise = new Constructor(lib$es6$promise$$internal$$noop);
       
   623             if (!lib$es6$promise$utils$$isArray(entries)) {
       
   624                 lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
       
   625                 return promise;
       
   626             }
       
   627             var length = entries.length;
       
   628             function onFulfillment(value) {
       
   629                 lib$es6$promise$$internal$$resolve(promise, value);
       
   630             }
       
   631             function onRejection(reason) {
       
   632                 lib$es6$promise$$internal$$reject(promise, reason);
       
   633             }
       
   634             for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
       
   635                 lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
       
   636             }
       
   637             return promise;
       
   638         }
       
   639         var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
       
   640         function lib$es6$promise$promise$resolve$$resolve(object) {
       
   641             var Constructor = this;
       
   642             if (object && typeof object === 'object' && object.constructor === Constructor) {
       
   643                 return object;
       
   644             }
       
   645             var promise = new Constructor(lib$es6$promise$$internal$$noop);
       
   646             lib$es6$promise$$internal$$resolve(promise, object);
       
   647             return promise;
       
   648         }
       
   649         var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
       
   650         function lib$es6$promise$promise$reject$$reject(reason) {
       
   651             var Constructor = this;
       
   652             var promise = new Constructor(lib$es6$promise$$internal$$noop);
       
   653             lib$es6$promise$$internal$$reject(promise, reason);
       
   654             return promise;
       
   655         }
       
   656         var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
       
   657         var lib$es6$promise$promise$$counter = 0;
       
   658         function lib$es6$promise$promise$$needsResolver() {
       
   659             throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
       
   660         }
       
   661         function lib$es6$promise$promise$$needsNew() {
       
   662             throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
       
   663         }
       
   664         var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
       
   665         function lib$es6$promise$promise$$Promise(resolver) {
       
   666             this._id = lib$es6$promise$promise$$counter++;
       
   667             this._state = undefined;
       
   668             this._result = undefined;
       
   669             this._subscribers = [];
       
   670             if (lib$es6$promise$$internal$$noop !== resolver) {
       
   671                 if (!lib$es6$promise$utils$$isFunction(resolver)) {
       
   672                     lib$es6$promise$promise$$needsResolver();
       
   673                 }
       
   674                 if (!(this instanceof lib$es6$promise$promise$$Promise)) {
       
   675                     lib$es6$promise$promise$$needsNew();
       
   676                 }
       
   677                 lib$es6$promise$$internal$$initializePromise(this, resolver);
       
   678             }
       
   679         }
       
   680         lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
       
   681         lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
       
   682         lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
       
   683         lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
       
   684         lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
       
   685         lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
       
   686         lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
       
   687         lib$es6$promise$promise$$Promise.prototype = {
       
   688             constructor: lib$es6$promise$promise$$Promise,
       
   689             then: function (onFulfillment, onRejection) {
       
   690                 var parent = this;
       
   691                 var state = parent._state;
       
   692                 if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
       
   693                     return this;
       
   694                 }
       
   695                 var child = new this.constructor(lib$es6$promise$$internal$$noop);
       
   696                 var result = parent._result;
       
   697                 if (state) {
       
   698                     var callback = arguments[state - 1];
       
   699                     lib$es6$promise$asap$$asap(function () {
       
   700                         lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
       
   701                     });
       
   702                 } else {
       
   703                     lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
       
   704                 }
       
   705                 return child;
       
   706             },
       
   707             'catch': function (onRejection) {
       
   708                 return this.then(null, onRejection);
       
   709             }
       
   710         };
       
   711         function lib$es6$promise$polyfill$$polyfill() {
       
   712             var local;
       
   713             if (typeof global !== 'undefined') {
       
   714                 local = global;
       
   715             } else if (typeof self !== 'undefined') {
       
   716                 local = self;
       
   717             } else {
       
   718                 try {
       
   719                     local = Function('return this')();
       
   720                 } catch (e) {
       
   721                     throw new Error('polyfill failed because global object is unavailable in this environment');
       
   722                 }
       
   723             }
       
   724             var P = local.Promise;
       
   725             if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
       
   726                 return;
       
   727             }
       
   728             local.Promise = lib$es6$promise$promise$$default;
       
   729         }
       
   730         var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
       
   731         var lib$es6$promise$umd$$ES6Promise = {
       
   732             'Promise': lib$es6$promise$promise$$default,
       
   733             'polyfill': lib$es6$promise$polyfill$$default
       
   734         };
       
   735         if (true) {
       
   736             promise = function () {
       
   737                 return lib$es6$promise$umd$$ES6Promise;
       
   738             }();
       
   739         } else if (typeof module !== 'undefined' && module['exports']) {
       
   740             module['exports'] = lib$es6$promise$umd$$ES6Promise;
       
   741         } else if (typeof this !== 'undefined') {
       
   742             this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
       
   743         }
       
   744         lib$es6$promise$polyfill$$default();
       
   745     }.call(this));
       
   746     ProtocolsXHR = function (Logger, Helper, ES6Promise) {
       
   747         var XHR = {
       
   748             call: function (settings) {
       
   749                 ES6Promise.polyfill();
       
   750                 if (!settings.url) {
       
   751                     throw new Error('missing parameter : url is not defined !');
       
   752                 }
       
   753                 if (!settings.method) {
       
   754                     throw new Error('missing parameter : method is not defined !');
       
   755                 }
       
   756                 if (!settings.format) {
       
   757                     settings.format = 'text';
       
   758                 }
       
   759                 var options = {};
       
   760                 options.url = settings.url;
       
   761                 options.data = settings.data ? settings.data : null;
       
   762                 options.method = settings.method;
       
   763                 options.timeOut = settings.timeOut || 0;
       
   764                 options.scope = settings.scope || this;
       
   765                 switch (settings.method) {
       
   766                 case 'DELETE':
       
   767                 case 'GET':
       
   768                     break;
       
   769                 case 'PUT':
       
   770                 case 'POST':
       
   771                     options.content = settings.content ? settings.content : 'application/x-www-form-urlencoded';
       
   772                     options.headers = settings.headers ? settings.headers : { referer: 'http://localhost' };
       
   773                     break;
       
   774                 case 'HEAD':
       
   775                 case 'OPTIONS':
       
   776                     throw new Error('HTTP method not yet supported !');
       
   777                 default:
       
   778                     throw new Error('HTTP method unknown !');
       
   779                 }
       
   780                 switch (settings.format) {
       
   781                 case 'text':
       
   782                     this.__call(options).then(function (response) {
       
   783                         settings.onResponse.call(this, response);
       
   784                     }).catch(function (error) {
       
   785                         settings.onFailure.call(this, error);
       
   786                     });
       
   787                     break;
       
   788                 case 'json':
       
   789                     this.__callJSON(options).then(function (response) {
       
   790                         settings.onResponse.call(this, response);
       
   791                     }).catch(function (error) {
       
   792                         settings.onFailure.call(this, error);
       
   793                     });
       
   794                     break;
       
   795                 case 'xml':
       
   796                     this.__callXML(options).then(function (response) {
       
   797                         settings.onResponse.call(this, response);
       
   798                     }).catch(function (error) {
       
   799                         settings.onFailure.call(this, error);
       
   800                     });
       
   801                     break;
       
   802                 default:
       
   803                     throw new Error('This output Format is not yet supported !');
       
   804                 }
       
   805             },
       
   806             __call: function (options) {
       
   807                 var promise = new Promise(function (resolve, reject) {
       
   808                     var corps = options.method === 'POST' || options.method === 'PUT' ? true : false;
       
   809                     if (options.data && !corps) {
       
   810                         options.url = Helper.normalyzeUrl(options.url, options.data);
       
   811                     }
       
   812                     var hXHR = null;
       
   813                     if (window.XMLHttpRequest) {
       
   814                         hXHR = new XMLHttpRequest();
       
   815                         hXHR.open(options.method, options.url, true);
       
   816                         hXHR.overrideMimeType = options.content;
       
   817                         var onTimeOutTrigger = null;
       
   818                         if (options.timeOut > 0) {
       
   819                             onTimeOutTrigger = window.setTimeout(function () {
       
   820                                 var message = 'TimeOut Occured on Http Request with XMLHttpRequest !';
       
   821                                 reject({
       
   822                                     message: message,
       
   823                                     status: -1
       
   824                                 });
       
   825                             }, options.timeOut);
       
   826                         }
       
   827                         if (corps) {
       
   828                             hXHR.setRequestHeader('Content-type', options.content);
       
   829                         }
       
   830                         hXHR.onerror = function (e) {
       
   831                             console.log(e);
       
   832                             reject(new Error('Errors Occured on Http Request with XMLHttpRequest !'));
       
   833                         };
       
   834                         hXHR.ontimeout = function () {
       
   835                             reject(new Error('TimeOut Occured on Http Request with XMLHttpRequest !'));
       
   836                         };
       
   837                         hXHR.onreadystatechange = function () {
       
   838                             if (hXHR.readyState == 4) {
       
   839                                 if (hXHR.status == 200) {
       
   840                                     window.clearTimeout(onTimeOutTrigger);
       
   841                                     resolve(hXHR.response);
       
   842                                 } else {
       
   843                                     var message = 'Errors Occured on Http Request (status : \'' + hXHR.status + '\' | response : \'' + hXHR.response + '\')';
       
   844                                     var status = hXHR.status;
       
   845                                     reject({
       
   846                                         message: message,
       
   847                                         status: status
       
   848                                     });
       
   849                                 }
       
   850                             }
       
   851                         };
       
   852                         var data4xhr = options.data && corps ? options.data : null;
       
   853                         hXHR.send(data4xhr);
       
   854                     } else if (window.XDomainRequest) {
       
   855                         hXHR = new XDomainRequest();
       
   856                         hXHR.open(options.method, options.url);
       
   857                         hXHR.overrideMimeType = options.content;
       
   858                         if (options.timeOut > 0) {
       
   859                             hXHR.timeout = options.timeout;
       
   860                         }
       
   861                         if (corps) {
       
   862                             hXHR.setRequestHeader('Content-type', options.content);
       
   863                         }
       
   864                         hXHR.onerror = function () {
       
   865                             reject(new Error('Errors Occured on Http Request with XMLHttpRequest !'));
       
   866                         };
       
   867                         hXHR.ontimeout = function () {
       
   868                             reject(new Error('TimeOut Occured on Http Request with XMLHttpRequest !'));
       
   869                         };
       
   870                         hXHR.onload = function () {
       
   871                             if (hXHR.status == 200) {
       
   872                                 resolve(hXHR.responseText);
       
   873                             } else {
       
   874                                 var message = 'Errors Occured on Http Request (status : \'' + hXHR.status + '\' | response : \'' + hXHR.responseText + '\')';
       
   875                                 var status = hXHR.status;
       
   876                                 reject({
       
   877                                     message: message,
       
   878                                     status: status
       
   879                                 });
       
   880                             }
       
   881                         };
       
   882                         var data4xdr = options.data && corps ? options.data : null;
       
   883                         hXHR.send(data4xdr);
       
   884                     } else {
       
   885                         throw new Error('CORS not supported');
       
   886                     }
       
   887                 });
       
   888                 return promise;
       
   889             },
       
   890             __callJSON: function (options) {
       
   891                 return this.__call(options).then(JSON.parse).catch(function (error) {
       
   892                     console.log('_callJSON failed on : ', options.url, error);
       
   893                     throw error;
       
   894                 });
       
   895             },
       
   896             __callXML: function (options) {
       
   897                 return this.__call(options).then(function (response) {
       
   898                     var xmlDoc;
       
   899                     if (window.DOMParser) {
       
   900                         var parser = new DOMParser();
       
   901                         xmlDoc = parser.parseFromString(response, 'text/xml');
       
   902                     } else {
       
   903                         xmlDoc = new window.ActiveXObject('Microsoft.XMLDOM');
       
   904                         xmlDoc.async = false;
       
   905                         xmlDoc.loadXML(response);
       
   906                     }
       
   907                     return xmlDoc;
       
   908                 }).catch(function (error) {
       
   909                     console.log('__callXML failed on : ', options.url, error);
       
   910                     throw error;
       
   911                 });
       
   912             }
       
   913         };
       
   914         return XHR;
       
   915     }(UtilsLoggerByDefault, UtilsHelper, promise);
       
   916     UtilsMessagesResources = function () {
       
   917         var MessagesResources = {
       
   918             PARAM_MISSING: 'Parameter(s) \'%var%\' missing',
       
   919             PARAM_EMPTY: 'Parameter(s) \'%var%\' empty',
       
   920             PARAM_TYPE: 'Wrong type(s) for parameter(s) \'%var%\'',
       
   921             PARAM_FORMAT: 'Parameter(s) \'%var%\' not correctly formatted',
       
   922             PARAM_NOT_SUPPORT: 'Value(s) for parameter(s) \'%var%\' not supported',
       
   923             PARAM_UNKNOWN: 'Value(s) for parameter(s) \'%var%\' unknown',
       
   924             SERVICE_REQUEST_BUILD: 'An error occurred during the request building of the service',
       
   925             SERVICE_REQUEST_EMPTY: 'The request sent to the service is empty',
       
   926             SERVICE_RESPONSE_EXCEPTION: 'The service returned an exception : \'%var%\'',
       
   927             SERVICE_RESPONSE_EXCEPTION_2: 'The service returned an exception',
       
   928             SERVICE_RESPONSE_ANALYSE: 'An error occurred while parsing the response \'%var%\' of the service',
       
   929             SERVICE_RESPONSE_ANALYSE_2: 'An unknown error occurred while parsing the response',
       
   930             SERVICE_RESPONSE_EMPTY: 'The response of the service is empty',
       
   931             SERVICE_RESPONSE_EMPTY_2: 'The response from the service could not be analyzed or is empty',
       
   932             SERVICE_RESPONSE_FORMAT: 'The format of the service response is not supported (handled format(s) : \'%var%\')',
       
   933             SERVICE_RESPONSE_FORMAT_2: 'The format of the service response is not supported',
       
   934             SERVICE_RESPONSE_FORMAT_3: 'No suggestion matching the search',
       
   935             CLASS_CONSTRUCTOR: '\'%var%\' constructor cannot be called as a function.',
       
   936             getMessage: function (clef, parametres) {
       
   937                 if (!arguments) {
       
   938                     return 'Message indefined !';
       
   939                 }
       
   940                 var params = Array.prototype.slice.call(arguments);
       
   941                 var key = params.shift();
       
   942                 var args = params;
       
   943                 var message = this[key];
       
   944                 try {
       
   945                     if (Array.isArray(args) && args.length > 0) {
       
   946                         message = message.replace('%var%', args.join(' - '));
       
   947                     } else {
       
   948                         message = message.replace('%var%', '%var% (not specified)');
       
   949                     }
       
   950                 } catch (e) {
       
   951                 }
       
   952                 return message;
       
   953             }
       
   954         };
       
   955         return MessagesResources;
       
   956     }();
       
   957     ExceptionsErrorService = function () {
       
   958         function ErrorService(error) {
       
   959             if (!(this instanceof ErrorService)) {
       
   960                 throw new TypeError('ErrorService constructor cannot be called as a function.');
       
   961             }
       
   962             var e = error;
       
   963             if (typeof error === 'string' || error instanceof String) {
       
   964                 this.message = error;
       
   965                 this.status = -1;
       
   966                 this.type = ErrorService.TYPE_UNKERR;
       
   967             } else {
       
   968                 this.message = e.message || 'undefined!?';
       
   969                 this.type = e.type;
       
   970                 this.status = e.status || -1;
       
   971             }
       
   972             this.name = 'ErrorService';
       
   973             this.stack = new Error().stack;
       
   974         }
       
   975         ErrorService.TYPE_SRVERR = 'SERVICE_ERROR';
       
   976         ErrorService.TYPE_USEERR = 'USAGE_ERROR';
       
   977         ErrorService.TYPE_UNKERR = 'UNKNOWN_ERROR';
       
   978         ErrorService.prototype = Object.create(Error.prototype, {
       
   979             constructor: {
       
   980                 value: ErrorService,
       
   981                 writable: true,
       
   982                 configurable: true
       
   983             }
       
   984         });
       
   985         return ErrorService;
       
   986     }();
       
   987     ProtocolsJSONP = function (Logger) {
       
   988         var JSONP = {
       
   989             uuid: function () {
       
   990                 var id = Math.floor(Date.now());
       
   991                 return function () {
       
   992                     return id++;
       
   993                 };
       
   994             }(),
       
   995             call: function (options) {
       
   996                 if (!options) {
       
   997                     throw new Error('missing parameter : options !');
       
   998                 }
       
   999                 if (!options.url) {
       
  1000                     throw new Error('missing parameter : options.url !');
       
  1001                 }
       
  1002                 if (!options.timeOut) {
       
  1003                     options.timeOut = 0;
       
  1004                 }
       
  1005                 if (!options.onResponse) {
       
  1006                     throw new Error('missing parameter : options.onResponse !');
       
  1007                 }
       
  1008                 var callbackId = typeof options.callbackSuffix === 'string' ? options.callbackSuffix : this.uuid();
       
  1009                 var urlHasCallbackKey = false;
       
  1010                 var urlHasCallbackName = false;
       
  1011                 var idx = options.url.indexOf('callback=');
       
  1012                 if (idx != -1) {
       
  1013                     urlHasCallbackKey = true;
       
  1014                     var j = options.url.indexOf('&', idx);
       
  1015                     if (j === -1) {
       
  1016                         j = options.url.length;
       
  1017                     }
       
  1018                     var callbackName = options.url.substring(idx + 9, j);
       
  1019                     if (callbackName) {
       
  1020                         urlHasCallbackName = true;
       
  1021                         options.callbackName = callbackName;
       
  1022                     }
       
  1023                 }
       
  1024                 if (!urlHasCallbackKey) {
       
  1025                     var k = options.url.indexOf('?');
       
  1026                     if (k === -1) {
       
  1027                         options.url = options.url + '?' + 'callback=';
       
  1028                     } else if (k === options.url.length) {
       
  1029                         options.url = options.url + 'callback=';
       
  1030                     } else {
       
  1031                         options.url = options.url + '&' + 'callback=';
       
  1032                     }
       
  1033                 }
       
  1034                 var HasCallbackName = options.callbackName ? true : urlHasCallbackName;
       
  1035                 if (!urlHasCallbackName) {
       
  1036                     if (!options.callbackName) {
       
  1037                         options.callbackName = 'callback';
       
  1038                         if (callbackId || callbackId === '') {
       
  1039                             options.callbackName += callbackId;
       
  1040                         }
       
  1041                     }
       
  1042                     options.url = options.url.replace('callback=', 'callback=' + options.callbackName);
       
  1043                 }
       
  1044                 if (!options.onTimeOut) {
       
  1045                     options.onTimeOut = function () {
       
  1046                         console.log('TimeOut while invoking url : ' + options.url);
       
  1047                     };
       
  1048                 }
       
  1049                 if (!HasCallbackName) {
       
  1050                     var self = this;
       
  1051                     var onTimeOutTrigger = null;
       
  1052                     if (options.timeOut > 0) {
       
  1053                         onTimeOutTrigger = window.setTimeout(function () {
       
  1054                             window[options.callbackName] = function () {
       
  1055                             };
       
  1056                             options.onTimeOut();
       
  1057                             self._deleteScript(callbackId);
       
  1058                         }, options.timeOut);
       
  1059                     }
       
  1060                     window[options.callbackName] = function (data) {
       
  1061                         window.clearTimeout(onTimeOutTrigger);
       
  1062                         options.onResponse(data);
       
  1063                         self._deleteScript(callbackId);
       
  1064                     };
       
  1065                 }
       
  1066                 this._createScript(callbackId, options.url);
       
  1067             },
       
  1068             _createScript: function (callbackId, url) {
       
  1069                 var scriptu;
       
  1070                 var scripto = document.getElementById('results' + callbackId);
       
  1071                 scriptu = document.createElement('script');
       
  1072                 scriptu.setAttribute('type', 'text/javascript');
       
  1073                 scriptu.setAttribute('src', url);
       
  1074                 scriptu.setAttribute('charset', 'UTF-8');
       
  1075                 scriptu.setAttribute('id', 'results' + callbackId);
       
  1076                 scriptu.setAttribute('async', 'true');
       
  1077                 var node = document.documentElement || document.getElementsByTagName('head')[0];
       
  1078                 if (scripto === null) {
       
  1079                     node.appendChild(scriptu);
       
  1080                 } else {
       
  1081                     node.replaceChild(scriptu, scripto);
       
  1082                 }
       
  1083             },
       
  1084             _deleteScript: function (callbackId) {
       
  1085                 var script = document.getElementById('results' + callbackId);
       
  1086                 if (script) {
       
  1087                     var node = script.parentNode || document.documentElement;
       
  1088                     if (!node) {
       
  1089                         return;
       
  1090                     }
       
  1091                     node.removeChild(script);
       
  1092                 }
       
  1093             }
       
  1094         };
       
  1095         return JSONP;
       
  1096     }(UtilsLoggerByDefault);
       
  1097     ProtocolsProtocol = function (Helper, XHR, JSONP) {
       
  1098         var Protocol = {
       
  1099             send: function (options) {
       
  1100                 var settings = options || {
       
  1101                     method: 'GET',
       
  1102                     protocol: 'JSONP',
       
  1103                     timeOut: 0,
       
  1104                     format: null,
       
  1105                     wrap: true,
       
  1106                     nocache: true,
       
  1107                     output: 'json',
       
  1108                     callback: null,
       
  1109                     callbackSuffix: null
       
  1110                 };
       
  1111                 if (options.protocol === 'XHR' || options.format === 'json') {
       
  1112                     settings.wrap = false;
       
  1113                 } else if (options.protocol === 'JSONP' && options.format === 'xml') {
       
  1114                     settings.wrap = true;
       
  1115                 }
       
  1116                 settings.callback = options.protocol == 'JSONP' ? null : null;
       
  1117                 settings.output = settings.wrap ? 'json' : null;
       
  1118                 if (settings.wrap) {
       
  1119                     var params = {};
       
  1120                     params.output = settings.output;
       
  1121                     params.callback = settings.callback;
       
  1122                     delete params.callback;
       
  1123                     settings.url = Helper.normalyzeUrl(options.url, params);
       
  1124                 }
       
  1125                 switch (settings.protocol) {
       
  1126                 case 'XHR':
       
  1127                     if (options.method === 'GET' && options.nocache) {
       
  1128                         settings.url = Helper.normalyzeUrl(settings.url, { t: new Date().getTime() });
       
  1129                     }
       
  1130                     XHR.call(settings);
       
  1131                     break;
       
  1132                 case 'JSONP':
       
  1133                     if (settings.data) {
       
  1134                         settings.url = Helper.normalyzeUrl(settings.url, settings.data);
       
  1135                     }
       
  1136                     JSONP.call(settings);
       
  1137                     break;
       
  1138                 default:
       
  1139                     throw new Error('protocol not supported (XHR|JSONP) !');
       
  1140                 }
       
  1141             }
       
  1142         };
       
  1143         return Protocol;
       
  1144     }(UtilsHelper, ProtocolsXHR, ProtocolsJSONP);
       
  1145     ServicesDefaultUrlService = function () {
       
  1146         var protocol = location && location.protocol && location.protocol.indexOf('https:') === 0 ? 'https://' : 'http://';
       
  1147         var hostname = 'wxs.ign.fr';
       
  1148         var keyname = '%KEY%';
       
  1149         var url = protocol + hostname.concat('/', keyname);
       
  1150         var fkey = function (key) {
       
  1151             return this._key.replace(key ? keyname : null, key);
       
  1152         };
       
  1153         var DefaultUrlService = {
       
  1154             Alti: {
       
  1155                 _key: {
       
  1156                     'elevation-json': url + '/alti/rest/elevation.json',
       
  1157                     'elevation-xml': url + '/alti/rest/elevation.xml',
       
  1158                     'profil-json': url + '/alti/rest/elevationLine.json',
       
  1159                     'profil-xml': url + '/alti/rest/elevationLine.xml',
       
  1160                     wps: url + '/alti/wps'
       
  1161                 },
       
  1162                 url: function (key) {
       
  1163                     return {
       
  1164                         'elevation-json': this._key['elevation-json'].replace(key ? keyname : null, key),
       
  1165                         'elevation-xml': this._key['elevation-xml'].replace(key ? keyname : null, key),
       
  1166                         'profil-json': this._key['profil-json'].replace(key ? keyname : null, key),
       
  1167                         'profil-xml': this._key['profil-xml'].replace(key ? keyname : null, key),
       
  1168                         wps: this._key.wps.replace(key ? keyname : null, key)
       
  1169                     };
       
  1170                 }
       
  1171             },
       
  1172             ProcessIsoCurve: {
       
  1173                 _key: {
       
  1174                     'iso-json': url + '/isochrone/isochrone.json',
       
  1175                     'iso-xml': url + '/isochrone/isochrone.xml'
       
  1176                 },
       
  1177                 url: function (key) {
       
  1178                     return {
       
  1179                         'iso-json': this._key['iso-json'].replace(key ? keyname : null, key),
       
  1180                         'iso-xml': this._key['iso-xml'].replace(key ? keyname : null, key)
       
  1181                     };
       
  1182                 }
       
  1183             },
       
  1184             AutoComplete: {
       
  1185                 _key: url + '/ols/apis/completion',
       
  1186                 url: fkey
       
  1187             },
       
  1188             ReverseGeocode: {
       
  1189                 _key: url + '/geoportail/ols',
       
  1190                 url: fkey
       
  1191             },
       
  1192             AutoConf: {
       
  1193                 _key: {
       
  1194                     apiKey: url + '/autoconf',
       
  1195                     apiKeys: url + '/autoconf?keys=%KEYS%'
       
  1196                 },
       
  1197                 url: function (key) {
       
  1198                     var keys = '';
       
  1199                     if (Array.isArray(key) && key.length > 0) {
       
  1200                         keys = key[0];
       
  1201                         for (var i = 1; i < key.length; i++) {
       
  1202                             keys += ',' + key[i];
       
  1203                         }
       
  1204                     }
       
  1205                     return {
       
  1206                         apiKey: this._key['apiKey'].replace(key ? keyname : null, key),
       
  1207                         apiKeys: this._key['apiKeys'].replace(keyname, key[0]).replace('%KEYS%', keys),
       
  1208                         aggregate: protocol + hostname.concat('/') + key + '/autoconf/id/'
       
  1209                     };
       
  1210                 }
       
  1211             },
       
  1212             Geocode: {
       
  1213                 _key: url + '/geoportail/ols',
       
  1214                 url: fkey
       
  1215             },
       
  1216             Route: {
       
  1217                 _key: {
       
  1218                     ols: url + '/itineraire/ols',
       
  1219                     'route-json': url + '/itineraire/rest/route.json',
       
  1220                     'route-xml': url + '/itineraire/rest/route.xml'
       
  1221                 },
       
  1222                 url: function (key) {
       
  1223                     return {
       
  1224                         ols: this._key.ols.replace(key ? keyname : null, key),
       
  1225                         'route-json': this._key['route-json'].replace(key ? keyname : null, key),
       
  1226                         'route-xml': this._key['route-xml'].replace(key ? keyname : null, key)
       
  1227                     };
       
  1228                 }
       
  1229             }
       
  1230         };
       
  1231         return DefaultUrlService;
       
  1232     }();
       
  1233     ServicesCommonService = function (Logger, Helper, _, Protocol, ErrorService, DefaultUrlService) {
       
  1234         function CommonService(options) {
       
  1235             if (!(this instanceof CommonService)) {
       
  1236                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR'));
       
  1237             }
       
  1238             this.options = {
       
  1239                 protocol: 'JSONP',
       
  1240                 proxyURL: '',
       
  1241                 callbackSuffix: null,
       
  1242                 httpMethod: 'GET',
       
  1243                 timeOut: 0,
       
  1244                 rawResponse: false,
       
  1245                 scope: this,
       
  1246                 onSuccess: function (response) {
       
  1247                     console.log('onSuccess - la reponse est la suivante : ', response);
       
  1248                 },
       
  1249                 onFailure: function (error) {
       
  1250                     if (error.status === 200 || !error.status) {
       
  1251                         console.log('onFailure : ', error.message);
       
  1252                     } else {
       
  1253                         console.log('onFailure - Erreur (', error.status, ') : ', error.message);
       
  1254                     }
       
  1255                 }
       
  1256             };
       
  1257             for (var opt in options) {
       
  1258                 if (options.hasOwnProperty(opt)) {
       
  1259                     this.options[opt] = options[opt];
       
  1260                 }
       
  1261             }
       
  1262             if (!this.options.apiKey && !this.options.serverUrl) {
       
  1263                 throw new Error(_.getMessage('PARAM_MISSING', 'apiKey', 'serverUrl'));
       
  1264             }
       
  1265             if (this.options.rawResponse && !this.options.onSuccess) {
       
  1266                 this.options.onSuccess = function (response) {
       
  1267                     console.log('onSuccess - la réponse brute du service est la suivante : ', response);
       
  1268                 };
       
  1269             }
       
  1270             var bOnSuccess = this.options.onSuccess !== null && typeof this.options.onSuccess === 'function' ? true : false;
       
  1271             if (!bOnSuccess) {
       
  1272                 throw new Error(_.getMessage('PARAM_MISSING', 'onSuccess()'));
       
  1273             }
       
  1274             if (!this.options.serverUrl) {
       
  1275                 var urlByDefault = DefaultUrlService[this.CLASSNAME].url(this.options.apiKey);
       
  1276                 if (typeof urlByDefault === 'string') {
       
  1277                     this.options.serverUrl = urlByDefault;
       
  1278                 } else {
       
  1279                 }
       
  1280             }
       
  1281             if (this.options.serverUrl) {
       
  1282                 var urlsource = this.options.serverUrl;
       
  1283                 var urlparts = urlsource.split('?');
       
  1284                 this.options.serverUrl = urlparts[0];
       
  1285             }
       
  1286             this.options.httpMethod = typeof options.httpMethod === 'string' ? options.httpMethod.toUpperCase() : 'GET';
       
  1287             switch (this.options.httpMethod) {
       
  1288             case 'POST':
       
  1289             case 'GET':
       
  1290                 break;
       
  1291             case 'PUT':
       
  1292             case 'DELETE':
       
  1293             case 'HEAD':
       
  1294             case 'OPTIONS':
       
  1295                 throw new Error(_.getMessage('PARAM_NOT_SUPPORT', 'httpMethod'));
       
  1296             default:
       
  1297                 throw new Error(_.getMessage('PARAM_UNKNOWN', 'httpMethod'));
       
  1298             }
       
  1299             this.options.protocol = typeof options.protocol === 'string' ? options.protocol.toUpperCase() : 'JSONP';
       
  1300             switch (this.options.protocol) {
       
  1301             case 'JSONP':
       
  1302             case 'XHR':
       
  1303                 break;
       
  1304             default:
       
  1305                 throw new Error(_.getMessage('PARAM_UNKNOWN', 'protocol'));
       
  1306             }
       
  1307             if (this.options.protocol === 'JSONP') {
       
  1308                 this.options.httpMethod = 'GET';
       
  1309             }
       
  1310             this.options.nocache = options.nocache || false;
       
  1311             this.options.outputFormat = null;
       
  1312             this.request = null;
       
  1313             this.response = null;
       
  1314         }
       
  1315         CommonService.prototype = {
       
  1316             constructor: CommonService,
       
  1317             call: function () {
       
  1318                 function run() {
       
  1319                     this.buildRequest.call(this, onError, onBuildRequest);
       
  1320                 }
       
  1321                 run.call(this);
       
  1322                 function onBuildRequest(result) {
       
  1323                     this.callService.call(this, onError, onCallService);
       
  1324                 }
       
  1325                 function onCallService(result) {
       
  1326                     this.analyzeResponse.call(this, onError, onAnalyzeResponse);
       
  1327                 }
       
  1328                 function onAnalyzeResponse(result) {
       
  1329                     if (result) {
       
  1330                         this.options.onSuccess.call(this, result);
       
  1331                     } else {
       
  1332                         return onError.call(this, new ErrorService('Analyse de la reponse en échec !?'));
       
  1333                     }
       
  1334                 }
       
  1335                 function onError(error) {
       
  1336                     var e = error;
       
  1337                     if (!(e instanceof ErrorService)) {
       
  1338                         e = new ErrorService(error.message);
       
  1339                     }
       
  1340                     this.options.onFailure.call(this, e);
       
  1341                 }
       
  1342             },
       
  1343             buildRequest: function (error, success) {
       
  1344             },
       
  1345             callService: function (error, success) {
       
  1346                 var strUrlProxified = null;
       
  1347                 var strData = this.request;
       
  1348                 var bUrlProxified = this.options.proxyURL && this.options.protocol === 'XHR' ? true : false;
       
  1349                 this.options.serverUrl = Helper.normalyzeUrl(this.options.serverUrl, { 'gp-access-lib': '1.0.0-beta3' }, false);
       
  1350                 if (bUrlProxified) {
       
  1351                     if (this.options.httpMethod === 'GET') {
       
  1352                         strUrlProxified = this.options.proxyURL + Helper.normalyzeUrl(this.options.serverUrl, this.request, true);
       
  1353                         strData = null;
       
  1354                     }
       
  1355                     if (this.options.httpMethod === 'POST') {
       
  1356                         strUrlProxified = this.options.proxyURL + Helper.normalyzeUrl(this.options.serverUrl, null, true);
       
  1357                         strData = this.request;
       
  1358                     }
       
  1359                 }
       
  1360                 var self = this;
       
  1361                 var options = {
       
  1362                     url: strUrlProxified || this.options.serverUrl,
       
  1363                     method: this.options.httpMethod,
       
  1364                     protocol: this.options.protocol,
       
  1365                     timeOut: this.options.timeOut || 0,
       
  1366                     format: this.options.outputFormat,
       
  1367                     nocache: this.options.nocache || false,
       
  1368                     wrap: this.options.protocol === 'XHR' ? false : true,
       
  1369                     callbackSuffix: this.options.callbackSuffix,
       
  1370                     data: strData,
       
  1371                     headers: null,
       
  1372                     content: this.options.contentType || 'application/xml',
       
  1373                     scope: this.options.scope || this,
       
  1374                     onResponse: function (response) {
       
  1375                         var content = null;
       
  1376                         if (self.options.protocol == 'XHR') {
       
  1377                             content = response;
       
  1378                         }
       
  1379                         if (self.options.protocol == 'JSONP') {
       
  1380                             if (response) {
       
  1381                                 if (response.http) {
       
  1382                                     if (response.http.status !== 200) {
       
  1383                                         error.call(self, new ErrorService({
       
  1384                                             status: response.http.status,
       
  1385                                             message: response.http.error,
       
  1386                                             type: ErrorService.TYPE_SRVERR
       
  1387                                         }));
       
  1388                                         return;
       
  1389                                     } else {
       
  1390                                         content = response.xml;
       
  1391                                     }
       
  1392                                 } else {
       
  1393                                     content = response;
       
  1394                                 }
       
  1395                             } else {
       
  1396                                 error.call(self, new ErrorService('Le contenu de la reponse est vide !?'));
       
  1397                                 return;
       
  1398                             }
       
  1399                         }
       
  1400                         self.response = content;
       
  1401                         success.call(self, content);
       
  1402                     },
       
  1403                     onFailure: function (e) {
       
  1404                         e.type = ErrorService.TYPE_SRVERR;
       
  1405                         error.call(self, new ErrorService(e));
       
  1406                     },
       
  1407                     onTimeOut: function () {
       
  1408                         error.call(self, new ErrorService('TimeOut!'));
       
  1409                     }
       
  1410                 };
       
  1411                 Protocol.send(options);
       
  1412             },
       
  1413             analyzeResponse: function (error, success) {
       
  1414             }
       
  1415         };
       
  1416         return CommonService;
       
  1417     }(UtilsLoggerByDefault, UtilsHelper, UtilsMessagesResources, ProtocolsProtocol, ExceptionsErrorService, ServicesDefaultUrlService);
       
  1418     ServicesAltiRequestModelAltiRequest = function (Logger) {
       
  1419         function AltiRequest(options) {
       
  1420             if (!(this instanceof AltiRequest)) {
       
  1421                 throw new TypeError('AltiRequest constructor cannot be called as a function.');
       
  1422             }
       
  1423             this.options = options || {};
       
  1424             this.positions = this.options.positions || [];
       
  1425             this.delimiter = this.options.delimiter || '|';
       
  1426             this.indent = this.options.indent || false;
       
  1427             this.crs = this.options.crs || 'CRS:84';
       
  1428             this.format = this.options.format || 'json';
       
  1429         }
       
  1430         AltiRequest.CLASSNAME = 'AltiRequest';
       
  1431         AltiRequest.prototype = {
       
  1432             constructor: AltiRequest,
       
  1433             setPositions: function (lstPosition) {
       
  1434                 var positions = [];
       
  1435                 for (var i = 0; i < lstPosition.length; i++) {
       
  1436                     var o = lstPosition[i];
       
  1437                     if (o.lon && o.lat) {
       
  1438                         positions.push(o);
       
  1439                     }
       
  1440                 }
       
  1441                 this.positions = positions;
       
  1442             },
       
  1443             getPositions: function (pos) {
       
  1444                 if (!pos) {
       
  1445                     return this.positions;
       
  1446                 }
       
  1447                 var index = this.positions.length - 1;
       
  1448                 if (pos > index || pos < index) {
       
  1449                     return this.positions;
       
  1450                 }
       
  1451                 return this.positions[pos];
       
  1452             },
       
  1453             addPositions: function (lstPosition) {
       
  1454                 for (var i = 0; i < lstPosition.length; i++) {
       
  1455                     var o = lstPosition[i];
       
  1456                     if (o.lon && o.lat) {
       
  1457                         this.positions.push(lstPosition[i]);
       
  1458                     }
       
  1459                 }
       
  1460             },
       
  1461             getLon: function () {
       
  1462                 var lstLon = [];
       
  1463                 for (var i = 0; i < this.positions.length; i++) {
       
  1464                     lstLon.push(this.positions[i].lon);
       
  1465                 }
       
  1466                 return lstLon.join(this.delimiter);
       
  1467             },
       
  1468             getLat: function () {
       
  1469                 var lstLat = [];
       
  1470                 for (var i = 0; i < this.positions.length; i++) {
       
  1471                     lstLat.push(this.positions[i].lat);
       
  1472                 }
       
  1473                 return lstLat.join(this.delimiter);
       
  1474             }
       
  1475         };
       
  1476         AltiRequest.prototype.getData = function () {
       
  1477             var map = [];
       
  1478             map.push({
       
  1479                 k: 'lon',
       
  1480                 v: this.getLon()
       
  1481             });
       
  1482             map.push({
       
  1483                 k: 'lat',
       
  1484                 v: this.getLat()
       
  1485             });
       
  1486             map.push({
       
  1487                 k: 'delimiter',
       
  1488                 v: this.delimiter
       
  1489             });
       
  1490             map.push({
       
  1491                 k: 'indent',
       
  1492                 v: this.indent
       
  1493             });
       
  1494             map.push({
       
  1495                 k: 'crs',
       
  1496                 v: this.crs
       
  1497             });
       
  1498             map.push({
       
  1499                 k: 'format',
       
  1500                 v: this.format
       
  1501             });
       
  1502             return map;
       
  1503         };
       
  1504         return AltiRequest;
       
  1505     }(UtilsLoggerByDefault);
       
  1506     ServicesAltiRequestModelAltiElevationRequest = function (Logger, AltiRequest) {
       
  1507         function AltiElevationRequest(options) {
       
  1508             if (!(this instanceof AltiElevationRequest)) {
       
  1509                 throw new TypeError('AltiElevationRequest constructor cannot be called as a function.');
       
  1510             }
       
  1511             this.CLASSNAME = 'AltiElevationRequest';
       
  1512             AltiRequest.apply(this, arguments);
       
  1513             this.zonly = this.options.zonly || false;
       
  1514         }
       
  1515         AltiElevationRequest.prototype = Object.create(AltiRequest.prototype, {
       
  1516             zonly: {
       
  1517                 get: function () {
       
  1518                     return this._zonly;
       
  1519                 },
       
  1520                 set: function (z) {
       
  1521                     this._zonly = z;
       
  1522                 }
       
  1523             }
       
  1524         });
       
  1525         AltiElevationRequest.prototype.constructor = AltiElevationRequest;
       
  1526         AltiElevationRequest.prototype.getData = function () {
       
  1527             var map = [];
       
  1528             map.push({
       
  1529                 k: 'lon',
       
  1530                 v: this.getLon()
       
  1531             });
       
  1532             map.push({
       
  1533                 k: 'lat',
       
  1534                 v: this.getLat()
       
  1535             });
       
  1536             map.push({
       
  1537                 k: 'indent',
       
  1538                 v: this.indent
       
  1539             });
       
  1540             map.push({
       
  1541                 k: 'crs',
       
  1542                 v: this.crs
       
  1543             });
       
  1544             map.push({
       
  1545                 k: 'zonly',
       
  1546                 v: this.zonly
       
  1547             });
       
  1548             map.push({
       
  1549                 k: 'format',
       
  1550                 v: this.format
       
  1551             });
       
  1552             return map;
       
  1553         };
       
  1554         return AltiElevationRequest;
       
  1555     }(UtilsLoggerByDefault, ServicesAltiRequestModelAltiRequest);
       
  1556     ServicesAltiRequestModelAltiProfilRequest = function (Logger, AltiRequest) {
       
  1557         function AltiProfilRequest(options) {
       
  1558             if (!(this instanceof AltiProfilRequest)) {
       
  1559                 throw new TypeError('AltiProfilRequest constructor cannot be called as a function.');
       
  1560             }
       
  1561             this.CLASSNAME = 'AltiProfilRequest';
       
  1562             AltiRequest.apply(this, arguments);
       
  1563             this.sampling = this.options.sampling || 3;
       
  1564         }
       
  1565         AltiProfilRequest.prototype = Object.create(AltiRequest.prototype, {
       
  1566             sampling: {
       
  1567                 get: function () {
       
  1568                     return this._sampling;
       
  1569                 },
       
  1570                 set: function (value) {
       
  1571                     this._sampling = value;
       
  1572                 }
       
  1573             }
       
  1574         });
       
  1575         AltiProfilRequest.prototype.constructor = AltiProfilRequest;
       
  1576         AltiProfilRequest.prototype.getData = function () {
       
  1577             var map = [];
       
  1578             map.push({
       
  1579                 k: 'lon',
       
  1580                 v: this.getLon()
       
  1581             });
       
  1582             map.push({
       
  1583                 k: 'lat',
       
  1584                 v: this.getLat()
       
  1585             });
       
  1586             map.push({
       
  1587                 k: 'indent',
       
  1588                 v: this.indent
       
  1589             });
       
  1590             map.push({
       
  1591                 k: 'crs',
       
  1592                 v: this.crs
       
  1593             });
       
  1594             map.push({
       
  1595                 k: 'sampling',
       
  1596                 v: this.sampling
       
  1597             });
       
  1598             map.push({
       
  1599                 k: 'format',
       
  1600                 v: this.format
       
  1601             });
       
  1602             return map;
       
  1603         };
       
  1604         return AltiProfilRequest;
       
  1605     }(UtilsLoggerByDefault, ServicesAltiRequestModelAltiRequest);
       
  1606     ServicesAltiRequestAltiRequestREST = function (Logger, _, AltiElevationRequest, AltiProfilRequest) {
       
  1607         function AltiRequestREST(options) {
       
  1608             if (!(this instanceof AltiRequestREST)) {
       
  1609                 throw new TypeError('AltiRequestREST constructor cannot be called as a function.');
       
  1610             }
       
  1611             this.options = options || {};
       
  1612             if (!this.options) {
       
  1613                 throw new Error(_.getMessage('PARAM_EMPTY', 'options'));
       
  1614             }
       
  1615             if (!this.options.type) {
       
  1616                 throw new Error(_.getMessage('PARAM_EMPTY', 'type (Elevation or Profil)'));
       
  1617             }
       
  1618             this.DataObject = null;
       
  1619             switch (this.options.type) {
       
  1620             case 'Elevation':
       
  1621                 this.DataObject = new AltiElevationRequest(this.options.param);
       
  1622                 break;
       
  1623             case 'Profil':
       
  1624                 this.DataObject = new AltiProfilRequest(this.options.param);
       
  1625                 break;
       
  1626             default:
       
  1627                 throw new Error(_.getMessage('PARAM_TYPE', 'type (Elevation or Profil)'));
       
  1628             }
       
  1629             this.method = this.options.method || 'GET';
       
  1630         }
       
  1631         AltiRequestREST.prototype = {
       
  1632             requestString: null,
       
  1633             constructor: AltiRequestREST,
       
  1634             template: {
       
  1635                 get: {
       
  1636                     value: 'lon=__LON__&lat=__LAT__&indent=__INDENT__&crs=\'__CRS__\'',
       
  1637                     input: {
       
  1638                         point: '&zonly=__ZONLY__',
       
  1639                         profil: '&sampling=__SAMPLING__'
       
  1640                     }
       
  1641                 },
       
  1642                 post: {
       
  1643                     value: 'lon=__LON__\n' + 'lat=__LAT__\n' + 'indent=__INDENT__\n' + 'crs=\'__CRS__\'\n',
       
  1644                     input: {
       
  1645                         point: 'zonly=__ZONLY__',
       
  1646                         profil: 'sampling=__SAMPLING__'
       
  1647                     }
       
  1648                 }
       
  1649             },
       
  1650             processRequestString: function () {
       
  1651                 var template = '';
       
  1652                 if (this.method == 'POST') {
       
  1653                     template = this.template.post.value;
       
  1654                 } else if (this.method == 'GET') {
       
  1655                     template = this.template.get.value;
       
  1656                 }
       
  1657                 template = template.replace(/__LON__/g, this.DataObject.getLon());
       
  1658                 template = template.replace(/__LAT__/g, this.DataObject.getLat());
       
  1659                 template = template.replace(/__INDENT__/g, this.DataObject.indent);
       
  1660                 template = template.replace(/__CRS__/g, this.DataObject.crs);
       
  1661                 template = template + this.__addDataInputs();
       
  1662                 this.requestString = template;
       
  1663                 return this.requestString;
       
  1664             },
       
  1665             __addDataInputs: function () {
       
  1666                 var myTemplate;
       
  1667                 if (this.method == 'POST') {
       
  1668                     myTemplate = this.template.post;
       
  1669                 } else if (this.method == 'GET') {
       
  1670                     myTemplate = this.template.get;
       
  1671                 } else {
       
  1672                     throw new Error('No other HTTP method supported by the service !');
       
  1673                 }
       
  1674                 var tmpl = null;
       
  1675                 if (this.DataObject.CLASSNAME == 'AltiElevationRequest') {
       
  1676                     tmpl = myTemplate.input.point;
       
  1677                     return tmpl.replace(/__ZONLY__/g, this.DataObject.zonly);
       
  1678                 } else if (this.DataObject.CLASSNAME == 'AltiProfilRequest') {
       
  1679                     tmpl = myTemplate.input.profil;
       
  1680                     return tmpl.replace(/__SAMPLING__/g, this.DataObject.sampling);
       
  1681                 } else {
       
  1682                     throw new Error('No other object supported than elevation or profil !?');
       
  1683                 }
       
  1684             }
       
  1685         };
       
  1686         return AltiRequestREST;
       
  1687     }(UtilsLoggerByDefault, UtilsMessagesResources, ServicesAltiRequestModelAltiElevationRequest, ServicesAltiRequestModelAltiProfilRequest);
       
  1688     FormatsWPS = function (Logger) {
       
  1689         function WPS(options) {
       
  1690             if (!(this instanceof WPS)) {
       
  1691                 throw new TypeError('WPS constructor cannot be called as a function.');
       
  1692             }
       
  1693             this.options = options || {};
       
  1694             this.DataObject = this.options.data;
       
  1695             if (!this.DataObject) {
       
  1696                 throw new TypeError('This data object is not defined !');
       
  1697             }
       
  1698             this.paramservice = this.options.param.service || 'WPS';
       
  1699             this.paramversion = this.options.param.version || '1.0.0';
       
  1700             this.paramidentifier = this.options.param.identifier || 'gs:WPS';
       
  1701             this.paramrawdataoutput = this.options.param.rawdataoutput || 'result';
       
  1702             this.paramrequest = this.options.param.request || 'Execute';
       
  1703             this.method = this.options.method || 'GET';
       
  1704         }
       
  1705         WPS.prototype = {
       
  1706             requestString: null,
       
  1707             constructor: WPS,
       
  1708             template: {
       
  1709                 get: {
       
  1710                     value: 'service=__SERVICE__' + '&version=__VERSION__' + '&rawdataoutput=__RAWDATAOUTPUT__' + '&identifier=__IDENTIFIER__' + '&request=__REQUEST__' + '&datainputs=<!-- __DATAINPUTS__ -->',
       
  1711                     input: '__KEY__=__DATA__'
       
  1712                 },
       
  1713                 post: {
       
  1714                     value: '<?xml version="1.0" encoding="UTF-8"?>' + '<wps:__REQUEST__ version="__VERSION__" service="__SERVICE__" ' + '__NAMESPACE__ __SCHEMALOCATION__>' + '<ows:Identifier>__IDENTIFIER__</ows:Identifier>' + '<wps:DataInputs>' + '<!-- __DATAINPUTS__ -->' + '</wps:DataInputs>' + '<wps:ResponseForm>' + '<wps:RawDataOutput>' + '<ows:Identifier>__RAWDATAOUTPUT__</ows:Identifier>' + '</wps:RawDataOutput>' + '</wps:ResponseForm>' + '</wps:__REQUEST__>',
       
  1715                     input: '<wps:Input>' + '<ows:Identifier>__KEY__</ows:Identifier>' + '<wps:Data>' + '<wps:LiteralData>__DATA__</wps:LiteralData>' + '</wps:Data>' + '</wps:Input>'
       
  1716                 }
       
  1717             },
       
  1718             namespaceByDefault: function () {
       
  1719                 var ns = [
       
  1720                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
       
  1721                     'xmlns="http://www.opengis.net/wps/1.0.0"',
       
  1722                     'xmlns:wfs="http://www.opengis.net/wfs"',
       
  1723                     'xmlns:wps="http://www.opengis.net/wps/1.0.0"',
       
  1724                     'xmlns:ows="http://www.opengis.net/ows/1.1"',
       
  1725                     'xmlns:gml="http://www.opengis.net/gml"',
       
  1726                     'xmlns:ogc="http://www.opengis.net/ogc"',
       
  1727                     'xmlns:wcs="http://www.opengis.net/wcs/1.1.1"',
       
  1728                     'xmlns:xlink="http://www.w3.org/1999/xlink"'
       
  1729                 ];
       
  1730                 return ns.join(' ');
       
  1731             },
       
  1732             schemaLocationByDefault: function () {
       
  1733                 return 'xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"';
       
  1734             },
       
  1735             processRequestString: function () {
       
  1736                 var template = '';
       
  1737                 if (this.method == 'POST') {
       
  1738                     template = this.template.post.value;
       
  1739                 } else if (this.method == 'GET') {
       
  1740                     template = this.template.get.value;
       
  1741                 } else {
       
  1742                     return false;
       
  1743                 }
       
  1744                 template = template.replace(/__SERVICE__/g, this.paramservice);
       
  1745                 template = template.replace(/__VERSION__/g, this.paramversion);
       
  1746                 template = template.replace(/__RAWDATAOUTPUT__/g, this.paramrawdataoutput);
       
  1747                 template = template.replace(/__IDENTIFIER__/g, this.paramidentifier);
       
  1748                 template = template.replace(/__REQUEST__/g, this.paramrequest);
       
  1749                 if (this.method == 'POST') {
       
  1750                     template = template.replace(/__NAMESPACE__/g, this.namespaceByDefault);
       
  1751                     template = template.replace(/__SCHEMALOCATION__/g, this.schemaLocationByDefault);
       
  1752                 }
       
  1753                 template = template.replace(/<!-- __DATAINPUTS__ -->/g, this.__addDataInputs());
       
  1754                 if (!template) {
       
  1755                     return false;
       
  1756                 }
       
  1757                 this.requestString = template;
       
  1758                 return true;
       
  1759             },
       
  1760             __addDataInputs: function () {
       
  1761                 var tmpl = this.method == 'GET' ? this.template.get.input : this.template.post.input;
       
  1762                 var sep = this.method == 'GET' ? ';' : '';
       
  1763                 var result = '';
       
  1764                 var that = this;
       
  1765                 var map = this.DataObject.getData();
       
  1766                 for (var i = 0; i < map.length; i++) {
       
  1767                     (function (j) {
       
  1768                         if (sep) {
       
  1769                             sep = j == map.length - 1 ? '' : ';';
       
  1770                         }
       
  1771                         result = result.concat(that.__addDataInput(tmpl, map[j].k, map[j].v), sep);
       
  1772                     }(i));
       
  1773                 }
       
  1774                 return result;
       
  1775             },
       
  1776             __addDataInput: function (tmpl, key, data) {
       
  1777                 var tmp = tmpl;
       
  1778                 tmp = tmp.replace(/__KEY__/g, key);
       
  1779                 tmp = tmp.replace(/__DATA__/g, data);
       
  1780                 return tmp;
       
  1781             },
       
  1782             setMethod: function (method) {
       
  1783                 if (method == 'GET' || method == 'POST') {
       
  1784                     this.method = method;
       
  1785                 } else {
       
  1786                 }
       
  1787             },
       
  1788             getMethod: function () {
       
  1789                 return this.method;
       
  1790             }
       
  1791         };
       
  1792         return WPS;
       
  1793     }(UtilsLoggerByDefault);
       
  1794     ServicesAltiRequestAltiRequestWPS = function (Logger, _, WPS, AltiElevationRequest, AltiProfilRequest) {
       
  1795         var AltiRequestWPS = {
       
  1796             build: function (options) {
       
  1797                 if (!options) {
       
  1798                     throw new Error(_.getMessage('PARAM_EMPTY', 'options'));
       
  1799                 }
       
  1800                 if (!options.type) {
       
  1801                     throw new Error(_.getMessage('PARAM_EMPTY', 'type (Elevation or Profil)'));
       
  1802                 }
       
  1803                 var DataObject = null;
       
  1804                 switch (options.type) {
       
  1805                 case 'Elevation':
       
  1806                     options.wps.identifier = 'gs:WPSElevation';
       
  1807                     DataObject = new AltiElevationRequest(options.param);
       
  1808                     break;
       
  1809                 case 'Profil':
       
  1810                     options.wps.identifier = 'gs:WPSLineElevation';
       
  1811                     DataObject = new AltiProfilRequest(options.param);
       
  1812                     break;
       
  1813                 default:
       
  1814                     throw new Error(_.getMessage('PARAM_TYPE', 'type (Elevation or Profil)'));
       
  1815                 }
       
  1816                 var settings = {
       
  1817                     data: DataObject,
       
  1818                     method: options.method,
       
  1819                     param: options.wps
       
  1820                 };
       
  1821                 var rqstWPS = new WPS(settings);
       
  1822                 if (!rqstWPS.processRequestString()) {
       
  1823                     throw new Error('Enable to process request !');
       
  1824                 }
       
  1825                 return rqstWPS.requestString;
       
  1826             }
       
  1827         };
       
  1828         return AltiRequestWPS;
       
  1829     }(UtilsLoggerByDefault, UtilsMessagesResources, FormatsWPS, ServicesAltiRequestModelAltiElevationRequest, ServicesAltiRequestModelAltiProfilRequest);
       
  1830     ServicesAltiRequestAltiRequestFactory = function (Logger, ErrorService, AltiRequestREST, AltiRequestWPS) {
       
  1831         var AltiRequestFactory = {
       
  1832             build: function (options) {
       
  1833                 var request = null;
       
  1834                 var settings = {
       
  1835                     type: options.sampling ? 'Profil' : 'Elevation',
       
  1836                     method: options.httpMethod,
       
  1837                     param: {
       
  1838                         positions: null,
       
  1839                         delimiter: null,
       
  1840                         indent: null,
       
  1841                         crs: null,
       
  1842                         format: null,
       
  1843                         sampling: null,
       
  1844                         zonly: null
       
  1845                     }
       
  1846                 };
       
  1847                 settings.param.positions = options.positions;
       
  1848                 settings.param.format = options.outputFormat;
       
  1849                 settings.param.sampling = options.sampling;
       
  1850                 settings.param.zonly = options.zonly;
       
  1851                 var bOnError = options.onError !== null && typeof options.onError === 'function' ? true : false;
       
  1852                 var bOnSuccess = options.onSuccess !== null && typeof options.onSuccess === 'function' ? true : false;
       
  1853                 var message = null;
       
  1854                 switch (options.api) {
       
  1855                 case 'REST':
       
  1856                     var myReq = new AltiRequestREST(settings);
       
  1857                     if (!myReq.processRequestString()) {
       
  1858                         message = 'Error in process request (rest) !';
       
  1859                         if (bOnError) {
       
  1860                             options.onError.call(options.scope, new ErrorService(message));
       
  1861                             return;
       
  1862                         }
       
  1863                         throw new Error(message);
       
  1864                     }
       
  1865                     request = myReq.requestString;
       
  1866                     break;
       
  1867                 case 'WPS':
       
  1868                     settings.wps = {
       
  1869                         service: null,
       
  1870                         version: null,
       
  1871                         identifier: null,
       
  1872                         rawdataoutput: null,
       
  1873                         request: null
       
  1874                     };
       
  1875                     request = AltiRequestWPS.build(settings);
       
  1876                     if (!request) {
       
  1877                         message = 'Error in process request (wps) !';
       
  1878                         if (bOnError) {
       
  1879                             options.onError.call(options.scope, new ErrorService(message));
       
  1880                             return;
       
  1881                         }
       
  1882                         throw new Error(message);
       
  1883                     }
       
  1884                     break;
       
  1885                 default:
       
  1886                     message = 'Type of API is not supported by service (REST or WPS) !';
       
  1887                     if (bOnError) {
       
  1888                         options.onError.call(options.scope, new ErrorService(message));
       
  1889                         return;
       
  1890                     }
       
  1891                     throw new Error(message);
       
  1892                 }
       
  1893                 if (bOnSuccess) {
       
  1894                     options.onSuccess.call(options.scope, request);
       
  1895                 }
       
  1896                 return request;
       
  1897             }
       
  1898         };
       
  1899         return AltiRequestFactory;
       
  1900     }(UtilsLoggerByDefault, ExceptionsErrorService, ServicesAltiRequestAltiRequestREST, ServicesAltiRequestAltiRequestWPS);
       
  1901     FormatsXML = function (Logger) {
       
  1902         function XML(options) {
       
  1903             if (!(this instanceof XML)) {
       
  1904                 throw new TypeError('XML constructor cannot be called as a function.');
       
  1905             }
       
  1906             this.xmlString = null;
       
  1907             this.xmlDoc = null;
       
  1908             this.reader = null;
       
  1909             if (options) {
       
  1910                 if (options.xmlString && typeof options.xmlString === 'string') {
       
  1911                     this.xmlString = options.xmlString;
       
  1912                     this.xmlDoc = __getXMLDOC(options.xmlString);
       
  1913                 }
       
  1914                 if (options.reader) {
       
  1915                     this.setReader(options.reader);
       
  1916                 }
       
  1917             }
       
  1918         }
       
  1919         XML.prototype = {
       
  1920             constructor: XML,
       
  1921             getXMLString: function () {
       
  1922                 return this.xmlString;
       
  1923             },
       
  1924             setXMLString: function (xmlString) {
       
  1925                 if (xmlString && typeof xmlString === 'string') {
       
  1926                     this.xmlString = xmlString;
       
  1927                     this.xmlDoc = __getXMLDOC(xmlString);
       
  1928                 }
       
  1929             },
       
  1930             getReader: function () {
       
  1931                 return this.reader;
       
  1932             },
       
  1933             setReader: function (reader) {
       
  1934                 if (reader && reader.read && typeof reader.read === 'function') {
       
  1935                     this.reader = reader;
       
  1936                 }
       
  1937             },
       
  1938             getXMLDoc: function () {
       
  1939                 return this.xmlDoc;
       
  1940             },
       
  1941             setXMLDoc: function (doc) {
       
  1942                 this.xmlDoc = doc;
       
  1943             },
       
  1944             parse: function () {
       
  1945                 if (!this.xmlDoc && this.xmlString) {
       
  1946                     this.xmlDoc = __getXMLDOC(this.xmlString);
       
  1947                 }
       
  1948                 if (this.xmlDoc) {
       
  1949                     var root = __getRootNode(this.xmlDoc);
       
  1950                     if (root) {
       
  1951                         var parserOutput;
       
  1952                         if (this.reader && this.reader.read) {
       
  1953                             parserOutput = this.reader.read(root);
       
  1954                         } else {
       
  1955                             parserOutput = {};
       
  1956                             parserOutput[root.nodeName] = __readDefault(root);
       
  1957                         }
       
  1958                         return parserOutput;
       
  1959                     } else {
       
  1960                         return {};
       
  1961                     }
       
  1962                 }
       
  1963             }
       
  1964         };
       
  1965         function __getXMLDOC(xmlString) {
       
  1966             if (typeof exports === 'object') {
       
  1967                 var DOMParser = xmldom.DOMParser;
       
  1968                 return new DOMParser().parseFromString(xmlString, 'text/xml');
       
  1969             } else {
       
  1970                 var parser;
       
  1971                 var xmlDoc;
       
  1972                 var errorMsg = 'Erreur lors du parsing de la réponse du service : XML non conforme';
       
  1973                 if (window.ActiveXObject) {
       
  1974                     xmlDoc = new window.ActiveXObject('Microsoft.XMLDOM');
       
  1975                     xmlDoc.async = false;
       
  1976                     xmlDoc.loadXML(xmlString);
       
  1977                     var parseError = xmlDoc.parseError;
       
  1978                     if (parseError.errorCode) {
       
  1979                         if (parseError.line && parseError.linepos) {
       
  1980                             errorMsg += '( ligne ' + parseError.line + ', colonne ' + parseError.linepos;
       
  1981                         }
       
  1982                         if (parseError.reason) {
       
  1983                             errorMsg += ':  ' + parseError.reason + ')';
       
  1984                         }
       
  1985                         throw new Error(errorMsg);
       
  1986                     }
       
  1987                     return xmlDoc;
       
  1988                 } else if (window.DOMParser) {
       
  1989                     parser = new window.DOMParser();
       
  1990                     try {
       
  1991                         xmlDoc = parser.parseFromString(xmlString, 'text/xml');
       
  1992                     } catch (e) {
       
  1993                         if (e.message === 'SyntaxError') {
       
  1994                             throw new Error(errorMsg);
       
  1995                         } else {
       
  1996                             throw new Error('Erreur lors du parsing de la réponse du service : ' + e.message);
       
  1997                         }
       
  1998                     }
       
  1999                     if (xmlDoc.getElementsByTagName('parsererror').length > 0) {
       
  2000                         var parsererror = xmlDoc.getElementsByTagName('parsererror');
       
  2001                         for (var i = 0; i < parsererror.length; i++) {
       
  2002                             var content = parsererror[i].innerHTML;
       
  2003                             if (content.indexOf('Huge input lookup') == -1) {
       
  2004                                 errorMsg += '(' + content + ')';
       
  2005                                 throw new Error(errorMsg);
       
  2006                             }
       
  2007                         }
       
  2008                     } else if (!xmlDoc.documentElement) {
       
  2009                         throw new Error(errorMsg);
       
  2010                     }
       
  2011                     return xmlDoc;
       
  2012                 } else {
       
  2013                     throw new Error('Incompatible DOM Parser pour ce navigateur !');
       
  2014                 }
       
  2015             }
       
  2016         }
       
  2017         function __getRootNode(xmlDoc) {
       
  2018             var root;
       
  2019             if (xmlDoc.nodeType === 9) {
       
  2020                 root = xmlDoc.documentElement;
       
  2021             } else if (xmlDoc.nodeType === 1) {
       
  2022                 root = xmlDoc;
       
  2023             }
       
  2024             return root;
       
  2025         }
       
  2026         function __readDefault(node) {
       
  2027             var data = {};
       
  2028             if (node.attributes.length > 0) {
       
  2029                 var dataAttributes = __getAttributes(node);
       
  2030                 data['attributes'] = dataAttributes;
       
  2031             }
       
  2032             if (node.hasChildNodes()) {
       
  2033                 var childData = {};
       
  2034                 var child;
       
  2035                 var children = node.childNodes;
       
  2036                 for (var i = 0; i < children.length; i++) {
       
  2037                     child = children[i];
       
  2038                     if (child.nodeType === 3) {
       
  2039                         data['textContent'] = child.nodeValue;
       
  2040                     } else if (child.nodeType === 1) {
       
  2041                         childData = __readDefault(child);
       
  2042                         if (!data[child.nodeName]) {
       
  2043                             data[child.nodeName] = childData;
       
  2044                         } else {
       
  2045                             if (!Array.isArray(data[child.nodeName])) {
       
  2046                                 var old = data[child.nodeName];
       
  2047                                 data[child.nodeName] = [];
       
  2048                                 data[child.nodeName].push(old);
       
  2049                             }
       
  2050                             data[child.nodeName].push(childData);
       
  2051                         }
       
  2052                     }
       
  2053                 }
       
  2054             }
       
  2055             return data;
       
  2056         }
       
  2057         function __getAttributes(node) {
       
  2058             if (node.attributes.length > 0) {
       
  2059                 var nodeAttributes = {};
       
  2060                 var attributes = node.attributes;
       
  2061                 for (var i = 0; i < attributes.length; i++) {
       
  2062                     var attribute = attributes[i];
       
  2063                     nodeAttributes[attribute.nodeName] = attribute.nodeValue;
       
  2064                 }
       
  2065                 return nodeAttributes;
       
  2066             }
       
  2067         }
       
  2068         return XML;
       
  2069     }(UtilsLoggerByDefault);
       
  2070     ServicesAltiResponseModelAltiResponse = function () {
       
  2071         function AltiResponse() {
       
  2072             if (!(this instanceof AltiResponse)) {
       
  2073                 throw new TypeError('AltiResponse constructor cannot be called as a function.');
       
  2074             }
       
  2075             this.elevations = [];
       
  2076         }
       
  2077         AltiResponse.prototype = { constructor: AltiResponse };
       
  2078         return AltiResponse;
       
  2079     }();
       
  2080     ServicesAltiResponseModelElevation = function () {
       
  2081         function Elevation() {
       
  2082             if (!(this instanceof Elevation)) {
       
  2083                 throw new TypeError('Elevation constructor cannot be called as a function.');
       
  2084             }
       
  2085             this.z = null;
       
  2086         }
       
  2087         Elevation.prototype = { constructor: Elevation };
       
  2088         return Elevation;
       
  2089     }();
       
  2090     ServicesAltiFormatsAltiResponseReader = function (Logger, AltiResponse, Elevation) {
       
  2091         var AltiResponseReader = {};
       
  2092         AltiResponseReader.READERS = {
       
  2093             elevations: function (root) {
       
  2094                 var altiResponse = new AltiResponse();
       
  2095                 if (root.hasChildNodes()) {
       
  2096                     var children = root.childNodes;
       
  2097                     var child;
       
  2098                     var elevation;
       
  2099                     for (var i = 0; i < children.length; i++) {
       
  2100                         child = children[i];
       
  2101                         if (AltiResponseReader.READERS[child.nodeName]) {
       
  2102                             elevation = AltiResponseReader.READERS[child.nodeName](child);
       
  2103                             altiResponse.elevations.push(elevation);
       
  2104                         }
       
  2105                     }
       
  2106                 }
       
  2107                 return altiResponse;
       
  2108             },
       
  2109             elevation: function (node) {
       
  2110                 var elevation = new Elevation();
       
  2111                 if (node.hasChildNodes()) {
       
  2112                     var children = node.childNodes;
       
  2113                     var child;
       
  2114                     for (var i = 0; i < children.length; i++) {
       
  2115                         child = children[i];
       
  2116                         if (AltiResponseReader.READERS[child.nodeName]) {
       
  2117                             AltiResponseReader.READERS[child.nodeName](child, elevation);
       
  2118                         }
       
  2119                     }
       
  2120                 }
       
  2121                 return elevation;
       
  2122             },
       
  2123             lat: function (node, elevation) {
       
  2124                 var textNode = node.firstChild;
       
  2125                 if (textNode && textNode.nodeType === 3) {
       
  2126                     elevation.lat = parseFloat(textNode.nodeValue);
       
  2127                 } else {
       
  2128                     throw new Error('Erreur dans la lecture de la réponse du service: latitude attendue mais absente');
       
  2129                 }
       
  2130             },
       
  2131             lon: function (node, elevation) {
       
  2132                 var textNode = node.firstChild;
       
  2133                 if (textNode && textNode.nodeType === 3) {
       
  2134                     elevation.lon = parseFloat(textNode.nodeValue);
       
  2135                 } else {
       
  2136                     throw new Error('Erreur dans la lecture de la réponse du service: longitude attendue mais absente');
       
  2137                 }
       
  2138             },
       
  2139             z: function (node, elevation) {
       
  2140                 var textNode = node.firstChild;
       
  2141                 if (textNode && textNode.nodeType === 3) {
       
  2142                     if (elevation) {
       
  2143                         elevation.z = parseFloat(textNode.nodeValue);
       
  2144                     } else {
       
  2145                         elevation = new Elevation();
       
  2146                         elevation.z = parseFloat(textNode.nodeValue);
       
  2147                         return elevation;
       
  2148                     }
       
  2149                 } else {
       
  2150                     throw new Error('Erreur dans la lecture de la réponse du service: altitude attendue mais absente');
       
  2151                 }
       
  2152             },
       
  2153             acc: function (node, elevation) {
       
  2154                 var textNode = node.firstChild;
       
  2155                 if (textNode && textNode.nodeType === 3) {
       
  2156                     elevation.acc = parseFloat(textNode.nodeValue);
       
  2157                 } else {
       
  2158                     throw new Error('Erreur dans la lecture de la réponse du service: précision (acc) attendue mais absente');
       
  2159                 }
       
  2160             },
       
  2161             exceptionreport: function (node) {
       
  2162                 var response = {};
       
  2163                 if (node.hasChildNodes()) {
       
  2164                     var children = node.childNodes;
       
  2165                     var child;
       
  2166                     for (var i = 0; i < children.length; i++) {
       
  2167                         child = children[i];
       
  2168                         if (child.nodeName === 'Exception') {
       
  2169                             response.exceptionReport = AltiResponseReader.READERS.exception(child);
       
  2170                         }
       
  2171                     }
       
  2172                 }
       
  2173                 return response;
       
  2174             },
       
  2175             exception: function (node) {
       
  2176                 var exceptionReport = {};
       
  2177                 var exceptionCode = node.getAttribute('exceptionCode');
       
  2178                 if (exceptionCode) {
       
  2179                     exceptionReport.exceptionCode = exceptionCode;
       
  2180                 }
       
  2181                 var textNode = node.firstChild;
       
  2182                 if (textNode && textNode.nodeType === 3) {
       
  2183                     exceptionReport.exception = textNode.nodeValue;
       
  2184                 }
       
  2185                 return exceptionReport;
       
  2186             },
       
  2187             error: function (node) {
       
  2188                 var response = { error: {} };
       
  2189                 if (node.hasChildNodes()) {
       
  2190                     var children = node.childNodes;
       
  2191                     var child;
       
  2192                     for (var i = 0; i < children.length; i++) {
       
  2193                         child = children[i];
       
  2194                         var textNode;
       
  2195                         if (child.nodeType === 1 && child.nodeName === 'code') {
       
  2196                             textNode = child.firstChild;
       
  2197                             if (textNode && textNode.nodeType === 3) {
       
  2198                                 response.error.code = textNode.nodeValue;
       
  2199                             }
       
  2200                         }
       
  2201                         if (child.nodeType === 1 && child.nodeName === 'description') {
       
  2202                             textNode = child.firstChild;
       
  2203                             if (textNode && textNode.nodeType === 3) {
       
  2204                                 response.error.description = textNode.nodeValue;
       
  2205                             }
       
  2206                         }
       
  2207                     }
       
  2208                 }
       
  2209                 return response;
       
  2210             }
       
  2211         };
       
  2212         AltiResponseReader.read = function (root) {
       
  2213             if (root.nodeName === 'elevations') {
       
  2214                 var altiResponse = AltiResponseReader.READERS.elevations(root);
       
  2215                 return altiResponse;
       
  2216             } else if (root.nodeName === 'ExceptionReport') {
       
  2217                 var exceptionReport = AltiResponseReader.READERS.exceptionreport(root);
       
  2218                 return exceptionReport;
       
  2219             } else if (root.nodeName === 'error') {
       
  2220                 var error = AltiResponseReader.READERS.error(root);
       
  2221                 return error;
       
  2222             } else {
       
  2223                 throw new Error('Erreur lors de la lecture de la réponse : elle n\'est pas au format attendu.');
       
  2224             }
       
  2225         };
       
  2226         return AltiResponseReader;
       
  2227     }(UtilsLoggerByDefault, ServicesAltiResponseModelAltiResponse, ServicesAltiResponseModelElevation);
       
  2228     ServicesAltiResponseAltiResponseFactory = function (Logger, ErrorService, MRes, XML, AltiResponseReader, AltiResponse, Elevation) {
       
  2229         var AltiResponseFactory = {
       
  2230             build: function (options) {
       
  2231                 var data = null;
       
  2232                 if (options.response) {
       
  2233                     if (options.rawResponse) {
       
  2234                         data = options.response;
       
  2235                     } else {
       
  2236                         switch (options.outputFormat) {
       
  2237                         case 'xml':
       
  2238                             try {
       
  2239                                 var p = new XML({ reader: AltiResponseReader });
       
  2240                                 if (typeof options.response === 'string') {
       
  2241                                     p.setXMLString(options.response);
       
  2242                                 } else {
       
  2243                                     p.setXMLDoc(options.response);
       
  2244                                 }
       
  2245                                 data = p.parse();
       
  2246                                 if (!data) {
       
  2247                                     throw new Error(MRes.getMessage('SERVICE_RESPONSE_EXCEPTION_2'));
       
  2248                                 }
       
  2249                             } catch (e) {
       
  2250                                 var message = e.message;
       
  2251                                 options.onError.call(options.scope, new ErrorService({
       
  2252                                     message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', message),
       
  2253                                     status: 200,
       
  2254                                     type: ErrorService.TYPE_SRVERR
       
  2255                                 }));
       
  2256                                 return;
       
  2257                             }
       
  2258                             break;
       
  2259                         case 'json':
       
  2260                             var JSONResponse;
       
  2261                             if (typeof options.response === 'string') {
       
  2262                                 JSONResponse = window.JSON.parse(options.response);
       
  2263                             } else {
       
  2264                                 JSONResponse = options.response;
       
  2265                             }
       
  2266                             if (JSONResponse.error) {
       
  2267                                 options.onError.call(options.scope, new ErrorService({
       
  2268                                     message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', JSONResponse.error.description),
       
  2269                                     status: 200,
       
  2270                                     type: ErrorService.TYPE_SRVERR
       
  2271                                 }));
       
  2272                                 return;
       
  2273                             }
       
  2274                             if (JSONResponse) {
       
  2275                                 var elevations = JSONResponse.elevations;
       
  2276                                 var altiResponse = new AltiResponse();
       
  2277                                 var elevation;
       
  2278                                 if (Array.isArray(elevations) && elevations.length) {
       
  2279                                     for (var i = 0; i < elevations.length; i++) {
       
  2280                                         elevation = new Elevation();
       
  2281                                         if (typeof elevations[i] === 'object') {
       
  2282                                             if (elevations[i].lon) {
       
  2283                                                 elevation.lon = elevations[i].lon;
       
  2284                                             }
       
  2285                                             if (elevations[i].lat) {
       
  2286                                                 elevation.lat = elevations[i].lat;
       
  2287                                             }
       
  2288                                             if (elevations[i].z) {
       
  2289                                                 elevation.z = elevations[i].z;
       
  2290                                             }
       
  2291                                             if (elevations[i].acc) {
       
  2292                                                 elevation.acc = elevations[i].acc;
       
  2293                                             }
       
  2294                                         } else if (typeof elevations[i] === 'number') {
       
  2295                                             elevation.z = elevations[i];
       
  2296                                         }
       
  2297                                         if (Array.isArray(altiResponse.elevations)) {
       
  2298                                             altiResponse.elevations.push(elevation);
       
  2299                                         }
       
  2300                                     }
       
  2301                                 }
       
  2302                                 data = altiResponse;
       
  2303                             }
       
  2304                             if (!data) {
       
  2305                                 options.onError.call(options.scope, new ErrorService({
       
  2306                                     message: MRes.getMessage('SERVICE_RESPONSE_ANALYSE_2'),
       
  2307                                     type: ErrorService.TYPE_UNKERR,
       
  2308                                     status: -1
       
  2309                                 }));
       
  2310                                 return;
       
  2311                             }
       
  2312                             break;
       
  2313                         default:
       
  2314                             options.onError.call(options.scope, new ErrorService({
       
  2315                                 message: MRes.getMessage('SERVICE_RESPONSE_FORMAT_2'),
       
  2316                                 type: ErrorService.TYPE_UNKERR,
       
  2317                                 status: -1
       
  2318                             }));
       
  2319                             return;
       
  2320                         }
       
  2321                         if (data.exceptionReport) {
       
  2322                             options.onError.call(options.scope, new ErrorService({
       
  2323                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  2324                                 type: ErrorService.TYPE_SRVERR,
       
  2325                                 status: 200
       
  2326                             }));
       
  2327                             return;
       
  2328                         } else if (data.error) {
       
  2329                             var errorMess = data.error.description;
       
  2330                             options.onError.call(options.scope, new ErrorService({
       
  2331                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', errorMess),
       
  2332                                 type: ErrorService.TYPE_SRVERR,
       
  2333                                 status: 200
       
  2334                             }));
       
  2335                             return;
       
  2336                         }
       
  2337                     }
       
  2338                 } else {
       
  2339                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  2340                     return;
       
  2341                 }
       
  2342                 options.onSuccess.call(options.scope, data);
       
  2343                 return;
       
  2344             }
       
  2345         };
       
  2346         return AltiResponseFactory;
       
  2347     }(UtilsLoggerByDefault, ExceptionsErrorService, UtilsMessagesResources, FormatsXML, ServicesAltiFormatsAltiResponseReader, ServicesAltiResponseModelAltiResponse, ServicesAltiResponseModelElevation);
       
  2348     ServicesAltiAlti = function (Logger, _, ErrorService, CommonService, DefaultUrlService, AltiRequestFactory, AltiResponseFactory) {
       
  2349         function Alti(options) {
       
  2350             if (!(this instanceof Alti)) {
       
  2351                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'Alti'));
       
  2352             }
       
  2353             this.CLASSNAME = 'Alti';
       
  2354             CommonService.apply(this, arguments);
       
  2355             if (!options.positions) {
       
  2356                 throw new Error(_.getMessage('PARAM_MISSING', 'positions'));
       
  2357             }
       
  2358             if (options.positions.length === 0) {
       
  2359                 throw new Error(_.getMessage('PARAM_EMPTY', 'positions'));
       
  2360             }
       
  2361             this.options.positions = options.positions;
       
  2362             this.options.outputFormat = typeof options.outputFormat === 'string' ? options.outputFormat.toLowerCase() : 'xml';
       
  2363             this.options.sampling = options.sampling || null;
       
  2364             this.options.api = typeof options.api === 'string' ? options.api.toUpperCase() : 'REST';
       
  2365             if (this.options.api === 'REST') {
       
  2366                 this.options.httpMethod = 'GET';
       
  2367             }
       
  2368             this.options.zonly = options.zonly || false;
       
  2369             if (!this.options.serverUrl) {
       
  2370                 var lstUrlByDefault = DefaultUrlService.Alti.url(this.options.apiKey);
       
  2371                 var urlFound = null;
       
  2372                 switch (this.options.api) {
       
  2373                 case 'WPS':
       
  2374                     urlFound = lstUrlByDefault.wps;
       
  2375                     break;
       
  2376                 case 'REST':
       
  2377                     var key = (options.sampling ? 'profil' : 'elevation') + '-' + this.options.outputFormat;
       
  2378                     urlFound = lstUrlByDefault[key];
       
  2379                     break;
       
  2380                 default:
       
  2381                     throw new Error(_.getMessage('PARAM_UNKNOWN', 'api'));
       
  2382                 }
       
  2383                 if (!urlFound) {
       
  2384                     throw new Error('Url by default not found !');
       
  2385                 }
       
  2386                 this.options.serverUrl = urlFound;
       
  2387             }
       
  2388             var idx = this.options.serverUrl.lastIndexOf('.');
       
  2389             if (idx !== -1) {
       
  2390                 var extension = this.options.serverUrl.substring(idx + 1);
       
  2391                 if (extension && extension.length < 5) {
       
  2392                     switch (extension.toLowerCase()) {
       
  2393                     case 'json':
       
  2394                     case 'xml':
       
  2395                         this.options.outputFormat = extension.toLowerCase();
       
  2396                         break;
       
  2397                     default:
       
  2398                         throw new Error('type of service : unknown or unsupported (json or xml) !');
       
  2399                     }
       
  2400                 }
       
  2401             }
       
  2402         }
       
  2403         Alti.prototype = Object.create(CommonService.prototype, {});
       
  2404         Alti.prototype.constructor = Alti;
       
  2405         Alti.prototype.buildRequest = function (error, success) {
       
  2406             var options = {
       
  2407                 httpMethod: this.options.httpMethod,
       
  2408                 onSuccess: function (result) {
       
  2409                     this.request = result;
       
  2410                     success.call(this, this.request);
       
  2411                 },
       
  2412                 onError: error,
       
  2413                 scope: this,
       
  2414                 positions: this.options.positions,
       
  2415                 outputFormat: this.options.outputFormat,
       
  2416                 sampling: this.options.sampling,
       
  2417                 api: this.options.api,
       
  2418                 zonly: this.options.zonly
       
  2419             };
       
  2420             AltiRequestFactory.build(options);
       
  2421         };
       
  2422         Alti.prototype.analyzeResponse = function (error, success) {
       
  2423             if (this.response) {
       
  2424                 var options = {
       
  2425                     response: this.response,
       
  2426                     outputFormat: this.options.outputFormat,
       
  2427                     rawResponse: this.options.rawResponse,
       
  2428                     onError: error,
       
  2429                     onSuccess: success,
       
  2430                     scope: this
       
  2431                 };
       
  2432                 AltiResponseFactory.build(options);
       
  2433             } else {
       
  2434                 error.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  2435             }
       
  2436         };
       
  2437         return Alti;
       
  2438     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesCommonService, ServicesDefaultUrlService, ServicesAltiRequestAltiRequestFactory, ServicesAltiResponseAltiResponseFactory);
       
  2439     ServicesAutoConfResponseModelAutoConfResponse = function () {
       
  2440         function AutoConfResponse() {
       
  2441             if (!(this instanceof AutoConfResponse)) {
       
  2442                 throw new TypeError('AutoConfResponse constructor cannot be called as a function.');
       
  2443             }
       
  2444             this.generalOptions = {
       
  2445                 apiKeys: {},
       
  2446                 title: null,
       
  2447                 defaultGMLGFIStyle: null,
       
  2448                 theme: null,
       
  2449                 wgs84Resolutions: []
       
  2450             };
       
  2451             this.layers = {};
       
  2452             this.territories = {};
       
  2453             this.tileMatrixSets = {};
       
  2454             this.services = {};
       
  2455         }
       
  2456         AutoConfResponse.prototype = {
       
  2457             constructor: AutoConfResponse,
       
  2458             isConfLoaded: function (apiKey) {
       
  2459                 if (!apiKey) {
       
  2460                     return;
       
  2461                 }
       
  2462                 if (this.generalOptions.apiKeys[apiKey]) {
       
  2463                     return true;
       
  2464                 }
       
  2465                 return false;
       
  2466             },
       
  2467             getLayersId: function (apiKey) {
       
  2468                 return this.generalOptions.apiKeys[apiKey];
       
  2469             },
       
  2470             getLayersConf: function (apiKey) {
       
  2471                 var layers = {};
       
  2472                 var layersIdArray = this.getLayersId(apiKey);
       
  2473                 if (layersIdArray) {
       
  2474                     for (var i = 0; i < layersIdArray.length; i++) {
       
  2475                         var lyrId = layersIdArray[i];
       
  2476                         layers[lyrId] = this.layers[lyrId];
       
  2477                     }
       
  2478                 }
       
  2479                 return layers;
       
  2480             },
       
  2481             getLayerConf: function (layerId) {
       
  2482                 if (!this.layers) {
       
  2483                     return;
       
  2484                 }
       
  2485                 return this.layers[layerId];
       
  2486             },
       
  2487             getTileMatrixSets: function () {
       
  2488                 return this.tileMatrixSets;
       
  2489             },
       
  2490             getTMSConf: function (tmsID) {
       
  2491                 if (!this.tileMatrixSets) {
       
  2492                     return;
       
  2493                 }
       
  2494                 return this.tileMatrixSets[tmsID];
       
  2495             },
       
  2496             getTerritories: function () {
       
  2497                 return this.territories;
       
  2498             },
       
  2499             getTerritoryConf: function (territoryID) {
       
  2500                 if (!this.territories) {
       
  2501                     return;
       
  2502                 }
       
  2503                 return this.territories[territoryID];
       
  2504             },
       
  2505             getServices: function () {
       
  2506                 return this.services;
       
  2507             },
       
  2508             getServiceConf: function (serviceID) {
       
  2509                 if (!this.services) {
       
  2510                     return;
       
  2511                 }
       
  2512                 return this.services[serviceID];
       
  2513             }
       
  2514         };
       
  2515         return AutoConfResponse;
       
  2516     }();
       
  2517     ServicesAutoConfResponseModelConstraint = function () {
       
  2518         function Constraint() {
       
  2519             if (!(this instanceof Constraint)) {
       
  2520                 throw new TypeError('Constraint constructor cannot be called as a function.');
       
  2521             }
       
  2522             this.crs = null;
       
  2523             this.bbox = {
       
  2524                 left: null,
       
  2525                 right: null,
       
  2526                 top: null,
       
  2527                 bottom: null
       
  2528             };
       
  2529             this.minScaleDenominator = null;
       
  2530             this.maxScaleDenominator = null;
       
  2531             this.temporalExtent = [
       
  2532                 null,
       
  2533                 null
       
  2534             ];
       
  2535         }
       
  2536         Constraint.prototype = { constructor: Constraint };
       
  2537         return Constraint;
       
  2538     }();
       
  2539     ServicesAutoConfResponseModelFormat = function () {
       
  2540         function Format() {
       
  2541             if (!(this instanceof Format)) {
       
  2542                 throw new TypeError('Format constructor cannot be called as a function.');
       
  2543             }
       
  2544             this.current = null;
       
  2545             this.name = null;
       
  2546         }
       
  2547         Format.prototype = { constructor: Format };
       
  2548         return Format;
       
  2549     }();
       
  2550     ServicesAutoConfResponseModelLayer = function () {
       
  2551         function Layer() {
       
  2552             if (!(this instanceof Layer)) {
       
  2553                 throw new TypeError('Layer constructor cannot be called as a function.');
       
  2554             }
       
  2555         }
       
  2556         Layer.prototype = {
       
  2557             constructor: Layer,
       
  2558             getName: function () {
       
  2559                 return this.name;
       
  2560             },
       
  2561             getTitle: function () {
       
  2562                 return this.title;
       
  2563             },
       
  2564             getDescription: function () {
       
  2565                 return this.description;
       
  2566             },
       
  2567             getLayerId: function () {
       
  2568                 return this.layerId;
       
  2569             },
       
  2570             getQuicklookUrl: function () {
       
  2571                 return this.quicklookUrl;
       
  2572             },
       
  2573             getDefaultProjection: function () {
       
  2574                 return this.defaultProjection;
       
  2575             },
       
  2576             getProjections: function () {
       
  2577                 var projections = [];
       
  2578                 projections.push(this.defaultProjection);
       
  2579                 var proj = projections.concat(this.additionalProjections);
       
  2580                 return proj;
       
  2581             },
       
  2582             getBBOX: function () {
       
  2583                 if (!this.globalConstraint) {
       
  2584                     return;
       
  2585                 }
       
  2586                 return this.globalConstraint.bbox;
       
  2587             },
       
  2588             getMinScaleDenominator: function () {
       
  2589                 if (!this.globalConstraint) {
       
  2590                     return;
       
  2591                 }
       
  2592                 return this.globalConstraint.minScaleDenominator;
       
  2593             },
       
  2594             getMaxScaleDenominator: function () {
       
  2595                 if (!this.globalConstraint) {
       
  2596                     return;
       
  2597                 }
       
  2598                 return this.globalConstraint.maxScaleDenominator;
       
  2599             },
       
  2600             getTMSID: function () {
       
  2601                 if (this.wmtsOptions) {
       
  2602                     return this.wmtsOptions.tileMatrixSetLink;
       
  2603                 }
       
  2604                 return;
       
  2605             },
       
  2606             getServiceParams: function () {
       
  2607                 return this.serviceParams;
       
  2608             },
       
  2609             getServerUrl: function (apiKey) {
       
  2610                 if (!apiKey || !this.serviceParams || !this.serviceParams.serverUrl) {
       
  2611                     return;
       
  2612                 }
       
  2613                 return this.serviceParams.serverUrl[apiKey];
       
  2614             },
       
  2615             getLegends: function () {
       
  2616                 return this.legends;
       
  2617             },
       
  2618             getMetadata: function () {
       
  2619                 return this.metadata;
       
  2620             },
       
  2621             getStyles: function () {
       
  2622                 return this.styles;
       
  2623             },
       
  2624             getDefaultStyle: function () {
       
  2625                 if (!this.styles) {
       
  2626                     return;
       
  2627                 }
       
  2628                 var style;
       
  2629                 var s = this.styles;
       
  2630                 for (var i = 0; i < s.length; i++) {
       
  2631                     if (s[i].current === true) {
       
  2632                         style = s[i].name;
       
  2633                         break;
       
  2634                     }
       
  2635                 }
       
  2636                 return style;
       
  2637             },
       
  2638             getThematics: function () {
       
  2639                 return this.thematics;
       
  2640             },
       
  2641             getDefaultFormat: function () {
       
  2642                 if (!this.formats) {
       
  2643                     return;
       
  2644                 }
       
  2645                 var format;
       
  2646                 var f = this.formats;
       
  2647                 for (var i = 0; i < f.length; i++) {
       
  2648                     if (f[i].current === true) {
       
  2649                         format = f[i].name;
       
  2650                         break;
       
  2651                     }
       
  2652                 }
       
  2653                 return format;
       
  2654             },
       
  2655             getConstraints: function () {
       
  2656                 return this.constraints;
       
  2657             },
       
  2658             getOriginators: function () {
       
  2659                 return this.originators;
       
  2660             },
       
  2661             getDimensions: function () {
       
  2662                 return this.dimensions;
       
  2663             },
       
  2664             getAggregatedLayers: function () {
       
  2665                 if (this.isAggregate) {
       
  2666                     return this.aggregatedLayers;
       
  2667                 } else {
       
  2668                     return;
       
  2669                 }
       
  2670             }
       
  2671         };
       
  2672         return Layer;
       
  2673     }();
       
  2674     ServicesAutoConfResponseModelLegend = function () {
       
  2675         function Legend() {
       
  2676             if (!(this instanceof Legend)) {
       
  2677                 throw new TypeError('Legend constructor cannot be called as a function.');
       
  2678             }
       
  2679             this.format = null;
       
  2680             this.url = null;
       
  2681             this.minScaleDenominator = null;
       
  2682         }
       
  2683         Legend.prototype = { constructor: Legend };
       
  2684         return Legend;
       
  2685     }();
       
  2686     ServicesAutoConfResponseModelMetadata = function () {
       
  2687         function Metadata() {
       
  2688             if (!(this instanceof Metadata)) {
       
  2689                 throw new TypeError('Metadata constructor cannot be called as a function.');
       
  2690             }
       
  2691             this.format = null;
       
  2692             this.url = null;
       
  2693         }
       
  2694         Metadata.prototype = { constructor: Metadata };
       
  2695         return Metadata;
       
  2696     }();
       
  2697     ServicesAutoConfResponseModelOriginator = function () {
       
  2698         function Originator() {
       
  2699             if (!(this instanceof Originator)) {
       
  2700                 throw new TypeError('Originator constructor cannot be called as a function.');
       
  2701             }
       
  2702             this.name = null;
       
  2703             this.attribution = null;
       
  2704             this.logo = null;
       
  2705             this.url = null;
       
  2706             this.constraints = [];
       
  2707         }
       
  2708         Originator.prototype = { constructor: Originator };
       
  2709         return Originator;
       
  2710     }();
       
  2711     ServicesAutoConfResponseModelService = function () {
       
  2712         function Service() {
       
  2713             if (!(this instanceof Service)) {
       
  2714                 throw new TypeError('Service constructor cannot be called as a function.');
       
  2715             }
       
  2716             this.title = null;
       
  2717             this.serverUrl = null;
       
  2718             this.version = null;
       
  2719         }
       
  2720         Service.prototype = { constructor: Service };
       
  2721         return Service;
       
  2722     }();
       
  2723     ServicesAutoConfResponseModelStyle = function () {
       
  2724         function Style() {
       
  2725             if (!(this instanceof Style)) {
       
  2726                 throw new TypeError('Style constructor cannot be called as a function.');
       
  2727             }
       
  2728             this.name = null;
       
  2729             this.title = null;
       
  2730             this.current = null;
       
  2731         }
       
  2732         Style.prototype = { constructor: Style };
       
  2733         return Style;
       
  2734     }();
       
  2735     ServicesAutoConfResponseModelTerritory = function () {
       
  2736         function Territory() {
       
  2737             if (!(this instanceof Territory)) {
       
  2738                 throw new TypeError('Territory constructor cannot be called as a function.');
       
  2739             }
       
  2740             this.isDefault = null;
       
  2741             this.defaultCRS = null;
       
  2742             this.additionalCRS = [];
       
  2743             this.geoBBOX = {
       
  2744                 left: null,
       
  2745                 right: null,
       
  2746                 top: null,
       
  2747                 bottom: null
       
  2748             };
       
  2749             this.geoCenter = {
       
  2750                 lon: null,
       
  2751                 lat: null
       
  2752             };
       
  2753             this.defaultOptions = {
       
  2754                 resolution: null,
       
  2755                 minScaleDenominator: null,
       
  2756                 maxScaleDenominator: null
       
  2757             };
       
  2758             this.defaultLayers = [];
       
  2759         }
       
  2760         Territory.prototype = { constructor: Territory };
       
  2761         return Territory;
       
  2762     }();
       
  2763     ServicesAutoConfResponseModelThematic = function () {
       
  2764         function Thematic() {
       
  2765             if (!(this instanceof Thematic)) {
       
  2766                 throw new TypeError('Thematic constructor cannot be called as a function.');
       
  2767             }
       
  2768             this.inspire = null;
       
  2769             this.name = null;
       
  2770         }
       
  2771         Thematic.prototype = { constructor: Thematic };
       
  2772         return Thematic;
       
  2773     }();
       
  2774     ServicesAutoConfResponseModelTileMatrixSet = function () {
       
  2775         function TileMatrixSet() {
       
  2776             if (!(this instanceof TileMatrixSet)) {
       
  2777                 throw new TypeError('TileMatrixSet constructor cannot be called as a function.');
       
  2778             }
       
  2779             this.projection = null;
       
  2780             this.nativeResolutions = [];
       
  2781             this.matrixIds = [];
       
  2782             this.tileMatrices = {};
       
  2783         }
       
  2784         TileMatrixSet.prototype = {
       
  2785             constructor: TileMatrixSet,
       
  2786             getResolutions: function () {
       
  2787                 return this.nativeResolutions;
       
  2788             },
       
  2789             getMatrixIds: function () {
       
  2790                 return this.matrixIds;
       
  2791             },
       
  2792             getProjection: function () {
       
  2793                 return this.projection;
       
  2794             },
       
  2795             getTileMatrices: function () {
       
  2796                 return this.tileMatrices;
       
  2797             },
       
  2798             getTopLeftCorner: function () {
       
  2799                 var topLeftCorner;
       
  2800                 var matrices = this.getTileMatrices();
       
  2801                 if (matrices) {
       
  2802                     for (var id in matrices) {
       
  2803                         if (matrices.hasOwnProperty(id)) {
       
  2804                             topLeftCorner = matrices[id].topLeftCorner;
       
  2805                             break;
       
  2806                         }
       
  2807                     }
       
  2808                 }
       
  2809                 return topLeftCorner;
       
  2810             }
       
  2811         };
       
  2812         return TileMatrixSet;
       
  2813     }();
       
  2814     ServicesAutoConfResponseModelTileMatrix = function () {
       
  2815         function TileMatrix() {
       
  2816             if (!(this instanceof TileMatrix)) {
       
  2817                 throw new TypeError('TileMatrix constructor cannot be called as a function.');
       
  2818             }
       
  2819             this.matrixId = null;
       
  2820             this.matrixHeight = null;
       
  2821             this.matrixWidth = null;
       
  2822             this.scaleDenominator = null;
       
  2823             this.tileHeight = null;
       
  2824             this.tileWidth = null;
       
  2825             this.topLeftCorner = null;
       
  2826         }
       
  2827         TileMatrix.prototype = {
       
  2828             constructor: TileMatrix,
       
  2829             getTopLeftCorner: function () {
       
  2830                 return this.topLeftCorner;
       
  2831             },
       
  2832             getScaleDenominator: function () {
       
  2833                 return this.scaleDenominator;
       
  2834             },
       
  2835             getTileHeight: function () {
       
  2836                 return this.tileHeight;
       
  2837             },
       
  2838             getTileWidth: function () {
       
  2839                 return this.tileWidth;
       
  2840             },
       
  2841             getMatrixHeight: function () {
       
  2842                 return this.matrixHeight;
       
  2843             },
       
  2844             getMatrixWidth: function () {
       
  2845                 return this.matrixWidth;
       
  2846             }
       
  2847         };
       
  2848         return TileMatrix;
       
  2849     }();
       
  2850     ServicesAutoConfResponseModelTileMatrixLimit = function () {
       
  2851         function TileMatrixLimit() {
       
  2852             if (!(this instanceof TileMatrixLimit)) {
       
  2853                 throw new TypeError('TileMatrixLimit constructor cannot be called as a function.');
       
  2854             }
       
  2855             this.minTileRow = null;
       
  2856             this.maxTileRow = null;
       
  2857             this.minTileCol = null;
       
  2858             this.maxTileCol = null;
       
  2859         }
       
  2860         TileMatrixLimit.prototype = { constructor: TileMatrixLimit };
       
  2861         return TileMatrixLimit;
       
  2862     }();
       
  2863     ServicesAutoConfFormatsAutoConfResponseReader = function (Logger, AutoConfResponse, Constraint, Format, Layer, Legend, Metadata, Originator, Service, Style, Territory, Thematic, TileMatrixSet, TileMatrix, TileMatrixLimit) {
       
  2864         var AutoConfResponseReader = {};
       
  2865         AutoConfResponseReader.VERSION = '1.1.0';
       
  2866         AutoConfResponseReader.NAMESPACES = {
       
  2867             xmlns: 'http://www.opengis.net/context',
       
  2868             gpp: 'http://api.ign.fr/geoportail',
       
  2869             ows: 'http://www.opengis.net/ows/1.1',
       
  2870             sld: 'http://www.opengis.net/sld',
       
  2871             wmts: 'http://www.opengis.net/wmts/1.0',
       
  2872             xlink: 'http://www.w3.org/1999/xlink',
       
  2873             xsi: 'http://www.w3.org/2001/XMLSchema-instance'
       
  2874         };
       
  2875         AutoConfResponseReader.SCHEMALOCATION = [
       
  2876             'http://www.opengis.net/context http://gpp3-wxs.ign.fr/schemas/extContext.xsd http://api.ign.fr/geoportail http://wxs.ign.fr/schemas/autoconf/autoconf.xsd',
       
  2877             'http://www.opengis.net/context http://gpp3-wxs.ign.fr/schemas/extContext.xsd http://api.ign.fr/geoportail http://gpp3-wxs.ign.fr/schemas/autoconf.xsd'
       
  2878         ];
       
  2879         AutoConfResponseReader.DEFAULTPREFIX = 'context';
       
  2880         AutoConfResponseReader.READERS = {
       
  2881             context: {
       
  2882                 ViewContext: function (viewContextNode) {
       
  2883                     __checkServiceAttributes(viewContextNode);
       
  2884                     var config = new AutoConfResponse();
       
  2885                     __getChildNodes(viewContextNode, config);
       
  2886                     return config;
       
  2887                 },
       
  2888                 Title: function (titleNode, data) {
       
  2889                     if (data && data.generalOptions) {
       
  2890                         data.generalOptions.title = __getChildValue(titleNode);
       
  2891                     } else if (data && data.lyr) {
       
  2892                         data.lyr.title = __getChildValue(titleNode);
       
  2893                     }
       
  2894                 },
       
  2895                 Abstract: function (node, data) {
       
  2896                     if (data && data.lyr) {
       
  2897                         data.lyr.description = __getChildValue(node);
       
  2898                     }
       
  2899                 },
       
  2900                 Server: function (node, data) {
       
  2901                     var serverId = node.getAttribute('service');
       
  2902                     var title = node.getAttribute('title');
       
  2903                     var version = node.getAttribute('version');
       
  2904                     if (serverId) {
       
  2905                         if (data && data.services && typeof data.services === 'object' && !data.services[serverId]) {
       
  2906                             var s = new Service();
       
  2907                             s.title = title;
       
  2908                             s.version = version;
       
  2909                             __getChildNodes(node, s);
       
  2910                             data.services[serverId] = s;
       
  2911                         } else if (data && data.lyr) {
       
  2912                             if (!data.lyr.serviceParams) {
       
  2913                                 data.lyr.serviceParams = {};
       
  2914                             }
       
  2915                             data.lyr.serviceParams.id = serverId;
       
  2916                             data.lyr.serviceParams.version = version;
       
  2917                         }
       
  2918                     }
       
  2919                 },
       
  2920                 OnlineResource: function (node, service) {
       
  2921                     if (service && service.hasOwnProperty('serverUrl')) {
       
  2922                         service.serverUrl = node.getAttribute('xlink:href');
       
  2923                     }
       
  2924                 },
       
  2925                 LayerList: function (layerListNode, config) {
       
  2926                     __getChildNodes(layerListNode, config);
       
  2927                     if (config && config.layers && config.generalOptions && config.services) {
       
  2928                         for (var lyr in config.layers) {
       
  2929                             if (config.layers.hasOwnProperty(lyr)) {
       
  2930                                 var layerConfig = config.layers[lyr];
       
  2931                                 var apiKeys = layerConfig.apiKeys;
       
  2932                                 if (apiKeys && Array.isArray(apiKeys)) {
       
  2933                                     for (var i = 0; i < apiKeys.length; i++) {
       
  2934                                         var key = apiKeys[i];
       
  2935                                         if (config.generalOptions.apiKeys) {
       
  2936                                             if (!config.generalOptions.apiKeys[key] || !Array.isArray(config.generalOptions.apiKeys[key])) {
       
  2937                                                 config.generalOptions.apiKeys[key] = [];
       
  2938                                             }
       
  2939                                             config.generalOptions.apiKeys[key].push(lyr);
       
  2940                                         }
       
  2941                                     }
       
  2942                                 }
       
  2943                                 var serviceParams = layerConfig.serviceParams;
       
  2944                                 if (serviceParams && serviceParams.id) {
       
  2945                                     if (!config.services[serviceParams.id]) {
       
  2946                                         var s = new Service();
       
  2947                                         if (serviceParams.serverUrl) {
       
  2948                                             s.serverUrl = serviceParams.serverUrl;
       
  2949                                         }
       
  2950                                         if (serviceParams.version) {
       
  2951                                             s.version = serviceParams.version;
       
  2952                                         }
       
  2953                                         config.services[serviceParams.id] = s;
       
  2954                                     }
       
  2955                                 }
       
  2956                                 if (layerConfig.wmtsOptions && layerConfig.wmtsOptions.tileMatrixSetLink && config.tileMatrixSets) {
       
  2957                                     var tmsLink = layerConfig.wmtsOptions.tileMatrixSetLink;
       
  2958                                     var tileMatrixSets = config.tileMatrixSets;
       
  2959                                     for (var tms in tileMatrixSets) {
       
  2960                                         if (tileMatrixSets.hasOwnProperty(tms) && tms === tmsLink) {
       
  2961                                             layerConfig.defaultProjection = tileMatrixSets[tms].projection;
       
  2962                                         }
       
  2963                                     }
       
  2964                                 }
       
  2965                             }
       
  2966                         }
       
  2967                     }
       
  2968                 },
       
  2969                 Layer: function (layerNode, config) {
       
  2970                     if (config && config.layers) {
       
  2971                         var lyrData = {
       
  2972                             lyr: new Layer(),
       
  2973                             lyrId: null
       
  2974                         };
       
  2975                         var hidden = layerNode.getAttribute('hidden');
       
  2976                         if (hidden === '1') {
       
  2977                             lyrData.lyr.hidden = true;
       
  2978                         } else {
       
  2979                             lyrData.lyr.hidden = false;
       
  2980                         }
       
  2981                         var queryable = layerNode.getAttribute('queryable');
       
  2982                         if (queryable === '1') {
       
  2983                             lyrData.lyr.queryable = true;
       
  2984                         } else {
       
  2985                             lyrData.lyr.queryable = false;
       
  2986                         }
       
  2987                         __getChildNodes(layerNode, lyrData);
       
  2988                         if (lyrData.lyrId) {
       
  2989                             if (lyrData.lyr.serviceParams && lyrData.lyr.serviceParams.id) {
       
  2990                                 var serviceid = lyrData.lyr.serviceParams.id;
       
  2991                                 if (serviceid.toUpperCase().indexOf('OPENLS') !== -1 || serviceid.toUpperCase().indexOf('ELEVATION') !== -1) {
       
  2992                                     var resourceId = lyrData.lyrId.split('$')[0];
       
  2993                                     lyrData.lyrId = resourceId + '$' + serviceid;
       
  2994                                 }
       
  2995                             }
       
  2996                             lyrData.lyr.layerId = lyrData.lyrId;
       
  2997                             config.layers[lyrData.lyrId] = lyrData.lyr;
       
  2998                         }
       
  2999                     }
       
  3000                 },
       
  3001                 Name: function (node, lyrData) {
       
  3002                     if (lyrData && lyrData.lyr) {
       
  3003                         lyrData.lyr.name = __getChildValue(node);
       
  3004                     }
       
  3005                 },
       
  3006                 SRS: function (node, lyrData) {
       
  3007                     if (lyrData && lyrData.lyr) {
       
  3008                         lyrData.lyr.defaultProjection = __getChildValue(node);
       
  3009                     }
       
  3010                 },
       
  3011                 Format: function (node, lyrData) {
       
  3012                     if (lyrData && lyrData.lyr) {
       
  3013                         var f = new Format();
       
  3014                         var current = node.getAttribute('current');
       
  3015                         if (current === '1') {
       
  3016                             f.current = true;
       
  3017                         } else {
       
  3018                             f.current = false;
       
  3019                         }
       
  3020                         f.name = __getChildValue(node);
       
  3021                         if (!lyrData.lyr.formats || !Array.isArray(lyrData.lyr.formats)) {
       
  3022                             lyrData.lyr.formats = [];
       
  3023                         }
       
  3024                         lyrData.lyr.formats.push(f);
       
  3025                     }
       
  3026                 },
       
  3027                 Style: function (node, lyrData) {
       
  3028                     if (lyrData && lyrData.lyr) {
       
  3029                         var s = new Style();
       
  3030                         var current = node.getAttribute('current');
       
  3031                         if (current === '1' || current === 1) {
       
  3032                             s.current = true;
       
  3033                         } else {
       
  3034                             s.current = false;
       
  3035                         }
       
  3036                         if (node.hasChildNodes) {
       
  3037                             var children = node.childNodes;
       
  3038                             var child;
       
  3039                             var childName;
       
  3040                             for (var i = 0; i < children.length; i++) {
       
  3041                                 child = children[i];
       
  3042                                 if (child.nodeType === 1) {
       
  3043                                     childName = child.localName || child.baseName || child.nodeName;
       
  3044                                     if (childName === 'Name') {
       
  3045                                         s.name = __getChildValue(child);
       
  3046                                     } else if (childName === 'Title') {
       
  3047                                         s.title = __getChildValue(child);
       
  3048                                     }
       
  3049                                 }
       
  3050                             }
       
  3051                         }
       
  3052                         if (!lyrData.lyr.styles || !Array.isArray(lyrData.lyr.styles)) {
       
  3053                             lyrData.lyr.styles = [];
       
  3054                         }
       
  3055                         lyrData.lyr.styles.push(s);
       
  3056                     }
       
  3057                 },
       
  3058                 Dimension: function (node, lyrData) {
       
  3059                     var name = node.getAttribute('name');
       
  3060                     var dim = __getChildValue(node);
       
  3061                     if (lyrData && lyrData.lyr) {
       
  3062                         if (!lyrData.lyr.dimensions) {
       
  3063                             lyrData.lyr.dimensions = {};
       
  3064                         }
       
  3065                         if (name === 'Type') {
       
  3066                             lyrData.lyr.dimensions.type = dim;
       
  3067                         } else if (name === 'VisibilityRange') {
       
  3068                             lyrData.lyr.dimensions.visibilityRange = dim;
       
  3069                         } else if (name === 'VisibilityMode ') {
       
  3070                             lyrData.lyr.dimensions.visibilityMode = dim;
       
  3071                         } else if (name === 'GeometricType') {
       
  3072                             lyrData.lyr.dimensions.geometricType = dim;
       
  3073                         } else if (name === 'NoDataValue') {
       
  3074                             lyrData.lyr.dimensions.noDataValue = dim;
       
  3075                         }
       
  3076                     }
       
  3077                 }
       
  3078             },
       
  3079             gpp: {
       
  3080                 Theme: function (themeNode, config) {
       
  3081                     if (config && config.generalOptions && config.generalOptions.hasOwnProperty('theme')) {
       
  3082                         config.generalOptions.theme = __getChildValue(themeNode);
       
  3083                     }
       
  3084                 },
       
  3085                 defaultGMLGFIStyleUrl: function (node, config) {
       
  3086                     if (config && config.generalOptions && config.generalOptions.hasOwnProperty('defaultGMLGFIStyle')) {
       
  3087                         config.generalOptions.defaultGMLGFIStyle = __getChildValue(node);
       
  3088                     }
       
  3089                 },
       
  3090                 Territory: function (territoryNode, config) {
       
  3091                     var tid = territoryNode.getAttribute('id');
       
  3092                     if (tid) {
       
  3093                         var t = new Territory();
       
  3094                         var isDefault = territoryNode.getAttribute('default');
       
  3095                         if (isDefault === '1') {
       
  3096                             t.isDefault = true;
       
  3097                         } else {
       
  3098                             t.isDefault = false;
       
  3099                         }
       
  3100                         __getChildNodes(territoryNode, t);
       
  3101                         if (config && config.territories && typeof config.territories === 'object') {
       
  3102                             config.territories[tid] = t;
       
  3103                         }
       
  3104                     }
       
  3105                 },
       
  3106                 defaultCRS: function (node, territory) {
       
  3107                     if (territory && territory.hasOwnProperty('defaultCRS')) {
       
  3108                         territory.defaultCRS = __getChildValue(node);
       
  3109                     }
       
  3110                 },
       
  3111                 AdditionalCRS: function (node, data) {
       
  3112                     var addCRS = __getChildValue(node);
       
  3113                     if (addCRS && data) {
       
  3114                         if (Array.isArray(data.additionalCRS)) {
       
  3115                             data.additionalCRS.push(addCRS);
       
  3116                         } else {
       
  3117                             if (!data.additionalProjections || !Array.isArray(data.additionalProjections)) {
       
  3118                                 data.additionalProjections = [];
       
  3119                             }
       
  3120                             data.additionalProjections.push(addCRS);
       
  3121                         }
       
  3122                     }
       
  3123                 },
       
  3124                 DefaultLayer: function (node, territory) {
       
  3125                     var lyr = node.getAttribute('layerId');
       
  3126                     if (lyr && territory && Array.isArray(territory.defaultLayers)) {
       
  3127                         territory.defaultLayers.push(lyr);
       
  3128                     }
       
  3129                 },
       
  3130                 BoundingBox: function (node, data) {
       
  3131                     if (data) {
       
  3132                         var values = __getChildValue(node).split(',');
       
  3133                         if (values.length === 4) {
       
  3134                             var bbox = {
       
  3135                                 left: parseFloat(values[0]),
       
  3136                                 right: parseFloat(values[2]),
       
  3137                                 top: parseFloat(values[3]),
       
  3138                                 bottom: parseFloat(values[1])
       
  3139                             };
       
  3140                             var minT = node.getAttribute('minT');
       
  3141                             var maxT = node.getAttribute('maxT');
       
  3142                             if (data.hasOwnProperty('geoBBOX')) {
       
  3143                                 data.geoBBOX = bbox;
       
  3144                             } else if (data.hasOwnProperty('bbox')) {
       
  3145                                 if (data.bbox.left || data.bbox.right || data.bbox.top || data.bbox.bottom) {
       
  3146                                     if (!data.multiConstraints) {
       
  3147                                         data.multiConstraints = [];
       
  3148                                     }
       
  3149                                     var newConstraint = new Constraint();
       
  3150                                     newConstraint.bbox = bbox;
       
  3151                                     newConstraint.temporalExtent = [
       
  3152                                         minT,
       
  3153                                         maxT
       
  3154                                     ];
       
  3155                                     data.multiConstraints.push(newConstraint);
       
  3156                                 } else {
       
  3157                                     data.bbox = bbox;
       
  3158                                     data.temporalExtent = [
       
  3159                                         minT,
       
  3160                                         maxT
       
  3161                                     ];
       
  3162                                 }
       
  3163                             } else {
       
  3164                                 if (!data.globalConstraint) {
       
  3165                                     data.globalConstraint = new Constraint();
       
  3166                                 }
       
  3167                                 data.globalConstraint.bbox = bbox;
       
  3168                                 data.globalConstraint.temporalExtent = [
       
  3169                                     minT,
       
  3170                                     maxT
       
  3171                                 ];
       
  3172                             }
       
  3173                         }
       
  3174                     }
       
  3175                 },
       
  3176                 Resolution: function (node, territory) {
       
  3177                     var res = __getChildValue(node);
       
  3178                     if (res && territory && territory.defaultOptions && territory.defaultOptions.hasOwnProperty('resolution')) {
       
  3179                         territory.defaultOptions.resolution = parseFloat(res);
       
  3180                     }
       
  3181                 },
       
  3182                 x: function (node, territory) {
       
  3183                     var lon = __getChildValue(node);
       
  3184                     if (lon && territory && territory.geoCenter && territory.geoCenter.hasOwnProperty('lon')) {
       
  3185                         territory.geoCenter.lon = parseFloat(lon);
       
  3186                     }
       
  3187                 },
       
  3188                 y: function (node, territory) {
       
  3189                     var lat = __getChildValue(node);
       
  3190                     if (lat && territory && territory.geoCenter && territory.geoCenter.hasOwnProperty('lat')) {
       
  3191                         territory.geoCenter.lat = parseFloat(lat);
       
  3192                     }
       
  3193                 },
       
  3194                 Resolutions: function (resNode, config) {
       
  3195                     if (config && config.generalOptions && config.generalOptions.hasOwnProperty('wgs84Resolutions')) {
       
  3196                         config.generalOptions.wgs84Resolutions = __getChildValue(resNode).split(',');
       
  3197                     }
       
  3198                 },
       
  3199                 Layer: function (node, lyrData) {
       
  3200                     if (lyrData && lyrData.hasOwnProperty('lyrId') && lyrData.lyr) {
       
  3201                         lyrData.lyrId = node.getAttribute('id');
       
  3202                         var aggregate = node.getAttribute('aggregate');
       
  3203                         var more = node.getAttribute('more');
       
  3204                         if (aggregate || more) {
       
  3205                             lyrData.lyr.isAggregate = true;
       
  3206                         }
       
  3207                         __getChildNodes(node, lyrData.lyr);
       
  3208                     }
       
  3209                 },
       
  3210                 Constraint: function (node, data) {
       
  3211                     var c = new Constraint();
       
  3212                     __getChildNodes(node, c);
       
  3213                     if (data) {
       
  3214                         if (!data.constraints || !Array.isArray(data.constraints)) {
       
  3215                             data.constraints = [];
       
  3216                         }
       
  3217                         if (c.multiConstraints && Array.isArray(c.multiConstraints)) {
       
  3218                             var constraint = new Constraint();
       
  3219                             constraint.crs = c.crs;
       
  3220                             constraint.bbox = c.bbox;
       
  3221                             constraint.minScaleDenominator = c.minScaleDenominator;
       
  3222                             constraint.maxScaleDenominator = c.maxScaleDenominator;
       
  3223                             constraint.temporalExtent = c.temporalExtent;
       
  3224                             data.constraints.push(constraint);
       
  3225                             for (var i = 0; i < c.multiConstraints.length; i++) {
       
  3226                                 constraint = new Constraint();
       
  3227                                 constraint.crs = c.crs;
       
  3228                                 constraint.minScaleDenominator = c.minScaleDenominator;
       
  3229                                 constraint.maxScaleDenominator = c.maxScaleDenominator;
       
  3230                                 constraint.bbox = c.multiConstraints[i].bbox;
       
  3231                                 constraint.temporalExtent = c.multiConstraints[i].temporalExtent;
       
  3232                                 data.constraints.push(constraint);
       
  3233                             }
       
  3234                         } else {
       
  3235                             data.constraints.push(c);
       
  3236                         }
       
  3237                     }
       
  3238                 },
       
  3239                 CRS: function (node, data) {
       
  3240                     if (data && data.hasOwnProperty('crs')) {
       
  3241                         data.crs = __getChildValue(node);
       
  3242                     }
       
  3243                 },
       
  3244                 Thematic: function (node, lyr) {
       
  3245                     if (lyr) {
       
  3246                         var t = new Thematic();
       
  3247                         t.inspire = false;
       
  3248                         t.name = __getChildValue(node);
       
  3249                         if (!lyr.thematics || !Array.isArray(lyr.thematics)) {
       
  3250                             lyr.thematics = [];
       
  3251                         }
       
  3252                         lyr.thematics.push(t);
       
  3253                     }
       
  3254                 },
       
  3255                 InspireThematic: function (node, lyr) {
       
  3256                     if (lyr) {
       
  3257                         var t = new Thematic();
       
  3258                         t.inspire = true;
       
  3259                         t.name = __getChildValue(node);
       
  3260                         if (!lyr.thematics || !Array.isArray(lyr.thematics)) {
       
  3261                             lyr.thematics = [];
       
  3262                         }
       
  3263                         lyr.thematics.push(t);
       
  3264                     }
       
  3265                 },
       
  3266                 Originator: function (node, lyr) {
       
  3267                     if (lyr) {
       
  3268                         var o = new Originator();
       
  3269                         o.name = node.getAttribute('name');
       
  3270                         __getChildNodes(node, o);
       
  3271                         if (!lyr.originators || !Array.isArray(lyr.originators)) {
       
  3272                             lyr.originators = [];
       
  3273                         }
       
  3274                         lyr.originators.push(o);
       
  3275                     }
       
  3276                 },
       
  3277                 Attribution: function (node, originator) {
       
  3278                     if (originator && originator.hasOwnProperty('attribution')) {
       
  3279                         originator.attribution = __getChildValue(node);
       
  3280                     }
       
  3281                 },
       
  3282                 Logo: function (node, originator) {
       
  3283                     if (originator && originator.hasOwnProperty('logo')) {
       
  3284                         originator.logo = __getChildValue(node);
       
  3285                     }
       
  3286                 },
       
  3287                 URL: function (node, originator) {
       
  3288                     if (originator && originator.hasOwnProperty('url')) {
       
  3289                         originator.url = __getChildValue(node);
       
  3290                     }
       
  3291                 },
       
  3292                 Legend: function (node, lyr) {
       
  3293                     var l = new Legend();
       
  3294                     __getChildNodes(node, l);
       
  3295                     if (lyr) {
       
  3296                         if (!lyr.legends || !Array.isArray(lyr.legends)) {
       
  3297                             lyr.legends = [];
       
  3298                         }
       
  3299                         lyr.legends.push(l);
       
  3300                     }
       
  3301                 },
       
  3302                 LegendURL: function (node, legend) {
       
  3303                     if (legend && legend.hasOwnProperty('format')) {
       
  3304                         legend.format = node.getAttribute('format');
       
  3305                         if (node.hasChildNodes) {
       
  3306                             var child = node.childNodes[0];
       
  3307                             var childName = child.localName || child.baseName || child.nodeName;
       
  3308                             if (childName === 'OnlineResource' && legend.hasOwnProperty('url')) {
       
  3309                                 legend.url = child.getAttribute('xlink:href');
       
  3310                             }
       
  3311                         }
       
  3312                     }
       
  3313                 },
       
  3314                 QuickLook: function (node, lyr) {
       
  3315                     if (node.hasChildNodes) {
       
  3316                         var child = node.childNodes[0];
       
  3317                         var childName = child.localName || child.baseName || child.nodeName;
       
  3318                         if (childName === 'OnlineResource' && lyr) {
       
  3319                             lyr.quicklookUrl = child.getAttribute('xlink:href');
       
  3320                         }
       
  3321                     }
       
  3322                 },
       
  3323                 MetadataURL: function (node, lyr) {
       
  3324                     if (lyr) {
       
  3325                         var m = new Metadata();
       
  3326                         m.format = node.getAttribute('format');
       
  3327                         if (node.hasChildNodes) {
       
  3328                             var child = node.childNodes[0];
       
  3329                             var childName = child.localName || child.baseName || child.nodeName;
       
  3330                             if (childName === 'OnlineResource') {
       
  3331                                 m.url = child.getAttribute('xlink:href');
       
  3332                             }
       
  3333                         }
       
  3334                         if (!lyr.metadata && !Array.isArray(lyr.metadata)) {
       
  3335                             lyr.metadata = [];
       
  3336                         }
       
  3337                         lyr.metadata.push(m);
       
  3338                     }
       
  3339                 },
       
  3340                 Key: function (node, lyr) {
       
  3341                     if (lyr) {
       
  3342                         var key = node.getAttribute('id');
       
  3343                         if (!lyr.apiKeys || !Array.isArray(lyr.apiKeys)) {
       
  3344                             lyr.apiKeys = [];
       
  3345                         }
       
  3346                         lyr.apiKeys.push(key);
       
  3347                         var serverUrl = __getChildValue(node);
       
  3348                         if (!lyr.serviceParams) {
       
  3349                             lyr.serviceParams = {};
       
  3350                         }
       
  3351                         if (!lyr.serviceParams.serverUrl) {
       
  3352                             lyr.serviceParams.serverUrl = {};
       
  3353                         }
       
  3354                         if (!lyr.serviceParams.serverUrl[key]) {
       
  3355                             lyr.serviceParams.serverUrl[key] = serverUrl;
       
  3356                         }
       
  3357                     }
       
  3358                 }
       
  3359             },
       
  3360             ows: {
       
  3361                 Identifier: function (node, data) {
       
  3362                     if (data && data.hasOwnProperty('TMS')) {
       
  3363                         data.identifier = __getChildValue(node);
       
  3364                     } else if (data && data.hasOwnProperty('matrixId')) {
       
  3365                         data.matrixId = __getChildValue(node);
       
  3366                     }
       
  3367                 },
       
  3368                 SupportedCRS: function (node, tmsData) {
       
  3369                     if (tmsData && tmsData.TMS && tmsData.TMS.hasOwnProperty('projection')) {
       
  3370                         tmsData.TMS.projection = __getChildValue(node);
       
  3371                     }
       
  3372                 }
       
  3373             },
       
  3374             sld: {
       
  3375                 MinScaleDenominator: function (node, data) {
       
  3376                     var minScale = __getChildValue(node);
       
  3377                     if (minScale && data) {
       
  3378                         if (data.hasOwnProperty('defaultOptions')) {
       
  3379                             data.defaultOptions.minScaleDenominator = parseFloat(minScale);
       
  3380                         } else if (data.lyr) {
       
  3381                             if (!data.lyr.globalConstraint) {
       
  3382                                 data.lyr.globalConstraint = new Constraint();
       
  3383                             }
       
  3384                             data.lyr.globalConstraint.minScaleDenominator = parseFloat(minScale);
       
  3385                         } else if (data.hasOwnProperty('minScaleDenominator')) {
       
  3386                             data.minScaleDenominator = parseFloat(minScale);
       
  3387                         }
       
  3388                     }
       
  3389                 },
       
  3390                 MaxScaleDenominator: function (node, data) {
       
  3391                     var maxScale = __getChildValue(node);
       
  3392                     if (maxScale && data) {
       
  3393                         if (data.hasOwnProperty('defaultOptions')) {
       
  3394                             data.defaultOptions.maxScaleDenominator = parseFloat(maxScale);
       
  3395                         } else if (data.lyr) {
       
  3396                             if (!data.lyr.globalConstraint) {
       
  3397                                 data.lyr.globalConstraint = new Constraint();
       
  3398                             }
       
  3399                             data.lyr.globalConstraint.maxScaleDenominator = parseFloat(maxScale);
       
  3400                         } else if (data.hasOwnProperty('maxScaleDenominator')) {
       
  3401                             data.maxScaleDenominator = parseFloat(maxScale);
       
  3402                         }
       
  3403                     }
       
  3404                 }
       
  3405             },
       
  3406             wmts: {
       
  3407                 TileMatrixSetLimits: function (node, lyr) {
       
  3408                     if (lyr) {
       
  3409                         var limits = {};
       
  3410                         __getChildNodes(node, limits);
       
  3411                         if (!lyr.wmtsOptions) {
       
  3412                             lyr.wmtsOptions = {};
       
  3413                         }
       
  3414                         lyr.wmtsOptions.tileMatrixSetLimits = limits;
       
  3415                     }
       
  3416                 },
       
  3417                 TileMatrixLimits: function (node, limits) {
       
  3418                     var limit = new TileMatrixLimit();
       
  3419                     var limitId;
       
  3420                     if (node.hasChildNodes) {
       
  3421                         var children = node.childNodes;
       
  3422                         for (var i = 0; i < children.length; i++) {
       
  3423                             var child = children[i];
       
  3424                             var childName = child.localName || child.baseName || child.nodeName;
       
  3425                             if (childName === 'TileMatrix') {
       
  3426                                 limitId = __getChildValue(child);
       
  3427                             } else if (childName === 'MinTileRow') {
       
  3428                                 limit.minTileRow = __getChildValue(child);
       
  3429                             } else if (childName === 'MaxTileRow') {
       
  3430                                 limit.maxTileRow = __getChildValue(child);
       
  3431                             } else if (childName === 'MinTileCol') {
       
  3432                                 limit.minTileCol = __getChildValue(child);
       
  3433                             } else if (childName === 'MaxTileCol') {
       
  3434                                 limit.maxTileCol = __getChildValue(child);
       
  3435                             }
       
  3436                         }
       
  3437                         if (limitId && limits && !limits[limitId]) {
       
  3438                             limits[limitId] = limit;
       
  3439                         }
       
  3440                     }
       
  3441                 },
       
  3442                 TileMatrixSet: function (node, data) {
       
  3443                     if (data && data.tileMatrixSets) {
       
  3444                         var tmsData = {};
       
  3445                         tmsData.TMS = new TileMatrixSet();
       
  3446                         tmsData.resolutions = [];
       
  3447                         __getChildNodes(node, tmsData);
       
  3448                         var tileMatrices = tmsData.TMS.tileMatrices;
       
  3449                         for (var tm in tileMatrices) {
       
  3450                             if (tileMatrices.hasOwnProperty(tm)) {
       
  3451                                 tmsData.TMS.matrixIds.push(tm);
       
  3452                             }
       
  3453                         }
       
  3454                         if (tmsData.TMS.getProjection() === 'IGNF:WGS84G' || tmsData.TMS.getProjection() === 'EPSG:4326') {
       
  3455                             if (data.generalOptions && Array.isArray(data.generalOptions.wgs84Resolutions)) {
       
  3456                                 var wgs84Resolutions = data.generalOptions.wgs84Resolutions;
       
  3457                                 for (var i = 0; i < wgs84Resolutions.length; i++) {
       
  3458                                     tmsData.resolutions[i] = parseFloat(wgs84Resolutions[i]);
       
  3459                                 }
       
  3460                             }
       
  3461                         }
       
  3462                         if (Array.isArray(tmsData.resolutions) && tmsData.resolutions.sort !== undefined) {
       
  3463                             tmsData.resolutions.sort(function (x, y) {
       
  3464                                 return y - x;
       
  3465                             });
       
  3466                         }
       
  3467                         tmsData.TMS.nativeResolutions = tmsData.resolutions;
       
  3468                         data.tileMatrixSets[tmsData.identifier] = tmsData.TMS;
       
  3469                     } else {
       
  3470                         if (data && !data.wmtsOptions) {
       
  3471                             data.wmtsOptions = {};
       
  3472                         }
       
  3473                         data.wmtsOptions.tileMatrixSetLink = __getChildValue(node);
       
  3474                     }
       
  3475                 },
       
  3476                 TileMatrix: function (node, tmsData) {
       
  3477                     if (tmsData) {
       
  3478                         var tileMatrix = new TileMatrix();
       
  3479                         __getChildNodes(node, tileMatrix);
       
  3480                         if (tmsData.TMS && tmsData.TMS.getProjection()) {
       
  3481                             var proj = tmsData.TMS.getProjection();
       
  3482                             if (proj === 'EPSG:3857' || proj === 'EPSG:2154') {
       
  3483                                 var r = tileMatrix.scaleDenominator * 0.00028;
       
  3484                                 if (tmsData.resolutions && Array.isArray(tmsData.resolutions)) {
       
  3485                                     tmsData.resolutions.push(r);
       
  3486                                 }
       
  3487                             }
       
  3488                         }
       
  3489                         if (tmsData.TMS && tmsData.TMS.tileMatrices) {
       
  3490                             tmsData.TMS.tileMatrices[tileMatrix.matrixId] = tileMatrix;
       
  3491                         }
       
  3492                     }
       
  3493                 },
       
  3494                 ScaleDenominator: function (node, tileMatrix) {
       
  3495                     var scale = __getChildValue(node);
       
  3496                     if (scale && tileMatrix && tileMatrix.hasOwnProperty('scaleDenominator')) {
       
  3497                         tileMatrix.scaleDenominator = parseFloat(scale);
       
  3498                     }
       
  3499                 },
       
  3500                 TopLeftCorner: function (node, tileMatrix) {
       
  3501                     var values = __getChildValue(node).split(' ');
       
  3502                     if (values && tileMatrix) {
       
  3503                         tileMatrix.topLeftCorner = {};
       
  3504                         tileMatrix.topLeftCorner.x = parseFloat(values[0]);
       
  3505                         tileMatrix.topLeftCorner.y = parseFloat(values[1]);
       
  3506                     }
       
  3507                 },
       
  3508                 TileWidth: function (node, tileMatrix) {
       
  3509                     var value = __getChildValue(node);
       
  3510                     if (value && tileMatrix && tileMatrix.hasOwnProperty('tileWidth')) {
       
  3511                         tileMatrix.tileWidth = parseInt(value, 10);
       
  3512                     }
       
  3513                 },
       
  3514                 TileHeight: function (node, tileMatrix) {
       
  3515                     var value = __getChildValue(node);
       
  3516                     if (value && tileMatrix && tileMatrix.hasOwnProperty('tileHeight')) {
       
  3517                         tileMatrix.tileHeight = parseInt(value, 10);
       
  3518                     }
       
  3519                 },
       
  3520                 MatrixWidth: function (node, tileMatrix) {
       
  3521                     var value = __getChildValue(node);
       
  3522                     if (value && tileMatrix && tileMatrix.hasOwnProperty('matrixWidth')) {
       
  3523                         tileMatrix.matrixWidth = parseInt(value, 10);
       
  3524                     }
       
  3525                 },
       
  3526                 MatrixHeight: function (node, tileMatrix) {
       
  3527                     var value = __getChildValue(node);
       
  3528                     if (value && tileMatrix && tileMatrix.hasOwnProperty('matrixHeight')) {
       
  3529                         tileMatrix.matrixHeight = parseInt(value, 10);
       
  3530                     }
       
  3531                 }
       
  3532             },
       
  3533             serviceException: function (node) {
       
  3534                 var response = {};
       
  3535                 if (node.hasChildNodes()) {
       
  3536                     var children = node.childNodes;
       
  3537                     var child;
       
  3538                     for (var i = 0; i < children.length; i++) {
       
  3539                         child = children[i];
       
  3540                         if (child.nodeName === 'exception') {
       
  3541                             response.exceptionReport = AutoConfResponseReader.READERS['exception'](child);
       
  3542                         }
       
  3543                     }
       
  3544                 }
       
  3545                 return response;
       
  3546             },
       
  3547             exception: function (node) {
       
  3548                 var exceptionReport = {};
       
  3549                 var exceptionCode = node.getAttribute('code');
       
  3550                 if (exceptionCode) {
       
  3551                     exceptionReport.exceptionCode = exceptionCode;
       
  3552                 }
       
  3553                 var textNode = node.firstChild;
       
  3554                 if (textNode && textNode.nodeType === 3) {
       
  3555                     exceptionReport.exception = textNode.nodeValue;
       
  3556                 }
       
  3557                 return exceptionReport;
       
  3558             }
       
  3559         };
       
  3560         AutoConfResponseReader.read = function (root) {
       
  3561             if (root.nodeName === 'ViewContext') {
       
  3562                 var nsPrefix = root.prefix || AutoConfResponseReader.DEFAULTPREFIX;
       
  3563                 var config = AutoConfResponseReader.READERS[nsPrefix][root.nodeName](root);
       
  3564                 return config;
       
  3565             } else if (root.nodeName === 'serviceException') {
       
  3566                 var exceptionReport = AutoConfResponseReader.READERS[root.nodeName](root);
       
  3567                 return exceptionReport;
       
  3568             } else {
       
  3569                 throw new Error('Erreur lors de la lecture de la réponse : elle n\'est pas au format attendu.');
       
  3570             }
       
  3571         };
       
  3572         function __getAttributes(node) {
       
  3573             if (node.attributes.length > 0) {
       
  3574                 var nodeAttributes = {};
       
  3575                 var attributes = node.attributes;
       
  3576                 for (var i = 0; i < attributes.length; i++) {
       
  3577                     var attribute = attributes[i];
       
  3578                     nodeAttributes[attribute.nodeName] = attribute.nodeValue;
       
  3579                 }
       
  3580                 return nodeAttributes;
       
  3581             }
       
  3582         }
       
  3583         function __getChildNodes(node, data) {
       
  3584             if (node.hasChildNodes()) {
       
  3585                 var children = node.childNodes;
       
  3586                 var child;
       
  3587                 var childName;
       
  3588                 var childPrefix;
       
  3589                 for (var i = 0; i < children.length; i++) {
       
  3590                     child = children[i];
       
  3591                     if (child.nodeType === 1) {
       
  3592                         childName = child.localName || child.baseName || child.nodeName;
       
  3593                         childPrefix = child.prefix || AutoConfResponseReader.DEFAULTPREFIX;
       
  3594                         if (AutoConfResponseReader.READERS[childPrefix][childName]) {
       
  3595                             var reader = AutoConfResponseReader.READERS[childPrefix][childName];
       
  3596                             reader(child, data);
       
  3597                         } else {
       
  3598                             __getChildNodes(child, data);
       
  3599                         }
       
  3600                     }
       
  3601                 }
       
  3602             }
       
  3603         }
       
  3604         function __getChildValue(node) {
       
  3605             var textNode;
       
  3606             var value = '';
       
  3607             if (node.hasChildNodes()) {
       
  3608                 textNode = node.firstChild;
       
  3609                 if (textNode.nodeType === 3 || textNode.nodeType === 4) {
       
  3610                     value = textNode.nodeValue;
       
  3611                 }
       
  3612             }
       
  3613             return value;
       
  3614         }
       
  3615         function __checkServiceAttributes(viewContextNode) {
       
  3616             if (viewContextNode.attributes.length > 0) {
       
  3617                 var xlsAttributes = __getAttributes(viewContextNode);
       
  3618                 for (var att in xlsAttributes) {
       
  3619                     if (xlsAttributes.hasOwnProperty(att)) {
       
  3620                         if (att === 'version') {
       
  3621                             if (xlsAttributes['version'] !== AutoConfResponseReader.VERSION) {
       
  3622                                 console.log('[AutoConfResponseReader] autoconf version is not the expected one : there may be errors in parsing');
       
  3623                                 return;
       
  3624                             }
       
  3625                         }
       
  3626                         if (att === 'xmlns') {
       
  3627                             if (xlsAttributes[att] !== AutoConfResponseReader.NAMESPACES.xmlns) {
       
  3628                                 console.log('[AutoConfResponseReader] autoconf response default namespace is not the expected one');
       
  3629                                 return;
       
  3630                             }
       
  3631                             continue;
       
  3632                         }
       
  3633                         var prefix = att.split(':')[0];
       
  3634                         var ns = att.split(':')[1];
       
  3635                         if (prefix === 'xmlns' && ns) {
       
  3636                             if (AutoConfResponseReader.NAMESPACES[ns]) {
       
  3637                                 if (AutoConfResponseReader.NAMESPACES[ns] !== xlsAttributes[att]) {
       
  3638                                     console.log('[AutoConfResponseReader] autoconf response ' + att + ' namespace is not the expected one');
       
  3639                                     return;
       
  3640                                 }
       
  3641                             }
       
  3642                         }
       
  3643                         if (ns === 'schemaLocation') {
       
  3644                             if (xlsAttributes[att] !== AutoConfResponseReader.SCHEMALOCATION[0] && xlsAttributes[att] !== AutoConfResponseReader.SCHEMALOCATION[1]) {
       
  3645                                 console.log('[AutoConfResponseReader] autoconf response schema location is not the expected one');
       
  3646                                 return;
       
  3647                             }
       
  3648                         }
       
  3649                     }
       
  3650                 }
       
  3651             }
       
  3652         }
       
  3653         return AutoConfResponseReader;
       
  3654     }(UtilsLoggerByDefault, ServicesAutoConfResponseModelAutoConfResponse, ServicesAutoConfResponseModelConstraint, ServicesAutoConfResponseModelFormat, ServicesAutoConfResponseModelLayer, ServicesAutoConfResponseModelLegend, ServicesAutoConfResponseModelMetadata, ServicesAutoConfResponseModelOriginator, ServicesAutoConfResponseModelService, ServicesAutoConfResponseModelStyle, ServicesAutoConfResponseModelTerritory, ServicesAutoConfResponseModelThematic, ServicesAutoConfResponseModelTileMatrixSet, ServicesAutoConfResponseModelTileMatrix, ServicesAutoConfResponseModelTileMatrixLimit);
       
  3655     ServicesAutoConfResponseAutoConfResponseFactory = function (Logger, ErrorService, MRes, XML, AutoConfResponseReader) {
       
  3656         var AutoConfReponseFactory = {
       
  3657             build: function (options) {
       
  3658                 var data = null;
       
  3659                 if (options.response) {
       
  3660                     if (options.rawResponse) {
       
  3661                         data = options.response;
       
  3662                     } else {
       
  3663                         try {
       
  3664                             var p = new XML({ reader: AutoConfResponseReader });
       
  3665                             if (typeof options.response === 'string') {
       
  3666                                 p.setXMLString(options.response);
       
  3667                             } else {
       
  3668                                 p.setXMLDoc(options.response);
       
  3669                             }
       
  3670                             data = p.parse();
       
  3671                         } catch (e) {
       
  3672                             var message = e.message;
       
  3673                             if (typeof options.response === 'string') {
       
  3674                                 message += '\n(raw response service\'' + options.response + '\')';
       
  3675                             } else {
       
  3676                                 message += '\n(raw response service\'' + options.response.documentElement.innerHTML + '\')';
       
  3677                             }
       
  3678                             options.onError.call(options.scope, new ErrorService({
       
  3679                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', message),
       
  3680                                 status: 200,
       
  3681                                 type: ErrorService.TYPE_SRVERR
       
  3682                             }));
       
  3683                             return;
       
  3684                         }
       
  3685                         var isEmpty = true;
       
  3686                         for (var key in data) {
       
  3687                             if (data.hasOwnProperty(key)) {
       
  3688                                 isEmpty = false;
       
  3689                             }
       
  3690                         }
       
  3691                         if (isEmpty) {
       
  3692                             options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY_2')));
       
  3693                             return;
       
  3694                         }
       
  3695                         if (data.exceptionReport) {
       
  3696                             options.onError.call(options.scope, new ErrorService({
       
  3697                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  3698                                 type: ErrorService.TYPE_SRVERR,
       
  3699                                 status: 200
       
  3700                             }));
       
  3701                             return;
       
  3702                         }
       
  3703                     }
       
  3704                 } else {
       
  3705                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  3706                     return;
       
  3707                 }
       
  3708                 var scope = typeof window !== 'undefined' ? window : {};
       
  3709                 if (!scope.Gp) {
       
  3710                     scope.Gp = {};
       
  3711                 }
       
  3712                 if (!scope.Gp.Config) {
       
  3713                     scope.Gp.Config = data;
       
  3714                 } else {
       
  3715                     this.mergeConfig(scope.Gp.Config, data, options.layerId);
       
  3716                 }
       
  3717                 options.onSuccess.call(options.scope, scope.Gp.Config);
       
  3718                 return;
       
  3719             },
       
  3720             mergeConfig: function (GpConfig, data, layerId) {
       
  3721                 if (data && GpConfig) {
       
  3722                     for (var prop in data) {
       
  3723                         if (data.hasOwnProperty(prop)) {
       
  3724                             if (prop == 'generalOptions') {
       
  3725                                 for (var key in data[prop].apiKeys) {
       
  3726                                     if (data[prop].apiKeys.hasOwnProperty(key) && !GpConfig.generalOptions.apiKeys[key]) {
       
  3727                                         GpConfig.generalOptions.apiKeys[key] = data[prop].apiKeys[key];
       
  3728                                     }
       
  3729                                 }
       
  3730                             } else {
       
  3731                                 if (GpConfig[prop]) {
       
  3732                                     for (var obj in data[prop]) {
       
  3733                                         if (data[prop].hasOwnProperty(obj) && !GpConfig[prop][obj]) {
       
  3734                                             GpConfig[prop][obj] = data[prop][obj];
       
  3735                                         }
       
  3736                                     }
       
  3737                                 }
       
  3738                             }
       
  3739                         }
       
  3740                     }
       
  3741                     if (layerId) {
       
  3742                         var aggregatedLayers = [];
       
  3743                         for (var lyr in data.layers) {
       
  3744                             if (data.layers.hasOwnProperty(lyr)) {
       
  3745                                 aggregatedLayers.push(lyr);
       
  3746                             }
       
  3747                         }
       
  3748                         if (GpConfig.layers[layerId]) {
       
  3749                             GpConfig.layers[layerId].aggregatedLayers = aggregatedLayers;
       
  3750                         }
       
  3751                     }
       
  3752                 }
       
  3753             }
       
  3754         };
       
  3755         return AutoConfReponseFactory;
       
  3756     }(UtilsLoggerByDefault, ExceptionsErrorService, UtilsMessagesResources, FormatsXML, ServicesAutoConfFormatsAutoConfResponseReader);
       
  3757     ServicesAutoConfAutoConf = function (Logger, _, ErrorService, Helper, DefaultUrlService, CommonService, AutoConfResponseFactory) {
       
  3758         function AutoConf(options) {
       
  3759             if (!(this instanceof AutoConf)) {
       
  3760                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'AutoConf'));
       
  3761             }
       
  3762             this.CLASSNAME = 'AutoConf';
       
  3763             CommonService.apply(this, arguments);
       
  3764             if (!this.options.serverUrl) {
       
  3765                 if (!this.options.serverUrl) {
       
  3766                     var lstUrlByDefault = DefaultUrlService.AutoConf.url(this.options.apiKey);
       
  3767                     if (!this.options.layerId) {
       
  3768                         if (Array.isArray(this.options.apiKey) && this.options.apiKey.length > 0) {
       
  3769                             this.options.serverUrl = lstUrlByDefault.apiKeys;
       
  3770                         } else {
       
  3771                             this.options.serverUrl = lstUrlByDefault.apiKey;
       
  3772                         }
       
  3773                     } else {
       
  3774                         this.options.serverUrl = lstUrlByDefault.aggregate + this.options.layerId;
       
  3775                     }
       
  3776                 }
       
  3777             }
       
  3778             if (this.options.protocol === 'XHR' && this.options.httpMethod === 'POST') {
       
  3779                 this.options.httpMethod = 'GET';
       
  3780             }
       
  3781             this.options.outputFormat = 'xml';
       
  3782         }
       
  3783         AutoConf.prototype = Object.create(CommonService.prototype, {});
       
  3784         AutoConf.prototype.constructor = AutoConf;
       
  3785         AutoConf.prototype.buildRequest = function (error, success) {
       
  3786             var scope = typeof window !== 'undefined' ? window : {};
       
  3787             if (scope.Gp && scope.Gp.Config && scope.Gp.Config.generalOptions && scope.Gp.Config.layers) {
       
  3788                 if (scope.Gp.Config.generalOptions.apiKeys[this.options.apiKey]) {
       
  3789                     if (this.options.layerId) {
       
  3790                         if (scope.Gp.Config.layers[this.options.layerId] && scope.Gp.Config.layers[this.options.layerId].aggregatedLayers) {
       
  3791                             this.options.onSuccess.call(this, scope.Gp.Config);
       
  3792                             return;
       
  3793                         }
       
  3794                     } else {
       
  3795                         this.options.onSuccess.call(this, scope.Gp.Config);
       
  3796                         return;
       
  3797                     }
       
  3798                 }
       
  3799             }
       
  3800             this.request = '';
       
  3801             var bLocal;
       
  3802             if (this.options.serverUrl.indexOf('http://') === -1) {
       
  3803                 bLocal = true;
       
  3804             } else {
       
  3805                 bLocal = false;
       
  3806             }
       
  3807             if (!bLocal && this.layerId) {
       
  3808                 this.request = Helper.normalyzeParameters({ layerId: this.layerId });
       
  3809             }
       
  3810             success.call(this, this.request);
       
  3811         };
       
  3812         AutoConf.prototype.analyzeResponse = function (error, success) {
       
  3813             if (this.response) {
       
  3814                 var options = {
       
  3815                     layerId: this.options.layerId,
       
  3816                     response: this.response,
       
  3817                     rawResponse: this.options.rawResponse,
       
  3818                     onSuccess: success,
       
  3819                     onError: error,
       
  3820                     scope: this
       
  3821                 };
       
  3822                 AutoConfResponseFactory.build(options);
       
  3823             } else {
       
  3824                 error.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  3825             }
       
  3826         };
       
  3827         return AutoConf;
       
  3828     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, UtilsHelper, ServicesDefaultUrlService, ServicesCommonService, ServicesAutoConfResponseAutoConfResponseFactory);
       
  3829     FormatsXLSRequestHeader = function (Logger) {
       
  3830         function RequestHeader(options) {
       
  3831             if (!(this instanceof RequestHeader)) {
       
  3832                 throw new TypeError('RequestHeader constructor cannot be called as a function.');
       
  3833             }
       
  3834             this.options = options || { srsName: 'EPSG:4326' };
       
  3835             for (var opt in options) {
       
  3836                 if (options.hasOwnProperty(opt)) {
       
  3837                     this.options[opt] = options[opt];
       
  3838                 }
       
  3839             }
       
  3840         }
       
  3841         RequestHeader.prototype = {
       
  3842             requestString: null,
       
  3843             template: '<RequestHeader srsName="__SRSNAME__"/>',
       
  3844             constructor: RequestHeader,
       
  3845             toString: function () {
       
  3846                 var template = null;
       
  3847                 template = this.template;
       
  3848                 template = template.replace(/__SRSNAME__/g, this.options.srsName);
       
  3849                 this.requestString = template;
       
  3850                 return this.requestString;
       
  3851             }
       
  3852         };
       
  3853         return RequestHeader;
       
  3854     }(UtilsLoggerByDefault);
       
  3855     FormatsXLSRequest = function (Logger) {
       
  3856         function Request(options) {
       
  3857             if (!(this instanceof Request)) {
       
  3858                 throw new TypeError('Request constructor cannot be called as a function.');
       
  3859             }
       
  3860             this.options = options || {
       
  3861                 maximumResponses: 25,
       
  3862                 methodName: null,
       
  3863                 version: '1.2'
       
  3864             };
       
  3865             for (var opt in options) {
       
  3866                 if (options.hasOwnProperty(opt)) {
       
  3867                     this.options[opt] = options[opt];
       
  3868                 }
       
  3869             }
       
  3870         }
       
  3871         Request.prototype = {
       
  3872             requestString: null,
       
  3873             template: '<Request maximumResponses="__MAXRESPONSES__" methodName="__METHODNAME__" requestID="__UUID__" version="__VERSION__">' + '<!-- __REQUESTSERVICE__ -->' + '</Request>',
       
  3874             constructor: Request,
       
  3875             guid: function () {
       
  3876                 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
       
  3877                     var r = Math.random() * 16 | 0;
       
  3878                     var v = c === 'x' ? r : r & 3 | 8;
       
  3879                     return v.toString(16);
       
  3880                 });
       
  3881             },
       
  3882             toString: function () {
       
  3883                 var template = null;
       
  3884                 template = this.template;
       
  3885                 template = template.replace(/__MAXRESPONSES__/g, this.options.maximumResponses);
       
  3886                 template = template.replace(/__METHODNAME__/g, this.options.methodName);
       
  3887                 template = template.replace(/__UUID__/g, this.guid());
       
  3888                 template = template.replace(/__VERSION__/g, this.options.version);
       
  3889                 this.requestString = template;
       
  3890                 return this.requestString;
       
  3891             }
       
  3892         };
       
  3893         return Request;
       
  3894     }(UtilsLoggerByDefault);
       
  3895     FormatsXLSAbstractService = function (Logger) {
       
  3896         function AbstractService(options) {
       
  3897             if (!(this instanceof AbstractService)) {
       
  3898                 throw new TypeError('AbstractService constructor cannot be called as a function.');
       
  3899             }
       
  3900             this.options = options || {};
       
  3901             for (var opt in options) {
       
  3902                 if (options.hasOwnProperty(opt)) {
       
  3903                     this.options[opt] = options[opt];
       
  3904                 }
       
  3905             }
       
  3906         }
       
  3907         AbstractService.prototype = {
       
  3908             strRequest: null,
       
  3909             oRequest: null,
       
  3910             oFilter: null,
       
  3911             constructor: AbstractService,
       
  3912             addRequest: function (oRequest) {
       
  3913             },
       
  3914             addFilter: function (oFilter) {
       
  3915             },
       
  3916             toString: function () {
       
  3917             }
       
  3918         };
       
  3919         return AbstractService;
       
  3920     }(UtilsLoggerByDefault);
       
  3921     FormatsXLS = function (Logger, RequestHeader, Request, AbstractService) {
       
  3922         function XLS(options) {
       
  3923             if (!(this instanceof XLS)) {
       
  3924                 throw new TypeError('XLS constructor cannot be called as a function.');
       
  3925             }
       
  3926             this.options = {
       
  3927                 srsName: 'EPSG:4326',
       
  3928                 maximumResponses: 25
       
  3929             };
       
  3930             for (var opt in options) {
       
  3931                 if (options.hasOwnProperty(opt)) {
       
  3932                     if (options[opt]) {
       
  3933                         this.options[opt] = options[opt];
       
  3934                     }
       
  3935                 }
       
  3936             }
       
  3937         }
       
  3938         XLS.VERSION = '1.2';
       
  3939         XLS.prototype = {
       
  3940             requestString: null,
       
  3941             namespace: false,
       
  3942             oService: null,
       
  3943             constructor: XLS,
       
  3944             template: '<?xml version="1.0" encoding="UTF-8"?>\n' + '<XLS version="__VERSION__"\n' + '__NAMESPACE__ \n' + '__SCHEMALOCATION__>\n' + '__REQUESTHEADER__\n' + '__REQUEST__\n' + '</XLS>\n',
       
  3945             namespaceByDefault: function () {
       
  3946                 var ns = [
       
  3947                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
       
  3948                     'xmlns:xls="http://www.opengis.net/xls"',
       
  3949                     'xmlns:gml="http://www.opengis.net/gml"'
       
  3950                 ];
       
  3951                 return ns.join(' ');
       
  3952             },
       
  3953             schemaLocationByDefault: function () {
       
  3954                 return 'xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"';
       
  3955             },
       
  3956             setService: function (oService) {
       
  3957                 if (!oService) {
       
  3958                     return;
       
  3959                 }
       
  3960                 if (oService instanceof AbstractService) {
       
  3961                     this.oService = oService;
       
  3962                 } else {
       
  3963                 }
       
  3964             },
       
  3965             getService: function () {
       
  3966                 return this.oService;
       
  3967             }
       
  3968         };
       
  3969         XLS.prototype.addNamespace = function (ns, request) {
       
  3970             var keyNS = ns.key;
       
  3971             var bFound = false;
       
  3972             var allNS = this.namespaceByDefault().split(' ');
       
  3973             for (var index = 0; index < allNS.length; index++) {
       
  3974                 var element = allNS[index];
       
  3975                 var map = element.split('=');
       
  3976                 var key = map[0];
       
  3977                 if (key === 'xmlns:' + keyNS) {
       
  3978                     bFound = true;
       
  3979                     break;
       
  3980                 }
       
  3981             }
       
  3982             if (!bFound) {
       
  3983                 return request;
       
  3984             }
       
  3985             var regex;
       
  3986             var subst;
       
  3987             regex = /<(\w+[\s>])/g;
       
  3988             subst = '<' + keyNS + ':$1';
       
  3989             request = request.replace(regex, subst);
       
  3990             regex = /<\/(\w+[\s>])/g;
       
  3991             subst = '</' + keyNS + ':$1';
       
  3992             request = request.replace(regex, subst);
       
  3993             return request;
       
  3994         };
       
  3995         XLS.prototype.build = function () {
       
  3996             var bService = this.getService() ? true : false;
       
  3997             var template = '';
       
  3998             template = this.template;
       
  3999             template = template.replace(/__VERSION__/g, XLS.VERSION);
       
  4000             template = template.replace(/__NAMESPACE__/g, this.namespaceByDefault);
       
  4001             template = template.replace(/__SCHEMALOCATION__/g, this.schemaLocationByDefault);
       
  4002             var oHeader = new RequestHeader({ srsName: this.options.srsName });
       
  4003             template = template.replace(/__REQUESTHEADER__/g, oHeader.toString());
       
  4004             var oRequest = new Request({
       
  4005                 maximumResponses: this.options.maximumResponses,
       
  4006                 version: XLS.VERSION,
       
  4007                 methodName: bService ? this.getService().CLASSTYPE : null
       
  4008             });
       
  4009             template = template.replace(/__REQUEST__/g, oRequest.toString());
       
  4010             if (bService) {
       
  4011                 template = template.replace(/<!-- __REQUESTSERVICE__ -->/g, this.getService().toString());
       
  4012             }
       
  4013             if (!template) {
       
  4014                 return;
       
  4015             }
       
  4016             if (this.namespace) {
       
  4017                 template = this.addNamespace({
       
  4018                     key: 'xls',
       
  4019                     url: 'http://www.opengis.net/xls'
       
  4020                 }, template);
       
  4021             }
       
  4022             this.requestString = template;
       
  4023             return this.requestString;
       
  4024         };
       
  4025         return XLS;
       
  4026     }(UtilsLoggerByDefault, FormatsXLSRequestHeader, FormatsXLSRequest, FormatsXLSAbstractService);
       
  4027     FormatsXLSLocationUtilityServiceModelAddress = function (Gp, Logger) {
       
  4028         function Address(options) {
       
  4029             if (!(this instanceof Address)) {
       
  4030                 throw new TypeError('Address constructor cannot be called as a function.');
       
  4031             }
       
  4032             this.options = options || {
       
  4033                 location: {},
       
  4034                 type: ['StreetAddress'],
       
  4035                 filter: {}
       
  4036             };
       
  4037             if (!options.location) {
       
  4038                 throw new Error('l\'option \'location\' n\'est pas renseignée !');
       
  4039             }
       
  4040             for (var opt in options) {
       
  4041                 if (options.hasOwnProperty(opt)) {
       
  4042                     this.options[opt] = options[opt];
       
  4043                 }
       
  4044             }
       
  4045         }
       
  4046         Address.prototype = {
       
  4047             constructor: Address,
       
  4048             requestString: null,
       
  4049             template: {
       
  4050                 address: '<Address countryCode="__COUNTRYCODE__">' + '__LOCATION__' + '__PLACE__' + '__POSTALCODE__' + '__ENVELOPE__' + '</Address>',
       
  4051                 location: {
       
  4052                     freeFormAddress: '<freeFormAddress>__FREEFORMADDRESSVALUE__</freeFormAddress>',
       
  4053                     streetAddress: {
       
  4054                         container: '<StreetAddress>' + '__STREET__' + '__BUILDING__' + '</StreetAddress>',
       
  4055                         building: '<Building number="__BUILDINGVALUE__"/>',
       
  4056                         street: '<Street>__STREETVALUE__</Street>'
       
  4057                     }
       
  4058                 },
       
  4059                 place: '<Place type="__PLACETYPE__">__PLACEVALUE__</Place>',
       
  4060                 postalCode: '<PostalCode>__POSTALCODEVALUE__</PostalCode>',
       
  4061                 envelope: '<gml:Envelope>' + '<gml:lowerCorner>__LEFT__ __BOTTOM__</gml:lowerCorner>' + '<gml:upperCorner>__RIGHT__ __TOP__</gml:upperCorner>' + '</gml:Envelope>'
       
  4062             }
       
  4063         };
       
  4064         Address.prototype.toString = function () {
       
  4065             var template = null;
       
  4066             template = this.template.address;
       
  4067             template = template.replace(/__COUNTRYCODE__/g, this.options.type);
       
  4068             if (typeof this.options.location === 'string') {
       
  4069                 var tmplFreeFormAddress = this.template.location.freeFormAddress;
       
  4070                 tmplFreeFormAddress = tmplFreeFormAddress.replace(/__FREEFORMADDRESSVALUE__/g, this.options.location);
       
  4071                 template = template.replace(/__LOCATION__/g, tmplFreeFormAddress);
       
  4072             } else {
       
  4073                 var tmplBuilding = '';
       
  4074                 var tmplStreet = '';
       
  4075                 if (this.options.location.number) {
       
  4076                     tmplBuilding = this.template.location.streetAddress.building;
       
  4077                     tmplBuilding = tmplBuilding.replace(/__BUILDINGVALUE__/g, this.options.location.number);
       
  4078                 }
       
  4079                 if (this.options.location.street) {
       
  4080                     tmplStreet = this.template.location.streetAddress.street;
       
  4081                     tmplStreet = tmplStreet.replace(/__STREETVALUE__/g, this.options.location.street);
       
  4082                 }
       
  4083                 var tmplStreetAddress = this.template.location.streetAddress.container;
       
  4084                 tmplStreetAddress = tmplStreetAddress.replace(/__STREET__/g, tmplStreet);
       
  4085                 tmplStreetAddress = tmplStreetAddress.replace(/__BUILDING__/g, tmplBuilding);
       
  4086                 template = template.replace(/__LOCATION__/g, tmplStreetAddress);
       
  4087             }
       
  4088             var tmplPostalCode = '';
       
  4089             if (this.options.location.postalCode) {
       
  4090                 tmplPostalCode = this.template.postalCode;
       
  4091                 tmplPostalCode = tmplPostalCode.replace(/__POSTALCODEVALUE__/g, this.options.location.postalCode);
       
  4092             }
       
  4093             var tmplEnvelope = '';
       
  4094             if (this.options.filter) {
       
  4095                 var bbox = this.options.filter.bbox;
       
  4096                 if (bbox) {
       
  4097                     tmplEnvelope = this.template.envelope;
       
  4098                     tmplEnvelope = tmplEnvelope.replace(/__LEFT__/g, bbox.left);
       
  4099                     tmplEnvelope = tmplEnvelope.replace(/__BOTTOM__/g, bbox.bottom);
       
  4100                     tmplEnvelope = tmplEnvelope.replace(/__RIGHT__/g, bbox.right);
       
  4101                     tmplEnvelope = tmplEnvelope.replace(/__TOP__/g, bbox.top);
       
  4102                 }
       
  4103             }
       
  4104             var Places = [];
       
  4105             var tmplPlace = '';
       
  4106             if (this.options.filter) {
       
  4107                 var filters = this.options.filter;
       
  4108                 for (var filter in filters) {
       
  4109                     if (filter === 'bbox') {
       
  4110                         continue;
       
  4111                     }
       
  4112                     tmplPlace = this.template.place;
       
  4113                     tmplPlace = tmplPlace.replace(/__PLACETYPE__/g, filter);
       
  4114                     tmplPlace = tmplPlace.replace(/__PLACEVALUE__/g, filters[filter]);
       
  4115                     Places.push(tmplPlace);
       
  4116                 }
       
  4117             }
       
  4118             var tmplPlaceCity = '';
       
  4119             if (this.options.location.city) {
       
  4120                 tmplPlaceCity = this.template.place;
       
  4121                 tmplPlaceCity = tmplPlaceCity.replace(/__PLACETYPE__/g, 'Municipality');
       
  4122                 tmplPlaceCity = tmplPlaceCity.replace(/__PLACEVALUE__/g, this.options.location.city);
       
  4123                 Places.push(tmplPlaceCity);
       
  4124             }
       
  4125             template = template.replace(/__POSTALCODE__/g, tmplPostalCode);
       
  4126             template = template.replace(/__PLACE__/g, Places.join('\n'));
       
  4127             template = template.replace(/__ENVELOPE__/g, tmplEnvelope);
       
  4128             this.requestString = template;
       
  4129             return this.requestString;
       
  4130         };
       
  4131         return Address;
       
  4132     }(Gp, UtilsLoggerByDefault);
       
  4133     FormatsXLSLocationUtilityServiceGeocodeFilterExtension = function (Logger) {
       
  4134         function GeocodeFilterExtension() {
       
  4135             if (!(this instanceof GeocodeFilterExtension)) {
       
  4136                 throw new TypeError('GeocodeFilterExtension constructor cannot be called as a function.');
       
  4137             }
       
  4138             this.filters = [];
       
  4139         }
       
  4140         GeocodeFilterExtension.prototype = {
       
  4141             constructor: GeocodeFilterExtension,
       
  4142             addFilterExtensions: function (oGeocodeLocation) {
       
  4143                 if (oGeocodeLocation) {
       
  4144                     this.filters.push(oGeocodeLocation);
       
  4145                 }
       
  4146             },
       
  4147             getNames: function () {
       
  4148                 var names = [];
       
  4149                 for (var idx in this.filters) {
       
  4150                     names.push(this.filters[idx].CLASSNAME);
       
  4151                 }
       
  4152                 return names;
       
  4153             },
       
  4154             getFilter: function (name) {
       
  4155                 var filter = null;
       
  4156                 for (var idx in this.filters) {
       
  4157                     if (this.filters[idx].CLASSNAME == name) {
       
  4158                         filter = this.filters[idx];
       
  4159                     }
       
  4160                 }
       
  4161                 return filter;
       
  4162             },
       
  4163             getFilters: function () {
       
  4164                 return this.filters;
       
  4165             },
       
  4166             getAttributs: function (name) {
       
  4167                 var attributs = [];
       
  4168                 for (var idx in this.filters) {
       
  4169                     if (this.filters[idx].CLASSNAME == name) {
       
  4170                         attributs = this.filters[idx].attributesList;
       
  4171                     }
       
  4172                 }
       
  4173                 return attributs;
       
  4174             },
       
  4175             setPlaceAttributs: function (name, options) {
       
  4176                 var filter = this.getFilter(name);
       
  4177                 var attributs = this.getAttributs(name);
       
  4178                 for (var idx in attributs) {
       
  4179                     var value = attributs[idx];
       
  4180                     if (options[value]) {
       
  4181                         filter.placeAttributes[value] = options[value];
       
  4182                     }
       
  4183                 }
       
  4184             },
       
  4185             getPlaceAttributs: function (name) {
       
  4186                 var places = {};
       
  4187                 for (var idx in this.filters) {
       
  4188                     if (this.filters[idx].CLASSNAME == name) {
       
  4189                         places = this.filters[idx].placeAttributes;
       
  4190                     }
       
  4191                 }
       
  4192                 return places;
       
  4193             }
       
  4194         };
       
  4195         return GeocodeFilterExtension;
       
  4196     }(UtilsLoggerByDefault);
       
  4197     FormatsXLSLocationUtilityServiceGeocodeRequest = function (Logger, Address, GeocodeFilterExtension) {
       
  4198         function GeocodeRequest(options) {
       
  4199             if (!(this instanceof GeocodeRequest)) {
       
  4200                 throw new TypeError('GeocodeRequest constructor cannot be called as a function.');
       
  4201             }
       
  4202             this.options = options || {};
       
  4203             for (var opt in options) {
       
  4204                 if (options.hasOwnProperty(opt)) {
       
  4205                     this.options[opt] = options[opt];
       
  4206                 }
       
  4207             }
       
  4208             this.CLASSNAME = 'GeocodeRequest';
       
  4209         }
       
  4210         GeocodeRequest.prototype = {
       
  4211             strRequest: null,
       
  4212             oAddress: null,
       
  4213             oFilter: null,
       
  4214             template: '<GeocodeRequest returnFreeForm="__RETURNFREEFORM__">' + '__ADDRESS__' + '</GeocodeRequest>',
       
  4215             addAddress: function (oAddress) {
       
  4216                 if (oAddress instanceof Address) {
       
  4217                     this.oAddress = oAddress;
       
  4218                 }
       
  4219             },
       
  4220             addFilter: function (oFilter) {
       
  4221                 if (oFilter instanceof GeocodeFilterExtension) {
       
  4222                     this.oFilter = oFilter;
       
  4223                 }
       
  4224             },
       
  4225             constructor: GeocodeRequest,
       
  4226             toString: function () {
       
  4227                 var template = '';
       
  4228                 template = this.template;
       
  4229                 if (!this.oAddress) {
       
  4230                     var settings = {};
       
  4231                     settings.location = this.options.location;
       
  4232                     settings.type = this.options.filterOptions.type || ['StreetAddress'];
       
  4233                     settings.filter = this.options.filterOptions;
       
  4234                     delete settings.filter.type;
       
  4235                     if (this.oFilter) {
       
  4236                         settings.filter = {};
       
  4237                         for (var idx in settings.type) {
       
  4238                             var filter = settings.type[idx];
       
  4239                             var oFilter = this.oFilter.getFilter(filter);
       
  4240                             if (!oFilter) {
       
  4241                                 continue;
       
  4242                             }
       
  4243                             var mFilter = this.options.filterOptions;
       
  4244                             var attributs = oFilter.attributesList;
       
  4245                             for (var idxe = 0; idxe < attributs.length; idxe++) {
       
  4246                                 var key = attributs[idxe];
       
  4247                                 if (mFilter[key]) {
       
  4248                                     var matchingKey = oFilter.serviceAttributes[idxe];
       
  4249                                     oFilter.placeAttributes[matchingKey] = mFilter[key];
       
  4250                                 }
       
  4251                             }
       
  4252                             var places = oFilter.placeAttributes;
       
  4253                             for (var kplace in places) {
       
  4254                                 if (places.hasOwnProperty(kplace)) {
       
  4255                                     settings.filter[kplace] = places[kplace];
       
  4256                                 }
       
  4257                             }
       
  4258                         }
       
  4259                     }
       
  4260                     this.oAddress = new Address(settings);
       
  4261                     if (!this.oAddress) {
       
  4262                         throw new Error('La construction de l\'adresse n\'est pas correctement definie !?');
       
  4263                     }
       
  4264                 }
       
  4265                 template = template.replace(/__ADDRESS__/g, this.oAddress.toString());
       
  4266                 template = template.replace(/__RETURNFREEFORM__/g, this.options.returnFreeForm ? 'true' : 'false');
       
  4267                 this.strRequest = template;
       
  4268                 return this.strRequest;
       
  4269             }
       
  4270         };
       
  4271         return GeocodeRequest;
       
  4272     }(UtilsLoggerByDefault, FormatsXLSLocationUtilityServiceModelAddress, FormatsXLSLocationUtilityServiceGeocodeFilterExtension);
       
  4273     FormatsXLSLocationUtilityServiceModelPosition = function (Logger) {
       
  4274         function Position(options) {
       
  4275             if (!(this instanceof Position)) {
       
  4276                 throw new TypeError('Position constructor cannot be called as a function.');
       
  4277             }
       
  4278             this.options = options || {};
       
  4279             if (!options.position) {
       
  4280                 throw new Error('l\'option \'position\' n\'est pas renseignée !');
       
  4281             }
       
  4282             for (var opt in options) {
       
  4283                 if (options.hasOwnProperty(opt)) {
       
  4284                     this.options[opt] = options[opt];
       
  4285                 }
       
  4286             }
       
  4287         }
       
  4288         Position.prototype = {
       
  4289             constructor: Position,
       
  4290             requestString: null,
       
  4291             template: {
       
  4292                 position: '<Position>' + '__GMLPOINT__' + '__GMLFILTER__' + '</Position>',
       
  4293                 gml: {
       
  4294                     point: '<gml:Point xmlns:gml="http://www.opengis.net/gml"><gml:pos>__X__ __Y__</gml:pos></gml:Point>',
       
  4295                     pos: null,
       
  4296                     filter: {
       
  4297                         bbox: '<gml:Envelope xmlns:gml="http://www.opengis.net/gml">' + '<gml:lowerCorner>__LEFT__ __BOTTOM__</gml:lowerCorner>' + '<gml:upperCorner>__RIGHT__ __TOP__</gml:upperCorner>' + '</gml:Envelope>',
       
  4298                         circle: '<gml:CircleByCenterPoint xmlns:gml="http://www.opengis.net/gml"><gml:pos>__X__ __Y__</gml:pos><gml:radius>__RADIUS__</gml:radius></gml:CircleByCenterPoint>',
       
  4299                         polygon: '<gml:Polygon xmlns:gml="http://www.opengis.net/gml"><gml:exterior><gml:LinearRing><gml:posList>__XY__</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>',
       
  4300                         multipolygon: null
       
  4301                     }
       
  4302                 }
       
  4303             }
       
  4304         };
       
  4305         Position.prototype.toString = function () {
       
  4306             var template = this.template.position;
       
  4307             var tmplGmlPoint = this.template.gml.point;
       
  4308             tmplGmlPoint = tmplGmlPoint.replace(/__X__/g, this.options.position.x);
       
  4309             tmplGmlPoint = tmplGmlPoint.replace(/__Y__/g, this.options.position.y);
       
  4310             var tmplGmlFilter = '';
       
  4311             if (this.options.filter) {
       
  4312                 var filter = this.options.filter;
       
  4313                 for (var name in filter) {
       
  4314                     switch (name) {
       
  4315                     case 'circle':
       
  4316                         tmplGmlFilter = this.template.gml.filter[name];
       
  4317                         tmplGmlFilter = tmplGmlFilter.replace(/__X__/g, filter[name].x);
       
  4318                         tmplGmlFilter = tmplGmlFilter.replace(/__Y__/g, filter[name].y);
       
  4319                         tmplGmlFilter = tmplGmlFilter.replace(/__RADIUS__/g, filter[name].radius);
       
  4320                         break;
       
  4321                     case 'bbox':
       
  4322                         tmplGmlFilter = this.template.gml.filter[name];
       
  4323                         tmplGmlFilter = tmplGmlFilter.replace(/__LEFT__/g, filter[name].left);
       
  4324                         tmplGmlFilter = tmplGmlFilter.replace(/__BOTTOM__/g, filter[name].bottom);
       
  4325                         tmplGmlFilter = tmplGmlFilter.replace(/__RIGHT__/g, filter[name].right);
       
  4326                         tmplGmlFilter = tmplGmlFilter.replace(/__TOP__/g, filter[name].top);
       
  4327                         break;
       
  4328                     case 'polygon':
       
  4329                         tmplGmlFilter = this.template.gml.filter[name];
       
  4330                         var strPoints = '';
       
  4331                         var lstPoints = filter[name];
       
  4332                         for (var i = 0; i < lstPoints.length; i++) {
       
  4333                             var coord = lstPoints[i];
       
  4334                             if (Array.isArray(coord)) {
       
  4335                                 break;
       
  4336                             }
       
  4337                             if (coord.x && coord.y || (coord.x === 0 || coord.y === 0)) {
       
  4338                                 strPoints += coord.x + ' ' + coord.y;
       
  4339                             }
       
  4340                             if (lstPoints.length !== i + 1) {
       
  4341                                 strPoints += ' ';
       
  4342                             }
       
  4343                         }
       
  4344                         tmplGmlFilter = tmplGmlFilter.replace(/__XY__/g, strPoints);
       
  4345                         break;
       
  4346                     case 'multipolygon':
       
  4347                         break;
       
  4348                     default:
       
  4349                     }
       
  4350                 }
       
  4351             }
       
  4352             template = template.replace(/__GMLPOINT__/g, tmplGmlPoint);
       
  4353             template = template.replace(/__GMLFILTER__/g, tmplGmlFilter);
       
  4354             this.requestString = template;
       
  4355             return this.requestString;
       
  4356         };
       
  4357         return Position;
       
  4358     }(UtilsLoggerByDefault);
       
  4359     FormatsXLSLocationUtilityServiceModelPreference = function (Logger) {
       
  4360         function Preference(type) {
       
  4361             if (!(this instanceof Preference)) {
       
  4362                 throw new TypeError('Preference constructor cannot be called as a function.');
       
  4363             }
       
  4364             this.type = type;
       
  4365         }
       
  4366         Preference.prototype = {
       
  4367             constructor: Preference,
       
  4368             requestString: null,
       
  4369             template: '<ReverseGeocodePreference>__TYPE__</ReverseGeocodePreference>'
       
  4370         };
       
  4371         Preference.prototype.toString = function () {
       
  4372             var Preferences = [];
       
  4373             var tmplPreference = '';
       
  4374             for (var idx = 0; idx < this.type.length; idx++) {
       
  4375                 tmplPreference = this.template;
       
  4376                 tmplPreference = tmplPreference.replace(/__TYPE__/g, this.type[idx]);
       
  4377                 Preferences.push(tmplPreference);
       
  4378             }
       
  4379             this.strRequest = Preferences.join('\n');
       
  4380             return this.strRequest;
       
  4381         };
       
  4382         return Preference;
       
  4383     }(UtilsLoggerByDefault);
       
  4384     FormatsXLSLocationUtilityServiceReverseGeocodeRequest = function (Logger, Position, Preference) {
       
  4385         function ReverseGeocodeRequest(options) {
       
  4386             if (!(this instanceof ReverseGeocodeRequest)) {
       
  4387                 throw new TypeError('ReverseGeocodeRequest constructor cannot be called as a function.');
       
  4388             }
       
  4389             this.options = options || {};
       
  4390             for (var opt in options) {
       
  4391                 if (options.hasOwnProperty(opt)) {
       
  4392                     this.options[opt] = options[opt];
       
  4393                 }
       
  4394             }
       
  4395             this.CLASSNAME = 'ReverseGeocodeRequest';
       
  4396         }
       
  4397         ReverseGeocodeRequest.prototype = {
       
  4398             strRequest: null,
       
  4399             oPosition: null,
       
  4400             oPreference: null,
       
  4401             constructor: ReverseGeocodeRequest,
       
  4402             template: '<ReverseGeocodeRequest returnFreeForm="__RETURNFREEFORM__">' + '__POSITION__' + '__PREFERENCE__' + '</ReverseGeocodeRequest>',
       
  4403             addPosition: function (oPosition) {
       
  4404                 if (oPosition instanceof Position) {
       
  4405                     this.oPosition = oPosition;
       
  4406                 }
       
  4407             },
       
  4408             addPreferences: function (oPreference) {
       
  4409                 if (oPreference instanceof Preference) {
       
  4410                     this.oPreference = oPreference;
       
  4411                 }
       
  4412             },
       
  4413             toString: function () {
       
  4414                 var template = '';
       
  4415                 template = this.template;
       
  4416                 if (!this.oPreference) {
       
  4417                     this.oPreference = new Preference(this.options.filterOptions.type || ['StreetAddress']);
       
  4418                     if (!this.oPreference) {
       
  4419                         throw new Error('Les preferences ne sont pas definies !?');
       
  4420                     }
       
  4421                 }
       
  4422                 template = template.replace(/__PREFERENCE__/g, this.oPreference.toString());
       
  4423                 if (!this.oPosition) {
       
  4424                     var settings = {
       
  4425                         position: this.options.position,
       
  4426                         filter: {}
       
  4427                     };
       
  4428                     if (this.options.filterOptions) {
       
  4429                         settings.filter = this.options.filterOptions;
       
  4430                         delete settings.filter.type;
       
  4431                     }
       
  4432                     this.oPosition = new Position(settings);
       
  4433                     if (!this.oPosition) {
       
  4434                         throw new Error('La position et ses filtres ne sont pas definis !?');
       
  4435                     }
       
  4436                 }
       
  4437                 template = template.replace(/__POSITION__/g, this.oPosition.toString());
       
  4438                 template = template.replace(/__RETURNFREEFORM__/g, this.options.returnFreeForm ? 'true' : 'false');
       
  4439                 this.strRequest = template;
       
  4440                 return this.strRequest;
       
  4441             }
       
  4442         };
       
  4443         return ReverseGeocodeRequest;
       
  4444     }(UtilsLoggerByDefault, FormatsXLSLocationUtilityServiceModelPosition, FormatsXLSLocationUtilityServiceModelPreference);
       
  4445     FormatsXLSLocationUtilityService = function (Logger, AbstractService, GeocodeRequest, ReverseGeocodeRequest, GeocodeFilterExtension) {
       
  4446         function LocationUtilityService(options) {
       
  4447             if (!(this instanceof LocationUtilityService)) {
       
  4448                 throw new TypeError('LocationUtilityService constructor cannot be called as a function.');
       
  4449             }
       
  4450             this.CLASSNAME = 'LocationUtilityService';
       
  4451             this.CLASSTYPE = null;
       
  4452             AbstractService.apply(this, arguments);
       
  4453             if (this.options) {
       
  4454                 this.CLASSTYPE = this.options.location ? 'GeocodeRequest' : this.options.position ? 'ReverseGeocodeRequest' : null;
       
  4455             }
       
  4456         }
       
  4457         LocationUtilityService.prototype = Object.create(AbstractService.prototype, {});
       
  4458         LocationUtilityService.prototype.constructor = LocationUtilityService;
       
  4459         LocationUtilityService.prototype.addRequest = function (oLUSRequest) {
       
  4460             this.CLASSTYPE = oLUSRequest.CLASSNAME;
       
  4461             switch (this.CLASSTYPE) {
       
  4462             case 'GeocodeRequest':
       
  4463             case 'ReverseGeocodeRequest':
       
  4464                 this.oRequest = oLUSRequest;
       
  4465                 break;
       
  4466             default:
       
  4467                 throw new Error('Ce n\'est pas un objet de type \'LUS Request\' !?');
       
  4468             }
       
  4469         };
       
  4470         LocationUtilityService.prototype.addFilter = function (oFilter) {
       
  4471             if (oFilter instanceof GeocodeFilterExtension) {
       
  4472                 this.oFilter = oFilter;
       
  4473             }
       
  4474         };
       
  4475         LocationUtilityService.prototype.toString = function () {
       
  4476             if (!this.oRequest) {
       
  4477                 if (!this.options) {
       
  4478                     throw new Error('Les options ne sont pas renseignées, impossible de construire la requête !');
       
  4479                 }
       
  4480                 if (this.CLASSTYPE === 'GeocodeRequest') {
       
  4481                     var settingsDirect = {
       
  4482                         location: this.options.location,
       
  4483                         returnFreeForm: this.options.returnFreeForm,
       
  4484                         filterOptions: this.options.filterOptions || {}
       
  4485                     };
       
  4486                     this.oRequest = new GeocodeRequest(settingsDirect);
       
  4487                     if (this.oFilter) {
       
  4488                         this.oRequest.addFilter(this.oFilter);
       
  4489                     }
       
  4490                 } else if (this.CLASSTYPE === 'ReverseGeocodeRequest') {
       
  4491                     var settingsInv = {
       
  4492                         position: this.options.position,
       
  4493                         returnFreeForm: this.options.returnFreeForm,
       
  4494                         filterOptions: this.options.filterOptions || {}
       
  4495                     };
       
  4496                     this.oRequest = new ReverseGeocodeRequest(settingsInv);
       
  4497                 } else {
       
  4498                 }
       
  4499             }
       
  4500             if (!this.oRequest) {
       
  4501                 throw new Error('Type de Geocodage indefini !');
       
  4502             }
       
  4503             this.strRequest = this.oRequest.toString();
       
  4504             return this.strRequest;
       
  4505         };
       
  4506         return LocationUtilityService;
       
  4507     }(UtilsLoggerByDefault, FormatsXLSAbstractService, FormatsXLSLocationUtilityServiceGeocodeRequest, FormatsXLSLocationUtilityServiceReverseGeocodeRequest, FormatsXLSLocationUtilityServiceGeocodeFilterExtension);
       
  4508     ServicesGeocodeRequestGeocodeLocation = function () {
       
  4509         function GeocodeLocation() {
       
  4510             if (!(this instanceof GeocodeLocation)) {
       
  4511                 throw new TypeError('GeocodeLocation constructor cannot be called as a function.');
       
  4512             }
       
  4513             this.placeAttributes = {};
       
  4514             this.attributesList = [];
       
  4515             this.serviceAttributes = [];
       
  4516         }
       
  4517         GeocodeLocation.prototype = { constructor: GeocodeLocation };
       
  4518         return GeocodeLocation;
       
  4519     }();
       
  4520     ServicesGeocodeRequestModelStreetAddress = function (GeocodeLocation) {
       
  4521         function StreetAddress() {
       
  4522             if (!(this instanceof StreetAddress)) {
       
  4523                 throw new TypeError('StreetAddress constructor cannot be called as a function.');
       
  4524             }
       
  4525             GeocodeLocation.apply(this, arguments);
       
  4526             this.CLASSNAME = 'StreetAddress';
       
  4527             this.attributesList = [
       
  4528                 'bbox',
       
  4529                 'ID',
       
  4530                 'IDTR',
       
  4531                 'quality',
       
  4532                 'territory',
       
  4533                 'commune',
       
  4534                 'department',
       
  4535                 'insee',
       
  4536                 'municipality'
       
  4537             ];
       
  4538             this.serviceAttributes = [
       
  4539                 'bbox',
       
  4540                 'ID',
       
  4541                 'IDTR',
       
  4542                 'Qualite',
       
  4543                 'Territoire',
       
  4544                 'Commune',
       
  4545                 'Departement',
       
  4546                 'INSEE',
       
  4547                 'Municipality'
       
  4548             ];
       
  4549         }
       
  4550         StreetAddress.prototype = Object.create(GeocodeLocation.prototype);
       
  4551         StreetAddress.prototype.constructor = StreetAddress;
       
  4552         return StreetAddress;
       
  4553     }(ServicesGeocodeRequestGeocodeLocation);
       
  4554     ServicesGeocodeRequestModelPositionOfInterest = function (GeocodeLocation) {
       
  4555         function PositionOfInterest() {
       
  4556             if (!(this instanceof PositionOfInterest)) {
       
  4557                 throw new TypeError('PositionOfInterest constructor cannot be called as a function.');
       
  4558             }
       
  4559             GeocodeLocation.apply(this, arguments);
       
  4560             this.CLASSNAME = 'PositionOfInterest';
       
  4561             this.attributesList = [
       
  4562                 'bbox',
       
  4563                 'importance',
       
  4564                 'nature',
       
  4565                 'territory',
       
  4566                 'commune',
       
  4567                 'department',
       
  4568                 'insee',
       
  4569                 'municipality'
       
  4570             ];
       
  4571             this.serviceAttributes = [
       
  4572                 'bbox',
       
  4573                 'Importance',
       
  4574                 'Nature',
       
  4575                 'Territoire',
       
  4576                 'Commune',
       
  4577                 'Departement',
       
  4578                 'INSEE',
       
  4579                 'Municipality'
       
  4580             ];
       
  4581         }
       
  4582         PositionOfInterest.prototype = Object.create(GeocodeLocation.prototype);
       
  4583         PositionOfInterest.prototype.constructor = PositionOfInterest;
       
  4584         return PositionOfInterest;
       
  4585     }(ServicesGeocodeRequestGeocodeLocation);
       
  4586     ServicesGeocodeRequestModelCadastralParcel = function (GeocodeLocation) {
       
  4587         function CadastralParcel() {
       
  4588             if (!(this instanceof CadastralParcel)) {
       
  4589                 throw new TypeError('CadastralParcel constructor cannot be called as a function.');
       
  4590             }
       
  4591             GeocodeLocation.apply(this, arguments);
       
  4592             this.CLASSNAME = 'CadastralParcel';
       
  4593             this.attributesList = [
       
  4594                 'absorbedCity',
       
  4595                 'sheet',
       
  4596                 'number',
       
  4597                 'section',
       
  4598                 'commune',
       
  4599                 'department',
       
  4600                 'insee',
       
  4601                 'municipality',
       
  4602                 'origin'
       
  4603             ];
       
  4604             this.serviceAttributes = [
       
  4605                 'CommuneAbsorbee',
       
  4606                 'Feuille',
       
  4607                 'Numero',
       
  4608                 'Section',
       
  4609                 'Commune',
       
  4610                 'Departement',
       
  4611                 'INSEE',
       
  4612                 'Municipality',
       
  4613                 'Type'
       
  4614             ];
       
  4615         }
       
  4616         CadastralParcel.prototype = Object.create(GeocodeLocation.prototype);
       
  4617         CadastralParcel.prototype.constructor = CadastralParcel;
       
  4618         return CadastralParcel;
       
  4619     }(ServicesGeocodeRequestGeocodeLocation);
       
  4620     ServicesGeocodeRequestModelAdministratif = function (GeocodeLocation) {
       
  4621         function Administratif() {
       
  4622             if (!(this instanceof Administratif)) {
       
  4623                 throw new TypeError('Administratif constructor cannot be called as a function.');
       
  4624             }
       
  4625             GeocodeLocation.apply(this, arguments);
       
  4626             this.CLASSNAME = 'Administratif';
       
  4627             this.attributesList = [
       
  4628                 'bbox',
       
  4629                 'prefecture',
       
  4630                 'inseeRegion',
       
  4631                 'inseeDepartment',
       
  4632                 'municipality'
       
  4633             ];
       
  4634             this.serviceAttributes = [
       
  4635                 'bbox',
       
  4636                 'Prefecture',
       
  4637                 'InseeRegion',
       
  4638                 'InseeDepartement',
       
  4639                 'Municipality'
       
  4640             ];
       
  4641         }
       
  4642         Administratif.prototype = Object.create(GeocodeLocation.prototype);
       
  4643         Administratif.prototype.constructor = Administratif;
       
  4644         return Administratif;
       
  4645     }(ServicesGeocodeRequestGeocodeLocation);
       
  4646     ServicesGeocodeRequestDirectGeocodeRequestFactory = function (Logger, XLS, LocationUtilityService, GeocodeFilterExtension, StreetAddress, PositionOfInterest, CadastralParcel, Administratif) {
       
  4647         var DirectGeocodeRequestFactory = {
       
  4648             build: function (options) {
       
  4649                 var request = null;
       
  4650                 var oFilter = new GeocodeFilterExtension();
       
  4651                 oFilter.addFilterExtensions(new Administratif());
       
  4652                 oFilter.addFilterExtensions(new StreetAddress());
       
  4653                 oFilter.addFilterExtensions(new PositionOfInterest());
       
  4654                 oFilter.addFilterExtensions(new CadastralParcel());
       
  4655                 var oLUS = new LocationUtilityService({
       
  4656                     location: options.location,
       
  4657                     returnFreeForm: options.returnFreeForm,
       
  4658                     filterOptions: options.filterOptions
       
  4659                 });
       
  4660                 oLUS.addFilter(oFilter);
       
  4661                 var oXLS = new XLS({
       
  4662                     srsName: options.srs,
       
  4663                     maximumResponses: options.maximumResponses
       
  4664                 });
       
  4665                 oXLS.namespace = true;
       
  4666                 oXLS.setService(oLUS);
       
  4667                 request = oXLS.build();
       
  4668                 if (options.httpMethod == 'GET') {
       
  4669                     var myRequest = 'qxml=' + encodeURIComponent(request).replace(/\-/g, '%2D').replace(/\_/g, '%5F').replace(/\./g, '%2E').replace(/\!/g, '%21').replace(/\~/g, '%7E').replace(/\*/g, '%2A').replace(/\'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29');
       
  4670                     request = myRequest;
       
  4671                 }
       
  4672                 return request;
       
  4673             }
       
  4674         };
       
  4675         return DirectGeocodeRequestFactory;
       
  4676     }(UtilsLoggerByDefault, FormatsXLS, FormatsXLSLocationUtilityService, FormatsXLSLocationUtilityServiceGeocodeFilterExtension, ServicesGeocodeRequestModelStreetAddress, ServicesGeocodeRequestModelPositionOfInterest, ServicesGeocodeRequestModelCadastralParcel, ServicesGeocodeRequestModelAdministratif);
       
  4677     ServicesGeocodeResponseModelGeocodeResponse = function () {
       
  4678         function GeocodeResponse() {
       
  4679             if (!(this instanceof GeocodeResponse)) {
       
  4680                 throw new TypeError('GeocodeResponse constructor cannot be called as a function.');
       
  4681             }
       
  4682             this.locations = [];
       
  4683         }
       
  4684         GeocodeResponse.prototype = { constructor: GeocodeResponse };
       
  4685         return GeocodeResponse;
       
  4686     }();
       
  4687     ServicesGeocodeResponseModelGeocodedLocation = function () {
       
  4688         function GeocodedLocation() {
       
  4689             if (!(this instanceof GeocodedLocation)) {
       
  4690                 throw new TypeError('GeocodedLocation constructor cannot be called as a function.');
       
  4691             }
       
  4692             this.position = {
       
  4693                 x: null,
       
  4694                 y: null
       
  4695             };
       
  4696             this.matchType = null;
       
  4697             this.placeAttributes = {};
       
  4698             this.type = null;
       
  4699         }
       
  4700         GeocodedLocation.prototype = { constructor: GeocodedLocation };
       
  4701         return GeocodedLocation;
       
  4702     }();
       
  4703     ServicesGeocodeResponseModelDirectGeocodedLocation = function (GeocodedLocation) {
       
  4704         function DirectGeocodedLocation() {
       
  4705             if (!(this instanceof DirectGeocodedLocation)) {
       
  4706                 throw new TypeError('DirectGeocodedLocation constructor cannot be called as a function.');
       
  4707             }
       
  4708             GeocodedLocation.apply(this, arguments);
       
  4709             this.CLASSNAME = 'DirectGeocodedLocation';
       
  4710             this.accuracy = null;
       
  4711         }
       
  4712         DirectGeocodedLocation.prototype = Object.create(GeocodedLocation.prototype);
       
  4713         DirectGeocodedLocation.prototype.constructor = DirectGeocodedLocation;
       
  4714         return DirectGeocodedLocation;
       
  4715     }(ServicesGeocodeResponseModelGeocodedLocation);
       
  4716     ServicesGeocodeFormatsDirectGeocodeResponseReader = function (Logger, MR, ErrSrv, GeocodeResponse, DirectGeocodedLocation) {
       
  4717         var DirectGeocodeResponseReader = {};
       
  4718         DirectGeocodeResponseReader.VERSION = '1.2';
       
  4719         DirectGeocodeResponseReader.NAMESPACES = {
       
  4720             xmlns: 'http://www.opengis.net/xls',
       
  4721             gml: 'http://www.opengis.net/gml',
       
  4722             xls: 'http://www.opengis.net/xls',
       
  4723             xlsext: 'http://www.opengis.net/xlsext',
       
  4724             xsi: 'http://www.w3.org/2001/XMLSchema-instance'
       
  4725         };
       
  4726         DirectGeocodeResponseReader.SCHEMALOCATION = 'http://wxs.ign.fr/schemas/olsAll.xsd';
       
  4727         DirectGeocodeResponseReader.DEFAULTPREFIX = 'xls';
       
  4728         DirectGeocodeResponseReader.READERS = {
       
  4729             xls: {
       
  4730                 XLS: function (root) {
       
  4731                     var geocodeResponse = new GeocodeResponse();
       
  4732                     __checkServiceAttributes(root);
       
  4733                     __getChildNodes(root, geocodeResponse);
       
  4734                     return geocodeResponse;
       
  4735                 },
       
  4736                 GeocodedAddress: function (node, geocodeResponse) {
       
  4737                     var geocodedLocation = new DirectGeocodedLocation();
       
  4738                     __getChildNodes(node, geocodedLocation);
       
  4739                     if (geocodeResponse && Array.isArray(geocodeResponse.locations)) {
       
  4740                         geocodeResponse.locations.push(geocodedLocation);
       
  4741                     }
       
  4742                 },
       
  4743                 GeocodeMatchCode: function (node, geocodedLocation) {
       
  4744                     var acc = node.getAttribute('accuracy');
       
  4745                     if (acc && geocodedLocation) {
       
  4746                         geocodedLocation.accuracy = parseFloat(acc);
       
  4747                     }
       
  4748                     var matchType = node.getAttribute('matchType');
       
  4749                     if (matchType && geocodedLocation) {
       
  4750                         geocodedLocation.matchType = matchType;
       
  4751                     }
       
  4752                 },
       
  4753                 Address: function (node, geocodedLocation) {
       
  4754                     var countrycode = node.getAttribute('countryCode');
       
  4755                     if (geocodedLocation && countrycode) {
       
  4756                         geocodedLocation.type = countrycode;
       
  4757                     }
       
  4758                     __getChildNodes(node, geocodedLocation);
       
  4759                 },
       
  4760                 freeFormAddress: function (node, geocodedLocation) {
       
  4761                     if (geocodedLocation && geocodedLocation.hasOwnProperty('placeAttributes')) {
       
  4762                         geocodedLocation.placeAttributes.freeform = __getChildValue(node);
       
  4763                     }
       
  4764                 },
       
  4765                 Building: function (node, geocodedLocation) {
       
  4766                     var num = node.getAttribute('number');
       
  4767                     if (geocodedLocation && geocodedLocation.hasOwnProperty('placeAttributes')) {
       
  4768                         if (num) {
       
  4769                             geocodedLocation.placeAttributes.number = num;
       
  4770                         } else if (node.getAttribute('buildingName')) {
       
  4771                             geocodedLocation.placeAttributes.number = node.getAttribute('buildingName');
       
  4772                         } else if (node.getAttribute('subdivision')) {
       
  4773                             geocodedLocation.placeAttributes.number = node.getAttribute('subdivision');
       
  4774                         }
       
  4775                     }
       
  4776                 },
       
  4777                 Street: function (node, geocodedLocation) {
       
  4778                     if (geocodedLocation && geocodedLocation.hasOwnProperty('placeAttributes')) {
       
  4779                         if (geocodedLocation.type === 'StreetAddress') {
       
  4780                             geocodedLocation.placeAttributes.street = __getChildValue(node);
       
  4781                         } else if (geocodedLocation.type === 'CadastralParcel') {
       
  4782                             geocodedLocation.placeAttributes.cadastralParcel = __getChildValue(node);
       
  4783                         }
       
  4784                     }
       
  4785                 },
       
  4786                 Place: function (node, geocodedLocation) {
       
  4787                     var placeType = node.getAttribute('type');
       
  4788                     var placeName = __getChildValue(node);
       
  4789                     if (geocodedLocation && geocodedLocation.hasOwnProperty('placeAttributes')) {
       
  4790                         if (placeType === 'Municipality') {
       
  4791                             geocodedLocation.placeAttributes.municipality = placeName;
       
  4792                         } else if (placeType === 'Bbox') {
       
  4793                             var values = placeName.split(';');
       
  4794                             if (values.length === 4) {
       
  4795                                 geocodedLocation.placeAttributes.bbox = {
       
  4796                                     left: parseFloat(values[0]),
       
  4797                                     right: parseFloat(values[2]),
       
  4798                                     top: parseFloat(values[1]),
       
  4799                                     bottom: parseFloat(values[3])
       
  4800                                 };
       
  4801                             }
       
  4802                         } else if (placeType === 'Commune') {
       
  4803                             geocodedLocation.placeAttributes.commune = placeName;
       
  4804                         } else if (placeType === 'Departement') {
       
  4805                             geocodedLocation.placeAttributes.department = placeName;
       
  4806                         } else if (placeType === 'INSEE') {
       
  4807                             geocodedLocation.placeAttributes.insee = placeName;
       
  4808                         } else if (placeType === 'Qualite') {
       
  4809                             geocodedLocation.placeAttributes.quality = placeName;
       
  4810                         } else if (placeType === 'Territoire') {
       
  4811                             geocodedLocation.placeAttributes.territory = placeName;
       
  4812                         } else if (placeType === 'ID') {
       
  4813                             geocodedLocation.placeAttributes.ID = placeName;
       
  4814                         } else if (placeType === 'ID_TR') {
       
  4815                             geocodedLocation.placeAttributes.IDTR = placeName;
       
  4816                         } else if (placeType === 'Importance') {
       
  4817                             geocodedLocation.placeAttributes.importance = parseInt(placeName, 10);
       
  4818                         } else if (placeType === 'Nature') {
       
  4819                             geocodedLocation.placeAttributes.nature = placeName;
       
  4820                         } else if (placeType === 'Numero') {
       
  4821                             geocodedLocation.placeAttributes.number = placeName;
       
  4822                         } else if (placeType === 'Feuille') {
       
  4823                             geocodedLocation.placeAttributes.sheet = placeName;
       
  4824                         } else if (placeType === 'Section') {
       
  4825                             geocodedLocation.placeAttributes.section = placeName;
       
  4826                         } else if (placeType === 'CommuneAbsorbee') {
       
  4827                             geocodedLocation.placeAttributes.absorbedCity = placeName;
       
  4828                         } else if (placeType === 'Arrondissement') {
       
  4829                             if (placeName) {
       
  4830                                 geocodedLocation.placeAttributes.arrondissement = placeName;
       
  4831                             }
       
  4832                         } else if (placeType === 'Type') {
       
  4833                             geocodedLocation.placeAttributes.origin = placeName;
       
  4834                         } else if (placeType === 'Prefecture') {
       
  4835                             geocodedLocation.placeAttributes.prefecture = placeName;
       
  4836                         } else if (placeType === 'InseeRegion') {
       
  4837                             geocodedLocation.placeAttributes.inseeRegion = placeName;
       
  4838                         } else if (placeType === 'InseeDepartment') {
       
  4839                             geocodedLocation.placeAttributes.inseeDepartment = placeName;
       
  4840                         }
       
  4841                     }
       
  4842                 },
       
  4843                 PostalCode: function (node, geocodedLocation) {
       
  4844                     if (geocodedLocation && geocodedLocation.hasOwnProperty('placeAttributes')) {
       
  4845                         geocodedLocation.placeAttributes.postalCode = __getChildValue(node);
       
  4846                     }
       
  4847                 },
       
  4848                 Error: function (node) {
       
  4849                     var srvMess = node.getAttribute('message');
       
  4850                     var errorCode = node.getAttribute('errorCode');
       
  4851                     var message = MR.getMessage('SERVICE_RESPONSE_EXCEPTION', '(' + errorCode + ') : ' + srvMess);
       
  4852                     throw new ErrSrv({
       
  4853                         message: message,
       
  4854                         type: ErrSrv.TYPE_SRVERR
       
  4855                     });
       
  4856                 }
       
  4857             },
       
  4858             gml: {
       
  4859                 pos: function (node, geocodedLocation) {
       
  4860                     var pos = __getChildValue(node);
       
  4861                     if (geocodedLocation && pos) {
       
  4862                         geocodedLocation.position = {
       
  4863                             x: parseFloat(pos.split(' ')[0]),
       
  4864                             y: parseFloat(pos.split(' ')[1])
       
  4865                         };
       
  4866                     }
       
  4867                 }
       
  4868             },
       
  4869             ExceptionReport: function (node) {
       
  4870                 var response = {};
       
  4871                 if (node.hasChildNodes()) {
       
  4872                     var children = node.childNodes;
       
  4873                     var child;
       
  4874                     for (var i = 0; i < children.length; i++) {
       
  4875                         child = children[i];
       
  4876                         if (child.nodeName === 'Exception') {
       
  4877                             response.exceptionReport = DirectGeocodeResponseReader.READERS['Exception'](child);
       
  4878                         }
       
  4879                     }
       
  4880                 }
       
  4881                 return response;
       
  4882             },
       
  4883             Exception: function (node) {
       
  4884                 var exceptionReport = {};
       
  4885                 var exceptionCode = node.getAttribute('exceptionCode');
       
  4886                 if (exceptionCode) {
       
  4887                     exceptionReport.exceptionCode = exceptionCode;
       
  4888                 }
       
  4889                 var textNode = node.firstChild;
       
  4890                 if (textNode && textNode.nodeType === 3) {
       
  4891                     exceptionReport.exception = textNode.nodeValue;
       
  4892                 }
       
  4893                 return exceptionReport;
       
  4894             }
       
  4895         };
       
  4896         DirectGeocodeResponseReader.read = function (root) {
       
  4897             if (root.nodeName === 'XLS') {
       
  4898                 var nsPrefix = root.prefix;
       
  4899                 if (!nsPrefix) {
       
  4900                     nsPrefix = DirectGeocodeResponseReader.DEFAULTPREFIX;
       
  4901                 }
       
  4902                 var geocodeResponse = DirectGeocodeResponseReader.READERS[nsPrefix][root.nodeName](root);
       
  4903                 return geocodeResponse;
       
  4904             } else if (root.nodeName === 'ExceptionReport') {
       
  4905                 var exceptionReport = DirectGeocodeResponseReader.READERS[root.nodeName](root);
       
  4906                 return exceptionReport;
       
  4907             } else {
       
  4908                 var mess = MR.getMessage('SERVICE_RESPONSE_ANALYSE', root.nodeName);
       
  4909                 throw new ErrSrv({
       
  4910                     message: mess,
       
  4911                     type: ErrSrv.TYPE_UNKERR,
       
  4912                     status: 200
       
  4913                 });
       
  4914             }
       
  4915         };
       
  4916         function __getAttributes(node) {
       
  4917             if (node.attributes.length > 0) {
       
  4918                 var nodeAttributes = {};
       
  4919                 var attributes = node.attributes;
       
  4920                 for (var i = 0; i < attributes.length; i++) {
       
  4921                     var attribute = attributes[i];
       
  4922                     nodeAttributes[attribute.nodeName] = attribute.nodeValue;
       
  4923                 }
       
  4924                 return nodeAttributes;
       
  4925             }
       
  4926         }
       
  4927         function __getChildNodes(node, data) {
       
  4928             if (node.hasChildNodes()) {
       
  4929                 var children = node.childNodes;
       
  4930                 var child;
       
  4931                 var childName;
       
  4932                 var childPrefix;
       
  4933                 for (var i = 0; i < children.length; i++) {
       
  4934                     child = children[i];
       
  4935                     if (child.nodeType === 1) {
       
  4936                         childName = child.localName || child.baseName || child.nodeName;
       
  4937                         childPrefix = child.prefix || DirectGeocodeResponseReader.DEFAULTPREFIX;
       
  4938                         if (DirectGeocodeResponseReader.READERS[childPrefix][childName]) {
       
  4939                             var reader = DirectGeocodeResponseReader.READERS[childPrefix][childName];
       
  4940                             reader(child, data);
       
  4941                         } else {
       
  4942                             __getChildNodes(child, data);
       
  4943                         }
       
  4944                     }
       
  4945                 }
       
  4946             }
       
  4947         }
       
  4948         function __getChildValue(node) {
       
  4949             var textNode;
       
  4950             var value = '';
       
  4951             if (node.hasChildNodes()) {
       
  4952                 textNode = node.firstChild;
       
  4953                 if (textNode.nodeType === 3) {
       
  4954                     value = textNode.nodeValue;
       
  4955                 }
       
  4956             }
       
  4957             return value;
       
  4958         }
       
  4959         function __checkServiceAttributes(XLSNode) {
       
  4960             if (XLSNode.attributes.length > 0) {
       
  4961                 var xlsAttributes = __getAttributes(XLSNode);
       
  4962                 for (var att in xlsAttributes) {
       
  4963                     if (xlsAttributes.hasOwnProperty(att)) {
       
  4964                         if (att === 'version') {
       
  4965                             if (xlsAttributes['version'] !== DirectGeocodeResponseReader.VERSION) {
       
  4966                                 console.log('[DirectGeocodeResponseReader] geocode version is not the expected one : there may be errors in parsing');
       
  4967                                 return;
       
  4968                             }
       
  4969                         }
       
  4970                         if (att === 'xmlns') {
       
  4971                             if (xlsAttributes[att] !== DirectGeocodeResponseReader.NAMESPACES[DirectGeocodeResponseReader.DEFAULTPREFIX]) {
       
  4972                                 console.log('[DirectGeocodeResponseReader] geocode response default namespace is not the expected one');
       
  4973                                 return;
       
  4974                             }
       
  4975                             continue;
       
  4976                         }
       
  4977                         var prefix = att.split(':')[0];
       
  4978                         var ns = att.split(':')[1];
       
  4979                         if (prefix === 'xmlns' && ns) {
       
  4980                             if (DirectGeocodeResponseReader.NAMESPACES[ns]) {
       
  4981                                 if (DirectGeocodeResponseReader.NAMESPACES[ns] !== xlsAttributes[att]) {
       
  4982                                     console.log('[DirectGeocodeResponseReader] geocode response ' + att + ' namespace is not the expected one');
       
  4983                                     return;
       
  4984                                 }
       
  4985                             }
       
  4986                         }
       
  4987                         if (ns === 'schemaLocation') {
       
  4988                             if (DirectGeocodeResponseReader.SCHEMALOCATION !== xlsAttributes[att]) {
       
  4989                                 console.log('[DirectGeocodeResponseReader] geocode response schema location is not the expected one');
       
  4990                                 return;
       
  4991                             }
       
  4992                         }
       
  4993                     }
       
  4994                 }
       
  4995             }
       
  4996         }
       
  4997         return DirectGeocodeResponseReader;
       
  4998     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesGeocodeResponseModelGeocodeResponse, ServicesGeocodeResponseModelDirectGeocodedLocation);
       
  4999     ServicesGeocodeResponseDirectGeocodeResponseFactory = function (Logger, ErrorService, MRes, XML, DirectGeocodeResponseReader) {
       
  5000         var DirectGeocodeReponseFactory = {
       
  5001             build: function (options) {
       
  5002                 var data = null;
       
  5003                 if (options.response) {
       
  5004                     if (options.rawResponse) {
       
  5005                         data = options.response;
       
  5006                     } else {
       
  5007                         try {
       
  5008                             var p = new XML({ reader: DirectGeocodeResponseReader });
       
  5009                             if (typeof options.response === 'string') {
       
  5010                                 p.setXMLString(options.response);
       
  5011                             } else {
       
  5012                                 p.setXMLDoc(options.response);
       
  5013                             }
       
  5014                             data = p.parse();
       
  5015                             if (!data) {
       
  5016                                 throw new Error('L\'analyse de la réponse du service !?');
       
  5017                             }
       
  5018                         } catch (e) {
       
  5019                             var message = e.message;
       
  5020                             if (typeof options.response === 'string') {
       
  5021                                 message += '(\'' + options.response + '\')';
       
  5022                             } else {
       
  5023                                 message += '(\'' + options.response.documentElement.innerHTML + '\')';
       
  5024                             }
       
  5025                             options.onError.call(options.scope, new ErrorService({
       
  5026                                 message: MRes.getMessage('SERVICE_RESPONSE_ANALYSE', message),
       
  5027                                 type: ErrorService.TYPE_UNKERR,
       
  5028                                 status: -1
       
  5029                             }));
       
  5030                             return;
       
  5031                         }
       
  5032                         if (data.exceptionReport) {
       
  5033                             options.onError.call(options.scope, new ErrorService({
       
  5034                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  5035                                 type: ErrorService.TYPE_SRVERR,
       
  5036                                 status: 200
       
  5037                             }));
       
  5038                             return;
       
  5039                         }
       
  5040                     }
       
  5041                 } else {
       
  5042                     options.onError.call(options.scope, new ErrorService({
       
  5043                         message: MRes.getMessage('SERVICE_RESPONSE_EMPTY'),
       
  5044                         type: ErrorService.TYPE_SRVERR,
       
  5045                         status: -1
       
  5046                     }));
       
  5047                     return;
       
  5048                 }
       
  5049                 options.onSuccess.call(options.scope, data);
       
  5050                 return;
       
  5051             }
       
  5052         };
       
  5053         return DirectGeocodeReponseFactory;
       
  5054     }(UtilsLoggerByDefault, ExceptionsErrorService, UtilsMessagesResources, FormatsXML, ServicesGeocodeFormatsDirectGeocodeResponseReader);
       
  5055     ServicesGeocodeGeocode = function (Logger, _, ErrorService, CommonService, DirectGeocodeRequestFactory, DirectGeocodeResponseFactory) {
       
  5056         function Geocode(options) {
       
  5057             if (!(this instanceof Geocode)) {
       
  5058                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'Geocode'));
       
  5059             }
       
  5060             this.CLASSNAME = 'Geocode';
       
  5061             CommonService.apply(this, arguments);
       
  5062             if (!options.location) {
       
  5063                 throw new Error(_.getMessage('PARAM_MISSING', 'location'));
       
  5064             }
       
  5065             if (typeof options.location === 'object' && Object.keys(options.location).length === 0) {
       
  5066                 throw new Error(_.getMessage('PARAM_EMPTY', 'location'));
       
  5067             } else if (typeof options.location === 'string' && options.location.length === 0) {
       
  5068                 throw new Error(_.getMessage('PARAM_EMPTY', 'location'));
       
  5069             }
       
  5070             this.options.location = options.location;
       
  5071             if (!options.filterOptions || typeof options.filterOptions !== 'object') {
       
  5072                 this.options.filterOptions = options.filterOptions = { type: ['StreetAddress'] };
       
  5073             }
       
  5074             if (Object.keys(options.filterOptions).length === 0) {
       
  5075                 this.options.filterOptions = { type: ['StreetAddress'] };
       
  5076             }
       
  5077             var filter = Object.keys(options.filterOptions);
       
  5078             for (var i = 0; i < filter.length; i++) {
       
  5079                 var key = filter[i];
       
  5080                 var filtersCouldBeNumberList = [
       
  5081                     'department',
       
  5082                     'number',
       
  5083                     'postalCode',
       
  5084                     'insee',
       
  5085                     'importance',
       
  5086                     'ID',
       
  5087                     'IDTR',
       
  5088                     'absorbedCity',
       
  5089                     'sheet',
       
  5090                     'section',
       
  5091                     'inseeRegion',
       
  5092                     'inseeDepartment'
       
  5093                 ];
       
  5094                 if (filtersCouldBeNumberList.indexOf(key) !== -1 && typeof options.filterOptions[key] !== 'string') {
       
  5095                     options.filterOptions[key] = options.filterOptions[key].toString();
       
  5096                 }
       
  5097                 if (!options.filterOptions[key]) {
       
  5098                     delete this.options.filterOptions[key];
       
  5099                 }
       
  5100             }
       
  5101             this.options.filterOptions.type = options.filterOptions.type || ['StreetAddress'];
       
  5102             this.options.maximumResponses = options.maximumResponses || 25;
       
  5103             this.options.returnFreeForm = options.returnFreeForm || false;
       
  5104             this.options.srs = options.srs || 'EPSG:4326';
       
  5105             this.options.outputFormat = 'xml';
       
  5106         }
       
  5107         Geocode.prototype = Object.create(CommonService.prototype, {});
       
  5108         Geocode.prototype.constructor = Geocode;
       
  5109         Geocode.prototype.buildRequest = function (error, success) {
       
  5110             var options = {
       
  5111                 httpMethod: this.options.httpMethod,
       
  5112                 location: this.options.location,
       
  5113                 returnFreeForm: this.options.returnFreeForm,
       
  5114                 filterOptions: this.options.filterOptions,
       
  5115                 srs: this.options.srs,
       
  5116                 maximumResponses: this.options.maximumResponses
       
  5117             };
       
  5118             this.request = DirectGeocodeRequestFactory.build(options);
       
  5119             if (!this.request) {
       
  5120                 error.call(this, new ErrorService(_.getMessage('SERVICE_REQUEST_BUILD')));
       
  5121             } else {
       
  5122                 success.call(this, this.request);
       
  5123             }
       
  5124         };
       
  5125         Geocode.prototype.analyzeResponse = function (error, success) {
       
  5126             if (this.response) {
       
  5127                 var options = {
       
  5128                     response: this.response,
       
  5129                     rawResponse: this.options.rawResponse,
       
  5130                     onError: error,
       
  5131                     onSuccess: success,
       
  5132                     scope: this
       
  5133                 };
       
  5134                 DirectGeocodeResponseFactory.build(options);
       
  5135             } else {
       
  5136                 error.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  5137             }
       
  5138         };
       
  5139         return Geocode;
       
  5140     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesCommonService, ServicesGeocodeRequestDirectGeocodeRequestFactory, ServicesGeocodeResponseDirectGeocodeResponseFactory);
       
  5141     ServicesGeocodeRequestReverseGeocodeRequestFactory = function (Logger, XLS, LocationUtilityService) {
       
  5142         var ReverseGeocodeRequestFactory = {
       
  5143             build: function (options) {
       
  5144                 var settings = options || {};
       
  5145                 var request = null;
       
  5146                 var oLUS = new LocationUtilityService({
       
  5147                     position: settings.position,
       
  5148                     returnFreeForm: settings.returnFreeForm,
       
  5149                     filterOptions: settings.filterOptions
       
  5150                 });
       
  5151                 var oXLS = new XLS({
       
  5152                     srsName: settings.srs,
       
  5153                     maximumResponses: settings.maximumResponses
       
  5154                 });
       
  5155                 oXLS.namespace = true;
       
  5156                 oXLS.setService(oLUS);
       
  5157                 request = oXLS.build();
       
  5158                 if (settings.httpMethod == 'GET') {
       
  5159                     var myRequest = 'qxml=' + encodeURIComponent(request).replace(/\-/g, '%2D').replace(/\_/g, '%5F').replace(/\./g, '%2E').replace(/\!/g, '%21').replace(/\~/g, '%7E').replace(/\*/g, '%2A').replace(/\'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29');
       
  5160                     request = myRequest;
       
  5161                 }
       
  5162                 return request;
       
  5163             }
       
  5164         };
       
  5165         return ReverseGeocodeRequestFactory;
       
  5166     }(UtilsLoggerByDefault, FormatsXLS, FormatsXLSLocationUtilityService);
       
  5167     ServicesGeocodeResponseModelReverseGeocodedLocation = function (GeocodedLocation) {
       
  5168         function ReverseGeocodedLocation() {
       
  5169             if (!(this instanceof ReverseGeocodedLocation)) {
       
  5170                 throw new TypeError('ReverseGeocodedLocation constructor cannot be called as a function.');
       
  5171             }
       
  5172             GeocodedLocation.apply(this, arguments);
       
  5173             this.CLASSNAME = 'ReverseGeocodedLocation';
       
  5174             this.searchCenterDistance = null;
       
  5175         }
       
  5176         ReverseGeocodedLocation.prototype = Object.create(GeocodedLocation.prototype);
       
  5177         ReverseGeocodedLocation.prototype.constructor = ReverseGeocodedLocation;
       
  5178         return ReverseGeocodedLocation;
       
  5179     }(ServicesGeocodeResponseModelGeocodedLocation);
       
  5180     ServicesGeocodeFormatsReverseGeocodeResponseReader = function (Logger, MR, ErrSrv, ReverseGeocodeResponse, ReverseGeocodedLocation) {
       
  5181         var ReverseGeocodeResponseReader = {};
       
  5182         ReverseGeocodeResponseReader.VERSION = '1.2';
       
  5183         ReverseGeocodeResponseReader.NAMESPACES = {
       
  5184             xmlns: 'http://www.opengis.net/xls',
       
  5185             gml: 'http://www.opengis.net/gml',
       
  5186             xls: 'http://www.opengis.net/xls',
       
  5187             xlsext: 'http://www.opengis.net/xlsext',
       
  5188             xsi: 'http://www.w3.org/2001/XMLSchema-instance'
       
  5189         };
       
  5190         ReverseGeocodeResponseReader.SCHEMALOCATION = 'http://wxs.ign.fr/schemas/olsAll.xsd';
       
  5191         ReverseGeocodeResponseReader.DEFAULTPREFIX = 'xls';
       
  5192         ReverseGeocodeResponseReader.READERS = {
       
  5193             xls: {
       
  5194                 XLS: function (root) {
       
  5195                     var reverseGeocodeResponse = new ReverseGeocodeResponse();
       
  5196                     __checkServiceAttributes(root);
       
  5197                     __getChildNodes(root, reverseGeocodeResponse);
       
  5198                     return reverseGeocodeResponse;
       
  5199                 },
       
  5200                 ReverseGeocodedLocation: function (node, reverseGeocodeResponse) {
       
  5201                     var reverseGeocodedLocation = new ReverseGeocodedLocation();
       
  5202                     __getChildNodes(node, reverseGeocodedLocation);
       
  5203                     if (reverseGeocodeResponse && Array.isArray(reverseGeocodeResponse.locations)) {
       
  5204                         reverseGeocodeResponse.locations.push(reverseGeocodedLocation);
       
  5205                     }
       
  5206                 },
       
  5207                 Address: function (node, reverseGeocodedLocation) {
       
  5208                     var countrycode = node.getAttribute('countryCode');
       
  5209                     if (reverseGeocodedLocation && countrycode) {
       
  5210                         reverseGeocodedLocation.type = countrycode;
       
  5211                     }
       
  5212                     __getChildNodes(node, reverseGeocodedLocation);
       
  5213                 },
       
  5214                 Building: function (node, reverseGeocodedLocation) {
       
  5215                     var num = node.getAttribute('number');
       
  5216                     if (reverseGeocodedLocation && reverseGeocodedLocation.hasOwnProperty('placeAttributes')) {
       
  5217                         if (num) {
       
  5218                             reverseGeocodedLocation.placeAttributes.number = num;
       
  5219                         } else if (node.getAttribute('buildingName')) {
       
  5220                             reverseGeocodedLocation.placeAttributes.number = node.getAttribute('buildingName');
       
  5221                         } else if (node.getAttribute('subdivision')) {
       
  5222                             reverseGeocodedLocation.placeAttributes.number = node.getAttribute('subdivision');
       
  5223                         }
       
  5224                     }
       
  5225                 },
       
  5226                 Street: function (node, reverseGeocodedLocation) {
       
  5227                     if (reverseGeocodedLocation.type === 'StreetAddress') {
       
  5228                         reverseGeocodedLocation.placeAttributes.street = __getChildValue(node);
       
  5229                     } else if (reverseGeocodedLocation.type === 'CadastralParcel') {
       
  5230                         reverseGeocodedLocation.placeAttributes.cadastralParcel = __getChildValue(node);
       
  5231                     }
       
  5232                 },
       
  5233                 Place: function (node, reverseGeocodedLocation) {
       
  5234                     var placeType = node.getAttribute('type');
       
  5235                     var placeName = __getChildValue(node);
       
  5236                     if (reverseGeocodedLocation && reverseGeocodedLocation.hasOwnProperty('placeAttributes')) {
       
  5237                         if (placeType === 'Municipality') {
       
  5238                             reverseGeocodedLocation.placeAttributes.municipality = placeName;
       
  5239                         } else if (placeType === 'Bbox') {
       
  5240                             var values = placeName.split(';');
       
  5241                             if (values.length === 4) {
       
  5242                                 reverseGeocodedLocation.placeAttributes.bbox = {
       
  5243                                     left: parseFloat(values[0]),
       
  5244                                     right: parseFloat(values[2]),
       
  5245                                     top: parseFloat(values[1]),
       
  5246                                     bottom: parseFloat(values[3])
       
  5247                                 };
       
  5248                             }
       
  5249                         } else if (placeType === 'Commune') {
       
  5250                             reverseGeocodedLocation.placeAttributes.commune = placeName;
       
  5251                         } else if (placeType === 'Departement') {
       
  5252                             reverseGeocodedLocation.placeAttributes.department = placeName;
       
  5253                         } else if (placeType === 'INSEE') {
       
  5254                             reverseGeocodedLocation.placeAttributes.insee = placeName;
       
  5255                         } else if (placeType === 'Qualite') {
       
  5256                             reverseGeocodedLocation.placeAttributes.quality = placeName;
       
  5257                         } else if (placeType === 'Territoire') {
       
  5258                             reverseGeocodedLocation.placeAttributes.territory = placeName;
       
  5259                         } else if (placeType === 'ID') {
       
  5260                             reverseGeocodedLocation.placeAttributes.ID = placeName;
       
  5261                         } else if (placeType === 'ID_TR') {
       
  5262                             reverseGeocodedLocation.placeAttributes.IDTR = placeName;
       
  5263                         } else if (placeType === 'Importance') {
       
  5264                             reverseGeocodedLocation.placeAttributes.importance = parseInt(placeName, 10);
       
  5265                         } else if (placeType === 'Nature') {
       
  5266                             reverseGeocodedLocation.placeAttributes.nature = placeName;
       
  5267                         } else if (placeType === 'Numero') {
       
  5268                             reverseGeocodedLocation.placeAttributes.number = placeName;
       
  5269                         } else if (placeType === 'Feuille') {
       
  5270                             reverseGeocodedLocation.placeAttributes.sheet = placeName;
       
  5271                         } else if (placeType === 'Section') {
       
  5272                             reverseGeocodedLocation.placeAttributes.section = placeName;
       
  5273                         } else if (placeType === 'CommuneAbsorbee') {
       
  5274                             reverseGeocodedLocation.placeAttributes.absorbedCity = placeName;
       
  5275                         } else if (placeType === 'Arrondissement') {
       
  5276                             if (placeName) {
       
  5277                                 reverseGeocodedLocation.placeAttributes.arrondissement = placeName;
       
  5278                             }
       
  5279                         } else if (placeType === 'Type') {
       
  5280                             reverseGeocodedLocation.placeAttributes.origin = placeName;
       
  5281                         } else if (placeType === 'Prefecture') {
       
  5282                             reverseGeocodedLocation.placeAttributes.prefecture = placeName;
       
  5283                         } else if (placeType === 'InseeRegion') {
       
  5284                             reverseGeocodedLocation.placeAttributes.inseeRegion = placeName;
       
  5285                         } else if (placeType === 'InseeDepartment') {
       
  5286                             reverseGeocodedLocation.placeAttributes.inseeDepartment = placeName;
       
  5287                         }
       
  5288                     }
       
  5289                 },
       
  5290                 PostalCode: function (node, reverseGeocodedLocation) {
       
  5291                     if (reverseGeocodedLocation && reverseGeocodedLocation.hasOwnProperty('placeAttributes')) {
       
  5292                         reverseGeocodedLocation.placeAttributes.postalCode = __getChildValue(node);
       
  5293                     }
       
  5294                 },
       
  5295                 SearchCentreDistance: function (node, reverseGeocodedLocation) {
       
  5296                     if (reverseGeocodedLocation) {
       
  5297                         reverseGeocodedLocation.searchCenterDistance = parseFloat(node.getAttribute('value'));
       
  5298                     }
       
  5299                 },
       
  5300                 Error: function (node) {
       
  5301                     var srvMess = node.getAttribute('message');
       
  5302                     var errorCode = node.getAttribute('errorCode');
       
  5303                     var message = MR.getMessage('SERVICE_RESPONSE_EXCEPTION', '(' + errorCode + ') : ' + srvMess);
       
  5304                     throw new ErrSrv({
       
  5305                         message: message,
       
  5306                         type: ErrSrv.TYPE_SRVERR
       
  5307                     });
       
  5308                 }
       
  5309             },
       
  5310             gml: {
       
  5311                 pos: function (node, reverseGeocodedLocation) {
       
  5312                     var pos = __getChildValue(node);
       
  5313                     if (reverseGeocodedLocation && pos) {
       
  5314                         reverseGeocodedLocation.position = {
       
  5315                             x: parseFloat(pos.split(' ')[0]),
       
  5316                             y: parseFloat(pos.split(' ')[1])
       
  5317                         };
       
  5318                     }
       
  5319                 }
       
  5320             },
       
  5321             xlsext: {
       
  5322                 ExtendedGeocodeMatchCode: function (node, reverseGeocodedLocation) {
       
  5323                     if (reverseGeocodedLocation) {
       
  5324                         reverseGeocodedLocation.matchType = __getChildValue(node);
       
  5325                     }
       
  5326                 }
       
  5327             },
       
  5328             ExceptionReport: function (node) {
       
  5329                 var response = {};
       
  5330                 if (node.hasChildNodes()) {
       
  5331                     var children = node.childNodes;
       
  5332                     var child;
       
  5333                     for (var i = 0; i < children.length; i++) {
       
  5334                         child = children[i];
       
  5335                         if (child.nodeName === 'Exception') {
       
  5336                             response.exceptionReport = ReverseGeocodeResponseReader.READERS['Exception'](child);
       
  5337                         }
       
  5338                     }
       
  5339                 }
       
  5340                 return response;
       
  5341             },
       
  5342             Exception: function (node) {
       
  5343                 var exceptionReport = {};
       
  5344                 var exceptionCode = node.getAttribute('exceptionCode');
       
  5345                 if (exceptionCode) {
       
  5346                     exceptionReport.exceptionCode = exceptionCode;
       
  5347                 }
       
  5348                 var textNode = node.firstChild;
       
  5349                 if (textNode && textNode.nodeType === 3) {
       
  5350                     exceptionReport.exception = textNode.nodeValue;
       
  5351                 }
       
  5352                 return exceptionReport;
       
  5353             }
       
  5354         };
       
  5355         ReverseGeocodeResponseReader.read = function (root) {
       
  5356             if (root.nodeName === 'XLS') {
       
  5357                 var nsPrefix = root.prefix;
       
  5358                 if (!nsPrefix) {
       
  5359                     nsPrefix = ReverseGeocodeResponseReader.DEFAULTPREFIX;
       
  5360                 }
       
  5361                 var geocodeResponse = ReverseGeocodeResponseReader.READERS[nsPrefix][root.nodeName](root);
       
  5362                 return geocodeResponse;
       
  5363             } else if (root.nodeName === 'ExceptionReport') {
       
  5364                 var exceptionReport = ReverseGeocodeResponseReader.READERS[root.nodeName](root);
       
  5365                 return exceptionReport;
       
  5366             } else {
       
  5367                 throw new Error('Erreur lors de la lecture de la réponse : elle n\'est pas au format attendu.');
       
  5368             }
       
  5369         };
       
  5370         function __getAttributes(node) {
       
  5371             if (node.attributes.length > 0) {
       
  5372                 var nodeAttributes = {};
       
  5373                 var attributes = node.attributes;
       
  5374                 for (var i = 0; i < attributes.length; i++) {
       
  5375                     var attribute = attributes[i];
       
  5376                     nodeAttributes[attribute.nodeName] = attribute.nodeValue;
       
  5377                 }
       
  5378                 return nodeAttributes;
       
  5379             }
       
  5380         }
       
  5381         function __getChildNodes(node, data) {
       
  5382             if (node.hasChildNodes()) {
       
  5383                 var children = node.childNodes;
       
  5384                 var child;
       
  5385                 var childName;
       
  5386                 var childPrefix;
       
  5387                 for (var i = 0; i < children.length; i++) {
       
  5388                     child = children[i];
       
  5389                     if (child.nodeType === 1) {
       
  5390                         childName = child.localName || child.baseName || child.nodeName;
       
  5391                         childPrefix = child.prefix || ReverseGeocodeResponseReader.DEFAULTPREFIX;
       
  5392                         if (ReverseGeocodeResponseReader.READERS[childPrefix][childName]) {
       
  5393                             var reader = ReverseGeocodeResponseReader.READERS[childPrefix][childName];
       
  5394                             reader(child, data);
       
  5395                         } else {
       
  5396                             __getChildNodes(child, data);
       
  5397                         }
       
  5398                     }
       
  5399                 }
       
  5400             }
       
  5401         }
       
  5402         function __getChildValue(node) {
       
  5403             var textNode;
       
  5404             var value = '';
       
  5405             if (node.hasChildNodes()) {
       
  5406                 textNode = node.firstChild;
       
  5407                 if (textNode.nodeType === 3) {
       
  5408                     value = textNode.nodeValue;
       
  5409                 }
       
  5410             }
       
  5411             return value;
       
  5412         }
       
  5413         function __checkServiceAttributes(XLSNode) {
       
  5414             if (XLSNode.attributes.length > 0) {
       
  5415                 var xlsAttributes = __getAttributes(XLSNode);
       
  5416                 for (var att in xlsAttributes) {
       
  5417                     if (xlsAttributes.hasOwnProperty(att)) {
       
  5418                         if (att === 'version') {
       
  5419                             if (xlsAttributes['version'] !== ReverseGeocodeResponseReader.VERSION) {
       
  5420                                 console.log('[ReverseGeocodeResponseReader] geocode version is not the expected one : there may be errors in parsing');
       
  5421                                 return;
       
  5422                             }
       
  5423                         }
       
  5424                         if (att === 'xmlns') {
       
  5425                             if (xlsAttributes[att] !== ReverseGeocodeResponseReader.NAMESPACES[ReverseGeocodeResponseReader.DEFAULTPREFIX]) {
       
  5426                                 console.log('[ReverseGeocodeResponseReader] geocode response default namespace is not the expected one');
       
  5427                                 return;
       
  5428                             }
       
  5429                             continue;
       
  5430                         }
       
  5431                         var prefix = att.split(':')[0];
       
  5432                         var ns = att.split(':')[1];
       
  5433                         if (prefix === 'xmlns' && ns) {
       
  5434                             if (ReverseGeocodeResponseReader.NAMESPACES[ns]) {
       
  5435                                 if (ReverseGeocodeResponseReader.NAMESPACES[ns] !== xlsAttributes[att]) {
       
  5436                                     console.log('[ReverseGeocodeResponseReader] geocode response ' + att + ' namespace is not the expected one');
       
  5437                                     return;
       
  5438                                 }
       
  5439                             }
       
  5440                         }
       
  5441                         if (ns === 'schemaLocation') {
       
  5442                             if (ReverseGeocodeResponseReader.SCHEMALOCATION !== xlsAttributes[att]) {
       
  5443                                 console.log('[ReverseGeocodeResponseReader] geocode response schema location is not the expected one');
       
  5444                                 return;
       
  5445                             }
       
  5446                         }
       
  5447                     }
       
  5448                 }
       
  5449             }
       
  5450         }
       
  5451         return ReverseGeocodeResponseReader;
       
  5452     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesGeocodeResponseModelGeocodeResponse, ServicesGeocodeResponseModelReverseGeocodedLocation);
       
  5453     ServicesGeocodeResponseReverseGeocodeResponseFactory = function (Logger, MRes, ErrorService, XML, ReverseGeocodeResponseReader) {
       
  5454         var ReverseGeocodeReponseFactory = {
       
  5455             build: function (options) {
       
  5456                 var data = null;
       
  5457                 if (options.response) {
       
  5458                     if (options.rawResponse) {
       
  5459                         data = options.response;
       
  5460                     } else {
       
  5461                         try {
       
  5462                             var p = new XML({ reader: ReverseGeocodeResponseReader });
       
  5463                             if (typeof options.response === 'string') {
       
  5464                                 p.setXMLString(options.response);
       
  5465                             } else {
       
  5466                                 p.setXMLDoc(options.response);
       
  5467                             }
       
  5468                             data = p.parse();
       
  5469                             if (!data) {
       
  5470                                 throw new Error('L\'analyse de la réponse du service !?');
       
  5471                             }
       
  5472                         } catch (e) {
       
  5473                             e.status = 200;
       
  5474                             options.onError.call(options.scope, e);
       
  5475                             return;
       
  5476                         }
       
  5477                         if (data.exceptionReport) {
       
  5478                             options.onError.call(options.scope, new ErrorService({
       
  5479                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  5480                                 type: ErrorService.TYPE_SRVERR,
       
  5481                                 status: 200
       
  5482                             }));
       
  5483                             return;
       
  5484                         }
       
  5485                         if (options.scope && options.scope.options && options.scope.options.srs && options.scope.options.srs !== 'EPSG:4326') {
       
  5486                             var location;
       
  5487                             var pos;
       
  5488                             if (data || data.locations || data.locations.length) {
       
  5489                                 for (var i = 0; i < data.locations.length; i++) {
       
  5490                                     location = data.locations[i];
       
  5491                                     if (location) {
       
  5492                                         pos = location.position;
       
  5493                                         if (pos) {
       
  5494                                             location.position = {
       
  5495                                                 x: pos.y,
       
  5496                                                 y: pos.x
       
  5497                                             };
       
  5498                                         }
       
  5499                                     }
       
  5500                                 }
       
  5501                             }
       
  5502                         }
       
  5503                     }
       
  5504                 } else {
       
  5505                     options.onError.call(options.scope, new ErrorService({
       
  5506                         message: MRes.getMessage('SERVICE_RESPONSE_EMPTY'),
       
  5507                         type: ErrorService.TYPE_SRVERR,
       
  5508                         status: -1
       
  5509                     }));
       
  5510                     return;
       
  5511                 }
       
  5512                 options.onSuccess.call(options.scope, data);
       
  5513                 return;
       
  5514             }
       
  5515         };
       
  5516         return ReverseGeocodeReponseFactory;
       
  5517     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, FormatsXML, ServicesGeocodeFormatsReverseGeocodeResponseReader);
       
  5518     ServicesGeocodeReverseGeocode = function (Logger, _, ErrorService, CommonService, ReverseGeocodeRequestFactory, ReverseGeocodeResponseFactory) {
       
  5519         function ReverseGeocode(options) {
       
  5520             if (!(this instanceof ReverseGeocode)) {
       
  5521                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'ReverseGeocode'));
       
  5522             }
       
  5523             this.CLASSNAME = 'ReverseGeocode';
       
  5524             CommonService.apply(this, arguments);
       
  5525             if (!options.position) {
       
  5526                 throw new Error(_.getMessage('PARAM_MISSING', 'position'));
       
  5527             }
       
  5528             if (options.position.x == null) {
       
  5529                 throw new Error(_.getMessage('PARAM_MISSING', 'position.x'));
       
  5530             }
       
  5531             if (options.position.y == null) {
       
  5532                 throw new Error(_.getMessage('PARAM_MISSING', 'position.y'));
       
  5533             }
       
  5534             this.options.position = options.position;
       
  5535             if (!options.filterOptions || typeof options.filterOptions !== 'object') {
       
  5536                 this.options.filterOptions = options.filterOptions = { type: ['StreetAddress'] };
       
  5537             }
       
  5538             if (Object.keys(options.filterOptions).length === 0) {
       
  5539                 this.options.filterOptions = { type: ['StreetAddress'] };
       
  5540             }
       
  5541             var filter = Object.keys(options.filterOptions);
       
  5542             for (var i = 0; i < filter.length; i++) {
       
  5543                 var key = filter[i];
       
  5544                 if (!options.filterOptions[key] || Object.keys(options.filterOptions[key]).length === 0) {
       
  5545                     delete this.options.filterOptions[key];
       
  5546                 }
       
  5547             }
       
  5548             this.options.filterOptions.type = options.filterOptions.type || ['StreetAddress'];
       
  5549             if (!Array.isArray(this.options.filterOptions.type)) {
       
  5550                 throw new Error(_.getMessage('PARAM_TYPE', 'filterOptions.type'));
       
  5551             }
       
  5552             this.options.maximumResponses = options.maximumResponses || 25;
       
  5553             this.options.returnFreeForm = options.returnFreeForm || false;
       
  5554             this.options.srs = options.srs || 'CRS:84';
       
  5555             if (ReverseGeocode.geoEPSG.indexOf(this.options.srs) === -1) {
       
  5556                 this.options.position = {
       
  5557                     x: this.options.position.y,
       
  5558                     y: this.options.position.x
       
  5559                 };
       
  5560                 if (this.options.filterOptions && this.options.filterOptions.circle) {
       
  5561                     var circle = this.options.filterOptions.circle;
       
  5562                     this.options.filterOptions.circle = {
       
  5563                         x: circle.y,
       
  5564                         y: circle.x,
       
  5565                         radius: circle.radius
       
  5566                     };
       
  5567                 }
       
  5568                 if (this.options.filterOptions && this.options.filterOptions.polygon) {
       
  5569                     var polygon = this.options.filterOptions.polygon;
       
  5570                     for (i = 0; i < polygon.length; i++) {
       
  5571                         var coords = polygon[i];
       
  5572                         this.options.filterOptions.polygon[i] = {
       
  5573                             x: coords.y,
       
  5574                             y: coords.x
       
  5575                         };
       
  5576                     }
       
  5577                 }
       
  5578             }
       
  5579             this.options.outputFormat = 'xml';
       
  5580         }
       
  5581         ReverseGeocode.prototype = Object.create(CommonService.prototype, {});
       
  5582         ReverseGeocode.prototype.constructor = ReverseGeocode;
       
  5583         ReverseGeocode.prototype.buildRequest = function (error, success) {
       
  5584             var options = {
       
  5585                 httpMethod: this.options.httpMethod,
       
  5586                 position: this.options.position,
       
  5587                 returnFreeForm: this.options.returnFreeForm,
       
  5588                 filterOptions: this.options.filterOptions,
       
  5589                 srs: 'EPSG:4326',
       
  5590                 maximumResponses: this.options.maximumResponses
       
  5591             };
       
  5592             this.request = ReverseGeocodeRequestFactory.build(options);
       
  5593             if (!this.request) {
       
  5594                 error.call(this, new ErrorService(_.getMessage('SERVICE_REQUEST_BUILD')));
       
  5595             } else {
       
  5596                 success.call(this, this.request);
       
  5597             }
       
  5598         };
       
  5599         ReverseGeocode.prototype.analyzeResponse = function (error, success) {
       
  5600             if (this.response) {
       
  5601                 var options = {
       
  5602                     response: this.response,
       
  5603                     rawResponse: this.options.rawResponse,
       
  5604                     onError: error,
       
  5605                     onSuccess: success,
       
  5606                     scope: this
       
  5607                 };
       
  5608                 ReverseGeocodeResponseFactory.build(options);
       
  5609             } else {
       
  5610                 error.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  5611             }
       
  5612         };
       
  5613         ReverseGeocode.geoEPSG = ['EPSG:4326'];
       
  5614         return ReverseGeocode;
       
  5615     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesCommonService, ServicesGeocodeRequestReverseGeocodeRequestFactory, ServicesGeocodeResponseReverseGeocodeResponseFactory);
       
  5616     ServicesAutoCompleteResponseModelAutoCompleteResponse = function () {
       
  5617         function AutoCompleteResponse() {
       
  5618             if (!(this instanceof AutoCompleteResponse)) {
       
  5619                 throw new TypeError('AutoCompleteResponse constructor cannot be called as a function.');
       
  5620             }
       
  5621             this.suggestedLocations = [];
       
  5622         }
       
  5623         AutoCompleteResponse.prototype = { constructor: AutoCompleteResponse };
       
  5624         return AutoCompleteResponse;
       
  5625     }();
       
  5626     ServicesAutoCompleteResponseModelSuggestedLocation = function () {
       
  5627         function SuggestedLocation() {
       
  5628             if (!(this instanceof SuggestedLocation)) {
       
  5629                 throw new TypeError('SuggestedLocation constructor cannot be called as a function.');
       
  5630             }
       
  5631             this.type = null;
       
  5632             this.position = {
       
  5633                 x: null,
       
  5634                 y: null
       
  5635             };
       
  5636             this.commune = null;
       
  5637             this.fullText = null;
       
  5638             this.postalCode = null;
       
  5639             this.classification = null;
       
  5640             this.street = null;
       
  5641             this.poi = null;
       
  5642             this.kind = null;
       
  5643         }
       
  5644         SuggestedLocation.prototype = { constructor: SuggestedLocation };
       
  5645         return SuggestedLocation;
       
  5646     }();
       
  5647     ServicesAutoCompleteResponseAutoCompleteResponseFactory = function (Logger, ErrorService, MRes, XML, AutoCompleteResponse, SuggestedLocation) {
       
  5648         var AutoCompleteResponseFactory = {
       
  5649             build: function (options) {
       
  5650                 var data = null;
       
  5651                 if (options.response) {
       
  5652                     if (options.rawResponse) {
       
  5653                         data = options.response;
       
  5654                     } else {
       
  5655                         var JSONResponse;
       
  5656                         if (typeof options.response === 'string') {
       
  5657                             JSONResponse = window.JSON.parse(options.response);
       
  5658                         } else {
       
  5659                             JSONResponse = options.response;
       
  5660                         }
       
  5661                         if (JSONResponse) {
       
  5662                             if (JSONResponse.error) {
       
  5663                                 options.onError.call(options.scope, new ErrorService({
       
  5664                                     message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', JSONResponse.error.description),
       
  5665                                     status: JSONResponse.error.code,
       
  5666                                     type: ErrorService.TYPE_SRVERR
       
  5667                                 }));
       
  5668                                 return;
       
  5669                             }
       
  5670                             data = new AutoCompleteResponse();
       
  5671                             if (JSONResponse.results && Array.isArray(JSONResponse.results)) {
       
  5672                                 var suggestedLocation;
       
  5673                                 for (var i = 0; i < JSONResponse.results.length; i++) {
       
  5674                                     var result = JSONResponse.results[i];
       
  5675                                     suggestedLocation = new SuggestedLocation();
       
  5676                                     if (suggestedLocation) {
       
  5677                                         if (result && result.country === 'StreetAddress') {
       
  5678                                             suggestedLocation.street = result.street;
       
  5679                                             suggestedLocation.type = 'StreetAddress';
       
  5680                                         } else if (result && result.country === 'PositionOfInterest') {
       
  5681                                             suggestedLocation.poi = result.street;
       
  5682                                             suggestedLocation.kind = result.kind;
       
  5683                                             suggestedLocation.type = 'PositionOfInterest';
       
  5684                                         }
       
  5685                                         if (suggestedLocation.position) {
       
  5686                                             suggestedLocation.position.x = result.x;
       
  5687                                             suggestedLocation.position.y = result.y;
       
  5688                                         }
       
  5689                                         suggestedLocation.commune = result.city;
       
  5690                                         suggestedLocation.fullText = result.fulltext;
       
  5691                                         suggestedLocation.postalCode = result.zipcode;
       
  5692                                         suggestedLocation.classification = result.classification;
       
  5693                                     }
       
  5694                                     data.suggestedLocations.push(suggestedLocation);
       
  5695                                 }
       
  5696                             } else {
       
  5697                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_FORMAT_3')));
       
  5698                                 return;
       
  5699                             }
       
  5700                             if (!data.suggestedLocations.length) {
       
  5701                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_FORMAT_3')));
       
  5702                                 return;
       
  5703                             }
       
  5704                         }
       
  5705                         if (!data) {
       
  5706                             options.onError.call(options.scope, new ErrorService({
       
  5707                                 message: MRes.getMessage('SERVICE_RESPONSE_ANALYSE_2'),
       
  5708                                 type: ErrorService.TYPE_UNKERR,
       
  5709                                 status: -1
       
  5710                             }));
       
  5711                             return;
       
  5712                         }
       
  5713                         if (data.exceptionReport) {
       
  5714                             options.onError.call(options.scope, new ErrorService({
       
  5715                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  5716                                 type: ErrorService.TYPE_SRVERR,
       
  5717                                 status: 200
       
  5718                             }));
       
  5719                             return;
       
  5720                         }
       
  5721                     }
       
  5722                 } else {
       
  5723                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  5724                     return;
       
  5725                 }
       
  5726                 options.onSuccess.call(options.scope, data);
       
  5727                 return;
       
  5728             }
       
  5729         };
       
  5730         return AutoCompleteResponseFactory;
       
  5731     }(UtilsLoggerByDefault, ExceptionsErrorService, UtilsMessagesResources, FormatsXML, ServicesAutoCompleteResponseModelAutoCompleteResponse, ServicesAutoCompleteResponseModelSuggestedLocation);
       
  5732     ServicesAutoCompleteAutoComplete = function (CommonService, AutoCompleteResponseFactory, Logger, MR, ErrorService, Helper) {
       
  5733         function AutoComplete(options) {
       
  5734             if (!(this instanceof AutoComplete)) {
       
  5735                 throw new TypeError(MR.getMessage('CLASS_CONSTRUCTOR', 'AutoComplete'));
       
  5736             }
       
  5737             this.CLASSNAME = 'AutoComplete';
       
  5738             CommonService.apply(this, arguments);
       
  5739             if (!options.text) {
       
  5740                 throw new Error(MR.getMessage('PARAM_MISSING', 'text'));
       
  5741             }
       
  5742             this.options.text = options.text;
       
  5743             if (!options.filterOptions || typeof options.filterOptions !== 'object') {
       
  5744                 this.options.filterOptions = options.filterOptions = {
       
  5745                     territory: [],
       
  5746                     type: ['StreetAddress']
       
  5747                 };
       
  5748             }
       
  5749             if (Object.keys(options.filterOptions).length === 0) {
       
  5750                 this.options.filterOptions = {
       
  5751                     territory: [],
       
  5752                     type: ['StreetAddress']
       
  5753                 };
       
  5754             }
       
  5755             this.options.filterOptions.type = options.filterOptions.type || ['StreetAddress'];
       
  5756             this.options.filterOptions.territory = options.filterOptions.territory || [];
       
  5757             this.options.maximumResponses = options.maximumResponses || 10;
       
  5758             if (this.options.protocol === 'XHR' && this.options.httpMethod === 'POST') {
       
  5759                 this.options.httpMethod = 'GET';
       
  5760             }
       
  5761             this.options.outputFormat = 'json';
       
  5762         }
       
  5763         AutoComplete.prototype = Object.create(CommonService.prototype, {});
       
  5764         AutoComplete.prototype.constructor = AutoComplete;
       
  5765         AutoComplete.prototype.buildRequest = function (error, success) {
       
  5766             var territories = '';
       
  5767             if (this.options.filterOptions.territory) {
       
  5768                 territories = this.options.filterOptions.territory.join(';');
       
  5769             }
       
  5770             var types = '';
       
  5771             if (this.options.filterOptions.type) {
       
  5772                 types = this.options.filterOptions.type.join(',');
       
  5773             }
       
  5774             this.request = Helper.normalyzeParameters({
       
  5775                 text: encodeURIComponent(this.options.text),
       
  5776                 type: types,
       
  5777                 terr: territories,
       
  5778                 maximumResponses: this.options.maximumResponses
       
  5779             });
       
  5780             success.call(this, this.request);
       
  5781         };
       
  5782         AutoComplete.prototype.analyzeResponse = function (error, success) {
       
  5783             if (this.response) {
       
  5784                 var options = {
       
  5785                     response: this.response,
       
  5786                     rawResponse: this.options.rawResponse,
       
  5787                     onSuccess: success,
       
  5788                     onError: error,
       
  5789                     scope: this
       
  5790                 };
       
  5791                 AutoCompleteResponseFactory.build(options);
       
  5792             } else {
       
  5793                 error.call(this, new ErrorService(MR.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  5794             }
       
  5795         };
       
  5796         return AutoComplete;
       
  5797     }(ServicesCommonService, ServicesAutoCompleteResponseAutoCompleteResponseFactory, UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, UtilsHelper);
       
  5798     FormatsXLSRouteServiceModelRoutePlan = function (Logger) {
       
  5799         function RoutePlan(options) {
       
  5800             if (!(this instanceof RoutePlan)) {
       
  5801                 throw new TypeError('RoutePlan constructor cannot be called as a function.');
       
  5802             }
       
  5803             this.options = options || {};
       
  5804             if (!options.startPoint) {
       
  5805                 throw new Error('l\'option \'startPoint\' n\'est pas renseignée !');
       
  5806             }
       
  5807             if (!options.endPoint) {
       
  5808                 throw new Error('l\'option \'endPoint\' n\'est pas renseignée !');
       
  5809             }
       
  5810             for (var opt in options) {
       
  5811                 if (options.hasOwnProperty(opt)) {
       
  5812                     this.options[opt] = options[opt];
       
  5813                 }
       
  5814             }
       
  5815         }
       
  5816         RoutePlan.prototype = {
       
  5817             constructor: RoutePlan,
       
  5818             requestString: null,
       
  5819             template: {
       
  5820                 routePlan: '<RoutePlan>' + '__ROUTEPREFERENCE__' + '__GRAPH__' + '__WAYPOINTLIST__' + '__AVOIDLIST__' + '</RoutePlan>',
       
  5821                 routePreference: '<RoutePreference>__VALUEROUTEPREFERENCE__</RoutePreference>',
       
  5822                 graph: '<xlsext:graphName xmlns:xlsext="http://www.opengis.net/xlsext" name="__VALUEGRAPH__"/>',
       
  5823                 wayPointList: {
       
  5824                     container: '<WayPointList>' + '__STARTPOINT__' + '__VIAPOINT__' + '__ENDPOINT__' + '</WayPointList>',
       
  5825                     point: '<Position><gml:Point xmlns:gml="http://www.opengis.net/gml"><gml:pos>__X__ __Y__</gml:pos></gml:Point></Position>',
       
  5826                     startPoint: '<StartPoint>' + '__POINT__' + '</StartPoint>',
       
  5827                     endPoint: '<EndPoint>' + '__POINT__' + '</EndPoint>',
       
  5828                     viaPoint: '<ViaPoint>' + '__POINT__' + '</ViaPoint>'
       
  5829                 },
       
  5830                 avoidList: {
       
  5831                     container: '<AvoidList>' + '__AVOIDFEATURE__' + '</AvoidList>',
       
  5832                     avoidFeature: '<AvoidFeature>__VALUEAVOIDFEATURE__</AvoidFeature>'
       
  5833                 }
       
  5834             },
       
  5835             toString: function () {
       
  5836                 var template = '';
       
  5837                 template = this.template.routePlan;
       
  5838                 if (this.options.routePreference) {
       
  5839                     var tmplPreference = this.template.routePreference;
       
  5840                     tmplPreference = tmplPreference.replace(/__VALUEROUTEPREFERENCE__/, this.options.routePreference);
       
  5841                     template = template.replace(/__ROUTEPREFERENCE__/g, tmplPreference);
       
  5842                 }
       
  5843                 template = template.replace(/__ROUTEPREFERENCE__/g, '');
       
  5844                 if (this.options.avoidFeature) {
       
  5845                     var tmplAvoidList = this.template.avoidList.container;
       
  5846                     var avoidFeatures = [];
       
  5847                     for (var i = 0; i < this.options.avoidFeature.length; i++) {
       
  5848                         var tmplAvoidFeature = this.template.avoidList.avoidFeature;
       
  5849                         tmplAvoidFeature = tmplAvoidFeature.replace(/__VALUEAVOIDFEATURE__/, this.options.avoidFeature[i]);
       
  5850                         avoidFeatures.push(tmplAvoidFeature);
       
  5851                     }
       
  5852                     tmplAvoidList = tmplAvoidList.replace(/__AVOIDFEATURE__/, avoidFeatures.join('\n'));
       
  5853                     template = template.replace(/__AVOIDLIST__/g, tmplAvoidList);
       
  5854                 }
       
  5855                 template = template.replace(/__AVOIDLIST__/g, '');
       
  5856                 if (this.options.graph) {
       
  5857                     var tmplVehicle = this.template.graph;
       
  5858                     tmplVehicle = tmplVehicle.replace(/__VALUEGRAPH__/, this.options.graph);
       
  5859                     template = template.replace(/__GRAPH__/g, tmplVehicle);
       
  5860                 }
       
  5861                 template = template.replace(/__GRAPH__/g, '');
       
  5862                 var tmplWayPointList = this.template.wayPointList.container;
       
  5863                 var tmplPoint = '';
       
  5864                 tmplPoint = this.template.wayPointList.point;
       
  5865                 tmplPoint = tmplPoint.replace(/__X__/, this.options.startPoint.x);
       
  5866                 tmplPoint = tmplPoint.replace(/__Y__/, this.options.startPoint.y);
       
  5867                 tmplWayPointList = tmplWayPointList.replace(/__STARTPOINT__/, this.template.wayPointList.startPoint.replace(/__POINT__/, tmplPoint));
       
  5868                 tmplPoint = this.template.wayPointList.point;
       
  5869                 tmplPoint = tmplPoint.replace(/__X__/, this.options.endPoint.x);
       
  5870                 tmplPoint = tmplPoint.replace(/__Y__/, this.options.endPoint.y);
       
  5871                 tmplWayPointList = tmplWayPointList.replace(/__ENDPOINT__/, this.template.wayPointList.endPoint.replace(/__POINT__/, tmplPoint));
       
  5872                 if (this.options.viaPoint) {
       
  5873                     var points = [];
       
  5874                     for (var j = 0; j < this.options.viaPoint.length; j++) {
       
  5875                         var p = this.options.viaPoint[j];
       
  5876                         tmplPoint = this.template.wayPointList.point;
       
  5877                         tmplPoint = tmplPoint.replace(/__X__/, p.x);
       
  5878                         tmplPoint = tmplPoint.replace(/__Y__/, p.y);
       
  5879                         points.push(tmplPoint);
       
  5880                     }
       
  5881                     tmplWayPointList = tmplWayPointList.replace(/__VIAPOINT__/, this.template.wayPointList.viaPoint.replace(/__POINT__/, points.join('\n')));
       
  5882                 } else {
       
  5883                     tmplWayPointList = tmplWayPointList.replace(/__VIAPOINT__/, '');
       
  5884                 }
       
  5885                 template = template.replace(/__WAYPOINTLIST__/g, tmplWayPointList);
       
  5886                 this.requestString = template;
       
  5887                 return this.requestString;
       
  5888             }
       
  5889         };
       
  5890         return RoutePlan;
       
  5891     }(UtilsLoggerByDefault);
       
  5892     FormatsXLSRouteServiceDetermineRouteRequest = function (Logger, RoutePlan) {
       
  5893         function DetermineRouteRequest(options) {
       
  5894             if (!(this instanceof DetermineRouteRequest)) {
       
  5895                 throw new TypeError('DetermineRouteRequest constructor cannot be called as a function.');
       
  5896             }
       
  5897             this.options = options || {};
       
  5898             for (var opt in options) {
       
  5899                 if (options.hasOwnProperty(opt)) {
       
  5900                     this.options[opt] = options[opt];
       
  5901                 }
       
  5902             }
       
  5903             this.CLASSNAME = 'DetermineRouteRequest';
       
  5904         }
       
  5905         DetermineRouteRequest.prototype = {
       
  5906             strRequest: null,
       
  5907             oRoutePlan: null,
       
  5908             template: {
       
  5909                 determineRouteRequest: '<DetermineRouteRequest distanceUnit="__DISTANCEUNIT__">' + '__ROUTEPLAN__' + '__ROUTEINSTRUCTIONREQUEST__' + '__ROUTEGEOMETRYREQUEST__' + '__ROUTEMAPREQUEST__' + '</DetermineRouteRequest>',
       
  5910                 routeInstructionRequest: '<RouteInstructionsRequest ' + 'provideGeometry="__PROVIDEGEOMETRY__" ' + 'provideBoundingBox="__PROVIDEBBOX__" />',
       
  5911                 routeGeometryRequest: '<RouteGeometryRequest />',
       
  5912                 routeMapRequest: ''
       
  5913             },
       
  5914             addRoute: function (oRoutePlan) {
       
  5915                 if (oRoutePlan instanceof RoutePlan) {
       
  5916                     this.oRoutePlan = oRoutePlan;
       
  5917                 }
       
  5918             },
       
  5919             constructor: DetermineRouteRequest,
       
  5920             toString: function () {
       
  5921                 var template = '';
       
  5922                 template = this.template.determineRouteRequest;
       
  5923                 template = template.replace(/__DISTANCEUNIT__/g, this.options.distanceUnit || 'KM');
       
  5924                 if (!this.oRoutePlan) {
       
  5925                     var settings = this.options.route;
       
  5926                     this.oRoutePlan = new RoutePlan(settings);
       
  5927                     if (!this.oRoutePlan) {
       
  5928                         throw new Error('La construction du calcul d\'initineraire n\'est pas correctement definie !?');
       
  5929                     }
       
  5930                 }
       
  5931                 template = template.replace(/__ROUTEPLAN__/g, this.oRoutePlan.toString());
       
  5932                 var tmplInstruction = this.template.routeInstructionRequest;
       
  5933                 tmplInstruction = tmplInstruction.replace(/__PROVIDEGEOMETRY__/g, this.options.provideGeometry || false);
       
  5934                 tmplInstruction = tmplInstruction.replace(/__PROVIDEBBOX__/g, this.options.provideBoundingBox || false);
       
  5935                 template = template.replace(/__ROUTEINSTRUCTIONREQUEST__/g, tmplInstruction);
       
  5936                 var tmplGeometry = this.template.routeGeometryRequest;
       
  5937                 template = template.replace(/__ROUTEGEOMETRYREQUEST__/g, tmplGeometry);
       
  5938                 var tmplMap = this.template.routeMapRequest;
       
  5939                 template = template.replace(/__ROUTEMAPREQUEST__/g, tmplMap);
       
  5940                 this.strRequest = template;
       
  5941                 return this.strRequest;
       
  5942             }
       
  5943         };
       
  5944         return DetermineRouteRequest;
       
  5945     }(UtilsLoggerByDefault, FormatsXLSRouteServiceModelRoutePlan);
       
  5946     FormatsXLSRouteServiceRouteRequestExtension = undefined;
       
  5947     FormatsXLSRouteService = function (Logger, AbstractService, DetermineRouteRequest, RouteRequestExtension) {
       
  5948         function RouteService(options) {
       
  5949             if (!(this instanceof RouteService)) {
       
  5950                 throw new TypeError('RouteService constructor cannot be called as a function.');
       
  5951             }
       
  5952             this.CLASSNAME = 'RouteService';
       
  5953             this.CLASSTYPE = 'RouteRequest';
       
  5954             AbstractService.apply(this, arguments);
       
  5955         }
       
  5956         RouteService.prototype = Object.create(AbstractService.prototype, {});
       
  5957         RouteService.prototype.constructor = RouteService;
       
  5958         RouteService.prototype.addRequest = function (oRequest) {
       
  5959             if (oRequest.CLASSNAME === 'DetermineRouteRequest') {
       
  5960                 this.oRequest = oRequest;
       
  5961             } else {
       
  5962                 throw new Error('Ce n\'est pas un objet de type \'Route Request\' !?');
       
  5963             }
       
  5964         };
       
  5965         RouteService.prototype.addFilter = function (oFilter) {
       
  5966             if (oFilter instanceof RouteRequestExtension) {
       
  5967                 this.oFilter = oFilter;
       
  5968             }
       
  5969         };
       
  5970         RouteService.prototype.toString = function () {
       
  5971             if (!this.oRequest) {
       
  5972                 if (!this.options) {
       
  5973                     throw new Error('Les options ne sont pas renseignées, impossible de construire la requête !');
       
  5974                 }
       
  5975                 if (this.CLASSTYPE === 'RouteRequest') {
       
  5976                     var settings = {
       
  5977                         distanceUnit: this.options.distanceUnit || null,
       
  5978                         provideGeometry: this.options.provideGeometry || null,
       
  5979                         provideBoundingBox: this.options.provideBoundingBox || null,
       
  5980                         route: {
       
  5981                             routePreference: this.options.routePreference || null,
       
  5982                             startPoint: this.options.startPoint,
       
  5983                             viaPoint: this.options.viaPoint || null,
       
  5984                             endPoint: this.options.endPoint,
       
  5985                             avoidFeature: this.options.avoidFeature || null,
       
  5986                             graph: this.options.graph || null,
       
  5987                             expectedStartTime: this.options.expectedStartTime || null
       
  5988                         }
       
  5989                     };
       
  5990                     this.oRequest = new DetermineRouteRequest(settings);
       
  5991                     if (this.oFilter) {
       
  5992                         this.oRequest.addFilter(this.oFilter);
       
  5993                     }
       
  5994                 }
       
  5995             }
       
  5996             if (!this.oRequest) {
       
  5997                 throw new Error('Type de requête indefini !');
       
  5998             }
       
  5999             this.strRequest = this.oRequest.toString();
       
  6000             return this.strRequest;
       
  6001         };
       
  6002         return RouteService;
       
  6003     }(UtilsLoggerByDefault, FormatsXLSAbstractService, FormatsXLSRouteServiceDetermineRouteRequest, FormatsXLSRouteServiceRouteRequestExtension);
       
  6004     ServicesRouteRequestRouteRequestOLS = function (Logger, XLS, RouteService) {
       
  6005         var RouteRequestOLS = {
       
  6006             build: function (options) {
       
  6007                 var request = null;
       
  6008                 var settings = {
       
  6009                     startPoint: options.startPoint,
       
  6010                     endPoint: options.endPoint,
       
  6011                     viaPoint: options.viaPoints,
       
  6012                     provideBoundingBox: options.provideBbox,
       
  6013                     avoidFeature: options.exclusions,
       
  6014                     expectedStartTime: options.expectedStartTime,
       
  6015                     distanceUnit: options.distanceUnit,
       
  6016                     graph: options.graph,
       
  6017                     provideGeometry: options.geometryInInstructions,
       
  6018                     routePreference: options.routePreference
       
  6019                 };
       
  6020                 var oRS = new RouteService(settings);
       
  6021                 var oXLS = new XLS({
       
  6022                     srsName: options.srs,
       
  6023                     maximumResponses: options.maximumResponses
       
  6024                 });
       
  6025                 oXLS.namespace = true;
       
  6026                 oXLS.setService(oRS);
       
  6027                 request = oXLS.build();
       
  6028                 if (options.httpMethod == 'GET') {
       
  6029                     var myRequest = 'qxml=' + encodeURIComponent(request).replace(/\-/g, '%2D').replace(/\_/g, '%5F').replace(/\./g, '%2E').replace(/\!/g, '%21').replace(/\~/g, '%7E').replace(/\*/g, '%2A').replace(/\'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29');
       
  6030                     request = myRequest;
       
  6031                 }
       
  6032                 return request;
       
  6033             }
       
  6034         };
       
  6035         return RouteRequestOLS;
       
  6036     }(UtilsLoggerByDefault, FormatsXLS, FormatsXLSRouteService);
       
  6037     ServicesRouteRequestModelRouteParamREST = function (Logger) {
       
  6038         function RouteParamREST(options) {
       
  6039             if (!(this instanceof RouteParamREST)) {
       
  6040                 throw new TypeError('RouteParamREST constructor cannot be called as a function.');
       
  6041             }
       
  6042             this.options = options || {};
       
  6043             this.origin = this.options.startPoint.x + ',' + this.options.startPoint.y;
       
  6044             this.destination = this.options.endPoint.x + ',' + this.options.endPoint.y;
       
  6045             this.waypoints = this.options.viaPoints || null;
       
  6046             this.startDateTime = this.options.expectedStartTime || null;
       
  6047             this.graphName = this.options.graph;
       
  6048             this.srs = this.options.srs;
       
  6049             this.exclusions = this.options.exclusions;
       
  6050             this.method = 'TIME';
       
  6051             if (this.options.routePreference) {
       
  6052                 var value = this.options.routePreference;
       
  6053                 switch (value) {
       
  6054                 case 'fastest':
       
  6055                     this.method = 'TIME';
       
  6056                     break;
       
  6057                 case 'shortest':
       
  6058                     this.method = 'DISTANCE';
       
  6059                     break;
       
  6060                 default:
       
  6061                     this.method = 'TIME';
       
  6062                 }
       
  6063             }
       
  6064             this.format = this.options.geometryInInstructions ? 'STANDARDEXT' : 'STANDARD';
       
  6065             this.tolerance = 10;
       
  6066             this.profileId = null;
       
  6067             this.profileName = null;
       
  6068         }
       
  6069         RouteParamREST.CLASSNAME = 'RouteParamREST';
       
  6070         RouteParamREST.prototype = {
       
  6071             constructor: RouteParamREST,
       
  6072             getWaypoints: function () {
       
  6073                 if (!this.waypoints) {
       
  6074                     return;
       
  6075                 }
       
  6076                 var array = [];
       
  6077                 for (var i = 0; i < this.waypoints.length; i++) {
       
  6078                     var obj = this.waypoints[i];
       
  6079                     array.push(obj.x + ',' + obj.y);
       
  6080                 }
       
  6081                 return array.join(';');
       
  6082             },
       
  6083             getExclusions: function () {
       
  6084                 return this.exclusions.join(';');
       
  6085             }
       
  6086         };
       
  6087         RouteParamREST.prototype.getParams = function () {
       
  6088             var map = [];
       
  6089             map.push({
       
  6090                 k: 'origin',
       
  6091                 v: this.origin
       
  6092             });
       
  6093             map.push({
       
  6094                 k: 'destination',
       
  6095                 v: this.destination
       
  6096             });
       
  6097             map.push({
       
  6098                 k: 'method',
       
  6099                 v: this.method
       
  6100             });
       
  6101             if (this.waypoints) {
       
  6102                 map.push({
       
  6103                     k: 'waypoints',
       
  6104                     v: this.getWaypoints()
       
  6105                 });
       
  6106             }
       
  6107             if (this.startDateTime) {
       
  6108                 map.push({
       
  6109                     k: 'startDateTime',
       
  6110                     v: this.startDateTime
       
  6111                 });
       
  6112             }
       
  6113             if (this.graphName) {
       
  6114                 map.push({
       
  6115                     k: 'graphName',
       
  6116                     v: this.graphName
       
  6117                 });
       
  6118             }
       
  6119             if (this.exclusions) {
       
  6120                 map.push({
       
  6121                     k: 'exclusions',
       
  6122                     v: this.getExclusions()
       
  6123                 });
       
  6124             }
       
  6125             if (this.srs) {
       
  6126                 map.push({
       
  6127                     k: 'srs',
       
  6128                     v: this.srs
       
  6129                 });
       
  6130             }
       
  6131             if (this.format) {
       
  6132                 map.push({
       
  6133                     k: 'format',
       
  6134                     v: this.format
       
  6135                 });
       
  6136             }
       
  6137             return map;
       
  6138         };
       
  6139         return RouteParamREST;
       
  6140     }(UtilsLoggerByDefault);
       
  6141     ServicesRouteRequestRouteRequestREST = function (Logger, _, RouteParamREST) {
       
  6142         function RouteRequestREST(options) {
       
  6143             if (!(this instanceof RouteRequestREST)) {
       
  6144                 throw new TypeError('RouteRequestREST constructor cannot be called as a function.');
       
  6145             }
       
  6146             if (!options) {
       
  6147                 throw new Error(_.getMessage('PARAM_EMPTY', 'options'));
       
  6148             }
       
  6149             this.settings = options;
       
  6150         }
       
  6151         RouteRequestREST.prototype = {
       
  6152             requestString: null,
       
  6153             constructor: RouteRequestREST,
       
  6154             processRequestString: function () {
       
  6155                 var oParams = new RouteParamREST(this.settings);
       
  6156                 var params = oParams.getParams();
       
  6157                 var request = '';
       
  6158                 for (var i = 0; i < params.length; i++) {
       
  6159                     var o = params[i];
       
  6160                     if (request) {
       
  6161                         request += '&';
       
  6162                     }
       
  6163                     request += o.k + '=' + o.v;
       
  6164                 }
       
  6165                 this.requestString = request;
       
  6166                 return this.requestString;
       
  6167             }
       
  6168         };
       
  6169         return RouteRequestREST;
       
  6170     }(UtilsLoggerByDefault, UtilsMessagesResources, ServicesRouteRequestModelRouteParamREST);
       
  6171     ServicesRouteRequestRouteRequestFactory = function (Logger, ErrorService, RouteRequestOLS, RouteRequestREST) {
       
  6172         var RouteRequestFactory = {
       
  6173             build: function (options) {
       
  6174                 var request = null;
       
  6175                 var settings = options || {};
       
  6176                 var bOnError = options.onError !== null && typeof options.onError === 'function' ? true : false;
       
  6177                 var message = null;
       
  6178                 switch (options.api) {
       
  6179                 case 'REST':
       
  6180                     var myReq = new RouteRequestREST(settings);
       
  6181                     if (!myReq.processRequestString()) {
       
  6182                         message = 'Error process request (rest) !';
       
  6183                         if (bOnError) {
       
  6184                             options.onError.call(options.scope, new ErrorService(message));
       
  6185                             return;
       
  6186                         }
       
  6187                         throw new Error(message);
       
  6188                     }
       
  6189                     request = myReq.requestString;
       
  6190                     break;
       
  6191                 case 'OLS':
       
  6192                     request = RouteRequestOLS.build(settings);
       
  6193                     if (!request) {
       
  6194                         message = 'Error process request (ols) !';
       
  6195                         if (bOnError) {
       
  6196                             options.onError.call(options.scope, new ErrorService(message));
       
  6197                             return;
       
  6198                         }
       
  6199                         throw new Error(message);
       
  6200                     }
       
  6201                     break;
       
  6202                 default:
       
  6203                     message = 'Type of API is not supported by service (REST or OLS) !';
       
  6204                     if (bOnError) {
       
  6205                         options.onError.call(options.scope, new ErrorService(message));
       
  6206                         return;
       
  6207                     }
       
  6208                     throw new Error(message);
       
  6209                 }
       
  6210                 return request;
       
  6211             }
       
  6212         };
       
  6213         return RouteRequestFactory;
       
  6214     }(UtilsLoggerByDefault, ExceptionsErrorService, ServicesRouteRequestRouteRequestOLS, ServicesRouteRequestRouteRequestREST);
       
  6215     FormatsWKT = function (Logger) {
       
  6216         var WKT = {
       
  6217             toJson: function (strWkt, success, error) {
       
  6218                 var json = null;
       
  6219                 try {
       
  6220                     if (!strWkt) {
       
  6221                         throw new Error('La chaine WKT n\'est pas renseignée !');
       
  6222                     }
       
  6223                     if (!success) {
       
  6224                         success = function (json) {
       
  6225                             console.log(json);
       
  6226                         };
       
  6227                     }
       
  6228                     if (!error) {
       
  6229                         error = function (e) {
       
  6230                             console.log(e);
       
  6231                         };
       
  6232                     }
       
  6233                     var regex;
       
  6234                     var subst;
       
  6235                     var result;
       
  6236                     regex = /(-?\d+\.?[0-9]*)\s(-?\d+\.?[0-9]+)/g;
       
  6237                     subst = '[$1,$2]';
       
  6238                     strWkt = strWkt.replace(regex, subst);
       
  6239                     regex = /^(\w+)/;
       
  6240                     result = regex.exec(strWkt);
       
  6241                     if (RegExp.$1 === 'POLYGON') {
       
  6242                         subst = '{"type" : "Polygon",';
       
  6243                         strWkt = strWkt.replace(RegExp.$1, subst);
       
  6244                         regex = /(\({2}?)/;
       
  6245                         subst = '"coordinates" : [[';
       
  6246                         strWkt = strWkt.replace(regex, subst);
       
  6247                         regex = /(\){2}?)/;
       
  6248                         subst = ']]}';
       
  6249                         strWkt = strWkt.replace(regex, subst);
       
  6250                         regex = /(\()/g;
       
  6251                         subst = '[';
       
  6252                         strWkt = strWkt.replace(regex, subst);
       
  6253                         regex = /(\))/g;
       
  6254                         subst = ']';
       
  6255                         strWkt = strWkt.replace(regex, subst);
       
  6256                     } else if (RegExp.$1 === 'LINESTRING') {
       
  6257                         subst = '{"type" : "LineString",';
       
  6258                         strWkt = strWkt.replace(RegExp.$1, subst);
       
  6259                         regex = /(\(\(?)/;
       
  6260                         subst = '"coordinates" : [';
       
  6261                         strWkt = strWkt.replace(regex, subst);
       
  6262                         regex = /(\)\)?)/;
       
  6263                         subst = ']}';
       
  6264                         strWkt = strWkt.replace(regex, subst);
       
  6265                     }
       
  6266                     json = JSON.parse(strWkt);
       
  6267                     if (!json) {
       
  6268                         throw new Error('Le JSON est vide !');
       
  6269                     }
       
  6270                     if (!json.type) {
       
  6271                         throw new Error('Le type de geometrie n\'est pas connu !');
       
  6272                     }
       
  6273                     if (!json.coordinates) {
       
  6274                         throw new Error('La liste des points est vide !');
       
  6275                     }
       
  6276                     success.call(this, json);
       
  6277                 } catch (e) {
       
  6278                     if (e.name === 'SyntaxError') {
       
  6279                         error.call(this, 'Erreur de parsing JSON !');
       
  6280                         return;
       
  6281                     }
       
  6282                     error.call(this, e);
       
  6283                 }
       
  6284             }
       
  6285         };
       
  6286         return WKT;
       
  6287     }(UtilsLoggerByDefault);
       
  6288     ServicesRouteResponseModelRouteResponse = function () {
       
  6289         function RouteResponse() {
       
  6290             if (!(this instanceof RouteResponse)) {
       
  6291                 throw new TypeError('RouteResponse constructor cannot be called as a function.');
       
  6292             }
       
  6293             this.totalTime = null;
       
  6294             this.totalDistance = null;
       
  6295             this.bbox = {
       
  6296                 left: null,
       
  6297                 right: null,
       
  6298                 top: null,
       
  6299                 bottom: null
       
  6300             };
       
  6301             this.routeGeometry = null;
       
  6302             this.routeInstructions = [];
       
  6303         }
       
  6304         RouteResponse.prototype = { constructor: RouteResponse };
       
  6305         return RouteResponse;
       
  6306     }();
       
  6307     ServicesRouteResponseModelRouteInstruction = function () {
       
  6308         function RouteInstruction() {
       
  6309             if (!(this instanceof RouteInstruction)) {
       
  6310                 throw new TypeError('RouteInstruction constructor cannot be called as a function.');
       
  6311             }
       
  6312             this.duration = null;
       
  6313             this.distance = null;
       
  6314             this.code = null;
       
  6315             this.instruction = null;
       
  6316             this.geometry = null;
       
  6317         }
       
  6318         RouteInstruction.prototype = { constructor: RouteInstruction };
       
  6319         return RouteInstruction;
       
  6320     }();
       
  6321     ServicesRouteFormatsRouteResponseRESTReader = function (Logger, WKT, MessagesResources, ErrSrv, RouteResponse, RouteInstruction) {
       
  6322         var RouteResponseRESTReader = {};
       
  6323         RouteResponseRESTReader.READERS = {
       
  6324             routeResult: function (node) {
       
  6325                 var response = new RouteResponse();
       
  6326                 __getChildNodes(node, response);
       
  6327                 if (response.status === 'error') {
       
  6328                     var message = MessagesResources.getMessage('SERVICE_RESPONSE_EXCEPTION', response.message);
       
  6329                     throw new ErrSrv({
       
  6330                         message: message,
       
  6331                         type: ErrSrv.TYPE_SRVERR
       
  6332                     });
       
  6333                 }
       
  6334                 return response;
       
  6335             },
       
  6336             status: function (node, response) {
       
  6337                 var status = __getChildValue(node);
       
  6338                 if (status === 'ERROR' || status === 'error') {
       
  6339                     if (response) {
       
  6340                         response.status = 'error';
       
  6341                     }
       
  6342                 }
       
  6343             },
       
  6344             message: function (node, response) {
       
  6345                 if (response) {
       
  6346                     response.message = __getChildValue(node);
       
  6347                 }
       
  6348             },
       
  6349             distance: function (node, response) {
       
  6350                 if (response) {
       
  6351                     response.totalDistance = __getChildValue(node);
       
  6352                 }
       
  6353             },
       
  6354             durationSeconds: function (node, response) {
       
  6355                 if (response) {
       
  6356                     response.totalTime = parseFloat(__getChildValue(node));
       
  6357                 }
       
  6358             },
       
  6359             bounds: function (node, response) {
       
  6360                 if (response && response.bbox) {
       
  6361                     var coords = __getChildValue(node).split(/[,;]/);
       
  6362                     response.bbox.left = parseFloat(coords[0]);
       
  6363                     response.bbox.bottom = parseFloat(coords[1]);
       
  6364                     response.bbox.right = parseFloat(coords[2]);
       
  6365                     response.bbox.top = parseFloat(coords[3]);
       
  6366                 }
       
  6367             },
       
  6368             geometryWkt: function (node, response) {
       
  6369                 if (response) {
       
  6370                     var geomWkt = node.innerHTML;
       
  6371                     var onWKTSuccess = function (json) {
       
  6372                         response.routeGeometry = json;
       
  6373                     };
       
  6374                     var onWKTError = function () {
       
  6375                         var msg = MessagesResources.getMessage('PARAM_FORMAT', ['geometryWkt']);
       
  6376                         throw new Error(msg);
       
  6377                     };
       
  6378                     WKT.toJson(geomWkt, onWKTSuccess, onWKTError);
       
  6379                 }
       
  6380             },
       
  6381             step: function (node, response) {
       
  6382                 var routeInstruction = new RouteInstruction();
       
  6383                 var name;
       
  6384                 if (node.hasChildNodes) {
       
  6385                     var children = node.childNodes;
       
  6386                     var child;
       
  6387                     var childName;
       
  6388                     for (var i = 0; i < children.length; i++) {
       
  6389                         child = children[i];
       
  6390                         if (child.nodeType === 1) {
       
  6391                             childName = child.localName || child.baseName || child.nodeName;
       
  6392                             if (childName === 'durationSeconds') {
       
  6393                                 routeInstruction.duration = __getChildValue(child);
       
  6394                             } else if (childName === 'distance') {
       
  6395                                 routeInstruction.distance = __getChildValue(child);
       
  6396                             } else if (childName === 'navInstruction') {
       
  6397                                 routeInstruction.code = __getChildValue(child);
       
  6398                             } else if (childName === 'name') {
       
  6399                                 name = __getChildValue(child);
       
  6400                             }
       
  6401                         }
       
  6402                     }
       
  6403                 }
       
  6404                 if (routeInstruction.code) {
       
  6405                     switch (routeInstruction.code) {
       
  6406                     case 'F':
       
  6407                         if (name != 'Valeur non renseignée') {
       
  6408                             routeInstruction.instruction = 'Tout droit ' + name;
       
  6409                         } else {
       
  6410                             routeInstruction.instruction = 'Continuer tout droit ';
       
  6411                         }
       
  6412                         break;
       
  6413                     case 'B':
       
  6414                         routeInstruction.instruction = 'Demi-tour ' + name;
       
  6415                         break;
       
  6416                     case 'L':
       
  6417                         routeInstruction.instruction = 'Tourner à gauche ' + name;
       
  6418                         break;
       
  6419                     case 'R':
       
  6420                         routeInstruction.instruction = 'Tourner à droite ' + name;
       
  6421                         break;
       
  6422                     case 'BL':
       
  6423                         routeInstruction.instruction = 'Tourner très à gauche ' + name;
       
  6424                         break;
       
  6425                     case 'BR':
       
  6426                         routeInstruction.instruction = 'Tourner très à droite ' + name;
       
  6427                         break;
       
  6428                     case 'FL':
       
  6429                         routeInstruction.instruction = 'Tourner légèrement à gauche ' + name;
       
  6430                         break;
       
  6431                     case 'FR':
       
  6432                         routeInstruction.instruction = 'Tourner légèrement à droite ' + name;
       
  6433                         break;
       
  6434                     case 'round_about_entry':
       
  6435                         routeInstruction.instruction = 'Entrée rond-point ' + name;
       
  6436                         break;
       
  6437                     case 'round_about_exit':
       
  6438                         routeInstruction.instruction = 'Sortie rond-point ' + name;
       
  6439                         break;
       
  6440                     case null:
       
  6441                         routeInstruction.instruction = 'Prendre ' + name;
       
  6442                         break;
       
  6443                     default:
       
  6444                         routeInstruction.instruction = '?' + routeInstruction.code + '? ' + name;
       
  6445                         break;
       
  6446                     }
       
  6447                 }
       
  6448                 if (Array.isArray(response.routeInstructions)) {
       
  6449                     response.routeInstructions.push(routeInstruction);
       
  6450                 }
       
  6451             }
       
  6452         };
       
  6453         RouteResponseRESTReader.read = function (root) {
       
  6454             var response;
       
  6455             if (root.nodeName === 'routeResult') {
       
  6456                 response = RouteResponseRESTReader.READERS['routeResult'](root);
       
  6457                 return response;
       
  6458             } else {
       
  6459                 throw new Error('Erreur lors de la lecture de la réponse : elle n\'est pas au format attendu.');
       
  6460             }
       
  6461         };
       
  6462         function __getChildValue(node) {
       
  6463             var textNode;
       
  6464             var value = '';
       
  6465             if (node.hasChildNodes()) {
       
  6466                 textNode = node.firstChild;
       
  6467                 if (textNode && textNode.nodeType === 3) {
       
  6468                     value = textNode.nodeValue;
       
  6469                 }
       
  6470             }
       
  6471             return value;
       
  6472         }
       
  6473         function __getChildNodes(node, data) {
       
  6474             if (node.hasChildNodes()) {
       
  6475                 var children = node.childNodes;
       
  6476                 var child;
       
  6477                 var childName;
       
  6478                 for (var i = 0; i < children.length; i++) {
       
  6479                     child = children[i];
       
  6480                     if (child.nodeType === 1) {
       
  6481                         childName = child.localName || child.baseName || child.nodeName;
       
  6482                         if (RouteResponseRESTReader.READERS[childName]) {
       
  6483                             var reader = RouteResponseRESTReader.READERS[childName];
       
  6484                             reader(child, data);
       
  6485                         } else {
       
  6486                             __getChildNodes(child, data);
       
  6487                         }
       
  6488                     }
       
  6489                 }
       
  6490             }
       
  6491         }
       
  6492         return RouteResponseRESTReader;
       
  6493     }(UtilsLoggerByDefault, FormatsWKT, UtilsMessagesResources, ExceptionsErrorService, ServicesRouteResponseModelRouteResponse, ServicesRouteResponseModelRouteInstruction);
       
  6494     ServicesRouteFormatsRouteResponseOLSReader = function (Logger) {
       
  6495         var RouteResponseOLSReader = {};
       
  6496         RouteResponseOLSReader.READERS = {};
       
  6497         RouteResponseOLSReader.read = function (root) {
       
  6498         };
       
  6499         return RouteResponseOLSReader;
       
  6500     }(UtilsLoggerByDefault);
       
  6501     ServicesRouteResponseRouteResponseFactory = function (Logger, ErrorService, XML, WKT, MRes, RouteResponseRESTReader, RouteResponseOLSReader, RouteResponse, RouteInstruction) {
       
  6502         var RouteResponseFactory = {
       
  6503             build: function (options) {
       
  6504                 var data = null;
       
  6505                 if (options.response) {
       
  6506                     if (options.rawResponse) {
       
  6507                         data = options.response;
       
  6508                     } else {
       
  6509                         switch (options.outputFormat) {
       
  6510                         case 'xml':
       
  6511                             var routeReader = options.api === 'REST' ? RouteResponseRESTReader : RouteResponseOLSReader;
       
  6512                             try {
       
  6513                                 var p = new XML({ reader: routeReader });
       
  6514                                 if (typeof options.response === 'string') {
       
  6515                                     p.setXMLString(options.response);
       
  6516                                 } else {
       
  6517                                     p.setXMLDoc(options.response);
       
  6518                                 }
       
  6519                                 data = p.parse();
       
  6520                                 if (!data) {
       
  6521                                     throw new ErrorService(MRes.getMessage('SERVICE_RESPONSE_FORMAT', 'xml'));
       
  6522                                 }
       
  6523                             } catch (e) {
       
  6524                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_ANALYSE', options.response)));
       
  6525                                 return;
       
  6526                             }
       
  6527                             break;
       
  6528                         case 'json':
       
  6529                             var JSONResponse;
       
  6530                             if (typeof options.response === 'string') {
       
  6531                                 JSONResponse = window.JSON.parse(options.response);
       
  6532                             } else {
       
  6533                                 JSONResponse = options.response;
       
  6534                             }
       
  6535                             if (JSONResponse.message) {
       
  6536                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', JSONResponse.message)));
       
  6537                                 return;
       
  6538                             }
       
  6539                             if (JSONResponse) {
       
  6540                                 var legs = [];
       
  6541                                 var legSteps = [];
       
  6542                                 var steps = [];
       
  6543                                 data = new RouteResponse();
       
  6544                                 if (data.hasOwnProperty('totalTime')) {
       
  6545                                     data.totalTime = parseFloat(JSONResponse.durationSeconds);
       
  6546                                 }
       
  6547                                 if (data.hasOwnProperty('totalDistance')) {
       
  6548                                     data.totalDistance = options.distanceUnit === 'm' ? JSONResponse.distanceMeters : JSONResponse.distance;
       
  6549                                 }
       
  6550                                 if (data.hasOwnProperty('bbox')) {
       
  6551                                     var coords = JSONResponse.bounds.split(/[,;]/);
       
  6552                                     data.bbox.left = parseFloat(coords[0]);
       
  6553                                     data.bbox.bottom = parseFloat(coords[1]);
       
  6554                                     data.bbox.right = parseFloat(coords[2]);
       
  6555                                     data.bbox.top = parseFloat(coords[3]);
       
  6556                                 }
       
  6557                                 var onWKTSuccess = function (json) {
       
  6558                                     data.routeGeometry = json;
       
  6559                                 };
       
  6560                                 var onWKTError = function (e) {
       
  6561                                     console.log(e);
       
  6562                                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('PARAM_FORMAT', ['geometryWkt'])));
       
  6563                                 };
       
  6564                                 if (data.hasOwnProperty('routeGeometry')) {
       
  6565                                     var geometry = JSONResponse.geometryWkt || JSONResponse.simplifiedWkt;
       
  6566                                     if (geometry) {
       
  6567                                         WKT.toJson(geometry, onWKTSuccess, onWKTError);
       
  6568                                         if (!data.routeGeometry) {
       
  6569                                             return;
       
  6570                                         }
       
  6571                                     }
       
  6572                                 }
       
  6573                                 if (data.hasOwnProperty('routeInstructions')) {
       
  6574                                     var legList = JSONResponse.legs;
       
  6575                                     var i;
       
  6576                                     if (Array.isArray(legList) && legList.length) {
       
  6577                                         for (i = 0; i < legList.length; i++) {
       
  6578                                             legs.push(legList[i]);
       
  6579                                         }
       
  6580                                     }
       
  6581                                     if (Array.isArray(legs) && legs.length) {
       
  6582                                         for (i = 0; i < legs.length; i++) {
       
  6583                                             legSteps.push(legs[i].steps);
       
  6584                                         }
       
  6585                                     }
       
  6586                                     if (Array.isArray(legSteps) && legSteps.length) {
       
  6587                                         for (i = 0; i < legSteps.length; i++) {
       
  6588                                             steps = steps.concat(legSteps[i]);
       
  6589                                         }
       
  6590                                     }
       
  6591                                     steps.forEach(function (step) {
       
  6592                                         data.routeInstructions.push(new RouteInstruction());
       
  6593                                         data.routeInstructions[data.routeInstructions.length - 1].duration = step.durationSeconds;
       
  6594                                         data.routeInstructions[data.routeInstructions.length - 1].distance = options.distanceUnit === 'm' ? step.distanceMeters : step.distance;
       
  6595                                         data.routeInstructions[data.routeInstructions.length - 1].code = step.navInstruction;
       
  6596                                         var points = [];
       
  6597                                         for (var i = 0; i < step.points.length; i++) {
       
  6598                                             var point = step.points[i].split(',');
       
  6599                                             if (point) {
       
  6600                                                 points.push(point);
       
  6601                                             }
       
  6602                                         }
       
  6603                                         if (points && points.length !== 0) {
       
  6604                                             data.routeInstructions[data.routeInstructions.length - 1].geometry = {
       
  6605                                                 coordinates: points,
       
  6606                                                 type: 'LineString'
       
  6607                                             };
       
  6608                                         } else {
       
  6609                                             data.routeInstructions[data.routeInstructions.length - 1].geometry = null;
       
  6610                                         }
       
  6611                                         if (step.name == 'Valeur non renseignée') {
       
  6612                                             step.name = '';
       
  6613                                         }
       
  6614                                         switch (step.navInstruction) {
       
  6615                                         case 'F':
       
  6616                                             if (step.name) {
       
  6617                                                 data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tout droit ' + step.name;
       
  6618                                             } else {
       
  6619                                                 data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Continuer tout droit ';
       
  6620                                             }
       
  6621                                             break;
       
  6622                                         case 'B':
       
  6623                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Demi-tour ' + step.name;
       
  6624                                             break;
       
  6625                                         case 'L':
       
  6626                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner à gauche ' + step.name;
       
  6627                                             break;
       
  6628                                         case 'R':
       
  6629                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner à droite ' + step.name;
       
  6630                                             break;
       
  6631                                         case 'BL':
       
  6632                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner très à gauche ' + step.name;
       
  6633                                             break;
       
  6634                                         case 'BR':
       
  6635                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner très à droite ' + step.name;
       
  6636                                             break;
       
  6637                                         case 'FL':
       
  6638                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner légèrement à gauche ' + step.name;
       
  6639                                             break;
       
  6640                                         case 'FR':
       
  6641                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Tourner légèrement à droite ' + step.name;
       
  6642                                             break;
       
  6643                                         case 'round_about_entry':
       
  6644                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Entrée rond-point ' + step.name;
       
  6645                                             break;
       
  6646                                         case 'round_about_exit':
       
  6647                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Sortie rond-point ' + step.name;
       
  6648                                             break;
       
  6649                                         case null:
       
  6650                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = 'Prendre tout droit ' + step.name;
       
  6651                                             break;
       
  6652                                         default:
       
  6653                                             data.routeInstructions[data.routeInstructions.length - 1].instruction = '?' + step.navInstruction + '? ' + step.name;
       
  6654                                             break;
       
  6655                                         }
       
  6656                                     });
       
  6657                                 }
       
  6658                             }
       
  6659                             if (!data) {
       
  6660                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_ANALYSE', 'json')));
       
  6661                                 return;
       
  6662                             }
       
  6663                             break;
       
  6664                         default:
       
  6665                             options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_FORMAT', 'json', 'xml')));
       
  6666                             return;
       
  6667                         }
       
  6668                         if (data && data.exceptionReport) {
       
  6669                             options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EXCEPTION_2')));
       
  6670                             return;
       
  6671                         }
       
  6672                     }
       
  6673                 } else {
       
  6674                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  6675                     return;
       
  6676                 }
       
  6677                 options.onSuccess.call(options.scope, data);
       
  6678                 return;
       
  6679             }
       
  6680         };
       
  6681         return RouteResponseFactory;
       
  6682     }(UtilsLoggerByDefault, ExceptionsErrorService, FormatsXML, FormatsWKT, UtilsMessagesResources, ServicesRouteFormatsRouteResponseRESTReader, ServicesRouteFormatsRouteResponseOLSReader, ServicesRouteResponseModelRouteResponse, ServicesRouteResponseModelRouteInstruction);
       
  6683     ServicesRouteRoute = function (Logger, _, ErrorService, CommonService, DefaultUrlService, RouteRequestFactory, RouteResponseFactory) {
       
  6684         function Route(options) {
       
  6685             if (!(this instanceof Route)) {
       
  6686                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'Route'));
       
  6687             }
       
  6688             this.CLASSNAME = 'Route';
       
  6689             CommonService.apply(this, arguments);
       
  6690             if (!options.startPoint) {
       
  6691                 throw new Error(_.getMessage('PARAM_MISSING', 'startPoint'));
       
  6692             }
       
  6693             if (options.startPoint.x == null) {
       
  6694                 throw new Error(_.getMessage('PARAM_MISSING', 'startPoint.x'));
       
  6695             }
       
  6696             if (options.startPoint.y == null) {
       
  6697                 throw new Error(_.getMessage('PARAM_MISSING', 'startPoint.y'));
       
  6698             }
       
  6699             if (!options.endPoint) {
       
  6700                 throw new Error(_.getMessage('PARAM_MISSING', 'endPoint'));
       
  6701             }
       
  6702             if (options.endPoint.x == null) {
       
  6703                 throw new Error(_.getMessage('PARAM_MISSING', 'endPoint.x'));
       
  6704             }
       
  6705             if (options.endPoint.y == null) {
       
  6706                 throw new Error(_.getMessage('PARAM_MISSING', 'endPoint.y'));
       
  6707             }
       
  6708             this.options.api = typeof options.api == 'string' ? options.api.toUpperCase() : 'REST';
       
  6709             this.options.outputFormat = typeof options.outputFormat == 'string' ? options.outputFormat.toLowerCase() : 'json';
       
  6710             this.options.startPoint = options.startPoint;
       
  6711             this.options.endPoint = options.endPoint;
       
  6712             this.options.viaPoints = options.viaPoints || null;
       
  6713             this.options.exclusions = options.exclusions || null;
       
  6714             this.options.routePreference = options.routePreference || 'fastest';
       
  6715             this.options.graph = options.graph || 'Voiture';
       
  6716             this.options.geometryInInstructions = options.geometryInInstructions || false;
       
  6717             this.options.provideBbox = options.provideBbox || true;
       
  6718             this.options.distanceUnit = options.distanceUnit || 'km';
       
  6719             this.options.expectedStartTime = null;
       
  6720             this.options.srs = options.srs || 'EPSG:4326';
       
  6721             this.options.api = 'REST';
       
  6722             if (this.options.protocol === 'XHR') {
       
  6723                 this.options.httpMethod = 'GET';
       
  6724             }
       
  6725             if (!this.options.serverUrl) {
       
  6726                 var lstUrlByDefault = DefaultUrlService.Route.url(this.options.apiKey);
       
  6727                 var urlFound = null;
       
  6728                 switch (this.options.api) {
       
  6729                 case 'OLS':
       
  6730                     urlFound = lstUrlByDefault.ols;
       
  6731                     break;
       
  6732                 case 'REST':
       
  6733                     var key = 'route' + '-' + this.options.outputFormat;
       
  6734                     urlFound = lstUrlByDefault[key];
       
  6735                     break;
       
  6736                 default:
       
  6737                     throw new Error(_.getMessage('PARAM_UNKNOWN', 'api'));
       
  6738                 }
       
  6739                 if (!urlFound) {
       
  6740                     throw new Error('Url by default not found !');
       
  6741                 }
       
  6742                 this.options.serverUrl = urlFound;
       
  6743             }
       
  6744             var idx = this.options.serverUrl.lastIndexOf('.');
       
  6745             if (idx !== -1) {
       
  6746                 var extension = this.options.serverUrl.substring(idx + 1);
       
  6747                 if (extension && extension.length < 5) {
       
  6748                     switch (extension.toLowerCase()) {
       
  6749                     case 'json':
       
  6750                     case 'xml':
       
  6751                         this.options.outputFormat = extension.toLowerCase();
       
  6752                         break;
       
  6753                     default:
       
  6754                         throw new Error('type of service : unknown or unsupported (json or xml) !');
       
  6755                     }
       
  6756                 }
       
  6757             }
       
  6758         }
       
  6759         Route.prototype = Object.create(CommonService.prototype, {});
       
  6760         Route.prototype.constructor = Route;
       
  6761         Route.prototype.buildRequest = function (error, success) {
       
  6762             var options = {
       
  6763                 api: this.options.api,
       
  6764                 startPoint: this.options.startPoint,
       
  6765                 endPoint: this.options.endPoint,
       
  6766                 viaPoints: this.options.viaPoints,
       
  6767                 provideBbox: this.options.provideBbox,
       
  6768                 exclusions: this.options.exclusions,
       
  6769                 distanceUnit: this.options.distanceUnit,
       
  6770                 graph: this.options.graph,
       
  6771                 geometryInInstructions: this.options.geometryInInstructions,
       
  6772                 routePreference: this.options.routePreference,
       
  6773                 srs: this.options.srs
       
  6774             };
       
  6775             this.request = RouteRequestFactory.build(options);
       
  6776             if (!this.request) {
       
  6777                 error.call(this, new ErrorService(_.getMessage('SERVICE_REQUEST_BUILD')));
       
  6778             } else {
       
  6779                 success.call(this, this.request);
       
  6780             }
       
  6781         };
       
  6782         Route.prototype.analyzeResponse = function (error, success) {
       
  6783             if (this.response) {
       
  6784                 var options = {
       
  6785                     distanceUnit: this.options.distanceUnit,
       
  6786                     response: this.response,
       
  6787                     outputFormat: this.options.outputFormat,
       
  6788                     api: this.options.api,
       
  6789                     rawResponse: this.options.rawResponse,
       
  6790                     onError: error,
       
  6791                     onSuccess: success,
       
  6792                     scope: this
       
  6793                 };
       
  6794                 RouteResponseFactory.build(options);
       
  6795             } else {
       
  6796                 error.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  6797             }
       
  6798         };
       
  6799         return Route;
       
  6800     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesCommonService, ServicesDefaultUrlService, ServicesRouteRequestRouteRequestFactory, ServicesRouteResponseRouteResponseFactory);
       
  6801     ServicesProcessIsoCurveRequestModelProcessIsoCurveParam = function (Logger) {
       
  6802         function ProcessIsoCurveParam(options) {
       
  6803             if (!(this instanceof ProcessIsoCurveParam)) {
       
  6804                 throw new TypeError('ProcessIsoCurveParam constructor cannot be called as a function.');
       
  6805             }
       
  6806             this.options = options || {};
       
  6807             this.id = this.options.id;
       
  6808             this.location = this.options.position;
       
  6809             this.srs = this.options.srs;
       
  6810             this.graphName = this.options.graph;
       
  6811             this.profileId = this.options.profileId || null;
       
  6812             this.profileName = this.options.profileName || null;
       
  6813             this.exclusions = this.options.exclusions;
       
  6814             this.reverse = this.options.reverse;
       
  6815             this.smoothing = this.options.smoothing;
       
  6816             this.holes = this.options.holes;
       
  6817             var value = this.options.method;
       
  6818             switch (value) {
       
  6819             case 'time':
       
  6820                 this.method = 'time';
       
  6821                 this.time = this.options.time;
       
  6822                 break;
       
  6823             case 'distance':
       
  6824                 this.method = 'distance';
       
  6825                 this.distance = this.options.distance;
       
  6826                 break;
       
  6827             default:
       
  6828                 this.method = 'time';
       
  6829             }
       
  6830         }
       
  6831         ProcessIsoCurveParam.CLASSNAME = 'ProcessIsoCurveParam';
       
  6832         ProcessIsoCurveParam.prototype = {
       
  6833             constructor: ProcessIsoCurveParam,
       
  6834             getLocation: function () {
       
  6835                 return this.location.x + ',' + this.location.y;
       
  6836             },
       
  6837             getExclusions: function () {
       
  6838                 return this.exclusions.join(';');
       
  6839             }
       
  6840         };
       
  6841         ProcessIsoCurveParam.prototype.getParams = function () {
       
  6842             var map = [];
       
  6843             map.push({
       
  6844                 k: 'location',
       
  6845                 v: this.getLocation()
       
  6846             });
       
  6847             map.push({
       
  6848                 k: 'smoothing',
       
  6849                 v: this.smoothing
       
  6850             });
       
  6851             map.push({
       
  6852                 k: 'holes',
       
  6853                 v: this.holes
       
  6854             });
       
  6855             map.push({
       
  6856                 k: 'reverse',
       
  6857                 v: this.reverse
       
  6858             });
       
  6859             map.push({
       
  6860                 k: 'method',
       
  6861                 v: this.method
       
  6862             });
       
  6863             if (this.time) {
       
  6864                 map.push({
       
  6865                     k: 'time',
       
  6866                     v: this.time
       
  6867                 });
       
  6868             }
       
  6869             if (this.distance) {
       
  6870                 map.push({
       
  6871                     k: 'distance',
       
  6872                     v: this.distance
       
  6873                 });
       
  6874             }
       
  6875             map.push({
       
  6876                 k: 'graphName',
       
  6877                 v: this.graphName
       
  6878             });
       
  6879             if (this.exclusions) {
       
  6880                 map.push({
       
  6881                     k: 'exclusions',
       
  6882                     v: this.getExclusions()
       
  6883                 });
       
  6884             }
       
  6885             if (this.srs) {
       
  6886                 map.push({
       
  6887                     k: 'srs',
       
  6888                     v: this.srs
       
  6889                 });
       
  6890             }
       
  6891             return map;
       
  6892         };
       
  6893         return ProcessIsoCurveParam;
       
  6894     }(UtilsLoggerByDefault);
       
  6895     ServicesProcessIsoCurveRequestProcessIsoCurveRequest = function (Logger, _, ProcessIsoCurveParam) {
       
  6896         function ProcessIsoCurveRequest(options) {
       
  6897             if (!(this instanceof ProcessIsoCurveRequest)) {
       
  6898                 throw new TypeError('ProcessIsoCurveRequest constructor cannot be called as a function.');
       
  6899             }
       
  6900             if (!options) {
       
  6901                 throw new Error(_.getMessage('PARAM_EMPTY', 'options'));
       
  6902             }
       
  6903             this.settings = options;
       
  6904             this.mode = this.settings.httpMethod || 'GET';
       
  6905         }
       
  6906         ProcessIsoCurveRequest.prototype = {
       
  6907             requestString: null,
       
  6908             constructor: ProcessIsoCurveRequest,
       
  6909             template: {
       
  6910                 container: '<?xml version="1.0" encoding="UTF-8"?>\n' + '<isochroneRequest>\n' + '__ID__' + '\t<location>\n' + '\t\t<x>__X__</x>\n' + '\t\t<y>__Y__</y>\n' + '\t</location>\n' + '\t<srs>__SRS__</srs>\n' + '\t<graphName>__GRAPHNAME__</graphName>\n' + '__PROFIL__' + '__EXCLUSIONS__' + '\t<method>__METHOD__</method>\n' + '__TIME__' + '__DISTANCE__' + '\t<reverse>__REVERSE__</reverse>\n' + '\t<smoothing>__SMOOTHING__</smoothing>\n' + '\t<holes>__HOLES__</holes>\n' + '</isochroneRequest>',
       
  6911                 id: '\t<id>__IDVALUE__</id>\n',
       
  6912                 profil: '\t<profileId>__PROFILID__</profileId>\n' + '\t<profileName>__PROFILNAME__</profileName>\n',
       
  6913                 exclusions: {
       
  6914                     container: '\t<exclusions>\n' + '__EXCLUSIONFEATURE__\n' + '\t</exclusions>\n',
       
  6915                     feature: '\t\t<exclusion>__EXCLUSIONVALUE__</exclusion>'
       
  6916                 },
       
  6917                 time: '\t<time>__TIMEVALUE__</time>\n',
       
  6918                 distance: '\t<distance>__DISTANCEVALUE__</distance>\n'
       
  6919             },
       
  6920             processRequestString: function () {
       
  6921                 var request = '';
       
  6922                 var i = 0;
       
  6923                 switch (this.mode) {
       
  6924                 case 'GET':
       
  6925                     var oParams = new ProcessIsoCurveParam(this.settings);
       
  6926                     var params = oParams.getParams();
       
  6927                     for (i = 0; i < params.length; i++) {
       
  6928                         var o = params[i];
       
  6929                         if (request) {
       
  6930                             request += '&';
       
  6931                         }
       
  6932                         request += o.k + '=' + o.v;
       
  6933                     }
       
  6934                     break;
       
  6935                 case 'POST':
       
  6936                     request = this.template.container;
       
  6937                     request = request.replace(/__ID__/g, '');
       
  6938                     request = request.replace(/__PROFIL__/g, '');
       
  6939                     request = request.replace(/__X__/g, this.settings.position.x);
       
  6940                     request = request.replace(/__Y__/g, this.settings.position.y);
       
  6941                     request = request.replace(/__GRAPHNAME__/g, this.settings.graph);
       
  6942                     request = request.replace(/__SRS__/g, this.settings.srs);
       
  6943                     request = request.replace(/__SMOOTHING__/g, this.settings.smoothing);
       
  6944                     request = request.replace(/__HOLES__/g, this.settings.holes);
       
  6945                     request = request.replace(/__REVERSE__/g, this.settings.reverse);
       
  6946                     if (this.settings.exclusions) {
       
  6947                         var tmplExclusions = this.template.exclusions.container;
       
  6948                         var exclusions = [];
       
  6949                         for (i = 0; i < this.settings.exclusions.length; i++) {
       
  6950                             var tmplFeature = this.template.exclusions.feature;
       
  6951                             tmplFeature = tmplFeature.replace(/__EXCLUSIONVALUE__/, this.settings.exclusions[i]);
       
  6952                             exclusions.push(tmplFeature);
       
  6953                         }
       
  6954                         tmplExclusions = tmplExclusions.replace(/__EXCLUSIONFEATURE__/, exclusions.join('\n'));
       
  6955                         request = request.replace(/__EXCLUSIONS__/g, tmplExclusions);
       
  6956                     }
       
  6957                     request = request.replace(/__EXCLUSIONS__/g, '');
       
  6958                     if (this.settings.distance) {
       
  6959                         var tmplDistance = this.template.distance;
       
  6960                         tmplDistance = tmplDistance.replace(/__DISTANCEVALUE__/g, this.settings.distance);
       
  6961                         request = request.replace(/__DISTANCE__/g, tmplDistance);
       
  6962                         request = request.replace(/__METHOD__/g, 'distance');
       
  6963                     }
       
  6964                     request = request.replace(/__DISTANCE__/g, '');
       
  6965                     if (this.settings.time) {
       
  6966                         var tmplTime = this.template.time;
       
  6967                         tmplTime = tmplTime.replace(/__TIMEVALUE__/g, this.settings.time);
       
  6968                         request = request.replace(/__TIME__/g, tmplTime);
       
  6969                         request = request.replace(/__METHOD__/g, 'time');
       
  6970                     }
       
  6971                     request = request.replace(/__TIME__/g, '');
       
  6972                     break;
       
  6973                 default:
       
  6974                 }
       
  6975                 this.requestString = request;
       
  6976                 return this.requestString;
       
  6977             }
       
  6978         };
       
  6979         return ProcessIsoCurveRequest;
       
  6980     }(UtilsLoggerByDefault, UtilsMessagesResources, ServicesProcessIsoCurveRequestModelProcessIsoCurveParam);
       
  6981     ServicesProcessIsoCurveResponseModelProcessIsoCurveResponse = function () {
       
  6982         function ProcessIsoCurveResponse() {
       
  6983             if (!(this instanceof ProcessIsoCurveResponse)) {
       
  6984                 throw new TypeError('ProcessIsoCurveResponse constructor cannot be called as a function.');
       
  6985             }
       
  6986             this.message = null;
       
  6987             this.id = null;
       
  6988             this.location = {};
       
  6989             this.location.x = null;
       
  6990             this.location.y = null;
       
  6991             this.srs = null;
       
  6992             this.geometry = null;
       
  6993             this.time = null;
       
  6994             this.distance = null;
       
  6995         }
       
  6996         ProcessIsoCurveResponse.prototype = { constructor: ProcessIsoCurveResponse };
       
  6997         return ProcessIsoCurveResponse;
       
  6998     }();
       
  6999     ServicesProcessIsoCurveFormatsProcessIsoCurveResponseReader = function (Logger, WKT, ErrSrv, MessagesResources, ProcessIsoCurveResponse) {
       
  7000         var ProcessIsoCurveResponseReader = {};
       
  7001         ProcessIsoCurveResponseReader.READERS = {
       
  7002             isochronResult: function (root) {
       
  7003                 var response = new ProcessIsoCurveResponse();
       
  7004                 if (root.hasChildNodes()) {
       
  7005                     var children = root.childNodes;
       
  7006                     var child;
       
  7007                     for (var i = 0; i < children.length; i++) {
       
  7008                         child = children[i];
       
  7009                         if (ProcessIsoCurveResponseReader.READERS[child.nodeName]) {
       
  7010                             ProcessIsoCurveResponseReader.READERS[child.nodeName](child, response);
       
  7011                         }
       
  7012                     }
       
  7013                 }
       
  7014                 if (response.status === 'error') {
       
  7015                     var message = MessagesResources.getMessage('SERVICE_RESPONSE_EXCEPTION', response.message);
       
  7016                     throw new ErrSrv({
       
  7017                         message: message,
       
  7018                         type: ErrSrv.TYPE_SRVERR
       
  7019                     });
       
  7020                 }
       
  7021                 return response;
       
  7022             },
       
  7023             message: function (node, response) {
       
  7024                 if (response) {
       
  7025                     response.message = __getChildValue(node);
       
  7026                 }
       
  7027             },
       
  7028             status: function (node, response) {
       
  7029                 var status = __getChildValue(node);
       
  7030                 if (status === 'ERROR' || status === 'error') {
       
  7031                     if (response) {
       
  7032                         response.status = 'error';
       
  7033                     }
       
  7034                 }
       
  7035             },
       
  7036             id: function (node, response) {
       
  7037                 if (response) {
       
  7038                     response.id = __getChildValue(node);
       
  7039                 }
       
  7040             },
       
  7041             location: function (node, response) {
       
  7042                 var coords = __getChildValue(node);
       
  7043                 if (response && response.location) {
       
  7044                     response.location.x = parseFloat(coords.split(',')[0]);
       
  7045                     response.location.y = parseFloat(coords.split(',')[1]);
       
  7046                 }
       
  7047             },
       
  7048             srs: function (node, response) {
       
  7049                 if (response) {
       
  7050                     response.srs = __getChildValue(node);
       
  7051                 }
       
  7052             },
       
  7053             distance: function (node, response) {
       
  7054                 if (response) {
       
  7055                     response.distance = parseFloat(__getChildValue(node));
       
  7056                 }
       
  7057             },
       
  7058             time: function (node, response) {
       
  7059                 if (response) {
       
  7060                     response.time = parseFloat(__getChildValue(node));
       
  7061                 }
       
  7062             },
       
  7063             wktGeometry: function (node, response) {
       
  7064                 if (response) {
       
  7065                     var wktGeometry = node.innerHTML;
       
  7066                     var onWKTSuccess = function (json) {
       
  7067                         response.geometry = json;
       
  7068                     };
       
  7069                     var onWKTError = function () {
       
  7070                         var msg = MessagesResources.getMessage('PARAM_FORMAT', ['wktGeometry']);
       
  7071                         throw new Error(msg);
       
  7072                     };
       
  7073                     if (response.hasOwnProperty('geometry')) {
       
  7074                         WKT.toJson(wktGeometry, onWKTSuccess, onWKTError);
       
  7075                     }
       
  7076                 }
       
  7077             },
       
  7078             serviceResult: function (node) {
       
  7079                 var response = {};
       
  7080                 if (node.hasChildNodes()) {
       
  7081                     var children = node.childNodes;
       
  7082                     var child;
       
  7083                     for (var i = 0; i < children.length; i++) {
       
  7084                         child = children[i];
       
  7085                         if (ProcessIsoCurveResponseReader.READERS[child.nodeName]) {
       
  7086                             ProcessIsoCurveResponseReader.READERS[child.nodeName](child, response);
       
  7087                         }
       
  7088                     }
       
  7089                 }
       
  7090                 return response;
       
  7091             },
       
  7092             ExceptionReport: function (node) {
       
  7093                 var response = {};
       
  7094                 if (node.hasChildNodes()) {
       
  7095                     var children = node.childNodes;
       
  7096                     var child;
       
  7097                     for (var i = 0; i < children.length; i++) {
       
  7098                         child = children[i];
       
  7099                         if (child.nodeName === 'Exception') {
       
  7100                             response.exceptionReport = ProcessIsoCurveResponseReader.READERS['Exception'](child);
       
  7101                         }
       
  7102                     }
       
  7103                 }
       
  7104                 return response;
       
  7105             },
       
  7106             Exception: function (node) {
       
  7107                 var exceptionReport = {};
       
  7108                 var exceptionCode = node.getAttribute('exceptionCode');
       
  7109                 if (exceptionCode) {
       
  7110                     exceptionReport.exceptionCode = exceptionCode;
       
  7111                 }
       
  7112                 var textNode = node.firstChild;
       
  7113                 if (textNode && textNode.nodeType === 3) {
       
  7114                     exceptionReport.exception = textNode.nodeValue;
       
  7115                 }
       
  7116                 return exceptionReport;
       
  7117             }
       
  7118         };
       
  7119         ProcessIsoCurveResponseReader.read = function (root) {
       
  7120             var response;
       
  7121             if (root.nodeName === 'isochronResult' || root.nodeName === 'isochroneResult' || root.nodeName === 'IsochroneResult') {
       
  7122                 response = ProcessIsoCurveResponseReader.READERS['isochronResult'](root);
       
  7123                 return response;
       
  7124             } else if (root.nodeName === 'ExceptionReport') {
       
  7125                 response = ProcessIsoCurveResponseReader.READERS[root.nodeName](root);
       
  7126                 return response;
       
  7127             } else if (ProcessIsoCurveResponseReader.READERS[root.nodeName]) {
       
  7128                 response = ProcessIsoCurveResponseReader.READERS[root.nodeName](root);
       
  7129                 if (response.status === 'error') {
       
  7130                     var errMsg = MessagesResources.getMessage('SERVICE_RESPONSE_EXCEPTION', response.message);
       
  7131                     throw new ErrSrv({
       
  7132                         message: errMsg,
       
  7133                         type: ErrSrv.TYPE_SRVERR
       
  7134                     });
       
  7135                 }
       
  7136                 return response;
       
  7137             } else {
       
  7138                 throw new ErrSrv({
       
  7139                     message: MessagesResources.getMessage('SERVICE_RESPONSE_ANALYSE', root.nodeName),
       
  7140                     type: ErrSrv.TYPE_UNKERR
       
  7141                 });
       
  7142             }
       
  7143         };
       
  7144         function __getChildValue(node) {
       
  7145             var textNode;
       
  7146             var value = '';
       
  7147             if (node.hasChildNodes()) {
       
  7148                 textNode = node.firstChild;
       
  7149                 if (textNode && textNode.nodeType === 3) {
       
  7150                     value = textNode.nodeValue;
       
  7151                 }
       
  7152             }
       
  7153             return value;
       
  7154         }
       
  7155         return ProcessIsoCurveResponseReader;
       
  7156     }(UtilsLoggerByDefault, FormatsWKT, ExceptionsErrorService, UtilsMessagesResources, ServicesProcessIsoCurveResponseModelProcessIsoCurveResponse);
       
  7157     ServicesProcessIsoCurveResponseProcessIsoCurveResponseFactory = function (Logger, ErrorService, MRes, XML, WKT, ProcessIsoCurveResponseReader, ProcessIsoCurveResponse) {
       
  7158         var ProcessIsoCurveResponseFactory = {
       
  7159             build: function (options) {
       
  7160                 var data = null;
       
  7161                 if (options.response) {
       
  7162                     if (options.rawResponse) {
       
  7163                         data = options.response;
       
  7164                     } else {
       
  7165                         switch (options.outputFormat) {
       
  7166                         case 'xml':
       
  7167                             try {
       
  7168                                 var p = new XML({ reader: ProcessIsoCurveResponseReader });
       
  7169                                 if (typeof options.response === 'string') {
       
  7170                                     p.setXMLString(options.response);
       
  7171                                 } else {
       
  7172                                     p.setXMLDoc(options.response);
       
  7173                                 }
       
  7174                                 data = p.parse();
       
  7175                                 if (!data) {
       
  7176                                     throw new Error(MRes.getMessage('SERVICE_RESPONSE_EXCEPTION_2'));
       
  7177                                 }
       
  7178                             } catch (e) {
       
  7179                                 var message = e.message;
       
  7180                                 message += '\n(raw response service : \'' + options.response + '\')';
       
  7181                                 options.onError.call(options.scope, new ErrorService({
       
  7182                                     message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', message),
       
  7183                                     status: 200,
       
  7184                                     type: ErrorService.TYPE_SRVERR
       
  7185                                 }));
       
  7186                                 return;
       
  7187                             }
       
  7188                             break;
       
  7189                         case 'json':
       
  7190                             var JSONResponse;
       
  7191                             if (typeof options.response === 'string') {
       
  7192                                 JSONResponse = window.JSON.parse(options.response);
       
  7193                             } else {
       
  7194                                 JSONResponse = options.response;
       
  7195                             }
       
  7196                             if (JSONResponse.status === 'OK' || JSONResponse.status === 'ok') {
       
  7197                                 data = new ProcessIsoCurveResponse();
       
  7198                                 if (data) {
       
  7199                                     data.time = JSONResponse.time;
       
  7200                                     data.distance = JSONResponse.distance;
       
  7201                                     data.message = JSONResponse.message;
       
  7202                                     data.id = JSONResponse.id;
       
  7203                                     data.srs = JSONResponse.srs;
       
  7204                                     var onWKTSuccess = function (json) {
       
  7205                                         data.geometry = json;
       
  7206                                     };
       
  7207                                     var onWKTError = function () {
       
  7208                                         options.onError.call(options.scope, new ErrorService({ message: MRes.getMessage('PARAM_FORMAT', 'wktGeometry') }));
       
  7209                                     };
       
  7210                                     if (data.hasOwnProperty('geometry')) {
       
  7211                                         WKT.toJson(JSONResponse.wktGeometry, onWKTSuccess, onWKTError);
       
  7212                                         if (!data.geometry) {
       
  7213                                             return;
       
  7214                                         }
       
  7215                                     }
       
  7216                                     var coords = JSONResponse.location.split(',');
       
  7217                                     if (data.location) {
       
  7218                                         data.location.x = coords[0];
       
  7219                                         data.location.y = coords[1];
       
  7220                                     }
       
  7221                                 } else {
       
  7222                                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_ANALYSE', options.response)));
       
  7223                                     return;
       
  7224                                 }
       
  7225                             } else if (JSONResponse.status === 'ERROR' || JSONResponse.status === 'error') {
       
  7226                                 var mess = JSONResponse.message;
       
  7227                                 mess += '\n(raw response service : \'' + JSONResponse + '\')';
       
  7228                                 options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', mess)));
       
  7229                                 return;
       
  7230                             }
       
  7231                             break;
       
  7232                         default:
       
  7233                             options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_FORMAT', 'json', 'xml')));
       
  7234                             return;
       
  7235                         }
       
  7236                         if (data && data.exceptionReport) {
       
  7237                             options.onError.call(options.scope, new ErrorService({
       
  7238                                 message: MRes.getMessage('SERVICE_RESPONSE_EXCEPTION', data.exceptionReport),
       
  7239                                 type: ErrorService.TYPE_SRVERR,
       
  7240                                 status: 200
       
  7241                             }));
       
  7242                             return;
       
  7243                         }
       
  7244                     }
       
  7245                 } else {
       
  7246                     options.onError.call(options.scope, new ErrorService(MRes.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  7247                     return;
       
  7248                 }
       
  7249                 options.onSuccess.call(options.scope, data);
       
  7250                 return;
       
  7251             }
       
  7252         };
       
  7253         return ProcessIsoCurveResponseFactory;
       
  7254     }(UtilsLoggerByDefault, ExceptionsErrorService, UtilsMessagesResources, FormatsXML, FormatsWKT, ServicesProcessIsoCurveFormatsProcessIsoCurveResponseReader, ServicesProcessIsoCurveResponseModelProcessIsoCurveResponse);
       
  7255     ServicesProcessIsoCurveProcessIsoCurve = function (Logger, _, ErrorService, CommonService, DefaultUrlService, ProcessIsoCurveRequest, ProcessIsoCurveResponseFactory) {
       
  7256         function ProcessIsoCurve(options) {
       
  7257             if (!(this instanceof ProcessIsoCurve)) {
       
  7258                 throw new TypeError(_.getMessage('CLASS_CONSTRUCTOR', 'ProcessIsoCurve'));
       
  7259             }
       
  7260             this.CLASSNAME = 'ProcessIsoCurve';
       
  7261             CommonService.apply(this, arguments);
       
  7262             if (!options.position) {
       
  7263                 throw new Error(_.getMessage('PARAM_MISSING', 'position'));
       
  7264             }
       
  7265             if (options.position.x == null) {
       
  7266                 throw new Error(_.getMessage('PARAM_MISSING', 'position.x'));
       
  7267             }
       
  7268             if (options.position.y == null) {
       
  7269                 throw new Error(_.getMessage('PARAM_MISSING', 'position.y'));
       
  7270             }
       
  7271             if (!options.time && !options.distance) {
       
  7272                 throw new Error('Parameter(s) \'distance\' missing. Parameter time to calculate an isochrone, parameter distance for an isodistance');
       
  7273             }
       
  7274             if (!options.time && options.distance) {
       
  7275                 this.options.method = 'distance';
       
  7276                 if (this.options.time) {
       
  7277                     delete this.options.time;
       
  7278                 }
       
  7279             }
       
  7280             if (options.time && !options.distance) {
       
  7281                 this.options.method = 'time';
       
  7282                 if (this.options.distance) {
       
  7283                     delete this.options.distance;
       
  7284                 }
       
  7285             }
       
  7286             this.options.method = this.options.method || 'time';
       
  7287             this.options.exclusions = options.exclusions || null;
       
  7288             this.options.graph = options.graph || 'Voiture';
       
  7289             this.options.reverse = options.reverse || false;
       
  7290             this.options.smoothing = options.smoothing || false;
       
  7291             this.options.holes = options.holes || false;
       
  7292             this.options.srs = options.srs || 'EPSG:4326';
       
  7293             this.options.outputFormat = typeof options.outputFormat == 'string' ? options.outputFormat.toLowerCase() : 'json';
       
  7294             if (!this.options.serverUrl) {
       
  7295                 var lstUrlByDefault = DefaultUrlService.ProcessIsoCurve.url(this.options.apiKey);
       
  7296                 var urlFound = lstUrlByDefault['iso' + '-' + this.options.outputFormat];
       
  7297                 if (!urlFound) {
       
  7298                     throw new Error('Url by default not found !');
       
  7299                 }
       
  7300                 this.options.serverUrl = urlFound;
       
  7301             }
       
  7302             var idx = this.options.serverUrl.lastIndexOf('.');
       
  7303             if (idx !== -1) {
       
  7304                 var extension = this.options.serverUrl.substring(idx + 1);
       
  7305                 if (extension && extension.length < 5) {
       
  7306                     switch (extension.toLowerCase()) {
       
  7307                     case 'json':
       
  7308                     case 'xml':
       
  7309                         this.options.outputFormat = extension.toLowerCase();
       
  7310                         break;
       
  7311                     default:
       
  7312                         throw new Error('type of service : unknown or unsupported (json or xml) !');
       
  7313                     }
       
  7314                 }
       
  7315             }
       
  7316         }
       
  7317         ProcessIsoCurve.prototype = Object.create(CommonService.prototype, {});
       
  7318         ProcessIsoCurve.prototype.constructor = ProcessIsoCurve;
       
  7319         ProcessIsoCurve.prototype.buildRequest = function (error, success) {
       
  7320             try {
       
  7321                 var oIsoCurve = new ProcessIsoCurveRequest(this.options);
       
  7322                 if (!oIsoCurve.processRequestString()) {
       
  7323                     throw new Error(_.getMessage('SERVICE_REQUEST_BUILD'));
       
  7324                 }
       
  7325                 this.request = oIsoCurve.requestString;
       
  7326             } catch (e) {
       
  7327                 error.call(this, new ErrorService(e.message));
       
  7328                 return;
       
  7329             }
       
  7330             success.call(this, this.request);
       
  7331         };
       
  7332         ProcessIsoCurve.prototype.analyzeResponse = function (onError, onSuccess) {
       
  7333             if (this.response) {
       
  7334                 var options = {
       
  7335                     response: this.response,
       
  7336                     outputFormat: this.options.outputFormat,
       
  7337                     rawResponse: this.options.rawResponse,
       
  7338                     onSuccess: onSuccess,
       
  7339                     onError: onError,
       
  7340                     scope: this
       
  7341                 };
       
  7342                 ProcessIsoCurveResponseFactory.build(options);
       
  7343             } else {
       
  7344                 onError.call(this, new ErrorService(_.getMessage('SERVICE_RESPONSE_EMPTY')));
       
  7345             }
       
  7346         };
       
  7347         return ProcessIsoCurve;
       
  7348     }(UtilsLoggerByDefault, UtilsMessagesResources, ExceptionsErrorService, ServicesCommonService, ServicesDefaultUrlService, ServicesProcessIsoCurveRequestProcessIsoCurveRequest, ServicesProcessIsoCurveResponseProcessIsoCurveResponseFactory);
       
  7349     ServicesServices = function (Alti, AutoConf, Geocode, ReverseGeocode, AutoComplete, Route, ProcessIsoCurve) {
       
  7350         var Services = {
       
  7351             getConfig: function (options) {
       
  7352                 var autoconfService = new AutoConf(options);
       
  7353                 autoconfService.call();
       
  7354             },
       
  7355             getAltitude: function (options) {
       
  7356                 var altiService = new Alti(options);
       
  7357                 altiService.call();
       
  7358             },
       
  7359             geocode: function (options) {
       
  7360                 var geocodeService = new Geocode(options);
       
  7361                 geocodeService.call();
       
  7362             },
       
  7363             reverseGeocode: function (options) {
       
  7364                 var reverseGeocodeService = new ReverseGeocode(options);
       
  7365                 reverseGeocodeService.call();
       
  7366             },
       
  7367             autoComplete: function (options) {
       
  7368                 var autoCompleteService = new AutoComplete(options);
       
  7369                 autoCompleteService.call();
       
  7370             },
       
  7371             route: function (options) {
       
  7372                 var routeService = new Route(options);
       
  7373                 routeService.call();
       
  7374             },
       
  7375             isoCurve: function (options) {
       
  7376                 var processIsoCurveService = new ProcessIsoCurve(options);
       
  7377                 processIsoCurveService.call();
       
  7378             }
       
  7379         };
       
  7380         var point = {};
       
  7381         var circle = {};
       
  7382         var bbox = {};
       
  7383         return Services;
       
  7384     }(ServicesAltiAlti, ServicesAutoConfAutoConf, ServicesGeocodeGeocode, ServicesGeocodeReverseGeocode, ServicesAutoCompleteAutoComplete, ServicesRouteRoute, ServicesProcessIsoCurveProcessIsoCurve);
       
  7385     Gp = function (XHR, Services, AltiResponse, Elevation, AutoCompleteResponse, SuggestedLocation, GetConfigResponse, Constraint, Format, Layer, Legend, Metadata, Originator, Service, Style, Territory, Thematic, TM, TMLimit, TMS, GeocodeResponse, GeocodedLocation, DirectGeocodedLocation, ReverseGeocodedLocation, IsoCurveResponse, RouteResponse, RouteInstruction, Error, Helper) {
       
  7386         var scope = typeof window !== 'undefined' ? window : {};
       
  7387         var Gp = scope.Gp || {
       
  7388             servicesVersion: '1.0.0-beta3',
       
  7389             servicesDate: '2016-12-01',
       
  7390             extend: function (strNS, value) {
       
  7391                 var parts = strNS.split('.');
       
  7392                 var parent = this;
       
  7393                 var pl;
       
  7394                 pl = parts.length;
       
  7395                 for (var i = 0; i < pl; i++) {
       
  7396                     if (typeof parent[parts[i]] === 'undefined') {
       
  7397                         parent[parts[i]] = {};
       
  7398                     }
       
  7399                     var n = pl - 1;
       
  7400                     if (i === n) {
       
  7401                         parent[parts[i]] = value;
       
  7402                     }
       
  7403                     parent = parent[parts[i]];
       
  7404                 }
       
  7405                 return this;
       
  7406             }
       
  7407         };
       
  7408         Gp.extend('Protocols', {});
       
  7409         Gp.extend('Protocols.XHR', XHR);
       
  7410         Gp.extend('Services', Services);
       
  7411         Gp.extend('Services.AltiResponse', AltiResponse);
       
  7412         Gp.extend('Services.Alti.Elevation', Elevation);
       
  7413         Gp.extend('Services.AutoCompleteResponse', AutoCompleteResponse);
       
  7414         Gp.extend('Services.AutoComplete.SuggestedLocation', SuggestedLocation);
       
  7415         Gp.extend('Services.GetConfigResponse', GetConfigResponse);
       
  7416         Gp.extend('Services.Config.Constraint', Constraint);
       
  7417         Gp.extend('Services.Config.Format', Format);
       
  7418         Gp.extend('Services.Config.Layer', Layer);
       
  7419         Gp.extend('Services.Config.Legend', Legend);
       
  7420         Gp.extend('Services.Config.Metadata', Metadata);
       
  7421         Gp.extend('Services.Config.Originator', Originator);
       
  7422         Gp.extend('Services.Config.Service', Service);
       
  7423         Gp.extend('Services.Config.Style', Style);
       
  7424         Gp.extend('Services.Config.Territory', Territory);
       
  7425         Gp.extend('Services.Config.Thematic', SuggestedLocation);
       
  7426         Gp.extend('Services.Config.TileMatrix', TM);
       
  7427         Gp.extend('Services.Config.TileMatrixLimit', TMLimit);
       
  7428         Gp.extend('Services.Config.TileMatrixSet', TMS);
       
  7429         Gp.extend('Services.GeocodeResponse', GeocodeResponse);
       
  7430         Gp.extend('Services.Geocode.GeocodedLocation', GeocodedLocation);
       
  7431         Gp.extend('Services.Geocode.DirectGeocodedLocation', DirectGeocodedLocation);
       
  7432         Gp.extend('Services.Geocode.ReverseGeocodedLocation', ReverseGeocodedLocation);
       
  7433         Gp.extend('Services.IsoCurveResponse', IsoCurveResponse);
       
  7434         Gp.extend('Services.RouteResponse', RouteResponse);
       
  7435         Gp.extend('Services.Route.RouteInstruction', RouteInstruction);
       
  7436         Gp.extend('Error', Error);
       
  7437         Gp.extend('Helper', Helper);
       
  7438         scope.Gp = Gp;
       
  7439         return scope.Gp;
       
  7440     }(ProtocolsXHR, ServicesServices, ServicesAltiResponseModelAltiResponse, ServicesAltiResponseModelElevation, ServicesAutoCompleteResponseModelAutoCompleteResponse, ServicesAutoCompleteResponseModelSuggestedLocation, ServicesAutoConfResponseModelAutoConfResponse, ServicesAutoConfResponseModelConstraint, ServicesAutoConfResponseModelFormat, ServicesAutoConfResponseModelLayer, ServicesAutoConfResponseModelLegend, ServicesAutoConfResponseModelMetadata, ServicesAutoConfResponseModelOriginator, ServicesAutoConfResponseModelService, ServicesAutoConfResponseModelStyle, ServicesAutoConfResponseModelTerritory, ServicesAutoConfResponseModelThematic, ServicesAutoConfResponseModelTileMatrix, ServicesAutoConfResponseModelTileMatrixLimit, ServicesAutoConfResponseModelTileMatrixSet, ServicesGeocodeResponseModelGeocodeResponse, ServicesGeocodeResponseModelGeocodedLocation, ServicesGeocodeResponseModelDirectGeocodedLocation, ServicesGeocodeResponseModelReverseGeocodedLocation, ServicesProcessIsoCurveResponseModelProcessIsoCurveResponse, ServicesRouteResponseModelRouteResponse, ServicesRouteResponseModelRouteInstruction, ExceptionsErrorService, UtilsHelper);
       
  7441     return Gp;
       
  7442 }));
       
  7443 CommonUtilsAutoLoadConfig = function (Gp) {
       
  7444     (function () {
       
  7445         var scripts = document.getElementsByTagName('script');
       
  7446         var key = scripts[scripts.length - 1].getAttribute('data-key');
       
  7447         if (key) {
       
  7448             var splitKeys = key.split(/;|,|\|/);
       
  7449             if (key && splitKeys.length > 1) {
       
  7450                 var keys = [];
       
  7451                 for (var i = 0; i < splitKeys.length; i++) {
       
  7452                     keys.push(splitKeys[i]);
       
  7453                 }
       
  7454                 key = keys;
       
  7455             }
       
  7456         }
       
  7457         var url = scripts[scripts.length - 1].getAttribute('data-url');
       
  7458         var timeout = scripts[scripts.length - 1].getAttribute('data-timeout');
       
  7459         var success = function () {
       
  7460         };
       
  7461         var error = function (e) {
       
  7462             throw new Error('Configuration load failed : ' + e.message);
       
  7463         };
       
  7464         if (!key && !url) {
       
  7465             return;
       
  7466         }
       
  7467         var options = {
       
  7468             apiKey: key,
       
  7469             onSuccess: success,
       
  7470             onFailure: error
       
  7471         };
       
  7472         if (url) {
       
  7473             options.serverUrl = url;
       
  7474             options.callbackSuffix = '';
       
  7475         }
       
  7476         if (timeout) {
       
  7477             options.timeOut = timeout;
       
  7478         }
       
  7479         if (!Gp.Config) {
       
  7480             Gp.Services.getConfig(options);
       
  7481         }
       
  7482     }());
       
  7483 }(gp);
       
  7484 (function (window, document, undefined) {
       
  7485     L.drawVersion = '0.3.0-dev';
       
  7486     L.drawLocal = {
       
  7487         draw: {
       
  7488             toolbar: {
       
  7489                 actions: {
       
  7490                     title: 'Cancel drawing',
       
  7491                     text: 'Cancel'
       
  7492                 },
       
  7493                 finish: {
       
  7494                     title: 'Finish drawing',
       
  7495                     text: 'Finish'
       
  7496                 },
       
  7497                 undo: {
       
  7498                     title: 'Delete last point drawn',
       
  7499                     text: 'Delete last point'
       
  7500                 },
       
  7501                 buttons: {
       
  7502                     polyline: 'Draw a polyline',
       
  7503                     polygon: 'Draw a polygon',
       
  7504                     rectangle: 'Draw a rectangle',
       
  7505                     circle: 'Draw a circle',
       
  7506                     marker: 'Draw a marker'
       
  7507                 }
       
  7508             },
       
  7509             handlers: {
       
  7510                 circle: {
       
  7511                     tooltip: { start: 'Click and drag to draw circle.' },
       
  7512                     radius: 'Radius'
       
  7513                 },
       
  7514                 marker: { tooltip: { start: 'Click map to place marker.' } },
       
  7515                 polygon: {
       
  7516                     tooltip: {
       
  7517                         start: 'Click to start drawing shape.',
       
  7518                         cont: 'Click to continue drawing shape.',
       
  7519                         end: 'Click first point to close this shape.'
       
  7520                     }
       
  7521                 },
       
  7522                 polyline: {
       
  7523                     error: '<strong>Error:</strong> shape edges cannot cross!',
       
  7524                     tooltip: {
       
  7525                         start: 'Click to start drawing line.',
       
  7526                         cont: 'Click to continue drawing line.',
       
  7527                         end: 'Click last point to finish line.'
       
  7528                     }
       
  7529                 },
       
  7530                 rectangle: { tooltip: { start: 'Click and drag to draw rectangle.' } },
       
  7531                 simpleshape: { tooltip: { end: 'Release mouse to finish drawing.' } }
       
  7532             }
       
  7533         },
       
  7534         edit: {
       
  7535             toolbar: {
       
  7536                 actions: {
       
  7537                     save: {
       
  7538                         title: 'Save changes.',
       
  7539                         text: 'Save'
       
  7540                     },
       
  7541                     cancel: {
       
  7542                         title: 'Cancel editing, discards all changes.',
       
  7543                         text: 'Cancel'
       
  7544                     }
       
  7545                 },
       
  7546                 buttons: {
       
  7547                     edit: 'Edit layers.',
       
  7548                     editDisabled: 'No layers to edit.',
       
  7549                     remove: 'Delete layers.',
       
  7550                     removeDisabled: 'No layers to delete.'
       
  7551                 }
       
  7552             },
       
  7553             handlers: {
       
  7554                 edit: {
       
  7555                     tooltip: {
       
  7556                         text: 'Drag handles, or marker to edit feature.',
       
  7557                         subtext: 'Click cancel to undo changes.'
       
  7558                     }
       
  7559                 },
       
  7560                 remove: { tooltip: { text: 'Click on a feature to remove' } }
       
  7561             }
       
  7562         }
       
  7563     };
       
  7564     L.Draw = {};
       
  7565     L.Draw.Feature = L.Handler.extend({
       
  7566         includes: L.Mixin.Events,
       
  7567         initialize: function (map, options) {
       
  7568             this._map = map;
       
  7569             this._container = map._container;
       
  7570             this._overlayPane = map._panes.overlayPane;
       
  7571             this._popupPane = map._panes.popupPane;
       
  7572             if (options && options.shapeOptions) {
       
  7573                 options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);
       
  7574             }
       
  7575             L.setOptions(this, options);
       
  7576         },
       
  7577         enable: function () {
       
  7578             if (this._enabled) {
       
  7579                 return;
       
  7580             }
       
  7581             L.Handler.prototype.enable.call(this);
       
  7582             this.fire('enabled', { handler: this.type });
       
  7583             this._map.fire('draw:drawstart', { layerType: this.type });
       
  7584         },
       
  7585         disable: function () {
       
  7586             if (!this._enabled) {
       
  7587                 return;
       
  7588             }
       
  7589             L.Handler.prototype.disable.call(this);
       
  7590             this._map.fire('draw:drawstop', { layerType: this.type });
       
  7591             this.fire('disabled', { handler: this.type });
       
  7592         },
       
  7593         addHooks: function () {
       
  7594             var map = this._map;
       
  7595             if (map) {
       
  7596                 L.DomUtil.disableTextSelection();
       
  7597                 map.getContainer().focus();
       
  7598                 this._tooltip = new L.Tooltip(this._map);
       
  7599                 L.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);
       
  7600             }
       
  7601         },
       
  7602         removeHooks: function () {
       
  7603             if (this._map) {
       
  7604                 L.DomUtil.enableTextSelection();
       
  7605                 this._tooltip.dispose();
       
  7606                 this._tooltip = null;
       
  7607                 L.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);
       
  7608             }
       
  7609         },
       
  7610         setOptions: function (options) {
       
  7611             L.setOptions(this, options);
       
  7612         },
       
  7613         _fireCreatedEvent: function (layer) {
       
  7614             this._map.fire('draw:created', {
       
  7615                 layer: layer,
       
  7616                 layerType: this.type
       
  7617             });
       
  7618         },
       
  7619         _cancelDrawing: function (e) {
       
  7620             if (e.keyCode === 27) {
       
  7621                 this.disable();
       
  7622             }
       
  7623         }
       
  7624     });
       
  7625     L.Draw.Polyline = L.Draw.Feature.extend({
       
  7626         statics: { TYPE: 'polyline' },
       
  7627         Poly: L.Polyline,
       
  7628         options: {
       
  7629             allowIntersection: true,
       
  7630             repeatMode: false,
       
  7631             drawError: {
       
  7632                 color: '#b00b00',
       
  7633                 timeout: 2500
       
  7634             },
       
  7635             icon: new L.DivIcon({
       
  7636                 iconSize: new L.Point(8, 8),
       
  7637                 className: 'leaflet-div-icon leaflet-editing-icon'
       
  7638             }),
       
  7639             touchIcon: new L.DivIcon({
       
  7640                 iconSize: new L.Point(20, 20),
       
  7641                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
       
  7642             }),
       
  7643             guidelineDistance: 20,
       
  7644             maxGuideLineLength: 4000,
       
  7645             shapeOptions: {
       
  7646                 stroke: true,
       
  7647                 color: '#f06eaa',
       
  7648                 weight: 4,
       
  7649                 opacity: 0.5,
       
  7650                 fill: false,
       
  7651                 clickable: true
       
  7652             },
       
  7653             metric: true,
       
  7654             feet: true,
       
  7655             showLength: true,
       
  7656             zIndexOffset: 2000
       
  7657         },
       
  7658         initialize: function (map, options) {
       
  7659             if (L.Browser.touch) {
       
  7660                 this.options.icon = this.options.touchIcon;
       
  7661             }
       
  7662             this.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;
       
  7663             if (options && options.drawError) {
       
  7664                 options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
       
  7665             }
       
  7666             this.type = L.Draw.Polyline.TYPE;
       
  7667             L.Draw.Feature.prototype.initialize.call(this, map, options);
       
  7668         },
       
  7669         addHooks: function () {
       
  7670             L.Draw.Feature.prototype.addHooks.call(this);
       
  7671             if (this._map) {
       
  7672                 this._markers = [];
       
  7673                 this._markerGroup = new L.LayerGroup();
       
  7674                 this._map.addLayer(this._markerGroup);
       
  7675                 this._poly = new L.Polyline([], this.options.shapeOptions);
       
  7676                 this._tooltip.updateContent(this._getTooltipText());
       
  7677                 if (!this._mouseMarker) {
       
  7678                     this._mouseMarker = L.marker(this._map.getCenter(), {
       
  7679                         icon: L.divIcon({
       
  7680                             className: 'leaflet-mouse-marker',
       
  7681                             iconAnchor: [
       
  7682                                 20,
       
  7683                                 20
       
  7684                             ],
       
  7685                             iconSize: [
       
  7686                                 40,
       
  7687                                 40
       
  7688                             ]
       
  7689                         }),
       
  7690                         opacity: 0,
       
  7691                         zIndexOffset: this.options.zIndexOffset
       
  7692                     });
       
  7693                 }
       
  7694                 this._mouseMarker.on('mousedown', this._onMouseDown, this).on('mouseout', this._onMouseOut, this).on('mouseup', this._onMouseUp, this).on('mousemove', this._onMouseMove, this).addTo(this._map);
       
  7695                 this._map.on('mouseup', this._onMouseUp, this).on('mousemove', this._onMouseMove, this).on('zoomlevelschange', this._onZoomEnd, this).on('click', this._onTouch, this).on('zoomend', this._onZoomEnd, this);
       
  7696             }
       
  7697         },
       
  7698         removeHooks: function () {
       
  7699             L.Draw.Feature.prototype.removeHooks.call(this);
       
  7700             this._clearHideErrorTimeout();
       
  7701             this._cleanUpShape();
       
  7702             this._map.removeLayer(this._markerGroup);
       
  7703             delete this._markerGroup;
       
  7704             delete this._markers;
       
  7705             this._map.removeLayer(this._poly);
       
  7706             delete this._poly;
       
  7707             this._mouseMarker.off('mousedown', this._onMouseDown, this).off('mouseout', this._onMouseOut, this).off('mouseup', this._onMouseUp, this).off('mousemove', this._onMouseMove, this);
       
  7708             this._map.removeLayer(this._mouseMarker);
       
  7709             delete this._mouseMarker;
       
  7710             this._clearGuides();
       
  7711             this._map.off('mouseup', this._onMouseUp, this).off('mousemove', this._onMouseMove, this).off('mouseup', this._onMouseUp, this).off('zoomend', this._onZoomEnd, this).off('click', this._onTouch, this);
       
  7712         },
       
  7713         deleteLastVertex: function () {
       
  7714             if (this._markers.length <= 1) {
       
  7715                 return;
       
  7716             }
       
  7717             var lastMarker = this._markers.pop(), poly = this._poly, latlng = this._poly.spliceLatLngs(poly.getLatLngs().length - 1, 1)[0];
       
  7718             this._markerGroup.removeLayer(lastMarker);
       
  7719             if (poly.getLatLngs().length < 2) {
       
  7720                 this._map.removeLayer(poly);
       
  7721             }
       
  7722             this._vertexChanged(latlng, false);
       
  7723         },
       
  7724         addVertex: function (latlng) {
       
  7725             var markersLength = this._markers.length;
       
  7726             if (markersLength > 0 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {
       
  7727                 this._showErrorTooltip();
       
  7728                 return;
       
  7729             } else if (this._errorShown) {
       
  7730                 this._hideErrorTooltip();
       
  7731             }
       
  7732             this._markers.push(this._createMarker(latlng));
       
  7733             this._poly.addLatLng(latlng);
       
  7734             if (this._poly.getLatLngs().length === 2) {
       
  7735                 this._map.addLayer(this._poly);
       
  7736             }
       
  7737             this._vertexChanged(latlng, true);
       
  7738         },
       
  7739         completeShape: function () {
       
  7740             if (this._markers.length <= 1) {
       
  7741                 return;
       
  7742             }
       
  7743             this._fireCreatedEvent();
       
  7744             this.disable();
       
  7745             if (this.options.repeatMode) {
       
  7746                 this.enable();
       
  7747             }
       
  7748         },
       
  7749         _finishShape: function () {
       
  7750             var intersects = this._poly.newLatLngIntersects(this._poly.getLatLngs()[0], true);
       
  7751             if (!this.options.allowIntersection && intersects || !this._shapeIsValid()) {
       
  7752                 this._showErrorTooltip();
       
  7753                 return;
       
  7754             }
       
  7755             this._fireCreatedEvent();
       
  7756             this.disable();
       
  7757             if (this.options.repeatMode) {
       
  7758                 this.enable();
       
  7759             }
       
  7760         },
       
  7761         _shapeIsValid: function () {
       
  7762             return true;
       
  7763         },
       
  7764         _onZoomEnd: function () {
       
  7765             this._updateGuide();
       
  7766         },
       
  7767         _onMouseMove: function (e) {
       
  7768             var newPos = this._map.mouseEventToLayerPoint(e.originalEvent);
       
  7769             var latlng = this._map.layerPointToLatLng(newPos);
       
  7770             this._currentLatLng = latlng;
       
  7771             this._updateTooltip(latlng);
       
  7772             this._updateGuide(newPos);
       
  7773             this._mouseMarker.setLatLng(latlng);
       
  7774             L.DomEvent.preventDefault(e.originalEvent);
       
  7775         },
       
  7776         _vertexChanged: function (latlng, added) {
       
  7777             this._map.fire('draw:drawvertex', { layers: this._markerGroup });
       
  7778             this._updateFinishHandler();
       
  7779             this._updateRunningMeasure(latlng, added);
       
  7780             this._clearGuides();
       
  7781             this._updateTooltip();
       
  7782         },
       
  7783         _onMouseDown: function (e) {
       
  7784             var originalEvent = e.originalEvent;
       
  7785             this._mouseDownOrigin = L.point(originalEvent.clientX, originalEvent.clientY);
       
  7786         },
       
  7787         _onMouseUp: function (e) {
       
  7788             if (this._mouseDownOrigin) {
       
  7789                 var distance = L.point(e.originalEvent.clientX, e.originalEvent.clientY).distanceTo(this._mouseDownOrigin);
       
  7790                 if (Math.abs(distance) < 9 * (window.devicePixelRatio || 1)) {
       
  7791                     this.addVertex(e.latlng);
       
  7792                 }
       
  7793             }
       
  7794             this._mouseDownOrigin = null;
       
  7795         },
       
  7796         _onTouch: function (e) {
       
  7797             if (L.Browser.touch) {
       
  7798                 this._onMouseDown(e);
       
  7799                 this._onMouseUp(e);
       
  7800             }
       
  7801         },
       
  7802         _onMouseOut: function () {
       
  7803             if (this._tooltip) {
       
  7804                 this._tooltip._onMouseOut.call(this._tooltip);
       
  7805             }
       
  7806         },
       
  7807         _updateFinishHandler: function () {
       
  7808             var markerCount = this._markers.length;
       
  7809             if (markerCount > 1) {
       
  7810                 this._markers[markerCount - 1].on('click', this._finishShape, this);
       
  7811             }
       
  7812             if (markerCount > 2) {
       
  7813                 this._markers[markerCount - 2].off('click', this._finishShape, this);
       
  7814             }
       
  7815         },
       
  7816         _createMarker: function (latlng) {
       
  7817             var marker = new L.Marker(latlng, {
       
  7818                 icon: this.options.icon,
       
  7819                 zIndexOffset: this.options.zIndexOffset * 2
       
  7820             });
       
  7821             this._markerGroup.addLayer(marker);
       
  7822             return marker;
       
  7823         },
       
  7824         _updateGuide: function (newPos) {
       
  7825             var markerCount = this._markers.length;
       
  7826             if (markerCount > 0) {
       
  7827                 newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
       
  7828                 this._clearGuides();
       
  7829                 this._drawGuide(this._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()), newPos);
       
  7830             }
       
  7831         },
       
  7832         _updateTooltip: function (latLng) {
       
  7833             var text = this._getTooltipText();
       
  7834             if (latLng) {
       
  7835                 this._tooltip.updatePosition(latLng);
       
  7836             }
       
  7837             if (!this._errorShown) {
       
  7838                 this._tooltip.updateContent(text);
       
  7839             }
       
  7840         },
       
  7841         _drawGuide: function (pointA, pointB) {
       
  7842             var length = Math.floor(Math.sqrt(Math.pow(pointB.x - pointA.x, 2) + Math.pow(pointB.y - pointA.y, 2))), guidelineDistance = this.options.guidelineDistance, maxGuideLineLength = this.options.maxGuideLineLength, i = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance, fraction, dashPoint, dash;
       
  7843             if (!this._guidesContainer) {
       
  7844                 this._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);
       
  7845             }
       
  7846             for (; i < length; i += this.options.guidelineDistance) {
       
  7847                 fraction = i / length;
       
  7848                 dashPoint = {
       
  7849                     x: Math.floor(pointA.x * (1 - fraction) + fraction * pointB.x),
       
  7850                     y: Math.floor(pointA.y * (1 - fraction) + fraction * pointB.y)
       
  7851                 };
       
  7852                 dash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);
       
  7853                 dash.style.backgroundColor = !this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;
       
  7854                 L.DomUtil.setPosition(dash, dashPoint);
       
  7855             }
       
  7856         },
       
  7857         _updateGuideColor: function (color) {
       
  7858             if (this._guidesContainer) {
       
  7859                 for (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {
       
  7860                     this._guidesContainer.childNodes[i].style.backgroundColor = color;
       
  7861                 }
       
  7862             }
       
  7863         },
       
  7864         _clearGuides: function () {
       
  7865             if (this._guidesContainer) {
       
  7866                 while (this._guidesContainer.firstChild) {
       
  7867                     this._guidesContainer.removeChild(this._guidesContainer.firstChild);
       
  7868                 }
       
  7869             }
       
  7870         },
       
  7871         _getTooltipText: function () {
       
  7872             var showLength = this.options.showLength, labelText, distanceStr;
       
  7873             if (this._markers.length === 0) {
       
  7874                 labelText = { text: L.drawLocal.draw.handlers.polyline.tooltip.start };
       
  7875             } else {
       
  7876                 distanceStr = showLength ? this._getMeasurementString() : '';
       
  7877                 if (this._markers.length === 1) {
       
  7878                     labelText = {
       
  7879                         text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
       
  7880                         subtext: distanceStr
       
  7881                     };
       
  7882                 } else {
       
  7883                     labelText = {
       
  7884                         text: L.drawLocal.draw.handlers.polyline.tooltip.end,
       
  7885                         subtext: distanceStr
       
  7886                     };
       
  7887                 }
       
  7888             }
       
  7889             return labelText;
       
  7890         },
       
  7891         _updateRunningMeasure: function (latlng, added) {
       
  7892             var markersLength = this._markers.length, previousMarkerIndex, distance;
       
  7893             if (this._markers.length === 1) {
       
  7894                 this._measurementRunningTotal = 0;
       
  7895             } else {
       
  7896                 previousMarkerIndex = markersLength - (added ? 2 : 1);
       
  7897                 distance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng());
       
  7898                 this._measurementRunningTotal += distance * (added ? 1 : -1);
       
  7899             }
       
  7900         },
       
  7901         _getMeasurementString: function () {
       
  7902             var currentLatLng = this._currentLatLng, previousLatLng = this._markers[this._markers.length - 1].getLatLng(), distance;
       
  7903             distance = this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng);
       
  7904             return L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet);
       
  7905         },
       
  7906         _showErrorTooltip: function () {
       
  7907             this._errorShown = true;
       
  7908             this._tooltip.showAsError().updateContent({ text: this.options.drawError.message });
       
  7909             this._updateGuideColor(this.options.drawError.color);
       
  7910             this._poly.setStyle({ color: this.options.drawError.color });
       
  7911             this._clearHideErrorTimeout();
       
  7912             this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);
       
  7913         },
       
  7914         _hideErrorTooltip: function () {
       
  7915             this._errorShown = false;
       
  7916             this._clearHideErrorTimeout();
       
  7917             this._tooltip.removeError().updateContent(this._getTooltipText());
       
  7918             this._updateGuideColor(this.options.shapeOptions.color);
       
  7919             this._poly.setStyle({ color: this.options.shapeOptions.color });
       
  7920         },
       
  7921         _clearHideErrorTimeout: function () {
       
  7922             if (this._hideErrorTimeout) {
       
  7923                 clearTimeout(this._hideErrorTimeout);
       
  7924                 this._hideErrorTimeout = null;
       
  7925             }
       
  7926         },
       
  7927         _cleanUpShape: function () {
       
  7928             if (this._markers.length > 1) {
       
  7929                 this._markers[this._markers.length - 1].off('click', this._finishShape, this);
       
  7930             }
       
  7931         },
       
  7932         _fireCreatedEvent: function () {
       
  7933             var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);
       
  7934             L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);
       
  7935         }
       
  7936     });
       
  7937     L.Draw.Polygon = L.Draw.Polyline.extend({
       
  7938         statics: { TYPE: 'polygon' },
       
  7939         Poly: L.Polygon,
       
  7940         options: {
       
  7941             showArea: false,
       
  7942             shapeOptions: {
       
  7943                 stroke: true,
       
  7944                 color: '#f06eaa',
       
  7945                 weight: 4,
       
  7946                 opacity: 0.5,
       
  7947                 fill: true,
       
  7948                 fillColor: null,
       
  7949                 fillOpacity: 0.2,
       
  7950                 clickable: true
       
  7951             }
       
  7952         },
       
  7953         initialize: function (map, options) {
       
  7954             L.Draw.Polyline.prototype.initialize.call(this, map, options);
       
  7955             this.type = L.Draw.Polygon.TYPE;
       
  7956         },
       
  7957         _updateFinishHandler: function () {
       
  7958             var markerCount = this._markers.length;
       
  7959             if (markerCount === 1) {
       
  7960                 this._markers[0].on('click', this._finishShape, this);
       
  7961             }
       
  7962             if (markerCount > 2) {
       
  7963                 this._markers[markerCount - 1].on('dblclick', this._finishShape, this);
       
  7964                 if (markerCount > 3) {
       
  7965                     this._markers[markerCount - 2].off('dblclick', this._finishShape, this);
       
  7966                 }
       
  7967             }
       
  7968         },
       
  7969         _getTooltipText: function () {
       
  7970             var text, subtext;
       
  7971             if (this._markers.length === 0) {
       
  7972                 text = L.drawLocal.draw.handlers.polygon.tooltip.start;
       
  7973             } else if (this._markers.length < 3) {
       
  7974                 text = L.drawLocal.draw.handlers.polygon.tooltip.cont;
       
  7975             } else {
       
  7976                 text = L.drawLocal.draw.handlers.polygon.tooltip.end;
       
  7977                 subtext = this._getMeasurementString();
       
  7978             }
       
  7979             return {
       
  7980                 text: text,
       
  7981                 subtext: subtext
       
  7982             };
       
  7983         },
       
  7984         _getMeasurementString: function () {
       
  7985             var area = this._area;
       
  7986             if (!area) {
       
  7987                 return null;
       
  7988             }
       
  7989             return L.GeometryUtil.readableArea(area, this.options.metric);
       
  7990         },
       
  7991         _shapeIsValid: function () {
       
  7992             return this._markers.length >= 3;
       
  7993         },
       
  7994         _vertexChanged: function (latlng, added) {
       
  7995             var latLngs;
       
  7996             if (!this.options.allowIntersection && this.options.showArea) {
       
  7997                 latLngs = this._poly.getLatLngs();
       
  7998                 this._area = L.GeometryUtil.geodesicArea(latLngs);
       
  7999             }
       
  8000             L.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);
       
  8001         },
       
  8002         _cleanUpShape: function () {
       
  8003             var markerCount = this._markers.length;
       
  8004             if (markerCount > 0) {
       
  8005                 this._markers[0].off('click', this._finishShape, this);
       
  8006                 if (markerCount > 2) {
       
  8007                     this._markers[markerCount - 1].off('dblclick', this._finishShape, this);
       
  8008                 }
       
  8009             }
       
  8010         }
       
  8011     });
       
  8012     L.SimpleShape = {};
       
  8013     L.Draw.SimpleShape = L.Draw.Feature.extend({
       
  8014         options: { repeatMode: false },
       
  8015         initialize: function (map, options) {
       
  8016             this._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;
       
  8017             L.Draw.Feature.prototype.initialize.call(this, map, options);
       
  8018         },
       
  8019         addHooks: function () {
       
  8020             L.Draw.Feature.prototype.addHooks.call(this);
       
  8021             if (this._map) {
       
  8022                 this._mapDraggable = this._map.dragging.enabled();
       
  8023                 if (this._mapDraggable) {
       
  8024                     this._map.dragging.disable();
       
  8025                 }
       
  8026                 this._container.style.cursor = 'crosshair';
       
  8027                 this._tooltip.updateContent({ text: this._initialLabelText });
       
  8028                 this._map.on('mousedown', this._onMouseDown, this).on('mousemove', this._onMouseMove, this).on('touchstart', this._onMouseDown, this).on('touchmove', this._onMouseMove, this);
       
  8029             }
       
  8030         },
       
  8031         removeHooks: function () {
       
  8032             L.Draw.Feature.prototype.removeHooks.call(this);
       
  8033             if (this._map) {
       
  8034                 if (this._mapDraggable) {
       
  8035                     this._map.dragging.enable();
       
  8036                 }
       
  8037                 this._container.style.cursor = '';
       
  8038                 this._map.off('mousedown', this._onMouseDown, this).off('mousemove', this._onMouseMove, this).off('touchstart', this._onMouseDown, this).off('touchmove', this._onMouseMove, this);
       
  8039                 L.DomEvent.off(document, 'mouseup', this._onMouseUp, this);
       
  8040                 L.DomEvent.off(document, 'touchend', this._onMouseUp, this);
       
  8041                 if (this._shape) {
       
  8042                     this._map.removeLayer(this._shape);
       
  8043                     delete this._shape;
       
  8044                 }
       
  8045             }
       
  8046             this._isDrawing = false;
       
  8047         },
       
  8048         _getTooltipText: function () {
       
  8049             return { text: this._endLabelText };
       
  8050         },
       
  8051         _onMouseDown: function (e) {
       
  8052             this._isDrawing = true;
       
  8053             this._startLatLng = e.latlng;
       
  8054             L.DomEvent.on(document, 'mouseup', this._onMouseUp, this).on(document, 'touchend', this._onMouseUp, this).preventDefault(e.originalEvent);
       
  8055         },
       
  8056         _onMouseMove: function (e) {
       
  8057             var latlng = e.latlng;
       
  8058             this._tooltip.updatePosition(latlng);
       
  8059             if (this._isDrawing) {
       
  8060                 this._tooltip.updateContent(this._getTooltipText());
       
  8061                 this._drawShape(latlng);
       
  8062             }
       
  8063         },
       
  8064         _onMouseUp: function () {
       
  8065             if (this._shape) {
       
  8066                 this._fireCreatedEvent();
       
  8067             }
       
  8068             this.disable();
       
  8069             if (this.options.repeatMode) {
       
  8070                 this.enable();
       
  8071             }
       
  8072         }
       
  8073     });
       
  8074     L.Draw.Rectangle = L.Draw.SimpleShape.extend({
       
  8075         statics: { TYPE: 'rectangle' },
       
  8076         options: {
       
  8077             shapeOptions: {
       
  8078                 stroke: true,
       
  8079                 color: '#f06eaa',
       
  8080                 weight: 4,
       
  8081                 opacity: 0.5,
       
  8082                 fill: true,
       
  8083                 fillColor: null,
       
  8084                 fillOpacity: 0.2,
       
  8085                 clickable: true
       
  8086             },
       
  8087             metric: true
       
  8088         },
       
  8089         initialize: function (map, options) {
       
  8090             this.type = L.Draw.Rectangle.TYPE;
       
  8091             this._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;
       
  8092             L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
       
  8093         },
       
  8094         _drawShape: function (latlng) {
       
  8095             if (!this._shape) {
       
  8096                 this._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);
       
  8097                 this._map.addLayer(this._shape);
       
  8098             } else {
       
  8099                 this._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));
       
  8100             }
       
  8101         },
       
  8102         _fireCreatedEvent: function () {
       
  8103             var rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);
       
  8104             L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);
       
  8105         },
       
  8106         _getTooltipText: function () {
       
  8107             var tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this), shape = this._shape, latLngs, area, subtext;
       
  8108             if (shape) {
       
  8109                 latLngs = this._shape.getLatLngs();
       
  8110                 area = L.GeometryUtil.geodesicArea(latLngs);
       
  8111                 subtext = L.GeometryUtil.readableArea(area, this.options.metric);
       
  8112             }
       
  8113             return {
       
  8114                 text: tooltipText.text,
       
  8115                 subtext: subtext
       
  8116             };
       
  8117         }
       
  8118     });
       
  8119     L.Draw.Circle = L.Draw.SimpleShape.extend({
       
  8120         statics: { TYPE: 'circle' },
       
  8121         options: {
       
  8122             shapeOptions: {
       
  8123                 stroke: true,
       
  8124                 color: '#f06eaa',
       
  8125                 weight: 4,
       
  8126                 opacity: 0.5,
       
  8127                 fill: true,
       
  8128                 fillColor: null,
       
  8129                 fillOpacity: 0.2,
       
  8130                 clickable: true
       
  8131             },
       
  8132             showRadius: true,
       
  8133             metric: true,
       
  8134             feet: true
       
  8135         },
       
  8136         initialize: function (map, options) {
       
  8137             this.type = L.Draw.Circle.TYPE;
       
  8138             this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;
       
  8139             L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
       
  8140         },
       
  8141         _drawShape: function (latlng) {
       
  8142             if (!this._shape) {
       
  8143                 this._shape = new L.Circle(this._startLatLng, this._startLatLng.distanceTo(latlng), this.options.shapeOptions);
       
  8144                 this._map.addLayer(this._shape);
       
  8145             } else {
       
  8146                 this._shape.setRadius(this._startLatLng.distanceTo(latlng));
       
  8147             }
       
  8148         },
       
  8149         _fireCreatedEvent: function () {
       
  8150             var circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);
       
  8151             L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);
       
  8152         },
       
  8153         _onMouseMove: function (e) {
       
  8154             var latlng = e.latlng, showRadius = this.options.showRadius, useMetric = this.options.metric, radius;
       
  8155             this._tooltip.updatePosition(latlng);
       
  8156             if (this._isDrawing) {
       
  8157                 this._drawShape(latlng);
       
  8158                 radius = this._shape.getRadius().toFixed(1);
       
  8159                 this._tooltip.updateContent({
       
  8160                     text: this._endLabelText,
       
  8161                     subtext: showRadius ? L.drawLocal.draw.handlers.circle.radius + ': ' + L.GeometryUtil.readableDistance(radius, useMetric, this.options.feet) : ''
       
  8162                 });
       
  8163             }
       
  8164         }
       
  8165     });
       
  8166     L.Draw.Marker = L.Draw.Feature.extend({
       
  8167         statics: { TYPE: 'marker' },
       
  8168         options: {
       
  8169             icon: new L.Icon.Default(),
       
  8170             repeatMode: false,
       
  8171             zIndexOffset: 2000
       
  8172         },
       
  8173         initialize: function (map, options) {
       
  8174             this.type = L.Draw.Marker.TYPE;
       
  8175             L.Draw.Feature.prototype.initialize.call(this, map, options);
       
  8176         },
       
  8177         addHooks: function () {
       
  8178             L.Draw.Feature.prototype.addHooks.call(this);
       
  8179             if (this._map) {
       
  8180                 this._tooltip.updateContent({ text: L.drawLocal.draw.handlers.marker.tooltip.start });
       
  8181                 if (!this._mouseMarker) {
       
  8182                     this._mouseMarker = L.marker(this._map.getCenter(), {
       
  8183                         icon: L.divIcon({
       
  8184                             className: 'leaflet-mouse-marker',
       
  8185                             iconAnchor: [
       
  8186                                 20,
       
  8187                                 20
       
  8188                             ],
       
  8189                             iconSize: [
       
  8190                                 40,
       
  8191                                 40
       
  8192                             ]
       
  8193                         }),
       
  8194                         opacity: 0,
       
  8195                         zIndexOffset: this.options.zIndexOffset
       
  8196                     });
       
  8197                 }
       
  8198                 this._mouseMarker.on('click', this._onClick, this).addTo(this._map);
       
  8199                 this._map.on('mousemove', this._onMouseMove, this);
       
  8200                 this._map.on('click', this._onTouch, this);
       
  8201             }
       
  8202         },
       
  8203         removeHooks: function () {
       
  8204             L.Draw.Feature.prototype.removeHooks.call(this);
       
  8205             if (this._map) {
       
  8206                 if (this._marker) {
       
  8207                     this._marker.off('click', this._onClick, this);
       
  8208                     this._map.off('click', this._onClick, this).off('click', this._onTouch, this).removeLayer(this._marker);
       
  8209                     delete this._marker;
       
  8210                 }
       
  8211                 this._mouseMarker.off('click', this._onClick, this);
       
  8212                 this._map.removeLayer(this._mouseMarker);
       
  8213                 delete this._mouseMarker;
       
  8214                 this._map.off('mousemove', this._onMouseMove, this);
       
  8215             }
       
  8216         },
       
  8217         _onMouseMove: function (e) {
       
  8218             var latlng = e.latlng;
       
  8219             this._tooltip.updatePosition(latlng);
       
  8220             this._mouseMarker.setLatLng(latlng);
       
  8221             if (!this._marker) {
       
  8222                 this._marker = new L.Marker(latlng, {
       
  8223                     icon: this.options.icon,
       
  8224                     zIndexOffset: this.options.zIndexOffset
       
  8225                 });
       
  8226                 this._marker.on('click', this._onClick, this);
       
  8227                 this._map.on('click', this._onClick, this).addLayer(this._marker);
       
  8228             } else {
       
  8229                 latlng = this._mouseMarker.getLatLng();
       
  8230                 this._marker.setLatLng(latlng);
       
  8231             }
       
  8232         },
       
  8233         _onClick: function () {
       
  8234             this._fireCreatedEvent();
       
  8235             this.disable();
       
  8236             if (this.options.repeatMode) {
       
  8237                 this.enable();
       
  8238             }
       
  8239         },
       
  8240         _onTouch: function (e) {
       
  8241             this._onMouseMove(e);
       
  8242             this._onClick();
       
  8243         },
       
  8244         _fireCreatedEvent: function () {
       
  8245             var marker = new L.Marker.Touch(this._marker.getLatLng(), { icon: this.options.icon });
       
  8246             L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);
       
  8247         }
       
  8248     });
       
  8249     L.Edit = L.Edit || {};
       
  8250     L.Edit.Marker = L.Handler.extend({
       
  8251         initialize: function (marker, options) {
       
  8252             this._marker = marker;
       
  8253             L.setOptions(this, options);
       
  8254         },
       
  8255         addHooks: function () {
       
  8256             var marker = this._marker;
       
  8257             marker.dragging.enable();
       
  8258             marker.on('dragend', this._onDragEnd, marker);
       
  8259             this._toggleMarkerHighlight();
       
  8260         },
       
  8261         removeHooks: function () {
       
  8262             var marker = this._marker;
       
  8263             marker.dragging.disable();
       
  8264             marker.off('dragend', this._onDragEnd, marker);
       
  8265             this._toggleMarkerHighlight();
       
  8266         },
       
  8267         _onDragEnd: function (e) {
       
  8268             var layer = e.target;
       
  8269             layer.edited = true;
       
  8270         },
       
  8271         _toggleMarkerHighlight: function () {
       
  8272             var icon = this._marker._icon;
       
  8273             if (!icon) {
       
  8274                 return;
       
  8275             }
       
  8276             icon.style.display = 'none';
       
  8277             if (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {
       
  8278                 L.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');
       
  8279                 this._offsetMarker(icon, -4);
       
  8280             } else {
       
  8281                 L.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');
       
  8282                 this._offsetMarker(icon, 4);
       
  8283             }
       
  8284             icon.style.display = '';
       
  8285         },
       
  8286         _offsetMarker: function (icon, offset) {
       
  8287             var iconMarginTop = parseInt(icon.style.marginTop, 10) - offset, iconMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;
       
  8288             icon.style.marginTop = iconMarginTop + 'px';
       
  8289             icon.style.marginLeft = iconMarginLeft + 'px';
       
  8290         }
       
  8291     });
       
  8292     L.Marker.addInitHook(function () {
       
  8293         if (L.Edit.Marker) {
       
  8294             this.editing = new L.Edit.Marker(this);
       
  8295             if (this.options.editable) {
       
  8296                 this.editing.enable();
       
  8297             }
       
  8298         }
       
  8299     });
       
  8300     L.Edit = L.Edit || {};
       
  8301     L.Edit.Poly = L.Handler.extend({
       
  8302         options: {},
       
  8303         initialize: function (poly, options) {
       
  8304             this.latlngs = [poly._latlngs];
       
  8305             if (poly._holes) {
       
  8306                 this.latlngs = this.latlngs.concat(poly._holes);
       
  8307             }
       
  8308             this._verticesHandlers = [];
       
  8309             for (var i = 0; i < this.latlngs.length; i++) {
       
  8310                 this._verticesHandlers.push(new L.Edit.PolyVerticesEdit(poly, this.latlngs[i], options));
       
  8311             }
       
  8312             this._poly = poly;
       
  8313             L.setOptions(this, options);
       
  8314         },
       
  8315         _eachVertexHandler: function (callback) {
       
  8316             for (var i = 0; i < this._verticesHandlers.length; i++) {
       
  8317                 callback(this._verticesHandlers[i]);
       
  8318             }
       
  8319         },
       
  8320         addHooks: function () {
       
  8321             this._eachVertexHandler(function (handler) {
       
  8322                 handler.addHooks();
       
  8323             });
       
  8324         },
       
  8325         removeHooks: function () {
       
  8326             this._eachVertexHandler(function (handler) {
       
  8327                 handler.removeHooks();
       
  8328             });
       
  8329         },
       
  8330         updateMarkers: function () {
       
  8331             this._eachVertexHandler(function (handler) {
       
  8332                 handler.updateMarkers();
       
  8333             });
       
  8334         }
       
  8335     });
       
  8336     L.Edit.PolyVerticesEdit = L.Handler.extend({
       
  8337         options: {
       
  8338             icon: new L.DivIcon({
       
  8339                 iconSize: new L.Point(8, 8),
       
  8340                 className: 'leaflet-div-icon leaflet-editing-icon'
       
  8341             }),
       
  8342             touchIcon: new L.DivIcon({
       
  8343                 iconSize: new L.Point(20, 20),
       
  8344                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
       
  8345             })
       
  8346         },
       
  8347         initialize: function (poly, latlngs, options) {
       
  8348             if (L.Browser.touch) {
       
  8349                 this.options.icon = this.options.touchIcon;
       
  8350             }
       
  8351             this._poly = poly;
       
  8352             this._latlngs = latlngs;
       
  8353             L.setOptions(this, options);
       
  8354         },
       
  8355         addHooks: function () {
       
  8356             var poly = this._poly;
       
  8357             if (!(poly instanceof L.Polygon)) {
       
  8358                 poly.options.editing.fill = false;
       
  8359             }
       
  8360             poly.setStyle(poly.options.editing);
       
  8361             if (this._poly._map) {
       
  8362                 this._map = this._poly._map;
       
  8363                 if (!this._markerGroup) {
       
  8364                     this._initMarkers();
       
  8365                 }
       
  8366                 this._poly._map.addLayer(this._markerGroup);
       
  8367             }
       
  8368         },
       
  8369         removeHooks: function () {
       
  8370             var poly = this._poly;
       
  8371             poly.setStyle(poly.options.original);
       
  8372             if (poly._map) {
       
  8373                 poly._map.removeLayer(this._markerGroup);
       
  8374                 delete this._markerGroup;
       
  8375                 delete this._markers;
       
  8376             }
       
  8377         },
       
  8378         updateMarkers: function () {
       
  8379             this._markerGroup.clearLayers();
       
  8380             this._initMarkers();
       
  8381         },
       
  8382         _initMarkers: function () {
       
  8383             if (!this._markerGroup) {
       
  8384                 this._markerGroup = new L.LayerGroup();
       
  8385             }
       
  8386             this._markers = [];
       
  8387             var latlngs = this._latlngs, i, j, len, marker;
       
  8388             for (i = 0, len = latlngs.length; i < len; i++) {
       
  8389                 marker = this._createMarker(latlngs[i], i);
       
  8390                 marker.on('click', this._onMarkerClick, this);
       
  8391                 this._markers.push(marker);
       
  8392             }
       
  8393             var markerLeft, markerRight;
       
  8394             for (i = 0, j = len - 1; i < len; j = i++) {
       
  8395                 if (i === 0 && !(L.Polygon && this._poly instanceof L.Polygon)) {
       
  8396                     continue;
       
  8397                 }
       
  8398                 markerLeft = this._markers[j];
       
  8399                 markerRight = this._markers[i];
       
  8400                 this._createMiddleMarker(markerLeft, markerRight);
       
  8401                 this._updatePrevNext(markerLeft, markerRight);
       
  8402             }
       
  8403         },
       
  8404         _createMarker: function (latlng, index) {
       
  8405             var marker = new L.Marker.Touch(latlng, {
       
  8406                 draggable: true,
       
  8407                 icon: this.options.icon
       
  8408             });
       
  8409             marker._origLatLng = latlng;
       
  8410             marker._index = index;
       
  8411             marker.on('dragstart', this._onMarkerDragStart, this).on('drag', this._onMarkerDrag, this).on('dragend', this._fireEdit, this).on('touchmove', this._onTouchMove, this).on('MSPointerMove', this._onTouchMove, this).on('touchend', this._fireEdit, this).on('MSPointerUp', this._fireEdit, this);
       
  8412             this._markerGroup.addLayer(marker);
       
  8413             return marker;
       
  8414         },
       
  8415         _onMarkerDragStart: function () {
       
  8416             this._poly.fire('editstart');
       
  8417         },
       
  8418         _spliceLatLngs: function () {
       
  8419             var removed = [].splice.apply(this._latlngs, arguments);
       
  8420             this._poly._convertLatLngs(this._latlngs, true);
       
  8421             this._poly.redraw();
       
  8422             return removed;
       
  8423         },
       
  8424         _removeMarker: function (marker) {
       
  8425             var i = marker._index;
       
  8426             this._markerGroup.removeLayer(marker);
       
  8427             this._markers.splice(i, 1);
       
  8428             this._spliceLatLngs(i, 1);
       
  8429             this._updateIndexes(i, -1);
       
  8430             marker.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);
       
  8431         },
       
  8432         _fireEdit: function () {
       
  8433             this._poly.edited = true;
       
  8434             this._poly.fire('edit');
       
  8435             this._poly._map.fire('draw:editvertex', { layers: this._markerGroup });
       
  8436         },
       
  8437         _onMarkerDrag: function (e) {
       
  8438             var marker = e.target;
       
  8439             L.extend(marker._origLatLng, marker._latlng);
       
  8440             if (marker._middleLeft) {
       
  8441                 marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
       
  8442             }
       
  8443             if (marker._middleRight) {
       
  8444                 marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
       
  8445             }
       
  8446             this._poly.redraw();
       
  8447             this._poly.fire('editdrag');
       
  8448         },
       
  8449         _onMarkerClick: function (e) {
       
  8450             var minPoints = L.Polygon && this._poly instanceof L.Polygon ? 4 : 3, marker = e.target;
       
  8451             if (this._latlngs.length < minPoints) {
       
  8452                 return;
       
  8453             }
       
  8454             this._removeMarker(marker);
       
  8455             this._updatePrevNext(marker._prev, marker._next);
       
  8456             if (marker._middleLeft) {
       
  8457                 this._markerGroup.removeLayer(marker._middleLeft);
       
  8458             }
       
  8459             if (marker._middleRight) {
       
  8460                 this._markerGroup.removeLayer(marker._middleRight);
       
  8461             }
       
  8462             if (marker._prev && marker._next) {
       
  8463                 this._createMiddleMarker(marker._prev, marker._next);
       
  8464             } else if (!marker._prev) {
       
  8465                 marker._next._middleLeft = null;
       
  8466             } else if (!marker._next) {
       
  8467                 marker._prev._middleRight = null;
       
  8468             }
       
  8469             this._fireEdit();
       
  8470         },
       
  8471         _onTouchMove: function (e) {
       
  8472             var layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]), latlng = this._map.layerPointToLatLng(layerPoint), marker = e.target;
       
  8473             L.extend(marker._origLatLng, latlng);
       
  8474             if (marker._middleLeft) {
       
  8475                 marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
       
  8476             }
       
  8477             if (marker._middleRight) {
       
  8478                 marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
       
  8479             }
       
  8480             this._poly.redraw();
       
  8481             this.updateMarkers();
       
  8482         },
       
  8483         _updateIndexes: function (index, delta) {
       
  8484             this._markerGroup.eachLayer(function (marker) {
       
  8485                 if (marker._index > index) {
       
  8486                     marker._index += delta;
       
  8487                 }
       
  8488             });
       
  8489         },
       
  8490         _createMiddleMarker: function (marker1, marker2) {
       
  8491             var latlng = this._getMiddleLatLng(marker1, marker2), marker = this._createMarker(latlng), onClick, onDragStart, onDragEnd;
       
  8492             marker.setOpacity(0.6);
       
  8493             marker1._middleRight = marker2._middleLeft = marker;
       
  8494             onDragStart = function () {
       
  8495                 var i = marker2._index;
       
  8496                 marker._index = i;
       
  8497                 marker.off('click', onClick, this).on('click', this._onMarkerClick, this);
       
  8498                 latlng.lat = marker.getLatLng().lat;
       
  8499                 latlng.lng = marker.getLatLng().lng;
       
  8500                 this._spliceLatLngs(i, 0, latlng);
       
  8501                 this._markers.splice(i, 0, marker);
       
  8502                 marker.setOpacity(1);
       
  8503                 this._updateIndexes(i, 1);
       
  8504                 marker2._index++;
       
  8505                 this._updatePrevNext(marker1, marker);
       
  8506                 this._updatePrevNext(marker, marker2);
       
  8507                 this._poly.fire('editstart');
       
  8508             };
       
  8509             onDragEnd = function () {
       
  8510                 marker.off('dragstart', onDragStart, this);
       
  8511                 marker.off('dragend', onDragEnd, this);
       
  8512                 marker.off('touchmove', onDragStart, this);
       
  8513                 this._createMiddleMarker(marker1, marker);
       
  8514                 this._createMiddleMarker(marker, marker2);
       
  8515             };
       
  8516             onClick = function () {
       
  8517                 onDragStart.call(this);
       
  8518                 onDragEnd.call(this);
       
  8519                 this._fireEdit();
       
  8520             };
       
  8521             marker.on('click', onClick, this).on('dragstart', onDragStart, this).on('dragend', onDragEnd, this).on('touchmove', onDragStart, this);
       
  8522             this._markerGroup.addLayer(marker);
       
  8523         },
       
  8524         _updatePrevNext: function (marker1, marker2) {
       
  8525             if (marker1) {
       
  8526                 marker1._next = marker2;
       
  8527             }
       
  8528             if (marker2) {
       
  8529                 marker2._prev = marker1;
       
  8530             }
       
  8531         },
       
  8532         _getMiddleLatLng: function (marker1, marker2) {
       
  8533             var map = this._poly._map, p1 = map.project(marker1.getLatLng()), p2 = map.project(marker2.getLatLng());
       
  8534             return map.unproject(p1._add(p2)._divideBy(2));
       
  8535         }
       
  8536     });
       
  8537     L.Polyline.addInitHook(function () {
       
  8538         if (this.editing) {
       
  8539             return;
       
  8540         }
       
  8541         if (L.Edit.Poly) {
       
  8542             this.editing = new L.Edit.Poly(this);
       
  8543             if (this.options.editable) {
       
  8544                 this.editing.enable();
       
  8545             }
       
  8546         }
       
  8547         this.on('add', function () {
       
  8548             if (this.editing && this.editing.enabled()) {
       
  8549                 this.editing.addHooks();
       
  8550             }
       
  8551         });
       
  8552         this.on('remove', function () {
       
  8553             if (this.editing && this.editing.enabled()) {
       
  8554                 this.editing.removeHooks();
       
  8555             }
       
  8556         });
       
  8557     });
       
  8558     L.Edit = L.Edit || {};
       
  8559     L.Edit.SimpleShape = L.Handler.extend({
       
  8560         options: {
       
  8561             moveIcon: new L.DivIcon({
       
  8562                 iconSize: new L.Point(8, 8),
       
  8563                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'
       
  8564             }),
       
  8565             resizeIcon: new L.DivIcon({
       
  8566                 iconSize: new L.Point(8, 8),
       
  8567                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'
       
  8568             }),
       
  8569             touchMoveIcon: new L.DivIcon({
       
  8570                 iconSize: new L.Point(20, 20),
       
  8571                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'
       
  8572             }),
       
  8573             touchResizeIcon: new L.DivIcon({
       
  8574                 iconSize: new L.Point(20, 20),
       
  8575                 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'
       
  8576             })
       
  8577         },
       
  8578         initialize: function (shape, options) {
       
  8579             if (L.Browser.touch) {
       
  8580                 this.options.moveIcon = this.options.touchMoveIcon;
       
  8581                 this.options.resizeIcon = this.options.touchResizeIcon;
       
  8582             }
       
  8583             this._shape = shape;
       
  8584             L.Util.setOptions(this, options);
       
  8585         },
       
  8586         addHooks: function () {
       
  8587             var shape = this._shape;
       
  8588             if (this._shape._map) {
       
  8589                 this._map = this._shape._map;
       
  8590                 shape.setStyle(shape.options.editing);
       
  8591                 if (shape._map) {
       
  8592                     this._map = shape._map;
       
  8593                     if (!this._markerGroup) {
       
  8594                         this._initMarkers();
       
  8595                     }
       
  8596                     this._map.addLayer(this._markerGroup);
       
  8597                 }
       
  8598             }
       
  8599         },
       
  8600         removeHooks: function () {
       
  8601             var shape = this._shape;
       
  8602             shape.setStyle(shape.options.original);
       
  8603             if (shape._map) {
       
  8604                 this._unbindMarker(this._moveMarker);
       
  8605                 for (var i = 0, l = this._resizeMarkers.length; i < l; i++) {
       
  8606                     this._unbindMarker(this._resizeMarkers[i]);
       
  8607                 }
       
  8608                 this._resizeMarkers = null;
       
  8609                 this._map.removeLayer(this._markerGroup);
       
  8610                 delete this._markerGroup;
       
  8611             }
       
  8612             this._map = null;
       
  8613         },
       
  8614         updateMarkers: function () {
       
  8615             this._markerGroup.clearLayers();
       
  8616             this._initMarkers();
       
  8617         },
       
  8618         _initMarkers: function () {
       
  8619             if (!this._markerGroup) {
       
  8620                 this._markerGroup = new L.LayerGroup();
       
  8621             }
       
  8622             this._createMoveMarker();
       
  8623             this._createResizeMarker();
       
  8624         },
       
  8625         _createMoveMarker: function () {
       
  8626         },
       
  8627         _createResizeMarker: function () {
       
  8628         },
       
  8629         _createMarker: function (latlng, icon) {
       
  8630             var marker = new L.Marker.Touch(latlng, {
       
  8631                 draggable: true,
       
  8632                 icon: icon,
       
  8633                 zIndexOffset: 10
       
  8634             });
       
  8635             this._bindMarker(marker);
       
  8636             this._markerGroup.addLayer(marker);
       
  8637             return marker;
       
  8638         },
       
  8639         _bindMarker: function (marker) {
       
  8640             marker.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);
       
  8641         },
       
  8642         _unbindMarker: function (marker) {
       
  8643             marker.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);
       
  8644         },
       
  8645         _onMarkerDragStart: function (e) {
       
  8646             var marker = e.target;
       
  8647             marker.setOpacity(0);
       
  8648             this._shape.fire('editstart');
       
  8649         },
       
  8650         _fireEdit: function () {
       
  8651             this._shape.edited = true;
       
  8652             this._shape.fire('edit');
       
  8653         },
       
  8654         _onMarkerDrag: function (e) {
       
  8655             var marker = e.target, latlng = marker.getLatLng();
       
  8656             if (marker === this._moveMarker) {
       
  8657                 this._move(latlng);
       
  8658             } else {
       
  8659                 this._resize(latlng);
       
  8660             }
       
  8661             this._shape.redraw();
       
  8662             this._shape.fire('editdrag');
       
  8663         },
       
  8664         _onMarkerDragEnd: function (e) {
       
  8665             var marker = e.target;
       
  8666             marker.setOpacity(1);
       
  8667             this._fireEdit();
       
  8668         },
       
  8669         _onTouchStart: function (e) {
       
  8670             L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);
       
  8671             if (typeof this._getCorners === 'function') {
       
  8672                 var corners = this._getCorners(), marker = e.target, currentCornerIndex = marker._cornerIndex;
       
  8673                 marker.setOpacity(0);
       
  8674                 this._oppositeCorner = corners[(currentCornerIndex + 2) % 4];
       
  8675                 this._toggleCornerMarkers(0, currentCornerIndex);
       
  8676             }
       
  8677             this._shape.fire('editstart');
       
  8678         },
       
  8679         _onTouchMove: function (e) {
       
  8680             var layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]), latlng = this._map.layerPointToLatLng(layerPoint), marker = e.target;
       
  8681             if (marker === this._moveMarker) {
       
  8682                 this._move(latlng);
       
  8683             } else {
       
  8684                 this._resize(latlng);
       
  8685             }
       
  8686             this._shape.redraw();
       
  8687             return false;
       
  8688         },
       
  8689         _onTouchEnd: function (e) {
       
  8690             var marker = e.target;
       
  8691             marker.setOpacity(1);
       
  8692             this.updateMarkers();
       
  8693             this._fireEdit();
       
  8694         },
       
  8695         _move: function () {
       
  8696         },
       
  8697         _resize: function () {
       
  8698         }
       
  8699     });
       
  8700     L.Edit = L.Edit || {};
       
  8701     L.Edit.Rectangle = L.Edit.SimpleShape.extend({
       
  8702         _createMoveMarker: function () {
       
  8703             var bounds = this._shape.getBounds(), center = bounds.getCenter();
       
  8704             this._moveMarker = this._createMarker(center, this.options.moveIcon);
       
  8705         },
       
  8706         _createResizeMarker: function () {
       
  8707             var corners = this._getCorners();
       
  8708             this._resizeMarkers = [];
       
  8709             for (var i = 0, l = corners.length; i < l; i++) {
       
  8710                 this._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));
       
  8711                 this._resizeMarkers[i]._cornerIndex = i;
       
  8712             }
       
  8713         },
       
  8714         _onMarkerDragStart: function (e) {
       
  8715             L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);
       
  8716             var corners = this._getCorners(), marker = e.target, currentCornerIndex = marker._cornerIndex;
       
  8717             this._oppositeCorner = corners[(currentCornerIndex + 2) % 4];
       
  8718             this._toggleCornerMarkers(0, currentCornerIndex);
       
  8719         },
       
  8720         _onMarkerDragEnd: function (e) {
       
  8721             var marker = e.target, bounds, center;
       
  8722             if (marker === this._moveMarker) {
       
  8723                 bounds = this._shape.getBounds();
       
  8724                 center = bounds.getCenter();
       
  8725                 marker.setLatLng(center);
       
  8726             }
       
  8727             this._toggleCornerMarkers(1);
       
  8728             this._repositionCornerMarkers();
       
  8729             L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);
       
  8730         },
       
  8731         _move: function (newCenter) {
       
  8732             var latlngs = this._shape.getLatLngs(), bounds = this._shape.getBounds(), center = bounds.getCenter(), offset, newLatLngs = [];
       
  8733             for (var i = 0, l = latlngs.length; i < l; i++) {
       
  8734                 offset = [
       
  8735                     latlngs[i].lat - center.lat,
       
  8736                     latlngs[i].lng - center.lng
       
  8737                 ];
       
  8738                 newLatLngs.push([
       
  8739                     newCenter.lat + offset[0],
       
  8740                     newCenter.lng + offset[1]
       
  8741                 ]);
       
  8742             }
       
  8743             this._shape.setLatLngs(newLatLngs);
       
  8744             this._repositionCornerMarkers();
       
  8745         },
       
  8746         _resize: function (latlng) {
       
  8747             var bounds;
       
  8748             this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));
       
  8749             bounds = this._shape.getBounds();
       
  8750             this._moveMarker.setLatLng(bounds.getCenter());
       
  8751         },
       
  8752         _getCorners: function () {
       
  8753             var bounds = this._shape.getBounds(), nw = bounds.getNorthWest(), ne = bounds.getNorthEast(), se = bounds.getSouthEast(), sw = bounds.getSouthWest();
       
  8754             return [
       
  8755                 nw,
       
  8756                 ne,
       
  8757                 se,
       
  8758                 sw
       
  8759             ];
       
  8760         },
       
  8761         _toggleCornerMarkers: function (opacity) {
       
  8762             for (var i = 0, l = this._resizeMarkers.length; i < l; i++) {
       
  8763                 this._resizeMarkers[i].setOpacity(opacity);
       
  8764             }
       
  8765         },
       
  8766         _repositionCornerMarkers: function () {
       
  8767             var corners = this._getCorners();
       
  8768             for (var i = 0, l = this._resizeMarkers.length; i < l; i++) {
       
  8769                 this._resizeMarkers[i].setLatLng(corners[i]);
       
  8770             }
       
  8771         }
       
  8772     });
       
  8773     L.Rectangle.addInitHook(function () {
       
  8774         if (L.Edit.Rectangle) {
       
  8775             this.editing = new L.Edit.Rectangle(this);
       
  8776             if (this.options.editable) {
       
  8777                 this.editing.enable();
       
  8778             }
       
  8779         }
       
  8780     });
       
  8781     L.Edit = L.Edit || {};
       
  8782     L.Edit.Circle = L.Edit.SimpleShape.extend({
       
  8783         _createMoveMarker: function () {
       
  8784             var center = this._shape.getLatLng();
       
  8785             this._moveMarker = this._createMarker(center, this.options.moveIcon);
       
  8786         },
       
  8787         _createResizeMarker: function () {
       
  8788             var center = this._shape.getLatLng(), resizemarkerPoint = this._getResizeMarkerPoint(center);
       
  8789             this._resizeMarkers = [];
       
  8790             this._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));
       
  8791         },
       
  8792         _getResizeMarkerPoint: function (latlng) {
       
  8793             var delta = this._shape._radius * Math.cos(Math.PI / 4), point = this._map.project(latlng);
       
  8794             return this._map.unproject([
       
  8795                 point.x + delta,
       
  8796                 point.y - delta
       
  8797             ]);
       
  8798         },
       
  8799         _move: function (latlng) {
       
  8800             var resizemarkerPoint = this._getResizeMarkerPoint(latlng);
       
  8801             this._resizeMarkers[0].setLatLng(resizemarkerPoint);
       
  8802             this._shape.setLatLng(latlng);
       
  8803         },
       
  8804         _resize: function (latlng) {
       
  8805             var moveLatLng = this._moveMarker.getLatLng(), radius = moveLatLng.distanceTo(latlng);
       
  8806             this._shape.setRadius(radius);
       
  8807         }
       
  8808     });
       
  8809     L.Circle.addInitHook(function () {
       
  8810         if (L.Edit.Circle) {
       
  8811             this.editing = new L.Edit.Circle(this);
       
  8812             if (this.options.editable) {
       
  8813                 this.editing.enable();
       
  8814             }
       
  8815         }
       
  8816         this.on('add', function () {
       
  8817             if (this.editing && this.editing.enabled()) {
       
  8818                 this.editing.addHooks();
       
  8819             }
       
  8820         });
       
  8821         this.on('remove', function () {
       
  8822             if (this.editing && this.editing.enabled()) {
       
  8823                 this.editing.removeHooks();
       
  8824             }
       
  8825         });
       
  8826     });
       
  8827     L.Map.mergeOptions({ touchExtend: true });
       
  8828     L.Map.TouchExtend = L.Handler.extend({
       
  8829         initialize: function (map) {
       
  8830             this._map = map;
       
  8831             this._container = map._container;
       
  8832             this._pane = map._panes.overlayPane;
       
  8833         },
       
  8834         addHooks: function () {
       
  8835             L.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);
       
  8836             L.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);
       
  8837             L.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);
       
  8838             if (this._detectIE()) {
       
  8839                 L.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);
       
  8840                 L.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);
       
  8841                 L.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);
       
  8842                 L.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);
       
  8843             } else {
       
  8844                 L.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);
       
  8845                 L.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);
       
  8846             }
       
  8847         },
       
  8848         removeHooks: function () {
       
  8849             L.DomEvent.off(this._container, 'touchstart', this._onTouchStart);
       
  8850             L.DomEvent.off(this._container, 'touchend', this._onTouchEnd);
       
  8851             L.DomEvent.off(this._container, 'touchmove', this._onTouchMove);
       
  8852             if (this._detectIE()) {
       
  8853                 L.DomEvent.off(this._container, 'MSPointerDowm', this._onTouchStart);
       
  8854                 L.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd);
       
  8855                 L.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove);
       
  8856                 L.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel);
       
  8857             } else {
       
  8858                 L.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel);
       
  8859                 L.DomEvent.off(this._container, 'touchleave', this._onTouchLeave);
       
  8860             }
       
  8861         },
       
  8862         _touchEvent: function (e, type) {
       
  8863             var touchEvent = {};
       
  8864             if (typeof e.touches !== 'undefined') {
       
  8865                 if (!e.touches.length) {
       
  8866                     return;
       
  8867                 }
       
  8868                 touchEvent = e.touches[0];
       
  8869             } else if (e.pointerType === 'touch') {
       
  8870                 touchEvent = e;
       
  8871                 if (!this._filterClick(e)) {
       
  8872                     return;
       
  8873                 }
       
  8874             } else {
       
  8875                 return;
       
  8876             }
       
  8877             var containerPoint = this._map.mouseEventToContainerPoint(touchEvent), layerPoint = this._map.mouseEventToLayerPoint(touchEvent), latlng = this._map.layerPointToLatLng(layerPoint);
       
  8878             this._map.fire(type, {
       
  8879                 latlng: latlng,
       
  8880                 layerPoint: layerPoint,
       
  8881                 containerPoint: containerPoint,
       
  8882                 pageX: touchEvent.pageX,
       
  8883                 pageY: touchEvent.pageY,
       
  8884                 originalEvent: e
       
  8885             });
       
  8886         },
       
  8887         _filterClick: function (e) {
       
  8888             var timeStamp = e.timeStamp || e.originalEvent.timeStamp, elapsed = L.DomEvent._lastClick && timeStamp - L.DomEvent._lastClick;
       
  8889             if (elapsed && elapsed > 100 && elapsed < 500 || e.target._simulatedClick && !e._simulated) {
       
  8890                 L.DomEvent.stop(e);
       
  8891                 return false;
       
  8892             }
       
  8893             L.DomEvent._lastClick = timeStamp;
       
  8894             return true;
       
  8895         },
       
  8896         _onTouchStart: function (e) {
       
  8897             if (!this._map._loaded) {
       
  8898                 return;
       
  8899             }
       
  8900             var type = 'touchstart';
       
  8901             this._touchEvent(e, type);
       
  8902         },
       
  8903         _onTouchEnd: function (e) {
       
  8904             if (!this._map._loaded) {
       
  8905                 return;
       
  8906             }
       
  8907             var type = 'touchend';
       
  8908             this._touchEvent(e, type);
       
  8909         },
       
  8910         _onTouchCancel: function (e) {
       
  8911             if (!this._map._loaded) {
       
  8912                 return;
       
  8913             }
       
  8914             var type = 'touchcancel';
       
  8915             if (this._detectIE()) {
       
  8916                 type = 'pointercancel';
       
  8917             }
       
  8918             this._touchEvent(e, type);
       
  8919         },
       
  8920         _onTouchLeave: function (e) {
       
  8921             if (!this._map._loaded) {
       
  8922                 return;
       
  8923             }
       
  8924             var type = 'touchleave';
       
  8925             this._touchEvent(e, type);
       
  8926         },
       
  8927         _onTouchMove: function (e) {
       
  8928             if (!this._map._loaded) {
       
  8929                 return;
       
  8930             }
       
  8931             var type = 'touchmove';
       
  8932             this._touchEvent(e, type);
       
  8933         },
       
  8934         _detectIE: function () {
       
  8935             var ua = window.navigator.userAgent;
       
  8936             var msie = ua.indexOf('MSIE ');
       
  8937             if (msie > 0) {
       
  8938                 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
       
  8939             }
       
  8940             var trident = ua.indexOf('Trident/');
       
  8941             if (trident > 0) {
       
  8942                 var rv = ua.indexOf('rv:');
       
  8943                 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
       
  8944             }
       
  8945             var edge = ua.indexOf('Edge/');
       
  8946             if (edge > 0) {
       
  8947                 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
       
  8948             }
       
  8949             return false;
       
  8950         }
       
  8951     });
       
  8952     L.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);
       
  8953     L.Marker.Touch = L.Marker.extend({
       
  8954         _initInteraction: function () {
       
  8955             if (!this.options.clickable) {
       
  8956                 return;
       
  8957             }
       
  8958             var icon = this._icon, events = [
       
  8959                     'dblclick',
       
  8960                     'mousedown',
       
  8961                     'mouseover',
       
  8962                     'mouseout',
       
  8963                     'contextmenu',
       
  8964                     'touchstart',
       
  8965                     'touchend',
       
  8966                     'touchmove'
       
  8967                 ];
       
  8968             if (this._detectIE) {
       
  8969                 events.concat([
       
  8970                     'MSPointerDown',
       
  8971                     'MSPointerUp',
       
  8972                     'MSPointerMove',
       
  8973                     'MSPointerCancel'
       
  8974                 ]);
       
  8975             } else {
       
  8976                 events.concat(['touchcancel']);
       
  8977             }
       
  8978             L.DomUtil.addClass(icon, 'leaflet-clickable');
       
  8979             L.DomEvent.on(icon, 'click', this._onMouseClick, this);
       
  8980             L.DomEvent.on(icon, 'keypress', this._onKeyPress, this);
       
  8981             for (var i = 0; i < events.length; i++) {
       
  8982                 L.DomEvent.on(icon, events[i], this._fireMouseEvent, this);
       
  8983             }
       
  8984             if (L.Handler.MarkerDrag) {
       
  8985                 this.dragging = new L.Handler.MarkerDrag(this);
       
  8986                 if (this.options.draggable) {
       
  8987                     this.dragging.enable();
       
  8988                 }
       
  8989             }
       
  8990         },
       
  8991         _detectIE: function () {
       
  8992             var ua = window.navigator.userAgent;
       
  8993             var msie = ua.indexOf('MSIE ');
       
  8994             if (msie > 0) {
       
  8995                 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
       
  8996             }
       
  8997             var trident = ua.indexOf('Trident/');
       
  8998             if (trident > 0) {
       
  8999                 var rv = ua.indexOf('rv:');
       
  9000                 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
       
  9001             }
       
  9002             var edge = ua.indexOf('Edge/');
       
  9003             if (edge > 0) {
       
  9004                 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
       
  9005             }
       
  9006             return false;
       
  9007         }
       
  9008     });
       
  9009     L.LatLngUtil = {
       
  9010         cloneLatLngs: function (latlngs) {
       
  9011             var clone = [];
       
  9012             for (var i = 0, l = latlngs.length; i < l; i++) {
       
  9013                 clone.push(this.cloneLatLng(latlngs[i]));
       
  9014             }
       
  9015             return clone;
       
  9016         },
       
  9017         cloneLatLng: function (latlng) {
       
  9018             return L.latLng(latlng.lat, latlng.lng);
       
  9019         }
       
  9020     };
       
  9021     L.GeometryUtil = L.extend(L.GeometryUtil || {}, {
       
  9022         geodesicArea: function (latLngs) {
       
  9023             var pointsCount = latLngs.length, area = 0, d2r = L.LatLng.DEG_TO_RAD, p1, p2;
       
  9024             if (pointsCount > 2) {
       
  9025                 for (var i = 0; i < pointsCount; i++) {
       
  9026                     p1 = latLngs[i];
       
  9027                     p2 = latLngs[(i + 1) % pointsCount];
       
  9028                     area += (p2.lng - p1.lng) * d2r * (2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));
       
  9029                 }
       
  9030                 area = area * 6378137 * 6378137 / 2;
       
  9031             }
       
  9032             return Math.abs(area);
       
  9033         },
       
  9034         readableArea: function (area, isMetric) {
       
  9035             var areaStr;
       
  9036             if (isMetric) {
       
  9037                 if (area >= 10000) {
       
  9038                     areaStr = (area * 0.0001).toFixed(2) + ' ha';
       
  9039                 } else {
       
  9040                     areaStr = area.toFixed(2) + ' m&sup2;';
       
  9041                 }
       
  9042             } else {
       
  9043                 area /= 0.836127;
       
  9044                 if (area >= 3097600) {
       
  9045                     areaStr = (area / 3097600).toFixed(2) + ' mi&sup2;';
       
  9046                 } else if (area >= 4840) {
       
  9047                     areaStr = (area / 4840).toFixed(2) + ' acres';
       
  9048                 } else {
       
  9049                     areaStr = Math.ceil(area) + ' yd&sup2;';
       
  9050                 }
       
  9051             }
       
  9052             return areaStr;
       
  9053         },
       
  9054         readableDistance: function (distance, isMetric, useFeet) {
       
  9055             var distanceStr;
       
  9056             if (isMetric) {
       
  9057                 if (distance > 1000) {
       
  9058                     distanceStr = (distance / 1000).toFixed(2) + ' km';
       
  9059                 } else {
       
  9060                     distanceStr = Math.ceil(distance) + ' m';
       
  9061                 }
       
  9062             } else {
       
  9063                 distance *= 1.09361;
       
  9064                 if (distance > 1760) {
       
  9065                     distanceStr = (distance / 1760).toFixed(2) + ' miles';
       
  9066                 } else {
       
  9067                     var suffix = ' yd';
       
  9068                     if (useFeet) {
       
  9069                         distance = distance * 3;
       
  9070                         suffix = ' ft';
       
  9071                     }
       
  9072                     distanceStr = Math.ceil(distance) + suffix;
       
  9073                 }
       
  9074             }
       
  9075             return distanceStr;
       
  9076         }
       
  9077     });
       
  9078     L.Util.extend(L.LineUtil, {
       
  9079         segmentsIntersect: function (p, p1, p2, p3) {
       
  9080             return this._checkCounterclockwise(p, p2, p3) !== this._checkCounterclockwise(p1, p2, p3) && this._checkCounterclockwise(p, p1, p2) !== this._checkCounterclockwise(p, p1, p3);
       
  9081         },
       
  9082         _checkCounterclockwise: function (p, p1, p2) {
       
  9083             return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);
       
  9084         }
       
  9085     });
       
  9086     L.Polyline.include({
       
  9087         intersects: function () {
       
  9088             var points = this._originalPoints, len = points ? points.length : 0, i, p, p1;
       
  9089             if (this._tooFewPointsForIntersection()) {
       
  9090                 return false;
       
  9091             }
       
  9092             for (i = len - 1; i >= 3; i--) {
       
  9093                 p = points[i - 1];
       
  9094                 p1 = points[i];
       
  9095                 if (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {
       
  9096                     return true;
       
  9097                 }
       
  9098             }
       
  9099             return false;
       
  9100         },
       
  9101         newLatLngIntersects: function (latlng, skipFirst) {
       
  9102             if (!this._map) {
       
  9103                 return false;
       
  9104             }
       
  9105             return this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);
       
  9106         },
       
  9107         newPointIntersects: function (newPoint, skipFirst) {
       
  9108             var points = this._originalPoints, len = points ? points.length : 0, lastPoint = points ? points[len - 1] : null, maxIndex = len - 2;
       
  9109             if (this._tooFewPointsForIntersection(1)) {
       
  9110                 return false;
       
  9111             }
       
  9112             return this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);
       
  9113         },
       
  9114         _tooFewPointsForIntersection: function (extraPoints) {
       
  9115             var points = this._originalPoints, len = points ? points.length : 0;
       
  9116             len += extraPoints || 0;
       
  9117             return !this._originalPoints || len <= 3;
       
  9118         },
       
  9119         _lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {
       
  9120             var points = this._originalPoints, p2, p3;
       
  9121             minIndex = minIndex || 0;
       
  9122             for (var j = maxIndex; j > minIndex; j--) {
       
  9123                 p2 = points[j - 1];
       
  9124                 p3 = points[j];
       
  9125                 if (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {
       
  9126                     return true;
       
  9127                 }
       
  9128             }
       
  9129             return false;
       
  9130         }
       
  9131     });
       
  9132     L.Polygon.include({
       
  9133         intersects: function () {
       
  9134             var polylineIntersects, points = this._originalPoints, len, firstPoint, lastPoint, maxIndex;
       
  9135             if (this._tooFewPointsForIntersection()) {
       
  9136                 return false;
       
  9137             }
       
  9138             polylineIntersects = L.Polyline.prototype.intersects.call(this);
       
  9139             if (polylineIntersects) {
       
  9140                 return true;
       
  9141             }
       
  9142             len = points.length;
       
  9143             firstPoint = points[0];
       
  9144             lastPoint = points[len - 1];
       
  9145             maxIndex = len - 2;
       
  9146             return this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);
       
  9147         }
       
  9148     });
       
  9149     L.Control.Draw = L.Control.extend({
       
  9150         options: {
       
  9151             position: 'topleft',
       
  9152             draw: {},
       
  9153             edit: false
       
  9154         },
       
  9155         initialize: function (options) {
       
  9156             if (L.version < '0.7') {
       
  9157                 throw new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');
       
  9158             }
       
  9159             L.Control.prototype.initialize.call(this, options);
       
  9160             var toolbar;
       
  9161             this._toolbars = {};
       
  9162             if (L.DrawToolbar && this.options.draw) {
       
  9163                 toolbar = new L.DrawToolbar(this.options.draw);
       
  9164                 this._toolbars[L.DrawToolbar.TYPE] = toolbar;
       
  9165                 this._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);
       
  9166             }
       
  9167             if (L.EditToolbar && this.options.edit) {
       
  9168                 toolbar = new L.EditToolbar(this.options.edit);
       
  9169                 this._toolbars[L.EditToolbar.TYPE] = toolbar;
       
  9170                 this._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);
       
  9171             }
       
  9172             L.toolbar = this;
       
  9173         },
       
  9174         onAdd: function (map) {
       
  9175             var container = L.DomUtil.create('div', 'leaflet-draw'), addedTopClass = false, topClassName = 'leaflet-draw-toolbar-top', toolbarContainer;
       
  9176             for (var toolbarId in this._toolbars) {
       
  9177                 if (this._toolbars.hasOwnProperty(toolbarId)) {
       
  9178                     toolbarContainer = this._toolbars[toolbarId].addToolbar(map);
       
  9179                     if (toolbarContainer) {
       
  9180                         if (!addedTopClass) {
       
  9181                             if (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {
       
  9182                                 L.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);
       
  9183                             }
       
  9184                             addedTopClass = true;
       
  9185                         }
       
  9186                         container.appendChild(toolbarContainer);
       
  9187                     }
       
  9188                 }
       
  9189             }
       
  9190             return container;
       
  9191         },
       
  9192         onRemove: function () {
       
  9193             for (var toolbarId in this._toolbars) {
       
  9194                 if (this._toolbars.hasOwnProperty(toolbarId)) {
       
  9195                     this._toolbars[toolbarId].removeToolbar();
       
  9196                 }
       
  9197             }
       
  9198         },
       
  9199         setDrawingOptions: function (options) {
       
  9200             for (var toolbarId in this._toolbars) {
       
  9201                 if (this._toolbars[toolbarId] instanceof L.DrawToolbar) {
       
  9202                     this._toolbars[toolbarId].setOptions(options);
       
  9203                 }
       
  9204             }
       
  9205         },
       
  9206         _toolbarEnabled: function (e) {
       
  9207             var enabledToolbar = e.target;
       
  9208             for (var toolbarId in this._toolbars) {
       
  9209                 if (this._toolbars[toolbarId] !== enabledToolbar) {
       
  9210                     this._toolbars[toolbarId].disable();
       
  9211                 }
       
  9212             }
       
  9213         }
       
  9214     });
       
  9215     L.Map.mergeOptions({
       
  9216         drawControlTooltips: true,
       
  9217         drawControl: false
       
  9218     });
       
  9219     L.Map.addInitHook(function () {
       
  9220         if (this.options.drawControl) {
       
  9221             this.drawControl = new L.Control.Draw();
       
  9222             this.addControl(this.drawControl);
       
  9223         }
       
  9224     });
       
  9225     L.Toolbar = L.Class.extend({
       
  9226         includes: [L.Mixin.Events],
       
  9227         initialize: function (options) {
       
  9228             L.setOptions(this, options);
       
  9229             this._modes = {};
       
  9230             this._actionButtons = [];
       
  9231             this._activeMode = null;
       
  9232         },
       
  9233         enabled: function () {
       
  9234             return this._activeMode !== null;
       
  9235         },
       
  9236         disable: function () {
       
  9237             if (!this.enabled()) {
       
  9238                 return;
       
  9239             }
       
  9240             this._activeMode.handler.disable();
       
  9241         },
       
  9242         addToolbar: function (map) {
       
  9243             var container = L.DomUtil.create('div', 'leaflet-draw-section'), buttonIndex = 0, buttonClassPrefix = this._toolbarClass || '', modeHandlers = this.getModeHandlers(map), i;
       
  9244             this._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');
       
  9245             this._map = map;
       
  9246             for (i = 0; i < modeHandlers.length; i++) {
       
  9247                 if (modeHandlers[i].enabled) {
       
  9248                     this._initModeHandler(modeHandlers[i].handler, this._toolbarContainer, buttonIndex++, buttonClassPrefix, modeHandlers[i].title);
       
  9249                 }
       
  9250             }
       
  9251             if (!buttonIndex) {
       
  9252                 return;
       
  9253             }
       
  9254             this._lastButtonIndex = --buttonIndex;
       
  9255             this._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');
       
  9256             container.appendChild(this._toolbarContainer);
       
  9257             container.appendChild(this._actionsContainer);
       
  9258             return container;
       
  9259         },
       
  9260         removeToolbar: function () {
       
  9261             for (var handlerId in this._modes) {
       
  9262                 if (this._modes.hasOwnProperty(handlerId)) {
       
  9263                     this._disposeButton(this._modes[handlerId].button, this._modes[handlerId].handler.enable, this._modes[handlerId].handler);
       
  9264                     this._modes[handlerId].handler.disable();
       
  9265                     this._modes[handlerId].handler.off('enabled', this._handlerActivated, this).off('disabled', this._handlerDeactivated, this);
       
  9266                 }
       
  9267             }
       
  9268             this._modes = {};
       
  9269             for (var i = 0, l = this._actionButtons.length; i < l; i++) {
       
  9270                 this._disposeButton(this._actionButtons[i].button, this._actionButtons[i].callback, this);
       
  9271             }
       
  9272             this._actionButtons = [];
       
  9273             this._actionsContainer = null;
       
  9274         },
       
  9275         _initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {
       
  9276             var type = handler.type;
       
  9277             this._modes[type] = {};
       
  9278             this._modes[type].handler = handler;
       
  9279             this._modes[type].button = this._createButton({
       
  9280                 type: type,
       
  9281                 title: buttonTitle,
       
  9282                 className: classNamePredix + '-' + type,
       
  9283                 container: container,
       
  9284                 callback: this._modes[type].handler.enable,
       
  9285                 context: this._modes[type].handler
       
  9286             });
       
  9287             this._modes[type].buttonIndex = buttonIndex;
       
  9288             this._modes[type].handler.on('enabled', this._handlerActivated, this).on('disabled', this._handlerDeactivated, this);
       
  9289         },
       
  9290         _createButton: function (options) {
       
  9291             var link = L.DomUtil.create('a', options.className || '', options.container);
       
  9292             link.href = '#';
       
  9293             if (options.text) {
       
  9294                 link.innerHTML = options.text;
       
  9295             }
       
  9296             if (options.title) {
       
  9297                 link.title = options.title;
       
  9298             }
       
  9299             L.DomEvent.on(link, 'click', L.DomEvent.stopPropagation).on(link, 'mousedown', L.DomEvent.stopPropagation).on(link, 'dblclick', L.DomEvent.stopPropagation).on(link, 'click', L.DomEvent.preventDefault).on(link, 'click', options.callback, options.context);
       
  9300             return link;
       
  9301         },
       
  9302         _disposeButton: function (button, callback) {
       
  9303             L.DomEvent.off(button, 'click', L.DomEvent.stopPropagation).off(button, 'mousedown', L.DomEvent.stopPropagation).off(button, 'dblclick', L.DomEvent.stopPropagation).off(button, 'click', L.DomEvent.preventDefault).off(button, 'click', callback);
       
  9304         },
       
  9305         _handlerActivated: function (e) {
       
  9306             this.disable();
       
  9307             this._activeMode = this._modes[e.handler];
       
  9308             L.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');
       
  9309             this._showActionsToolbar();
       
  9310             this.fire('enable');
       
  9311         },
       
  9312         _handlerDeactivated: function () {
       
  9313             this._hideActionsToolbar();
       
  9314             L.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');
       
  9315             this._activeMode = null;
       
  9316             this.fire('disable');
       
  9317         },
       
  9318         _createActions: function (handler) {
       
  9319             var container = this._actionsContainer, buttons = this.getActions(handler), l = buttons.length, li, di, dl, button;
       
  9320             for (di = 0, dl = this._actionButtons.length; di < dl; di++) {
       
  9321                 this._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);
       
  9322             }
       
  9323             this._actionButtons = [];
       
  9324             while (container.firstChild) {
       
  9325                 container.removeChild(container.firstChild);
       
  9326             }
       
  9327             for (var i = 0; i < l; i++) {
       
  9328                 if ('enabled' in buttons[i] && !buttons[i].enabled) {
       
  9329                     continue;
       
  9330                 }
       
  9331                 li = L.DomUtil.create('li', '', container);
       
  9332                 button = this._createButton({
       
  9333                     title: buttons[i].title,
       
  9334                     text: buttons[i].text,
       
  9335                     container: li,
       
  9336                     callback: buttons[i].callback,
       
  9337                     context: buttons[i].context
       
  9338                 });
       
  9339                 this._actionButtons.push({
       
  9340                     button: button,
       
  9341                     callback: buttons[i].callback
       
  9342                 });
       
  9343             }
       
  9344         },
       
  9345         _showActionsToolbar: function () {
       
  9346             var buttonIndex = this._activeMode.buttonIndex, lastButtonIndex = this._lastButtonIndex, toolbarPosition = this._activeMode.button.offsetTop - 1;
       
  9347             this._createActions(this._activeMode.handler);
       
  9348             this._actionsContainer.style.top = toolbarPosition + 'px';
       
  9349             if (buttonIndex === 0) {
       
  9350                 L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');
       
  9351                 L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');
       
  9352             }
       
  9353             if (buttonIndex === lastButtonIndex) {
       
  9354                 L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');
       
  9355                 L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');
       
  9356             }
       
  9357             this._actionsContainer.style.display = 'block';
       
  9358         },
       
  9359         _hideActionsToolbar: function () {
       
  9360             this._actionsContainer.style.display = 'none';
       
  9361             L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');
       
  9362             L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');
       
  9363             L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');
       
  9364             L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');
       
  9365         }
       
  9366     });
       
  9367     L.Tooltip = L.Class.extend({
       
  9368         initialize: function (map) {
       
  9369             this._map = map;
       
  9370             this._popupPane = map._panes.popupPane;
       
  9371             this._container = map.options.drawControlTooltips ? L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;
       
  9372             this._singleLineLabel = false;
       
  9373             this._map.on('mouseout', this._onMouseOut, this);
       
  9374         },
       
  9375         dispose: function () {
       
  9376             this._map.off('mouseout', this._onMouseOut, this);
       
  9377             if (this._container) {
       
  9378                 this._popupPane.removeChild(this._container);
       
  9379                 this._container = null;
       
  9380             }
       
  9381         },
       
  9382         updateContent: function (labelText) {
       
  9383             if (!this._container) {
       
  9384                 return this;
       
  9385             }
       
  9386             labelText.subtext = labelText.subtext || '';
       
  9387             if (labelText.subtext.length === 0 && !this._singleLineLabel) {
       
  9388                 L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');
       
  9389                 this._singleLineLabel = true;
       
  9390             } else if (labelText.subtext.length > 0 && this._singleLineLabel) {
       
  9391                 L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');
       
  9392                 this._singleLineLabel = false;
       
  9393             }
       
  9394             this._container.innerHTML = (labelText.subtext.length > 0 ? '<span class="leaflet-draw-tooltip-subtext">' + labelText.subtext + '</span>' + '<br />' : '') + '<span>' + labelText.text + '</span>';
       
  9395             return this;
       
  9396         },
       
  9397         updatePosition: function (latlng) {
       
  9398             var pos = this._map.latLngToLayerPoint(latlng), tooltipContainer = this._container;
       
  9399             if (this._container) {
       
  9400                 tooltipContainer.style.visibility = 'inherit';
       
  9401                 L.DomUtil.setPosition(tooltipContainer, pos);
       
  9402             }
       
  9403             return this;
       
  9404         },
       
  9405         showAsError: function () {
       
  9406             if (this._container) {
       
  9407                 L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');
       
  9408             }
       
  9409             return this;
       
  9410         },
       
  9411         removeError: function () {
       
  9412             if (this._container) {
       
  9413                 L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');
       
  9414             }
       
  9415             return this;
       
  9416         },
       
  9417         _onMouseOut: function () {
       
  9418             if (this._container) {
       
  9419                 this._container.style.visibility = 'hidden';
       
  9420             }
       
  9421         }
       
  9422     });
       
  9423     L.DrawToolbar = L.Toolbar.extend({
       
  9424         statics: { TYPE: 'draw' },
       
  9425         options: {
       
  9426             polyline: {},
       
  9427             polygon: {},
       
  9428             rectangle: {},
       
  9429             circle: {},
       
  9430             marker: {}
       
  9431         },
       
  9432         initialize: function (options) {
       
  9433             for (var type in this.options) {
       
  9434                 if (this.options.hasOwnProperty(type)) {
       
  9435                     if (options[type]) {
       
  9436                         options[type] = L.extend({}, this.options[type], options[type]);
       
  9437                     }
       
  9438                 }
       
  9439             }
       
  9440             this._toolbarClass = 'leaflet-draw-draw';
       
  9441             L.Toolbar.prototype.initialize.call(this, options);
       
  9442         },
       
  9443         getModeHandlers: function (map) {
       
  9444             return [
       
  9445                 {
       
  9446                     enabled: this.options.polyline,
       
  9447                     handler: new L.Draw.Polyline(map, this.options.polyline),
       
  9448                     title: L.drawLocal.draw.toolbar.buttons.polyline
       
  9449                 },
       
  9450                 {
       
  9451                     enabled: this.options.polygon,
       
  9452                     handler: new L.Draw.Polygon(map, this.options.polygon),
       
  9453                     title: L.drawLocal.draw.toolbar.buttons.polygon
       
  9454                 },
       
  9455                 {
       
  9456                     enabled: this.options.rectangle,
       
  9457                     handler: new L.Draw.Rectangle(map, this.options.rectangle),
       
  9458                     title: L.drawLocal.draw.toolbar.buttons.rectangle
       
  9459                 },
       
  9460                 {
       
  9461                     enabled: this.options.circle,
       
  9462                     handler: new L.Draw.Circle(map, this.options.circle),
       
  9463                     title: L.drawLocal.draw.toolbar.buttons.circle
       
  9464                 },
       
  9465                 {
       
  9466                     enabled: this.options.marker,
       
  9467                     handler: new L.Draw.Marker(map, this.options.marker),
       
  9468                     title: L.drawLocal.draw.toolbar.buttons.marker
       
  9469                 }
       
  9470             ];
       
  9471         },
       
  9472         getActions: function (handler) {
       
  9473             return [
       
  9474                 {
       
  9475                     enabled: handler.completeShape,
       
  9476                     title: L.drawLocal.draw.toolbar.finish.title,
       
  9477                     text: L.drawLocal.draw.toolbar.finish.text,
       
  9478                     callback: handler.completeShape,
       
  9479                     context: handler
       
  9480                 },
       
  9481                 {
       
  9482                     enabled: handler.deleteLastVertex,
       
  9483                     title: L.drawLocal.draw.toolbar.undo.title,
       
  9484                     text: L.drawLocal.draw.toolbar.undo.text,
       
  9485                     callback: handler.deleteLastVertex,
       
  9486                     context: handler
       
  9487                 },
       
  9488                 {
       
  9489                     title: L.drawLocal.draw.toolbar.actions.title,
       
  9490                     text: L.drawLocal.draw.toolbar.actions.text,
       
  9491                     callback: this.disable,
       
  9492                     context: this
       
  9493                 }
       
  9494             ];
       
  9495         },
       
  9496         setOptions: function (options) {
       
  9497             L.setOptions(this, options);
       
  9498             for (var type in this._modes) {
       
  9499                 if (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {
       
  9500                     this._modes[type].handler.setOptions(options[type]);
       
  9501                 }
       
  9502             }
       
  9503         }
       
  9504     });
       
  9505     L.EditToolbar = L.Toolbar.extend({
       
  9506         statics: { TYPE: 'edit' },
       
  9507         options: {
       
  9508             edit: {
       
  9509                 selectedPathOptions: {
       
  9510                     dashArray: '10, 10',
       
  9511                     fill: true,
       
  9512                     fillColor: '#fe57a1',
       
  9513                     fillOpacity: 0.1,
       
  9514                     maintainColor: false
       
  9515                 }
       
  9516             },
       
  9517             remove: {},
       
  9518             featureGroup: null
       
  9519         },
       
  9520         initialize: function (options) {
       
  9521             if (options.edit) {
       
  9522                 if (typeof options.edit.selectedPathOptions === 'undefined') {
       
  9523                     options.edit.selectedPathOptions = this.options.edit.selectedPathOptions;
       
  9524                 }
       
  9525                 options.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);
       
  9526             }
       
  9527             if (options.remove) {
       
  9528                 options.remove = L.extend({}, this.options.remove, options.remove);
       
  9529             }
       
  9530             this._toolbarClass = 'leaflet-draw-edit';
       
  9531             L.Toolbar.prototype.initialize.call(this, options);
       
  9532             this._selectedFeatureCount = 0;
       
  9533         },
       
  9534         getModeHandlers: function (map) {
       
  9535             var featureGroup = this.options.featureGroup;
       
  9536             return [
       
  9537                 {
       
  9538                     enabled: this.options.edit,
       
  9539                     handler: new L.EditToolbar.Edit(map, {
       
  9540                         featureGroup: featureGroup,
       
  9541                         selectedPathOptions: this.options.edit.selectedPathOptions
       
  9542                     }),
       
  9543                     title: L.drawLocal.edit.toolbar.buttons.edit
       
  9544                 },
       
  9545                 {
       
  9546                     enabled: this.options.remove,
       
  9547                     handler: new L.EditToolbar.Delete(map, { featureGroup: featureGroup }),
       
  9548                     title: L.drawLocal.edit.toolbar.buttons.remove
       
  9549                 }
       
  9550             ];
       
  9551         },
       
  9552         getActions: function () {
       
  9553             return [
       
  9554                 {
       
  9555                     title: L.drawLocal.edit.toolbar.actions.save.title,
       
  9556                     text: L.drawLocal.edit.toolbar.actions.save.text,
       
  9557                     callback: this._save,
       
  9558                     context: this
       
  9559                 },
       
  9560                 {
       
  9561                     title: L.drawLocal.edit.toolbar.actions.cancel.title,
       
  9562                     text: L.drawLocal.edit.toolbar.actions.cancel.text,
       
  9563                     callback: this.disable,
       
  9564                     context: this
       
  9565                 }
       
  9566             ];
       
  9567         },
       
  9568         addToolbar: function (map) {
       
  9569             var container = L.Toolbar.prototype.addToolbar.call(this, map);
       
  9570             this._checkDisabled();
       
  9571             this.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);
       
  9572             return container;
       
  9573         },
       
  9574         removeToolbar: function () {
       
  9575             this.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);
       
  9576             L.Toolbar.prototype.removeToolbar.call(this);
       
  9577         },
       
  9578         disable: function () {
       
  9579             if (!this.enabled()) {
       
  9580                 return;
       
  9581             }
       
  9582             this._activeMode.handler.revertLayers();
       
  9583             L.Toolbar.prototype.disable.call(this);
       
  9584         },
       
  9585         _save: function () {
       
  9586             this._activeMode.handler.save();
       
  9587             this._activeMode.handler.disable();
       
  9588         },
       
  9589         _checkDisabled: function () {
       
  9590             var featureGroup = this.options.featureGroup, hasLayers = featureGroup.getLayers().length !== 0, button;
       
  9591             if (this.options.edit) {
       
  9592                 button = this._modes[L.EditToolbar.Edit.TYPE].button;
       
  9593                 if (hasLayers) {
       
  9594                     L.DomUtil.removeClass(button, 'leaflet-disabled');
       
  9595                 } else {
       
  9596                     L.DomUtil.addClass(button, 'leaflet-disabled');
       
  9597                 }
       
  9598                 button.setAttribute('title', hasLayers ? L.drawLocal.edit.toolbar.buttons.edit : L.drawLocal.edit.toolbar.buttons.editDisabled);
       
  9599             }
       
  9600             if (this.options.remove) {
       
  9601                 button = this._modes[L.EditToolbar.Delete.TYPE].button;
       
  9602                 if (hasLayers) {
       
  9603                     L.DomUtil.removeClass(button, 'leaflet-disabled');
       
  9604                 } else {
       
  9605                     L.DomUtil.addClass(button, 'leaflet-disabled');
       
  9606                 }
       
  9607                 button.setAttribute('title', hasLayers ? L.drawLocal.edit.toolbar.buttons.remove : L.drawLocal.edit.toolbar.buttons.removeDisabled);
       
  9608             }
       
  9609         }
       
  9610     });
       
  9611     L.EditToolbar.Edit = L.Handler.extend({
       
  9612         statics: { TYPE: 'edit' },
       
  9613         includes: L.Mixin.Events,
       
  9614         initialize: function (map, options) {
       
  9615             L.Handler.prototype.initialize.call(this, map);
       
  9616             L.setOptions(this, options);
       
  9617             this._featureGroup = options.featureGroup;
       
  9618             if (!(this._featureGroup instanceof L.FeatureGroup)) {
       
  9619                 throw new Error('options.featureGroup must be a L.FeatureGroup');
       
  9620             }
       
  9621             this._uneditedLayerProps = {};
       
  9622             this.type = L.EditToolbar.Edit.TYPE;
       
  9623         },
       
  9624         enable: function () {
       
  9625             if (this._enabled || !this._hasAvailableLayers()) {
       
  9626                 return;
       
  9627             }
       
  9628             this.fire('enabled', { handler: this.type });
       
  9629             this._map.fire('draw:editstart', { handler: this.type });
       
  9630             L.Handler.prototype.enable.call(this);
       
  9631             this._featureGroup.on('layeradd', this._enableLayerEdit, this).on('layerremove', this._disableLayerEdit, this);
       
  9632         },
       
  9633         disable: function () {
       
  9634             if (!this._enabled) {
       
  9635                 return;
       
  9636             }
       
  9637             this._featureGroup.off('layeradd', this._enableLayerEdit, this).off('layerremove', this._disableLayerEdit, this);
       
  9638             L.Handler.prototype.disable.call(this);
       
  9639             this._map.fire('draw:editstop', { handler: this.type });
       
  9640             this.fire('disabled', { handler: this.type });
       
  9641         },
       
  9642         addHooks: function () {
       
  9643             var map = this._map;
       
  9644             if (map) {
       
  9645                 map.getContainer().focus();
       
  9646                 this._featureGroup.eachLayer(this._enableLayerEdit, this);
       
  9647                 this._tooltip = new L.Tooltip(this._map);
       
  9648                 this._updateTooltip();
       
  9649                 this._map.on('mousemove', this._onMouseMove, this).on('touchmove', this._onMouseMove, this).on('MSPointerMove', this._onMouseMove, this).on('click', this._editStyle, this).on('draw:editvertex', this._updateTooltip, this);
       
  9650             }
       
  9651         },
       
  9652         removeHooks: function () {
       
  9653             if (this._map) {
       
  9654                 this._featureGroup.eachLayer(this._disableLayerEdit, this);
       
  9655                 this._uneditedLayerProps = {};
       
  9656                 this._tooltip.dispose();
       
  9657                 this._tooltip = null;
       
  9658                 this._map.off('mousemove', this._onMouseMove, this).off('touchmove', this._onMouseMove, this).off('MSPointerMove', this._onMouseMove, this);
       
  9659             }
       
  9660         },
       
  9661         revertLayers: function () {
       
  9662             this._featureGroup.eachLayer(function (layer) {
       
  9663                 this._revertLayer(layer);
       
  9664             }, this);
       
  9665         },
       
  9666         save: function () {
       
  9667             var editedLayers = new L.LayerGroup();
       
  9668             this._featureGroup.eachLayer(function (layer) {
       
  9669                 if (layer.edited) {
       
  9670                     editedLayers.addLayer(layer);
       
  9671                     layer.edited = false;
       
  9672                 }
       
  9673             });
       
  9674             this._map.fire('draw:edited', { layers: editedLayers });
       
  9675         },
       
  9676         _backupLayer: function (layer) {
       
  9677             var id = L.Util.stamp(layer);
       
  9678             if (!this._uneditedLayerProps[id]) {
       
  9679                 if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {
       
  9680                     this._uneditedLayerProps[id] = { latlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs()) };
       
  9681                 } else if (layer instanceof L.Circle) {
       
  9682                     this._uneditedLayerProps[id] = {
       
  9683                         latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),
       
  9684                         radius: layer.getRadius()
       
  9685                     };
       
  9686                 } else if (layer instanceof L.Marker) {
       
  9687                     this._uneditedLayerProps[id] = { latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()) };
       
  9688                 }
       
  9689             }
       
  9690         },
       
  9691         _getTooltipText: function () {
       
  9692             return {
       
  9693                 text: L.drawLocal.edit.handlers.edit.tooltip.text,
       
  9694                 subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
       
  9695             };
       
  9696         },
       
  9697         _updateTooltip: function () {
       
  9698             this._tooltip.updateContent(this._getTooltipText());
       
  9699         },
       
  9700         _revertLayer: function (layer) {
       
  9701             var id = L.Util.stamp(layer);
       
  9702             layer.edited = false;
       
  9703             if (this._uneditedLayerProps.hasOwnProperty(id)) {
       
  9704                 if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {
       
  9705                     layer.setLatLngs(this._uneditedLayerProps[id].latlngs);
       
  9706                 } else if (layer instanceof L.Circle) {
       
  9707                     layer.setLatLng(this._uneditedLayerProps[id].latlng);
       
  9708                     layer.setRadius(this._uneditedLayerProps[id].radius);
       
  9709                 } else if (layer instanceof L.Marker) {
       
  9710                     layer.setLatLng(this._uneditedLayerProps[id].latlng);
       
  9711                 }
       
  9712                 layer.fire('revert-edited', { layer: layer });
       
  9713             }
       
  9714         },
       
  9715         _enableLayerEdit: function (e) {
       
  9716             var layer = e.layer || e.target || e, pathOptions;
       
  9717             this._backupLayer(layer);
       
  9718             if (this.options.selectedPathOptions) {
       
  9719                 pathOptions = L.Util.extend({}, this.options.selectedPathOptions);
       
  9720                 if (pathOptions.maintainColor) {
       
  9721                     pathOptions.color = layer.options.color;
       
  9722                     pathOptions.fillColor = layer.options.fillColor;
       
  9723                 }
       
  9724                 layer.options.original = L.extend({}, layer.options);
       
  9725                 layer.options.editing = pathOptions;
       
  9726             }
       
  9727             if (this.isMarker) {
       
  9728                 layer.dragging.enable();
       
  9729                 layer.on('dragend', this._onMarkerDragEnd).on('touchmove', this._onTouchMove, this).on('MSPointerMove', this._onTouchMove, this).on('touchend', this._onMarkerDragEnd, this).on('MSPointerUp', this._onMarkerDragEnd, this);
       
  9730             } else {
       
  9731                 layer.editing.enable();
       
  9732             }
       
  9733         },
       
  9734         _disableLayerEdit: function (e) {
       
  9735             var layer = e.layer || e.target || e;
       
  9736             layer.edited = false;
       
  9737             layer.editing.disable();
       
  9738             delete layer.options.editing;
       
  9739             delete layer.options.original;
       
  9740             if (this._selectedPathOptions) {
       
  9741                 if (layer instanceof L.Marker) {
       
  9742                     this._toggleMarkerHighlight(layer);
       
  9743                 } else {
       
  9744                     layer.setStyle(layer.options.previousOptions);
       
  9745                     delete layer.options.previousOptions;
       
  9746                 }
       
  9747             }
       
  9748             if (layer instanceof L.Marker) {
       
  9749                 layer.dragging.disable();
       
  9750                 layer.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);
       
  9751             } else {
       
  9752                 layer.editing.disable();
       
  9753             }
       
  9754         },
       
  9755         _onMouseMove: function (e) {
       
  9756             this._tooltip.updatePosition(e.latlng);
       
  9757         },
       
  9758         _onTouchMove: function (e) {
       
  9759             var touchEvent = e.originalEvent.changedTouches[0], layerPoint = this._map.mouseEventToLayerPoint(touchEvent), latlng = this._map.layerPointToLatLng(layerPoint);
       
  9760             e.target.setLatLng(latlng);
       
  9761         },
       
  9762         _hasAvailableLayers: function () {
       
  9763             return this._featureGroup.getLayers().length !== 0;
       
  9764         }
       
  9765     });
       
  9766     L.EditToolbar.Delete = L.Handler.extend({
       
  9767         statics: { TYPE: 'remove' },
       
  9768         includes: L.Mixin.Events,
       
  9769         initialize: function (map, options) {
       
  9770             L.Handler.prototype.initialize.call(this, map);
       
  9771             L.Util.setOptions(this, options);
       
  9772             this._deletableLayers = this.options.featureGroup;
       
  9773             if (!(this._deletableLayers instanceof L.FeatureGroup)) {
       
  9774                 throw new Error('options.featureGroup must be a L.FeatureGroup');
       
  9775             }
       
  9776             this.type = L.EditToolbar.Delete.TYPE;
       
  9777         },
       
  9778         enable: function () {
       
  9779             if (this._enabled || !this._hasAvailableLayers()) {
       
  9780                 return;
       
  9781             }
       
  9782             this.fire('enabled', { handler: this.type });
       
  9783             this._map.fire('draw:deletestart', { handler: this.type });
       
  9784             L.Handler.prototype.enable.call(this);
       
  9785             this._deletableLayers.on('layeradd', this._enableLayerDelete, this).on('layerremove', this._disableLayerDelete, this);
       
  9786         },
       
  9787         disable: function () {
       
  9788             if (!this._enabled) {
       
  9789                 return;
       
  9790             }
       
  9791             this._deletableLayers.off('layeradd', this._enableLayerDelete, this).off('layerremove', this._disableLayerDelete, this);
       
  9792             L.Handler.prototype.disable.call(this);
       
  9793             this._map.fire('draw:deletestop', { handler: this.type });
       
  9794             this.fire('disabled', { handler: this.type });
       
  9795         },
       
  9796         addHooks: function () {
       
  9797             var map = this._map;
       
  9798             if (map) {
       
  9799                 map.getContainer().focus();
       
  9800                 this._deletableLayers.eachLayer(this._enableLayerDelete, this);
       
  9801                 this._deletedLayers = new L.LayerGroup();
       
  9802                 this._tooltip = new L.Tooltip(this._map);
       
  9803                 this._tooltip.updateContent({ text: L.drawLocal.edit.handlers.remove.tooltip.text });
       
  9804                 this._map.on('mousemove', this._onMouseMove, this);
       
  9805             }
       
  9806         },
       
  9807         removeHooks: function () {
       
  9808             if (this._map) {
       
  9809                 this._deletableLayers.eachLayer(this._disableLayerDelete, this);
       
  9810                 this._deletedLayers = null;
       
  9811                 this._tooltip.dispose();
       
  9812                 this._tooltip = null;
       
  9813                 this._map.off('mousemove', this._onMouseMove, this);
       
  9814             }
       
  9815         },
       
  9816         revertLayers: function () {
       
  9817             this._deletedLayers.eachLayer(function (layer) {
       
  9818                 this._deletableLayers.addLayer(layer);
       
  9819                 layer.fire('revert-deleted', { layer: layer });
       
  9820             }, this);
       
  9821         },
       
  9822         save: function () {
       
  9823             this._map.fire('draw:deleted', { layers: this._deletedLayers });
       
  9824         },
       
  9825         _enableLayerDelete: function (e) {
       
  9826             var layer = e.layer || e.target || e;
       
  9827             layer.on('click', this._removeLayer, this);
       
  9828         },
       
  9829         _disableLayerDelete: function (e) {
       
  9830             var layer = e.layer || e.target || e;
       
  9831             layer.off('click', this._removeLayer, this);
       
  9832             this._deletedLayers.removeLayer(layer);
       
  9833         },
       
  9834         _removeLayer: function (e) {
       
  9835             var layer = e.layer || e.target || e;
       
  9836             this._deletableLayers.removeLayer(layer);
       
  9837             this._deletedLayers.addLayer(layer);
       
  9838             layer.fire('deleted');
       
  9839         },
       
  9840         _onMouseMove: function (e) {
       
  9841             this._tooltip.updatePosition(e.latlng);
       
  9842         },
       
  9843         _hasAvailableLayers: function () {
       
  9844             return this._deletableLayers.getLayers().length !== 0;
       
  9845         }
       
  9846     });
       
  9847 }(window, document));
       
  9848 leafletDraw = undefined;
       
  9849 (function (factory) {
       
  9850     'use strict';
       
  9851     if (true) {
       
  9852         sortable = function () {
       
  9853             return typeof factory === 'function' ? factory() : factory;
       
  9854         }();
       
  9855     } else if (typeof module != 'undefined' && typeof module.exports != 'undefined') {
       
  9856         module.exports = factory();
       
  9857     } else if (typeof Package !== 'undefined') {
       
  9858         Sortable = factory();
       
  9859     } else {
       
  9860         window['Sortable'] = factory();
       
  9861     }
       
  9862 }(function () {
       
  9863     'use strict';
       
  9864     if (typeof window == 'undefined' || typeof window.document == 'undefined') {
       
  9865         return function () {
       
  9866             throw new Error('Sortable.js requires a window with a document');
       
  9867         };
       
  9868     }
       
  9869     var dragEl, parentEl, ghostEl, cloneEl, rootEl, nextEl, scrollEl, scrollParentEl, lastEl, lastCSS, lastParentCSS, oldIndex, newIndex, activeGroup, autoScroll = {}, tapEvt, touchEvt, moved, RSPACE = /\s+/g, expando = 'Sortable' + new Date().getTime(), win = window, document = win.document, parseInt = win.parseInt, supportDraggable = !!('draggable' in document.createElement('div')), supportCssPointerEvents = function (el) {
       
  9870             el = document.createElement('x');
       
  9871             el.style.cssText = 'pointer-events:auto';
       
  9872             return el.style.pointerEvents === 'auto';
       
  9873         }(), _silent = false, abs = Math.abs, slice = [].slice, touchDragOverListeners = [], _autoScroll = _throttle(function (evt, options, rootEl) {
       
  9874             if (rootEl && options.scroll) {
       
  9875                 var el, rect, sens = options.scrollSensitivity, speed = options.scrollSpeed, x = evt.clientX, y = evt.clientY, winWidth = window.innerWidth, winHeight = window.innerHeight, vx, vy;
       
  9876                 if (scrollParentEl !== rootEl) {
       
  9877                     scrollEl = options.scroll;
       
  9878                     scrollParentEl = rootEl;
       
  9879                     if (scrollEl === true) {
       
  9880                         scrollEl = rootEl;
       
  9881                         do {
       
  9882                             if (scrollEl.offsetWidth < scrollEl.scrollWidth || scrollEl.offsetHeight < scrollEl.scrollHeight) {
       
  9883                                 break;
       
  9884                             }
       
  9885                         } while (scrollEl = scrollEl.parentNode);
       
  9886                     }
       
  9887                 }
       
  9888                 if (scrollEl) {
       
  9889                     el = scrollEl;
       
  9890                     rect = scrollEl.getBoundingClientRect();
       
  9891                     vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens);
       
  9892                     vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens);
       
  9893                 }
       
  9894                 if (!(vx || vy)) {
       
  9895                     vx = (winWidth - x <= sens) - (x <= sens);
       
  9896                     vy = (winHeight - y <= sens) - (y <= sens);
       
  9897                     (vx || vy) && (el = win);
       
  9898                 }
       
  9899                 if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) {
       
  9900                     autoScroll.el = el;
       
  9901                     autoScroll.vx = vx;
       
  9902                     autoScroll.vy = vy;
       
  9903                     clearInterval(autoScroll.pid);
       
  9904                     if (el) {
       
  9905                         autoScroll.pid = setInterval(function () {
       
  9906                             if (el === win) {
       
  9907                                 win.scrollTo(win.pageXOffset + vx * speed, win.pageYOffset + vy * speed);
       
  9908                             } else {
       
  9909                                 vy && (el.scrollTop += vy * speed);
       
  9910                                 vx && (el.scrollLeft += vx * speed);
       
  9911                             }
       
  9912                         }, 24);
       
  9913                     }
       
  9914                 }
       
  9915             }
       
  9916         }, 30), _prepareGroup = function (options) {
       
  9917             var group = options.group;
       
  9918             if (!group || typeof group != 'object') {
       
  9919                 group = options.group = { name: group };
       
  9920             }
       
  9921             [
       
  9922                 'pull',
       
  9923                 'put'
       
  9924             ].forEach(function (key) {
       
  9925                 if (!(key in group)) {
       
  9926                     group[key] = true;
       
  9927                 }
       
  9928             });
       
  9929             options.groups = ' ' + group.name + (group.put.join ? ' ' + group.put.join(' ') : '') + ' ';
       
  9930         };
       
  9931     function Sortable(el, options) {
       
  9932         if (!(el && el.nodeType && el.nodeType === 1)) {
       
  9933             throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el);
       
  9934         }
       
  9935         this.el = el;
       
  9936         this.options = options = _extend({}, options);
       
  9937         el[expando] = this;
       
  9938         var defaults = {
       
  9939             group: Math.random(),
       
  9940             sort: true,
       
  9941             disabled: false,
       
  9942             store: null,
       
  9943             handle: null,
       
  9944             scroll: true,
       
  9945             scrollSensitivity: 30,
       
  9946             scrollSpeed: 10,
       
  9947             draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*',
       
  9948             ghostClass: 'sortable-ghost',
       
  9949             chosenClass: 'sortable-chosen',
       
  9950             ignore: 'a, img',
       
  9951             filter: null,
       
  9952             animation: 0,
       
  9953             setData: function (dataTransfer, dragEl) {
       
  9954                 dataTransfer.setData('Text', dragEl.textContent);
       
  9955             },
       
  9956             dropBubble: false,
       
  9957             dragoverBubble: false,
       
  9958             dataIdAttr: 'data-id',
       
  9959             delay: 0,
       
  9960             forceFallback: false,
       
  9961             fallbackClass: 'sortable-fallback',
       
  9962             fallbackOnBody: false
       
  9963         };
       
  9964         for (var name in defaults) {
       
  9965             !(name in options) && (options[name] = defaults[name]);
       
  9966         }
       
  9967         _prepareGroup(options);
       
  9968         for (var fn in this) {
       
  9969             if (fn.charAt(0) === '_') {
       
  9970                 this[fn] = this[fn].bind(this);
       
  9971             }
       
  9972         }
       
  9973         this.nativeDraggable = options.forceFallback ? false : supportDraggable;
       
  9974         _on(el, 'mousedown', this._onTapStart);
       
  9975         _on(el, 'touchstart', this._onTapStart);
       
  9976         if (this.nativeDraggable) {
       
  9977             _on(el, 'dragover', this);
       
  9978             _on(el, 'dragenter', this);
       
  9979         }
       
  9980         touchDragOverListeners.push(this._onDragOver);
       
  9981         options.store && this.sort(options.store.get(this));
       
  9982     }
       
  9983     Sortable.prototype = {
       
  9984         constructor: Sortable,
       
  9985         _onTapStart: function (evt) {
       
  9986             var _this = this, el = this.el, options = this.options, type = evt.type, touch = evt.touches && evt.touches[0], target = (touch || evt).target, originalTarget = target, filter = options.filter;
       
  9987             if (type === 'mousedown' && evt.button !== 0 || options.disabled) {
       
  9988                 return;
       
  9989             }
       
  9990             target = _closest(target, options.draggable, el);
       
  9991             if (!target) {
       
  9992                 return;
       
  9993             }
       
  9994             oldIndex = _index(target, options.draggable);
       
  9995             if (typeof filter === 'function') {
       
  9996                 if (filter.call(this, evt, target, this)) {
       
  9997                     _dispatchEvent(_this, originalTarget, 'filter', target, el, oldIndex);
       
  9998                     evt.preventDefault();
       
  9999                     return;
       
 10000                 }
       
 10001             } else if (filter) {
       
 10002                 filter = filter.split(',').some(function (criteria) {
       
 10003                     criteria = _closest(originalTarget, criteria.trim(), el);
       
 10004                     if (criteria) {
       
 10005                         _dispatchEvent(_this, criteria, 'filter', target, el, oldIndex);
       
 10006                         return true;
       
 10007                     }
       
 10008                 });
       
 10009                 if (filter) {
       
 10010                     evt.preventDefault();
       
 10011                     return;
       
 10012                 }
       
 10013             }
       
 10014             if (options.handle && !_closest(originalTarget, options.handle, el)) {
       
 10015                 return;
       
 10016             }
       
 10017             this._prepareDragStart(evt, touch, target);
       
 10018         },
       
 10019         _prepareDragStart: function (evt, touch, target) {
       
 10020             var _this = this, el = _this.el, options = _this.options, ownerDocument = el.ownerDocument, dragStartFn;
       
 10021             if (target && !dragEl && target.parentNode === el) {
       
 10022                 tapEvt = evt;
       
 10023                 rootEl = el;
       
 10024                 dragEl = target;
       
 10025                 parentEl = dragEl.parentNode;
       
 10026                 nextEl = dragEl.nextSibling;
       
 10027                 activeGroup = options.group;
       
 10028                 dragStartFn = function () {
       
 10029                     _this._disableDelayedDrag();
       
 10030                     dragEl.draggable = true;
       
 10031                     _toggleClass(dragEl, _this.options.chosenClass, true);
       
 10032                     _this._triggerDragStart(touch);
       
 10033                 };
       
 10034                 options.ignore.split(',').forEach(function (criteria) {
       
 10035                     _find(dragEl, criteria.trim(), _disableDraggable);
       
 10036                 });
       
 10037                 _on(ownerDocument, 'mouseup', _this._onDrop);
       
 10038                 _on(ownerDocument, 'touchend', _this._onDrop);
       
 10039                 _on(ownerDocument, 'touchcancel', _this._onDrop);
       
 10040                 if (options.delay) {
       
 10041                     _on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
       
 10042                     _on(ownerDocument, 'touchend', _this._disableDelayedDrag);
       
 10043                     _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
       
 10044                     _on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
       
 10045                     _on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
       
 10046                     _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
       
 10047                 } else {
       
 10048                     dragStartFn();
       
 10049                 }
       
 10050             }
       
 10051         },
       
 10052         _disableDelayedDrag: function () {
       
 10053             var ownerDocument = this.el.ownerDocument;
       
 10054             clearTimeout(this._dragStartTimer);
       
 10055             _off(ownerDocument, 'mouseup', this._disableDelayedDrag);
       
 10056             _off(ownerDocument, 'touchend', this._disableDelayedDrag);
       
 10057             _off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
       
 10058             _off(ownerDocument, 'mousemove', this._disableDelayedDrag);
       
 10059             _off(ownerDocument, 'touchmove', this._disableDelayedDrag);
       
 10060         },
       
 10061         _triggerDragStart: function (touch) {
       
 10062             if (touch) {
       
 10063                 tapEvt = {
       
 10064                     target: dragEl,
       
 10065                     clientX: touch.clientX,
       
 10066                     clientY: touch.clientY
       
 10067                 };
       
 10068                 this._onDragStart(tapEvt, 'touch');
       
 10069             } else if (!this.nativeDraggable) {
       
 10070                 this._onDragStart(tapEvt, true);
       
 10071             } else {
       
 10072                 _on(dragEl, 'dragend', this);
       
 10073                 _on(rootEl, 'dragstart', this._onDragStart);
       
 10074             }
       
 10075             try {
       
 10076                 if (document.selection) {
       
 10077                     document.selection.empty();
       
 10078                 } else {
       
 10079                     window.getSelection().removeAllRanges();
       
 10080                 }
       
 10081             } catch (err) {
       
 10082             }
       
 10083         },
       
 10084         _dragStarted: function () {
       
 10085             if (rootEl && dragEl) {
       
 10086                 _toggleClass(dragEl, this.options.ghostClass, true);
       
 10087                 Sortable.active = this;
       
 10088                 _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, oldIndex);
       
 10089             }
       
 10090         },
       
 10091         _emulateDragOver: function () {
       
 10092             if (touchEvt) {
       
 10093                 if (this._lastX === touchEvt.clientX && this._lastY === touchEvt.clientY) {
       
 10094                     return;
       
 10095                 }
       
 10096                 this._lastX = touchEvt.clientX;
       
 10097                 this._lastY = touchEvt.clientY;
       
 10098                 if (!supportCssPointerEvents) {
       
 10099                     _css(ghostEl, 'display', 'none');
       
 10100                 }
       
 10101                 var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY), parent = target, groupName = ' ' + this.options.group.name + '', i = touchDragOverListeners.length;
       
 10102                 if (parent) {
       
 10103                     do {
       
 10104                         if (parent[expando] && parent[expando].options.groups.indexOf(groupName) > -1) {
       
 10105                             while (i--) {
       
 10106                                 touchDragOverListeners[i]({
       
 10107                                     clientX: touchEvt.clientX,
       
 10108                                     clientY: touchEvt.clientY,
       
 10109                                     target: target,
       
 10110                                     rootEl: parent
       
 10111                                 });
       
 10112                             }
       
 10113                             break;
       
 10114                         }
       
 10115                         target = parent;
       
 10116                     } while (parent = parent.parentNode);
       
 10117                 }
       
 10118                 if (!supportCssPointerEvents) {
       
 10119                     _css(ghostEl, 'display', '');
       
 10120                 }
       
 10121             }
       
 10122         },
       
 10123         _onTouchMove: function (evt) {
       
 10124             if (tapEvt) {
       
 10125                 if (!Sortable.active) {
       
 10126                     this._dragStarted();
       
 10127                 }
       
 10128                 this._appendGhost();
       
 10129                 var touch = evt.touches ? evt.touches[0] : evt, dx = touch.clientX - tapEvt.clientX, dy = touch.clientY - tapEvt.clientY, translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
       
 10130                 moved = true;
       
 10131                 touchEvt = touch;
       
 10132                 _css(ghostEl, 'webkitTransform', translate3d);
       
 10133                 _css(ghostEl, 'mozTransform', translate3d);
       
 10134                 _css(ghostEl, 'msTransform', translate3d);
       
 10135                 _css(ghostEl, 'transform', translate3d);
       
 10136                 evt.preventDefault();
       
 10137             }
       
 10138         },
       
 10139         _appendGhost: function () {
       
 10140             if (!ghostEl) {
       
 10141                 var rect = dragEl.getBoundingClientRect(), css = _css(dragEl), options = this.options, ghostRect;
       
 10142                 ghostEl = dragEl.cloneNode(true);
       
 10143                 _toggleClass(ghostEl, options.ghostClass, false);
       
 10144                 _toggleClass(ghostEl, options.fallbackClass, true);
       
 10145                 _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
       
 10146                 _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
       
 10147                 _css(ghostEl, 'width', rect.width);
       
 10148                 _css(ghostEl, 'height', rect.height);
       
 10149                 _css(ghostEl, 'opacity', '0.8');
       
 10150                 _css(ghostEl, 'position', 'fixed');
       
 10151                 _css(ghostEl, 'zIndex', '100000');
       
 10152                 _css(ghostEl, 'pointerEvents', 'none');
       
 10153                 options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl);
       
 10154                 ghostRect = ghostEl.getBoundingClientRect();
       
 10155                 _css(ghostEl, 'width', rect.width * 2 - ghostRect.width);
       
 10156                 _css(ghostEl, 'height', rect.height * 2 - ghostRect.height);
       
 10157             }
       
 10158         },
       
 10159         _onDragStart: function (evt, useFallback) {
       
 10160             var dataTransfer = evt.dataTransfer, options = this.options;
       
 10161             this._offUpEvents();
       
 10162             if (activeGroup.pull == 'clone') {
       
 10163                 cloneEl = dragEl.cloneNode(true);
       
 10164                 _css(cloneEl, 'display', 'none');
       
 10165                 rootEl.insertBefore(cloneEl, dragEl);
       
 10166             }
       
 10167             if (useFallback) {
       
 10168                 if (useFallback === 'touch') {
       
 10169                     _on(document, 'touchmove', this._onTouchMove);
       
 10170                     _on(document, 'touchend', this._onDrop);
       
 10171                     _on(document, 'touchcancel', this._onDrop);
       
 10172                 } else {
       
 10173                     _on(document, 'mousemove', this._onTouchMove);
       
 10174                     _on(document, 'mouseup', this._onDrop);
       
 10175                 }
       
 10176                 this._loopId = setInterval(this._emulateDragOver, 50);
       
 10177             } else {
       
 10178                 if (dataTransfer) {
       
 10179                     dataTransfer.effectAllowed = 'move';
       
 10180                     options.setData && options.setData.call(this, dataTransfer, dragEl);
       
 10181                 }
       
 10182                 _on(document, 'drop', this);
       
 10183                 setTimeout(this._dragStarted, 0);
       
 10184             }
       
 10185         },
       
 10186         _onDragOver: function (evt) {
       
 10187             var el = this.el, target, dragRect, revert, options = this.options, group = options.group, groupPut = group.put, isOwner = activeGroup === group, canSort = options.sort;
       
 10188             if (evt.preventDefault !== void 0) {
       
 10189                 evt.preventDefault();
       
 10190                 !options.dragoverBubble && evt.stopPropagation();
       
 10191             }
       
 10192             moved = true;
       
 10193             if (activeGroup && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) : activeGroup.pull && groupPut && (activeGroup.name === group.name || groupPut.indexOf && ~groupPut.indexOf(activeGroup.name))) && (evt.rootEl === void 0 || evt.rootEl === this.el)) {
       
 10194                 _autoScroll(evt, options, this.el);
       
 10195                 if (_silent) {
       
 10196                     return;
       
 10197                 }
       
 10198                 target = _closest(evt.target, options.draggable, el);
       
 10199                 dragRect = dragEl.getBoundingClientRect();
       
 10200                 if (revert) {
       
 10201                     _cloneHide(true);
       
 10202                     if (cloneEl || nextEl) {
       
 10203                         rootEl.insertBefore(dragEl, cloneEl || nextEl);
       
 10204                     } else if (!canSort) {
       
 10205                         rootEl.appendChild(dragEl);
       
 10206                     }
       
 10207                     return;
       
 10208                 }
       
 10209                 if (el.children.length === 0 || el.children[0] === ghostEl || el === evt.target && (target = _ghostIsLast(el, evt))) {
       
 10210                     if (target) {
       
 10211                         if (target.animated) {
       
 10212                             return;
       
 10213                         }
       
 10214                         targetRect = target.getBoundingClientRect();
       
 10215                     }
       
 10216                     _cloneHide(isOwner);
       
 10217                     if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect) !== false) {
       
 10218                         if (!dragEl.contains(el)) {
       
 10219                             el.appendChild(dragEl);
       
 10220                             parentEl = el;
       
 10221                         }
       
 10222                         this._animate(dragRect, dragEl);
       
 10223                         target && this._animate(targetRect, target);
       
 10224                     }
       
 10225                 } else if (target && !target.animated && target !== dragEl && target.parentNode[expando] !== void 0) {
       
 10226                     if (lastEl !== target) {
       
 10227                         lastEl = target;
       
 10228                         lastCSS = _css(target);
       
 10229                         lastParentCSS = _css(target.parentNode);
       
 10230                     }
       
 10231                     var targetRect = target.getBoundingClientRect(), width = targetRect.right - targetRect.left, height = targetRect.bottom - targetRect.top, floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) || lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0, isWide = target.offsetWidth > dragEl.offsetWidth, isLong = target.offsetHeight > dragEl.offsetHeight, halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, nextSibling = target.nextElementSibling, moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect), after;
       
 10232                     if (moveVector !== false) {
       
 10233                         _silent = true;
       
 10234                         setTimeout(_unsilent, 30);
       
 10235                         _cloneHide(isOwner);
       
 10236                         if (moveVector === 1 || moveVector === -1) {
       
 10237                             after = moveVector === 1;
       
 10238                         } else if (floating) {
       
 10239                             var elTop = dragEl.offsetTop, tgTop = target.offsetTop;
       
 10240                             if (elTop === tgTop) {
       
 10241                                 after = target.previousElementSibling === dragEl && !isWide || halfway && isWide;
       
 10242                             } else {
       
 10243                                 after = tgTop > elTop;
       
 10244                             }
       
 10245                         } else {
       
 10246                             after = nextSibling !== dragEl && !isLong || halfway && isLong;
       
 10247                         }
       
 10248                         if (!dragEl.contains(el)) {
       
 10249                             if (after && !nextSibling) {
       
 10250                                 el.appendChild(dragEl);
       
 10251                             } else {
       
 10252                                 target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
       
 10253                             }
       
 10254                         }
       
 10255                         parentEl = dragEl.parentNode;
       
 10256                         this._animate(dragRect, dragEl);
       
 10257                         this._animate(targetRect, target);
       
 10258                     }
       
 10259                 }
       
 10260             }
       
 10261         },
       
 10262         _animate: function (prevRect, target) {
       
 10263             var ms = this.options.animation;
       
 10264             if (ms) {
       
 10265                 var currentRect = target.getBoundingClientRect();
       
 10266                 _css(target, 'transition', 'none');
       
 10267                 _css(target, 'transform', 'translate3d(' + (prevRect.left - currentRect.left) + 'px,' + (prevRect.top - currentRect.top) + 'px,0)');
       
 10268                 target.offsetWidth;
       
 10269                 _css(target, 'transition', 'all ' + ms + 'ms');
       
 10270                 _css(target, 'transform', 'translate3d(0,0,0)');
       
 10271                 clearTimeout(target.animated);
       
 10272                 target.animated = setTimeout(function () {
       
 10273                     _css(target, 'transition', '');
       
 10274                     _css(target, 'transform', '');
       
 10275                     target.animated = false;
       
 10276                 }, ms);
       
 10277             }
       
 10278         },
       
 10279         _offUpEvents: function () {
       
 10280             var ownerDocument = this.el.ownerDocument;
       
 10281             _off(document, 'touchmove', this._onTouchMove);
       
 10282             _off(ownerDocument, 'mouseup', this._onDrop);
       
 10283             _off(ownerDocument, 'touchend', this._onDrop);
       
 10284             _off(ownerDocument, 'touchcancel', this._onDrop);
       
 10285         },
       
 10286         _onDrop: function (evt) {
       
 10287             var el = this.el, options = this.options;
       
 10288             clearInterval(this._loopId);
       
 10289             clearInterval(autoScroll.pid);
       
 10290             clearTimeout(this._dragStartTimer);
       
 10291             _off(document, 'mousemove', this._onTouchMove);
       
 10292             if (this.nativeDraggable) {
       
 10293                 _off(document, 'drop', this);
       
 10294                 _off(el, 'dragstart', this._onDragStart);
       
 10295             }
       
 10296             this._offUpEvents();
       
 10297             if (evt) {
       
 10298                 if (moved) {
       
 10299                     evt.preventDefault();
       
 10300                     !options.dropBubble && evt.stopPropagation();
       
 10301                 }
       
 10302                 ghostEl && ghostEl.parentNode.removeChild(ghostEl);
       
 10303                 if (dragEl) {
       
 10304                     if (this.nativeDraggable) {
       
 10305                         _off(dragEl, 'dragend', this);
       
 10306                     }
       
 10307                     _disableDraggable(dragEl);
       
 10308                     _toggleClass(dragEl, this.options.ghostClass, false);
       
 10309                     _toggleClass(dragEl, this.options.chosenClass, false);
       
 10310                     if (rootEl !== parentEl) {
       
 10311                         newIndex = _index(dragEl, options.draggable);
       
 10312                         if (newIndex >= 0) {
       
 10313                             _dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
       
 10314                             _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
       
 10315                             _dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex);
       
 10316                             _dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex);
       
 10317                         }
       
 10318                     } else {
       
 10319                         cloneEl && cloneEl.parentNode.removeChild(cloneEl);
       
 10320                         if (dragEl.nextSibling !== nextEl) {
       
 10321                             newIndex = _index(dragEl, options.draggable);
       
 10322                             if (newIndex >= 0) {
       
 10323                                 _dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex);
       
 10324                                 _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
       
 10325                             }
       
 10326                         }
       
 10327                     }
       
 10328                     if (Sortable.active) {
       
 10329                         if (newIndex === null || newIndex === -1) {
       
 10330                             newIndex = oldIndex;
       
 10331                         }
       
 10332                         _dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex);
       
 10333                         this.save();
       
 10334                     }
       
 10335                 }
       
 10336             }
       
 10337             this._nulling();
       
 10338         },
       
 10339         _nulling: function () {
       
 10340             rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = scrollEl = scrollParentEl = tapEvt = touchEvt = moved = newIndex = lastEl = lastCSS = activeGroup = Sortable.active = null;
       
 10341         },
       
 10342         handleEvent: function (evt) {
       
 10343             var type = evt.type;
       
 10344             if (type === 'dragover' || type === 'dragenter') {
       
 10345                 if (dragEl) {
       
 10346                     this._onDragOver(evt);
       
 10347                     _globalDragOver(evt);
       
 10348                 }
       
 10349             } else if (type === 'drop' || type === 'dragend') {
       
 10350                 this._onDrop(evt);
       
 10351             }
       
 10352         },
       
 10353         toArray: function () {
       
 10354             var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
       
 10355             for (; i < n; i++) {
       
 10356                 el = children[i];
       
 10357                 if (_closest(el, options.draggable, this.el)) {
       
 10358                     order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
       
 10359                 }
       
 10360             }
       
 10361             return order;
       
 10362         },
       
 10363         sort: function (order) {
       
 10364             var items = {}, rootEl = this.el;
       
 10365             this.toArray().forEach(function (id, i) {
       
 10366                 var el = rootEl.children[i];
       
 10367                 if (_closest(el, this.options.draggable, rootEl)) {
       
 10368                     items[id] = el;
       
 10369                 }
       
 10370             }, this);
       
 10371             order.forEach(function (id) {
       
 10372                 if (items[id]) {
       
 10373                     rootEl.removeChild(items[id]);
       
 10374                     rootEl.appendChild(items[id]);
       
 10375                 }
       
 10376             });
       
 10377         },
       
 10378         save: function () {
       
 10379             var store = this.options.store;
       
 10380             store && store.set(this);
       
 10381         },
       
 10382         closest: function (el, selector) {
       
 10383             return _closest(el, selector || this.options.draggable, this.el);
       
 10384         },
       
 10385         option: function (name, value) {
       
 10386             var options = this.options;
       
 10387             if (value === void 0) {
       
 10388                 return options[name];
       
 10389             } else {
       
 10390                 options[name] = value;
       
 10391                 if (name === 'group') {
       
 10392                     _prepareGroup(options);
       
 10393                 }
       
 10394             }
       
 10395         },
       
 10396         destroy: function () {
       
 10397             var el = this.el;
       
 10398             el[expando] = null;
       
 10399             _off(el, 'mousedown', this._onTapStart);
       
 10400             _off(el, 'touchstart', this._onTapStart);
       
 10401             if (this.nativeDraggable) {
       
 10402                 _off(el, 'dragover', this);
       
 10403                 _off(el, 'dragenter', this);
       
 10404             }
       
 10405             Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
       
 10406                 el.removeAttribute('draggable');
       
 10407             });
       
 10408             touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1);
       
 10409             this._onDrop();
       
 10410             this.el = el = null;
       
 10411         }
       
 10412     };
       
 10413     function _cloneHide(state) {
       
 10414         if (cloneEl && cloneEl.state !== state) {
       
 10415             _css(cloneEl, 'display', state ? 'none' : '');
       
 10416             !state && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl);
       
 10417             cloneEl.state = state;
       
 10418         }
       
 10419     }
       
 10420     function _closest(el, selector, ctx) {
       
 10421         if (el) {
       
 10422             ctx = ctx || document;
       
 10423             do {
       
 10424                 if (selector === '>*' && el.parentNode === ctx || _matches(el, selector)) {
       
 10425                     return el;
       
 10426                 }
       
 10427             } while (el !== ctx && (el = el.parentNode));
       
 10428         }
       
 10429         return null;
       
 10430     }
       
 10431     function _globalDragOver(evt) {
       
 10432         if (evt.dataTransfer) {
       
 10433             evt.dataTransfer.dropEffect = 'move';
       
 10434         }
       
 10435         evt.preventDefault();
       
 10436     }
       
 10437     function _on(el, event, fn) {
       
 10438         el.addEventListener(event, fn, false);
       
 10439     }
       
 10440     function _off(el, event, fn) {
       
 10441         el.removeEventListener(event, fn, false);
       
 10442     }
       
 10443     function _toggleClass(el, name, state) {
       
 10444         if (el) {
       
 10445             if (el.classList) {
       
 10446                 el.classList[state ? 'add' : 'remove'](name);
       
 10447             } else {
       
 10448                 var className = (' ' + el.className + ' ').replace(RSPACE, ' ').replace(' ' + name + ' ', ' ');
       
 10449                 el.className = (className + (state ? ' ' + name : '')).replace(RSPACE, ' ');
       
 10450             }
       
 10451         }
       
 10452     }
       
 10453     function _css(el, prop, val) {
       
 10454         var style = el && el.style;
       
 10455         if (style) {
       
 10456             if (val === void 0) {
       
 10457                 if (document.defaultView && document.defaultView.getComputedStyle) {
       
 10458                     val = document.defaultView.getComputedStyle(el, '');
       
 10459                 } else if (el.currentStyle) {
       
 10460                     val = el.currentStyle;
       
 10461                 }
       
 10462                 return prop === void 0 ? val : val[prop];
       
 10463             } else {
       
 10464                 if (!(prop in style)) {
       
 10465                     prop = '-webkit-' + prop;
       
 10466                 }
       
 10467                 style[prop] = val + (typeof val === 'string' ? '' : 'px');
       
 10468             }
       
 10469         }
       
 10470     }
       
 10471     function _find(ctx, tagName, iterator) {
       
 10472         if (ctx) {
       
 10473             var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
       
 10474             if (iterator) {
       
 10475                 for (; i < n; i++) {
       
 10476                     iterator(list[i], i);
       
 10477                 }
       
 10478             }
       
 10479             return list;
       
 10480         }
       
 10481         return [];
       
 10482     }
       
 10483     function _dispatchEvent(sortable, rootEl, name, targetEl, fromEl, startIndex, newIndex) {
       
 10484         var evt = document.createEvent('Event'), options = (sortable || rootEl[expando]).options, onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
       
 10485         evt.initEvent(name, true, true);
       
 10486         evt.to = rootEl;
       
 10487         evt.from = fromEl || rootEl;
       
 10488         evt.item = targetEl || rootEl;
       
 10489         evt.clone = cloneEl;
       
 10490         evt.oldIndex = startIndex;
       
 10491         evt.newIndex = newIndex;
       
 10492         rootEl.dispatchEvent(evt);
       
 10493         if (options[onName]) {
       
 10494             options[onName].call(sortable, evt);
       
 10495         }
       
 10496     }
       
 10497     function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect) {
       
 10498         var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
       
 10499         evt = document.createEvent('Event');
       
 10500         evt.initEvent('move', true, true);
       
 10501         evt.to = toEl;
       
 10502         evt.from = fromEl;
       
 10503         evt.dragged = dragEl;
       
 10504         evt.draggedRect = dragRect;
       
 10505         evt.related = targetEl || toEl;
       
 10506         evt.relatedRect = targetRect || toEl.getBoundingClientRect();
       
 10507         fromEl.dispatchEvent(evt);
       
 10508         if (onMoveFn) {
       
 10509             retVal = onMoveFn.call(sortable, evt);
       
 10510         }
       
 10511         return retVal;
       
 10512     }
       
 10513     function _disableDraggable(el) {
       
 10514         el.draggable = false;
       
 10515     }
       
 10516     function _unsilent() {
       
 10517         _silent = false;
       
 10518     }
       
 10519     function _ghostIsLast(el, evt) {
       
 10520         var lastEl = el.lastElementChild, rect = lastEl.getBoundingClientRect();
       
 10521         return (evt.clientY - (rect.top + rect.height) > 5 || evt.clientX - (rect.right + rect.width) > 5) && lastEl;
       
 10522     }
       
 10523     function _generateId(el) {
       
 10524         var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
       
 10525         while (i--) {
       
 10526             sum += str.charCodeAt(i);
       
 10527         }
       
 10528         return sum.toString(36);
       
 10529     }
       
 10530     function _index(el, selector) {
       
 10531         var index = 0;
       
 10532         if (!el || !el.parentNode) {
       
 10533             return -1;
       
 10534         }
       
 10535         while (el && (el = el.previousElementSibling)) {
       
 10536             if (el.nodeName.toUpperCase() !== 'TEMPLATE' && _matches(el, selector)) {
       
 10537                 index++;
       
 10538             }
       
 10539         }
       
 10540         return index;
       
 10541     }
       
 10542     function _matches(el, selector) {
       
 10543         if (el) {
       
 10544             selector = selector.split('.');
       
 10545             var tag = selector.shift().toUpperCase(), re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g');
       
 10546             return (tag === '' || el.nodeName.toUpperCase() == tag) && (!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length);
       
 10547         }
       
 10548         return false;
       
 10549     }
       
 10550     function _throttle(callback, ms) {
       
 10551         var args, _this;
       
 10552         return function () {
       
 10553             if (args === void 0) {
       
 10554                 args = arguments;
       
 10555                 _this = this;
       
 10556                 setTimeout(function () {
       
 10557                     if (args.length === 1) {
       
 10558                         callback.call(_this, args[0]);
       
 10559                     } else {
       
 10560                         callback.apply(_this, args);
       
 10561                     }
       
 10562                     args = void 0;
       
 10563                 }, ms);
       
 10564             }
       
 10565         };
       
 10566     }
       
 10567     function _extend(dst, src) {
       
 10568         if (dst && src) {
       
 10569             for (var key in src) {
       
 10570                 if (src.hasOwnProperty(key)) {
       
 10571                     dst[key] = src[key];
       
 10572                 }
       
 10573             }
       
 10574         }
       
 10575         return dst;
       
 10576     }
       
 10577     Sortable.utils = {
       
 10578         on: _on,
       
 10579         off: _off,
       
 10580         css: _css,
       
 10581         find: _find,
       
 10582         is: function (el, selector) {
       
 10583             return !!_closest(el, selector, el);
       
 10584         },
       
 10585         extend: _extend,
       
 10586         throttle: _throttle,
       
 10587         closest: _closest,
       
 10588         toggleClass: _toggleClass,
       
 10589         index: _index
       
 10590     };
       
 10591     Sortable.create = function (el, options) {
       
 10592         return new Sortable(el, options);
       
 10593     };
       
 10594     Sortable.version = '1.4.2';
       
 10595     return Sortable;
       
 10596 }));
       
 10597 CommonControlsLayerSwitcherDOM = function (Sortable) {
       
 10598     var LayerSwitcherDOM = {
       
 10599         _createDraggableElement: function (elementDraggable, context) {
       
 10600             Sortable.create(elementDraggable, {
       
 10601                 handle: '.GPlayerName',
       
 10602                 draggable: '.draggable-layer',
       
 10603                 ghostClass: 'GPghostLayer',
       
 10604                 animation: 200,
       
 10605                 onEnd: function (e) {
       
 10606                     context._onDragAndDropLayerClick(e);
       
 10607                 }
       
 10608             });
       
 10609         },
       
 10610         _addUID: function (id) {
       
 10611             var uid = this._uid ? id + '-' + this._uid : id;
       
 10612             return uid;
       
 10613         },
       
 10614         _createMainContainerElement: function () {
       
 10615             var container = document.createElement('div');
       
 10616             container.id = this._addUID('GPlayerSwitcher');
       
 10617             container.className = 'GPwidget';
       
 10618             return container;
       
 10619         },
       
 10620         _createMainLayersShowElement: function () {
       
 10621             var input = document.createElement('input');
       
 10622             input.id = this._addUID('GPshowLayersList');
       
 10623             input.type = 'checkbox';
       
 10624             return input;
       
 10625         },
       
 10626         _createMainLayersElement: function () {
       
 10627             var div = document.createElement('div');
       
 10628             div.id = this._addUID('GPlayersList');
       
 10629             div.className = 'GPpanel';
       
 10630             return div;
       
 10631         },
       
 10632         _createMainPictoElement: function () {
       
 10633             var self = this;
       
 10634             var label = document.createElement('label');
       
 10635             label.id = this._addUID('GPshowLayersListPicto');
       
 10636             label.className = 'GPshowAdvancedToolPicto';
       
 10637             label.htmlFor = this._addUID('GPshowLayersList');
       
 10638             label.title = 'Afficher/masquer le gestionnaire de couches';
       
 10639             var spanOpen = document.createElement('span');
       
 10640             spanOpen.id = this._addUID('GPshowLayersListOpen');
       
 10641             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 10642             spanOpen.addEventListener('click', function () {
       
 10643                 if (document.getElementById(self._addUID('GPshowLayersList')).checked) {
       
 10644                     var layers = document.getElementsByClassName('GPlayerInfoOpened');
       
 10645                     for (var i = 0; i < layers.length; i++) {
       
 10646                         layers[i].className = 'GPlayerInfo';
       
 10647                     }
       
 10648                     document.getElementById(self._addUID('GPlayerInfoPanel')).className = 'GPlayerInfoPanelClosed';
       
 10649                 }
       
 10650             });
       
 10651             label.appendChild(spanOpen);
       
 10652             var spanClose = document.createElement('span');
       
 10653             spanClose.addEventListener('click', function () {
       
 10654                 if (document.getElementById(self._addUID('GPshowLayersList')).checked) {
       
 10655                     var layers = document.getElementsByClassName('GPlayerInfoOpened');
       
 10656                     for (var i = 0; i < layers.length; i++) {
       
 10657                         layers[i].className = 'GPlayerInfo';
       
 10658                     }
       
 10659                     document.getElementById(self._addUID('GPlayerInfoPanel')).className = 'GPlayerInfoPanelClosed';
       
 10660                 }
       
 10661             });
       
 10662             spanClose.id = self._addUID('GPshowLayersListClose');
       
 10663             label.appendChild(spanClose);
       
 10664             return label;
       
 10665         },
       
 10666         _createMainInfoElement: function () {
       
 10667             var div = document.createElement('div');
       
 10668             div.id = this._addUID('GPlayerInfoPanel');
       
 10669             div.className = 'GPpanel GPlayerInfoPanelClosed';
       
 10670             return div;
       
 10671         },
       
 10672         _createContainerLayerElement: function (obj) {
       
 10673             var container = document.createElement('div');
       
 10674             container.id = 'GPlayerSwitcher_ID' + obj.id;
       
 10675             container.className = 'GPlayerSwitcher_layer draggable-layer';
       
 10676             container.appendChild(this._createBasicToolElement(obj));
       
 10677             var array = this._createAdvancedToolShowElement(obj);
       
 10678             for (var i = 0; i < array.length; i++) {
       
 10679                 container.appendChild(array[i]);
       
 10680             }
       
 10681             container.appendChild(this._createAdvancedToolElement(obj));
       
 10682             return container;
       
 10683         },
       
 10684         _createBasicToolElement: function (obj) {
       
 10685             var div = document.createElement('div');
       
 10686             div.id = 'GPbasicTools_IDLayer' + obj.id;
       
 10687             div.className = 'GPlayerBasicTools';
       
 10688             div.appendChild(this._createBasicToolNameElement(obj));
       
 10689             var array = this._createBasicToolVisibilityElement(obj);
       
 10690             for (var i = 0; i < array.length; i++) {
       
 10691                 div.appendChild(array[i]);
       
 10692             }
       
 10693             return div;
       
 10694         },
       
 10695         _createBasicToolNameElement: function (obj) {
       
 10696             var span = document.createElement('span');
       
 10697             span.id = 'GPname_ID' + obj.id;
       
 10698             span.className = 'GPlayerName';
       
 10699             span.title = obj.description || obj.title;
       
 10700             span.innerHTML = obj.title;
       
 10701             return span;
       
 10702         },
       
 10703         _createBasicToolVisibilityElement: function (obj) {
       
 10704             var list = [];
       
 10705             var checked = obj.visibility;
       
 10706             var id = 'GPvisibility_ID' + obj.id;
       
 10707             var input = document.createElement('input');
       
 10708             input.id = id;
       
 10709             input.type = 'checkbox';
       
 10710             input.checked = checked;
       
 10711             var label = document.createElement('label');
       
 10712             label.htmlFor = id;
       
 10713             label.id = 'GPvisibilityPicto_ID' + obj.id;
       
 10714             label.className = 'GPlayerVisibility';
       
 10715             label.title = 'Afficher/masquer la couche';
       
 10716             var context = this;
       
 10717             if (input.addEventListener) {
       
 10718                 input.addEventListener('click', function (e) {
       
 10719                     context._onVisibilityLayerClick.call(context, e);
       
 10720                 });
       
 10721             } else if (input.attachEvent) {
       
 10722                 input.attachEvent('onclick', function (e) {
       
 10723                     context._onVisibilityLayerClick.call(context, e);
       
 10724                 });
       
 10725             }
       
 10726             list.push(input);
       
 10727             list.push(label);
       
 10728             return list;
       
 10729         },
       
 10730         _createAdvancedToolShowElement: function (obj) {
       
 10731             var list = [];
       
 10732             var label = document.createElement('label');
       
 10733             label.id = 'GPshowAdvancedToolsPicto_ID' + obj.id;
       
 10734             label.htmlFor = 'GPshowAdvancedTools_ID' + obj.id;
       
 10735             label.title = 'Plus d\'outils';
       
 10736             label.className = 'GPshowMoreOptions GPshowLayerAdvancedTools';
       
 10737             var input = document.createElement('input');
       
 10738             input.type = 'checkbox';
       
 10739             input.id = 'GPshowAdvancedTools_ID' + obj.id;
       
 10740             list.push(input);
       
 10741             list.push(label);
       
 10742             return list;
       
 10743         },
       
 10744         _createAdvancedToolElement: function (obj) {
       
 10745             var container = document.createElement('div');
       
 10746             container.id = 'GPadvancedTools_ID' + obj.id;
       
 10747             container.className = 'GPlayerAdvancedTools';
       
 10748             container.appendChild(this._createAdvancedToolDeleteElement(obj));
       
 10749             if (obj.title && obj.description) {
       
 10750                 container.appendChild(this._createAdvancedToolInformationElement(obj));
       
 10751             }
       
 10752             if (obj.type !== 'feature') {
       
 10753                 var array = this._createAdvancedToolOpacityElement(obj);
       
 10754                 for (var i = 0; i < array.length; i++) {
       
 10755                     container.appendChild(array[i]);
       
 10756                 }
       
 10757             }
       
 10758             return container;
       
 10759         },
       
 10760         _createAdvancedToolDeleteElement: function (obj) {
       
 10761             var div = document.createElement('div');
       
 10762             div.id = 'GPremove_ID' + obj.id;
       
 10763             div.className = 'GPlayerRemove';
       
 10764             div.title = 'Supprimer la couche';
       
 10765             div.layerId = obj.id;
       
 10766             var context = this;
       
 10767             if (div.addEventListener) {
       
 10768                 div.addEventListener('click', function (e) {
       
 10769                     context._onDropLayerClick.call(context, e);
       
 10770                 });
       
 10771             } else if (div.attachEvent) {
       
 10772                 div.attachEvent('onclick', function (e) {
       
 10773                     context._onDropLayerClick.call(context, e);
       
 10774                 });
       
 10775             }
       
 10776             return div;
       
 10777         },
       
 10778         _createAdvancedToolInformationElement: function (obj) {
       
 10779             var div = document.createElement('div');
       
 10780             div.id = 'GPinfo_ID' + obj.id;
       
 10781             div.className = 'GPlayerInfo';
       
 10782             div.title = 'Informations/légende';
       
 10783             div.layerId = obj.id;
       
 10784             var context = this;
       
 10785             if (div.addEventListener) {
       
 10786                 div.addEventListener('click', function (e) {
       
 10787                     context._onOpenLayerInfoClick.call(context, e);
       
 10788                 });
       
 10789             } else if (div.attachEvent) {
       
 10790                 div.attachEvent('onclick', function (e) {
       
 10791                     context._onOpenLayerInfoClick.call(context, e);
       
 10792                 });
       
 10793             }
       
 10794             return div;
       
 10795         },
       
 10796         _createAdvancedToolOpacityElement: function (obj) {
       
 10797             var list = [];
       
 10798             var divO = document.createElement('div');
       
 10799             divO.id = 'GPopacity_ID' + obj.id;
       
 10800             divO.className = 'GPlayerOpacity';
       
 10801             divO.title = 'Opacité';
       
 10802             var opacity = Math.round(obj.opacity * 100);
       
 10803             var input = document.createElement('input');
       
 10804             input.id = 'GPopacityValueDiv_ID' + obj.id;
       
 10805             input.type = 'range';
       
 10806             input.value = opacity;
       
 10807             var context = this;
       
 10808             if (input.addEventListener) {
       
 10809                 input.addEventListener('change', function (e) {
       
 10810                     context._onChangeLayerOpacity.call(context, e);
       
 10811                 });
       
 10812             } else if (input.attachEvent) {
       
 10813                 input.attachEvent('onchange', function (e) {
       
 10814                     context._onChangeLayerOpacity.call(context, e);
       
 10815                 });
       
 10816             }
       
 10817             if (input.addEventListener) {
       
 10818                 input.addEventListener('input', function (e) {
       
 10819                     context._onChangeLayerOpacity.call(context, e);
       
 10820                 });
       
 10821             } else if (input.attachEvent) {
       
 10822                 input.attachEvent('oninput', function (e) {
       
 10823                     context._onChangeLayerOpacity.call(context, e);
       
 10824                 });
       
 10825             }
       
 10826             divO.appendChild(input);
       
 10827             var divC = document.createElement('div');
       
 10828             divC.id = 'GPopacityValueDiv_ID' + obj.id;
       
 10829             divC.className = 'GPlayerOpacityValue';
       
 10830             var span = document.createElement('span');
       
 10831             span.id = 'GPopacityValue_ID' + obj.id;
       
 10832             span.innerHTML = opacity + '%';
       
 10833             divC.appendChild(span);
       
 10834             list.push(divO);
       
 10835             list.push(divC);
       
 10836             return list;
       
 10837         },
       
 10838         _createContainerLayerInfoElement: function (obj) {
       
 10839             var container = document.createElement('div');
       
 10840             container.id = 'GPlayerInfoContent';
       
 10841             var title = document.createElement('div');
       
 10842             title.id = 'GPlayerInfoTitle';
       
 10843             title.innerHTML = obj.title;
       
 10844             container.appendChild(title);
       
 10845             if (obj.quicklookUrl) {
       
 10846                 var quick = document.createElement('div');
       
 10847                 quick.id = 'GPlayerInfoQuicklook';
       
 10848                 quick.title = 'Afficher un aperçu de la couche';
       
 10849                 var refquick = document.createElement('a');
       
 10850                 refquick.href = obj.quicklookUrl;
       
 10851                 refquick.appendChild(quick);
       
 10852                 container.appendChild(refquick);
       
 10853             }
       
 10854             var close = document.createElement('div');
       
 10855             close.id = 'GPlayerInfoClose';
       
 10856             close.title = 'Fermer la fenêtre';
       
 10857             var onCloseClick = function () {
       
 10858                 document.getElementById('GPlayerInfoPanel').className = 'GPlayerInfoPanelClosed';
       
 10859                 var layers = document.getElementsByClassName('GPlayerInfoOpened');
       
 10860                 for (var i = 0; i < layers.length; i++) {
       
 10861                     layers[i].className = 'GPlayerInfo';
       
 10862                 }
       
 10863             };
       
 10864             if (close.addEventListener) {
       
 10865                 close.addEventListener('click', onCloseClick);
       
 10866             } else if (close.attachEvent) {
       
 10867                 close.attachEvent('onclick', onCloseClick);
       
 10868             }
       
 10869             container.appendChild(close);
       
 10870             var desc = document.createElement('div');
       
 10871             desc.id = 'GPlayerInfoDescription';
       
 10872             desc.innerHTML = obj.description;
       
 10873             container.appendChild(desc);
       
 10874             if (obj.metadata) {
       
 10875                 var mtd = document.createElement('div');
       
 10876                 mtd.id = 'GPlayerInfoMetadata';
       
 10877                 var mtdtitle = document.createElement('div');
       
 10878                 mtdtitle.className = 'GPlayerInfoSubtitle';
       
 10879                 mtdtitle.innerHTML = 'Métadonnées';
       
 10880                 mtd.appendChild(mtdtitle);
       
 10881                 for (var i = 0; i < obj.metadata.length; i++) {
       
 10882                     var urlmtd = obj.metadata[i].url;
       
 10883                     var mtdlink = document.createElement('div');
       
 10884                     mtdlink.className = 'GPlayerInfoLink';
       
 10885                     var refmtd = document.createElement('a');
       
 10886                     refmtd.href = urlmtd;
       
 10887                     refmtd.innerHTML = urlmtd;
       
 10888                     mtdlink.appendChild(refmtd);
       
 10889                     mtd.appendChild(mtdlink);
       
 10890                 }
       
 10891                 if (obj.metadata.length !== 0) {
       
 10892                     container.appendChild(mtd);
       
 10893                 }
       
 10894             }
       
 10895             if (obj.legends) {
       
 10896                 var lgd = document.createElement('div');
       
 10897                 lgd.id = 'GPlayerInfoLegend';
       
 10898                 var lgdtitle = document.createElement('div');
       
 10899                 lgdtitle.className = 'GPlayerInfoSubtitle';
       
 10900                 lgdtitle.innerHTML = 'Légende';
       
 10901                 lgd.appendChild(lgdtitle);
       
 10902                 var legends = {};
       
 10903                 var maxScale = obj.maxScaleDenominator || 560000000;
       
 10904                 for (var k = 0; k < obj.legends.length; k++) {
       
 10905                     var minScale = obj.legends[k].minScaleDenominator;
       
 10906                     if (minScale) {
       
 10907                         var s = minScale.toString();
       
 10908                         minScale = Math.round(parseInt(s.substring(0, 3), 10) / 10) * Math.pow(10, s.length - 2);
       
 10909                     } else {
       
 10910                         minScale = 270;
       
 10911                     }
       
 10912                     legends[minScale] = obj.legends[k];
       
 10913                 }
       
 10914                 for (var scale in legends) {
       
 10915                     if (legends.hasOwnProperty(scale)) {
       
 10916                         var urllgd = legends[scale].url;
       
 10917                         if (typeof urllgd === 'string' && urllgd.toLowerCase().indexOf('nolegend.jpg') == -1) {
       
 10918                             var lgdlink = document.createElement('div');
       
 10919                             lgdlink.className = 'GPlayerInfoLink';
       
 10920                             maxScale = legends[scale].maxScaleDenominator || maxScale;
       
 10921                             var reflgd = document.createElement('a');
       
 10922                             reflgd.href = urllgd;
       
 10923                             reflgd.innerHTML = 'Du 1/' + scale + ' au 1/' + maxScale;
       
 10924                             lgdlink.appendChild(reflgd);
       
 10925                             lgd.appendChild(lgdlink);
       
 10926                         } else {
       
 10927                             delete legends[scale];
       
 10928                         }
       
 10929                     }
       
 10930                 }
       
 10931                 if (Object.keys(legends).length !== 0) {
       
 10932                     container.appendChild(lgd);
       
 10933                 }
       
 10934             }
       
 10935             return container;
       
 10936         }
       
 10937     };
       
 10938     return LayerSwitcherDOM;
       
 10939 }(sortable);
       
 10940 LeafletControlsLayerSwitcher = function (L, woodman, LayerSwitcherDOM) {
       
 10941     var LayerSwitcher = L.Control.Layers.extend({
       
 10942         includes: LayerSwitcherDOM,
       
 10943         options: {
       
 10944             collapsed: true,
       
 10945             position: 'topright',
       
 10946             autoZIndex: true,
       
 10947             layers: []
       
 10948         },
       
 10949         initialize: function (options) {
       
 10950             L.Util.setOptions(this, options);
       
 10951             this._hasLayersConfig = !this.options.layers || Object.keys(this.options.layers).length === 0 ? false : true;
       
 10952             this._layersConfig = this._hasLayersConfig ? this.options.layers : [];
       
 10953             this._layers = {};
       
 10954             this._lastZIndex = 0;
       
 10955             if (this._hasLayersConfig) {
       
 10956                 for (var i = 0; i < this._layersConfig.length; i++) {
       
 10957                     var obj = this._layersConfig[i];
       
 10958                     this._addLayer(obj.layer, null, true);
       
 10959                 }
       
 10960             }
       
 10961         },
       
 10962         onAdd: function (map) {
       
 10963             var layersMap = map._layers;
       
 10964             if (Object.keys(layersMap).length !== 0) {
       
 10965                 var layersKeys = Object.keys(layersMap);
       
 10966                 this._lastZIndex = 0;
       
 10967                 for (var i = 0; i < layersKeys.length; i++) {
       
 10968                     var layerId = layersKeys[i];
       
 10969                     if (this.options.autoZIndex && layersMap[layerId].setZIndex) {
       
 10970                         this._lastZIndex++;
       
 10971                         layersMap[layerId].setZIndex(this._lastZIndex);
       
 10972                     }
       
 10973                     if (this._hasLayersConfig) {
       
 10974                         if (this._layers[layerId]) {
       
 10975                             continue;
       
 10976                         }
       
 10977                     }
       
 10978                     this.addOverlay(layersMap[layerId]);
       
 10979                 }
       
 10980             }
       
 10981             if (Object.keys(layersMap).length === 0) {
       
 10982                 var config = this._layersConfig;
       
 10983                 this._lastZIndex = 0;
       
 10984                 for (var j = 0; j < config.length; j++) {
       
 10985                     var layer = config[j].layer;
       
 10986                     if (!map.hasLayer(layer)) {
       
 10987                         map.addLayer(layer);
       
 10988                         this.addOverlay(layer, null);
       
 10989                         if (this.options.autoZIndex && layer.setZIndex) {
       
 10990                             this._lastZIndex++;
       
 10991                             layer.setZIndex(this._lastZIndex);
       
 10992                         }
       
 10993                     }
       
 10994                 }
       
 10995             }
       
 10996             for (var k in this._layers) {
       
 10997                 if (this._layers.hasOwnProperty(k)) {
       
 10998                     var obj = this._layers[k];
       
 10999                     if (!obj.visibility) {
       
 11000                         this._visibilityLayer(!obj.visibility, obj.layer);
       
 11001                     }
       
 11002                 }
       
 11003             }
       
 11004             this._initLayout();
       
 11005             this._update();
       
 11006             map.on('layeradd', this._onLayerChange, this);
       
 11007             map.on('layerremove', this._onLayerChange, this);
       
 11008             return this._container;
       
 11009         },
       
 11010         _addLayer: function (layer, name, overlay) {
       
 11011             var id = layer._geoportal_id ? layer._geoportal_id : layer._leaflet_id;
       
 11012             if (!id) {
       
 11013                 return;
       
 11014             }
       
 11015             var layerConfig = {};
       
 11016             for (var i in this._layersConfig) {
       
 11017                 if (this._layersConfig.hasOwnProperty(i)) {
       
 11018                     if (id === L.stamp(this._layersConfig[i].layer)) {
       
 11019                         layerConfig = this._layersConfig[i].config;
       
 11020                         var display = typeof this._layersConfig[i].display != 'undefined' ? this._layersConfig[i].display : true;
       
 11021                         if (!display) {
       
 11022                             return;
       
 11023                         }
       
 11024                         break;
       
 11025                     }
       
 11026                 }
       
 11027             }
       
 11028             this._layers[id] = {
       
 11029                 layer: layer,
       
 11030                 id: id,
       
 11031                 overlay: overlay,
       
 11032                 title: layer._geoportal_id && layer._title ? layer._title : name ? name : id,
       
 11033                 description: layer._geoportal_id && layer._description ? layer._description : name ? name : id,
       
 11034                 visibility: layer._geoportal_id ? layer.getVisible() : true,
       
 11035                 legends: layer._geoportal_id ? layer._legends : null,
       
 11036                 metadata: layer._geoportal_id ? layer._metadata : null,
       
 11037                 quicklookUrl: layer._geoportal_id ? layer._quicklookUrl : null
       
 11038             };
       
 11039             if (layerConfig && Object.keys(layerConfig)) {
       
 11040                 L.Util.extend(this._layers[id], layerConfig);
       
 11041             }
       
 11042             layer._geoportal_id ? layer.setVisible(this._layers[id].visibility) : null;
       
 11043         },
       
 11044         _initLayout: function () {
       
 11045             var container = this._container = this._createMainContainerElement();
       
 11046             var input = this._createMainLayersShowElement();
       
 11047             container.appendChild(input);
       
 11048             if (!this.options.collapsed) {
       
 11049                 input.checked = 'checked';
       
 11050             }
       
 11051             var divL = this._overlaysList = this._createMainLayersElement();
       
 11052             container.appendChild(divL);
       
 11053             var picto = this._createMainPictoElement();
       
 11054             container.appendChild(picto);
       
 11055             var divI = this._createMainInfoElement();
       
 11056             container.appendChild(divI);
       
 11057             this._createDraggableElement(this._overlaysList, this);
       
 11058             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 11059             this._map.on('moveend', this._onOutOfRangeLayerZoom, this);
       
 11060             switch (this.getPosition()) {
       
 11061             case 'topright':
       
 11062                 container.style.position = 'relative';
       
 11063                 container.style.top = '0';
       
 11064                 container.style.right = '0';
       
 11065                 break;
       
 11066             case 'topleft':
       
 11067                 container.style.position = 'relative';
       
 11068                 container.style.top = '0';
       
 11069                 container.style.right = 'initial';
       
 11070                 picto.style.float = 'left';
       
 11071                 divL.style.borderBottomRightRadius = '5px';
       
 11072                 divL.style.borderBottomLeftRadius = '0';
       
 11073                 divI.style.right = 'initial';
       
 11074                 divI.style.left = '190px';
       
 11075                 break;
       
 11076             case 'bottomleft':
       
 11077                 container.style.position = 'relative';
       
 11078                 container.style.top = '0';
       
 11079                 container.style.right = 'initial';
       
 11080                 picto.style.float = 'left';
       
 11081                 divL.style.borderBottomRightRadius = '5px';
       
 11082                 divL.style.borderBottomLeftRadius = '0';
       
 11083                 divI.style.right = 'initial';
       
 11084                 divI.style.left = '190px';
       
 11085                 break;
       
 11086             case 'bottomright':
       
 11087                 container.style.position = 'relative';
       
 11088                 container.style.top = '0';
       
 11089                 container.style.right = '0';
       
 11090                 break;
       
 11091             default:
       
 11092                 container.style.position = 'relative';
       
 11093                 container.style.top = '0';
       
 11094                 container.style.right = '0';
       
 11095             }
       
 11096         },
       
 11097         _update: function () {
       
 11098             if (!this._container) {
       
 11099                 return;
       
 11100             }
       
 11101             this._overlaysList.innerHTML = '';
       
 11102             var layersId = [];
       
 11103             for (var i in this._layers) {
       
 11104                 if (this._layers.hasOwnProperty(i)) {
       
 11105                     layersId.push(i);
       
 11106                 }
       
 11107             }
       
 11108             var layers = layersId.sort(function (a, b) {
       
 11109                 var ia = parseInt(a, 10);
       
 11110                 var ib = parseInt(b, 10);
       
 11111                 return ia - ib;
       
 11112             }).reverse();
       
 11113             for (var j = 0; j < layers.length; j++) {
       
 11114                 var id = layers[j];
       
 11115                 var obj = this._layers[id];
       
 11116                 this._addItem(obj);
       
 11117             }
       
 11118         },
       
 11119         _addItem: function (obj) {
       
 11120             obj.opacity = obj.layer.options.opacity;
       
 11121             var container = this._createContainerLayerElement(obj);
       
 11122             obj.layer.options.minZoom > this._map.getZoom() || obj.layer.options.maxZoom < this._map.getZoom() ? L.DomUtil.addClass(container, 'outOfRange') : L.DomUtil.removeClass(container, 'outOfRange');
       
 11123             this._overlaysList.appendChild(container);
       
 11124             return container;
       
 11125         },
       
 11126         _onLayerChange: function (e) {
       
 11127             var obj = this._layers[L.stamp(e.layer)];
       
 11128             if (!obj) {
       
 11129                 return;
       
 11130             }
       
 11131             if (!this._handlingClick) {
       
 11132                 this._update();
       
 11133             }
       
 11134             var type = e.type === 'layeradd' ? 'overlayadd' : 'overlayremove';
       
 11135             if (type) {
       
 11136                 this._map.fire(type, obj);
       
 11137             }
       
 11138         },
       
 11139         removeLayer: function (layer) {
       
 11140             var id = L.stamp(layer);
       
 11141             delete this._layers[id];
       
 11142             this._update();
       
 11143             return this;
       
 11144         },
       
 11145         _visibilityLayer: function (checked, layer) {
       
 11146             this._handlingClick = true;
       
 11147             if (layer._geoportal_id) {
       
 11148                 var value = !layer.getVisible();
       
 11149                 layer.setVisible(value);
       
 11150             }
       
 11151             if (checked && this._map.hasLayer(layer)) {
       
 11152                 this._map.removeLayer(layer);
       
 11153             } else if (!checked && !this._map.hasLayer(layer)) {
       
 11154                 this._map.addLayer(layer);
       
 11155             } else {
       
 11156             }
       
 11157             this._handlingClick = false;
       
 11158             this._refocusOnMap();
       
 11159         },
       
 11160         _onOutOfRangeLayerZoom: function () {
       
 11161             var map = this._map;
       
 11162             var layers = this._layers;
       
 11163             for (var i in layers) {
       
 11164                 if (layers.hasOwnProperty(i)) {
       
 11165                     var layer = layers[i].layer;
       
 11166                     var id = layers[i].id;
       
 11167                     var div = L.DomUtil.get('GPlayerSwitcher_ID' + id);
       
 11168                     if (layer.options.minZoom > map.getZoom() || layer.options.maxZoom < map.getZoom()) {
       
 11169                         L.DomUtil.addClass(div, 'outOfRange');
       
 11170                     } else {
       
 11171                         L.DomUtil.removeClass(div, 'outOfRange');
       
 11172                     }
       
 11173                 }
       
 11174             }
       
 11175         },
       
 11176         _onVisibilityLayerClick: function (e) {
       
 11177             var layerId = e.target.id;
       
 11178             var layerIdx = layerId.substring(layerId.indexOf('_') + 3);
       
 11179             var input = L.DomUtil.get(layerId);
       
 11180             this._layers[layerIdx].visibility = input.checked;
       
 11181             this._visibilityLayer(!input.checked, this._layers[layerIdx].layer);
       
 11182         },
       
 11183         _onDropLayerClick: function (e) {
       
 11184             var layerId = e.target.id;
       
 11185             var layerIdx = layerId.substring(layerId.indexOf('_') + 3);
       
 11186             var layer = this._layers[layerIdx].layer;
       
 11187             this.removeLayer(layer);
       
 11188             if (this._map.hasLayer(layer)) {
       
 11189                 this._map.removeLayer(layer);
       
 11190             }
       
 11191         },
       
 11192         _onChangeLayerOpacity: function (e) {
       
 11193             var layerId = e.target.id;
       
 11194             var layerIdx = layerId.substring(layerId.indexOf('_') + 3);
       
 11195             var layer = this._layers[layerIdx].layer;
       
 11196             var opacityValue = e.target.value;
       
 11197             var opacityId = L.DomUtil.get('GPopacityValue_ID' + layerIdx);
       
 11198             opacityId.innerHTML = opacityValue + '%';
       
 11199             if (this._map.hasLayer(layer)) {
       
 11200                 layer.setOpacity(opacityValue / 100);
       
 11201             }
       
 11202         },
       
 11203         _onOpenLayerInfoClick: function (e) {
       
 11204             var layerId = e.target.id;
       
 11205             var layerIdx = layerId.substring(layerId.indexOf('_') + 3);
       
 11206             var layer = this._layers[layerIdx];
       
 11207             var divId = L.DomUtil.get(e.target.id);
       
 11208             var panel = null;
       
 11209             var info = null;
       
 11210             if (divId.className === 'GPlayerInfoOpened') {
       
 11211                 L.DomUtil.removeClass(divId, 'GPlayerInfoOpened');
       
 11212                 L.DomUtil.addClass(divId, 'GPlayerInfo');
       
 11213                 panel = L.DomUtil.get('GPlayerInfoPanel');
       
 11214                 L.DomUtil.removeClass(panel, 'GPpanel');
       
 11215                 L.DomUtil.removeClass(panel, 'GPlayerInfoPanelOpened');
       
 11216                 L.DomUtil.addClass(panel, 'GPlayerInfoPanelClosed');
       
 11217                 info = L.DomUtil.get('GPlayerInfoContent');
       
 11218                 panel.removeChild(info);
       
 11219                 return;
       
 11220             }
       
 11221             var layers = document.getElementsByClassName('GPlayerInfoOpened');
       
 11222             for (var i = 0; i < layers.length; i++) {
       
 11223                 layers[i].className = 'GPlayerInfo';
       
 11224             }
       
 11225             L.DomUtil.removeClass(divId, 'GPlayerInfo');
       
 11226             L.DomUtil.addClass(divId, 'GPlayerInfoOpened');
       
 11227             panel = L.DomUtil.get('GPlayerInfoPanel');
       
 11228             L.DomUtil.addClass(panel, 'GPpanel');
       
 11229             L.DomUtil.removeClass(panel, 'GPlayerInfoPanelClosed');
       
 11230             L.DomUtil.addClass(panel, 'GPlayerInfoPanelOpened');
       
 11231             info = L.DomUtil.get('GPlayerInfoContent');
       
 11232             if (info) {
       
 11233                 panel.removeChild(info);
       
 11234             }
       
 11235             var infoLayer = this._createContainerLayerInfoElement(layer);
       
 11236             panel.appendChild(infoLayer);
       
 11237         },
       
 11238         _onDragAndDropLayerClick: function (e) {
       
 11239             var layerId = e.item.id;
       
 11240             var layerIdx = layerId.substring(layerId.indexOf('_') + 3);
       
 11241             var layer = this._layers[layerIdx].layer;
       
 11242             var matchesLayers = document.querySelectorAll('div.GPlayerSwitcher_layer');
       
 11243             this._lastZIndex = matchesLayers.length;
       
 11244             for (var i = 0; i < matchesLayers.length; i++) {
       
 11245                 var tag = matchesLayers[i].id;
       
 11246                 var id = tag.substring(tag.indexOf('_') + 3);
       
 11247                 var _layer = this._layers[id].layer;
       
 11248                 if (this.options.autoZIndex && _layer.setZIndex) {
       
 11249                     this._lastZIndex--;
       
 11250                     _layer.setZIndex(this._lastZIndex);
       
 11251                 }
       
 11252             }
       
 11253         },
       
 11254         addLayer: function (layer, config) {
       
 11255             var map = this._map;
       
 11256             var cfg = this._layersConfig;
       
 11257             if (!layer) {
       
 11258                 console.log('[ERROR] LayerSwitcher:addLayer - missing layer parameter !');
       
 11259                 return;
       
 11260             }
       
 11261             if (!map.hasLayer(layer)) {
       
 11262                 console.log('[WARN] LayerSwitcher:addLayer - layer has not been added on map !');
       
 11263             }
       
 11264             var id = L.stamp(layer);
       
 11265             for (var i in cfg) {
       
 11266                 if (cfg.hasOwnProperty(i)) {
       
 11267                     if (id === L.stamp(cfg[i].layer)) {
       
 11268                         delete cfg[i];
       
 11269                         break;
       
 11270                     }
       
 11271                 }
       
 11272             }
       
 11273             var _config = config || {};
       
 11274             L.Util.extend(_config, { layer: layer });
       
 11275             cfg.push(_config);
       
 11276             layer.setZIndex(this._lastZIndex++);
       
 11277             this.addOverlay(layer);
       
 11278             this._update();
       
 11279         }
       
 11280     });
       
 11281     return LayerSwitcher;
       
 11282 }(leaflet, {}, CommonControlsLayerSwitcherDOM);
       
 11283 CommonUtilsConfig = function () {
       
 11284     var Config = {
       
 11285         configuration: null,
       
 11286         isConfigLoaded: function () {
       
 11287             var scope = typeof window !== 'undefined' ? window : {};
       
 11288             if (scope.Gp && scope.Gp.Config && Object.keys(scope.Gp.Config).length !== 0) {
       
 11289                 this.configuration = scope.Gp.Config;
       
 11290                 return true;
       
 11291             }
       
 11292             return false;
       
 11293         },
       
 11294         getLayerId: function (layerName, service) {
       
 11295             var layerId = null;
       
 11296             if (this.configuration) {
       
 11297                 var layers = this.configuration['layers'];
       
 11298                 for (var key in layers) {
       
 11299                     if (layers.hasOwnProperty(key)) {
       
 11300                         var parts = key.split('$');
       
 11301                         if (layerName === parts[0]) {
       
 11302                             if (parts[1]) {
       
 11303                                 var servicePartsLayer = parts[1].split(':');
       
 11304                                 var servicePartsService = parts[1].split(';');
       
 11305                                 if (servicePartsService[1] === service) {
       
 11306                                     layerId = key;
       
 11307                                     break;
       
 11308                                 }
       
 11309                                 if (servicePartsLayer[2] === service) {
       
 11310                                     layerId = key;
       
 11311                                     break;
       
 11312                                 }
       
 11313                             }
       
 11314                         }
       
 11315                     }
       
 11316                 }
       
 11317             }
       
 11318             if (!layerId) {
       
 11319                 console.log('ERROR layer id (' + layerName + ' / ' + service + ') was not found !?');
       
 11320             }
       
 11321             return layerId;
       
 11322         },
       
 11323         getLayerParams: function (layerName, service, apiKey) {
       
 11324             var params = {};
       
 11325             if (this.configuration) {
       
 11326                 var layerId = this.getLayerId(layerName, service);
       
 11327                 if (layerId) {
       
 11328                     var layerConf = this.configuration.layers[layerId];
       
 11329                     var key = layerConf.apiKeys[0];
       
 11330                     if (apiKey) {
       
 11331                         if (apiKey !== key) {
       
 11332                             console.log('ERROR different keys (' + apiKey + ' !== ' + key + ') !?');
       
 11333                             return;
       
 11334                         }
       
 11335                     }
       
 11336                     apiKey = apiKey || key;
       
 11337                     params.key = apiKey;
       
 11338                     params.url = layerConf.getServerUrl(apiKey);
       
 11339                     params.version = layerConf.getServiceParams().version;
       
 11340                     params.styles = layerConf.getDefaultStyle();
       
 11341                     params.format = layerConf.getDefaultFormat();
       
 11342                     params.projection = layerConf.getDefaultProjection();
       
 11343                     params.minScale = layerConf.getMinScaleDenominator();
       
 11344                     params.maxScale = layerConf.getMaxScaleDenominator();
       
 11345                     params.extent = layerConf.getBBOX();
       
 11346                     params.legends = layerConf.getLegends();
       
 11347                     params.metadata = layerConf.getMetadata();
       
 11348                     params.originators = layerConf.getOriginators();
       
 11349                     params.title = layerConf.getTitle();
       
 11350                     params.description = layerConf.getDescription();
       
 11351                     params.quicklookUrl = layerConf.getQuicklookUrl();
       
 11352                     if (layerConf.wmtsOptions) {
       
 11353                         params.tileMatrixSetLimits = layerConf.wmtsOptions.tileMatrixSetLimits;
       
 11354                     }
       
 11355                     var TMSLink = layerConf.getTMSID();
       
 11356                     if (TMSLink) {
       
 11357                         params.TMSLink = TMSLink;
       
 11358                         var tmsConf = this.configuration.getTMSConf(TMSLink);
       
 11359                         params.matrixOrigin = tmsConf.getTopLeftCorner();
       
 11360                         params.nativeResolutions = tmsConf.nativeResolutions;
       
 11361                         params.matrixIds = tmsConf.matrixIds;
       
 11362                         params.tileMatrices = tmsConf.tileMatrices;
       
 11363                     }
       
 11364                 }
       
 11365             }
       
 11366             return params;
       
 11367         },
       
 11368         getServiceParams: function (resource, service, apiKey) {
       
 11369             var params = {};
       
 11370             if (this.configuration) {
       
 11371                 var layerId = this.getLayerId(resource, service);
       
 11372                 if (layerId) {
       
 11373                     var layerConf = this.configuration.layers[layerId];
       
 11374                     var key = layerConf.apiKeys[0];
       
 11375                     if (apiKey) {
       
 11376                         if (apiKey !== key) {
       
 11377                             return;
       
 11378                         }
       
 11379                     }
       
 11380                     apiKey = apiKey || key;
       
 11381                     params.key = apiKey;
       
 11382                     params.url = layerConf.getServerUrl(apiKey);
       
 11383                     params.version = layerConf.getServiceParams().version;
       
 11384                     params.extent = layerConf.getBBOX();
       
 11385                     params.title = layerConf.getTitle();
       
 11386                     params.description = layerConf.getDescription();
       
 11387                 }
       
 11388             }
       
 11389             return params;
       
 11390         },
       
 11391         getResolutions: function () {
       
 11392             var resolutions = [];
       
 11393             if (this.configuration) {
       
 11394                 resolutions = this.configuration['generalOptions']['wgs84Resolutions'];
       
 11395             }
       
 11396             return resolutions;
       
 11397         },
       
 11398         getTileMatrix: function (tmsName) {
       
 11399             var tms = {};
       
 11400             if (this.configuration) {
       
 11401                 if (tmsName) {
       
 11402                     tms = this.configuration['tileMatrixSets'][tmsName.toUpperCase()];
       
 11403                 }
       
 11404             }
       
 11405             return tms;
       
 11406         },
       
 11407         getGlobalConstraints: function (layerId) {
       
 11408             var params = {};
       
 11409             if (layerId) {
       
 11410                 var layerConf = this.configuration.layers[layerId];
       
 11411                 params.projection = layerConf.getDefaultProjection();
       
 11412                 params.minScale = layerConf.getMinScaleDenominator();
       
 11413                 params.maxScale = layerConf.getMaxScaleDenominator();
       
 11414                 params.extent = layerConf.getBBOX();
       
 11415             }
       
 11416             return params;
       
 11417         }
       
 11418     };
       
 11419     return Config;
       
 11420 }();
       
 11421 CommonUtilsCheckRightManagement = function (woodman, Config) {
       
 11422     return {
       
 11423         check: function (options) {
       
 11424             if (!options) {
       
 11425                 return;
       
 11426             }
       
 11427             var _key = options.key;
       
 11428             var _resources = options.resources || [];
       
 11429             var _services = options.services || [];
       
 11430             if (!_resources || _resources.length === 0) {
       
 11431                 return;
       
 11432             }
       
 11433             if (!_services || _services.length === 0) {
       
 11434                 return;
       
 11435             }
       
 11436             var _rightManagement = {};
       
 11437             if (!_key) {
       
 11438                 if (!Config.isConfigLoaded()) {
       
 11439                     console.log('WARNING : ' + 'parameter \'apiKey\' has not been parametered, ' + 'and the contract key configuration has not been loaded, ' + 'so impossible to check yours rights !');
       
 11440                     return;
       
 11441                 } else {
       
 11442                     _key = Object.keys(Config.configuration.generalOptions.apiKeys)[0];
       
 11443                 }
       
 11444             }
       
 11445             if (_key) {
       
 11446                 if (!Config.isConfigLoaded()) {
       
 11447                     console.log('WARNING : ' + 'the contract key configuration has not been loaded, ' + 'so be carefull !');
       
 11448                     var _noRightManagement = {};
       
 11449                     for (var i = 0; i < _services.length; i++) {
       
 11450                         var service = _services[i];
       
 11451                         _noRightManagement[service] = [];
       
 11452                         for (var j = 0; j < _resources.length; j++) {
       
 11453                             var resource = _resources[j];
       
 11454                             _noRightManagement[service].push(resource);
       
 11455                         }
       
 11456                     }
       
 11457                     _noRightManagement.key = _key;
       
 11458                     return _noRightManagement;
       
 11459                 } else {
       
 11460                     for (var k = 0; k < _resources.length; k++) {
       
 11461                         var _resource = _resources[k];
       
 11462                         for (var l = 0; l < _services.length; l++) {
       
 11463                             var _service = _services[l];
       
 11464                             var params = Config.getServiceParams(_resource, _service, _key);
       
 11465                             if (!params || Object.keys(params).length === 0) {
       
 11466                                 console.log('WARNING : ' + 'contract key configuration has no rights to load this geoportal ' + 'resource (' + _resource + ') ' + 'for this service (' + _service + ') ');
       
 11467                                 continue;
       
 11468                             }
       
 11469                             if (!_rightManagement[_service]) {
       
 11470                                 _rightManagement[_service] = [];
       
 11471                             }
       
 11472                             _rightManagement[_service].push(_resource);
       
 11473                         }
       
 11474                     }
       
 11475                     if (!_rightManagement || Object.keys(_rightManagement).length === 0) {
       
 11476                         console.log('WARNING : ' + 'the contract key configuration has been loaded, ' + 'and the parameter \'apiKey\' has been parametered, ' + 'but, there is a problem on the mapping between the contract and the key !');
       
 11477                         return;
       
 11478                     }
       
 11479                     _rightManagement.key = _key;
       
 11480                     return _rightManagement;
       
 11481                 }
       
 11482             }
       
 11483         }
       
 11484     };
       
 11485 }({}, CommonUtilsConfig);
       
 11486 CommonUtilsSelectorID = function () {
       
 11487     var SelectorID = {
       
 11488         generate: function () {
       
 11489             var timestamp = Math.floor(Date.now());
       
 11490             return function () {
       
 11491                 return timestamp++;
       
 11492             };
       
 11493         }(),
       
 11494         name: function (id) {
       
 11495             var name = null;
       
 11496             var i = id.indexOf('-');
       
 11497             if (i === -1) {
       
 11498                 name = id;
       
 11499             } else {
       
 11500                 name = id.substring(0, i);
       
 11501             }
       
 11502             return name;
       
 11503         },
       
 11504         index: function (id) {
       
 11505             var index = null;
       
 11506             var name = this.name(id);
       
 11507             if (name !== id) {
       
 11508                 var i = name.indexOf('_');
       
 11509                 if (i !== -1) {
       
 11510                     index = name.substring(i + 1);
       
 11511                 }
       
 11512             }
       
 11513             return index;
       
 11514         },
       
 11515         uuid: function (id) {
       
 11516             var uuid = null;
       
 11517             var i = id.indexOf('-');
       
 11518             if (i !== -1) {
       
 11519                 uuid = parseInt(id.substring(i + 1), 10);
       
 11520             }
       
 11521             return uuid;
       
 11522         }
       
 11523     };
       
 11524     return SelectorID;
       
 11525 }();
       
 11526 CommonControlsLocationSelectorDOM = function (ID) {
       
 11527     var LocationSelectorDOM = {
       
 11528         _addUID: function (id) {
       
 11529             return id + '-' + this._uid;
       
 11530         },
       
 11531         _createMainContainerElement: function () {
       
 11532             var container = document.createElement('div');
       
 11533             container.className = this._addUID('GPlocationPoint');
       
 11534             container.className += ' GPwidget';
       
 11535             return container;
       
 11536         },
       
 11537         _createLocationPointElement: function (id, display) {
       
 11538             var div = document.createElement('div');
       
 11539             div.id = this._addUID('GPlocationPoint_' + id);
       
 11540             div.className = display ? 'GPflexInput GPlocationStageFlexInput' : 'GPflexInput GPlocationStageFlexInputHidden';
       
 11541             div.style.cssText = '';
       
 11542             return div;
       
 11543         },
       
 11544         _createLocationPointLabelElement: function (id, text) {
       
 11545             var self = this;
       
 11546             var labelOrigin = document.createElement('label');
       
 11547             labelOrigin.id = this._addUID('GPlocationOriginLabel_' + id);
       
 11548             labelOrigin.htmlFor = 'GPlocationOrigin_' + id;
       
 11549             labelOrigin.innerHTML = text;
       
 11550             labelOrigin.addEventListener('click', function (e) {
       
 11551                 var i = ID.index(this.id);
       
 11552                 var points = document.getElementsByClassName(self._addUID('GPlocationPoint'));
       
 11553                 for (var j = 0; j < points.length; j++) {
       
 11554                     var tag = points[j].childNodes[0].id;
       
 11555                     var id = ID.index(tag);
       
 11556                     document.getElementById(self._addUID('GPlocationPoint_' + id)).style.cssText = '';
       
 11557                 }
       
 11558                 document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).value = '';
       
 11559                 document.getElementById(self._addUID('GPlocationOrigin_' + i)).value = '';
       
 11560                 document.getElementById(self._addUID('GPlocationPoint_' + i)).style.cssText = '';
       
 11561                 document.getElementById(self._addUID('GPlocationOriginPointer_' + i)).checked = false;
       
 11562                 document.getElementById(self._addUID('GPlocationOrigin_' + i)).className = 'GPlocationOriginVisible';
       
 11563                 document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).className = 'GPlocationOriginHidden';
       
 11564                 if (document.getElementById(self._addUID('GPlocationStageRemove_' + i))) {
       
 11565                     document.getElementById(self._addUID('GPlocationStageRemove_' + i)).className = 'GPlocationStageRemove';
       
 11566                 }
       
 11567                 if (document.getElementById(self._addUID('GPlocationStageAdd'))) {
       
 11568                     document.getElementById(self._addUID('GPlocationStageAdd')).className = '';
       
 11569                 }
       
 11570                 self.onLocationClearPointClick(e);
       
 11571             });
       
 11572             return labelOrigin;
       
 11573         },
       
 11574         _createLocationAutoCompleteteInputElement: function (id) {
       
 11575             var self = this;
       
 11576             var inputOrigin = document.createElement('input');
       
 11577             inputOrigin.id = this._addUID('GPlocationOrigin_' + id);
       
 11578             inputOrigin.className = 'GPlocationOriginVisible';
       
 11579             inputOrigin.type = 'text';
       
 11580             inputOrigin.placeholder = 'Saisir une adresse';
       
 11581             inputOrigin.autocomplete = 'off';
       
 11582             inputOrigin.addEventListener('keyup', function (e) {
       
 11583                 var charCode = e.which || e.keyCode;
       
 11584                 if (charCode === 13 || charCode === 10 || charCode === 38 || charCode === 40) {
       
 11585                     return;
       
 11586                 }
       
 11587                 var i = ID.index(this.id);
       
 11588                 if (document.getElementById(self._addUID('GPlocationOrigin_' + i)).value.length > 2) {
       
 11589                     document.getElementById(self._addUID('GPlocationAutoCompleteList_' + i)).style.display = 'block';
       
 11590                 } else {
       
 11591                     document.getElementById(self._addUID('GPlocationAutoCompleteList_' + i)).style.display = 'none';
       
 11592                 }
       
 11593                 self.onAutoCompleteSearchText(e);
       
 11594             });
       
 11595             inputOrigin.addEventListener('keydown', function (e) {
       
 11596                 var charCode = e.which || e.keyCode;
       
 11597                 var container = document.getElementById(self._addUID('GPlocationAutoCompleteList_' + id));
       
 11598                 if (!container) {
       
 11599                     return;
       
 11600                 }
       
 11601                 var curr = container.getElementsByClassName('GPautoCompleteProposal current');
       
 11602                 var list = container.getElementsByClassName('GPautoCompleteProposal');
       
 11603                 var length = list.length;
       
 11604                 if (!length) {
       
 11605                     return;
       
 11606                 }
       
 11607                 var current = null;
       
 11608                 if (!curr.length) {
       
 11609                     current = list[0];
       
 11610                     current.className = 'GPautoCompleteProposal current';
       
 11611                     current.style.color = '#000000';
       
 11612                     current.style['background-color'] = '#CEDBEF';
       
 11613                     return;
       
 11614                 } else {
       
 11615                     current = curr[0];
       
 11616                 }
       
 11617                 var index = parseInt(ID.index(current.id), 10);
       
 11618                 var next = index === length - 1 ? list[0] : list[index + 1];
       
 11619                 var prev = index === 0 ? list[length - 1] : list[index - 1];
       
 11620                 current.style['background-color'] = '';
       
 11621                 current.style.color = '';
       
 11622                 prev.style['background-color'] = '';
       
 11623                 prev.style.color = '';
       
 11624                 next.style['background-color'] = '';
       
 11625                 next.style.color = '';
       
 11626                 switch (charCode) {
       
 11627                 case 38:
       
 11628                     console.log('arrow up');
       
 11629                     current.className = 'GPautoCompleteProposal';
       
 11630                     prev.className = 'GPautoCompleteProposal current';
       
 11631                     prev.style.color = '#000000';
       
 11632                     prev.style['background-color'] = '#CEDBEF';
       
 11633                     break;
       
 11634                 case 40:
       
 11635                     console.log('arrow down');
       
 11636                     current.className = 'GPautoCompleteProposal';
       
 11637                     next.className = 'GPautoCompleteProposal current';
       
 11638                     next.style.color = '#000000';
       
 11639                     next.style['background-color'] = '#CEDBEF';
       
 11640                     break;
       
 11641                 case 13:
       
 11642                     console.log('enter');
       
 11643                     current.click(e);
       
 11644                     break;
       
 11645                 }
       
 11646                 current.focus();
       
 11647             });
       
 11648             return inputOrigin;
       
 11649         },
       
 11650         _createLocationCoordinateInputElement: function (id) {
       
 11651             var self = this;
       
 11652             var inputOriginCoord = document.createElement('input');
       
 11653             inputOriginCoord.id = this._addUID('GPlocationOriginCoords_' + id);
       
 11654             inputOriginCoord.className = 'GPlocationOriginHidden';
       
 11655             inputOriginCoord.type = 'text';
       
 11656             inputOriginCoord.disabled = false;
       
 11657             inputOriginCoord.addEventListener('click', function () {
       
 11658                 var i = ID.index(this.id);
       
 11659                 document.getElementById(self._addUID('GPlocationOriginLabel_' + i)).click();
       
 11660             });
       
 11661             return inputOriginCoord;
       
 11662         },
       
 11663         _createLocationPointerShowInputElement: function (id) {
       
 11664             var inputOriginPointer = document.createElement('input');
       
 11665             inputOriginPointer.id = this._addUID('GPlocationOriginPointer_' + id);
       
 11666             inputOriginPointer.type = 'checkbox';
       
 11667             return inputOriginPointer;
       
 11668         },
       
 11669         _createLocationPointerInputElement: function (id) {
       
 11670             var self = this;
       
 11671             var labelOriginPointer = document.createElement('label');
       
 11672             labelOriginPointer.id = this._addUID('GPlocationOriginPointerImg_' + id);
       
 11673             labelOriginPointer.htmlFor = 'GPlocationOriginPointer_' + id;
       
 11674             labelOriginPointer.className = 'GPlocationOriginPointerImg';
       
 11675             labelOriginPointer.title = 'Pointer un lieu sur la carte';
       
 11676             labelOriginPointer.addEventListener('click', function (e) {
       
 11677                 e.preventDefault();
       
 11678                 e.stopPropagation();
       
 11679                 var i = ID.index(this.id);
       
 11680                 var points = document.getElementsByClassName(self._addUID('GPlocationPoint'));
       
 11681                 var j;
       
 11682                 var tag;
       
 11683                 var id;
       
 11684                 for (j = 0; j < points.length; j++) {
       
 11685                     tag = points[j].childNodes[0].id;
       
 11686                     id = ID.index(tag);
       
 11687                     if (i != id) {
       
 11688                         document.getElementById(self._addUID('GPlocationOriginPointer_' + id)).checked = false;
       
 11689                         if (document.getElementById(self._addUID('GPlocationOriginCoords_' + id)).value == 'Pointer un lieu sur la carte') {
       
 11690                             document.getElementById(self._addUID('GPlocationOriginCoords_' + id)).value = '';
       
 11691                             document.getElementById(self._addUID('GPlocationOrigin_' + id)).className = 'GPlocationOriginVisible';
       
 11692                             document.getElementById(self._addUID('GPlocationOriginCoords_' + id)).className = 'GPlocationOriginHidden';
       
 11693                         }
       
 11694                     }
       
 11695                 }
       
 11696                 if (document.getElementById(self._addUID('GPlocationOriginPointer_' + i)).checked) {
       
 11697                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).value = '';
       
 11698                     for (j = 0; j < points.length; j++) {
       
 11699                         tag = points[j].childNodes[0].id;
       
 11700                         id = ID.index(tag);
       
 11701                         document.getElementById(self._addUID('GPlocationPoint_' + id)).style.cssText = '';
       
 11702                     }
       
 11703                     if (document.getElementById(self._addUID('GPlocationStageRemove_' + i))) {
       
 11704                         document.getElementById(self._addUID('GPlocationStageRemove_' + i)).className = 'GPlocationStageRemove';
       
 11705                     }
       
 11706                     if (document.getElementById(self._addUID('GPlocationStageAdd'))) {
       
 11707                         document.getElementById(self._addUID('GPlocationStageAdd')).className = '';
       
 11708                     }
       
 11709                     document.getElementById(self._addUID('GPlocationOriginPointer_' + i)).checked = false;
       
 11710                     document.getElementById(self._addUID('GPlocationOrigin_' + i)).className = 'GPlocationOriginVisible';
       
 11711                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).className = 'GPlocationOriginHidden';
       
 11712                 } else {
       
 11713                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).value = 'Pointer un lieu sur la carte';
       
 11714                     for (j = 0; j < points.length; j++) {
       
 11715                         tag = points[j].childNodes[0].id;
       
 11716                         id = ID.index(tag);
       
 11717                         if (i == id) {
       
 11718                             document.getElementById(self._addUID('GPlocationPoint_' + id)).style.cssText = '';
       
 11719                         } else {
       
 11720                             document.getElementById(self._addUID('GPlocationPoint_' + id)).style.display = 'none';
       
 11721                         }
       
 11722                     }
       
 11723                     if (document.getElementById(self._addUID('GPlocationStageRemove_' + i))) {
       
 11724                         document.getElementById(self._addUID('GPlocationStageRemove_' + i)).className = 'GPlocationOriginHidden';
       
 11725                     }
       
 11726                     if (document.getElementById(self._addUID('GPlocationStageAdd'))) {
       
 11727                         document.getElementById(self._addUID('GPlocationStageAdd')).className = 'GPlocationOriginHidden';
       
 11728                     }
       
 11729                     document.getElementById(self._addUID('GPlocationOriginPointer_' + i)).checked = true;
       
 11730                     document.getElementById(self._addUID('GPlocationOrigin_' + i)).className = 'GPlocationOriginHidden';
       
 11731                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).className = 'GPlocationOriginVisible';
       
 11732                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).disabled = true;
       
 11733                 }
       
 11734                 self.onActivateMapPointClick(e);
       
 11735             });
       
 11736             return labelOriginPointer;
       
 11737         },
       
 11738         _createLocationRemovePointElement: function (id) {
       
 11739             var self = this;
       
 11740             var divRm = document.createElement('div');
       
 11741             divRm.id = this._addUID('GPlocationStageRemove_' + id);
       
 11742             divRm.className = 'GPlocationStageRemove';
       
 11743             divRm.title = 'Supprimer l\'étape';
       
 11744             divRm.addEventListener('click', function (e) {
       
 11745                 var points = document.getElementsByClassName(self._addUID('GPlocationPoint'));
       
 11746                 var last = points.length - 1;
       
 11747                 var start = points[0].childNodes[0].id;
       
 11748                 var end = points[last].childNodes[0].id;
       
 11749                 var startID = ID.index(start);
       
 11750                 var endID = ID.index(end);
       
 11751                 if (id != startID && id != endID) {
       
 11752                     var i = ID.index(this.id);
       
 11753                     document.getElementById(self._addUID('GPlocationPoint_' + i)).className = 'GPflexInput GPlocationStageFlexInputHidden';
       
 11754                     document.getElementById(self._addUID('GPlocationOrigin_' + i)).value = '';
       
 11755                     document.getElementById(self._addUID('GPlocationOrigin_' + i)).className = 'GPlocationOriginVisible';
       
 11756                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).value = '';
       
 11757                     document.getElementById(self._addUID('GPlocationOriginCoords_' + i)).className = 'GPlocationOriginHidden';
       
 11758                     document.getElementById(self._addUID('GPlocationStageAdd')).style.display = '';
       
 11759                     self.onLocationRemovePointClick(e);
       
 11760                 }
       
 11761             });
       
 11762             return divRm;
       
 11763         },
       
 11764         _createLocationAddPointElement: function () {
       
 11765             var self = this;
       
 11766             var divAdd = document.createElement('div');
       
 11767             divAdd.id = this._addUID('GPlocationStageAdd');
       
 11768             divAdd.title = 'Ajouter une étape';
       
 11769             divAdd.addEventListener('click', function (e) {
       
 11770                 var lastStage = 1;
       
 11771                 var nbStages = 0;
       
 11772                 var points = document.getElementsByClassName(self._addUID('GPlocationPoint'));
       
 11773                 for (var i = 1; i < points.length - 1; i++) {
       
 11774                     var tag = points[i].childNodes[0].id;
       
 11775                     var id = ID.index(tag);
       
 11776                     if (document.getElementById(self._addUID('GPlocationPoint_' + id))) {
       
 11777                         if (document.getElementById(self._addUID('GPlocationPoint_' + id)).className == 'GPflexInput GPlocationStageFlexInputHidden') {
       
 11778                             if (lastStage == 1) {
       
 11779                                 lastStage = id;
       
 11780                             }
       
 11781                         } else {
       
 11782                             nbStages++;
       
 11783                         }
       
 11784                     }
       
 11785                 }
       
 11786                 if (lastStage < points.length) {
       
 11787                     document.getElementById(self._addUID('GPlocationPoint_' + lastStage)).className = 'GPflexInput GPlocationStageFlexInput';
       
 11788                 }
       
 11789                 if (nbStages == 4) {
       
 11790                     document.getElementById(self._addUID('GPlocationStageAdd')).style.display = 'none';
       
 11791                 }
       
 11792                 self.onLocationAddPointClick(e);
       
 11793             });
       
 11794             return divAdd;
       
 11795         },
       
 11796         _createLocationAutoCompleteResultElement: function (id) {
       
 11797             var self = this;
       
 11798             var div = document.createElement('div');
       
 11799             div.id = this._addUID('GPlocationAutoCompleteList_' + id);
       
 11800             div.className = 'GPadvancedAutoCompleteList';
       
 11801             if (div.addEventListener) {
       
 11802                 div.addEventListener('click', function (e) {
       
 11803                     self.onAutoCompletedResultsItemClick(e);
       
 11804                     document.getElementById(self._addUID('GPlocationAutoCompleteList_' + id)).style.display = 'none';
       
 11805                 }, false);
       
 11806             } else if (div.attachEvent) {
       
 11807                 div.attachEvent('onclick', function (e) {
       
 11808                     self.onAutoCompletedResultsItemClick(e);
       
 11809                     document.getElementById(self._addUID('GPlocationAutoCompleteList_' + id)).style.display = 'none';
       
 11810                 });
       
 11811             }
       
 11812             return div;
       
 11813         },
       
 11814         _createLocationAutoCompletedLocationElement: function (id, location, n) {
       
 11815             var container = document.getElementById(this._addUID('GPlocationAutoCompleteList_' + id));
       
 11816             var div = document.createElement('div');
       
 11817             div.id = this._addUID('AutoCompletedLocation_' + n);
       
 11818             div.className = 'GPautoCompleteProposal';
       
 11819             div.innerHTML = location.fullText;
       
 11820             container.appendChild(div);
       
 11821         },
       
 11822         GPdisplayCoordinate: function (value) {
       
 11823             var points = document.getElementsByClassName(this._addUID('GPlocationPoint'));
       
 11824             for (var i = 0; i < points.length; i++) {
       
 11825                 var tag = points[i].childNodes[0].id;
       
 11826                 var id1 = ID.index(tag);
       
 11827                 if (document.getElementById(this._addUID('GPlocationOriginPointer_' + id1)).checked) {
       
 11828                     document.getElementById(this._addUID('GPlocationOriginCoords_' + id1)).value = value;
       
 11829                     document.getElementById(this._addUID('GPlocationOriginCoords_' + id1)).disabled = false;
       
 11830                     for (var j = 0; j < points.length; j++) {
       
 11831                         tag = points[j].childNodes[0].id;
       
 11832                         var id2 = ID.index(tag);
       
 11833                         document.getElementById(this._addUID('GPlocationPoint_' + id2)).style.cssText = '';
       
 11834                         if (document.getElementById(this._addUID('GPlocationStageRemove_' + id2))) {
       
 11835                             document.getElementById(this._addUID('GPlocationStageRemove_' + id2)).className = 'GPlocationStageRemove';
       
 11836                         }
       
 11837                     }
       
 11838                     document.getElementById(this._addUID('GPlocationOriginPointer_' + id1)).checked = false;
       
 11839                     if (document.getElementById(this._addUID('GPlocationStageAdd'))) {
       
 11840                         document.getElementById(this._addUID('GPlocationStageAdd')).className = '';
       
 11841                     }
       
 11842                     return;
       
 11843                 }
       
 11844             }
       
 11845         }
       
 11846     };
       
 11847     return LocationSelectorDOM;
       
 11848 }(CommonUtilsSelectorID);
       
 11849 LeafletControlsUtilsPositionFormater = function () {
       
 11850     var PositionFormater = {
       
 11851         NORTH: 'N',
       
 11852         SOUTH: 'S',
       
 11853         EAST: 'E',
       
 11854         WEST: 'W',
       
 11855         digitSecond: 2,
       
 11856         digitDecimal: 5,
       
 11857         digitRadian: 8,
       
 11858         roundToDecimal: function (inputNum, numPoints) {
       
 11859             var multiplier = Math.pow(10, numPoints);
       
 11860             return Math.round(inputNum * multiplier) / multiplier;
       
 11861         },
       
 11862         decimalToRadian: function (location) {
       
 11863             var d = 0.017453292519943295;
       
 11864             return this.roundToDecimal(location * d, this.digitRadian);
       
 11865         },
       
 11866         decimalToGrade: function (location) {
       
 11867             var d = 1.1111111111111112;
       
 11868             return this.roundToDecimal(location * d, this.digitRadian);
       
 11869         },
       
 11870         decimalToDMS: function (location, hemisphere) {
       
 11871             if (location < 0) {
       
 11872                 location *= -1;
       
 11873             }
       
 11874             var degrees = Math.floor(location);
       
 11875             var minutesFromRemainder = (location - degrees) * 60;
       
 11876             var minutes = Math.floor(minutesFromRemainder);
       
 11877             var secondsFromRemainder = (minutesFromRemainder - minutes) * 60;
       
 11878             var seconds = this.roundToDecimal(secondsFromRemainder, this.digitSecond);
       
 11879             var dms = degrees + '\xB0 ' + minutes + '\' ' + seconds + '" ';
       
 11880             if (hemisphere) {
       
 11881                 dms += hemisphere;
       
 11882             }
       
 11883             return dms;
       
 11884         },
       
 11885         decimalLatToDMS: function (location) {
       
 11886             var hemisphere = location < 0 ? this.SOUTH : this.NORTH;
       
 11887             return this.decimalToDMS(location, hemisphere);
       
 11888         },
       
 11889         decimalLongToDMS: function (location) {
       
 11890             var hemisphere = location < 0 ? this.WEST : this.EAST;
       
 11891             return this.decimalToDMS(location, hemisphere);
       
 11892         },
       
 11893         DMSToDecimal: function (degrees, minutes, seconds, hemisphere) {
       
 11894             var ddVal = degrees + minutes / 60 + seconds / 3600;
       
 11895             ddVal = hemisphere == this.SOUTH || hemisphere == this.WEST ? ddVal * -1 : ddVal;
       
 11896             var decimal = this.roundToDecimal(ddVal, this.digitDecimal);
       
 11897             return decimal;
       
 11898         }
       
 11899     };
       
 11900     return PositionFormater;
       
 11901 }();
       
 11902 LeafletControlsUtilsIconDefault = function (L) {
       
 11903     var IconDefault = L.Icon.Default.extend({
       
 11904         images: {
       
 11905             shadow: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAC5ElEQVRYw+2YW4/TMBCF45S0S1luXZCABy5CgLQgwf//S4BYBLTdJLax0fFqmB07nnQfEGqkIydpVH85M+NLjPe++dcPc4Q8Qh4hj5D/AaQJx6H/4TMwB0PeBNwU7EGQAmAtsNfAzoZkgIa0ZgLMa4Aj6CxIAsjhjOCoL5z7Glg1JAOkaicgvQBXuncwJAWjksLtBTWZe04CnYRktUGdilALppZBOgHGZcBzL6OClABvMSVIzyBjazOgrvACf1ydC5mguqAVg6RhdkSWQFj2uxfaq/BrIZOLEWgZdALIDvcMcZLD8ZbLC9de4yR1sYMi4G20S4Q/PWeJYxTOZn5zJXANZHIxAd4JWhPIloTJZhzMQduM89WQ3MUVAE/RnhAXpTycqys3NZALOBbB7kFrgLesQl2h45Fcj8L1tTSohUwuxhy8H/Qg6K7gIs+3kkaigQCOcyEXCHN07wyQazhrmIulvKMQAwMcmLNqyCVyMAI+BuxSMeTk3OPikLY2J1uE+VHQk6ANrhds+tNARqBeaGc72cK550FP4WhXmFmcMGhTwAR1ifOe3EvPqIegFmF+C8gVy0OfAaWQPMR7gF1OQKqGoBjq90HPMP01BUjPOqGFksC4emE48tWQAH0YmvOgF3DST6xieJgHAWxPAHMuNhrImIdvoNOKNWIOcE+UXE0pYAnkX6uhWsgVXDxHdTfCmrEEmMB2zMFimLVOtiiajxiGWrbU52EeCdyOwPEQD8LqyPH9Ti2kgYMf4OhSKB7qYILbBv3CuVTJ11Y80oaseiMWOONc/Y7kJYe0xL2f0BaiFTxknHO5HaMGMublKwxFGzYdWsBF174H/QDknhTHmHHN39iWFnkZx8lPyM8WHfYELmlLKtgWNmFNzQcC1b47gJ4hL19i7o65dhH0Negbca8vONZoP7doIeOC9zXm8RjuL0Gf4d4OYaU5ljo3GYiqzrWQHfJxA6ALhDpVKv9qYeZA8eM3EhfPSCmpuD0AAAAASUVORK5CYII=',
       
 11906             color: {
       
 11907                 blue: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw7VXeUyTZxjvNnfELFuyIzOabermMZEeQC/OclkO49CpOHXOLJl/CAURuYbQi3KLgEhbrhZ1aDwmaoGqKII6odATmH/scDFbdC7LvFqOCc+e95s2VG50X/LLm/f4/Z7neY/ne18aANCmAr5E/xZf1uDOkTcGcWR6hl9247tT5U7Y6SNvWsKT63P58qbfeLJG8M5qcgTknrvvrdDbsT7Ml+tv82X6vVxJE33aRmgSyYtcWVMqX97Yv2JvW39UhRE2HuyBL+t+gK1116ly06EeWFNlAmHxlQE0OMiV6mQCScusKRlhS3QLeVJdl1+23h5dY4FNB3thrbYboqptEFlphTC1hSpJnbRvxP4NWgsE5Jyz86QNNi/5qSUTGuFk1gu54tN9wuK2wc3o+Wc13RCmsoBwEqzGcZsxsvCSy/9wJKf7UWf1mEY8JWfewc67UUoDbDjQC+FqK4QqLVMGGR9d2wurKzqBk3nqIT/9zLxRRjgZ9bqQgub+DdoeCC03Q8j+0QhFhBHR/eP3U/zCln7Uu+hihJ1+bBNffLIvmkyP0gpBZWYXhKussK6mBz5HT6M1Nqpcp+mBCPXosYQfrekGvrjewd59/GvKCE7TbK/04/ZV5QZYVWmDwH1mF3xa2Q3ra3DBC5vBT1oP7PTj4C0+CcL8c7C2CtejqhuCnuIQHaKHzvcRfZpnylFfXsYJx3pNLwhKzRAwAhEqG0SpusBHfAKkxw3w4627MPhoCH798z7s0ZnBJ/MEJbZSbXPhER2ih7p2ok/zSj2cEJDd4CAe+5WYnBCgR2uruyEw6zRoW6/DWJ/OeAP8pd/BGtzOZKpG8oke0SX6GMmRk6GFlyAc59K32OTEinILRJRchah8HQwND8N435Z9Z0FY1EqtxUg+0SO6RJ/mmXz4VuS+DpxXC3gXmZwIL7dBSH4zKE50wESf8qwVgrP1EIlTO5JP9Igu0aexdh28F1lmAEGJGfh7jE6ElyM5Rw/FDcYJjWhbeiBYoYNIpc2FT/SILivp0F1ipDWk4BIEo2VuodEJUifhbiltnNBIXPUFCMpthtAyqws/BPlEF/VbaIxErdxPphsU7rcCp8DohC+GvBIPJS/tW2jtvTmmAeuNO8BNOYQeG8G/2OzCJ3q+soYB5i6NhMaKr17FSal7GIHheuV3uSCY8qYVuEm1cOzqdWr7ku/R0BDoTT+DT+ohCM6/CCvKLKO4RI+dXPeAuaMqksaKrZ7L3FE5FIFbkIceeOZ2OcHO6wIhTkNo0ffgjRGxEqogXHYUPHfWAC/lADpwGcLRY3aeK4/oRGCKYcZXPVoeX/kelVYY8dUGf8V5EBRbgJXT5QIPhP9ePJi428JKOiEYhYXFBqou2Guh+p/mEB1/RfMw6rY7cxcjTrneI1FrDyuzUSRm9miwEJx8E/gUmqlyvHGkneiwErR21F3tNOK5Tf0yXaT+O7DgCvALTUBXdM4YhC/IawPU+2PduqMvuaR6eoxSwUk75ggqsYJ7VicsnwGIkZBSXKOUww73WGXyqP+J2/b9c+gi1YAg/xpwck3gJuucNrh5JvDPvQr0WFXf0piyt8f8/WI0hV4pRxxkQZdJDfDJNOAmM0Ag8jyT6hz0WGXWuP94Yh2jcfjmXAGvHCMslRimDHYuHuDsy2QtHuIavznhbYURq5R57KpzBBRZKPJi8eQg48h4j8SDdowifdIrEVdU+gbO6QNvRRt4ZBthUaZhUnjlYObNagV3keoeru3rU7rcuceqU1mJBxy+BWZYlNEBH+0eH4vRiB+OYybU2hnblYlTvkHinM4m54YnxSyaZYSF6R3jwgP7udKLGIX6r/lbNa9N6y5MFynjWDtrHd75ZvTYAPO/6RgF0k76mQla3FGq7dO+cH8sKn0Vo7nDllwAhqwLPkxrHwWmHJOo+AKJ4rab5OgrM7rVu8eWb2Pu0Dh4eDgXoOfvp7Y7QeqknRmvcTBEyq9m/HQQSCSz6LHq3z0yzsNySRfMS253wl2KyRDbcZPcfJKjZmSEOjcxyi+Y8dUOtsIEH6R2wNykdqrkYJ0RV92H0W58pkfQk7cKevsLK10Py8SdMGfXNXATY+pPbyJR/ET6n9nIfztNtZYRV9XniQu9IA2vOVgy4ir7GCLVmmd+zjkH0eAF9Po6K61pmCXHxU5rHMYd1ftc3owjwRSVRzLjKvqZEty6cRUD7jGqiOdu5HG6MdHjNcNYGqfDm5YRzLBBCCDl/2bk8a8gdbqcfwECu62Fg/HrggAAAABJRU5ErkJggg==',
       
 11908                 orange: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAASAAAAEgARslrPgAABghJREFUWMOdl1uInGcdxn/feWa+mflmJmZbqVqKigewKK5goHgRSEm8EC88F6tBFLfgZbzJnVdRYWExrVBoXazWlAYL0dVisLBYzEUUSbeNjZQmxGZ3NjO7c57v/P69mNnD7MzuzvrCA8PM+/+e93n+h/cb7c9PzXKE9RHAG36+BXRPP3390CDtT3MHklSA7wKngVOWbaOhA5AkEUqpKnAFePHMM9eX9yeZrMQAzgHni14ln826ZLLu2KY0TfD7XXq9NoHffxX48Zmnr6+MkSyNK6kAl4ql8qlisYxpWagoJA16gIxs1E0bI1cAoNNuslFb94Env/jM9csj+0SEXaiIyN+9cuVU5dhxdEmI23XSoAOoIckOVBISt+vE7Q0KRY8H3v+BbM7Nv7w0Nzs3QrLHopdL5crHyqUKSbdB6ndA1BRIiVs1Mo5NySsD/GJpbvbkjpKds50rFL2T5VKZpNdAkmjiAzXDHOye8FvS2cC2LWZmHjAELv1xbrYyIFGCKKmIkvMlr4iK+0gaDe0ZQHcyWIUyVqGMmDZWvoRVKGO63sg+UMSdGq6bo+R5x0XJuYFdGqDxLa9UzJumQRp0R3y3ChU002Zjc5Pbd+6wGem8e/sO6+vrBGGIVagMTdmJScMepZIHGj/4ww8/a5jDevl63s2h4nAgfbhM1yOMQt67V+WjZ87y+VNPYmXzANz7x19YufQzilFIySsTt+vbcSrsYTlZnEymEgTBCV2U5EXJiUzGJg1aI9I1w6DZbPHoE+f5+Jee2iYAeGj2cR479zyNjo+SFN12xqzLZRxEyWld4EOWbRmIApVuJ1E3LaIwRLkzPPzYl8caUURwZz7Iw1/4Cq1WG8POjBSBCvvYtonAJ3URqeiaNlYpuuXg+wHlRz41kQBAKUX5w5+m1/PHKk7SBF0DEfFMgUjJMGnaro7WFGig0nhfAhEhjQI0TRuL1wwNFSkEfF2Ee3GSjp0kDXq4WZv7b19HJeNEWySrN/5G3nUQlezpJ4MkTRHhni4i1ThOuipNByfakhsHmIZGRnV565WLYyoA1t68RuONq3j5DKnfHiXRdKIoRkTuGl/9zIMCfC7rGJ/I5vOocGsQCoiQz7vc/8+/WH37BrnKgzjFY7RWb/Pu8mVWLv2UmUoOxzYGJFtxmobhZFmrd0hS9SPtpbOPApx0s/ZfH3moRNyujU5aO4eRcWl2AjZbPn6YYFsGXt6h4mUxDX0sxioep9kJeG+9ffVrz994fKsZX+v60bVuPzzhFo6RdHY1VtRDEp9S4RilgjPyMBX2iXu90dIbFsFm20fgJwCm7BTEzzda/u/zrjVspl2JVoq4vc40yyrO0OqGdPvxa9/41Y3XYfQ+udLshO8EQYyZK0454idAKTYafUTkwrblu0Z9KjBfb/pouvl/EZhuma4f0e7H//zm4htXt0n23HaL9VZQS5IU3c4emUTTNOoNH9hRsVcJAr7As7VWgJHJDTp4SpiFMv0oodGLbwm8MkoyescjIgtrm4GvlEI37SOo0Kk1AkTkwhOLK+keEtiDmggv1FshRrYwFYGRLRJEKfV2fFeEF/dW3F67tjB/txamIoKm65N37IJu2dRaEQLz3/71m9E4ybhdiMgtEVna7EQY+Qoial/oTo4oTqk2opqIPDepd/QDzjh/vxmDOtgq3cqy3ogQuPidF97qTiaZrAQRWW776bVOkGIW3jfZJidHqoTVRtwVkYX9psCkxO/GwnojRhvMlvGE2zmqzRgRfnn2Nzdb+5McnNbL9a56x48FI+vtSbaDaPDfjSQSmD9onh1kFyKSishCtZmgW/ZY2a5txojI4vd+e7N6CMmBdiHC4lojrcWpoDsuIGimhYhwp5amIlzgkKUf1gMgXZBnq40Ew8kNBmGuxHozAeSl7//u37cPJTmUYoCLdzdVJMNcgLDWFoTDVUxrFyJURVisNhVGzqPWVvQCWRJhZSqS4Qv3NFhYaw10rbUENC4MansaJYO/DtPgZi+QK7W20OrLsih5XZRMSTJdTrZHzWpzkIut76az62hrueXzHPDqUYL+B8XVKUzuUimfAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDEyLTA4LTE4VDE0OjUwOjU2KzAxOjAwFlCkXwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMi0wOC0xOFQxNDo1MDo1NiswMTowMGcNHOMAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAAAElFTkSuQmCC',
       
 11909                 red: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAASAAAAEgARslrPgAABe5JREFUWMOdlWuIXGcZx3/nPbe5ZWbO2c0a8VIEpSq0io2QBT8FUlIFEbzfokUUKfgxIuSbn+JtYTEQqFQCQmkxVIiNFhcLwZoVtrFNt40ESrPEJju7s/eZM+f+Pn6Y2XVnZ3Zn0/fwcA7veZ/ze5//87zPMf56fJIHGB8Far3n20D79Nz1kU7GXw6G+MD3gdPAKdtxMJQFQJZEaK0bwBXg2Sfmrl87AHJi2LwJnAXOVf3xSrFcoVAuDyzKs4yw3SLY2iTqBC8BP31ibnZ+AHJ1MBIfeK7qeaeqno9l2+g4IQ86ILpvoXIczCMVAFob66wuLYXAmc/PXb/cB3nxsRN7AdfrY2MPe+Pj6Cjufnyk6Aa2XyfshLQ21glarae+8OrsxZ3N7JHoj3Xff9jzx8jWN8hbbdB6tOU5aXOVguNQ98YAfnv1+OTJHYgAPTt7pFY76Xk+2fo6kiSg8wEzLLMr25B32eoqjm0x8b5jpsBzLx6f9LsQARF8Ec7Vq1V0J0CSuM9ZFVxsr47t1RHHxq7XsL06Vq06AEqby5RLReq12lERzvbkEkC+VatWKpapyNtt6JERwfY9DMdmdW2NOwsLrCmDdxYWWFpaIopjbN/rarLLJw8C6rUqID/682MnTEsQgK9XSiV0nHQ17g2rViWOI95tLPOxJ89w4sx3sCvdarr3txnmf/kbqnFE3auTrqzu+OkgwC4WcAuuH0XRpBKhIsJkwbHJN9f79TcVG5tbPHruZ3z8qR/vAAA+8PgpPvf737Eehug8Rbn2gHQl10WE00rgw7ZtmdtVspMH2yKJY/TEBA996YsDVSsilD/0QR76ypfZ3GphFgp9AN3p4FgmAp9UIuIrQw2UpXJdwijGe+SRoQAArTXepz9FEEbdfOzylyxHddfWLEESLbpblrtPtM4AQafJvgARIY8iDMMY8DcM6a5BQiUY99I8H9hJHgSUHZvluVfRaToA2obc/8c/qbg2kqV9/oapyPIcwbinRKSRZnlb53l3R9vhRjGWAYV2i7cuXByIAmBx9l+sz8xQK7jkW1v9EKVI0hQRuWt+9dj7Bfhs0VSfKFZK6CDoq/lKucTya69x/+Y8pWPHcMd8Nu8s8M7lF5j/xa+ZKBVwTdWFbPsZBmaxwGIrINP6J8bzj34G4GTZcf7+kXqFtNns77SlMma5xEaUsBbGhFmGY5rUXBu/6GIpNeBjHz3KRpTw7lZ75ms3bzxudQXg5XaSzLbjZLI8Nka2srLrYLWRqEPdH6Pu2n0f050OaRD0l54yQIS1MELg5wDbEIBfrYbRCxW3MvDfkEyTLi+NavjdKMYn2Ixi2mn28jdu3nil1yCFnl3ZiNO3ozjtNb5DtPihbV+z2okRkfPDWn0uMLUSxhim9Z4AlufRThK20uzGN9/498wOhN0HUfSllShuZnmOKhXZ826kGYbBSicG0ed3S7g7EgRCgaebYYxZLvW/GWGW79HJM9bT7LbAn/oh/8/Jtk0vRkmotUY5zqGlMpSi2cvFt+dfz/dEYrDHmoLxh5Uwxjxy5FAAs1olynJWUn1XMJ7dW3FKGHpN3Y2yXEQwTDVSKuU6NKMEQaa+++brySBkUC5E5LaIXF2LE0zfR7Te11SpRJLlNJK8KSLPDDs76oA9Ti3H+UipVLHIUpggcOF7b73RHg4ZHgkicm0r17OtLMc6Oj5cpnKJXAv3U90Wken9uoAaUZzTS1GGIQxPeLFEI04RuPjkrfnN9wq5vKJ5OxTBrNb2JNtFFPw3lURg6qB+dpBciEguItONOEO5zkDZLoYpInLpB7fmGwdDRp/nS4sZzVQEVS6DCIZjIyIspOQC5xkx1O6/4D7WRuTpRpRhlkrdRlirsxRnIPL8D//z5p2RkH0O497rwt2cRBBUwQWExVwQZGQUPchAWxlmDcG41Eg0Zq1GM9EEoq4KxvyhIA/QaacXs+5z736+O3+YSEamZMduBaKuNFNhU9Q1EV6RwzEOnZOdxnk/7eZie+aQcj3QuLaJegZ46UGc/gcUeTtzDg/o4wAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMi0wOC0xOFQxNDo1MDo1NiswMTowMBZQpF8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTItMDgtMThUMTQ6NTA6NTYrMDE6MDBnDRzjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==',
       
 11910                 green: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wJCgoDDgqHD/MAAAZVSURBVFjDpZZtiFxXGcd/c+69M7PzurvdTTZNGvxQTCJqFSok+MmFQPSDUlsQhBaxWNhorQlWPxSKTYqsFLYGA8VCISDESIpCILYQW4xJNtHGGBooZtl16UrKNrMvM7N3Xu6555zHD7OZ7OzsW/Be/nBnznnO/zzP83/OcxKPv/IOW32KXzj2KFBc/nm7cuvl8IOXD21ql3j8lT9vsOjxfuB7wCHgoAoUCV8BYJsWRGaBc8DpvzwxfnF9kl90kxQ+f9wDXgReyg9kc8VkH4Wg2DUvdpqyXqRcKxOH5l3gZ+89OX5rDZLzqwhe7QfOZAcyB4fSO0h6KbSNqNt6F0lSJcn4WQA+bcyycHehATzz3pPjb6+cp0SEe8jvOdYvsRvPDmQOPpLZjRXLYjRPzYSIuC5EtsliNE9ZL7ItvY2dD+/sSRaDs8Nn9o90kLQ92HvcA87mduT27Mw8QiWuUDMhVuymMC5mPpoj42UYyu0A+M3wmf3D90lEQATgxfT29PDDPTup6jKx08gar6+CNf8XhEW9QEqlGNw16AFnhs/s72+FC6Gw79V+4KXtPUPUbZ3IRR07DVSSQlCkEBRRCdX+zvn5Lq/mohKFoEh2KDO4LB4ULUe+mxpI5RSKMA5xIm0Ug16SKsknjTtMfTxFGIdMfTzFzOIMoVmiGPQCdNjUTY3B9HZEeO5rv9/v+YggwncK6QKxxB3qyQU5aibk7iclvv3YUzz91WfJ+wUALsy+w+sf/opGusFgahuLerFt17BN0l4PQc7v10vmgJ/f98sccCDjZ5mP5jpIvITHYljm+QNH+NaupzrGDg59nc/m9/KDC08TD8UEyqdhG+1xh8PP+eglc0jhZLeXUp4V2yFPPxFQNzWymWwXAYAg7M5+hm/s+yZzzRIpL91hXzc1kioAJ59TQH9C3WOXNlJeitCEfLH3S2sSAFgxPNb7ZXQl7rJ3IiRaCxd9caLFgXUGcdJeyDiDiKBdtC6BE6FhGygv0WUvnsOKRZw0FHDHRg6HdCzWtHXyQZ4bn17HrBKEFdNaAMel0l/xcz5WbOd5hcI4A3BHiWPWaReKuNYOjEOMw2hDggQudpyceL3DC9cqXsZLl7g+9Q8KQYEls9S2FePwEgrbsIhjxuvb+2tJDYx/RXJuXzbI0dRR+xBwypDtyXLrvx9yLbzC9vR2HkoO8J9wkrMzp/nt+Bv0DKbwVUCj0VxxeEAQJKneDRErz/siAk5ONueiJzI7MrAirroe4zJC70NFphem+PnkUWzkUH6CZG9A364iXsKjulTprK98nqV6Fde0F/72/Q8+8hGh8u+fvl/Y89rVWn/tQDaXI6wu3e8ZYYzxLflsjlymU2UN2yAO4zUbVXNeIyLHAHzuJ/w1XY7/mN7mWKUBJHZUy9UttehsMUtYD7EN8/6lZ69fBmiFCxDLuWhBT0b90aN+zm9r/0EfEdfywjLaddRXJ45aYCxa0PjKp53FB0CqN0mzGWFC88/Lz12/sKIzrpjn5FRzLioZZ/B6fMTxQFAkiBY04mS0szOuYKlOHG0g8mazFOGlFGJly0jmfXQ9Rpf1bUT+tG6PX87PiWg+aiDgpbyWpLeARKCIyjHA6JWRG3ZVjxdWojJxpAT8rjkX4We9LSU7KATYhiWu6Bng9OpxtVYCxTHWLEX2XmE6tzGUnyAqx4hj7MrIDd1FsjpcIkJl4oXbYuW8rhqSfUkkduvCSymsdkRzUUmsvLWWp2o9OYqTsWhRb6pcP+ujyzHi5OTVH/8rXJNkLU9EhOrUCxdNzVw1NUN6ILlmsv2MhxhHcy4KgRPr5awr8Z3ghC7r5Uru3oif8YgWNMAb135ys7I+yYbx4O24aiZt5Ej2JjsvGSkPBKJ5rRHGNlLfuuESESqTP7IiLW+UrxBLG0E+aFW3cOrakZuzG5JsHC4BOKUrpuRM64ojTlB+AhGhOa8tMLpZHanN1FOZ/GEIvBlXYvweBSIk+wJ0q7r/8PejN6c3JdnSCevkZLSgtdhWLsSBLmtYdRD+H+ESKlOHZ8XJqbgaExQC4iWD0+58Zerwra2RbM7B8qX8hK7EiBN0WSPC6OoOun5O2NpbnT78kdXunKlbbOQuVqcPX5YtsqgH636M6bIGYbTj/rN5Trb+VKdHLtqme6s6PfLug9j9D/FCc1g2qf7VAAAAAElFTkSuQmCC'
       
 11911             }
       
 11912         },
       
 11913         initialize: function (color, options) {
       
 11914             L.Util.extend(this.options, options);
       
 11915             switch (color) {
       
 11916             case 'red':
       
 11917                 this.options.iconUrl = this.images.color.red;
       
 11918                 break;
       
 11919             case 'green':
       
 11920                 this.options.iconUrl = this.images.color.green;
       
 11921                 break;
       
 11922             case 'orange':
       
 11923                 this.options.iconUrl = this.images.color.orange;
       
 11924                 break;
       
 11925             case 'blue':
       
 11926                 this.options.iconUrl = this.images.color.blue;
       
 11927                 break;
       
 11928             default:
       
 11929                 this.options.iconUrl = this.images.color.blue;
       
 11930             }
       
 11931             this.options.shadowUrl = this.images.shadow;
       
 11932         }
       
 11933     });
       
 11934     return IconDefault;
       
 11935 }(leaflet);
       
 11936 LeafletControlsLocationSelector = function (L, woodman, Gp, RightManagement, ID, LocationSelectorDOM, PositionFormater, IconDefault) {
       
 11937     var LocationSelector = L.Control.extend({
       
 11938         includes: LocationSelectorDOM,
       
 11939         options: {
       
 11940             position: 'topleft',
       
 11941             tag: {
       
 11942                 id: 0,
       
 11943                 unique: null,
       
 11944                 label: '>',
       
 11945                 color: 'blue',
       
 11946                 display: true,
       
 11947                 addOption: false,
       
 11948                 removeOption: false
       
 11949             },
       
 11950             disableReverse: false,
       
 11951             displayInfo: true,
       
 11952             autocompleteOptions: {},
       
 11953             reverseGeocodeOptions: {}
       
 11954         },
       
 11955         initialize: function (options) {
       
 11956             L.Util.setOptions(this, options);
       
 11957             this._uid = this.options.tag.unique || null;
       
 11958             this._activeDragAndDrop = false;
       
 11959             this._pressedKeyOnDragAndDrop = false;
       
 11960             this._map = null;
       
 11961             this._inputsContainer = null;
       
 11962             this._inputLabelContainer = null;
       
 11963             this._inputAutoCompleteContainer = null;
       
 11964             this._inputShowPointerContainer = null;
       
 11965             this._inputCoordinateContainer = null;
       
 11966             this._coordinate = null;
       
 11967             this._suggestedContainer = null;
       
 11968             this._suggestedLocations = [];
       
 11969             this._currentLocation = null;
       
 11970             this._marker = null;
       
 11971             this._resources = {};
       
 11972             this._noRightManagement = false;
       
 11973             this._checkRightsManagement();
       
 11974             this._container = this._uid ? this._initLayout() : null;
       
 11975         },
       
 11976         onAdd: function () {
       
 11977             this._uid = ID.generate();
       
 11978             var container = this._initLayout();
       
 11979             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 11980             return container;
       
 11981         },
       
 11982         onRemove: function () {
       
 11983         },
       
 11984         getCoordinate: function () {
       
 11985             return this._coordinate;
       
 11986         },
       
 11987         getCoordinateInverse: function () {
       
 11988             if (!this._coordinate) {
       
 11989                 return;
       
 11990             }
       
 11991             var coordinateInv = {
       
 11992                 x: this._coordinate.y,
       
 11993                 y: this._coordinate.x
       
 11994             };
       
 11995             return coordinateInv;
       
 11996         },
       
 11997         setMap: function (map) {
       
 11998             if (!this._map) {
       
 11999                 this._map = map;
       
 12000             }
       
 12001         },
       
 12002         clear: function () {
       
 12003             this._setCursor();
       
 12004             this._setMarker();
       
 12005             this._clearResults();
       
 12006             this._inputLabelContainer.click();
       
 12007         },
       
 12008         dragging: function (active) {
       
 12009             if (this._marker) {
       
 12010                 if (active) {
       
 12011                     this._marker.dragging.enable();
       
 12012                 } else {
       
 12013                     this._marker.dragging.disable();
       
 12014                 }
       
 12015             }
       
 12016         },
       
 12017         _initLayout: function () {
       
 12018             var id = this.options.tag.id;
       
 12019             var container = this._createMainContainerElement();
       
 12020             var inputs = this._inputsContainer = this._createLocationPointElement(id, this.options.tag.display);
       
 12021             container.appendChild(inputs);
       
 12022             var _inputLabel = this._inputLabelContainer = this._createLocationPointLabelElement(id, this.options.tag.label);
       
 12023             inputs.appendChild(_inputLabel);
       
 12024             var _inputAutoComplete = this._inputAutoCompleteContainer = this._createLocationAutoCompleteteInputElement(id);
       
 12025             inputs.appendChild(_inputAutoComplete);
       
 12026             var _inputCoordinate = this._inputCoordinateContainer = this._createLocationCoordinateInputElement(id);
       
 12027             inputs.appendChild(_inputCoordinate);
       
 12028             var _inputShowPointer = this._inputShowPointerContainer = this._createLocationPointerShowInputElement(id);
       
 12029             inputs.appendChild(_inputShowPointer);
       
 12030             var _inputPointer = this._createLocationPointerInputElement(id);
       
 12031             inputs.appendChild(_inputPointer);
       
 12032             if (this.options.tag.addOption) {
       
 12033                 var _inputAddStage = this._createLocationAddPointElement();
       
 12034                 inputs.appendChild(_inputAddStage);
       
 12035             }
       
 12036             if (this.options.tag.removeOption) {
       
 12037                 var _inputRemoveStage = this._createLocationRemovePointElement(id);
       
 12038                 inputs.appendChild(_inputRemoveStage);
       
 12039             }
       
 12040             var results = this._suggestedContainer = this._createLocationAutoCompleteResultElement(id);
       
 12041             container.appendChild(results);
       
 12042             return container;
       
 12043         },
       
 12044         _checkRightsManagement: function () {
       
 12045             var _opts = null;
       
 12046             var _res = [];
       
 12047             var _key = null;
       
 12048             _key = this.options.reverseGeocodeOptions.apiKey;
       
 12049             _opts = this.options.reverseGeocodeOptions.filterOptions;
       
 12050             _res = _opts ? _opts.type : [];
       
 12051             if (!_res || _res.length === 0) {
       
 12052                 _res = [
       
 12053                     'PositionOfInterest',
       
 12054                     'StreetAddress'
       
 12055                 ];
       
 12056             }
       
 12057             var rightManagementRerverse = RightManagement.check({
       
 12058                 key: _key || this.options.apiKey,
       
 12059                 resources: _res,
       
 12060                 services: ['ReverseGeocode']
       
 12061             });
       
 12062             _key = this.options.autocompleteOptions.apiKey;
       
 12063             _opts = this.options.autocompleteOptions.filterOptions;
       
 12064             _res = _opts ? _opts.type : [];
       
 12065             if (!_res || _res.length === 0) {
       
 12066                 _res = [
       
 12067                     'PositionOfInterest',
       
 12068                     'StreetAddress'
       
 12069                 ];
       
 12070             }
       
 12071             var rightManagementAutoComplete = RightManagement.check({
       
 12072                 key: _key || this.options.apiKey,
       
 12073                 resources: _res,
       
 12074                 services: ['AutoCompletion']
       
 12075             });
       
 12076             if (!rightManagementRerverse && !rightManagementAutoComplete) {
       
 12077                 this._noRightManagement = true;
       
 12078             }
       
 12079             if (rightManagementAutoComplete) {
       
 12080                 this._resources['AutoCompletion'] = {};
       
 12081                 this._resources['AutoCompletion']['resources'] = rightManagementAutoComplete['AutoCompletion'];
       
 12082                 this._resources['AutoCompletion']['key'] = rightManagementAutoComplete['key'];
       
 12083             }
       
 12084             if (rightManagementRerverse) {
       
 12085                 this._resources['ReverseGeocode'] = {};
       
 12086                 this._resources['ReverseGeocode']['resources'] = rightManagementRerverse['ReverseGeocode'];
       
 12087                 this._resources['ReverseGeocode']['key'] = rightManagementRerverse['key'];
       
 12088             }
       
 12089         },
       
 12090         _setLabel: function (label) {
       
 12091             this._inputAutoCompleteContainer.value = label || '';
       
 12092         },
       
 12093         _setCoordinate: function (oLatLng) {
       
 12094             this._coordinate = {
       
 12095                 x: oLatLng.lng,
       
 12096                 y: oLatLng.lat
       
 12097             };
       
 12098             var lat = null;
       
 12099             var lng = null;
       
 12100             if (false) {
       
 12101                 lat = PositionFormater.decimalLatToDMS(oLatLng.lat);
       
 12102                 lng = PositionFormater.decimalLongToDMS(oLatLng.lng);
       
 12103             } else {
       
 12104                 lat = PositionFormater.roundToDecimal(oLatLng.lat, 4);
       
 12105                 lng = PositionFormater.roundToDecimal(oLatLng.lng, 4);
       
 12106             }
       
 12107             var value = lng + ' , ' + lat;
       
 12108             this.GPdisplayCoordinate(value);
       
 12109         },
       
 12110         _setPosition: function (position) {
       
 12111             var map = this._map;
       
 12112             map.panTo(L.latLng(position.y, position.x));
       
 12113         },
       
 12114         _setMarker: function (position, information, display) {
       
 12115             if (this._activeDragAndDrop) {
       
 12116                 return;
       
 12117             }
       
 12118             var map = this._map;
       
 12119             if (this._marker != null) {
       
 12120                 this._marker.off('mousedown', this.onMouseDownMarker, this);
       
 12121                 this._marker.off('dragstart', this.onStartDragMarker, this);
       
 12122                 this._marker.off('drag', this.onDragMarker, this);
       
 12123                 this._marker.off('dragend', this.onEndDragMarker, this);
       
 12124                 map.removeLayer(this._marker);
       
 12125                 this._marker = null;
       
 12126             }
       
 12127             if (position) {
       
 12128                 var options = {
       
 12129                     icon: new IconDefault(this.options.tag.color),
       
 12130                     draggable: true,
       
 12131                     clickable: true,
       
 12132                     zIndexOffset: 1000
       
 12133                 };
       
 12134                 this._marker = L.marker(L.latLng(position.y, position.x), options);
       
 12135                 this._marker.on('mousedown', this.onMouseDownMarker, this);
       
 12136                 this._marker.on('dragstart', this.onStartDragMarker, this);
       
 12137                 this._marker.on('drag', this.onDragMarker, this);
       
 12138                 this._marker.on('dragend', this.onEndDragMarker, this);
       
 12139                 this._marker.addTo(map);
       
 12140                 if (display) {
       
 12141                     var popupContent = null;
       
 12142                     if (typeof information !== 'string') {
       
 12143                         if (information.fields.fullText) {
       
 12144                             popupContent = information.fields.fullText;
       
 12145                         } else {
       
 12146                             var values = [];
       
 12147                             values.push(information.fields.street || '');
       
 12148                             values.push(information.fields.postalCode || '');
       
 12149                             values.push(information.fields.commune || '');
       
 12150                             if (information.type === 'PositionOfInterest') {
       
 12151                                 values.push(information.fields.poi || '');
       
 12152                                 values.push(information.fields.kind || '');
       
 12153                             }
       
 12154                             popupContent = values.join(' - ');
       
 12155                         }
       
 12156                     } else {
       
 12157                         popupContent = information;
       
 12158                     }
       
 12159                     this._marker.bindPopup(popupContent);
       
 12160                 }
       
 12161             }
       
 12162         },
       
 12163         _setCursor: function (cursor) {
       
 12164             var div = this._map.getContainer();
       
 12165             if (cursor) {
       
 12166                 div.style.cursor = cursor;
       
 12167             } else {
       
 12168                 div.style.cursor = null;
       
 12169             }
       
 12170         },
       
 12171         _clearResults: function () {
       
 12172             this._currentLocation = null;
       
 12173             this._coordinate = null;
       
 12174             this._clearSuggestedLocation();
       
 12175         },
       
 12176         _clearSuggestedLocation: function () {
       
 12177             this._suggestedLocations = [];
       
 12178             if (this._suggestedContainer) {
       
 12179                 while (this._suggestedContainer.firstChild) {
       
 12180                     this._suggestedContainer.removeChild(this._suggestedContainer.firstChild);
       
 12181                 }
       
 12182             }
       
 12183         },
       
 12184         _requestAutoComplete: function (settings) {
       
 12185             if (!settings || Object.keys(settings).length === 0) {
       
 12186                 return;
       
 12187             }
       
 12188             if (!settings.text) {
       
 12189                 return;
       
 12190             }
       
 12191             if (this._noRightManagement) {
       
 12192                 console.log('no rights for all service !?');
       
 12193                 return;
       
 12194             }
       
 12195             if (!this._resources['AutoCompletion']) {
       
 12196                 console.log('no rights for this service !?');
       
 12197                 return;
       
 12198             }
       
 12199             var resources = this._resources['AutoCompletion'].resources;
       
 12200             if (!resources || Object.keys(resources).length === 0) {
       
 12201                 return;
       
 12202             }
       
 12203             var key = this._resources['AutoCompletion']['key'];
       
 12204             var options = {};
       
 12205             L.Util.extend(options, this.options.autocompleteOptions);
       
 12206             L.Util.extend(options, settings);
       
 12207             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey || key });
       
 12208             Gp.Services.autoComplete(options);
       
 12209         },
       
 12210         _fillAutoCompletedLocationListContainer: function (locations) {
       
 12211             if (!locations || locations.length === 0) {
       
 12212                 return;
       
 12213             }
       
 12214             var element = this._suggestedContainer;
       
 12215             if (element.childElementCount) {
       
 12216                 while (element.firstChild) {
       
 12217                     element.removeChild(element.firstChild);
       
 12218                 }
       
 12219             }
       
 12220             for (var i = 0; i < locations.length; i++) {
       
 12221                 this._createLocationAutoCompletedLocationElement(this.options.tag.id, locations[i], i);
       
 12222             }
       
 12223             this._suggestedLocations = locations;
       
 12224         },
       
 12225         _requestReverseGeocode: function (settings) {
       
 12226             if (!settings || Object.keys(settings).length === 0) {
       
 12227                 return;
       
 12228             }
       
 12229             if (!settings.position || Object.keys(settings.position).length === 0) {
       
 12230                 return;
       
 12231             }
       
 12232             if (this._noRightManagement) {
       
 12233                 console.log('no rights for all service !?');
       
 12234                 return;
       
 12235             }
       
 12236             if (!this._resources['ReverseGeocode']) {
       
 12237                 console.log('no rights for this service !?');
       
 12238                 return;
       
 12239             }
       
 12240             var resources = this._resources['ReverseGeocode'].resources;
       
 12241             if (!resources || Object.keys(resources).length === 0) {
       
 12242                 return;
       
 12243             }
       
 12244             var key = this._resources['ReverseGeocode']['key'];
       
 12245             var options = {};
       
 12246             L.Util.extend(options, this.options.reverseGeocodeOptions);
       
 12247             L.Util.extend(options, settings);
       
 12248             L.Util.extend(options, {
       
 12249                 returnFreeForm: true,
       
 12250                 filterOptions: { type: ['StreetAddress'] }
       
 12251             });
       
 12252             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey || key });
       
 12253             Gp.Services.reverseGeocode(options);
       
 12254         },
       
 12255         _displayResultOfCoordinate: function (oLatLng) {
       
 12256             this._setCoordinate(oLatLng);
       
 12257             this._setMarker({
       
 12258                 x: oLatLng.lng,
       
 12259                 y: oLatLng.lat
       
 12260             }, null, false);
       
 12261             this.onActivateMapPointClick();
       
 12262         },
       
 12263         _displayResultOfLabel: function (oLocation) {
       
 12264             var places = oLocation.placeAttributes;
       
 12265             var label = places.number + ' ' + places.street + ', ' + places.postalCode + ' ' + places.commune;
       
 12266             this._setCoordinate({
       
 12267                 lat: oLocation.position.x,
       
 12268                 lng: oLocation.position.y
       
 12269             });
       
 12270             this._setLabel(label);
       
 12271             this._setMarker({
       
 12272                 x: oLocation.position.y,
       
 12273                 y: oLocation.position.x
       
 12274             }, null, false);
       
 12275             this._inputShowPointerContainer.checked = false;
       
 12276             this._inputAutoCompleteContainer.className = 'GPlocationOriginVisible';
       
 12277             this._inputCoordinateContainer.className = 'GPlocationOriginHidden';
       
 12278             this.onActivateMapPointClick();
       
 12279         },
       
 12280         onAutoCompleteSearchText: function (e) {
       
 12281             var value = e.target.value;
       
 12282             if (!value) {
       
 12283                 return;
       
 12284             }
       
 12285             if (this._noRightManagement) {
       
 12286                 console.log('no rights for this service !?');
       
 12287                 return;
       
 12288             }
       
 12289             this._currentLocation = value;
       
 12290             if (value.length < 3) {
       
 12291                 return;
       
 12292             }
       
 12293             var context = this;
       
 12294             this._requestAutoComplete({
       
 12295                 text: value,
       
 12296                 maximumResponses: 5,
       
 12297                 onSuccess: function (results) {
       
 12298                     if (results) {
       
 12299                         var locations = results.suggestedLocations;
       
 12300                         context._fillAutoCompletedLocationListContainer(locations);
       
 12301                     }
       
 12302                 },
       
 12303                 onFailure: function (error) {
       
 12304                     context._clearSuggestedLocation();
       
 12305                 }
       
 12306             });
       
 12307         },
       
 12308         onAutoCompletedResultsItemClick: function (e) {
       
 12309             var idx = ID.index(e.target.id);
       
 12310             if (!idx) {
       
 12311                 return;
       
 12312             }
       
 12313             var position = {
       
 12314                 x: this._suggestedLocations[idx].position.x,
       
 12315                 y: this._suggestedLocations[idx].position.y
       
 12316             };
       
 12317             var info = {
       
 12318                 type: this._suggestedLocations[idx].type,
       
 12319                 fields: this._suggestedLocations[idx]
       
 12320             };
       
 12321             var label = this._suggestedLocations[idx].fullText;
       
 12322             this._setLabel(label);
       
 12323             this._setPosition(position);
       
 12324             this._setMarker(position, info, this.options.displayInfo);
       
 12325             this._coordinate = position;
       
 12326         },
       
 12327         onActivateMapPointClick: function (e) {
       
 12328             var map = this._map;
       
 12329             if (this._inputShowPointerContainer.checked) {
       
 12330                 if (!this._activeDragAndDrop) {
       
 12331                     map.on('click', this.onMouseMapClick, this);
       
 12332                     this._setCursor('crosshair');
       
 12333                     this._setMarker();
       
 12334                     this._clearResults();
       
 12335                 }
       
 12336             } else {
       
 12337                 if (!this._activeDragAndDrop) {
       
 12338                     map.off('click', this.onMouseMapClick, this);
       
 12339                     this._setCursor();
       
 12340                 }
       
 12341             }
       
 12342         },
       
 12343         onLocationClearPointClick: function (e) {
       
 12344             this._setCursor();
       
 12345             this._setMarker();
       
 12346             this._clearResults();
       
 12347             this._inputAutoCompleteContainer.focus();
       
 12348         },
       
 12349         onLocationRemovePointClick: function (e) {
       
 12350             this._setCursor();
       
 12351             this._setMarker();
       
 12352             this._clearResults();
       
 12353         },
       
 12354         onLocationAddPointClick: function (e) {
       
 12355         },
       
 12356         onMouseMapClick: function (e) {
       
 12357             var oLatLng = e.latlng;
       
 12358             if (this.options.disableReverse || this._noRightManagement) {
       
 12359                 this._displayResultOfCoordinate(oLatLng);
       
 12360             } else {
       
 12361                 var self = this;
       
 12362                 this._requestReverseGeocode({
       
 12363                     position: {
       
 12364                         x: oLatLng.lat,
       
 12365                         y: oLatLng.lng
       
 12366                     },
       
 12367                     srs: 'EPSG:4326',
       
 12368                     onSuccess: function (results) {
       
 12369                         if (results.locations.length !== 0) {
       
 12370                             var oLocation = results.locations[0];
       
 12371                             self._displayResultOfLabel(oLocation);
       
 12372                         } else {
       
 12373                             self._displayResultOfCoordinate(oLatLng);
       
 12374                         }
       
 12375                     },
       
 12376                     onFailure: function (error) {
       
 12377                         self._displayResultOfCoordinate(oLatLng);
       
 12378                     }
       
 12379                 });
       
 12380             }
       
 12381         },
       
 12382         onStartDragMarker: function () {
       
 12383             if (!this._marker) {
       
 12384                 return;
       
 12385             }
       
 12386             this._activeDragAndDrop = true;
       
 12387             this._inputShowPointerContainer.checked = true;
       
 12388             this._inputAutoCompleteContainer.className = 'GPlocationOriginHidden';
       
 12389             this._inputCoordinateContainer.className = 'GPlocationOriginVisible';
       
 12390             this._marker.unbindPopup();
       
 12391             this._setLabel();
       
 12392             this._clearResults();
       
 12393         },
       
 12394         onDragMarker: function () {
       
 12395             if (!this._marker) {
       
 12396                 return;
       
 12397             }
       
 12398             this._activeDragAndDrop = false;
       
 12399             this._inputShowPointerContainer.checked = true;
       
 12400             var oLatLng = this._marker.getLatLng();
       
 12401             this._setCoordinate(oLatLng);
       
 12402         },
       
 12403         onEndDragMarker: function () {
       
 12404             if (!this._marker) {
       
 12405                 return;
       
 12406             }
       
 12407             this._inputShowPointerContainer.checked = true;
       
 12408             var oLatLng = this._marker.getLatLng();
       
 12409             if (this._pressedKeyOnDragAndDrop) {
       
 12410                 this._setCoordinate(oLatLng);
       
 12411             } else {
       
 12412                 this.onMouseMapClick({ latlng: oLatLng });
       
 12413             }
       
 12414             this._activeDragAndDrop = false;
       
 12415             this._pressedKeyOnDragAndDrop = false;
       
 12416         },
       
 12417         onMouseDownMarker: function (e) {
       
 12418             if (!this._marker) {
       
 12419                 return;
       
 12420             }
       
 12421             this._pressedKeyOnDragAndDrop = e.originalEvent.ctrlKey;
       
 12422         }
       
 12423     });
       
 12424     return LocationSelector;
       
 12425 }(leaflet, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, CommonControlsLocationSelectorDOM, LeafletControlsUtilsPositionFormater, LeafletControlsUtilsIconDefault);
       
 12426 CommonControlsIsoDOM = function () {
       
 12427     var IsoDOM = {
       
 12428         _addUID: function (id) {
       
 12429             return id + '-' + this._uid;
       
 12430         },
       
 12431         _createMainContainerElement: function () {
       
 12432             var container = document.createElement('div');
       
 12433             container.id = this._addUID('GPisochron');
       
 12434             container.className = 'GPwidget';
       
 12435             return container;
       
 12436         },
       
 12437         _createShowIsoElement: function () {
       
 12438             var input = document.createElement('input');
       
 12439             input.id = this._addUID('GPshowIsochron');
       
 12440             input.type = 'checkbox';
       
 12441             return input;
       
 12442         },
       
 12443         _createShowIsoPictoElement: function () {
       
 12444             var context = this;
       
 12445             var label = document.createElement('label');
       
 12446             label.id = this._addUID('GPshowIsochronPicto');
       
 12447             label.className = 'GPshowAdvancedToolPicto';
       
 12448             label.htmlFor = this._addUID('GPshowIsochron');
       
 12449             label.title = 'Calculer une isochrone';
       
 12450             if (label.addEventListener) {
       
 12451                 label.addEventListener('click', function (e) {
       
 12452                     context.onShowIsoPanelClick(e);
       
 12453                 });
       
 12454             } else if (label.attachEvent) {
       
 12455                 label.attachEvent('onclick', function (e) {
       
 12456                     context.onShowIsoPanelClick(e);
       
 12457                 });
       
 12458             }
       
 12459             var spanOpen = document.createElement('span');
       
 12460             spanOpen.id = this._addUID('GPshowIsochronOpen');
       
 12461             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 12462             label.appendChild(spanOpen);
       
 12463             return label;
       
 12464         },
       
 12465         _createIsoPanelElement: function () {
       
 12466             var div = document.createElement('div');
       
 12467             div.id = this._addUID('GPisochronPanel');
       
 12468             div.className = 'GPpanel';
       
 12469             return div;
       
 12470         },
       
 12471         _createIsoPanelHeaderElement: function () {
       
 12472             var self = this;
       
 12473             var container = document.createElement('div');
       
 12474             container.className = 'GPpanelHeader';
       
 12475             var div = document.createElement('div');
       
 12476             div.className = 'GPpanelTitle';
       
 12477             div.innerHTML = 'Calcul d\'isochrone';
       
 12478             container.appendChild(div);
       
 12479             var divClose = document.createElement('div');
       
 12480             divClose.id = this._addUID('GPisochronPanelClose');
       
 12481             divClose.className = 'GPpanelClose';
       
 12482             divClose.title = 'Fermer le panneau';
       
 12483             if (divClose.addEventListener) {
       
 12484                 divClose.addEventListener('click', function () {
       
 12485                     document.getElementById(self._addUID('GPshowIsochronPicto')).click();
       
 12486                 }, false);
       
 12487             } else if (divClose.attachEvent) {
       
 12488                 divClose.attachEvent('onclick', function () {
       
 12489                     document.getElementById(self._addUID('GPshowIsochronPicto')).click();
       
 12490                 });
       
 12491             }
       
 12492             container.appendChild(divClose);
       
 12493             return container;
       
 12494         },
       
 12495         _createIsoPanelFormElement: function () {
       
 12496             var self = this;
       
 12497             var form = document.createElement('form');
       
 12498             form.id = this._addUID('GPisochronForm');
       
 12499             form.addEventListener('submit', function (e) {
       
 12500                 e.preventDefault();
       
 12501                 self.onIsoComputationSubmit(e);
       
 12502                 return false;
       
 12503             });
       
 12504             return form;
       
 12505         },
       
 12506         _createIsoWaitingElement: function () {
       
 12507             var div = document.createElement('div');
       
 12508             div.id = this._addUID('GPisochronCalcWaitingContainer');
       
 12509             div.className = 'GPisochronCalcWaitingContainerHidden';
       
 12510             var p = document.createElement('p');
       
 12511             p.className = 'GPisochronCalcWaiting';
       
 12512             p.innerHTML = 'Calcul en cours...';
       
 12513             div.appendChild(p);
       
 12514             return div;
       
 12515         },
       
 12516         _createIsoPanelFormTypeChoiceElement: function () {
       
 12517             var div = document.createElement('div');
       
 12518             div.id = this._addUID('GPisochronChoice');
       
 12519             return div;
       
 12520         },
       
 12521         _createIsoPanelFormTypeChoiceChronElement: function (checked) {
       
 12522             var self = this;
       
 12523             var div = document.createElement('div');
       
 12524             div.className = 'GPisochronChoiceAlt';
       
 12525             var input = document.createElement('input');
       
 12526             input.id = this._addUID('GPisochronChoiceAltChron');
       
 12527             input.name = 'GPisochronChoiceMode';
       
 12528             input.type = 'radio';
       
 12529             input.checked = checked ? true : false;
       
 12530             if (input.addEventListener) {
       
 12531                 input.addEventListener('change', function (e) {
       
 12532                     document.getElementById(self._addUID('GPisochronValueChron')).className = 'GPflexInput';
       
 12533                     document.getElementById(self._addUID('GPisochronValueDist')).className = 'GPisochronValueHidden';
       
 12534                     self.onIsoTypeChoiceChange(e);
       
 12535                 }, false);
       
 12536             } else if (input.attachEvent) {
       
 12537                 input.attachEvent('onchange', function () {
       
 12538                     document.getElementById(self._addUID('GPisochronValueChron')).className = 'GPflexInput';
       
 12539                     document.getElementById(self._addUID('GPisochronValueDist')).className = 'GPisochronValueHidden';
       
 12540                     self.onIsoTypeChoiceChange();
       
 12541                 });
       
 12542             }
       
 12543             input.value = 'isochron';
       
 12544             div.appendChild(input);
       
 12545             var label = document.createElement('label');
       
 12546             label.className = 'GPisochronChoiceAltImg';
       
 12547             label.htmlFor = this._addUID('GPisochronChoiceAltChron');
       
 12548             div.appendChild(label);
       
 12549             var span = document.createElement('span');
       
 12550             span.id = this._addUID('GPisochronChoiceAltChronTxt');
       
 12551             span.innerHTML = 'isochrone';
       
 12552             if (span.addEventListener) {
       
 12553                 span.addEventListener('click', function () {
       
 12554                     document.getElementById(self._addUID('GPisochronChoiceAltChron')).click();
       
 12555                 }, false);
       
 12556             } else if (span.attachEvent) {
       
 12557                 span.attachEvent('onclick', function () {
       
 12558                     document.getElementById(self._addUID('GPisochronChoiceAltChron')).click();
       
 12559                 });
       
 12560             }
       
 12561             div.appendChild(span);
       
 12562             return div;
       
 12563         },
       
 12564         _createIsoPanelFormTypeChoiceDistElement: function (checked) {
       
 12565             var self = this;
       
 12566             var div = document.createElement('div');
       
 12567             div.className = 'GPisochronChoiceAlt';
       
 12568             var input = document.createElement('input');
       
 12569             input.id = this._addUID('GPisochronChoiceAltDist');
       
 12570             input.name = 'GPisochronChoiceMode';
       
 12571             input.type = 'radio';
       
 12572             input.checked = checked ? true : false;
       
 12573             if (input.addEventListener) {
       
 12574                 input.addEventListener('change', function (e) {
       
 12575                     document.getElementById(self._addUID('GPisochronValueDist')).className = 'GPflexInput';
       
 12576                     document.getElementById(self._addUID('GPisochronValueChron')).className = 'GPisochronValueHidden';
       
 12577                     self.onIsoTypeChoiceChange(e);
       
 12578                 }, false);
       
 12579             } else if (input.attachEvent) {
       
 12580                 input.attachEvent('onchange', function () {
       
 12581                     document.getElementById(self._addUID('GPisochronValueDist')).className = 'GPflexInput';
       
 12582                     document.getElementById(self._addUID('GPisochronValueChron')).className = 'GPisochronValueHidden';
       
 12583                     self.onIsoTypeChoiceChange();
       
 12584                 });
       
 12585             }
       
 12586             input.value = 'isodistance';
       
 12587             div.appendChild(input);
       
 12588             var label = document.createElement('label');
       
 12589             label.className = 'GPisochronChoiceAltImg';
       
 12590             label.htmlFor = this._addUID('GPisochronChoiceAltDist');
       
 12591             div.appendChild(label);
       
 12592             var span = document.createElement('span');
       
 12593             span.id = this._addUID('GPisochronChoiceAltDistTxt');
       
 12594             span.innerHTML = 'isodistance';
       
 12595             if (span.addEventListener) {
       
 12596                 span.addEventListener('click', function () {
       
 12597                     document.getElementById(self._addUID('GPisochronChoiceAltDist')).click();
       
 12598                 }, false);
       
 12599             } else if (span.attachEvent) {
       
 12600                 span.attachEvent('onclick', function () {
       
 12601                     document.getElementById(self._addUID('GPisochronChoiceAltDist')).click();
       
 12602                 });
       
 12603             }
       
 12604             div.appendChild(span);
       
 12605             return div;
       
 12606         },
       
 12607         _createIsoPanelFormValueIsochronElement: function (checked) {
       
 12608             var context = this;
       
 12609             var div = document.createElement('div');
       
 12610             div.id = this._addUID('GPisochronValueChron');
       
 12611             div.className = checked ? 'GPflexInput' : 'GPisochronValueHidden';
       
 12612             var label = document.createElement('label');
       
 12613             label.id = this._addUID('GPisochronValueChronLabel');
       
 12614             label.htmlFor = this._addUID('GPisochronValueChronInput');
       
 12615             label.innerHTML = 'Temps';
       
 12616             div.appendChild(label);
       
 12617             var input1 = document.createElement('input');
       
 12618             input1.id = this._addUID('GPisochronValueChronInput1');
       
 12619             input1.min = '0';
       
 12620             input1.step = '1';
       
 12621             input1.value = '0';
       
 12622             input1.type = 'number';
       
 12623             if (input1.addEventListener) {
       
 12624                 input1.addEventListener('change', function (e) {
       
 12625                     if (typeof context.onIsoValueChronTimeMinuteChange === 'function') {
       
 12626                         context.onIsoValueChronTimeHourChange(e);
       
 12627                     }
       
 12628                 });
       
 12629             } else if (input1.attachEvent) {
       
 12630                 input1.attachEvent('onchange', function (e) {
       
 12631                     if (typeof context.onIsoValueChronTimeMinuteChange === 'function') {
       
 12632                         context.onIsoValueChronTimeHourChange(e);
       
 12633                     }
       
 12634                 });
       
 12635             }
       
 12636             div.appendChild(input1);
       
 12637             var label1 = document.createElement('label');
       
 12638             label1.innerHTML = 'h';
       
 12639             div.appendChild(label1);
       
 12640             var input2 = document.createElement('input');
       
 12641             input2.id = this._addUID('GPisochronValueChronInput2');
       
 12642             input2.min = '0';
       
 12643             input2.max = '59';
       
 12644             input2.step = '1';
       
 12645             input2.value = '0';
       
 12646             input2.type = 'number';
       
 12647             if (input2.addEventListener) {
       
 12648                 input2.addEventListener('change', function (e) {
       
 12649                     if (typeof context.onIsoValueChronTimeMinuteChange === 'function') {
       
 12650                         context.onIsoValueChronTimeMinuteChange(e);
       
 12651                     }
       
 12652                 });
       
 12653             } else if (input2.attachEvent) {
       
 12654                 input2.attachEvent('onchange', function (e) {
       
 12655                     if (typeof context.onIsoValueChronTimeMinuteChange === 'function') {
       
 12656                         context.onIsoValueChronTimeMinuteChange(e);
       
 12657                     }
       
 12658                 });
       
 12659             }
       
 12660             div.appendChild(input2);
       
 12661             var label2 = document.createElement('label');
       
 12662             label2.innerHTML = 'min';
       
 12663             div.appendChild(label2);
       
 12664             return div;
       
 12665         },
       
 12666         _createIsoPanelFormValueIsodistanceElement: function (checked) {
       
 12667             var context = this;
       
 12668             var div = document.createElement('div');
       
 12669             div.id = this._addUID('GPisochronValueDist');
       
 12670             div.className = checked ? 'GPflexInput' : 'GPisochronValueHidden';
       
 12671             var label = document.createElement('label');
       
 12672             label.id = this._addUID('GPisochronValueDistLabel');
       
 12673             label.htmlFor = this._addUID('GPisochronValueDistInput');
       
 12674             label.innerHTML = 'Distance';
       
 12675             div.appendChild(label);
       
 12676             var input1 = document.createElement('input');
       
 12677             input1.id = this._addUID('GPisochronValueDistInput');
       
 12678             input1.min = '0';
       
 12679             input1.step = 'any';
       
 12680             input1.value = '0';
       
 12681             input1.type = 'number';
       
 12682             if (input1.addEventListener) {
       
 12683                 input1.addEventListener('change', function (e) {
       
 12684                     if (typeof context.onIsoValueDistChange === 'function') {
       
 12685                         context.onIsoValueDistChange(e);
       
 12686                     }
       
 12687                 });
       
 12688             } else if (input1.attachEvent) {
       
 12689                 input1.attachEvent('onchange', function (e) {
       
 12690                     if (typeof context.onIsoValueDistChange === 'function') {
       
 12691                         context.onIsoValueDistChange(e);
       
 12692                     }
       
 12693                 });
       
 12694             }
       
 12695             div.appendChild(input1);
       
 12696             var label1 = document.createElement('label');
       
 12697             label1.innerHTML = 'km';
       
 12698             div.appendChild(label1);
       
 12699             return div;
       
 12700         },
       
 12701         _createIsoPanelFormModeChoiceElement: function () {
       
 12702             var div = document.createElement('div');
       
 12703             div.id = this._addUID('GPisochronModeChoice');
       
 12704             return div;
       
 12705         },
       
 12706         _createIsoPanelFormModeChoiceTransportElement: function (transports) {
       
 12707             var context = this;
       
 12708             var div = document.createElement('div');
       
 12709             div.id = this._addUID('GPisochronTransportChoice');
       
 12710             var span = document.createElement('span');
       
 12711             span.className = 'GPisochronModeLabel';
       
 12712             span.innerHTML = 'Mode de transport';
       
 12713             div.appendChild(span);
       
 12714             for (var i = 0; i < transports.length; i++) {
       
 12715                 var transport = transports[i];
       
 12716                 if (transport === 'Voiture') {
       
 12717                     var inputCar = document.createElement('input');
       
 12718                     inputCar.id = this._addUID('GPisochronTransportCar');
       
 12719                     inputCar.type = 'radio';
       
 12720                     inputCar.name = 'GPisochronTransport';
       
 12721                     if (i === 0) {
       
 12722                         inputCar.checked = true;
       
 12723                     }
       
 12724                     if (inputCar.addEventListener) {
       
 12725                         inputCar.addEventListener('change', function (e) {
       
 12726                             context.onIsoModeTransportChange(e);
       
 12727                         });
       
 12728                     } else if (inputCar.attachEvent) {
       
 12729                         inputCar.attachEvent('onchange', function (e) {
       
 12730                             context.onIsoModeTransportChange(e);
       
 12731                         });
       
 12732                     }
       
 12733                     inputCar.value = 'Voiture';
       
 12734                     div.appendChild(inputCar);
       
 12735                     var labelCar = document.createElement('label');
       
 12736                     labelCar.className = 'GPisochronTransportImg';
       
 12737                     labelCar.htmlFor = this._addUID('GPisochronTransportCar');
       
 12738                     labelCar.title = 'Voiture';
       
 12739                     div.appendChild(labelCar);
       
 12740                 }
       
 12741                 if (transport === 'Pieton') {
       
 12742                     var inputPedestrian = document.createElement('input');
       
 12743                     inputPedestrian.id = this._addUID('GPisochronTransportPedestrian');
       
 12744                     inputPedestrian.type = 'radio';
       
 12745                     inputPedestrian.name = 'GPisochronTransport';
       
 12746                     if (i === 0) {
       
 12747                         inputPedestrian.checked = true;
       
 12748                     }
       
 12749                     if (inputPedestrian.addEventListener) {
       
 12750                         inputPedestrian.addEventListener('change', function (e) {
       
 12751                             context.onIsoModeTransportChange(e);
       
 12752                         });
       
 12753                     } else if (inputPedestrian.attachEvent) {
       
 12754                         inputPedestrian.attachEvent('onchange', function (e) {
       
 12755                             context.onIsoModeTransportChange(e);
       
 12756                         });
       
 12757                     }
       
 12758                     inputPedestrian.value = 'Pieton';
       
 12759                     div.appendChild(inputPedestrian);
       
 12760                     var labelPedestrian = document.createElement('label');
       
 12761                     labelPedestrian.className = 'GPisochronTransportImg';
       
 12762                     labelPedestrian.htmlFor = this._addUID('GPisochronTransportPedestrian');
       
 12763                     labelPedestrian.title = 'Piéton';
       
 12764                     div.appendChild(labelPedestrian);
       
 12765                 }
       
 12766             }
       
 12767             return div;
       
 12768         },
       
 12769         _createIsoPanelFormModeChoiceDirectionElement: function (directions) {
       
 12770             var self = this;
       
 12771             var div = document.createElement('div');
       
 12772             div.id = this._addUID('GPisochronDirectionChoice');
       
 12773             var span = document.createElement('span');
       
 12774             span.className = 'GPisochronModeLabel';
       
 12775             span.innerHTML = 'Sens de parcours';
       
 12776             div.appendChild(span);
       
 12777             var select = document.createElement('select');
       
 12778             select.id = this._addUID('GPisochronDirectionSelect');
       
 12779             select.className = 'GPinputSelect';
       
 12780             select.addEventListener('change', function (e) {
       
 12781                 self.onIsoModeDirectionChange(e);
       
 12782             });
       
 12783             for (var i = 0; i < directions.length; i++) {
       
 12784                 var direction = directions[i];
       
 12785                 if (direction.toLowerCase() === 'departure') {
       
 12786                     var departureOption = document.createElement('option');
       
 12787                     if (i === 0) {
       
 12788                         departureOption.selected = 'selected';
       
 12789                     }
       
 12790                     departureOption.value = 'departure';
       
 12791                     departureOption.text = 'Départ';
       
 12792                     select.appendChild(departureOption);
       
 12793                 }
       
 12794                 if (direction.toLowerCase() === 'arrival') {
       
 12795                     var arrivalOption = document.createElement('option');
       
 12796                     if (i === 0) {
       
 12797                         arrivalOption.selected = 'selected';
       
 12798                     }
       
 12799                     arrivalOption.value = 'arrival';
       
 12800                     arrivalOption.text = 'Arrivée';
       
 12801                     select.appendChild(arrivalOption);
       
 12802                 }
       
 12803             }
       
 12804             div.appendChild(select);
       
 12805             return div;
       
 12806         },
       
 12807         _createShowIsoExclusionsElement: function () {
       
 12808             var input = document.createElement('input');
       
 12809             input.id = this._addUID('GPshowIsoExclusions');
       
 12810             input.type = 'checkbox';
       
 12811             return input;
       
 12812         },
       
 12813         _createShowIsoExclusionsPictoElement: function () {
       
 12814             var label = document.createElement('label');
       
 12815             label.id = this._addUID('GPshowIsoExclusionsPicto');
       
 12816             label.className = 'GPshowMoreOptions GPshowIsoExclusionsPicto';
       
 12817             label.htmlFor = this._addUID('GPshowIsoExclusions');
       
 12818             label.title = 'Exclusions';
       
 12819             label.style.top = '240px';
       
 12820             return label;
       
 12821         },
       
 12822         _createIsoPanelFormExclusionsElement: function () {
       
 12823             var div = document.createElement('div');
       
 12824             div.id = this._addUID('GPisoExclusions');
       
 12825             var span = document.createElement('span');
       
 12826             span.className = 'GPisoExclusionsLabel';
       
 12827             span.innerHTML = 'Passages autorisés';
       
 12828             div.appendChild(span);
       
 12829             return div;
       
 12830         },
       
 12831         _createIsoPanelFormExclusionOptionsElement: function (exclusions) {
       
 12832             var context = this;
       
 12833             var div = document.createElement('div');
       
 12834             div.className = 'GPisoExclusionsOptions';
       
 12835             for (var value in exclusions) {
       
 12836                 if (exclusions.hasOwnProperty(value)) {
       
 12837                     var status = exclusions[value];
       
 12838                     switch (value) {
       
 12839                     case 'toll':
       
 12840                         var inputToll = document.createElement('input');
       
 12841                         inputToll.id = this._addUID('GPisoExclusionsToll');
       
 12842                         inputToll.type = 'checkbox';
       
 12843                         inputToll.checked = !status;
       
 12844                         if (inputToll.addEventListener) {
       
 12845                             inputToll.addEventListener('change', function (e) {
       
 12846                                 context.onIsoExclusionsChange(e);
       
 12847                             });
       
 12848                         } else if (inputToll.attachEvent) {
       
 12849                             inputToll.attachEvent('onchange', function (e) {
       
 12850                                 context.onIsoExclusionsChange(e);
       
 12851                             });
       
 12852                         }
       
 12853                         inputToll.value = 'Toll';
       
 12854                         div.appendChild(inputToll);
       
 12855                         var labelToll = document.createElement('label');
       
 12856                         labelToll.className = 'GPisoExclusionsOption';
       
 12857                         labelToll.htmlFor = this._addUID('GPisoExclusionsToll');
       
 12858                         labelToll.innerHTML = 'Péages';
       
 12859                         div.appendChild(labelToll);
       
 12860                         break;
       
 12861                     case 'tunnel':
       
 12862                         var inputTunnel = document.createElement('input');
       
 12863                         inputTunnel.id = this._addUID('GPisoExclusionsTunnel');
       
 12864                         inputTunnel.type = 'checkbox';
       
 12865                         inputTunnel.checked = !status;
       
 12866                         if (inputTunnel.addEventListener) {
       
 12867                             inputTunnel.addEventListener('change', function (e) {
       
 12868                                 context.onIsoExclusionsChange(e);
       
 12869                             });
       
 12870                         } else if (inputTunnel.attachEvent) {
       
 12871                             inputTunnel.attachEvent('onchange', function (e) {
       
 12872                                 context.onIsoExclusionsChange(e);
       
 12873                             });
       
 12874                         }
       
 12875                         inputTunnel.value = 'Tunnel';
       
 12876                         div.appendChild(inputTunnel);
       
 12877                         var labelTunnel = document.createElement('label');
       
 12878                         labelTunnel.className = 'GPisoExclusionsOption';
       
 12879                         labelTunnel.htmlFor = this._addUID('GPisoExclusionsTunnel');
       
 12880                         labelTunnel.innerHTML = 'Tunnels';
       
 12881                         div.appendChild(labelTunnel);
       
 12882                         break;
       
 12883                     case 'bridge':
       
 12884                         var inputBridge = document.createElement('input');
       
 12885                         inputBridge.id = this._addUID('GPisoExclusionsBridge');
       
 12886                         inputBridge.type = 'checkbox';
       
 12887                         inputBridge.checked = !status;
       
 12888                         if (inputBridge.addEventListener) {
       
 12889                             inputBridge.addEventListener('change', function (e) {
       
 12890                                 context.onIsoExclusionsChange(e);
       
 12891                             });
       
 12892                         } else if (inputBridge.attachEvent) {
       
 12893                             inputBridge.attachEvent('onchange', function (e) {
       
 12894                                 context.onIsoExclusionsChange(e);
       
 12895                             });
       
 12896                         }
       
 12897                         inputBridge.value = 'Bridge';
       
 12898                         div.appendChild(inputBridge);
       
 12899                         var labelBridge = document.createElement('label');
       
 12900                         labelBridge.className = 'GPisoExclusionsOption';
       
 12901                         labelBridge.htmlFor = this._addUID('GPisoExclusionsBridge');
       
 12902                         labelBridge.innerHTML = 'Ponts';
       
 12903                         div.appendChild(labelBridge);
       
 12904                         break;
       
 12905                     }
       
 12906                 }
       
 12907             }
       
 12908             return div;
       
 12909         },
       
 12910         _createIsoSubmitFormElement: function () {
       
 12911             var input = document.createElement('input');
       
 12912             input.id = this._addUID('GPisochronSubmit');
       
 12913             input.className = 'GPinputSubmit';
       
 12914             input.type = 'submit';
       
 12915             input.value = 'Calculer';
       
 12916             return input;
       
 12917         },
       
 12918         _createIsoFormResetElement: function () {
       
 12919             var self = this;
       
 12920             var divReset = document.createElement('div');
       
 12921             divReset.id = this._addUID('GPisochronReset');
       
 12922             divReset.title = 'Réinitialiser les paramètres';
       
 12923             divReset.addEventListener('click', function (e) {
       
 12924                 self.onIsoResetClick(e);
       
 12925             });
       
 12926             return divReset;
       
 12927         }
       
 12928     };
       
 12929     return IsoDOM;
       
 12930 }();
       
 12931 LeafletControlsIsocurve = function (L, woodman, Gp, RightManagement, ID, LocationSelector, IsoDOM) {
       
 12932     var Isocurve = L.Control.extend({
       
 12933         includes: IsoDOM,
       
 12934         options: {
       
 12935             position: 'topleft',
       
 12936             collapsed: true,
       
 12937             methods: [
       
 12938                 'time',
       
 12939                 'distance'
       
 12940             ],
       
 12941             graphs: [
       
 12942                 'Voiture',
       
 12943                 'Pieton'
       
 12944             ],
       
 12945             exclusions: {
       
 12946                 toll: false,
       
 12947                 tunnel: false,
       
 12948                 bridge: false
       
 12949             },
       
 12950             directions: [
       
 12951                 'departure',
       
 12952                 'arrival'
       
 12953             ],
       
 12954             disableReverse: false,
       
 12955             isocurveOptions: {},
       
 12956             autocompleteOptions: {}
       
 12957         },
       
 12958         initialize: function (options) {
       
 12959             L.Util.setOptions(this, options);
       
 12960             this._uid = ID.generate();
       
 12961             this._isDesktop = this._detectSupport();
       
 12962             this._waitingContainer = null;
       
 12963             this._showContainer = null;
       
 12964             this._formContainer = null;
       
 12965             this._submitContainer = null;
       
 12966             this._currentTransport = null;
       
 12967             this._currentDirection = null;
       
 12968             this._currentComputation = null;
       
 12969             this._currentTimeHour = 0;
       
 12970             this._currentTimeMinute = 0;
       
 12971             this._currentDistance = 0;
       
 12972             this._currentExclusions = [];
       
 12973             this._initTransport();
       
 12974             this._initComputation();
       
 12975             this._initDirection();
       
 12976             this._initExclusions();
       
 12977             this._currentPoint = null;
       
 12978             this._geojsonIso = null;
       
 12979             this._waiting = false;
       
 12980             this._timer = null;
       
 12981             this._currentIsoResults = null;
       
 12982             this._resources = {};
       
 12983             this._noRightManagement = false;
       
 12984             this._checkRightsManagement();
       
 12985         },
       
 12986         onAdd: function (map) {
       
 12987             var container = this._container = this._initLayout(map);
       
 12988             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 12989             return container;
       
 12990         },
       
 12991         onRemove: function () {
       
 12992         },
       
 12993         _initTransport: function () {
       
 12994             this._currentTransport = 'Voiture';
       
 12995             var transport = this.options.graphs;
       
 12996             if (!transport || transport.length === 0) {
       
 12997                 this.options.graphs = [
       
 12998                     'Voiture',
       
 12999                     'Pieton'
       
 13000                 ];
       
 13001             }
       
 13002             if (L.Util.isArray(transport) && transport.length) {
       
 13003                 if (transport[0] === 'Voiture' || transport[0] === 'Pieton') {
       
 13004                     this._currentTransport = transport[0];
       
 13005                 }
       
 13006             }
       
 13007             var serviceOptions = this.options.isocurveOptions;
       
 13008             if (serviceOptions.graph) {
       
 13009                 this._currentTransport = serviceOptions.graph;
       
 13010             }
       
 13011         },
       
 13012         _initDirection: function () {
       
 13013             this._currentDirection = 'departure';
       
 13014             var directions = this.options.directions;
       
 13015             if (!directions || directions.length === 0) {
       
 13016                 this.options.directions = [
       
 13017                     'departure',
       
 13018                     'arrival'
       
 13019                 ];
       
 13020             }
       
 13021             if (L.Util.isArray(directions) && directions.length) {
       
 13022                 if (directions[0] === 'departure' || directions[0] === 'arrival') {
       
 13023                     this._currentDirection = directions[0];
       
 13024                 }
       
 13025             }
       
 13026             var serviceOptions = this.options.isocurveOptions;
       
 13027             if (!serviceOptions.reverse) {
       
 13028                 this._currentDirection = 'departure';
       
 13029             }
       
 13030             if (serviceOptions.reverse === true) {
       
 13031                 this._currentDirection = 'arrival';
       
 13032                 this.options.directions = [
       
 13033                     'arrival',
       
 13034                     'departure'
       
 13035                 ];
       
 13036             }
       
 13037         },
       
 13038         _initComputation: function () {
       
 13039             this._currentComputation = 'time';
       
 13040             var methods = this.options.methods;
       
 13041             if (!methods || methods.length === 0) {
       
 13042                 this.options.methods = [
       
 13043                     'time',
       
 13044                     'distance'
       
 13045                 ];
       
 13046             }
       
 13047             if (L.Util.isArray(methods) && methods.length) {
       
 13048                 if (methods[0] === 'time' || methods[0] === 'distance') {
       
 13049                     this._currentComputation = methods[0];
       
 13050                 }
       
 13051             }
       
 13052             var serviceOptions = this.options.isocurveOptions;
       
 13053             if (serviceOptions.method) {
       
 13054                 this._currentComputation = serviceOptions.method;
       
 13055             }
       
 13056             if (serviceOptions.time) {
       
 13057                 this._currentComputation = 'time';
       
 13058             }
       
 13059             if (serviceOptions.distance) {
       
 13060                 this._currentComputation = 'distance';
       
 13061             }
       
 13062         },
       
 13063         _initExclusions: function () {
       
 13064             this._currentExclusions = [];
       
 13065             var exclusion = this.options.exclusions;
       
 13066             if (!exclusion || typeof exclusion === 'object' && Object.keys(exclusion).length === 0) {
       
 13067                 this.options.exclusions = {
       
 13068                     toll: false,
       
 13069                     tunnel: false,
       
 13070                     bridge: false
       
 13071                 };
       
 13072             }
       
 13073             if (exclusion && typeof exclusion === 'object' && Object.keys(exclusion).length) {
       
 13074                 for (var k in exclusion) {
       
 13075                     if (exclusion.hasOwnProperty(k)) {
       
 13076                         if (exclusion.k) {
       
 13077                             this._currentExclusions.push(k);
       
 13078                         }
       
 13079                     }
       
 13080                 }
       
 13081             }
       
 13082             var serviceOptions = this.options.isocurveOptions;
       
 13083             if (Array.isArray(serviceOptions.exclusions)) {
       
 13084                 this._currentExclusions = serviceOptions.exclusions;
       
 13085             }
       
 13086         },
       
 13087         _checkRightsManagement: function () {
       
 13088             var _opts = null;
       
 13089             var _res = [];
       
 13090             var _key = null;
       
 13091             _key = this.options.isocurveOptions.apiKey;
       
 13092             _opts = this.options.isocurveOptions.filterOptions;
       
 13093             _res = _opts ? _opts.type : [];
       
 13094             if (!_res || _res.length === 0) {
       
 13095                 _res = [
       
 13096                     'Voiture',
       
 13097                     'Pieton'
       
 13098                 ];
       
 13099             }
       
 13100             var rightManagementIsochrone = RightManagement.check({
       
 13101                 key: _key || this.options.apiKey,
       
 13102                 resources: _res,
       
 13103                 services: ['Isochrone']
       
 13104             });
       
 13105             _key = this.options.autocompleteOptions.apiKey;
       
 13106             _opts = this.options.autocompleteOptions.filterOptions;
       
 13107             _res = _opts ? _opts.type : [];
       
 13108             if (!_res || _res.length === 0) {
       
 13109                 _res = [
       
 13110                     'PositionOfInterest',
       
 13111                     'StreetAddress'
       
 13112                 ];
       
 13113             }
       
 13114             var rightManagementAutoComplete = RightManagement.check({
       
 13115                 key: _key || this.options.apiKey,
       
 13116                 resources: _res,
       
 13117                 services: ['AutoCompletion']
       
 13118             });
       
 13119             if (!rightManagementIsochrone && !rightManagementAutoComplete) {
       
 13120                 this._noRightManagement = true;
       
 13121             }
       
 13122             if (rightManagementAutoComplete) {
       
 13123                 this._resources['AutoCompletion'] = {};
       
 13124                 this._resources['AutoCompletion']['resources'] = rightManagementAutoComplete['AutoCompletion'];
       
 13125                 this._resources['AutoCompletion']['key'] = rightManagementAutoComplete['key'];
       
 13126             }
       
 13127             if (rightManagementIsochrone) {
       
 13128                 this._resources['Isochrone'] = {};
       
 13129                 this._resources['Isochrone']['resources'] = rightManagementIsochrone['Isochrone'];
       
 13130                 this._resources['Isochrone']['key'] = rightManagementIsochrone['key'];
       
 13131             }
       
 13132         },
       
 13133         _detectSupport: function () {
       
 13134             var isDesktop = true;
       
 13135             var userAgent = window.navigator.userAgent.toLowerCase();
       
 13136             if (userAgent.indexOf('iphone') !== -1 || userAgent.indexOf('ipod') !== -1 || userAgent.indexOf('ipad') !== -1 || userAgent.indexOf('android') !== -1 || userAgent.indexOf('mobile') !== -1 || userAgent.indexOf('blackberry') !== -1 || userAgent.indexOf('tablet') !== -1 || userAgent.indexOf('phone') !== -1 || userAgent.indexOf('touch') !== -1) {
       
 13137                 isDesktop = false;
       
 13138             }
       
 13139             if (userAgent.indexOf('msie') !== -1 || userAgent.indexOf('trident') !== -1) {
       
 13140                 isDesktop = true;
       
 13141             }
       
 13142             return isDesktop;
       
 13143         },
       
 13144         _initLayout: function (map) {
       
 13145             var container = this._createMainContainerElement();
       
 13146             var inputShow = this._showContainer = this._createShowIsoElement();
       
 13147             container.appendChild(inputShow);
       
 13148             if (!this.options.collapsed) {
       
 13149                 inputShow.checked = true;
       
 13150             }
       
 13151             var picto = this._createShowIsoPictoElement();
       
 13152             container.appendChild(picto);
       
 13153             var panel = this._createIsoPanelElement();
       
 13154             var header = this._createIsoPanelHeaderElement();
       
 13155             panel.appendChild(header);
       
 13156             var form = this._formContainer = this._createIsoPanelFormElement();
       
 13157             var point = this._createIsoPanelFormPointElement(map);
       
 13158             form.appendChild(point);
       
 13159             var isoChronChecked = false;
       
 13160             var isoDistChecked = false;
       
 13161             var typeChoice = this._createIsoPanelFormTypeChoiceElement();
       
 13162             for (var i = 0; i < this.options.methods.length; i++) {
       
 13163                 if (this.options.methods[i] === 'time') {
       
 13164                     isoChronChecked = i === 0 ? true : false;
       
 13165                     typeChoice.appendChild(this._createIsoPanelFormTypeChoiceChronElement(isoChronChecked));
       
 13166                 }
       
 13167                 if (this.options.methods[i] === 'distance') {
       
 13168                     isoDistChecked = i === 0 ? true : false;
       
 13169                     typeChoice.appendChild(this._createIsoPanelFormTypeChoiceDistElement(isoDistChecked));
       
 13170                 }
       
 13171             }
       
 13172             form.appendChild(typeChoice);
       
 13173             form.appendChild(this._createIsoPanelFormValueIsochronElement(isoChronChecked));
       
 13174             form.appendChild(this._createIsoPanelFormValueIsodistanceElement(isoDistChecked));
       
 13175             var modeChoice = this._createIsoPanelFormModeChoiceElement();
       
 13176             modeChoice.appendChild(this._createIsoPanelFormModeChoiceTransportElement(this.options.graphs));
       
 13177             modeChoice.appendChild(this._createIsoPanelFormModeChoiceDirectionElement(this.options.directions));
       
 13178             form.appendChild(modeChoice);
       
 13179             if (this.options.exclusions && typeof this.options.exclusions === 'object' && Object.keys(this.options.exclusions).length !== 0) {
       
 13180                 form.appendChild(this._createShowIsoExclusionsElement());
       
 13181                 form.appendChild(this._createShowIsoExclusionsPictoElement());
       
 13182                 var exclusion = this._createIsoPanelFormExclusionsElement();
       
 13183                 exclusion.appendChild(this._createIsoPanelFormExclusionOptionsElement(this.options.exclusions));
       
 13184                 form.appendChild(exclusion);
       
 13185             }
       
 13186             var divReset = this._createIsoFormResetElement();
       
 13187             form.appendChild(divReset);
       
 13188             var submit = this._submitContainer = this._createIsoSubmitFormElement();
       
 13189             form.appendChild(submit);
       
 13190             panel.appendChild(form);
       
 13191             var waiting = this._waitingContainer = this._createIsoWaitingElement();
       
 13192             panel.appendChild(waiting);
       
 13193             container.appendChild(panel);
       
 13194             return container;
       
 13195         },
       
 13196         _createIsoPanelFormPointElement: function (map) {
       
 13197             this._currentPoint = new LocationSelector({
       
 13198                 apiKey: this.options.apiKey || null,
       
 13199                 tag: {
       
 13200                     id: 0,
       
 13201                     unique: this._uid,
       
 13202                     label: 'Départ',
       
 13203                     color: 'red',
       
 13204                     display: true
       
 13205                 },
       
 13206                 displayInfo: true,
       
 13207                 disableReverse: this.options.disableReverse,
       
 13208                 autocompleteOptions: this.options.autocompleteOptions || null
       
 13209             });
       
 13210             this._currentPoint.setMap(map);
       
 13211             return this._currentPoint.getContainer();
       
 13212         },
       
 13213         onShowIsoPanelClick: function (e) {
       
 13214         },
       
 13215         onIsoResetClick: function (e) {
       
 13216             this._clear();
       
 13217         },
       
 13218         onIsoTypeChoiceChange: function (e) {
       
 13219             var value = e.target.value;
       
 13220             if (!value) {
       
 13221                 return;
       
 13222             }
       
 13223             if (value === 'isodistance') {
       
 13224                 this._currentComputation = 'distance';
       
 13225             }
       
 13226             if (value === 'isochron') {
       
 13227                 this._currentComputation = 'time';
       
 13228             }
       
 13229         },
       
 13230         onIsoModeTransportChange: function (e) {
       
 13231             var value = e.target.value;
       
 13232             if (!value) {
       
 13233                 return;
       
 13234             }
       
 13235             this._currentTransport = value;
       
 13236         },
       
 13237         onIsoModeDirectionChange: function (e) {
       
 13238             var value = e.target.value;
       
 13239             if (!value) {
       
 13240                 return;
       
 13241             }
       
 13242             this._currentDirection = value;
       
 13243         },
       
 13244         onIsoValueChronTimeHourChange: function (e) {
       
 13245             var value = e.target.value;
       
 13246             this._timeHourContainer = e.target;
       
 13247             if (!value) {
       
 13248                 return;
       
 13249             }
       
 13250             this._currentTimeHour = value;
       
 13251         },
       
 13252         onIsoValueChronTimeMinuteChange: function (e) {
       
 13253             var value = e.target.value;
       
 13254             this._timeMinuteContainer = e.target;
       
 13255             if (!value) {
       
 13256                 return;
       
 13257             }
       
 13258             this._currentTimeMinute = value;
       
 13259         },
       
 13260         onIsoValueDistChange: function (e) {
       
 13261             var value = e.target.value;
       
 13262             this._distanceContainer = e.target;
       
 13263             if (!value) {
       
 13264                 return;
       
 13265             }
       
 13266             this._currentDistance = value;
       
 13267         },
       
 13268         onIsoExclusionsChange: function (e) {
       
 13269             var value = e.target.value;
       
 13270             var checked = e.target.checked;
       
 13271             if (!value) {
       
 13272                 return;
       
 13273             }
       
 13274             var bFound = false;
       
 13275             var iFound = null;
       
 13276             for (var i = 0; i < this._currentExclusions.length; i++) {
       
 13277                 if (this._currentExclusions[i] === value) {
       
 13278                     iFound = i;
       
 13279                     bFound = true;
       
 13280                 }
       
 13281             }
       
 13282             if (!bFound && !checked) {
       
 13283                 this._currentExclusions.push(value);
       
 13284             }
       
 13285             if (bFound && checked) {
       
 13286                 this._currentExclusions.splice(iFound, 1);
       
 13287             }
       
 13288         },
       
 13289         onIsoComputationSubmit: function () {
       
 13290             if (!this._currentPoint || !this._currentPoint.getCoordinate || !this._currentPoint.getCoordinate()) {
       
 13291                 return;
       
 13292             }
       
 13293             var time;
       
 13294             if (this._currentComputation.toLowerCase() === 'time') {
       
 13295                 time = this._currentTimeHour * 3600 + this._currentTimeMinute * 60;
       
 13296             }
       
 13297             var distance;
       
 13298             if (this._currentComputation.toLowerCase() === 'distance') {
       
 13299                 distance = this._currentDistance * 1000;
       
 13300             }
       
 13301             if (!time && !distance) {
       
 13302                 return;
       
 13303             }
       
 13304             if (this._noRightManagement) {
       
 13305                 return;
       
 13306             }
       
 13307             this._displayWaitingContainer();
       
 13308             var self = this;
       
 13309             this._requestIsoCurve({
       
 13310                 position: self._currentPoint.getCoordinate(),
       
 13311                 graph: self._currentTransport,
       
 13312                 exclusions: self._currentExclusions,
       
 13313                 method: self._currentComputation,
       
 13314                 reverse: self._currentDirection.toLowerCase() === 'arrival' ? true : false,
       
 13315                 time: time,
       
 13316                 distance: distance,
       
 13317                 smoothing: true,
       
 13318                 timeout: 7000,
       
 13319                 protocol: 'XHR',
       
 13320                 onSuccess: function (results) {
       
 13321                     if (results) {
       
 13322                         self._drawIsoResults(results);
       
 13323                     }
       
 13324                 },
       
 13325                 onFailure: function (error) {
       
 13326                     self._hideWaitingContainer();
       
 13327                     self._clearIsoResultsGeometry();
       
 13328                 }
       
 13329             });
       
 13330         },
       
 13331         _requestIsoCurve: function (settings) {
       
 13332             if (!settings || typeof settings === 'object' && Object.keys(settings).length === 0) {
       
 13333                 return;
       
 13334             }
       
 13335             if (!settings.position) {
       
 13336                 return;
       
 13337             }
       
 13338             if (this._noRightManagement) {
       
 13339                 return;
       
 13340             }
       
 13341             var services = this._resources['Isochrone'];
       
 13342             if (!services) {
       
 13343                 return;
       
 13344             }
       
 13345             var resources = services.resources;
       
 13346             if (!resources || typeof resources === 'object' && Object.keys(resources).length === 0) {
       
 13347                 return;
       
 13348             }
       
 13349             var options = {};
       
 13350             L.Util.extend(options, settings);
       
 13351             L.Util.extend(options, this.options.isocurveOptions);
       
 13352             var bFound = false;
       
 13353             for (var i = 0; i < resources.length; i++) {
       
 13354                 if (resources[i] === options.graph) {
       
 13355                     bFound = true;
       
 13356                 }
       
 13357             }
       
 13358             if (!bFound) {
       
 13359                 console.log('no rights for this service !?');
       
 13360                 return;
       
 13361             }
       
 13362             var key = this._resources['Isochrone']['key'];
       
 13363             options.apiKey = this.options.isocurveOptions.apiKey || this.options.apiKey || key;
       
 13364             Gp.Services.isoCurve(options);
       
 13365         },
       
 13366         _drawIsoResults: function (results) {
       
 13367             this._clearIsoResultsGeometry();
       
 13368             this._currentIsoResults = results;
       
 13369             if (!results.geometry) {
       
 13370                 this._hideWaitingContainer();
       
 13371                 return;
       
 13372             }
       
 13373             var map = this._map;
       
 13374             var _geometry = results.geometry;
       
 13375             var _style = {
       
 13376                 color: '#ff7800',
       
 13377                 weight: 5,
       
 13378                 opacity: 0.65
       
 13379             };
       
 13380             this._geojsonIso = L.geoJson(_geometry, { style: _style }).addTo(map);
       
 13381             this._hideWaitingContainer();
       
 13382             this._formContainer.className = 'GPisochroComponentHidden';
       
 13383         },
       
 13384         _clear: function () {
       
 13385             this._initTransport();
       
 13386             this._initExclusions();
       
 13387             this._initComputation();
       
 13388             this._initDirection();
       
 13389             this._currentIsoResults = null;
       
 13390             this._clearIsoResultsGeometry();
       
 13391             this._currentPoint.clear();
       
 13392             if (this._timeHourContainer) {
       
 13393                 this._timeHourContainer.value = 0;
       
 13394             }
       
 13395             if (this._timeMinuteContainer) {
       
 13396                 this._timeMinuteContainer.value = 0;
       
 13397             }
       
 13398             if (this._distanceContainer) {
       
 13399                 this._distanceContainer.value = 0;
       
 13400             }
       
 13401         },
       
 13402         _clearIsoResultsGeometry: function () {
       
 13403             var map = this._map;
       
 13404             if (this._geojsonIso != null) {
       
 13405                 map.removeLayer(this._geojsonIso);
       
 13406                 this._geojsonIso = null;
       
 13407             }
       
 13408         },
       
 13409         _displayWaitingContainer: function () {
       
 13410             this._waitingContainer.className = 'GPisochronCalcWaitingContainerVisible';
       
 13411             this._waiting = true;
       
 13412             if (this._timer) {
       
 13413                 clearTimeout(this._timer);
       
 13414                 this._timer = null;
       
 13415             }
       
 13416             var context = this;
       
 13417             this._timer = setTimeout(function () {
       
 13418                 if (context._waiting === true) {
       
 13419                     context._hideWaitingContainer();
       
 13420                 } else {
       
 13421                     if (context._timer) {
       
 13422                         clearTimeout(context._timer);
       
 13423                     }
       
 13424                 }
       
 13425             }, 16000);
       
 13426         },
       
 13427         _hideWaitingContainer: function () {
       
 13428             if (this._waiting) {
       
 13429                 this._waitingContainer.className = 'GPisochronCalcWaitingContainerHidden';
       
 13430                 this._waiting = false;
       
 13431                 clearTimeout(this._timer);
       
 13432                 this._timer = null;
       
 13433             }
       
 13434         }
       
 13435     });
       
 13436     return Isocurve;
       
 13437 }(leaflet, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, LeafletControlsLocationSelector, CommonControlsIsoDOM);
       
 13438 CommonControlsMousePositionDOM = function () {
       
 13439     var MousePositionDOM = {
       
 13440         _addUID: function (id) {
       
 13441             var uid = this._uid ? id + '-' + this._uid : id;
       
 13442             return uid;
       
 13443         },
       
 13444         _createMainContainerElement: function () {
       
 13445             var container = document.createElement('div');
       
 13446             container.id = this._addUID('GPmousePosition');
       
 13447             container.className = 'GPwidget';
       
 13448             return container;
       
 13449         },
       
 13450         _createShowMousePositionElement: function () {
       
 13451             var input = document.createElement('input');
       
 13452             input.id = this._addUID('GPshowMousePosition');
       
 13453             input.type = 'checkbox';
       
 13454             return input;
       
 13455         },
       
 13456         _createShowMousePositionPictoElement: function (isDesktop) {
       
 13457             var self = this;
       
 13458             var label = document.createElement('label');
       
 13459             label.id = this._addUID('GPshowMousePositionPicto');
       
 13460             label.className = 'GPshowAdvancedToolPicto';
       
 13461             label.htmlFor = this._addUID('GPshowMousePosition');
       
 13462             label.title = 'Afficher les coordonnées du curseur';
       
 13463             label.addEventListener('click', function (e) {
       
 13464                 var mapCenterClass = '';
       
 13465                 if (!document.getElementById(self._addUID('GPshowMousePosition')).checked && !isDesktop) {
       
 13466                     mapCenterClass = 'GPmapCenterVisible';
       
 13467                 }
       
 13468                 document.getElementById('GPmapCenter').className = mapCenterClass;
       
 13469                 self.onShowMousePositionClick(e);
       
 13470             });
       
 13471             var spanOpen = document.createElement('span');
       
 13472             spanOpen.id = this._addUID('GPshowMousePositionOpen');
       
 13473             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 13474             label.appendChild(spanOpen);
       
 13475             return label;
       
 13476         },
       
 13477         _createMousePositionPanelElement: function (displayAltitude, displayCoordinates) {
       
 13478             displayAltitude = displayAltitude ? true : typeof displayAltitude === 'undefined' ? true : false;
       
 13479             displayCoordinates = displayCoordinates ? true : typeof displayCoordinates === 'undefined' ? true : false;
       
 13480             var div = document.createElement('div');
       
 13481             div.id = this._addUID('GPmousePositionPanel');
       
 13482             div.className = 'GPpanel';
       
 13483             div.appendChild(this._createMousePositionPanelHeaderElement());
       
 13484             div.appendChild(this._createMousePositionPanelBasicElement(displayAltitude, displayCoordinates));
       
 13485             var arraySettings = this._createShowMousePositionSettingsElement(displayCoordinates);
       
 13486             for (var j = 0; j < arraySettings.length; j++) {
       
 13487                 div.appendChild(arraySettings[j]);
       
 13488             }
       
 13489             return div;
       
 13490         },
       
 13491         _createMapCenter: function () {
       
 13492             var div = document.createElement('div');
       
 13493             div.id = 'GPmapCenter';
       
 13494             div.className = '';
       
 13495             return div;
       
 13496         },
       
 13497         _createMousePositionPanelHeaderElement: function () {
       
 13498             var container = document.createElement('div');
       
 13499             container.className = 'GPpanelHeader';
       
 13500             var divTitle = document.createElement('div');
       
 13501             divTitle.className = 'GPpanelTitle';
       
 13502             divTitle.innerHTML = 'Coordonnées';
       
 13503             container.appendChild(divTitle);
       
 13504             var divClose = document.createElement('div');
       
 13505             divClose.id = 'GPmousePositionPanelClose';
       
 13506             divClose.className = 'GPpanelClose';
       
 13507             divClose.title = 'Fermer le panneau';
       
 13508             var self = this;
       
 13509             if (divClose.addEventListener) {
       
 13510                 divClose.addEventListener('click', function () {
       
 13511                     document.getElementById(self._addUID('GPshowMousePositionPicto')).click();
       
 13512                 }, false);
       
 13513             } else if (divClose.attachEvent) {
       
 13514                 divClose.attachEvent('onclick', function () {
       
 13515                     document.getElementById(self._addUID('GPshowMousePositionPicto')).click();
       
 13516                 });
       
 13517             }
       
 13518             container.appendChild(divClose);
       
 13519             return container;
       
 13520         },
       
 13521         _createMousePositionPanelBasicElement: function (displayAltitude, displayCoordinates) {
       
 13522             var container = document.createElement('div');
       
 13523             container.id = this._addUID('GPmousePositionBasicPanel');
       
 13524             container.appendChild(this._createMousePositionPanelBasicCoordinateElement(displayCoordinates));
       
 13525             container.appendChild(this._createMousePositionPanelBasicAltitudeElement(displayAltitude));
       
 13526             return container;
       
 13527         },
       
 13528         _createMousePositionPanelBasicCoordinateElement: function (display) {
       
 13529             var div = document.createElement('div');
       
 13530             div.id = this._addUID('GPmousePositionCoordinate');
       
 13531             div.style.display = display ? 'block' : 'none';
       
 13532             var spanLat = document.createElement('span');
       
 13533             spanLat.className = 'GPmousePositionLabel';
       
 13534             spanLat.id = this._addUID('GPmousePositionLatLabel');
       
 13535             spanLat.innerHTML = 'Latitude : ';
       
 13536             div.appendChild(spanLat);
       
 13537             var spanCLat = document.createElement('span');
       
 13538             spanCLat.className = 'GPmousePositionCoords';
       
 13539             spanCLat.id = this._addUID('GPmousePositionLat');
       
 13540             spanCLat.innerHTML = '';
       
 13541             div.appendChild(spanCLat);
       
 13542             var spanLon = document.createElement('span');
       
 13543             spanLon.className = 'GPmousePositionLabel';
       
 13544             spanLon.id = this._addUID('GPmousePositionLonLabel');
       
 13545             spanLon.innerHTML = 'Longitude : ';
       
 13546             div.appendChild(spanLon);
       
 13547             var spanCLon = document.createElement('span');
       
 13548             spanCLon.className = 'GPmousePositionCoords';
       
 13549             spanCLon.id = this._addUID('GPmousePositionLon');
       
 13550             spanCLon.innerHTML = '';
       
 13551             div.appendChild(spanCLon);
       
 13552             return div;
       
 13553         },
       
 13554         _createMousePositionPanelBasicAltitudeElement: function (display) {
       
 13555             var div = document.createElement('div');
       
 13556             div.id = this._addUID('GPmousePositionAltitude');
       
 13557             div.style.display = display ? 'block' : 'none';
       
 13558             var spanLabel = document.createElement('span');
       
 13559             spanLabel.className = 'GPmousePositionLabel';
       
 13560             spanLabel.innerHTML = 'Altitude : ';
       
 13561             div.appendChild(spanLabel);
       
 13562             var spanAlt = document.createElement('span');
       
 13563             spanAlt.className = 'GPmousePositionCoords';
       
 13564             spanAlt.id = this._addUID('GPmousePositionAlt');
       
 13565             spanAlt.innerHTML = '';
       
 13566             div.appendChild(spanAlt);
       
 13567             return div;
       
 13568         },
       
 13569         _createShowMousePositionSettingsElement: function (display) {
       
 13570             var list = [];
       
 13571             var input = document.createElement('input');
       
 13572             input.type = 'checkbox';
       
 13573             input.id = this._addUID('GPshowMousePositionSettings');
       
 13574             var label = document.createElement('label');
       
 13575             label.id = this._addUID('GPshowMousePositionSettingsPicto');
       
 13576             label.htmlFor = this._addUID('GPshowMousePositionSettings');
       
 13577             label.title = 'Réglages';
       
 13578             label.className = 'GPshowMoreOptions GPshowMousePositionSettingsPicto';
       
 13579             label.style.display = display ? 'block' : 'none';
       
 13580             list.push(input);
       
 13581             list.push(label);
       
 13582             return list;
       
 13583         },
       
 13584         _createMousePositionSettingsElement: function () {
       
 13585             var container = document.createElement('div');
       
 13586             container.id = this._addUID('GPmousePositionSettings');
       
 13587             var span = document.createElement('span');
       
 13588             span.className = 'GPmousePositionSettingsLabel';
       
 13589             span.innerHTML = 'Système de référence';
       
 13590             container.appendChild(span);
       
 13591             return container;
       
 13592         },
       
 13593         _createMousePositionSettingsSystemsElement: function (systems) {
       
 13594             var context = this;
       
 13595             var selectSystem = document.createElement('select');
       
 13596             selectSystem.id = this._addUID('GPmousePositionProjectionSystem');
       
 13597             selectSystem.className = 'GPinputSelect GPmousePositionSettingsSelect';
       
 13598             selectSystem.addEventListener('change', function (e) {
       
 13599                 context.onMousePositionProjectionSystemChange(e);
       
 13600             });
       
 13601             selectSystem.addEventListener('mouseover', function (e) {
       
 13602                 context.onMousePositionProjectionSystemMouseOver(e);
       
 13603             });
       
 13604             for (var i = 0; i < systems.length; i++) {
       
 13605                 var obj = systems[i];
       
 13606                 var option = document.createElement('option');
       
 13607                 option.value = obj.code;
       
 13608                 option.text = obj.label || i;
       
 13609                 selectSystem.appendChild(option);
       
 13610             }
       
 13611             return selectSystem;
       
 13612         },
       
 13613         _createMousePositionSettingsUnitsElement: function (units) {
       
 13614             var context = this;
       
 13615             var selectUnits = document.createElement('select');
       
 13616             selectUnits.id = this._addUID('GPmousePositionProjectionUnits');
       
 13617             selectUnits.className = 'GPinputSelect GPmousePositionSettingsSelect';
       
 13618             selectUnits.addEventListener('change', function (e) {
       
 13619                 context.onMousePositionProjectionUnitsChange(e);
       
 13620             });
       
 13621             for (var j = 0; j < units.length; j++) {
       
 13622                 var obj = units[j];
       
 13623                 var option = document.createElement('option');
       
 13624                 option.value = obj.code ? obj.code : j;
       
 13625                 option.text = obj.label || j;
       
 13626                 selectUnits.appendChild(option);
       
 13627             }
       
 13628             return selectUnits;
       
 13629         },
       
 13630         GPdisplayCoords: function (coordinate) {
       
 13631             if (coordinate && coordinate != null) {
       
 13632                 var labelLon = document.getElementById(this._addUID('GPmousePositionLonLabel'));
       
 13633                 var labelLat = document.getElementById(this._addUID('GPmousePositionLatLabel'));
       
 13634                 if (coordinate.x || coordinate.y) {
       
 13635                     labelLat.innerHTML = 'X : ';
       
 13636                     labelLon.innerHTML = 'Y : ';
       
 13637                 } else if (coordinate.e || coordinate.n) {
       
 13638                     labelLat.innerHTML = 'E : ';
       
 13639                     labelLon.innerHTML = 'N : ';
       
 13640                 } else {
       
 13641                     labelLat.innerHTML = 'Latitude : ';
       
 13642                     labelLon.innerHTML = 'Longitude : ';
       
 13643                 }
       
 13644                 var elLat = document.getElementById(this._addUID('GPmousePositionLat'));
       
 13645                 var elLon = document.getElementById(this._addUID('GPmousePositionLon'));
       
 13646                 elLat.innerHTML = coordinate.x || coordinate.lat || coordinate.e || '0';
       
 13647                 if (coordinate.unit) {
       
 13648                     elLat.innerHTML += ' ';
       
 13649                     elLat.innerHTML += coordinate.unit;
       
 13650                 }
       
 13651                 elLon.innerHTML = coordinate.y || coordinate.lng || coordinate.lon || coordinate.n || '0';
       
 13652                 if (coordinate.unit) {
       
 13653                     elLon.innerHTML += ' ';
       
 13654                     elLon.innerHTML += coordinate.unit;
       
 13655                 }
       
 13656             }
       
 13657         },
       
 13658         GPdisplayElevation: function (coordinate, altitudeTimeoutDelay, noDataValue, noDataValueTolerance) {
       
 13659             var self = this;
       
 13660             var altitudeTimeout;
       
 13661             if (!altitudeTimeoutDelay) {
       
 13662                 altitudeTimeoutDelay = 500;
       
 13663             }
       
 13664             clearTimeout(altitudeTimeout);
       
 13665             document.getElementById(this._addUID('GPmousePositionAlt')).innerHTML = '...';
       
 13666             if (noDataValue == null) {
       
 13667                 noDataValue = -99999;
       
 13668             }
       
 13669             if (noDataValueTolerance == null) {
       
 13670                 noDataValueTolerance = 99980;
       
 13671             }
       
 13672             var maxThreshold = noDataValue + noDataValueTolerance;
       
 13673             var minThreshold = noDataValue - noDataValueTolerance;
       
 13674             if (coordinate && coordinate != null) {
       
 13675                 if (document.getElementById(this._addUID('GPmousePositionAltitude'))) {
       
 13676                     altitudeTimeout = setTimeout(function () {
       
 13677                         self.onRequestAltitude(coordinate, function (z) {
       
 13678                             if (minThreshold < z && z < maxThreshold) {
       
 13679                                 document.getElementById(self._addUID('GPmousePositionAlt')).innerHTML = '--- m';
       
 13680                             } else {
       
 13681                                 document.getElementById(self._addUID('GPmousePositionAlt')).innerHTML = z + ' m';
       
 13682                             }
       
 13683                         });
       
 13684                     }, altitudeTimeoutDelay);
       
 13685                 }
       
 13686             }
       
 13687         }
       
 13688     };
       
 13689     return MousePositionDOM;
       
 13690 }();
       
 13691 !function (e) {
       
 13692     if ('object' == typeof exports)
       
 13693         module.exports = e();
       
 13694     else if (true)
       
 13695         proj4 = function () {
       
 13696             return typeof e === 'function' ? e() : e;
       
 13697         }();
       
 13698     else {
       
 13699         var f;
       
 13700         'undefined' != typeof window ? f = window : 'undefined' != typeof global ? f = global : 'undefined' != typeof self && (f = self), f.proj4 = e();
       
 13701     }
       
 13702 }(function () {
       
 13703     var define, module, exports;
       
 13704     return function e(t, n, r) {
       
 13705         function s(o, u) {
       
 13706             if (!n[o]) {
       
 13707                 if (!t[o]) {
       
 13708                     var a = typeof require == 'function' && require;
       
 13709                     if (!u && a)
       
 13710                         return a(o, !0);
       
 13711                     if (i)
       
 13712                         return i(o, !0);
       
 13713                     throw new Error('Cannot find module \'' + o + '\'');
       
 13714                 }
       
 13715                 var f = n[o] = { exports: {} };
       
 13716                 t[o][0].call(f.exports, function (e) {
       
 13717                     var n = t[o][1][e];
       
 13718                     return s(n ? n : e);
       
 13719                 }, f, f.exports, e, t, n, r);
       
 13720             }
       
 13721             return n[o].exports;
       
 13722         }
       
 13723         var i = typeof require == 'function' && require;
       
 13724         for (var o = 0; o < r.length; o++)
       
 13725             s(r[o]);
       
 13726         return s;
       
 13727     }({
       
 13728         1: [
       
 13729             function (_dereq_, module, exports) {
       
 13730                 var mgrs = _dereq_('mgrs');
       
 13731                 function Point(x, y, z) {
       
 13732                     if (!(this instanceof Point)) {
       
 13733                         return new Point(x, y, z);
       
 13734                     }
       
 13735                     if (Array.isArray(x)) {
       
 13736                         this.x = x[0];
       
 13737                         this.y = x[1];
       
 13738                         this.z = x[2] || 0;
       
 13739                     } else if (typeof x === 'object') {
       
 13740                         this.x = x.x;
       
 13741                         this.y = x.y;
       
 13742                         this.z = x.z || 0;
       
 13743                     } else if (typeof x === 'string' && typeof y === 'undefined') {
       
 13744                         var coords = x.split(',');
       
 13745                         this.x = parseFloat(coords[0], 10);
       
 13746                         this.y = parseFloat(coords[1], 10);
       
 13747                         this.z = parseFloat(coords[2], 10) || 0;
       
 13748                     } else {
       
 13749                         this.x = x;
       
 13750                         this.y = y;
       
 13751                         this.z = z || 0;
       
 13752                     }
       
 13753                     console.warn('proj4.Point will be removed in version 3, use proj4.toPoint');
       
 13754                 }
       
 13755                 Point.fromMGRS = function (mgrsStr) {
       
 13756                     return new Point(mgrs.toPoint(mgrsStr));
       
 13757                 };
       
 13758                 Point.prototype.toMGRS = function (accuracy) {
       
 13759                     return mgrs.forward([
       
 13760                         this.x,
       
 13761                         this.y
       
 13762                     ], accuracy);
       
 13763                 };
       
 13764                 module.exports = Point;
       
 13765                 return exports;
       
 13766             },
       
 13767             { 'mgrs': 66 }
       
 13768         ],
       
 13769         2: [
       
 13770             function (_dereq_, module, exports) {
       
 13771                 var parseCode = _dereq_('./parseCode');
       
 13772                 var extend = _dereq_('./extend');
       
 13773                 var projections = _dereq_('./projections');
       
 13774                 var deriveConstants = _dereq_('./deriveConstants');
       
 13775                 function Projection(srsCode, callback) {
       
 13776                     if (!(this instanceof Projection)) {
       
 13777                         return new Projection(srsCode);
       
 13778                     }
       
 13779                     callback = callback || function (error) {
       
 13780                         if (error) {
       
 13781                             throw error;
       
 13782                         }
       
 13783                     };
       
 13784                     var json = parseCode(srsCode);
       
 13785                     if (typeof json !== 'object') {
       
 13786                         callback(srsCode);
       
 13787                         return;
       
 13788                     }
       
 13789                     var modifiedJSON = deriveConstants(json);
       
 13790                     var ourProj = Projection.projections.get(modifiedJSON.projName);
       
 13791                     if (ourProj) {
       
 13792                         extend(this, modifiedJSON);
       
 13793                         extend(this, ourProj);
       
 13794                         this.init();
       
 13795                         callback(null, this);
       
 13796                     } else {
       
 13797                         callback(srsCode);
       
 13798                     }
       
 13799                 }
       
 13800                 Projection.projections = projections;
       
 13801                 Projection.projections.start();
       
 13802                 module.exports = Projection;
       
 13803                 return exports;
       
 13804             },
       
 13805             {
       
 13806                 './deriveConstants': 32,
       
 13807                 './extend': 33,
       
 13808                 './parseCode': 36,
       
 13809                 './projections': 38
       
 13810             }
       
 13811         ],
       
 13812         3: [
       
 13813             function (_dereq_, module, exports) {
       
 13814                 module.exports = function (crs, denorm, point) {
       
 13815                     var xin = point.x, yin = point.y, zin = point.z || 0;
       
 13816                     var v, t, i;
       
 13817                     for (i = 0; i < 3; i++) {
       
 13818                         if (denorm && i === 2 && point.z === undefined) {
       
 13819                             continue;
       
 13820                         }
       
 13821                         if (i === 0) {
       
 13822                             v = xin;
       
 13823                             t = 'x';
       
 13824                         } else if (i === 1) {
       
 13825                             v = yin;
       
 13826                             t = 'y';
       
 13827                         } else {
       
 13828                             v = zin;
       
 13829                             t = 'z';
       
 13830                         }
       
 13831                         switch (crs.axis[i]) {
       
 13832                         case 'e':
       
 13833                             point[t] = v;
       
 13834                             break;
       
 13835                         case 'w':
       
 13836                             point[t] = -v;
       
 13837                             break;
       
 13838                         case 'n':
       
 13839                             point[t] = v;
       
 13840                             break;
       
 13841                         case 's':
       
 13842                             point[t] = -v;
       
 13843                             break;
       
 13844                         case 'u':
       
 13845                             if (point[t] !== undefined) {
       
 13846                                 point.z = v;
       
 13847                             }
       
 13848                             break;
       
 13849                         case 'd':
       
 13850                             if (point[t] !== undefined) {
       
 13851                                 point.z = -v;
       
 13852                             }
       
 13853                             break;
       
 13854                         default:
       
 13855                             return null;
       
 13856                         }
       
 13857                     }
       
 13858                     return point;
       
 13859                 };
       
 13860                 return exports;
       
 13861             },
       
 13862             {}
       
 13863         ],
       
 13864         4: [
       
 13865             function (_dereq_, module, exports) {
       
 13866                 var HALF_PI = Math.PI / 2;
       
 13867                 var sign = _dereq_('./sign');
       
 13868                 module.exports = function (x) {
       
 13869                     return Math.abs(x) < HALF_PI ? x : x - sign(x) * Math.PI;
       
 13870                 };
       
 13871                 return exports;
       
 13872             },
       
 13873             { './sign': 21 }
       
 13874         ],
       
 13875         5: [
       
 13876             function (_dereq_, module, exports) {
       
 13877                 var TWO_PI = Math.PI * 2;
       
 13878                 var sign = _dereq_('./sign');
       
 13879                 module.exports = function (x) {
       
 13880                     return Math.abs(x) < Math.PI ? x : x - sign(x) * TWO_PI;
       
 13881                 };
       
 13882                 return exports;
       
 13883             },
       
 13884             { './sign': 21 }
       
 13885         ],
       
 13886         6: [
       
 13887             function (_dereq_, module, exports) {
       
 13888                 module.exports = function (x) {
       
 13889                     if (Math.abs(x) > 1) {
       
 13890                         x = x > 1 ? 1 : -1;
       
 13891                     }
       
 13892                     return Math.asin(x);
       
 13893                 };
       
 13894                 return exports;
       
 13895             },
       
 13896             {}
       
 13897         ],
       
 13898         7: [
       
 13899             function (_dereq_, module, exports) {
       
 13900                 module.exports = function (x) {
       
 13901                     return 1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x));
       
 13902                 };
       
 13903                 return exports;
       
 13904             },
       
 13905             {}
       
 13906         ],
       
 13907         8: [
       
 13908             function (_dereq_, module, exports) {
       
 13909                 module.exports = function (x) {
       
 13910                     return 0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x));
       
 13911                 };
       
 13912                 return exports;
       
 13913             },
       
 13914             {}
       
 13915         ],
       
 13916         9: [
       
 13917             function (_dereq_, module, exports) {
       
 13918                 module.exports = function (x) {
       
 13919                     return 0.05859375 * x * x * (1 + 0.75 * x);
       
 13920                 };
       
 13921                 return exports;
       
 13922             },
       
 13923             {}
       
 13924         ],
       
 13925         10: [
       
 13926             function (_dereq_, module, exports) {
       
 13927                 module.exports = function (x) {
       
 13928                     return x * x * x * (35 / 3072);
       
 13929                 };
       
 13930                 return exports;
       
 13931             },
       
 13932             {}
       
 13933         ],
       
 13934         11: [
       
 13935             function (_dereq_, module, exports) {
       
 13936                 module.exports = function (a, e, sinphi) {
       
 13937                     var temp = e * sinphi;
       
 13938                     return a / Math.sqrt(1 - temp * temp);
       
 13939                 };
       
 13940                 return exports;
       
 13941             },
       
 13942             {}
       
 13943         ],
       
 13944         12: [
       
 13945             function (_dereq_, module, exports) {
       
 13946                 module.exports = function (ml, e0, e1, e2, e3) {
       
 13947                     var phi;
       
 13948                     var dphi;
       
 13949                     phi = ml / e0;
       
 13950                     for (var i = 0; i < 15; i++) {
       
 13951                         dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));
       
 13952                         phi += dphi;
       
 13953                         if (Math.abs(dphi) <= 1e-10) {
       
 13954                             return phi;
       
 13955                         }
       
 13956                     }
       
 13957                     return NaN;
       
 13958                 };
       
 13959                 return exports;
       
 13960             },
       
 13961             {}
       
 13962         ],
       
 13963         13: [
       
 13964             function (_dereq_, module, exports) {
       
 13965                 var HALF_PI = Math.PI / 2;
       
 13966                 module.exports = function (eccent, q) {
       
 13967                     var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));
       
 13968                     if (Math.abs(Math.abs(q) - temp) < 0.000001) {
       
 13969                         if (q < 0) {
       
 13970                             return -1 * HALF_PI;
       
 13971                         } else {
       
 13972                             return HALF_PI;
       
 13973                         }
       
 13974                     }
       
 13975                     var phi = Math.asin(0.5 * q);
       
 13976                     var dphi;
       
 13977                     var sin_phi;
       
 13978                     var cos_phi;
       
 13979                     var con;
       
 13980                     for (var i = 0; i < 30; i++) {
       
 13981                         sin_phi = Math.sin(phi);
       
 13982                         cos_phi = Math.cos(phi);
       
 13983                         con = eccent * sin_phi;
       
 13984                         dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
       
 13985                         phi += dphi;
       
 13986                         if (Math.abs(dphi) <= 1e-10) {
       
 13987                             return phi;
       
 13988                         }
       
 13989                     }
       
 13990                     return NaN;
       
 13991                 };
       
 13992                 return exports;
       
 13993             },
       
 13994             {}
       
 13995         ],
       
 13996         14: [
       
 13997             function (_dereq_, module, exports) {
       
 13998                 module.exports = function (e0, e1, e2, e3, phi) {
       
 13999                     return e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi);
       
 14000                 };
       
 14001                 return exports;
       
 14002             },
       
 14003             {}
       
 14004         ],
       
 14005         15: [
       
 14006             function (_dereq_, module, exports) {
       
 14007                 module.exports = function (eccent, sinphi, cosphi) {
       
 14008                     var con = eccent * sinphi;
       
 14009                     return cosphi / Math.sqrt(1 - con * con);
       
 14010                 };
       
 14011                 return exports;
       
 14012             },
       
 14013             {}
       
 14014         ],
       
 14015         16: [
       
 14016             function (_dereq_, module, exports) {
       
 14017                 var HALF_PI = Math.PI / 2;
       
 14018                 module.exports = function (eccent, ts) {
       
 14019                     var eccnth = 0.5 * eccent;
       
 14020                     var con, dphi;
       
 14021                     var phi = HALF_PI - 2 * Math.atan(ts);
       
 14022                     for (var i = 0; i <= 15; i++) {
       
 14023                         con = eccent * Math.sin(phi);
       
 14024                         dphi = HALF_PI - 2 * Math.atan(ts * Math.pow((1 - con) / (1 + con), eccnth)) - phi;
       
 14025                         phi += dphi;
       
 14026                         if (Math.abs(dphi) <= 1e-10) {
       
 14027                             return phi;
       
 14028                         }
       
 14029                     }
       
 14030                     return -9999;
       
 14031                 };
       
 14032                 return exports;
       
 14033             },
       
 14034             {}
       
 14035         ],
       
 14036         17: [
       
 14037             function (_dereq_, module, exports) {
       
 14038                 var C00 = 1;
       
 14039                 var C02 = 0.25;
       
 14040                 var C04 = 0.046875;
       
 14041                 var C06 = 0.01953125;
       
 14042                 var C08 = 0.01068115234375;
       
 14043                 var C22 = 0.75;
       
 14044                 var C44 = 0.46875;
       
 14045                 var C46 = 0.013020833333333334;
       
 14046                 var C48 = 0.007120768229166667;
       
 14047                 var C66 = 0.3645833333333333;
       
 14048                 var C68 = 0.005696614583333333;
       
 14049                 var C88 = 0.3076171875;
       
 14050                 module.exports = function (es) {
       
 14051                     var en = [];
       
 14052                     en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));
       
 14053                     en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));
       
 14054                     var t = es * es;
       
 14055                     en[2] = t * (C44 - es * (C46 + es * C48));
       
 14056                     t *= es;
       
 14057                     en[3] = t * (C66 - es * C68);
       
 14058                     en[4] = t * es * C88;
       
 14059                     return en;
       
 14060                 };
       
 14061                 return exports;
       
 14062             },
       
 14063             {}
       
 14064         ],
       
 14065         18: [
       
 14066             function (_dereq_, module, exports) {
       
 14067                 var pj_mlfn = _dereq_('./pj_mlfn');
       
 14068                 var EPSLN = 1e-10;
       
 14069                 var MAX_ITER = 20;
       
 14070                 module.exports = function (arg, es, en) {
       
 14071                     var k = 1 / (1 - es);
       
 14072                     var phi = arg;
       
 14073                     for (var i = MAX_ITER; i; --i) {
       
 14074                         var s = Math.sin(phi);
       
 14075                         var t = 1 - es * s * s;
       
 14076                         t = (pj_mlfn(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k;
       
 14077                         phi -= t;
       
 14078                         if (Math.abs(t) < EPSLN) {
       
 14079                             return phi;
       
 14080                         }
       
 14081                     }
       
 14082                     return phi;
       
 14083                 };
       
 14084                 return exports;
       
 14085             },
       
 14086             { './pj_mlfn': 19 }
       
 14087         ],
       
 14088         19: [
       
 14089             function (_dereq_, module, exports) {
       
 14090                 module.exports = function (phi, sphi, cphi, en) {
       
 14091                     cphi *= sphi;
       
 14092                     sphi *= sphi;
       
 14093                     return en[0] * phi - cphi * (en[1] + sphi * (en[2] + sphi * (en[3] + sphi * en[4])));
       
 14094                 };
       
 14095                 return exports;
       
 14096             },
       
 14097             {}
       
 14098         ],
       
 14099         20: [
       
 14100             function (_dereq_, module, exports) {
       
 14101                 module.exports = function (eccent, sinphi) {
       
 14102                     var con;
       
 14103                     if (eccent > 1e-7) {
       
 14104                         con = eccent * sinphi;
       
 14105                         return (1 - eccent * eccent) * (sinphi / (1 - con * con) - 0.5 / eccent * Math.log((1 - con) / (1 + con)));
       
 14106                     } else {
       
 14107                         return 2 * sinphi;
       
 14108                     }
       
 14109                 };
       
 14110                 return exports;
       
 14111             },
       
 14112             {}
       
 14113         ],
       
 14114         21: [
       
 14115             function (_dereq_, module, exports) {
       
 14116                 module.exports = function (x) {
       
 14117                     return x < 0 ? -1 : 1;
       
 14118                 };
       
 14119                 return exports;
       
 14120             },
       
 14121             {}
       
 14122         ],
       
 14123         22: [
       
 14124             function (_dereq_, module, exports) {
       
 14125                 module.exports = function (esinp, exp) {
       
 14126                     return Math.pow((1 - esinp) / (1 + esinp), exp);
       
 14127                 };
       
 14128                 return exports;
       
 14129             },
       
 14130             {}
       
 14131         ],
       
 14132         23: [
       
 14133             function (_dereq_, module, exports) {
       
 14134                 module.exports = function (array) {
       
 14135                     var out = {
       
 14136                         x: array[0],
       
 14137                         y: array[1]
       
 14138                     };
       
 14139                     if (array.length > 2) {
       
 14140                         out.z = array[2];
       
 14141                     }
       
 14142                     if (array.length > 3) {
       
 14143                         out.m = array[3];
       
 14144                     }
       
 14145                     return out;
       
 14146                 };
       
 14147                 return exports;
       
 14148             },
       
 14149             {}
       
 14150         ],
       
 14151         24: [
       
 14152             function (_dereq_, module, exports) {
       
 14153                 var HALF_PI = Math.PI / 2;
       
 14154                 module.exports = function (eccent, phi, sinphi) {
       
 14155                     var con = eccent * sinphi;
       
 14156                     var com = 0.5 * eccent;
       
 14157                     con = Math.pow((1 - con) / (1 + con), com);
       
 14158                     return Math.tan(0.5 * (HALF_PI - phi)) / con;
       
 14159                 };
       
 14160                 return exports;
       
 14161             },
       
 14162             {}
       
 14163         ],
       
 14164         25: [
       
 14165             function (_dereq_, module, exports) {
       
 14166                 exports.wgs84 = {
       
 14167                     towgs84: '0,0,0',
       
 14168                     ellipse: 'WGS84',
       
 14169                     datumName: 'WGS84'
       
 14170                 };
       
 14171                 exports.ch1903 = {
       
 14172                     towgs84: '674.374,15.056,405.346',
       
 14173                     ellipse: 'bessel',
       
 14174                     datumName: 'swiss'
       
 14175                 };
       
 14176                 exports.ggrs87 = {
       
 14177                     towgs84: '-199.87,74.79,246.62',
       
 14178                     ellipse: 'GRS80',
       
 14179                     datumName: 'Greek_Geodetic_Reference_System_1987'
       
 14180                 };
       
 14181                 exports.nad83 = {
       
 14182                     towgs84: '0,0,0',
       
 14183                     ellipse: 'GRS80',
       
 14184                     datumName: 'North_American_Datum_1983'
       
 14185                 };
       
 14186                 exports.nad27 = {
       
 14187                     nadgrids: '@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat',
       
 14188                     ellipse: 'clrk66',
       
 14189                     datumName: 'North_American_Datum_1927'
       
 14190                 };
       
 14191                 exports.potsdam = {
       
 14192                     towgs84: '606.0,23.0,413.0',
       
 14193                     ellipse: 'bessel',
       
 14194                     datumName: 'Potsdam Rauenberg 1950 DHDN'
       
 14195                 };
       
 14196                 exports.carthage = {
       
 14197                     towgs84: '-263.0,6.0,431.0',
       
 14198                     ellipse: 'clark80',
       
 14199                     datumName: 'Carthage 1934 Tunisia'
       
 14200                 };
       
 14201                 exports.hermannskogel = {
       
 14202                     towgs84: '653.0,-212.0,449.0',
       
 14203                     ellipse: 'bessel',
       
 14204                     datumName: 'Hermannskogel'
       
 14205                 };
       
 14206                 exports.ire65 = {
       
 14207                     towgs84: '482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15',
       
 14208                     ellipse: 'mod_airy',
       
 14209                     datumName: 'Ireland 1965'
       
 14210                 };
       
 14211                 exports.rassadiran = {
       
 14212                     towgs84: '-133.63,-157.5,-158.62',
       
 14213                     ellipse: 'intl',
       
 14214                     datumName: 'Rassadiran'
       
 14215                 };
       
 14216                 exports.nzgd49 = {
       
 14217                     towgs84: '59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993',
       
 14218                     ellipse: 'intl',
       
 14219                     datumName: 'New Zealand Geodetic Datum 1949'
       
 14220                 };
       
 14221                 exports.osgb36 = {
       
 14222                     towgs84: '446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894',
       
 14223                     ellipse: 'airy',
       
 14224                     datumName: 'Airy 1830'
       
 14225                 };
       
 14226                 exports.s_jtsk = {
       
 14227                     towgs84: '589,76,480',
       
 14228                     ellipse: 'bessel',
       
 14229                     datumName: 'S-JTSK (Ferro)'
       
 14230                 };
       
 14231                 exports.beduaram = {
       
 14232                     towgs84: '-106,-87,188',
       
 14233                     ellipse: 'clrk80',
       
 14234                     datumName: 'Beduaram'
       
 14235                 };
       
 14236                 exports.gunung_segara = {
       
 14237                     towgs84: '-403,684,41',
       
 14238                     ellipse: 'bessel',
       
 14239                     datumName: 'Gunung Segara Jakarta'
       
 14240                 };
       
 14241                 exports.rnb72 = {
       
 14242                     towgs84: '106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1',
       
 14243                     ellipse: 'intl',
       
 14244                     datumName: 'Reseau National Belge 1972'
       
 14245                 };
       
 14246                 return exports;
       
 14247             },
       
 14248             {}
       
 14249         ],
       
 14250         26: [
       
 14251             function (_dereq_, module, exports) {
       
 14252                 exports.MERIT = {
       
 14253                     a: 6378137,
       
 14254                     rf: 298.257,
       
 14255                     ellipseName: 'MERIT 1983'
       
 14256                 };
       
 14257                 exports.SGS85 = {
       
 14258                     a: 6378136,
       
 14259                     rf: 298.257,
       
 14260                     ellipseName: 'Soviet Geodetic System 85'
       
 14261                 };
       
 14262                 exports.GRS80 = {
       
 14263                     a: 6378137,
       
 14264                     rf: 298.257222101,
       
 14265                     ellipseName: 'GRS 1980(IUGG, 1980)'
       
 14266                 };
       
 14267                 exports.IAU76 = {
       
 14268                     a: 6378140,
       
 14269                     rf: 298.257,
       
 14270                     ellipseName: 'IAU 1976'
       
 14271                 };
       
 14272                 exports.airy = {
       
 14273                     a: 6377563.396,
       
 14274                     b: 6356256.91,
       
 14275                     ellipseName: 'Airy 1830'
       
 14276                 };
       
 14277                 exports.APL4 = {
       
 14278                     a: 6378137,
       
 14279                     rf: 298.25,
       
 14280                     ellipseName: 'Appl. Physics. 1965'
       
 14281                 };
       
 14282                 exports.NWL9D = {
       
 14283                     a: 6378145,
       
 14284                     rf: 298.25,
       
 14285                     ellipseName: 'Naval Weapons Lab., 1965'
       
 14286                 };
       
 14287                 exports.mod_airy = {
       
 14288                     a: 6377340.189,
       
 14289                     b: 6356034.446,
       
 14290                     ellipseName: 'Modified Airy'
       
 14291                 };
       
 14292                 exports.andrae = {
       
 14293                     a: 6377104.43,
       
 14294                     rf: 300,
       
 14295                     ellipseName: 'Andrae 1876 (Den., Iclnd.)'
       
 14296                 };
       
 14297                 exports.aust_SA = {
       
 14298                     a: 6378160,
       
 14299                     rf: 298.25,
       
 14300                     ellipseName: 'Australian Natl & S. Amer. 1969'
       
 14301                 };
       
 14302                 exports.GRS67 = {
       
 14303                     a: 6378160,
       
 14304                     rf: 298.247167427,
       
 14305                     ellipseName: 'GRS 67(IUGG 1967)'
       
 14306                 };
       
 14307                 exports.bessel = {
       
 14308                     a: 6377397.155,
       
 14309                     rf: 299.1528128,
       
 14310                     ellipseName: 'Bessel 1841'
       
 14311                 };
       
 14312                 exports.bess_nam = {
       
 14313                     a: 6377483.865,
       
 14314                     rf: 299.1528128,
       
 14315                     ellipseName: 'Bessel 1841 (Namibia)'
       
 14316                 };
       
 14317                 exports.clrk66 = {
       
 14318                     a: 6378206.4,
       
 14319                     b: 6356583.8,
       
 14320                     ellipseName: 'Clarke 1866'
       
 14321                 };
       
 14322                 exports.clrk80 = {
       
 14323                     a: 6378249.145,
       
 14324                     rf: 293.4663,
       
 14325                     ellipseName: 'Clarke 1880 mod.'
       
 14326                 };
       
 14327                 exports.clrk58 = {
       
 14328                     a: 6378293.645208759,
       
 14329                     rf: 294.2606763692654,
       
 14330                     ellipseName: 'Clarke 1858'
       
 14331                 };
       
 14332                 exports.CPM = {
       
 14333                     a: 6375738.7,
       
 14334                     rf: 334.29,
       
 14335                     ellipseName: 'Comm. des Poids et Mesures 1799'
       
 14336                 };
       
 14337                 exports.delmbr = {
       
 14338                     a: 6376428,
       
 14339                     rf: 311.5,
       
 14340                     ellipseName: 'Delambre 1810 (Belgium)'
       
 14341                 };
       
 14342                 exports.engelis = {
       
 14343                     a: 6378136.05,
       
 14344                     rf: 298.2566,
       
 14345                     ellipseName: 'Engelis 1985'
       
 14346                 };
       
 14347                 exports.evrst30 = {
       
 14348                     a: 6377276.345,
       
 14349                     rf: 300.8017,
       
 14350                     ellipseName: 'Everest 1830'
       
 14351                 };
       
 14352                 exports.evrst48 = {
       
 14353                     a: 6377304.063,
       
 14354                     rf: 300.8017,
       
 14355                     ellipseName: 'Everest 1948'
       
 14356                 };
       
 14357                 exports.evrst56 = {
       
 14358                     a: 6377301.243,
       
 14359                     rf: 300.8017,
       
 14360                     ellipseName: 'Everest 1956'
       
 14361                 };
       
 14362                 exports.evrst69 = {
       
 14363                     a: 6377295.664,
       
 14364                     rf: 300.8017,
       
 14365                     ellipseName: 'Everest 1969'
       
 14366                 };
       
 14367                 exports.evrstSS = {
       
 14368                     a: 6377298.556,
       
 14369                     rf: 300.8017,
       
 14370                     ellipseName: 'Everest (Sabah & Sarawak)'
       
 14371                 };
       
 14372                 exports.fschr60 = {
       
 14373                     a: 6378166,
       
 14374                     rf: 298.3,
       
 14375                     ellipseName: 'Fischer (Mercury Datum) 1960'
       
 14376                 };
       
 14377                 exports.fschr60m = {
       
 14378                     a: 6378155,
       
 14379                     rf: 298.3,
       
 14380                     ellipseName: 'Fischer 1960'
       
 14381                 };
       
 14382                 exports.fschr68 = {
       
 14383                     a: 6378150,
       
 14384                     rf: 298.3,
       
 14385                     ellipseName: 'Fischer 1968'
       
 14386                 };
       
 14387                 exports.helmert = {
       
 14388                     a: 6378200,
       
 14389                     rf: 298.3,
       
 14390                     ellipseName: 'Helmert 1906'
       
 14391                 };
       
 14392                 exports.hough = {
       
 14393                     a: 6378270,
       
 14394                     rf: 297,
       
 14395                     ellipseName: 'Hough'
       
 14396                 };
       
 14397                 exports.intl = {
       
 14398                     a: 6378388,
       
 14399                     rf: 297,
       
 14400                     ellipseName: 'International 1909 (Hayford)'
       
 14401                 };
       
 14402                 exports.kaula = {
       
 14403                     a: 6378163,
       
 14404                     rf: 298.24,
       
 14405                     ellipseName: 'Kaula 1961'
       
 14406                 };
       
 14407                 exports.lerch = {
       
 14408                     a: 6378139,
       
 14409                     rf: 298.257,
       
 14410                     ellipseName: 'Lerch 1979'
       
 14411                 };
       
 14412                 exports.mprts = {
       
 14413                     a: 6397300,
       
 14414                     rf: 191,
       
 14415                     ellipseName: 'Maupertius 1738'
       
 14416                 };
       
 14417                 exports.new_intl = {
       
 14418                     a: 6378157.5,
       
 14419                     b: 6356772.2,
       
 14420                     ellipseName: 'New International 1967'
       
 14421                 };
       
 14422                 exports.plessis = {
       
 14423                     a: 6376523,
       
 14424                     rf: 6355863,
       
 14425                     ellipseName: 'Plessis 1817 (France)'
       
 14426                 };
       
 14427                 exports.krass = {
       
 14428                     a: 6378245,
       
 14429                     rf: 298.3,
       
 14430                     ellipseName: 'Krassovsky, 1942'
       
 14431                 };
       
 14432                 exports.SEasia = {
       
 14433                     a: 6378155,
       
 14434                     b: 6356773.3205,
       
 14435                     ellipseName: 'Southeast Asia'
       
 14436                 };
       
 14437                 exports.walbeck = {
       
 14438                     a: 6376896,
       
 14439                     b: 6355834.8467,
       
 14440                     ellipseName: 'Walbeck'
       
 14441                 };
       
 14442                 exports.WGS60 = {
       
 14443                     a: 6378165,
       
 14444                     rf: 298.3,
       
 14445                     ellipseName: 'WGS 60'
       
 14446                 };
       
 14447                 exports.WGS66 = {
       
 14448                     a: 6378145,
       
 14449                     rf: 298.25,
       
 14450                     ellipseName: 'WGS 66'
       
 14451                 };
       
 14452                 exports.WGS7 = {
       
 14453                     a: 6378135,
       
 14454                     rf: 298.26,
       
 14455                     ellipseName: 'WGS 72'
       
 14456                 };
       
 14457                 exports.WGS84 = {
       
 14458                     a: 6378137,
       
 14459                     rf: 298.257223563,
       
 14460                     ellipseName: 'WGS 84'
       
 14461                 };
       
 14462                 exports.sphere = {
       
 14463                     a: 6370997,
       
 14464                     b: 6370997,
       
 14465                     ellipseName: 'Normal Sphere (r=6370997)'
       
 14466                 };
       
 14467                 return exports;
       
 14468             },
       
 14469             {}
       
 14470         ],
       
 14471         27: [
       
 14472             function (_dereq_, module, exports) {
       
 14473                 exports.greenwich = 0;
       
 14474                 exports.lisbon = -9.131906111111;
       
 14475                 exports.paris = 2.337229166667;
       
 14476                 exports.bogota = -74.080916666667;
       
 14477                 exports.madrid = -3.687938888889;
       
 14478                 exports.rome = 12.452333333333;
       
 14479                 exports.bern = 7.439583333333;
       
 14480                 exports.jakarta = 106.807719444444;
       
 14481                 exports.ferro = -17.666666666667;
       
 14482                 exports.brussels = 4.367975;
       
 14483                 exports.stockholm = 18.058277777778;
       
 14484                 exports.athens = 23.7163375;
       
 14485                 exports.oslo = 10.722916666667;
       
 14486                 return exports;
       
 14487             },
       
 14488             {}
       
 14489         ],
       
 14490         28: [
       
 14491             function (_dereq_, module, exports) {
       
 14492                 var proj = _dereq_('./Proj');
       
 14493                 var transform = _dereq_('./transform');
       
 14494                 var wgs84 = proj('WGS84');
       
 14495                 function transformer(from, to, coords) {
       
 14496                     var transformedArray;
       
 14497                     if (Array.isArray(coords)) {
       
 14498                         transformedArray = transform(from, to, coords);
       
 14499                         if (coords.length === 3) {
       
 14500                             return [
       
 14501                                 transformedArray.x,
       
 14502                                 transformedArray.y,
       
 14503                                 transformedArray.z
       
 14504                             ];
       
 14505                         } else {
       
 14506                             return [
       
 14507                                 transformedArray.x,
       
 14508                                 transformedArray.y
       
 14509                             ];
       
 14510                         }
       
 14511                     } else {
       
 14512                         return transform(from, to, coords);
       
 14513                     }
       
 14514                 }
       
 14515                 function checkProj(item) {
       
 14516                     if (item instanceof proj) {
       
 14517                         return item;
       
 14518                     }
       
 14519                     if (item.oProj) {
       
 14520                         return item.oProj;
       
 14521                     }
       
 14522                     return proj(item);
       
 14523                 }
       
 14524                 function proj4(fromProj, toProj, coord) {
       
 14525                     fromProj = checkProj(fromProj);
       
 14526                     var single = false;
       
 14527                     var obj;
       
 14528                     if (typeof toProj === 'undefined') {
       
 14529                         toProj = fromProj;
       
 14530                         fromProj = wgs84;
       
 14531                         single = true;
       
 14532                     } else if (typeof toProj.x !== 'undefined' || Array.isArray(toProj)) {
       
 14533                         coord = toProj;
       
 14534                         toProj = fromProj;
       
 14535                         fromProj = wgs84;
       
 14536                         single = true;
       
 14537                     }
       
 14538                     toProj = checkProj(toProj);
       
 14539                     if (coord) {
       
 14540                         return transformer(fromProj, toProj, coord);
       
 14541                     } else {
       
 14542                         obj = {
       
 14543                             forward: function (coords) {
       
 14544                                 return transformer(fromProj, toProj, coords);
       
 14545                             },
       
 14546                             inverse: function (coords) {
       
 14547                                 return transformer(toProj, fromProj, coords);
       
 14548                             }
       
 14549                         };
       
 14550                         if (single) {
       
 14551                             obj.oProj = toProj;
       
 14552                         }
       
 14553                         return obj;
       
 14554                     }
       
 14555                 }
       
 14556                 module.exports = proj4;
       
 14557                 return exports;
       
 14558             },
       
 14559             {
       
 14560                 './Proj': 2,
       
 14561                 './transform': 64
       
 14562             }
       
 14563         ],
       
 14564         29: [
       
 14565             function (_dereq_, module, exports) {
       
 14566                 var HALF_PI = Math.PI / 2;
       
 14567                 var PJD_3PARAM = 1;
       
 14568                 var PJD_7PARAM = 2;
       
 14569                 var PJD_GRIDSHIFT = 3;
       
 14570                 var PJD_WGS84 = 4;
       
 14571                 var PJD_NODATUM = 5;
       
 14572                 var SEC_TO_RAD = 0.00000484813681109536;
       
 14573                 var AD_C = 1.0026;
       
 14574                 var COS_67P5 = 0.3826834323650898;
       
 14575                 var datum = function (proj) {
       
 14576                     if (!(this instanceof datum)) {
       
 14577                         return new datum(proj);
       
 14578                     }
       
 14579                     this.datum_type = PJD_WGS84;
       
 14580                     if (!proj) {
       
 14581                         return;
       
 14582                     }
       
 14583                     if (proj.datumCode && proj.datumCode === 'none') {
       
 14584                         this.datum_type = PJD_NODATUM;
       
 14585                     }
       
 14586                     if (proj.datum_params) {
       
 14587                         for (var i = 0; i < proj.datum_params.length; i++) {
       
 14588                             proj.datum_params[i] = parseFloat(proj.datum_params[i]);
       
 14589                         }
       
 14590                         if (proj.datum_params[0] !== 0 || proj.datum_params[1] !== 0 || proj.datum_params[2] !== 0) {
       
 14591                             this.datum_type = PJD_3PARAM;
       
 14592                         }
       
 14593                         if (proj.datum_params.length > 3) {
       
 14594                             if (proj.datum_params[3] !== 0 || proj.datum_params[4] !== 0 || proj.datum_params[5] !== 0 || proj.datum_params[6] !== 0) {
       
 14595                                 this.datum_type = PJD_7PARAM;
       
 14596                                 proj.datum_params[3] *= SEC_TO_RAD;
       
 14597                                 proj.datum_params[4] *= SEC_TO_RAD;
       
 14598                                 proj.datum_params[5] *= SEC_TO_RAD;
       
 14599                                 proj.datum_params[6] = proj.datum_params[6] / 1000000 + 1;
       
 14600                             }
       
 14601                         }
       
 14602                     }
       
 14603                     this.datum_type = proj.grids ? PJD_GRIDSHIFT : this.datum_type;
       
 14604                     this.a = proj.a;
       
 14605                     this.b = proj.b;
       
 14606                     this.es = proj.es;
       
 14607                     this.ep2 = proj.ep2;
       
 14608                     this.datum_params = proj.datum_params;
       
 14609                     if (this.datum_type === PJD_GRIDSHIFT) {
       
 14610                         this.grids = proj.grids;
       
 14611                     }
       
 14612                 };
       
 14613                 datum.prototype = {
       
 14614                     compare_datums: function (dest) {
       
 14615                         if (this.datum_type !== dest.datum_type) {
       
 14616                             return false;
       
 14617                         } else if (this.a !== dest.a || Math.abs(this.es - dest.es) > 5e-11) {
       
 14618                             return false;
       
 14619                         } else if (this.datum_type === PJD_3PARAM) {
       
 14620                             return this.datum_params[0] === dest.datum_params[0] && this.datum_params[1] === dest.datum_params[1] && this.datum_params[2] === dest.datum_params[2];
       
 14621                         } else if (this.datum_type === PJD_7PARAM) {
       
 14622                             return this.datum_params[0] === dest.datum_params[0] && this.datum_params[1] === dest.datum_params[1] && this.datum_params[2] === dest.datum_params[2] && this.datum_params[3] === dest.datum_params[3] && this.datum_params[4] === dest.datum_params[4] && this.datum_params[5] === dest.datum_params[5] && this.datum_params[6] === dest.datum_params[6];
       
 14623                         } else if (this.datum_type === PJD_GRIDSHIFT || dest.datum_type === PJD_GRIDSHIFT) {
       
 14624                             return this.nadgrids === dest.nadgrids;
       
 14625                         } else {
       
 14626                             return true;
       
 14627                         }
       
 14628                     },
       
 14629                     geodetic_to_geocentric: function (p) {
       
 14630                         var Longitude = p.x;
       
 14631                         var Latitude = p.y;
       
 14632                         var Height = p.z ? p.z : 0;
       
 14633                         var X;
       
 14634                         var Y;
       
 14635                         var Z;
       
 14636                         var Error_Code = 0;
       
 14637                         var Rn;
       
 14638                         var Sin_Lat;
       
 14639                         var Sin2_Lat;
       
 14640                         var Cos_Lat;
       
 14641                         if (Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI) {
       
 14642                             Latitude = -HALF_PI;
       
 14643                         } else if (Latitude > HALF_PI && Latitude < 1.001 * HALF_PI) {
       
 14644                             Latitude = HALF_PI;
       
 14645                         } else if (Latitude < -HALF_PI || Latitude > HALF_PI) {
       
 14646                             return null;
       
 14647                         }
       
 14648                         if (Longitude > Math.PI) {
       
 14649                             Longitude -= 2 * Math.PI;
       
 14650                         }
       
 14651                         Sin_Lat = Math.sin(Latitude);
       
 14652                         Cos_Lat = Math.cos(Latitude);
       
 14653                         Sin2_Lat = Sin_Lat * Sin_Lat;
       
 14654                         Rn = this.a / Math.sqrt(1 - this.es * Sin2_Lat);
       
 14655                         X = (Rn + Height) * Cos_Lat * Math.cos(Longitude);
       
 14656                         Y = (Rn + Height) * Cos_Lat * Math.sin(Longitude);
       
 14657                         Z = (Rn * (1 - this.es) + Height) * Sin_Lat;
       
 14658                         p.x = X;
       
 14659                         p.y = Y;
       
 14660                         p.z = Z;
       
 14661                         return Error_Code;
       
 14662                     },
       
 14663                     geocentric_to_geodetic: function (p) {
       
 14664                         var genau = 1e-12;
       
 14665                         var genau2 = genau * genau;
       
 14666                         var maxiter = 30;
       
 14667                         var P;
       
 14668                         var RR;
       
 14669                         var CT;
       
 14670                         var ST;
       
 14671                         var RX;
       
 14672                         var RK;
       
 14673                         var RN;
       
 14674                         var CPHI0;
       
 14675                         var SPHI0;
       
 14676                         var CPHI;
       
 14677                         var SPHI;
       
 14678                         var SDPHI;
       
 14679                         var At_Pole;
       
 14680                         var iter;
       
 14681                         var X = p.x;
       
 14682                         var Y = p.y;
       
 14683                         var Z = p.z ? p.z : 0;
       
 14684                         var Longitude;
       
 14685                         var Latitude;
       
 14686                         var Height;
       
 14687                         At_Pole = false;
       
 14688                         P = Math.sqrt(X * X + Y * Y);
       
 14689                         RR = Math.sqrt(X * X + Y * Y + Z * Z);
       
 14690                         if (P / this.a < genau) {
       
 14691                             At_Pole = true;
       
 14692                             Longitude = 0;
       
 14693                             if (RR / this.a < genau) {
       
 14694                                 Latitude = HALF_PI;
       
 14695                                 Height = -this.b;
       
 14696                                 return;
       
 14697                             }
       
 14698                         } else {
       
 14699                             Longitude = Math.atan2(Y, X);
       
 14700                         }
       
 14701                         CT = Z / RR;
       
 14702                         ST = P / RR;
       
 14703                         RX = 1 / Math.sqrt(1 - this.es * (2 - this.es) * ST * ST);
       
 14704                         CPHI0 = ST * (1 - this.es) * RX;
       
 14705                         SPHI0 = CT * RX;
       
 14706                         iter = 0;
       
 14707                         do {
       
 14708                             iter++;
       
 14709                             RN = this.a / Math.sqrt(1 - this.es * SPHI0 * SPHI0);
       
 14710                             Height = P * CPHI0 + Z * SPHI0 - RN * (1 - this.es * SPHI0 * SPHI0);
       
 14711                             RK = this.es * RN / (RN + Height);
       
 14712                             RX = 1 / Math.sqrt(1 - RK * (2 - RK) * ST * ST);
       
 14713                             CPHI = ST * (1 - RK) * RX;
       
 14714                             SPHI = CT * RX;
       
 14715                             SDPHI = SPHI * CPHI0 - CPHI * SPHI0;
       
 14716                             CPHI0 = CPHI;
       
 14717                             SPHI0 = SPHI;
       
 14718                         } while (SDPHI * SDPHI > genau2 && iter < maxiter);
       
 14719                         Latitude = Math.atan(SPHI / Math.abs(CPHI));
       
 14720                         p.x = Longitude;
       
 14721                         p.y = Latitude;
       
 14722                         p.z = Height;
       
 14723                         return p;
       
 14724                     },
       
 14725                     geocentric_to_geodetic_noniter: function (p) {
       
 14726                         var X = p.x;
       
 14727                         var Y = p.y;
       
 14728                         var Z = p.z ? p.z : 0;
       
 14729                         var Longitude;
       
 14730                         var Latitude;
       
 14731                         var Height;
       
 14732                         var W;
       
 14733                         var W2;
       
 14734                         var T0;
       
 14735                         var T1;
       
 14736                         var S0;
       
 14737                         var S1;
       
 14738                         var Sin_B0;
       
 14739                         var Sin3_B0;
       
 14740                         var Cos_B0;
       
 14741                         var Sin_p1;
       
 14742                         var Cos_p1;
       
 14743                         var Rn;
       
 14744                         var Sum;
       
 14745                         var At_Pole;
       
 14746                         X = parseFloat(X);
       
 14747                         Y = parseFloat(Y);
       
 14748                         Z = parseFloat(Z);
       
 14749                         At_Pole = false;
       
 14750                         if (X !== 0) {
       
 14751                             Longitude = Math.atan2(Y, X);
       
 14752                         } else {
       
 14753                             if (Y > 0) {
       
 14754                                 Longitude = HALF_PI;
       
 14755                             } else if (Y < 0) {
       
 14756                                 Longitude = -HALF_PI;
       
 14757                             } else {
       
 14758                                 At_Pole = true;
       
 14759                                 Longitude = 0;
       
 14760                                 if (Z > 0) {
       
 14761                                     Latitude = HALF_PI;
       
 14762                                 } else if (Z < 0) {
       
 14763                                     Latitude = -HALF_PI;
       
 14764                                 } else {
       
 14765                                     Latitude = HALF_PI;
       
 14766                                     Height = -this.b;
       
 14767                                     return;
       
 14768                                 }
       
 14769                             }
       
 14770                         }
       
 14771                         W2 = X * X + Y * Y;
       
 14772                         W = Math.sqrt(W2);
       
 14773                         T0 = Z * AD_C;
       
 14774                         S0 = Math.sqrt(T0 * T0 + W2);
       
 14775                         Sin_B0 = T0 / S0;
       
 14776                         Cos_B0 = W / S0;
       
 14777                         Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
       
 14778                         T1 = Z + this.b * this.ep2 * Sin3_B0;
       
 14779                         Sum = W - this.a * this.es * Cos_B0 * Cos_B0 * Cos_B0;
       
 14780                         S1 = Math.sqrt(T1 * T1 + Sum * Sum);
       
 14781                         Sin_p1 = T1 / S1;
       
 14782                         Cos_p1 = Sum / S1;
       
 14783                         Rn = this.a / Math.sqrt(1 - this.es * Sin_p1 * Sin_p1);
       
 14784                         if (Cos_p1 >= COS_67P5) {
       
 14785                             Height = W / Cos_p1 - Rn;
       
 14786                         } else if (Cos_p1 <= -COS_67P5) {
       
 14787                             Height = W / -Cos_p1 - Rn;
       
 14788                         } else {
       
 14789                             Height = Z / Sin_p1 + Rn * (this.es - 1);
       
 14790                         }
       
 14791                         if (At_Pole === false) {
       
 14792                             Latitude = Math.atan(Sin_p1 / Cos_p1);
       
 14793                         }
       
 14794                         p.x = Longitude;
       
 14795                         p.y = Latitude;
       
 14796                         p.z = Height;
       
 14797                         return p;
       
 14798                     },
       
 14799                     geocentric_to_wgs84: function (p) {
       
 14800                         if (this.datum_type === PJD_3PARAM) {
       
 14801                             p.x += this.datum_params[0];
       
 14802                             p.y += this.datum_params[1];
       
 14803                             p.z += this.datum_params[2];
       
 14804                         } else if (this.datum_type === PJD_7PARAM) {
       
 14805                             var Dx_BF = this.datum_params[0];
       
 14806                             var Dy_BF = this.datum_params[1];
       
 14807                             var Dz_BF = this.datum_params[2];
       
 14808                             var Rx_BF = this.datum_params[3];
       
 14809                             var Ry_BF = this.datum_params[4];
       
 14810                             var Rz_BF = this.datum_params[5];
       
 14811                             var M_BF = this.datum_params[6];
       
 14812                             var x_out = M_BF * (p.x - Rz_BF * p.y + Ry_BF * p.z) + Dx_BF;
       
 14813                             var y_out = M_BF * (Rz_BF * p.x + p.y - Rx_BF * p.z) + Dy_BF;
       
 14814                             var z_out = M_BF * (-Ry_BF * p.x + Rx_BF * p.y + p.z) + Dz_BF;
       
 14815                             p.x = x_out;
       
 14816                             p.y = y_out;
       
 14817                             p.z = z_out;
       
 14818                         }
       
 14819                     },
       
 14820                     geocentric_from_wgs84: function (p) {
       
 14821                         if (this.datum_type === PJD_3PARAM) {
       
 14822                             p.x -= this.datum_params[0];
       
 14823                             p.y -= this.datum_params[1];
       
 14824                             p.z -= this.datum_params[2];
       
 14825                         } else if (this.datum_type === PJD_7PARAM) {
       
 14826                             var Dx_BF = this.datum_params[0];
       
 14827                             var Dy_BF = this.datum_params[1];
       
 14828                             var Dz_BF = this.datum_params[2];
       
 14829                             var Rx_BF = this.datum_params[3];
       
 14830                             var Ry_BF = this.datum_params[4];
       
 14831                             var Rz_BF = this.datum_params[5];
       
 14832                             var M_BF = this.datum_params[6];
       
 14833                             var x_tmp = (p.x - Dx_BF) / M_BF;
       
 14834                             var y_tmp = (p.y - Dy_BF) / M_BF;
       
 14835                             var z_tmp = (p.z - Dz_BF) / M_BF;
       
 14836                             p.x = x_tmp + Rz_BF * y_tmp - Ry_BF * z_tmp;
       
 14837                             p.y = -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp;
       
 14838                             p.z = Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp;
       
 14839                         }
       
 14840                     }
       
 14841                 };
       
 14842                 module.exports = datum;
       
 14843                 return exports;
       
 14844             },
       
 14845             {}
       
 14846         ],
       
 14847         30: [
       
 14848             function (_dereq_, module, exports) {
       
 14849                 var PJD_3PARAM = 1;
       
 14850                 var PJD_7PARAM = 2;
       
 14851                 var PJD_GRIDSHIFT = 3;
       
 14852                 var PJD_NODATUM = 5;
       
 14853                 var SRS_WGS84_SEMIMAJOR = 6378137;
       
 14854                 var SRS_WGS84_ESQUARED = 0.006694379990141316;
       
 14855                 module.exports = function (source, dest, point) {
       
 14856                     var wp, i, l;
       
 14857                     function checkParams(fallback) {
       
 14858                         return fallback === PJD_3PARAM || fallback === PJD_7PARAM;
       
 14859                     }
       
 14860                     if (source.compare_datums(dest)) {
       
 14861                         return point;
       
 14862                     }
       
 14863                     if (source.datum_type === PJD_NODATUM || dest.datum_type === PJD_NODATUM) {
       
 14864                         return point;
       
 14865                     }
       
 14866                     var src_a = source.a;
       
 14867                     var src_es = source.es;
       
 14868                     var dst_a = dest.a;
       
 14869                     var dst_es = dest.es;
       
 14870                     var fallback = source.datum_type;
       
 14871                     if (fallback === PJD_GRIDSHIFT) {
       
 14872                         if (this.apply_gridshift(source, 0, point) === 0) {
       
 14873                             source.a = SRS_WGS84_SEMIMAJOR;
       
 14874                             source.es = SRS_WGS84_ESQUARED;
       
 14875                         } else {
       
 14876                             if (!source.datum_params) {
       
 14877                                 source.a = src_a;
       
 14878                                 source.es = source.es;
       
 14879                                 return point;
       
 14880                             }
       
 14881                             wp = 1;
       
 14882                             for (i = 0, l = source.datum_params.length; i < l; i++) {
       
 14883                                 wp *= source.datum_params[i];
       
 14884                             }
       
 14885                             if (wp === 0) {
       
 14886                                 source.a = src_a;
       
 14887                                 source.es = source.es;
       
 14888                                 return point;
       
 14889                             }
       
 14890                             if (source.datum_params.length > 3) {
       
 14891                                 fallback = PJD_7PARAM;
       
 14892                             } else {
       
 14893                                 fallback = PJD_3PARAM;
       
 14894                             }
       
 14895                         }
       
 14896                     }
       
 14897                     if (dest.datum_type === PJD_GRIDSHIFT) {
       
 14898                         dest.a = SRS_WGS84_SEMIMAJOR;
       
 14899                         dest.es = SRS_WGS84_ESQUARED;
       
 14900                     }
       
 14901                     if (source.es !== dest.es || source.a !== dest.a || checkParams(fallback) || checkParams(dest.datum_type)) {
       
 14902                         source.geodetic_to_geocentric(point);
       
 14903                         if (checkParams(source.datum_type)) {
       
 14904                             source.geocentric_to_wgs84(point);
       
 14905                         }
       
 14906                         if (checkParams(dest.datum_type)) {
       
 14907                             dest.geocentric_from_wgs84(point);
       
 14908                         }
       
 14909                         dest.geocentric_to_geodetic(point);
       
 14910                     }
       
 14911                     if (dest.datum_type === PJD_GRIDSHIFT) {
       
 14912                         this.apply_gridshift(dest, 1, point);
       
 14913                     }
       
 14914                     source.a = src_a;
       
 14915                     source.es = src_es;
       
 14916                     dest.a = dst_a;
       
 14917                     dest.es = dst_es;
       
 14918                     return point;
       
 14919                 };
       
 14920                 return exports;
       
 14921             },
       
 14922             {}
       
 14923         ],
       
 14924         31: [
       
 14925             function (_dereq_, module, exports) {
       
 14926                 var globals = _dereq_('./global');
       
 14927                 var parseProj = _dereq_('./projString');
       
 14928                 var wkt = _dereq_('./wkt');
       
 14929                 function defs(name) {
       
 14930                     var that = this;
       
 14931                     if (arguments.length === 2) {
       
 14932                         var def = arguments[1];
       
 14933                         if (typeof def === 'string') {
       
 14934                             if (def[0] === '+') {
       
 14935                                 defs[name] = parseProj(arguments[1]);
       
 14936                             } else {
       
 14937                                 defs[name] = wkt(arguments[1]);
       
 14938                             }
       
 14939                         } else {
       
 14940                             defs[name] = def;
       
 14941                         }
       
 14942                     } else if (arguments.length === 1) {
       
 14943                         if (Array.isArray(name)) {
       
 14944                             return name.map(function (v) {
       
 14945                                 if (Array.isArray(v)) {
       
 14946                                     defs.apply(that, v);
       
 14947                                 } else {
       
 14948                                     defs(v);
       
 14949                                 }
       
 14950                             });
       
 14951                         } else if (typeof name === 'string') {
       
 14952                             if (name in defs) {
       
 14953                                 return defs[name];
       
 14954                             }
       
 14955                         } else if ('EPSG' in name) {
       
 14956                             defs['EPSG:' + name.EPSG] = name;
       
 14957                         } else if ('ESRI' in name) {
       
 14958                             defs['ESRI:' + name.ESRI] = name;
       
 14959                         } else if ('IAU2000' in name) {
       
 14960                             defs['IAU2000:' + name.IAU2000] = name;
       
 14961                         } else {
       
 14962                             console.log(name);
       
 14963                         }
       
 14964                         return;
       
 14965                     }
       
 14966                 }
       
 14967                 globals(defs);
       
 14968                 module.exports = defs;
       
 14969                 return exports;
       
 14970             },
       
 14971             {
       
 14972                 './global': 34,
       
 14973                 './projString': 37,
       
 14974                 './wkt': 65
       
 14975             }
       
 14976         ],
       
 14977         32: [
       
 14978             function (_dereq_, module, exports) {
       
 14979                 var Datum = _dereq_('./constants/Datum');
       
 14980                 var Ellipsoid = _dereq_('./constants/Ellipsoid');
       
 14981                 var extend = _dereq_('./extend');
       
 14982                 var datum = _dereq_('./datum');
       
 14983                 var EPSLN = 1e-10;
       
 14984                 var SIXTH = 0.16666666666666666;
       
 14985                 var RA4 = 0.04722222222222222;
       
 14986                 var RA6 = 0.022156084656084655;
       
 14987                 module.exports = function (json) {
       
 14988                     if (json.datumCode && json.datumCode !== 'none') {
       
 14989                         var datumDef = Datum[json.datumCode];
       
 14990                         if (datumDef) {
       
 14991                             json.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null;
       
 14992                             json.ellps = datumDef.ellipse;
       
 14993                             json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode;
       
 14994                         }
       
 14995                     }
       
 14996                     if (!json.a) {
       
 14997                         var ellipse = Ellipsoid[json.ellps] ? Ellipsoid[json.ellps] : Ellipsoid.WGS84;
       
 14998                         extend(json, ellipse);
       
 14999                     }
       
 15000                     if (json.rf && !json.b) {
       
 15001                         json.b = (1 - 1 / json.rf) * json.a;
       
 15002                     }
       
 15003                     if (json.rf === 0 || Math.abs(json.a - json.b) < EPSLN) {
       
 15004                         json.sphere = true;
       
 15005                         json.b = json.a;
       
 15006                     }
       
 15007                     json.a2 = json.a * json.a;
       
 15008                     json.b2 = json.b * json.b;
       
 15009                     json.es = (json.a2 - json.b2) / json.a2;
       
 15010                     json.e = Math.sqrt(json.es);
       
 15011                     if (json.R_A) {
       
 15012                         json.a *= 1 - json.es * (SIXTH + json.es * (RA4 + json.es * RA6));
       
 15013                         json.a2 = json.a * json.a;
       
 15014                         json.b2 = json.b * json.b;
       
 15015                         json.es = 0;
       
 15016                     }
       
 15017                     json.ep2 = (json.a2 - json.b2) / json.b2;
       
 15018                     if (!json.k0) {
       
 15019                         json.k0 = 1;
       
 15020                     }
       
 15021                     if (!json.axis) {
       
 15022                         json.axis = 'enu';
       
 15023                     }
       
 15024                     json.datum = datum(json);
       
 15025                     return json;
       
 15026                 };
       
 15027                 return exports;
       
 15028             },
       
 15029             {
       
 15030                 './constants/Datum': 25,
       
 15031                 './constants/Ellipsoid': 26,
       
 15032                 './datum': 29,
       
 15033                 './extend': 33
       
 15034             }
       
 15035         ],
       
 15036         33: [
       
 15037             function (_dereq_, module, exports) {
       
 15038                 module.exports = function (destination, source) {
       
 15039                     destination = destination || {};
       
 15040                     var value, property;
       
 15041                     if (!source) {
       
 15042                         return destination;
       
 15043                     }
       
 15044                     for (property in source) {
       
 15045                         value = source[property];
       
 15046                         if (value !== undefined) {
       
 15047                             destination[property] = value;
       
 15048                         }
       
 15049                     }
       
 15050                     return destination;
       
 15051                 };
       
 15052                 return exports;
       
 15053             },
       
 15054             {}
       
 15055         ],
       
 15056         34: [
       
 15057             function (_dereq_, module, exports) {
       
 15058                 module.exports = function (defs) {
       
 15059                     defs('EPSG:4326', '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees');
       
 15060                     defs('EPSG:4269', '+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees');
       
 15061                     defs('EPSG:3857', '+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');
       
 15062                     defs.WGS84 = defs['EPSG:4326'];
       
 15063                     defs['EPSG:3785'] = defs['EPSG:3857'];
       
 15064                     defs.GOOGLE = defs['EPSG:3857'];
       
 15065                     defs['EPSG:900913'] = defs['EPSG:3857'];
       
 15066                     defs['EPSG:102113'] = defs['EPSG:3857'];
       
 15067                 };
       
 15068                 return exports;
       
 15069             },
       
 15070             {}
       
 15071         ],
       
 15072         35: [
       
 15073             function (_dereq_, module, exports) {
       
 15074                 var proj4 = _dereq_('./core');
       
 15075                 proj4.defaultDatum = 'WGS84';
       
 15076                 proj4.Proj = _dereq_('./Proj');
       
 15077                 proj4.WGS84 = new proj4.Proj('WGS84');
       
 15078                 proj4.Point = _dereq_('./Point');
       
 15079                 proj4.toPoint = _dereq_('./common/toPoint');
       
 15080                 proj4.defs = _dereq_('./defs');
       
 15081                 proj4.transform = _dereq_('./transform');
       
 15082                 proj4.mgrs = _dereq_('mgrs');
       
 15083                 proj4.version = _dereq_('../package.json').version;
       
 15084                 _dereq_('./includedProjections')(proj4);
       
 15085                 module.exports = proj4;
       
 15086                 return exports;
       
 15087             },
       
 15088             {
       
 15089                 '../package.json': 67,
       
 15090                 './Point': 1,
       
 15091                 './Proj': 2,
       
 15092                 './common/toPoint': 23,
       
 15093                 './core': 28,
       
 15094                 './defs': 31,
       
 15095                 './includedProjections': 'gWUPNW',
       
 15096                 './transform': 64,
       
 15097                 'mgrs': 66
       
 15098             }
       
 15099         ],
       
 15100         36: [
       
 15101             function (_dereq_, module, exports) {
       
 15102                 var defs = _dereq_('./defs');
       
 15103                 var wkt = _dereq_('./wkt');
       
 15104                 var projStr = _dereq_('./projString');
       
 15105                 function testObj(code) {
       
 15106                     return typeof code === 'string';
       
 15107                 }
       
 15108                 function testDef(code) {
       
 15109                     return code in defs;
       
 15110                 }
       
 15111                 function testWKT(code) {
       
 15112                     var codeWords = [
       
 15113                         'GEOGCS',
       
 15114                         'GEOCCS',
       
 15115                         'PROJCS',
       
 15116                         'LOCAL_CS'
       
 15117                     ];
       
 15118                     return codeWords.reduce(function (a, b) {
       
 15119                         return a + 1 + code.indexOf(b);
       
 15120                     }, 0);
       
 15121                 }
       
 15122                 function testProj(code) {
       
 15123                     return code[0] === '+';
       
 15124                 }
       
 15125                 function parse(code) {
       
 15126                     if (testObj(code)) {
       
 15127                         if (testDef(code)) {
       
 15128                             return defs[code];
       
 15129                         } else if (testWKT(code)) {
       
 15130                             return wkt(code);
       
 15131                         } else if (testProj(code)) {
       
 15132                             return projStr(code);
       
 15133                         }
       
 15134                     } else {
       
 15135                         return code;
       
 15136                     }
       
 15137                 }
       
 15138                 module.exports = parse;
       
 15139                 return exports;
       
 15140             },
       
 15141             {
       
 15142                 './defs': 31,
       
 15143                 './projString': 37,
       
 15144                 './wkt': 65
       
 15145             }
       
 15146         ],
       
 15147         37: [
       
 15148             function (_dereq_, module, exports) {
       
 15149                 var D2R = 0.017453292519943295;
       
 15150                 var PrimeMeridian = _dereq_('./constants/PrimeMeridian');
       
 15151                 module.exports = function (defData) {
       
 15152                     var self = {};
       
 15153                     var paramObj = {};
       
 15154                     defData.split('+').map(function (v) {
       
 15155                         return v.trim();
       
 15156                     }).filter(function (a) {
       
 15157                         return a;
       
 15158                     }).forEach(function (a) {
       
 15159                         var split = a.split('=');
       
 15160                         split.push(true);
       
 15161                         paramObj[split[0].toLowerCase()] = split[1];
       
 15162                     });
       
 15163                     var paramName, paramVal, paramOutname;
       
 15164                     var params = {
       
 15165                         proj: 'projName',
       
 15166                         datum: 'datumCode',
       
 15167                         rf: function (v) {
       
 15168                             self.rf = parseFloat(v, 10);
       
 15169                         },
       
 15170                         lat_0: function (v) {
       
 15171                             self.lat0 = v * D2R;
       
 15172                         },
       
 15173                         lat_1: function (v) {
       
 15174                             self.lat1 = v * D2R;
       
 15175                         },
       
 15176                         lat_2: function (v) {
       
 15177                             self.lat2 = v * D2R;
       
 15178                         },
       
 15179                         lat_ts: function (v) {
       
 15180                             self.lat_ts = v * D2R;
       
 15181                         },
       
 15182                         lon_0: function (v) {
       
 15183                             self.long0 = v * D2R;
       
 15184                         },
       
 15185                         lon_1: function (v) {
       
 15186                             self.long1 = v * D2R;
       
 15187                         },
       
 15188                         lon_2: function (v) {
       
 15189                             self.long2 = v * D2R;
       
 15190                         },
       
 15191                         alpha: function (v) {
       
 15192                             self.alpha = parseFloat(v) * D2R;
       
 15193                         },
       
 15194                         lonc: function (v) {
       
 15195                             self.longc = v * D2R;
       
 15196                         },
       
 15197                         x_0: function (v) {
       
 15198                             self.x0 = parseFloat(v, 10);
       
 15199                         },
       
 15200                         y_0: function (v) {
       
 15201                             self.y0 = parseFloat(v, 10);
       
 15202                         },
       
 15203                         k_0: function (v) {
       
 15204                             self.k0 = parseFloat(v, 10);
       
 15205                         },
       
 15206                         k: function (v) {
       
 15207                             self.k0 = parseFloat(v, 10);
       
 15208                         },
       
 15209                         r_a: function () {
       
 15210                             self.R_A = true;
       
 15211                         },
       
 15212                         zone: function (v) {
       
 15213                             self.zone = parseInt(v, 10);
       
 15214                         },
       
 15215                         south: function () {
       
 15216                             self.utmSouth = true;
       
 15217                         },
       
 15218                         towgs84: function (v) {
       
 15219                             self.datum_params = v.split(',').map(function (a) {
       
 15220                                 return parseFloat(a, 10);
       
 15221                             });
       
 15222                         },
       
 15223                         to_meter: function (v) {
       
 15224                             self.to_meter = parseFloat(v, 10);
       
 15225                         },
       
 15226                         from_greenwich: function (v) {
       
 15227                             self.from_greenwich = v * D2R;
       
 15228                         },
       
 15229                         pm: function (v) {
       
 15230                             self.from_greenwich = (PrimeMeridian[v] ? PrimeMeridian[v] : parseFloat(v, 10)) * D2R;
       
 15231                         },
       
 15232                         nadgrids: function (v) {
       
 15233                             if (v === '@null') {
       
 15234                                 self.datumCode = 'none';
       
 15235                             } else {
       
 15236                                 self.nadgrids = v;
       
 15237                             }
       
 15238                         },
       
 15239                         axis: function (v) {
       
 15240                             var legalAxis = 'ewnsud';
       
 15241                             if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) {
       
 15242                                 self.axis = v;
       
 15243                             }
       
 15244                         }
       
 15245                     };
       
 15246                     for (paramName in paramObj) {
       
 15247                         paramVal = paramObj[paramName];
       
 15248                         if (paramName in params) {
       
 15249                             paramOutname = params[paramName];
       
 15250                             if (typeof paramOutname === 'function') {
       
 15251                                 paramOutname(paramVal);
       
 15252                             } else {
       
 15253                                 self[paramOutname] = paramVal;
       
 15254                             }
       
 15255                         } else {
       
 15256                             self[paramName] = paramVal;
       
 15257                         }
       
 15258                     }
       
 15259                     if (typeof self.datumCode === 'string' && self.datumCode !== 'WGS84') {
       
 15260                         self.datumCode = self.datumCode.toLowerCase();
       
 15261                     }
       
 15262                     return self;
       
 15263                 };
       
 15264                 return exports;
       
 15265             },
       
 15266             { './constants/PrimeMeridian': 27 }
       
 15267         ],
       
 15268         38: [
       
 15269             function (_dereq_, module, exports) {
       
 15270                 var projs = [
       
 15271                     _dereq_('./projections/merc'),
       
 15272                     _dereq_('./projections/longlat')
       
 15273                 ];
       
 15274                 var names = {};
       
 15275                 var projStore = [];
       
 15276                 function add(proj, i) {
       
 15277                     var len = projStore.length;
       
 15278                     if (!proj.names) {
       
 15279                         console.log(i);
       
 15280                         return true;
       
 15281                     }
       
 15282                     projStore[len] = proj;
       
 15283                     proj.names.forEach(function (n) {
       
 15284                         names[n.toLowerCase()] = len;
       
 15285                     });
       
 15286                     return this;
       
 15287                 }
       
 15288                 exports.add = add;
       
 15289                 exports.get = function (name) {
       
 15290                     if (!name) {
       
 15291                         return false;
       
 15292                     }
       
 15293                     var n = name.toLowerCase();
       
 15294                     if (typeof names[n] !== 'undefined' && projStore[names[n]]) {
       
 15295                         return projStore[names[n]];
       
 15296                     }
       
 15297                 };
       
 15298                 exports.start = function () {
       
 15299                     projs.forEach(add);
       
 15300                 };
       
 15301                 return exports;
       
 15302             },
       
 15303             {
       
 15304                 './projections/longlat': 50,
       
 15305                 './projections/merc': 51
       
 15306             }
       
 15307         ],
       
 15308         39: [
       
 15309             function (_dereq_, module, exports) {
       
 15310                 var EPSLN = 1e-10;
       
 15311                 var msfnz = _dereq_('../common/msfnz');
       
 15312                 var qsfnz = _dereq_('../common/qsfnz');
       
 15313                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15314                 var asinz = _dereq_('../common/asinz');
       
 15315                 exports.init = function () {
       
 15316                     if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
       
 15317                         return;
       
 15318                     }
       
 15319                     this.temp = this.b / this.a;
       
 15320                     this.es = 1 - Math.pow(this.temp, 2);
       
 15321                     this.e3 = Math.sqrt(this.es);
       
 15322                     this.sin_po = Math.sin(this.lat1);
       
 15323                     this.cos_po = Math.cos(this.lat1);
       
 15324                     this.t1 = this.sin_po;
       
 15325                     this.con = this.sin_po;
       
 15326                     this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);
       
 15327                     this.qs1 = qsfnz(this.e3, this.sin_po, this.cos_po);
       
 15328                     this.sin_po = Math.sin(this.lat2);
       
 15329                     this.cos_po = Math.cos(this.lat2);
       
 15330                     this.t2 = this.sin_po;
       
 15331                     this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);
       
 15332                     this.qs2 = qsfnz(this.e3, this.sin_po, this.cos_po);
       
 15333                     this.sin_po = Math.sin(this.lat0);
       
 15334                     this.cos_po = Math.cos(this.lat0);
       
 15335                     this.t3 = this.sin_po;
       
 15336                     this.qs0 = qsfnz(this.e3, this.sin_po, this.cos_po);
       
 15337                     if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
       
 15338                         this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);
       
 15339                     } else {
       
 15340                         this.ns0 = this.con;
       
 15341                     }
       
 15342                     this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
       
 15343                     this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0;
       
 15344                 };
       
 15345                 exports.forward = function (p) {
       
 15346                     var lon = p.x;
       
 15347                     var lat = p.y;
       
 15348                     this.sin_phi = Math.sin(lat);
       
 15349                     this.cos_phi = Math.cos(lat);
       
 15350                     var qs = qsfnz(this.e3, this.sin_phi, this.cos_phi);
       
 15351                     var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;
       
 15352                     var theta = this.ns0 * adjust_lon(lon - this.long0);
       
 15353                     var x = rh1 * Math.sin(theta) + this.x0;
       
 15354                     var y = this.rh - rh1 * Math.cos(theta) + this.y0;
       
 15355                     p.x = x;
       
 15356                     p.y = y;
       
 15357                     return p;
       
 15358                 };
       
 15359                 exports.inverse = function (p) {
       
 15360                     var rh1, qs, con, theta, lon, lat;
       
 15361                     p.x -= this.x0;
       
 15362                     p.y = this.rh - p.y + this.y0;
       
 15363                     if (this.ns0 >= 0) {
       
 15364                         rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15365                         con = 1;
       
 15366                     } else {
       
 15367                         rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
       
 15368                         con = -1;
       
 15369                     }
       
 15370                     theta = 0;
       
 15371                     if (rh1 !== 0) {
       
 15372                         theta = Math.atan2(con * p.x, con * p.y);
       
 15373                     }
       
 15374                     con = rh1 * this.ns0 / this.a;
       
 15375                     if (this.sphere) {
       
 15376                         lat = Math.asin((this.c - con * con) / (2 * this.ns0));
       
 15377                     } else {
       
 15378                         qs = (this.c - con * con) / this.ns0;
       
 15379                         lat = this.phi1z(this.e3, qs);
       
 15380                     }
       
 15381                     lon = adjust_lon(theta / this.ns0 + this.long0);
       
 15382                     p.x = lon;
       
 15383                     p.y = lat;
       
 15384                     return p;
       
 15385                 };
       
 15386                 exports.phi1z = function (eccent, qs) {
       
 15387                     var sinphi, cosphi, con, com, dphi;
       
 15388                     var phi = asinz(0.5 * qs);
       
 15389                     if (eccent < EPSLN) {
       
 15390                         return phi;
       
 15391                     }
       
 15392                     var eccnts = eccent * eccent;
       
 15393                     for (var i = 1; i <= 25; i++) {
       
 15394                         sinphi = Math.sin(phi);
       
 15395                         cosphi = Math.cos(phi);
       
 15396                         con = eccent * sinphi;
       
 15397                         com = 1 - con * con;
       
 15398                         dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
       
 15399                         phi = phi + dphi;
       
 15400                         if (Math.abs(dphi) <= 1e-7) {
       
 15401                             return phi;
       
 15402                         }
       
 15403                     }
       
 15404                     return null;
       
 15405                 };
       
 15406                 exports.names = [
       
 15407                     'Albers_Conic_Equal_Area',
       
 15408                     'Albers',
       
 15409                     'aea'
       
 15410                 ];
       
 15411                 return exports;
       
 15412             },
       
 15413             {
       
 15414                 '../common/adjust_lon': 5,
       
 15415                 '../common/asinz': 6,
       
 15416                 '../common/msfnz': 15,
       
 15417                 '../common/qsfnz': 20
       
 15418             }
       
 15419         ],
       
 15420         40: [
       
 15421             function (_dereq_, module, exports) {
       
 15422                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15423                 var HALF_PI = Math.PI / 2;
       
 15424                 var EPSLN = 1e-10;
       
 15425                 var mlfn = _dereq_('../common/mlfn');
       
 15426                 var e0fn = _dereq_('../common/e0fn');
       
 15427                 var e1fn = _dereq_('../common/e1fn');
       
 15428                 var e2fn = _dereq_('../common/e2fn');
       
 15429                 var e3fn = _dereq_('../common/e3fn');
       
 15430                 var gN = _dereq_('../common/gN');
       
 15431                 var asinz = _dereq_('../common/asinz');
       
 15432                 var imlfn = _dereq_('../common/imlfn');
       
 15433                 exports.init = function () {
       
 15434                     this.sin_p12 = Math.sin(this.lat0);
       
 15435                     this.cos_p12 = Math.cos(this.lat0);
       
 15436                 };
       
 15437                 exports.forward = function (p) {
       
 15438                     var lon = p.x;
       
 15439                     var lat = p.y;
       
 15440                     var sinphi = Math.sin(p.y);
       
 15441                     var cosphi = Math.cos(p.y);
       
 15442                     var dlon = adjust_lon(lon - this.long0);
       
 15443                     var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5;
       
 15444                     if (this.sphere) {
       
 15445                         if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
       
 15446                             p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);
       
 15447                             p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);
       
 15448                             return p;
       
 15449                         } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
       
 15450                             p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);
       
 15451                             p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);
       
 15452                             return p;
       
 15453                         } else {
       
 15454                             cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);
       
 15455                             c = Math.acos(cos_c);
       
 15456                             kp = c / Math.sin(c);
       
 15457                             p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon);
       
 15458                             p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));
       
 15459                             return p;
       
 15460                         }
       
 15461                     } else {
       
 15462                         e0 = e0fn(this.es);
       
 15463                         e1 = e1fn(this.es);
       
 15464                         e2 = e2fn(this.es);
       
 15465                         e3 = e3fn(this.es);
       
 15466                         if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
       
 15467                             Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
       
 15468                             Ml = this.a * mlfn(e0, e1, e2, e3, lat);
       
 15469                             p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);
       
 15470                             p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);
       
 15471                             return p;
       
 15472                         } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
       
 15473                             Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
       
 15474                             Ml = this.a * mlfn(e0, e1, e2, e3, lat);
       
 15475                             p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);
       
 15476                             p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);
       
 15477                             return p;
       
 15478                         } else {
       
 15479                             tanphi = sinphi / cosphi;
       
 15480                             Nl1 = gN(this.a, this.e, this.sin_p12);
       
 15481                             Nl = gN(this.a, this.e, sinphi);
       
 15482                             psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));
       
 15483                             Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));
       
 15484                             if (Az === 0) {
       
 15485                                 s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
       
 15486                             } else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {
       
 15487                                 s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
       
 15488                             } else {
       
 15489                                 s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));
       
 15490                             }
       
 15491                             G = this.e * this.sin_p12 / Math.sqrt(1 - this.es);
       
 15492                             H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es);
       
 15493                             GH = G * H;
       
 15494                             Hs = H * H;
       
 15495                             s2 = s * s;
       
 15496                             s3 = s2 * s;
       
 15497                             s4 = s3 * s;
       
 15498                             s5 = s4 * s;
       
 15499                             c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH);
       
 15500                             p.x = this.x0 + c * Math.sin(Az);
       
 15501                             p.y = this.y0 + c * Math.cos(Az);
       
 15502                             return p;
       
 15503                         }
       
 15504                     }
       
 15505                 };
       
 15506                 exports.inverse = function (p) {
       
 15507                     p.x -= this.x0;
       
 15508                     p.y -= this.y0;
       
 15509                     var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A, B, D, Ee, F;
       
 15510                     if (this.sphere) {
       
 15511                         rh = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15512                         if (rh > 2 * HALF_PI * this.a) {
       
 15513                             return;
       
 15514                         }
       
 15515                         z = rh / this.a;
       
 15516                         sinz = Math.sin(z);
       
 15517                         cosz = Math.cos(z);
       
 15518                         lon = this.long0;
       
 15519                         if (Math.abs(rh) <= EPSLN) {
       
 15520                             lat = this.lat0;
       
 15521                         } else {
       
 15522                             lat = asinz(cosz * this.sin_p12 + p.y * sinz * this.cos_p12 / rh);
       
 15523                             con = Math.abs(this.lat0) - HALF_PI;
       
 15524                             if (Math.abs(con) <= EPSLN) {
       
 15525                                 if (this.lat0 >= 0) {
       
 15526                                     lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y));
       
 15527                                 } else {
       
 15528                                     lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
       
 15529                                 }
       
 15530                             } else {
       
 15531                                 lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
       
 15532                             }
       
 15533                         }
       
 15534                         p.x = lon;
       
 15535                         p.y = lat;
       
 15536                         return p;
       
 15537                     } else {
       
 15538                         e0 = e0fn(this.es);
       
 15539                         e1 = e1fn(this.es);
       
 15540                         e2 = e2fn(this.es);
       
 15541                         e3 = e3fn(this.es);
       
 15542                         if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
       
 15543                             Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
       
 15544                             rh = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15545                             M = Mlp - rh;
       
 15546                             lat = imlfn(M / this.a, e0, e1, e2, e3);
       
 15547                             lon = adjust_lon(this.long0 + Math.atan2(p.x, -1 * p.y));
       
 15548                             p.x = lon;
       
 15549                             p.y = lat;
       
 15550                             return p;
       
 15551                         } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
       
 15552                             Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
       
 15553                             rh = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15554                             M = rh - Mlp;
       
 15555                             lat = imlfn(M / this.a, e0, e1, e2, e3);
       
 15556                             lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
       
 15557                             p.x = lon;
       
 15558                             p.y = lat;
       
 15559                             return p;
       
 15560                         } else {
       
 15561                             rh = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15562                             Az = Math.atan2(p.x, p.y);
       
 15563                             N1 = gN(this.a, this.e, this.sin_p12);
       
 15564                             cosAz = Math.cos(Az);
       
 15565                             tmp = this.e * this.cos_p12 * cosAz;
       
 15566                             A = -tmp * tmp / (1 - this.es);
       
 15567                             B = 3 * this.es * (1 - A) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es);
       
 15568                             D = rh / N1;
       
 15569                             Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;
       
 15570                             F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;
       
 15571                             psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);
       
 15572                             lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));
       
 15573                             lat = Math.atan((1 - this.es * F * this.sin_p12 / Math.sin(psi)) * Math.tan(psi) / (1 - this.es));
       
 15574                             p.x = lon;
       
 15575                             p.y = lat;
       
 15576                             return p;
       
 15577                         }
       
 15578                     }
       
 15579                 };
       
 15580                 exports.names = [
       
 15581                     'Azimuthal_Equidistant',
       
 15582                     'aeqd'
       
 15583                 ];
       
 15584                 return exports;
       
 15585             },
       
 15586             {
       
 15587                 '../common/adjust_lon': 5,
       
 15588                 '../common/asinz': 6,
       
 15589                 '../common/e0fn': 7,
       
 15590                 '../common/e1fn': 8,
       
 15591                 '../common/e2fn': 9,
       
 15592                 '../common/e3fn': 10,
       
 15593                 '../common/gN': 11,
       
 15594                 '../common/imlfn': 12,
       
 15595                 '../common/mlfn': 14
       
 15596             }
       
 15597         ],
       
 15598         41: [
       
 15599             function (_dereq_, module, exports) {
       
 15600                 var mlfn = _dereq_('../common/mlfn');
       
 15601                 var e0fn = _dereq_('../common/e0fn');
       
 15602                 var e1fn = _dereq_('../common/e1fn');
       
 15603                 var e2fn = _dereq_('../common/e2fn');
       
 15604                 var e3fn = _dereq_('../common/e3fn');
       
 15605                 var gN = _dereq_('../common/gN');
       
 15606                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15607                 var adjust_lat = _dereq_('../common/adjust_lat');
       
 15608                 var imlfn = _dereq_('../common/imlfn');
       
 15609                 var HALF_PI = Math.PI / 2;
       
 15610                 var EPSLN = 1e-10;
       
 15611                 exports.init = function () {
       
 15612                     if (!this.sphere) {
       
 15613                         this.e0 = e0fn(this.es);
       
 15614                         this.e1 = e1fn(this.es);
       
 15615                         this.e2 = e2fn(this.es);
       
 15616                         this.e3 = e3fn(this.es);
       
 15617                         this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
       
 15618                     }
       
 15619                 };
       
 15620                 exports.forward = function (p) {
       
 15621                     var x, y;
       
 15622                     var lam = p.x;
       
 15623                     var phi = p.y;
       
 15624                     lam = adjust_lon(lam - this.long0);
       
 15625                     if (this.sphere) {
       
 15626                         x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
       
 15627                         y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
       
 15628                     } else {
       
 15629                         var sinphi = Math.sin(phi);
       
 15630                         var cosphi = Math.cos(phi);
       
 15631                         var nl = gN(this.a, this.e, sinphi);
       
 15632                         var tl = Math.tan(phi) * Math.tan(phi);
       
 15633                         var al = lam * Math.cos(phi);
       
 15634                         var asq = al * al;
       
 15635                         var cl = this.es * cosphi * cosphi / (1 - this.es);
       
 15636                         var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
       
 15637                         x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
       
 15638                         y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);
       
 15639                     }
       
 15640                     p.x = x + this.x0;
       
 15641                     p.y = y + this.y0;
       
 15642                     return p;
       
 15643                 };
       
 15644                 exports.inverse = function (p) {
       
 15645                     p.x -= this.x0;
       
 15646                     p.y -= this.y0;
       
 15647                     var x = p.x / this.a;
       
 15648                     var y = p.y / this.a;
       
 15649                     var phi, lam;
       
 15650                     if (this.sphere) {
       
 15651                         var dd = y + this.lat0;
       
 15652                         phi = Math.asin(Math.sin(dd) * Math.cos(x));
       
 15653                         lam = Math.atan2(Math.tan(x), Math.cos(dd));
       
 15654                     } else {
       
 15655                         var ml1 = this.ml0 / this.a + y;
       
 15656                         var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);
       
 15657                         if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) {
       
 15658                             p.x = this.long0;
       
 15659                             p.y = HALF_PI;
       
 15660                             if (y < 0) {
       
 15661                                 p.y *= -1;
       
 15662                             }
       
 15663                             return p;
       
 15664                         }
       
 15665                         var nl1 = gN(this.a, this.e, Math.sin(phi1));
       
 15666                         var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es);
       
 15667                         var tl1 = Math.pow(Math.tan(phi1), 2);
       
 15668                         var dl = x * this.a / nl1;
       
 15669                         var dsq = dl * dl;
       
 15670                         phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);
       
 15671                         lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);
       
 15672                     }
       
 15673                     p.x = adjust_lon(lam + this.long0);
       
 15674                     p.y = adjust_lat(phi);
       
 15675                     return p;
       
 15676                 };
       
 15677                 exports.names = [
       
 15678                     'Cassini',
       
 15679                     'Cassini_Soldner',
       
 15680                     'cass'
       
 15681                 ];
       
 15682                 return exports;
       
 15683             },
       
 15684             {
       
 15685                 '../common/adjust_lat': 4,
       
 15686                 '../common/adjust_lon': 5,
       
 15687                 '../common/e0fn': 7,
       
 15688                 '../common/e1fn': 8,
       
 15689                 '../common/e2fn': 9,
       
 15690                 '../common/e3fn': 10,
       
 15691                 '../common/gN': 11,
       
 15692                 '../common/imlfn': 12,
       
 15693                 '../common/mlfn': 14
       
 15694             }
       
 15695         ],
       
 15696         42: [
       
 15697             function (_dereq_, module, exports) {
       
 15698                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15699                 var qsfnz = _dereq_('../common/qsfnz');
       
 15700                 var msfnz = _dereq_('../common/msfnz');
       
 15701                 var iqsfnz = _dereq_('../common/iqsfnz');
       
 15702                 exports.init = function () {
       
 15703                     if (!this.sphere) {
       
 15704                         this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
       
 15705                     }
       
 15706                 };
       
 15707                 exports.forward = function (p) {
       
 15708                     var lon = p.x;
       
 15709                     var lat = p.y;
       
 15710                     var x, y;
       
 15711                     var dlon = adjust_lon(lon - this.long0);
       
 15712                     if (this.sphere) {
       
 15713                         x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
       
 15714                         y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
       
 15715                     } else {
       
 15716                         var qs = qsfnz(this.e, Math.sin(lat));
       
 15717                         x = this.x0 + this.a * this.k0 * dlon;
       
 15718                         y = this.y0 + this.a * qs * 0.5 / this.k0;
       
 15719                     }
       
 15720                     p.x = x;
       
 15721                     p.y = y;
       
 15722                     return p;
       
 15723                 };
       
 15724                 exports.inverse = function (p) {
       
 15725                     p.x -= this.x0;
       
 15726                     p.y -= this.y0;
       
 15727                     var lon, lat;
       
 15728                     if (this.sphere) {
       
 15729                         lon = adjust_lon(this.long0 + p.x / this.a / Math.cos(this.lat_ts));
       
 15730                         lat = Math.asin(p.y / this.a * Math.cos(this.lat_ts));
       
 15731                     } else {
       
 15732                         lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
       
 15733                         lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
       
 15734                     }
       
 15735                     p.x = lon;
       
 15736                     p.y = lat;
       
 15737                     return p;
       
 15738                 };
       
 15739                 exports.names = ['cea'];
       
 15740                 return exports;
       
 15741             },
       
 15742             {
       
 15743                 '../common/adjust_lon': 5,
       
 15744                 '../common/iqsfnz': 13,
       
 15745                 '../common/msfnz': 15,
       
 15746                 '../common/qsfnz': 20
       
 15747             }
       
 15748         ],
       
 15749         43: [
       
 15750             function (_dereq_, module, exports) {
       
 15751                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15752                 var adjust_lat = _dereq_('../common/adjust_lat');
       
 15753                 exports.init = function () {
       
 15754                     this.x0 = this.x0 || 0;
       
 15755                     this.y0 = this.y0 || 0;
       
 15756                     this.lat0 = this.lat0 || 0;
       
 15757                     this.long0 = this.long0 || 0;
       
 15758                     this.lat_ts = this.lat_ts || 0;
       
 15759                     this.title = this.title || 'Equidistant Cylindrical (Plate Carre)';
       
 15760                     this.rc = Math.cos(this.lat_ts);
       
 15761                 };
       
 15762                 exports.forward = function (p) {
       
 15763                     var lon = p.x;
       
 15764                     var lat = p.y;
       
 15765                     var dlon = adjust_lon(lon - this.long0);
       
 15766                     var dlat = adjust_lat(lat - this.lat0);
       
 15767                     p.x = this.x0 + this.a * dlon * this.rc;
       
 15768                     p.y = this.y0 + this.a * dlat;
       
 15769                     return p;
       
 15770                 };
       
 15771                 exports.inverse = function (p) {
       
 15772                     var x = p.x;
       
 15773                     var y = p.y;
       
 15774                     p.x = adjust_lon(this.long0 + (x - this.x0) / (this.a * this.rc));
       
 15775                     p.y = adjust_lat(this.lat0 + (y - this.y0) / this.a);
       
 15776                     return p;
       
 15777                 };
       
 15778                 exports.names = [
       
 15779                     'Equirectangular',
       
 15780                     'Equidistant_Cylindrical',
       
 15781                     'eqc'
       
 15782                 ];
       
 15783                 return exports;
       
 15784             },
       
 15785             {
       
 15786                 '../common/adjust_lat': 4,
       
 15787                 '../common/adjust_lon': 5
       
 15788             }
       
 15789         ],
       
 15790         44: [
       
 15791             function (_dereq_, module, exports) {
       
 15792                 var e0fn = _dereq_('../common/e0fn');
       
 15793                 var e1fn = _dereq_('../common/e1fn');
       
 15794                 var e2fn = _dereq_('../common/e2fn');
       
 15795                 var e3fn = _dereq_('../common/e3fn');
       
 15796                 var msfnz = _dereq_('../common/msfnz');
       
 15797                 var mlfn = _dereq_('../common/mlfn');
       
 15798                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15799                 var adjust_lat = _dereq_('../common/adjust_lat');
       
 15800                 var imlfn = _dereq_('../common/imlfn');
       
 15801                 var EPSLN = 1e-10;
       
 15802                 exports.init = function () {
       
 15803                     if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
       
 15804                         return;
       
 15805                     }
       
 15806                     this.lat2 = this.lat2 || this.lat1;
       
 15807                     this.temp = this.b / this.a;
       
 15808                     this.es = 1 - Math.pow(this.temp, 2);
       
 15809                     this.e = Math.sqrt(this.es);
       
 15810                     this.e0 = e0fn(this.es);
       
 15811                     this.e1 = e1fn(this.es);
       
 15812                     this.e2 = e2fn(this.es);
       
 15813                     this.e3 = e3fn(this.es);
       
 15814                     this.sinphi = Math.sin(this.lat1);
       
 15815                     this.cosphi = Math.cos(this.lat1);
       
 15816                     this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
       
 15817                     this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
       
 15818                     if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
       
 15819                         this.ns = this.sinphi;
       
 15820                     } else {
       
 15821                         this.sinphi = Math.sin(this.lat2);
       
 15822                         this.cosphi = Math.cos(this.lat2);
       
 15823                         this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
       
 15824                         this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
       
 15825                         this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
       
 15826                     }
       
 15827                     this.g = this.ml1 + this.ms1 / this.ns;
       
 15828                     this.ml0 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
       
 15829                     this.rh = this.a * (this.g - this.ml0);
       
 15830                 };
       
 15831                 exports.forward = function (p) {
       
 15832                     var lon = p.x;
       
 15833                     var lat = p.y;
       
 15834                     var rh1;
       
 15835                     if (this.sphere) {
       
 15836                         rh1 = this.a * (this.g - lat);
       
 15837                     } else {
       
 15838                         var ml = mlfn(this.e0, this.e1, this.e2, this.e3, lat);
       
 15839                         rh1 = this.a * (this.g - ml);
       
 15840                     }
       
 15841                     var theta = this.ns * adjust_lon(lon - this.long0);
       
 15842                     var x = this.x0 + rh1 * Math.sin(theta);
       
 15843                     var y = this.y0 + this.rh - rh1 * Math.cos(theta);
       
 15844                     p.x = x;
       
 15845                     p.y = y;
       
 15846                     return p;
       
 15847                 };
       
 15848                 exports.inverse = function (p) {
       
 15849                     p.x -= this.x0;
       
 15850                     p.y = this.rh - p.y + this.y0;
       
 15851                     var con, rh1, lat, lon;
       
 15852                     if (this.ns >= 0) {
       
 15853                         rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
       
 15854                         con = 1;
       
 15855                     } else {
       
 15856                         rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
       
 15857                         con = -1;
       
 15858                     }
       
 15859                     var theta = 0;
       
 15860                     if (rh1 !== 0) {
       
 15861                         theta = Math.atan2(con * p.x, con * p.y);
       
 15862                     }
       
 15863                     if (this.sphere) {
       
 15864                         lon = adjust_lon(this.long0 + theta / this.ns);
       
 15865                         lat = adjust_lat(this.g - rh1 / this.a);
       
 15866                         p.x = lon;
       
 15867                         p.y = lat;
       
 15868                         return p;
       
 15869                     } else {
       
 15870                         var ml = this.g - rh1 / this.a;
       
 15871                         lat = imlfn(ml, this.e0, this.e1, this.e2, this.e3);
       
 15872                         lon = adjust_lon(this.long0 + theta / this.ns);
       
 15873                         p.x = lon;
       
 15874                         p.y = lat;
       
 15875                         return p;
       
 15876                     }
       
 15877                 };
       
 15878                 exports.names = [
       
 15879                     'Equidistant_Conic',
       
 15880                     'eqdc'
       
 15881                 ];
       
 15882                 return exports;
       
 15883             },
       
 15884             {
       
 15885                 '../common/adjust_lat': 4,
       
 15886                 '../common/adjust_lon': 5,
       
 15887                 '../common/e0fn': 7,
       
 15888                 '../common/e1fn': 8,
       
 15889                 '../common/e2fn': 9,
       
 15890                 '../common/e3fn': 10,
       
 15891                 '../common/imlfn': 12,
       
 15892                 '../common/mlfn': 14,
       
 15893                 '../common/msfnz': 15
       
 15894             }
       
 15895         ],
       
 15896         45: [
       
 15897             function (_dereq_, module, exports) {
       
 15898                 var FORTPI = Math.PI / 4;
       
 15899                 var srat = _dereq_('../common/srat');
       
 15900                 var HALF_PI = Math.PI / 2;
       
 15901                 var MAX_ITER = 20;
       
 15902                 exports.init = function () {
       
 15903                     var sphi = Math.sin(this.lat0);
       
 15904                     var cphi = Math.cos(this.lat0);
       
 15905                     cphi *= cphi;
       
 15906                     this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi);
       
 15907                     this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es));
       
 15908                     this.phic0 = Math.asin(sphi / this.C);
       
 15909                     this.ratexp = 0.5 * this.C * this.e;
       
 15910                     this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat(this.e * sphi, this.ratexp));
       
 15911                 };
       
 15912                 exports.forward = function (p) {
       
 15913                     var lon = p.x;
       
 15914                     var lat = p.y;
       
 15915                     p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat(this.e * Math.sin(lat), this.ratexp)) - HALF_PI;
       
 15916                     p.x = this.C * lon;
       
 15917                     return p;
       
 15918                 };
       
 15919                 exports.inverse = function (p) {
       
 15920                     var DEL_TOL = 1e-14;
       
 15921                     var lon = p.x / this.C;
       
 15922                     var lat = p.y;
       
 15923                     var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C);
       
 15924                     for (var i = MAX_ITER; i > 0; --i) {
       
 15925                         lat = 2 * Math.atan(num * srat(this.e * Math.sin(p.y), -0.5 * this.e)) - HALF_PI;
       
 15926                         if (Math.abs(lat - p.y) < DEL_TOL) {
       
 15927                             break;
       
 15928                         }
       
 15929                         p.y = lat;
       
 15930                     }
       
 15931                     if (!i) {
       
 15932                         return null;
       
 15933                     }
       
 15934                     p.x = lon;
       
 15935                     p.y = lat;
       
 15936                     return p;
       
 15937                 };
       
 15938                 exports.names = ['gauss'];
       
 15939                 return exports;
       
 15940             },
       
 15941             { '../common/srat': 22 }
       
 15942         ],
       
 15943         46: [
       
 15944             function (_dereq_, module, exports) {
       
 15945                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 15946                 var EPSLN = 1e-10;
       
 15947                 var asinz = _dereq_('../common/asinz');
       
 15948                 exports.init = function () {
       
 15949                     this.sin_p14 = Math.sin(this.lat0);
       
 15950                     this.cos_p14 = Math.cos(this.lat0);
       
 15951                     this.infinity_dist = 1000 * this.a;
       
 15952                     this.rc = 1;
       
 15953                 };
       
 15954                 exports.forward = function (p) {
       
 15955                     var sinphi, cosphi;
       
 15956                     var dlon;
       
 15957                     var coslon;
       
 15958                     var ksp;
       
 15959                     var g;
       
 15960                     var x, y;
       
 15961                     var lon = p.x;
       
 15962                     var lat = p.y;
       
 15963                     dlon = adjust_lon(lon - this.long0);
       
 15964                     sinphi = Math.sin(lat);
       
 15965                     cosphi = Math.cos(lat);
       
 15966                     coslon = Math.cos(dlon);
       
 15967                     g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
       
 15968                     ksp = 1;
       
 15969                     if (g > 0 || Math.abs(g) <= EPSLN) {
       
 15970                         x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g;
       
 15971                         y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g;
       
 15972                     } else {
       
 15973                         x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon);
       
 15974                         y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
       
 15975                     }
       
 15976                     p.x = x;
       
 15977                     p.y = y;
       
 15978                     return p;
       
 15979                 };
       
 15980                 exports.inverse = function (p) {
       
 15981                     var rh;
       
 15982                     var sinc, cosc;
       
 15983                     var c;
       
 15984                     var lon, lat;
       
 15985                     p.x = (p.x - this.x0) / this.a;
       
 15986                     p.y = (p.y - this.y0) / this.a;
       
 15987                     p.x /= this.k0;
       
 15988                     p.y /= this.k0;
       
 15989                     if (rh = Math.sqrt(p.x * p.x + p.y * p.y)) {
       
 15990                         c = Math.atan2(rh, this.rc);
       
 15991                         sinc = Math.sin(c);
       
 15992                         cosc = Math.cos(c);
       
 15993                         lat = asinz(cosc * this.sin_p14 + p.y * sinc * this.cos_p14 / rh);
       
 15994                         lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc);
       
 15995                         lon = adjust_lon(this.long0 + lon);
       
 15996                     } else {
       
 15997                         lat = this.phic0;
       
 15998                         lon = 0;
       
 15999                     }
       
 16000                     p.x = lon;
       
 16001                     p.y = lat;
       
 16002                     return p;
       
 16003                 };
       
 16004                 exports.names = ['gnom'];
       
 16005                 return exports;
       
 16006             },
       
 16007             {
       
 16008                 '../common/adjust_lon': 5,
       
 16009                 '../common/asinz': 6
       
 16010             }
       
 16011         ],
       
 16012         47: [
       
 16013             function (_dereq_, module, exports) {
       
 16014                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16015                 exports.init = function () {
       
 16016                     this.a = 6377397.155;
       
 16017                     this.es = 0.006674372230614;
       
 16018                     this.e = Math.sqrt(this.es);
       
 16019                     if (!this.lat0) {
       
 16020                         this.lat0 = 0.863937979737193;
       
 16021                     }
       
 16022                     if (!this.long0) {
       
 16023                         this.long0 = 0.7417649320975901 - 0.308341501185665;
       
 16024                     }
       
 16025                     if (!this.k0) {
       
 16026                         this.k0 = 0.9999;
       
 16027                     }
       
 16028                     this.s45 = 0.785398163397448;
       
 16029                     this.s90 = 2 * this.s45;
       
 16030                     this.fi0 = this.lat0;
       
 16031                     this.e2 = this.es;
       
 16032                     this.e = Math.sqrt(this.e2);
       
 16033                     this.alfa = Math.sqrt(1 + this.e2 * Math.pow(Math.cos(this.fi0), 4) / (1 - this.e2));
       
 16034                     this.uq = 1.04216856380474;
       
 16035                     this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa);
       
 16036                     this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2);
       
 16037                     this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g;
       
 16038                     this.k1 = this.k0;
       
 16039                     this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2));
       
 16040                     this.s0 = 1.37008346281555;
       
 16041                     this.n = Math.sin(this.s0);
       
 16042                     this.ro0 = this.k1 * this.n0 / Math.tan(this.s0);
       
 16043                     this.ad = this.s90 - this.uq;
       
 16044                 };
       
 16045                 exports.forward = function (p) {
       
 16046                     var gfi, u, deltav, s, d, eps, ro;
       
 16047                     var lon = p.x;
       
 16048                     var lat = p.y;
       
 16049                     var delta_lon = adjust_lon(lon - this.long0);
       
 16050                     gfi = Math.pow((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat)), this.alfa * this.e / 2);
       
 16051                     u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45);
       
 16052                     deltav = -delta_lon * this.alfa;
       
 16053                     s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav));
       
 16054                     d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s));
       
 16055                     eps = this.n * d;
       
 16056                     ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n);
       
 16057                     p.y = ro * Math.cos(eps) / 1;
       
 16058                     p.x = ro * Math.sin(eps) / 1;
       
 16059                     if (!this.czech) {
       
 16060                         p.y *= -1;
       
 16061                         p.x *= -1;
       
 16062                     }
       
 16063                     return p;
       
 16064                 };
       
 16065                 exports.inverse = function (p) {
       
 16066                     var u, deltav, s, d, eps, ro, fi1;
       
 16067                     var ok;
       
 16068                     var tmp = p.x;
       
 16069                     p.x = p.y;
       
 16070                     p.y = tmp;
       
 16071                     if (!this.czech) {
       
 16072                         p.y *= -1;
       
 16073                         p.x *= -1;
       
 16074                     }
       
 16075                     ro = Math.sqrt(p.x * p.x + p.y * p.y);
       
 16076                     eps = Math.atan2(p.y, p.x);
       
 16077                     d = eps / Math.sin(this.s0);
       
 16078                     s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);
       
 16079                     u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));
       
 16080                     deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));
       
 16081                     p.x = this.long0 - deltav / this.alfa;
       
 16082                     fi1 = u;
       
 16083                     ok = 0;
       
 16084                     var iter = 0;
       
 16085                     do {
       
 16086                         p.y = 2 * (Math.atan(Math.pow(this.k, -1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);
       
 16087                         if (Math.abs(fi1 - p.y) < 1e-10) {
       
 16088                             ok = 1;
       
 16089                         }
       
 16090                         fi1 = p.y;
       
 16091                         iter += 1;
       
 16092                     } while (ok === 0 && iter < 15);
       
 16093                     if (iter >= 15) {
       
 16094                         return null;
       
 16095                     }
       
 16096                     return p;
       
 16097                 };
       
 16098                 exports.names = [
       
 16099                     'Krovak',
       
 16100                     'krovak'
       
 16101                 ];
       
 16102                 return exports;
       
 16103             },
       
 16104             { '../common/adjust_lon': 5 }
       
 16105         ],
       
 16106         48: [
       
 16107             function (_dereq_, module, exports) {
       
 16108                 var HALF_PI = Math.PI / 2;
       
 16109                 var FORTPI = Math.PI / 4;
       
 16110                 var EPSLN = 1e-10;
       
 16111                 var qsfnz = _dereq_('../common/qsfnz');
       
 16112                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16113                 exports.S_POLE = 1;
       
 16114                 exports.N_POLE = 2;
       
 16115                 exports.EQUIT = 3;
       
 16116                 exports.OBLIQ = 4;
       
 16117                 exports.init = function () {
       
 16118                     var t = Math.abs(this.lat0);
       
 16119                     if (Math.abs(t - HALF_PI) < EPSLN) {
       
 16120                         this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;
       
 16121                     } else if (Math.abs(t) < EPSLN) {
       
 16122                         this.mode = this.EQUIT;
       
 16123                     } else {
       
 16124                         this.mode = this.OBLIQ;
       
 16125                     }
       
 16126                     if (this.es > 0) {
       
 16127                         var sinphi;
       
 16128                         this.qp = qsfnz(this.e, 1);
       
 16129                         this.mmf = 0.5 / (1 - this.es);
       
 16130                         this.apa = this.authset(this.es);
       
 16131                         switch (this.mode) {
       
 16132                         case this.N_POLE:
       
 16133                             this.dd = 1;
       
 16134                             break;
       
 16135                         case this.S_POLE:
       
 16136                             this.dd = 1;
       
 16137                             break;
       
 16138                         case this.EQUIT:
       
 16139                             this.rq = Math.sqrt(0.5 * this.qp);
       
 16140                             this.dd = 1 / this.rq;
       
 16141                             this.xmf = 1;
       
 16142                             this.ymf = 0.5 * this.qp;
       
 16143                             break;
       
 16144                         case this.OBLIQ:
       
 16145                             this.rq = Math.sqrt(0.5 * this.qp);
       
 16146                             sinphi = Math.sin(this.lat0);
       
 16147                             this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
       
 16148                             this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1);
       
 16149                             this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1);
       
 16150                             this.ymf = (this.xmf = this.rq) / this.dd;
       
 16151                             this.xmf *= this.dd;
       
 16152                             break;
       
 16153                         }
       
 16154                     } else {
       
 16155                         if (this.mode === this.OBLIQ) {
       
 16156                             this.sinph0 = Math.sin(this.lat0);
       
 16157                             this.cosph0 = Math.cos(this.lat0);
       
 16158                         }
       
 16159                     }
       
 16160                 };
       
 16161                 exports.forward = function (p) {
       
 16162                     var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi;
       
 16163                     var lam = p.x;
       
 16164                     var phi = p.y;
       
 16165                     lam = adjust_lon(lam - this.long0);
       
 16166                     if (this.sphere) {
       
 16167                         sinphi = Math.sin(phi);
       
 16168                         cosphi = Math.cos(phi);
       
 16169                         coslam = Math.cos(lam);
       
 16170                         if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
       
 16171                             y = this.mode === this.EQUIT ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
       
 16172                             if (y <= EPSLN) {
       
 16173                                 return null;
       
 16174                             }
       
 16175                             y = Math.sqrt(2 / y);
       
 16176                             x = y * cosphi * Math.sin(lam);
       
 16177                             y *= this.mode === this.EQUIT ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
       
 16178                         } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
       
 16179                             if (this.mode === this.N_POLE) {
       
 16180                                 coslam = -coslam;
       
 16181                             }
       
 16182                             if (Math.abs(phi + this.phi0) < EPSLN) {
       
 16183                                 return null;
       
 16184                             }
       
 16185                             y = FORTPI - phi * 0.5;
       
 16186                             y = 2 * (this.mode === this.S_POLE ? Math.cos(y) : Math.sin(y));
       
 16187                             x = y * Math.sin(lam);
       
 16188                             y *= coslam;
       
 16189                         }
       
 16190                     } else {
       
 16191                         sinb = 0;
       
 16192                         cosb = 0;
       
 16193                         b = 0;
       
 16194                         coslam = Math.cos(lam);
       
 16195                         sinlam = Math.sin(lam);
       
 16196                         sinphi = Math.sin(phi);
       
 16197                         q = qsfnz(this.e, sinphi);
       
 16198                         if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
       
 16199                             sinb = q / this.qp;
       
 16200                             cosb = Math.sqrt(1 - sinb * sinb);
       
 16201                         }
       
 16202                         switch (this.mode) {
       
 16203                         case this.OBLIQ:
       
 16204                             b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam;
       
 16205                             break;
       
 16206                         case this.EQUIT:
       
 16207                             b = 1 + cosb * coslam;
       
 16208                             break;
       
 16209                         case this.N_POLE:
       
 16210                             b = HALF_PI + phi;
       
 16211                             q = this.qp - q;
       
 16212                             break;
       
 16213                         case this.S_POLE:
       
 16214                             b = phi - HALF_PI;
       
 16215                             q = this.qp + q;
       
 16216                             break;
       
 16217                         }
       
 16218                         if (Math.abs(b) < EPSLN) {
       
 16219                             return null;
       
 16220                         }
       
 16221                         switch (this.mode) {
       
 16222                         case this.OBLIQ:
       
 16223                         case this.EQUIT:
       
 16224                             b = Math.sqrt(2 / b);
       
 16225                             if (this.mode === this.OBLIQ) {
       
 16226                                 y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam);
       
 16227                             } else {
       
 16228                                 y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf;
       
 16229                             }
       
 16230                             x = this.xmf * b * cosb * sinlam;
       
 16231                             break;
       
 16232                         case this.N_POLE:
       
 16233                         case this.S_POLE:
       
 16234                             if (q >= 0) {
       
 16235                                 x = (b = Math.sqrt(q)) * sinlam;
       
 16236                                 y = coslam * (this.mode === this.S_POLE ? b : -b);
       
 16237                             } else {
       
 16238                                 x = y = 0;
       
 16239                             }
       
 16240                             break;
       
 16241                         }
       
 16242                     }
       
 16243                     p.x = this.a * x + this.x0;
       
 16244                     p.y = this.a * y + this.y0;
       
 16245                     return p;
       
 16246                 };
       
 16247                 exports.inverse = function (p) {
       
 16248                     p.x -= this.x0;
       
 16249                     p.y -= this.y0;
       
 16250                     var x = p.x / this.a;
       
 16251                     var y = p.y / this.a;
       
 16252                     var lam, phi, cCe, sCe, q, rho, ab;
       
 16253                     if (this.sphere) {
       
 16254                         var cosz = 0, rh, sinz = 0;
       
 16255                         rh = Math.sqrt(x * x + y * y);
       
 16256                         phi = rh * 0.5;
       
 16257                         if (phi > 1) {
       
 16258                             return null;
       
 16259                         }
       
 16260                         phi = 2 * Math.asin(phi);
       
 16261                         if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
       
 16262                             sinz = Math.sin(phi);
       
 16263                             cosz = Math.cos(phi);
       
 16264                         }
       
 16265                         switch (this.mode) {
       
 16266                         case this.EQUIT:
       
 16267                             phi = Math.abs(rh) <= EPSLN ? 0 : Math.asin(y * sinz / rh);
       
 16268                             x *= sinz;
       
 16269                             y = cosz * rh;
       
 16270                             break;
       
 16271                         case this.OBLIQ:
       
 16272                             phi = Math.abs(rh) <= EPSLN ? this.phi0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh);
       
 16273                             x *= sinz * this.cosph0;
       
 16274                             y = (cosz - Math.sin(phi) * this.sinph0) * rh;
       
 16275                             break;
       
 16276                         case this.N_POLE:
       
 16277                             y = -y;
       
 16278                             phi = HALF_PI - phi;
       
 16279                             break;
       
 16280                         case this.S_POLE:
       
 16281                             phi -= HALF_PI;
       
 16282                             break;
       
 16283                         }
       
 16284                         lam = y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ) ? 0 : Math.atan2(x, y);
       
 16285                     } else {
       
 16286                         ab = 0;
       
 16287                         if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
       
 16288                             x /= this.dd;
       
 16289                             y *= this.dd;
       
 16290                             rho = Math.sqrt(x * x + y * y);
       
 16291                             if (rho < EPSLN) {
       
 16292                                 p.x = 0;
       
 16293                                 p.y = this.phi0;
       
 16294                                 return p;
       
 16295                             }
       
 16296                             sCe = 2 * Math.asin(0.5 * rho / this.rq);
       
 16297                             cCe = Math.cos(sCe);
       
 16298                             x *= sCe = Math.sin(sCe);
       
 16299                             if (this.mode === this.OBLIQ) {
       
 16300                                 ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho;
       
 16301                                 q = this.qp * ab;
       
 16302                                 y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe;
       
 16303                             } else {
       
 16304                                 ab = y * sCe / rho;
       
 16305                                 q = this.qp * ab;
       
 16306                                 y = rho * cCe;
       
 16307                             }
       
 16308                         } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
       
 16309                             if (this.mode === this.N_POLE) {
       
 16310                                 y = -y;
       
 16311                             }
       
 16312                             q = x * x + y * y;
       
 16313                             if (!q) {
       
 16314                                 p.x = 0;
       
 16315                                 p.y = this.phi0;
       
 16316                                 return p;
       
 16317                             }
       
 16318                             ab = 1 - q / this.qp;
       
 16319                             if (this.mode === this.S_POLE) {
       
 16320                                 ab = -ab;
       
 16321                             }
       
 16322                         }
       
 16323                         lam = Math.atan2(x, y);
       
 16324                         phi = this.authlat(Math.asin(ab), this.apa);
       
 16325                     }
       
 16326                     p.x = adjust_lon(this.long0 + lam);
       
 16327                     p.y = phi;
       
 16328                     return p;
       
 16329                 };
       
 16330                 exports.P00 = 0.3333333333333333;
       
 16331                 exports.P01 = 0.17222222222222222;
       
 16332                 exports.P02 = 0.10257936507936508;
       
 16333                 exports.P10 = 0.06388888888888888;
       
 16334                 exports.P11 = 0.0664021164021164;
       
 16335                 exports.P20 = 0.016415012942191543;
       
 16336                 exports.authset = function (es) {
       
 16337                     var t;
       
 16338                     var APA = [];
       
 16339                     APA[0] = es * this.P00;
       
 16340                     t = es * es;
       
 16341                     APA[0] += t * this.P01;
       
 16342                     APA[1] = t * this.P10;
       
 16343                     t *= es;
       
 16344                     APA[0] += t * this.P02;
       
 16345                     APA[1] += t * this.P11;
       
 16346                     APA[2] = t * this.P20;
       
 16347                     return APA;
       
 16348                 };
       
 16349                 exports.authlat = function (beta, APA) {
       
 16350                     var t = beta + beta;
       
 16351                     return beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t);
       
 16352                 };
       
 16353                 exports.names = [
       
 16354                     'Lambert Azimuthal Equal Area',
       
 16355                     'Lambert_Azimuthal_Equal_Area',
       
 16356                     'laea'
       
 16357                 ];
       
 16358                 return exports;
       
 16359             },
       
 16360             {
       
 16361                 '../common/adjust_lon': 5,
       
 16362                 '../common/qsfnz': 20
       
 16363             }
       
 16364         ],
       
 16365         49: [
       
 16366             function (_dereq_, module, exports) {
       
 16367                 var EPSLN = 1e-10;
       
 16368                 var msfnz = _dereq_('../common/msfnz');
       
 16369                 var tsfnz = _dereq_('../common/tsfnz');
       
 16370                 var HALF_PI = Math.PI / 2;
       
 16371                 var sign = _dereq_('../common/sign');
       
 16372                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16373                 var phi2z = _dereq_('../common/phi2z');
       
 16374                 exports.init = function () {
       
 16375                     if (!this.lat2) {
       
 16376                         this.lat2 = this.lat1;
       
 16377                     }
       
 16378                     if (!this.k0) {
       
 16379                         this.k0 = 1;
       
 16380                     }
       
 16381                     this.x0 = this.x0 || 0;
       
 16382                     this.y0 = this.y0 || 0;
       
 16383                     if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
       
 16384                         return;
       
 16385                     }
       
 16386                     var temp = this.b / this.a;
       
 16387                     this.e = Math.sqrt(1 - temp * temp);
       
 16388                     var sin1 = Math.sin(this.lat1);
       
 16389                     var cos1 = Math.cos(this.lat1);
       
 16390                     var ms1 = msfnz(this.e, sin1, cos1);
       
 16391                     var ts1 = tsfnz(this.e, this.lat1, sin1);
       
 16392                     var sin2 = Math.sin(this.lat2);
       
 16393                     var cos2 = Math.cos(this.lat2);
       
 16394                     var ms2 = msfnz(this.e, sin2, cos2);
       
 16395                     var ts2 = tsfnz(this.e, this.lat2, sin2);
       
 16396                     var ts0 = tsfnz(this.e, this.lat0, Math.sin(this.lat0));
       
 16397                     if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
       
 16398                         this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2);
       
 16399                     } else {
       
 16400                         this.ns = sin1;
       
 16401                     }
       
 16402                     if (isNaN(this.ns)) {
       
 16403                         this.ns = sin1;
       
 16404                     }
       
 16405                     this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns));
       
 16406                     this.rh = this.a * this.f0 * Math.pow(ts0, this.ns);
       
 16407                     if (!this.title) {
       
 16408                         this.title = 'Lambert Conformal Conic';
       
 16409                     }
       
 16410                 };
       
 16411                 exports.forward = function (p) {
       
 16412                     var lon = p.x;
       
 16413                     var lat = p.y;
       
 16414                     if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) {
       
 16415                         lat = sign(lat) * (HALF_PI - 2 * EPSLN);
       
 16416                     }
       
 16417                     var con = Math.abs(Math.abs(lat) - HALF_PI);
       
 16418                     var ts, rh1;
       
 16419                     if (con > EPSLN) {
       
 16420                         ts = tsfnz(this.e, lat, Math.sin(lat));
       
 16421                         rh1 = this.a * this.f0 * Math.pow(ts, this.ns);
       
 16422                     } else {
       
 16423                         con = lat * this.ns;
       
 16424                         if (con <= 0) {
       
 16425                             return null;
       
 16426                         }
       
 16427                         rh1 = 0;
       
 16428                     }
       
 16429                     var theta = this.ns * adjust_lon(lon - this.long0);
       
 16430                     p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0;
       
 16431                     p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0;
       
 16432                     return p;
       
 16433                 };
       
 16434                 exports.inverse = function (p) {
       
 16435                     var rh1, con, ts;
       
 16436                     var lat, lon;
       
 16437                     var x = (p.x - this.x0) / this.k0;
       
 16438                     var y = this.rh - (p.y - this.y0) / this.k0;
       
 16439                     if (this.ns > 0) {
       
 16440                         rh1 = Math.sqrt(x * x + y * y);
       
 16441                         con = 1;
       
 16442                     } else {
       
 16443                         rh1 = -Math.sqrt(x * x + y * y);
       
 16444                         con = -1;
       
 16445                     }
       
 16446                     var theta = 0;
       
 16447                     if (rh1 !== 0) {
       
 16448                         theta = Math.atan2(con * x, con * y);
       
 16449                     }
       
 16450                     if (rh1 !== 0 || this.ns > 0) {
       
 16451                         con = 1 / this.ns;
       
 16452                         ts = Math.pow(rh1 / (this.a * this.f0), con);
       
 16453                         lat = phi2z(this.e, ts);
       
 16454                         if (lat === -9999) {
       
 16455                             return null;
       
 16456                         }
       
 16457                     } else {
       
 16458                         lat = -HALF_PI;
       
 16459                     }
       
 16460                     lon = adjust_lon(theta / this.ns + this.long0);
       
 16461                     p.x = lon;
       
 16462                     p.y = lat;
       
 16463                     return p;
       
 16464                 };
       
 16465                 exports.names = [
       
 16466                     'Lambert Tangential Conformal Conic Projection',
       
 16467                     'Lambert_Conformal_Conic',
       
 16468                     'Lambert_Conformal_Conic_2SP',
       
 16469                     'lcc'
       
 16470                 ];
       
 16471                 return exports;
       
 16472             },
       
 16473             {
       
 16474                 '../common/adjust_lon': 5,
       
 16475                 '../common/msfnz': 15,
       
 16476                 '../common/phi2z': 16,
       
 16477                 '../common/sign': 21,
       
 16478                 '../common/tsfnz': 24
       
 16479             }
       
 16480         ],
       
 16481         50: [
       
 16482             function (_dereq_, module, exports) {
       
 16483                 exports.init = function () {
       
 16484                 };
       
 16485                 function identity(pt) {
       
 16486                     return pt;
       
 16487                 }
       
 16488                 exports.forward = identity;
       
 16489                 exports.inverse = identity;
       
 16490                 exports.names = [
       
 16491                     'longlat',
       
 16492                     'identity'
       
 16493                 ];
       
 16494                 return exports;
       
 16495             },
       
 16496             {}
       
 16497         ],
       
 16498         51: [
       
 16499             function (_dereq_, module, exports) {
       
 16500                 var msfnz = _dereq_('../common/msfnz');
       
 16501                 var HALF_PI = Math.PI / 2;
       
 16502                 var EPSLN = 1e-10;
       
 16503                 var R2D = 57.29577951308232;
       
 16504                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16505                 var FORTPI = Math.PI / 4;
       
 16506                 var tsfnz = _dereq_('../common/tsfnz');
       
 16507                 var phi2z = _dereq_('../common/phi2z');
       
 16508                 exports.init = function () {
       
 16509                     var con = this.b / this.a;
       
 16510                     this.es = 1 - con * con;
       
 16511                     if (!('x0' in this)) {
       
 16512                         this.x0 = 0;
       
 16513                     }
       
 16514                     if (!('y0' in this)) {
       
 16515                         this.y0 = 0;
       
 16516                     }
       
 16517                     this.e = Math.sqrt(this.es);
       
 16518                     if (this.lat_ts) {
       
 16519                         if (this.sphere) {
       
 16520                             this.k0 = Math.cos(this.lat_ts);
       
 16521                         } else {
       
 16522                             this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
       
 16523                         }
       
 16524                     } else {
       
 16525                         if (!this.k0) {
       
 16526                             if (this.k) {
       
 16527                                 this.k0 = this.k;
       
 16528                             } else {
       
 16529                                 this.k0 = 1;
       
 16530                             }
       
 16531                         }
       
 16532                     }
       
 16533                 };
       
 16534                 exports.forward = function (p) {
       
 16535                     var lon = p.x;
       
 16536                     var lat = p.y;
       
 16537                     if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {
       
 16538                         return null;
       
 16539                     }
       
 16540                     var x, y;
       
 16541                     if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
       
 16542                         return null;
       
 16543                     } else {
       
 16544                         if (this.sphere) {
       
 16545                             x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
       
 16546                             y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));
       
 16547                         } else {
       
 16548                             var sinphi = Math.sin(lat);
       
 16549                             var ts = tsfnz(this.e, lat, sinphi);
       
 16550                             x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
       
 16551                             y = this.y0 - this.a * this.k0 * Math.log(ts);
       
 16552                         }
       
 16553                         p.x = x;
       
 16554                         p.y = y;
       
 16555                         return p;
       
 16556                     }
       
 16557                 };
       
 16558                 exports.inverse = function (p) {
       
 16559                     var x = p.x - this.x0;
       
 16560                     var y = p.y - this.y0;
       
 16561                     var lon, lat;
       
 16562                     if (this.sphere) {
       
 16563                         lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0)));
       
 16564                     } else {
       
 16565                         var ts = Math.exp(-y / (this.a * this.k0));
       
 16566                         lat = phi2z(this.e, ts);
       
 16567                         if (lat === -9999) {
       
 16568                             return null;
       
 16569                         }
       
 16570                     }
       
 16571                     lon = adjust_lon(this.long0 + x / (this.a * this.k0));
       
 16572                     p.x = lon;
       
 16573                     p.y = lat;
       
 16574                     return p;
       
 16575                 };
       
 16576                 exports.names = [
       
 16577                     'Mercator',
       
 16578                     'Popular Visualisation Pseudo Mercator',
       
 16579                     'Mercator_1SP',
       
 16580                     'Mercator_Auxiliary_Sphere',
       
 16581                     'merc'
       
 16582                 ];
       
 16583                 return exports;
       
 16584             },
       
 16585             {
       
 16586                 '../common/adjust_lon': 5,
       
 16587                 '../common/msfnz': 15,
       
 16588                 '../common/phi2z': 16,
       
 16589                 '../common/tsfnz': 24
       
 16590             }
       
 16591         ],
       
 16592         52: [
       
 16593             function (_dereq_, module, exports) {
       
 16594                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16595                 exports.init = function () {
       
 16596                 };
       
 16597                 exports.forward = function (p) {
       
 16598                     var lon = p.x;
       
 16599                     var lat = p.y;
       
 16600                     var dlon = adjust_lon(lon - this.long0);
       
 16601                     var x = this.x0 + this.a * dlon;
       
 16602                     var y = this.y0 + this.a * Math.log(Math.tan(Math.PI / 4 + lat / 2.5)) * 1.25;
       
 16603                     p.x = x;
       
 16604                     p.y = y;
       
 16605                     return p;
       
 16606                 };
       
 16607                 exports.inverse = function (p) {
       
 16608                     p.x -= this.x0;
       
 16609                     p.y -= this.y0;
       
 16610                     var lon = adjust_lon(this.long0 + p.x / this.a);
       
 16611                     var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);
       
 16612                     p.x = lon;
       
 16613                     p.y = lat;
       
 16614                     return p;
       
 16615                 };
       
 16616                 exports.names = [
       
 16617                     'Miller_Cylindrical',
       
 16618                     'mill'
       
 16619                 ];
       
 16620                 return exports;
       
 16621             },
       
 16622             { '../common/adjust_lon': 5 }
       
 16623         ],
       
 16624         53: [
       
 16625             function (_dereq_, module, exports) {
       
 16626                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16627                 var EPSLN = 1e-10;
       
 16628                 exports.init = function () {
       
 16629                 };
       
 16630                 exports.forward = function (p) {
       
 16631                     var lon = p.x;
       
 16632                     var lat = p.y;
       
 16633                     var delta_lon = adjust_lon(lon - this.long0);
       
 16634                     var theta = lat;
       
 16635                     var con = Math.PI * Math.sin(lat);
       
 16636                     for (var i = 0; true; i++) {
       
 16637                         var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));
       
 16638                         theta += delta_theta;
       
 16639                         if (Math.abs(delta_theta) < EPSLN) {
       
 16640                             break;
       
 16641                         }
       
 16642                     }
       
 16643                     theta /= 2;
       
 16644                     if (Math.PI / 2 - Math.abs(lat) < EPSLN) {
       
 16645                         delta_lon = 0;
       
 16646                     }
       
 16647                     var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
       
 16648                     var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
       
 16649                     p.x = x;
       
 16650                     p.y = y;
       
 16651                     return p;
       
 16652                 };
       
 16653                 exports.inverse = function (p) {
       
 16654                     var theta;
       
 16655                     var arg;
       
 16656                     p.x -= this.x0;
       
 16657                     p.y -= this.y0;
       
 16658                     arg = p.y / (1.4142135623731 * this.a);
       
 16659                     if (Math.abs(arg) > 0.999999999999) {
       
 16660                         arg = 0.999999999999;
       
 16661                     }
       
 16662                     theta = Math.asin(arg);
       
 16663                     var lon = adjust_lon(this.long0 + p.x / (0.900316316158 * this.a * Math.cos(theta)));
       
 16664                     if (lon < -Math.PI) {
       
 16665                         lon = -Math.PI;
       
 16666                     }
       
 16667                     if (lon > Math.PI) {
       
 16668                         lon = Math.PI;
       
 16669                     }
       
 16670                     arg = (2 * theta + Math.sin(2 * theta)) / Math.PI;
       
 16671                     if (Math.abs(arg) > 1) {
       
 16672                         arg = 1;
       
 16673                     }
       
 16674                     var lat = Math.asin(arg);
       
 16675                     p.x = lon;
       
 16676                     p.y = lat;
       
 16677                     return p;
       
 16678                 };
       
 16679                 exports.names = [
       
 16680                     'Mollweide',
       
 16681                     'moll'
       
 16682                 ];
       
 16683                 return exports;
       
 16684             },
       
 16685             { '../common/adjust_lon': 5 }
       
 16686         ],
       
 16687         54: [
       
 16688             function (_dereq_, module, exports) {
       
 16689                 var SEC_TO_RAD = 0.00000484813681109536;
       
 16690                 exports.iterations = 1;
       
 16691                 exports.init = function () {
       
 16692                     this.A = [];
       
 16693                     this.A[1] = 0.6399175073;
       
 16694                     this.A[2] = -0.1358797613;
       
 16695                     this.A[3] = 0.063294409;
       
 16696                     this.A[4] = -0.02526853;
       
 16697                     this.A[5] = 0.0117879;
       
 16698                     this.A[6] = -0.0055161;
       
 16699                     this.A[7] = 0.0026906;
       
 16700                     this.A[8] = -0.001333;
       
 16701                     this.A[9] = 0.00067;
       
 16702                     this.A[10] = -0.00034;
       
 16703                     this.B_re = [];
       
 16704                     this.B_im = [];
       
 16705                     this.B_re[1] = 0.7557853228;
       
 16706                     this.B_im[1] = 0;
       
 16707                     this.B_re[2] = 0.249204646;
       
 16708                     this.B_im[2] = 0.003371507;
       
 16709                     this.B_re[3] = -0.001541739;
       
 16710                     this.B_im[3] = 0.04105856;
       
 16711                     this.B_re[4] = -0.10162907;
       
 16712                     this.B_im[4] = 0.01727609;
       
 16713                     this.B_re[5] = -0.26623489;
       
 16714                     this.B_im[5] = -0.36249218;
       
 16715                     this.B_re[6] = -0.6870983;
       
 16716                     this.B_im[6] = -1.1651967;
       
 16717                     this.C_re = [];
       
 16718                     this.C_im = [];
       
 16719                     this.C_re[1] = 1.3231270439;
       
 16720                     this.C_im[1] = 0;
       
 16721                     this.C_re[2] = -0.577245789;
       
 16722                     this.C_im[2] = -0.007809598;
       
 16723                     this.C_re[3] = 0.508307513;
       
 16724                     this.C_im[3] = -0.112208952;
       
 16725                     this.C_re[4] = -0.15094762;
       
 16726                     this.C_im[4] = 0.18200602;
       
 16727                     this.C_re[5] = 1.01418179;
       
 16728                     this.C_im[5] = 1.64497696;
       
 16729                     this.C_re[6] = 1.9660549;
       
 16730                     this.C_im[6] = 2.5127645;
       
 16731                     this.D = [];
       
 16732                     this.D[1] = 1.5627014243;
       
 16733                     this.D[2] = 0.5185406398;
       
 16734                     this.D[3] = -0.03333098;
       
 16735                     this.D[4] = -0.1052906;
       
 16736                     this.D[5] = -0.0368594;
       
 16737                     this.D[6] = 0.007317;
       
 16738                     this.D[7] = 0.0122;
       
 16739                     this.D[8] = 0.00394;
       
 16740                     this.D[9] = -0.0013;
       
 16741                 };
       
 16742                 exports.forward = function (p) {
       
 16743                     var n;
       
 16744                     var lon = p.x;
       
 16745                     var lat = p.y;
       
 16746                     var delta_lat = lat - this.lat0;
       
 16747                     var delta_lon = lon - this.long0;
       
 16748                     var d_phi = delta_lat / SEC_TO_RAD * 0.00001;
       
 16749                     var d_lambda = delta_lon;
       
 16750                     var d_phi_n = 1;
       
 16751                     var d_psi = 0;
       
 16752                     for (n = 1; n <= 10; n++) {
       
 16753                         d_phi_n = d_phi_n * d_phi;
       
 16754                         d_psi = d_psi + this.A[n] * d_phi_n;
       
 16755                     }
       
 16756                     var th_re = d_psi;
       
 16757                     var th_im = d_lambda;
       
 16758                     var th_n_re = 1;
       
 16759                     var th_n_im = 0;
       
 16760                     var th_n_re1;
       
 16761                     var th_n_im1;
       
 16762                     var z_re = 0;
       
 16763                     var z_im = 0;
       
 16764                     for (n = 1; n <= 6; n++) {
       
 16765                         th_n_re1 = th_n_re * th_re - th_n_im * th_im;
       
 16766                         th_n_im1 = th_n_im * th_re + th_n_re * th_im;
       
 16767                         th_n_re = th_n_re1;
       
 16768                         th_n_im = th_n_im1;
       
 16769                         z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im;
       
 16770                         z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im;
       
 16771                     }
       
 16772                     p.x = z_im * this.a + this.x0;
       
 16773                     p.y = z_re * this.a + this.y0;
       
 16774                     return p;
       
 16775                 };
       
 16776                 exports.inverse = function (p) {
       
 16777                     var n;
       
 16778                     var x = p.x;
       
 16779                     var y = p.y;
       
 16780                     var delta_x = x - this.x0;
       
 16781                     var delta_y = y - this.y0;
       
 16782                     var z_re = delta_y / this.a;
       
 16783                     var z_im = delta_x / this.a;
       
 16784                     var z_n_re = 1;
       
 16785                     var z_n_im = 0;
       
 16786                     var z_n_re1;
       
 16787                     var z_n_im1;
       
 16788                     var th_re = 0;
       
 16789                     var th_im = 0;
       
 16790                     for (n = 1; n <= 6; n++) {
       
 16791                         z_n_re1 = z_n_re * z_re - z_n_im * z_im;
       
 16792                         z_n_im1 = z_n_im * z_re + z_n_re * z_im;
       
 16793                         z_n_re = z_n_re1;
       
 16794                         z_n_im = z_n_im1;
       
 16795                         th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im;
       
 16796                         th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im;
       
 16797                     }
       
 16798                     for (var i = 0; i < this.iterations; i++) {
       
 16799                         var th_n_re = th_re;
       
 16800                         var th_n_im = th_im;
       
 16801                         var th_n_re1;
       
 16802                         var th_n_im1;
       
 16803                         var num_re = z_re;
       
 16804                         var num_im = z_im;
       
 16805                         for (n = 2; n <= 6; n++) {
       
 16806                             th_n_re1 = th_n_re * th_re - th_n_im * th_im;
       
 16807                             th_n_im1 = th_n_im * th_re + th_n_re * th_im;
       
 16808                             th_n_re = th_n_re1;
       
 16809                             th_n_im = th_n_im1;
       
 16810                             num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
       
 16811                             num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
       
 16812                         }
       
 16813                         th_n_re = 1;
       
 16814                         th_n_im = 0;
       
 16815                         var den_re = this.B_re[1];
       
 16816                         var den_im = this.B_im[1];
       
 16817                         for (n = 2; n <= 6; n++) {
       
 16818                             th_n_re1 = th_n_re * th_re - th_n_im * th_im;
       
 16819                             th_n_im1 = th_n_im * th_re + th_n_re * th_im;
       
 16820                             th_n_re = th_n_re1;
       
 16821                             th_n_im = th_n_im1;
       
 16822                             den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
       
 16823                             den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
       
 16824                         }
       
 16825                         var den2 = den_re * den_re + den_im * den_im;
       
 16826                         th_re = (num_re * den_re + num_im * den_im) / den2;
       
 16827                         th_im = (num_im * den_re - num_re * den_im) / den2;
       
 16828                     }
       
 16829                     var d_psi = th_re;
       
 16830                     var d_lambda = th_im;
       
 16831                     var d_psi_n = 1;
       
 16832                     var d_phi = 0;
       
 16833                     for (n = 1; n <= 9; n++) {
       
 16834                         d_psi_n = d_psi_n * d_psi;
       
 16835                         d_phi = d_phi + this.D[n] * d_psi_n;
       
 16836                     }
       
 16837                     var lat = this.lat0 + d_phi * SEC_TO_RAD * 100000;
       
 16838                     var lon = this.long0 + d_lambda;
       
 16839                     p.x = lon;
       
 16840                     p.y = lat;
       
 16841                     return p;
       
 16842                 };
       
 16843                 exports.names = [
       
 16844                     'New_Zealand_Map_Grid',
       
 16845                     'nzmg'
       
 16846                 ];
       
 16847                 return exports;
       
 16848             },
       
 16849             {}
       
 16850         ],
       
 16851         55: [
       
 16852             function (_dereq_, module, exports) {
       
 16853                 var tsfnz = _dereq_('../common/tsfnz');
       
 16854                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 16855                 var phi2z = _dereq_('../common/phi2z');
       
 16856                 var HALF_PI = Math.PI / 2;
       
 16857                 var FORTPI = Math.PI / 4;
       
 16858                 var EPSLN = 1e-10;
       
 16859                 exports.init = function () {
       
 16860                     this.no_off = this.no_off || false;
       
 16861                     this.no_rot = this.no_rot || false;
       
 16862                     if (isNaN(this.k0)) {
       
 16863                         this.k0 = 1;
       
 16864                     }
       
 16865                     var sinlat = Math.sin(this.lat0);
       
 16866                     var coslat = Math.cos(this.lat0);
       
 16867                     var con = this.e * sinlat;
       
 16868                     this.bl = Math.sqrt(1 + this.es / (1 - this.es) * Math.pow(coslat, 4));
       
 16869                     this.al = this.a * this.bl * this.k0 * Math.sqrt(1 - this.es) / (1 - con * con);
       
 16870                     var t0 = tsfnz(this.e, this.lat0, sinlat);
       
 16871                     var dl = this.bl / coslat * Math.sqrt((1 - this.es) / (1 - con * con));
       
 16872                     if (dl * dl < 1) {
       
 16873                         dl = 1;
       
 16874                     }
       
 16875                     var fl;
       
 16876                     var gl;
       
 16877                     if (!isNaN(this.longc)) {
       
 16878                         if (this.lat0 >= 0) {
       
 16879                             fl = dl + Math.sqrt(dl * dl - 1);
       
 16880                         } else {
       
 16881                             fl = dl - Math.sqrt(dl * dl - 1);
       
 16882                         }
       
 16883                         this.el = fl * Math.pow(t0, this.bl);
       
 16884                         gl = 0.5 * (fl - 1 / fl);
       
 16885                         this.gamma0 = Math.asin(Math.sin(this.alpha) / dl);
       
 16886                         this.long0 = this.longc - Math.asin(gl * Math.tan(this.gamma0)) / this.bl;
       
 16887                     } else {
       
 16888                         var t1 = tsfnz(this.e, this.lat1, Math.sin(this.lat1));
       
 16889                         var t2 = tsfnz(this.e, this.lat2, Math.sin(this.lat2));
       
 16890                         if (this.lat0 >= 0) {
       
 16891                             this.el = (dl + Math.sqrt(dl * dl - 1)) * Math.pow(t0, this.bl);
       
 16892                         } else {
       
 16893                             this.el = (dl - Math.sqrt(dl * dl - 1)) * Math.pow(t0, this.bl);
       
 16894                         }
       
 16895                         var hl = Math.pow(t1, this.bl);
       
 16896                         var ll = Math.pow(t2, this.bl);
       
 16897                         fl = this.el / hl;
       
 16898                         gl = 0.5 * (fl - 1 / fl);
       
 16899                         var jl = (this.el * this.el - ll * hl) / (this.el * this.el + ll * hl);
       
 16900                         var pl = (ll - hl) / (ll + hl);
       
 16901                         var dlon12 = adjust_lon(this.long1 - this.long2);
       
 16902                         this.long0 = 0.5 * (this.long1 + this.long2) - Math.atan(jl * Math.tan(0.5 * this.bl * dlon12) / pl) / this.bl;
       
 16903                         this.long0 = adjust_lon(this.long0);
       
 16904                         var dlon10 = adjust_lon(this.long1 - this.long0);
       
 16905                         this.gamma0 = Math.atan(Math.sin(this.bl * dlon10) / gl);
       
 16906                         this.alpha = Math.asin(dl * Math.sin(this.gamma0));
       
 16907                     }
       
 16908                     if (this.no_off) {
       
 16909                         this.uc = 0;
       
 16910                     } else {
       
 16911                         if (this.lat0 >= 0) {
       
 16912                             this.uc = this.al / this.bl * Math.atan2(Math.sqrt(dl * dl - 1), Math.cos(this.alpha));
       
 16913                         } else {
       
 16914                             this.uc = -1 * this.al / this.bl * Math.atan2(Math.sqrt(dl * dl - 1), Math.cos(this.alpha));
       
 16915                         }
       
 16916                     }
       
 16917                 };
       
 16918                 exports.forward = function (p) {
       
 16919                     var lon = p.x;
       
 16920                     var lat = p.y;
       
 16921                     var dlon = adjust_lon(lon - this.long0);
       
 16922                     var us, vs;
       
 16923                     var con;
       
 16924                     if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
       
 16925                         if (lat > 0) {
       
 16926                             con = -1;
       
 16927                         } else {
       
 16928                             con = 1;
       
 16929                         }
       
 16930                         vs = this.al / this.bl * Math.log(Math.tan(FORTPI + con * this.gamma0 * 0.5));
       
 16931                         us = -1 * con * HALF_PI * this.al / this.bl;
       
 16932                     } else {
       
 16933                         var t = tsfnz(this.e, lat, Math.sin(lat));
       
 16934                         var ql = this.el / Math.pow(t, this.bl);
       
 16935                         var sl = 0.5 * (ql - 1 / ql);
       
 16936                         var tl = 0.5 * (ql + 1 / ql);
       
 16937                         var vl = Math.sin(this.bl * dlon);
       
 16938                         var ul = (sl * Math.sin(this.gamma0) - vl * Math.cos(this.gamma0)) / tl;
       
 16939                         if (Math.abs(Math.abs(ul) - 1) <= EPSLN) {
       
 16940                             vs = Number.POSITIVE_INFINITY;
       
 16941                         } else {
       
 16942                             vs = 0.5 * this.al * Math.log((1 - ul) / (1 + ul)) / this.bl;
       
 16943                         }
       
 16944                         if (Math.abs(Math.cos(this.bl * dlon)) <= EPSLN) {
       
 16945                             us = this.al * this.bl * dlon;
       
 16946                         } else {
       
 16947                             us = this.al * Math.atan2(sl * Math.cos(this.gamma0) + vl * Math.sin(this.gamma0), Math.cos(this.bl * dlon)) / this.bl;
       
 16948                         }
       
 16949                     }
       
 16950                     if (this.no_rot) {
       
 16951                         p.x = this.x0 + us;
       
 16952                         p.y = this.y0 + vs;
       
 16953                     } else {
       
 16954                         us -= this.uc;
       
 16955                         p.x = this.x0 + vs * Math.cos(this.alpha) + us * Math.sin(this.alpha);
       
 16956                         p.y = this.y0 + us * Math.cos(this.alpha) - vs * Math.sin(this.alpha);
       
 16957                     }
       
 16958                     return p;
       
 16959                 };
       
 16960                 exports.inverse = function (p) {
       
 16961                     var us, vs;
       
 16962                     if (this.no_rot) {
       
 16963                         vs = p.y - this.y0;
       
 16964                         us = p.x - this.x0;
       
 16965                     } else {
       
 16966                         vs = (p.x - this.x0) * Math.cos(this.alpha) - (p.y - this.y0) * Math.sin(this.alpha);
       
 16967                         us = (p.y - this.y0) * Math.cos(this.alpha) + (p.x - this.x0) * Math.sin(this.alpha);
       
 16968                         us += this.uc;
       
 16969                     }
       
 16970                     var qp = Math.exp(-1 * this.bl * vs / this.al);
       
 16971                     var sp = 0.5 * (qp - 1 / qp);
       
 16972                     var tp = 0.5 * (qp + 1 / qp);
       
 16973                     var vp = Math.sin(this.bl * us / this.al);
       
 16974                     var up = (vp * Math.cos(this.gamma0) + sp * Math.sin(this.gamma0)) / tp;
       
 16975                     var ts = Math.pow(this.el / Math.sqrt((1 + up) / (1 - up)), 1 / this.bl);
       
 16976                     if (Math.abs(up - 1) < EPSLN) {
       
 16977                         p.x = this.long0;
       
 16978                         p.y = HALF_PI;
       
 16979                     } else if (Math.abs(up + 1) < EPSLN) {
       
 16980                         p.x = this.long0;
       
 16981                         p.y = -1 * HALF_PI;
       
 16982                     } else {
       
 16983                         p.y = phi2z(this.e, ts);
       
 16984                         p.x = adjust_lon(this.long0 - Math.atan2(sp * Math.cos(this.gamma0) - vp * Math.sin(this.gamma0), Math.cos(this.bl * us / this.al)) / this.bl);
       
 16985                     }
       
 16986                     return p;
       
 16987                 };
       
 16988                 exports.names = [
       
 16989                     'Hotine_Oblique_Mercator',
       
 16990                     'Hotine Oblique Mercator',
       
 16991                     'Hotine_Oblique_Mercator_Azimuth_Natural_Origin',
       
 16992                     'Hotine_Oblique_Mercator_Azimuth_Center',
       
 16993                     'omerc'
       
 16994                 ];
       
 16995                 return exports;
       
 16996             },
       
 16997             {
       
 16998                 '../common/adjust_lon': 5,
       
 16999                 '../common/phi2z': 16,
       
 17000                 '../common/tsfnz': 24
       
 17001             }
       
 17002         ],
       
 17003         56: [
       
 17004             function (_dereq_, module, exports) {
       
 17005                 var e0fn = _dereq_('../common/e0fn');
       
 17006                 var e1fn = _dereq_('../common/e1fn');
       
 17007                 var e2fn = _dereq_('../common/e2fn');
       
 17008                 var e3fn = _dereq_('../common/e3fn');
       
 17009                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17010                 var adjust_lat = _dereq_('../common/adjust_lat');
       
 17011                 var mlfn = _dereq_('../common/mlfn');
       
 17012                 var EPSLN = 1e-10;
       
 17013                 var gN = _dereq_('../common/gN');
       
 17014                 var MAX_ITER = 20;
       
 17015                 exports.init = function () {
       
 17016                     this.temp = this.b / this.a;
       
 17017                     this.es = 1 - Math.pow(this.temp, 2);
       
 17018                     this.e = Math.sqrt(this.es);
       
 17019                     this.e0 = e0fn(this.es);
       
 17020                     this.e1 = e1fn(this.es);
       
 17021                     this.e2 = e2fn(this.es);
       
 17022                     this.e3 = e3fn(this.es);
       
 17023                     this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
       
 17024                 };
       
 17025                 exports.forward = function (p) {
       
 17026                     var lon = p.x;
       
 17027                     var lat = p.y;
       
 17028                     var x, y, el;
       
 17029                     var dlon = adjust_lon(lon - this.long0);
       
 17030                     el = dlon * Math.sin(lat);
       
 17031                     if (this.sphere) {
       
 17032                         if (Math.abs(lat) <= EPSLN) {
       
 17033                             x = this.a * dlon;
       
 17034                             y = -1 * this.a * this.lat0;
       
 17035                         } else {
       
 17036                             x = this.a * Math.sin(el) / Math.tan(lat);
       
 17037                             y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));
       
 17038                         }
       
 17039                     } else {
       
 17040                         if (Math.abs(lat) <= EPSLN) {
       
 17041                             x = this.a * dlon;
       
 17042                             y = -1 * this.ml0;
       
 17043                         } else {
       
 17044                             var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);
       
 17045                             x = nl * Math.sin(el);
       
 17046                             y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));
       
 17047                         }
       
 17048                     }
       
 17049                     p.x = x + this.x0;
       
 17050                     p.y = y + this.y0;
       
 17051                     return p;
       
 17052                 };
       
 17053                 exports.inverse = function (p) {
       
 17054                     var lon, lat, x, y, i;
       
 17055                     var al, bl;
       
 17056                     var phi, dphi;
       
 17057                     x = p.x - this.x0;
       
 17058                     y = p.y - this.y0;
       
 17059                     if (this.sphere) {
       
 17060                         if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
       
 17061                             lon = adjust_lon(x / this.a + this.long0);
       
 17062                             lat = 0;
       
 17063                         } else {
       
 17064                             al = this.lat0 + y / this.a;
       
 17065                             bl = x * x / this.a / this.a + al * al;
       
 17066                             phi = al;
       
 17067                             var tanphi;
       
 17068                             for (i = MAX_ITER; i; --i) {
       
 17069                                 tanphi = Math.tan(phi);
       
 17070                                 dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);
       
 17071                                 phi += dphi;
       
 17072                                 if (Math.abs(dphi) <= EPSLN) {
       
 17073                                     lat = phi;
       
 17074                                     break;
       
 17075                                 }
       
 17076                             }
       
 17077                             lon = adjust_lon(this.long0 + Math.asin(x * Math.tan(phi) / this.a) / Math.sin(lat));
       
 17078                         }
       
 17079                     } else {
       
 17080                         if (Math.abs(y + this.ml0) <= EPSLN) {
       
 17081                             lat = 0;
       
 17082                             lon = adjust_lon(this.long0 + x / this.a);
       
 17083                         } else {
       
 17084                             al = (this.ml0 + y) / this.a;
       
 17085                             bl = x * x / this.a / this.a + al * al;
       
 17086                             phi = al;
       
 17087                             var cl, mln, mlnp, ma;
       
 17088                             var con;
       
 17089                             for (i = MAX_ITER; i; --i) {
       
 17090                                 con = this.e * Math.sin(phi);
       
 17091                                 cl = Math.sqrt(1 - con * con) * Math.tan(phi);
       
 17092                                 mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
       
 17093                                 mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);
       
 17094                                 ma = mln / this.a;
       
 17095                                 dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);
       
 17096                                 phi -= dphi;
       
 17097                                 if (Math.abs(dphi) <= EPSLN) {
       
 17098                                     lat = phi;
       
 17099                                     break;
       
 17100                                 }
       
 17101                             }
       
 17102                             cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
       
 17103                             lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
       
 17104                         }
       
 17105                     }
       
 17106                     p.x = lon;
       
 17107                     p.y = lat;
       
 17108                     return p;
       
 17109                 };
       
 17110                 exports.names = [
       
 17111                     'Polyconic',
       
 17112                     'poly'
       
 17113                 ];
       
 17114                 return exports;
       
 17115             },
       
 17116             {
       
 17117                 '../common/adjust_lat': 4,
       
 17118                 '../common/adjust_lon': 5,
       
 17119                 '../common/e0fn': 7,
       
 17120                 '../common/e1fn': 8,
       
 17121                 '../common/e2fn': 9,
       
 17122                 '../common/e3fn': 10,
       
 17123                 '../common/gN': 11,
       
 17124                 '../common/mlfn': 14
       
 17125             }
       
 17126         ],
       
 17127         57: [
       
 17128             function (_dereq_, module, exports) {
       
 17129                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17130                 var adjust_lat = _dereq_('../common/adjust_lat');
       
 17131                 var pj_enfn = _dereq_('../common/pj_enfn');
       
 17132                 var MAX_ITER = 20;
       
 17133                 var pj_mlfn = _dereq_('../common/pj_mlfn');
       
 17134                 var pj_inv_mlfn = _dereq_('../common/pj_inv_mlfn');
       
 17135                 var HALF_PI = Math.PI / 2;
       
 17136                 var EPSLN = 1e-10;
       
 17137                 var asinz = _dereq_('../common/asinz');
       
 17138                 exports.init = function () {
       
 17139                     if (!this.sphere) {
       
 17140                         this.en = pj_enfn(this.es);
       
 17141                     } else {
       
 17142                         this.n = 1;
       
 17143                         this.m = 0;
       
 17144                         this.es = 0;
       
 17145                         this.C_y = Math.sqrt((this.m + 1) / this.n);
       
 17146                         this.C_x = this.C_y / (this.m + 1);
       
 17147                     }
       
 17148                 };
       
 17149                 exports.forward = function (p) {
       
 17150                     var x, y;
       
 17151                     var lon = p.x;
       
 17152                     var lat = p.y;
       
 17153                     lon = adjust_lon(lon - this.long0);
       
 17154                     if (this.sphere) {
       
 17155                         if (!this.m) {
       
 17156                             lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;
       
 17157                         } else {
       
 17158                             var k = this.n * Math.sin(lat);
       
 17159                             for (var i = MAX_ITER; i; --i) {
       
 17160                                 var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));
       
 17161                                 lat -= V;
       
 17162                                 if (Math.abs(V) < EPSLN) {
       
 17163                                     break;
       
 17164                                 }
       
 17165                             }
       
 17166                         }
       
 17167                         x = this.a * this.C_x * lon * (this.m + Math.cos(lat));
       
 17168                         y = this.a * this.C_y * lat;
       
 17169                     } else {
       
 17170                         var s = Math.sin(lat);
       
 17171                         var c = Math.cos(lat);
       
 17172                         y = this.a * pj_mlfn(lat, s, c, this.en);
       
 17173                         x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);
       
 17174                     }
       
 17175                     p.x = x;
       
 17176                     p.y = y;
       
 17177                     return p;
       
 17178                 };
       
 17179                 exports.inverse = function (p) {
       
 17180                     var lat, temp, lon, s;
       
 17181                     p.x -= this.x0;
       
 17182                     lon = p.x / this.a;
       
 17183                     p.y -= this.y0;
       
 17184                     lat = p.y / this.a;
       
 17185                     if (this.sphere) {
       
 17186                         lat /= this.C_y;
       
 17187                         lon = lon / (this.C_x * (this.m + Math.cos(lat)));
       
 17188                         if (this.m) {
       
 17189                             lat = asinz((this.m * lat + Math.sin(lat)) / this.n);
       
 17190                         } else if (this.n !== 1) {
       
 17191                             lat = asinz(Math.sin(lat) / this.n);
       
 17192                         }
       
 17193                         lon = adjust_lon(lon + this.long0);
       
 17194                         lat = adjust_lat(lat);
       
 17195                     } else {
       
 17196                         lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);
       
 17197                         s = Math.abs(lat);
       
 17198                         if (s < HALF_PI) {
       
 17199                             s = Math.sin(lat);
       
 17200                             temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
       
 17201                             lon = adjust_lon(temp);
       
 17202                         } else if (s - EPSLN < HALF_PI) {
       
 17203                             lon = this.long0;
       
 17204                         }
       
 17205                     }
       
 17206                     p.x = lon;
       
 17207                     p.y = lat;
       
 17208                     return p;
       
 17209                 };
       
 17210                 exports.names = [
       
 17211                     'Sinusoidal',
       
 17212                     'sinu'
       
 17213                 ];
       
 17214                 return exports;
       
 17215             },
       
 17216             {
       
 17217                 '../common/adjust_lat': 4,
       
 17218                 '../common/adjust_lon': 5,
       
 17219                 '../common/asinz': 6,
       
 17220                 '../common/pj_enfn': 17,
       
 17221                 '../common/pj_inv_mlfn': 18,
       
 17222                 '../common/pj_mlfn': 19
       
 17223             }
       
 17224         ],
       
 17225         58: [
       
 17226             function (_dereq_, module, exports) {
       
 17227                 exports.init = function () {
       
 17228                     var phy0 = this.lat0;
       
 17229                     this.lambda0 = this.long0;
       
 17230                     var sinPhy0 = Math.sin(phy0);
       
 17231                     var semiMajorAxis = this.a;
       
 17232                     var invF = this.rf;
       
 17233                     var flattening = 1 / invF;
       
 17234                     var e2 = 2 * flattening - Math.pow(flattening, 2);
       
 17235                     var e = this.e = Math.sqrt(e2);
       
 17236                     this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2));
       
 17237                     this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4));
       
 17238                     this.b0 = Math.asin(sinPhy0 / this.alpha);
       
 17239                     var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2));
       
 17240                     var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2));
       
 17241                     var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0));
       
 17242                     this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3;
       
 17243                 };
       
 17244                 exports.forward = function (p) {
       
 17245                     var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2));
       
 17246                     var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y)));
       
 17247                     var S = -this.alpha * (Sa1 + Sa2) + this.K;
       
 17248                     var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4);
       
 17249                     var I = this.alpha * (p.x - this.lambda0);
       
 17250                     var rotI = Math.atan(Math.sin(I) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I)));
       
 17251                     var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I));
       
 17252                     p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0;
       
 17253                     p.x = this.R * rotI + this.x0;
       
 17254                     return p;
       
 17255                 };
       
 17256                 exports.inverse = function (p) {
       
 17257                     var Y = p.x - this.x0;
       
 17258                     var X = p.y - this.y0;
       
 17259                     var rotI = Y / this.R;
       
 17260                     var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4);
       
 17261                     var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI));
       
 17262                     var I = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB)));
       
 17263                     var lambda = this.lambda0 + I / this.alpha;
       
 17264                     var S = 0;
       
 17265                     var phy = b;
       
 17266                     var prevPhy = -1000;
       
 17267                     var iteration = 0;
       
 17268                     while (Math.abs(phy - prevPhy) > 1e-7) {
       
 17269                         if (++iteration > 20) {
       
 17270                             return;
       
 17271                         }
       
 17272                         S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2));
       
 17273                         prevPhy = phy;
       
 17274                         phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2;
       
 17275                     }
       
 17276                     p.x = lambda;
       
 17277                     p.y = phy;
       
 17278                     return p;
       
 17279                 };
       
 17280                 exports.names = ['somerc'];
       
 17281                 return exports;
       
 17282             },
       
 17283             {}
       
 17284         ],
       
 17285         59: [
       
 17286             function (_dereq_, module, exports) {
       
 17287                 var HALF_PI = Math.PI / 2;
       
 17288                 var EPSLN = 1e-10;
       
 17289                 var sign = _dereq_('../common/sign');
       
 17290                 var msfnz = _dereq_('../common/msfnz');
       
 17291                 var tsfnz = _dereq_('../common/tsfnz');
       
 17292                 var phi2z = _dereq_('../common/phi2z');
       
 17293                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17294                 exports.ssfn_ = function (phit, sinphi, eccen) {
       
 17295                     sinphi *= eccen;
       
 17296                     return Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen);
       
 17297                 };
       
 17298                 exports.init = function () {
       
 17299                     this.coslat0 = Math.cos(this.lat0);
       
 17300                     this.sinlat0 = Math.sin(this.lat0);
       
 17301                     if (this.sphere) {
       
 17302                         if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
       
 17303                             this.k0 = 0.5 * (1 + sign(this.lat0) * Math.sin(this.lat_ts));
       
 17304                         }
       
 17305                     } else {
       
 17306                         if (Math.abs(this.coslat0) <= EPSLN) {
       
 17307                             if (this.lat0 > 0) {
       
 17308                                 this.con = 1;
       
 17309                             } else {
       
 17310                                 this.con = -1;
       
 17311                             }
       
 17312                         }
       
 17313                         this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));
       
 17314                         if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
       
 17315                             this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));
       
 17316                         }
       
 17317                         this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
       
 17318                         this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
       
 17319                         this.cosX0 = Math.cos(this.X0);
       
 17320                         this.sinX0 = Math.sin(this.X0);
       
 17321                     }
       
 17322                 };
       
 17323                 exports.forward = function (p) {
       
 17324                     var lon = p.x;
       
 17325                     var lat = p.y;
       
 17326                     var sinlat = Math.sin(lat);
       
 17327                     var coslat = Math.cos(lat);
       
 17328                     var A, X, sinX, cosX, ts, rh;
       
 17329                     var dlon = adjust_lon(lon - this.long0);
       
 17330                     if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {
       
 17331                         p.x = NaN;
       
 17332                         p.y = NaN;
       
 17333                         return p;
       
 17334                     }
       
 17335                     if (this.sphere) {
       
 17336                         A = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon));
       
 17337                         p.x = this.a * A * coslat * Math.sin(dlon) + this.x0;
       
 17338                         p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
       
 17339                         return p;
       
 17340                     } else {
       
 17341                         X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;
       
 17342                         cosX = Math.cos(X);
       
 17343                         sinX = Math.sin(X);
       
 17344                         if (Math.abs(this.coslat0) <= EPSLN) {
       
 17345                             ts = tsfnz(this.e, lat * this.con, this.con * sinlat);
       
 17346                             rh = 2 * this.a * this.k0 * ts / this.cons;
       
 17347                             p.x = this.x0 + rh * Math.sin(lon - this.long0);
       
 17348                             p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0);
       
 17349                             return p;
       
 17350                         } else if (Math.abs(this.sinlat0) < EPSLN) {
       
 17351                             A = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon));
       
 17352                             p.y = A * sinX;
       
 17353                         } else {
       
 17354                             A = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon)));
       
 17355                             p.y = A * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0;
       
 17356                         }
       
 17357                         p.x = A * cosX * Math.sin(dlon) + this.x0;
       
 17358                     }
       
 17359                     return p;
       
 17360                 };
       
 17361                 exports.inverse = function (p) {
       
 17362                     p.x -= this.x0;
       
 17363                     p.y -= this.y0;
       
 17364                     var lon, lat, ts, ce, Chi;
       
 17365                     var rh = Math.sqrt(p.x * p.x + p.y * p.y);
       
 17366                     if (this.sphere) {
       
 17367                         var c = 2 * Math.atan(rh / (0.5 * this.a * this.k0));
       
 17368                         lon = this.long0;
       
 17369                         lat = this.lat0;
       
 17370                         if (rh <= EPSLN) {
       
 17371                             p.x = lon;
       
 17372                             p.y = lat;
       
 17373                             return p;
       
 17374                         }
       
 17375                         lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);
       
 17376                         if (Math.abs(this.coslat0) < EPSLN) {
       
 17377                             if (this.lat0 > 0) {
       
 17378                                 lon = adjust_lon(this.long0 + Math.atan2(p.x, -1 * p.y));
       
 17379                             } else {
       
 17380                                 lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
       
 17381                             }
       
 17382                         } else {
       
 17383                             lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));
       
 17384                         }
       
 17385                         p.x = lon;
       
 17386                         p.y = lat;
       
 17387                         return p;
       
 17388                     } else {
       
 17389                         if (Math.abs(this.coslat0) <= EPSLN) {
       
 17390                             if (rh <= EPSLN) {
       
 17391                                 lat = this.lat0;
       
 17392                                 lon = this.long0;
       
 17393                                 p.x = lon;
       
 17394                                 p.y = lat;
       
 17395                                 return p;
       
 17396                             }
       
 17397                             p.x *= this.con;
       
 17398                             p.y *= this.con;
       
 17399                             ts = rh * this.cons / (2 * this.a * this.k0);
       
 17400                             lat = this.con * phi2z(this.e, ts);
       
 17401                             lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, -1 * p.y));
       
 17402                         } else {
       
 17403                             ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));
       
 17404                             lon = this.long0;
       
 17405                             if (rh <= EPSLN) {
       
 17406                                 Chi = this.X0;
       
 17407                             } else {
       
 17408                                 Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);
       
 17409                                 lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));
       
 17410                             }
       
 17411                             lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));
       
 17412                         }
       
 17413                     }
       
 17414                     p.x = lon;
       
 17415                     p.y = lat;
       
 17416                     return p;
       
 17417                 };
       
 17418                 exports.names = ['stere'];
       
 17419                 return exports;
       
 17420             },
       
 17421             {
       
 17422                 '../common/adjust_lon': 5,
       
 17423                 '../common/msfnz': 15,
       
 17424                 '../common/phi2z': 16,
       
 17425                 '../common/sign': 21,
       
 17426                 '../common/tsfnz': 24
       
 17427             }
       
 17428         ],
       
 17429         60: [
       
 17430             function (_dereq_, module, exports) {
       
 17431                 var gauss = _dereq_('./gauss');
       
 17432                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17433                 exports.init = function () {
       
 17434                     gauss.init.apply(this);
       
 17435                     if (!this.rc) {
       
 17436                         return;
       
 17437                     }
       
 17438                     this.sinc0 = Math.sin(this.phic0);
       
 17439                     this.cosc0 = Math.cos(this.phic0);
       
 17440                     this.R2 = 2 * this.rc;
       
 17441                     if (!this.title) {
       
 17442                         this.title = 'Oblique Stereographic Alternative';
       
 17443                     }
       
 17444                 };
       
 17445                 exports.forward = function (p) {
       
 17446                     var sinc, cosc, cosl, k;
       
 17447                     p.x = adjust_lon(p.x - this.long0);
       
 17448                     gauss.forward.apply(this, [p]);
       
 17449                     sinc = Math.sin(p.y);
       
 17450                     cosc = Math.cos(p.y);
       
 17451                     cosl = Math.cos(p.x);
       
 17452                     k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl);
       
 17453                     p.x = k * cosc * Math.sin(p.x);
       
 17454                     p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl);
       
 17455                     p.x = this.a * p.x + this.x0;
       
 17456                     p.y = this.a * p.y + this.y0;
       
 17457                     return p;
       
 17458                 };
       
 17459                 exports.inverse = function (p) {
       
 17460                     var sinc, cosc, lon, lat, rho;
       
 17461                     p.x = (p.x - this.x0) / this.a;
       
 17462                     p.y = (p.y - this.y0) / this.a;
       
 17463                     p.x /= this.k0;
       
 17464                     p.y /= this.k0;
       
 17465                     if (rho = Math.sqrt(p.x * p.x + p.y * p.y)) {
       
 17466                         var c = 2 * Math.atan2(rho, this.R2);
       
 17467                         sinc = Math.sin(c);
       
 17468                         cosc = Math.cos(c);
       
 17469                         lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);
       
 17470                         lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc);
       
 17471                     } else {
       
 17472                         lat = this.phic0;
       
 17473                         lon = 0;
       
 17474                     }
       
 17475                     p.x = lon;
       
 17476                     p.y = lat;
       
 17477                     gauss.inverse.apply(this, [p]);
       
 17478                     p.x = adjust_lon(p.x + this.long0);
       
 17479                     return p;
       
 17480                 };
       
 17481                 exports.names = [
       
 17482                     'Stereographic_North_Pole',
       
 17483                     'Oblique_Stereographic',
       
 17484                     'Polar_Stereographic',
       
 17485                     'sterea',
       
 17486                     'Oblique Stereographic Alternative'
       
 17487                 ];
       
 17488                 return exports;
       
 17489             },
       
 17490             {
       
 17491                 '../common/adjust_lon': 5,
       
 17492                 './gauss': 45
       
 17493             }
       
 17494         ],
       
 17495         61: [
       
 17496             function (_dereq_, module, exports) {
       
 17497                 var e0fn = _dereq_('../common/e0fn');
       
 17498                 var e1fn = _dereq_('../common/e1fn');
       
 17499                 var e2fn = _dereq_('../common/e2fn');
       
 17500                 var e3fn = _dereq_('../common/e3fn');
       
 17501                 var mlfn = _dereq_('../common/mlfn');
       
 17502                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17503                 var HALF_PI = Math.PI / 2;
       
 17504                 var EPSLN = 1e-10;
       
 17505                 var sign = _dereq_('../common/sign');
       
 17506                 var asinz = _dereq_('../common/asinz');
       
 17507                 exports.init = function () {
       
 17508                     this.e0 = e0fn(this.es);
       
 17509                     this.e1 = e1fn(this.es);
       
 17510                     this.e2 = e2fn(this.es);
       
 17511                     this.e3 = e3fn(this.es);
       
 17512                     this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
       
 17513                 };
       
 17514                 exports.forward = function (p) {
       
 17515                     var lon = p.x;
       
 17516                     var lat = p.y;
       
 17517                     var delta_lon = adjust_lon(lon - this.long0);
       
 17518                     var con;
       
 17519                     var x, y;
       
 17520                     var sin_phi = Math.sin(lat);
       
 17521                     var cos_phi = Math.cos(lat);
       
 17522                     if (this.sphere) {
       
 17523                         var b = cos_phi * Math.sin(delta_lon);
       
 17524                         if (Math.abs(Math.abs(b) - 1) < 1e-10) {
       
 17525                             return 93;
       
 17526                         } else {
       
 17527                             x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b));
       
 17528                             con = Math.acos(cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - b * b));
       
 17529                             if (lat < 0) {
       
 17530                                 con = -con;
       
 17531                             }
       
 17532                             y = this.a * this.k0 * (con - this.lat0);
       
 17533                         }
       
 17534                     } else {
       
 17535                         var al = cos_phi * delta_lon;
       
 17536                         var als = Math.pow(al, 2);
       
 17537                         var c = this.ep2 * Math.pow(cos_phi, 2);
       
 17538                         var tq = Math.tan(lat);
       
 17539                         var t = Math.pow(tq, 2);
       
 17540                         con = 1 - this.es * Math.pow(sin_phi, 2);
       
 17541                         var n = this.a / Math.sqrt(con);
       
 17542                         var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat);
       
 17543                         x = this.k0 * n * al * (1 + als / 6 * (1 - t + c + als / 20 * (5 - 18 * t + Math.pow(t, 2) + 72 * c - 58 * this.ep2))) + this.x0;
       
 17544                         y = this.k0 * (ml - this.ml0 + n * tq * (als * (0.5 + als / 24 * (5 - t + 9 * c + 4 * Math.pow(c, 2) + als / 30 * (61 - 58 * t + Math.pow(t, 2) + 600 * c - 330 * this.ep2))))) + this.y0;
       
 17545                     }
       
 17546                     p.x = x;
       
 17547                     p.y = y;
       
 17548                     return p;
       
 17549                 };
       
 17550                 exports.inverse = function (p) {
       
 17551                     var con, phi;
       
 17552                     var delta_phi;
       
 17553                     var i;
       
 17554                     var max_iter = 6;
       
 17555                     var lat, lon;
       
 17556                     if (this.sphere) {
       
 17557                         var f = Math.exp(p.x / (this.a * this.k0));
       
 17558                         var g = 0.5 * (f - 1 / f);
       
 17559                         var temp = this.lat0 + p.y / (this.a * this.k0);
       
 17560                         var h = Math.cos(temp);
       
 17561                         con = Math.sqrt((1 - h * h) / (1 + g * g));
       
 17562                         lat = asinz(con);
       
 17563                         if (temp < 0) {
       
 17564                             lat = -lat;
       
 17565                         }
       
 17566                         if (g === 0 && h === 0) {
       
 17567                             lon = this.long0;
       
 17568                         } else {
       
 17569                             lon = adjust_lon(Math.atan2(g, h) + this.long0);
       
 17570                         }
       
 17571                     } else {
       
 17572                         var x = p.x - this.x0;
       
 17573                         var y = p.y - this.y0;
       
 17574                         con = (this.ml0 + y / this.k0) / this.a;
       
 17575                         phi = con;
       
 17576                         for (i = 0; true; i++) {
       
 17577                             delta_phi = (con + this.e1 * Math.sin(2 * phi) - this.e2 * Math.sin(4 * phi) + this.e3 * Math.sin(6 * phi)) / this.e0 - phi;
       
 17578                             phi += delta_phi;
       
 17579                             if (Math.abs(delta_phi) <= EPSLN) {
       
 17580                                 break;
       
 17581                             }
       
 17582                             if (i >= max_iter) {
       
 17583                                 return 95;
       
 17584                             }
       
 17585                         }
       
 17586                         if (Math.abs(phi) < HALF_PI) {
       
 17587                             var sin_phi = Math.sin(phi);
       
 17588                             var cos_phi = Math.cos(phi);
       
 17589                             var tan_phi = Math.tan(phi);
       
 17590                             var c = this.ep2 * Math.pow(cos_phi, 2);
       
 17591                             var cs = Math.pow(c, 2);
       
 17592                             var t = Math.pow(tan_phi, 2);
       
 17593                             var ts = Math.pow(t, 2);
       
 17594                             con = 1 - this.es * Math.pow(sin_phi, 2);
       
 17595                             var n = this.a / Math.sqrt(con);
       
 17596                             var r = n * (1 - this.es) / con;
       
 17597                             var d = x / (n * this.k0);
       
 17598                             var ds = Math.pow(d, 2);
       
 17599                             lat = phi - n * tan_phi * ds / r * (0.5 - ds / 24 * (5 + 3 * t + 10 * c - 4 * cs - 9 * this.ep2 - ds / 30 * (61 + 90 * t + 298 * c + 45 * ts - 252 * this.ep2 - 3 * cs)));
       
 17600                             lon = adjust_lon(this.long0 + d * (1 - ds / 6 * (1 + 2 * t + c - ds / 20 * (5 - 2 * c + 28 * t - 3 * cs + 8 * this.ep2 + 24 * ts))) / cos_phi);
       
 17601                         } else {
       
 17602                             lat = HALF_PI * sign(y);
       
 17603                             lon = this.long0;
       
 17604                         }
       
 17605                     }
       
 17606                     p.x = lon;
       
 17607                     p.y = lat;
       
 17608                     return p;
       
 17609                 };
       
 17610                 exports.names = [
       
 17611                     'Transverse_Mercator',
       
 17612                     'Transverse Mercator',
       
 17613                     'tmerc'
       
 17614                 ];
       
 17615                 return exports;
       
 17616             },
       
 17617             {
       
 17618                 '../common/adjust_lon': 5,
       
 17619                 '../common/asinz': 6,
       
 17620                 '../common/e0fn': 7,
       
 17621                 '../common/e1fn': 8,
       
 17622                 '../common/e2fn': 9,
       
 17623                 '../common/e3fn': 10,
       
 17624                 '../common/mlfn': 14,
       
 17625                 '../common/sign': 21
       
 17626             }
       
 17627         ],
       
 17628         62: [
       
 17629             function (_dereq_, module, exports) {
       
 17630                 var D2R = 0.017453292519943295;
       
 17631                 var tmerc = _dereq_('./tmerc');
       
 17632                 exports.dependsOn = 'tmerc';
       
 17633                 exports.init = function () {
       
 17634                     if (!this.zone) {
       
 17635                         return;
       
 17636                     }
       
 17637                     this.lat0 = 0;
       
 17638                     this.long0 = (6 * Math.abs(this.zone) - 183) * D2R;
       
 17639                     this.x0 = 500000;
       
 17640                     this.y0 = this.utmSouth ? 10000000 : 0;
       
 17641                     this.k0 = 0.9996;
       
 17642                     tmerc.init.apply(this);
       
 17643                     this.forward = tmerc.forward;
       
 17644                     this.inverse = tmerc.inverse;
       
 17645                 };
       
 17646                 exports.names = [
       
 17647                     'Universal Transverse Mercator System',
       
 17648                     'utm'
       
 17649                 ];
       
 17650                 return exports;
       
 17651             },
       
 17652             { './tmerc': 61 }
       
 17653         ],
       
 17654         63: [
       
 17655             function (_dereq_, module, exports) {
       
 17656                 var adjust_lon = _dereq_('../common/adjust_lon');
       
 17657                 var HALF_PI = Math.PI / 2;
       
 17658                 var EPSLN = 1e-10;
       
 17659                 var asinz = _dereq_('../common/asinz');
       
 17660                 exports.init = function () {
       
 17661                     this.R = this.a;
       
 17662                 };
       
 17663                 exports.forward = function (p) {
       
 17664                     var lon = p.x;
       
 17665                     var lat = p.y;
       
 17666                     var dlon = adjust_lon(lon - this.long0);
       
 17667                     var x, y;
       
 17668                     if (Math.abs(lat) <= EPSLN) {
       
 17669                         x = this.x0 + this.R * dlon;
       
 17670                         y = this.y0;
       
 17671                     }
       
 17672                     var theta = asinz(2 * Math.abs(lat / Math.PI));
       
 17673                     if (Math.abs(dlon) <= EPSLN || Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
       
 17674                         x = this.x0;
       
 17675                         if (lat >= 0) {
       
 17676                             y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta);
       
 17677                         } else {
       
 17678                             y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta);
       
 17679                         }
       
 17680                     }
       
 17681                     var al = 0.5 * Math.abs(Math.PI / dlon - dlon / Math.PI);
       
 17682                     var asq = al * al;
       
 17683                     var sinth = Math.sin(theta);
       
 17684                     var costh = Math.cos(theta);
       
 17685                     var g = costh / (sinth + costh - 1);
       
 17686                     var gsq = g * g;
       
 17687                     var m = g * (2 / sinth - 1);
       
 17688                     var msq = m * m;
       
 17689                     var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq);
       
 17690                     if (dlon < 0) {
       
 17691                         con = -con;
       
 17692                     }
       
 17693                     x = this.x0 + con;
       
 17694                     var q = asq + g;
       
 17695                     con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq);
       
 17696                     if (lat >= 0) {
       
 17697                         y = this.y0 + con;
       
 17698                     } else {
       
 17699                         y = this.y0 - con;
       
 17700                     }
       
 17701                     p.x = x;
       
 17702                     p.y = y;
       
 17703                     return p;
       
 17704                 };
       
 17705                 exports.inverse = function (p) {
       
 17706                     var lon, lat;
       
 17707                     var xx, yy, xys, c1, c2, c3;
       
 17708                     var a1;
       
 17709                     var m1;
       
 17710                     var con;
       
 17711                     var th1;
       
 17712                     var d;
       
 17713                     p.x -= this.x0;
       
 17714                     p.y -= this.y0;
       
 17715                     con = Math.PI * this.R;
       
 17716                     xx = p.x / con;
       
 17717                     yy = p.y / con;
       
 17718                     xys = xx * xx + yy * yy;
       
 17719                     c1 = -Math.abs(yy) * (1 + xys);
       
 17720                     c2 = c1 - 2 * yy * yy + xx * xx;
       
 17721                     c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys;
       
 17722                     d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27;
       
 17723                     a1 = (c1 - c2 * c2 / 3 / c3) / c3;
       
 17724                     m1 = 2 * Math.sqrt(-a1 / 3);
       
 17725                     con = 3 * d / a1 / m1;
       
 17726                     if (Math.abs(con) > 1) {
       
 17727                         if (con >= 0) {
       
 17728                             con = 1;
       
 17729                         } else {
       
 17730                             con = -1;
       
 17731                         }
       
 17732                     }
       
 17733                     th1 = Math.acos(con) / 3;
       
 17734                     if (p.y >= 0) {
       
 17735                         lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
       
 17736                     } else {
       
 17737                         lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
       
 17738                     }
       
 17739                     if (Math.abs(xx) < EPSLN) {
       
 17740                         lon = this.long0;
       
 17741                     } else {
       
 17742                         lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);
       
 17743                     }
       
 17744                     p.x = lon;
       
 17745                     p.y = lat;
       
 17746                     return p;
       
 17747                 };
       
 17748                 exports.names = [
       
 17749                     'Van_der_Grinten_I',
       
 17750                     'VanDerGrinten',
       
 17751                     'vandg'
       
 17752                 ];
       
 17753                 return exports;
       
 17754             },
       
 17755             {
       
 17756                 '../common/adjust_lon': 5,
       
 17757                 '../common/asinz': 6
       
 17758             }
       
 17759         ],
       
 17760         64: [
       
 17761             function (_dereq_, module, exports) {
       
 17762                 var D2R = 0.017453292519943295;
       
 17763                 var R2D = 57.29577951308232;
       
 17764                 var PJD_3PARAM = 1;
       
 17765                 var PJD_7PARAM = 2;
       
 17766                 var datum_transform = _dereq_('./datum_transform');
       
 17767                 var adjust_axis = _dereq_('./adjust_axis');
       
 17768                 var proj = _dereq_('./Proj');
       
 17769                 var toPoint = _dereq_('./common/toPoint');
       
 17770                 module.exports = function transform(source, dest, point) {
       
 17771                     var wgs84;
       
 17772                     if (Array.isArray(point)) {
       
 17773                         point = toPoint(point);
       
 17774                     }
       
 17775                     function checkNotWGS(source, dest) {
       
 17776                         return (source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM) && dest.datumCode !== 'WGS84';
       
 17777                     }
       
 17778                     if (source.datum && dest.datum && (checkNotWGS(source, dest) || checkNotWGS(dest, source))) {
       
 17779                         wgs84 = new proj('WGS84');
       
 17780                         transform(source, wgs84, point);
       
 17781                         source = wgs84;
       
 17782                     }
       
 17783                     if (source.axis !== 'enu') {
       
 17784                         adjust_axis(source, false, point);
       
 17785                     }
       
 17786                     if (source.projName === 'longlat') {
       
 17787                         point.x *= D2R;
       
 17788                         point.y *= D2R;
       
 17789                     } else {
       
 17790                         if (source.to_meter) {
       
 17791                             point.x *= source.to_meter;
       
 17792                             point.y *= source.to_meter;
       
 17793                         }
       
 17794                         source.inverse(point);
       
 17795                     }
       
 17796                     if (source.from_greenwich) {
       
 17797                         point.x += source.from_greenwich;
       
 17798                     }
       
 17799                     point = datum_transform(source.datum, dest.datum, point);
       
 17800                     if (dest.from_greenwich) {
       
 17801                         point.x -= dest.from_greenwich;
       
 17802                     }
       
 17803                     if (dest.projName === 'longlat') {
       
 17804                         point.x *= R2D;
       
 17805                         point.y *= R2D;
       
 17806                     } else {
       
 17807                         dest.forward(point);
       
 17808                         if (dest.to_meter) {
       
 17809                             point.x /= dest.to_meter;
       
 17810                             point.y /= dest.to_meter;
       
 17811                         }
       
 17812                     }
       
 17813                     if (dest.axis !== 'enu') {
       
 17814                         adjust_axis(dest, true, point);
       
 17815                     }
       
 17816                     return point;
       
 17817                 };
       
 17818                 return exports;
       
 17819             },
       
 17820             {
       
 17821                 './Proj': 2,
       
 17822                 './adjust_axis': 3,
       
 17823                 './common/toPoint': 23,
       
 17824                 './datum_transform': 30
       
 17825             }
       
 17826         ],
       
 17827         65: [
       
 17828             function (_dereq_, module, exports) {
       
 17829                 var D2R = 0.017453292519943295;
       
 17830                 var extend = _dereq_('./extend');
       
 17831                 function mapit(obj, key, v) {
       
 17832                     obj[key] = v.map(function (aa) {
       
 17833                         var o = {};
       
 17834                         sExpr(aa, o);
       
 17835                         return o;
       
 17836                     }).reduce(function (a, b) {
       
 17837                         return extend(a, b);
       
 17838                     }, {});
       
 17839                 }
       
 17840                 function sExpr(v, obj) {
       
 17841                     var key;
       
 17842                     if (!Array.isArray(v)) {
       
 17843                         obj[v] = true;
       
 17844                         return;
       
 17845                     } else {
       
 17846                         key = v.shift();
       
 17847                         if (key === 'PARAMETER') {
       
 17848                             key = v.shift();
       
 17849                         }
       
 17850                         if (v.length === 1) {
       
 17851                             if (Array.isArray(v[0])) {
       
 17852                                 obj[key] = {};
       
 17853                                 sExpr(v[0], obj[key]);
       
 17854                             } else {
       
 17855                                 obj[key] = v[0];
       
 17856                             }
       
 17857                         } else if (!v.length) {
       
 17858                             obj[key] = true;
       
 17859                         } else if (key === 'TOWGS84') {
       
 17860                             obj[key] = v;
       
 17861                         } else {
       
 17862                             obj[key] = {};
       
 17863                             if ([
       
 17864                                     'UNIT',
       
 17865                                     'PRIMEM',
       
 17866                                     'VERT_DATUM'
       
 17867                                 ].indexOf(key) > -1) {
       
 17868                                 obj[key] = {
       
 17869                                     name: v[0].toLowerCase(),
       
 17870                                     convert: v[1]
       
 17871                                 };
       
 17872                                 if (v.length === 3) {
       
 17873                                     obj[key].auth = v[2];
       
 17874                                 }
       
 17875                             } else if (key === 'SPHEROID') {
       
 17876                                 obj[key] = {
       
 17877                                     name: v[0],
       
 17878                                     a: v[1],
       
 17879                                     rf: v[2]
       
 17880                                 };
       
 17881                                 if (v.length === 4) {
       
 17882                                     obj[key].auth = v[3];
       
 17883                                 }
       
 17884                             } else if ([
       
 17885                                     'GEOGCS',
       
 17886                                     'GEOCCS',
       
 17887                                     'DATUM',
       
 17888                                     'VERT_CS',
       
 17889                                     'COMPD_CS',
       
 17890                                     'LOCAL_CS',
       
 17891                                     'FITTED_CS',
       
 17892                                     'LOCAL_DATUM'
       
 17893                                 ].indexOf(key) > -1) {
       
 17894                                 v[0] = [
       
 17895                                     'name',
       
 17896                                     v[0]
       
 17897                                 ];
       
 17898                                 mapit(obj, key, v);
       
 17899                             } else if (v.every(function (aa) {
       
 17900                                     return Array.isArray(aa);
       
 17901                                 })) {
       
 17902                                 mapit(obj, key, v);
       
 17903                             } else {
       
 17904                                 sExpr(v, obj[key]);
       
 17905                             }
       
 17906                         }
       
 17907                     }
       
 17908                 }
       
 17909                 function rename(obj, params) {
       
 17910                     var outName = params[0];
       
 17911                     var inName = params[1];
       
 17912                     if (!(outName in obj) && inName in obj) {
       
 17913                         obj[outName] = obj[inName];
       
 17914                         if (params.length === 3) {
       
 17915                             obj[outName] = params[2](obj[outName]);
       
 17916                         }
       
 17917                     }
       
 17918                 }
       
 17919                 function d2r(input) {
       
 17920                     return input * D2R;
       
 17921                 }
       
 17922                 function cleanWKT(wkt) {
       
 17923                     if (wkt.type === 'GEOGCS') {
       
 17924                         wkt.projName = 'longlat';
       
 17925                     } else if (wkt.type === 'LOCAL_CS') {
       
 17926                         wkt.projName = 'identity';
       
 17927                         wkt.local = true;
       
 17928                     } else {
       
 17929                         if (typeof wkt.PROJECTION === 'object') {
       
 17930                             wkt.projName = Object.keys(wkt.PROJECTION)[0];
       
 17931                         } else {
       
 17932                             wkt.projName = wkt.PROJECTION;
       
 17933                         }
       
 17934                     }
       
 17935                     if (wkt.UNIT) {
       
 17936                         wkt.units = wkt.UNIT.name.toLowerCase();
       
 17937                         if (wkt.units === 'metre') {
       
 17938                             wkt.units = 'meter';
       
 17939                         }
       
 17940                         if (wkt.UNIT.convert) {
       
 17941                             wkt.to_meter = parseFloat(wkt.UNIT.convert, 10);
       
 17942                         }
       
 17943                     }
       
 17944                     if (wkt.GEOGCS) {
       
 17945                         if (wkt.GEOGCS.DATUM) {
       
 17946                             wkt.datumCode = wkt.GEOGCS.DATUM.name.toLowerCase();
       
 17947                         } else {
       
 17948                             wkt.datumCode = wkt.GEOGCS.name.toLowerCase();
       
 17949                         }
       
 17950                         if (wkt.datumCode.slice(0, 2) === 'd_') {
       
 17951                             wkt.datumCode = wkt.datumCode.slice(2);
       
 17952                         }
       
 17953                         if (wkt.datumCode === 'new_zealand_geodetic_datum_1949' || wkt.datumCode === 'new_zealand_1949') {
       
 17954                             wkt.datumCode = 'nzgd49';
       
 17955                         }
       
 17956                         if (wkt.datumCode === 'wgs_1984') {
       
 17957                             if (wkt.PROJECTION === 'Mercator_Auxiliary_Sphere') {
       
 17958                                 wkt.sphere = true;
       
 17959                             }
       
 17960                             wkt.datumCode = 'wgs84';
       
 17961                         }
       
 17962                         if (wkt.datumCode.slice(-6) === '_ferro') {
       
 17963                             wkt.datumCode = wkt.datumCode.slice(0, -6);
       
 17964                         }
       
 17965                         if (wkt.datumCode.slice(-8) === '_jakarta') {
       
 17966                             wkt.datumCode = wkt.datumCode.slice(0, -8);
       
 17967                         }
       
 17968                         if (~wkt.datumCode.indexOf('belge')) {
       
 17969                             wkt.datumCode = 'rnb72';
       
 17970                         }
       
 17971                         if (wkt.GEOGCS.DATUM && wkt.GEOGCS.DATUM.SPHEROID) {
       
 17972                             wkt.ellps = wkt.GEOGCS.DATUM.SPHEROID.name.replace('_19', '').replace(/[Cc]larke\_18/, 'clrk');
       
 17973                             if (wkt.ellps.toLowerCase().slice(0, 13) === 'international') {
       
 17974                                 wkt.ellps = 'intl';
       
 17975                             }
       
 17976                             wkt.a = wkt.GEOGCS.DATUM.SPHEROID.a;
       
 17977                             wkt.rf = parseFloat(wkt.GEOGCS.DATUM.SPHEROID.rf, 10);
       
 17978                         }
       
 17979                         if (~wkt.datumCode.indexOf('osgb_1936')) {
       
 17980                             wkt.datumCode = 'osgb36';
       
 17981                         }
       
 17982                     }
       
 17983                     if (wkt.b && !isFinite(wkt.b)) {
       
 17984                         wkt.b = wkt.a;
       
 17985                     }
       
 17986                     function toMeter(input) {
       
 17987                         var ratio = wkt.to_meter || 1;
       
 17988                         return parseFloat(input, 10) * ratio;
       
 17989                     }
       
 17990                     var renamer = function (a) {
       
 17991                         return rename(wkt, a);
       
 17992                     };
       
 17993                     var list = [
       
 17994                         [
       
 17995                             'standard_parallel_1',
       
 17996                             'Standard_Parallel_1'
       
 17997                         ],
       
 17998                         [
       
 17999                             'standard_parallel_2',
       
 18000                             'Standard_Parallel_2'
       
 18001                         ],
       
 18002                         [
       
 18003                             'false_easting',
       
 18004                             'False_Easting'
       
 18005                         ],
       
 18006                         [
       
 18007                             'false_northing',
       
 18008                             'False_Northing'
       
 18009                         ],
       
 18010                         [
       
 18011                             'central_meridian',
       
 18012                             'Central_Meridian'
       
 18013                         ],
       
 18014                         [
       
 18015                             'latitude_of_origin',
       
 18016                             'Latitude_Of_Origin'
       
 18017                         ],
       
 18018                         [
       
 18019                             'scale_factor',
       
 18020                             'Scale_Factor'
       
 18021                         ],
       
 18022                         [
       
 18023                             'k0',
       
 18024                             'scale_factor'
       
 18025                         ],
       
 18026                         [
       
 18027                             'latitude_of_center',
       
 18028                             'Latitude_of_center'
       
 18029                         ],
       
 18030                         [
       
 18031                             'lat0',
       
 18032                             'latitude_of_center',
       
 18033                             d2r
       
 18034                         ],
       
 18035                         [
       
 18036                             'longitude_of_center',
       
 18037                             'Longitude_Of_Center'
       
 18038                         ],
       
 18039                         [
       
 18040                             'longc',
       
 18041                             'longitude_of_center',
       
 18042                             d2r
       
 18043                         ],
       
 18044                         [
       
 18045                             'x0',
       
 18046                             'false_easting',
       
 18047                             toMeter
       
 18048                         ],
       
 18049                         [
       
 18050                             'y0',
       
 18051                             'false_northing',
       
 18052                             toMeter
       
 18053                         ],
       
 18054                         [
       
 18055                             'long0',
       
 18056                             'central_meridian',
       
 18057                             d2r
       
 18058                         ],
       
 18059                         [
       
 18060                             'lat0',
       
 18061                             'latitude_of_origin',
       
 18062                             d2r
       
 18063                         ],
       
 18064                         [
       
 18065                             'lat0',
       
 18066                             'standard_parallel_1',
       
 18067                             d2r
       
 18068                         ],
       
 18069                         [
       
 18070                             'lat1',
       
 18071                             'standard_parallel_1',
       
 18072                             d2r
       
 18073                         ],
       
 18074                         [
       
 18075                             'lat2',
       
 18076                             'standard_parallel_2',
       
 18077                             d2r
       
 18078                         ],
       
 18079                         [
       
 18080                             'alpha',
       
 18081                             'azimuth',
       
 18082                             d2r
       
 18083                         ],
       
 18084                         [
       
 18085                             'srsCode',
       
 18086                             'name'
       
 18087                         ]
       
 18088                     ];
       
 18089                     list.forEach(renamer);
       
 18090                     if (!wkt.long0 && wkt.longc && (wkt.PROJECTION === 'Albers_Conic_Equal_Area' || wkt.PROJECTION === 'Lambert_Azimuthal_Equal_Area')) {
       
 18091                         wkt.long0 = wkt.longc;
       
 18092                     }
       
 18093                 }
       
 18094                 module.exports = function (wkt, self) {
       
 18095                     var lisp = JSON.parse((',' + wkt).replace(/\s*\,\s*([A-Z_0-9]+?)(\[)/g, ',["$1",').slice(1).replace(/\s*\,\s*([A-Z_0-9]+?)\]/g, ',"$1"]'));
       
 18096                     var type = lisp.shift();
       
 18097                     var name = lisp.shift();
       
 18098                     lisp.unshift([
       
 18099                         'name',
       
 18100                         name
       
 18101                     ]);
       
 18102                     lisp.unshift([
       
 18103                         'type',
       
 18104                         type
       
 18105                     ]);
       
 18106                     lisp.unshift('output');
       
 18107                     var obj = {};
       
 18108                     sExpr(lisp, obj);
       
 18109                     cleanWKT(obj.output);
       
 18110                     return extend(self, obj.output);
       
 18111                 };
       
 18112                 return exports;
       
 18113             },
       
 18114             { './extend': 33 }
       
 18115         ],
       
 18116         66: [
       
 18117             function (_dereq_, module, exports) {
       
 18118                 var NUM_100K_SETS = 6;
       
 18119                 var SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';
       
 18120                 var SET_ORIGIN_ROW_LETTERS = 'AFAFAF';
       
 18121                 var A = 65;
       
 18122                 var I = 73;
       
 18123                 var O = 79;
       
 18124                 var V = 86;
       
 18125                 var Z = 90;
       
 18126                 exports.forward = function (ll, accuracy) {
       
 18127                     accuracy = accuracy || 5;
       
 18128                     return encode(LLtoUTM({
       
 18129                         lat: ll[1],
       
 18130                         lon: ll[0]
       
 18131                     }), accuracy);
       
 18132                 };
       
 18133                 exports.inverse = function (mgrs) {
       
 18134                     var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
       
 18135                     return [
       
 18136                         bbox.left,
       
 18137                         bbox.bottom,
       
 18138                         bbox.right,
       
 18139                         bbox.top
       
 18140                     ];
       
 18141                 };
       
 18142                 exports.toPoint = function (mgrsStr) {
       
 18143                     var llbbox = exports.inverse(mgrsStr);
       
 18144                     return [
       
 18145                         (llbbox[2] + llbbox[0]) / 2,
       
 18146                         (llbbox[3] + llbbox[1]) / 2
       
 18147                     ];
       
 18148                 };
       
 18149                 function degToRad(deg) {
       
 18150                     return deg * (Math.PI / 180);
       
 18151                 }
       
 18152                 function radToDeg(rad) {
       
 18153                     return 180 * (rad / Math.PI);
       
 18154                 }
       
 18155                 function LLtoUTM(ll) {
       
 18156                     var Lat = ll.lat;
       
 18157                     var Long = ll.lon;
       
 18158                     var a = 6378137;
       
 18159                     var eccSquared = 0.00669438;
       
 18160                     var k0 = 0.9996;
       
 18161                     var LongOrigin;
       
 18162                     var eccPrimeSquared;
       
 18163                     var N, T, C, A, M;
       
 18164                     var LatRad = degToRad(Lat);
       
 18165                     var LongRad = degToRad(Long);
       
 18166                     var LongOriginRad;
       
 18167                     var ZoneNumber;
       
 18168                     ZoneNumber = Math.floor((Long + 180) / 6) + 1;
       
 18169                     if (Long === 180) {
       
 18170                         ZoneNumber = 60;
       
 18171                     }
       
 18172                     if (Lat >= 56 && Lat < 64 && Long >= 3 && Long < 12) {
       
 18173                         ZoneNumber = 32;
       
 18174                     }
       
 18175                     if (Lat >= 72 && Lat < 84) {
       
 18176                         if (Long >= 0 && Long < 9) {
       
 18177                             ZoneNumber = 31;
       
 18178                         } else if (Long >= 9 && Long < 21) {
       
 18179                             ZoneNumber = 33;
       
 18180                         } else if (Long >= 21 && Long < 33) {
       
 18181                             ZoneNumber = 35;
       
 18182                         } else if (Long >= 33 && Long < 42) {
       
 18183                             ZoneNumber = 37;
       
 18184                         }
       
 18185                     }
       
 18186                     LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3;
       
 18187                     LongOriginRad = degToRad(LongOrigin);
       
 18188                     eccPrimeSquared = eccSquared / (1 - eccSquared);
       
 18189                     N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));
       
 18190                     T = Math.tan(LatRad) * Math.tan(LatRad);
       
 18191                     C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
       
 18192                     A = Math.cos(LatRad) * (LongRad - LongOriginRad);
       
 18193                     M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - 35 * eccSquared * eccSquared * eccSquared / 3072 * Math.sin(6 * LatRad));
       
 18194                     var UTMEasting = k0 * N * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120) + 500000;
       
 18195                     var UTMNorthing = k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720));
       
 18196                     if (Lat < 0) {
       
 18197                         UTMNorthing += 10000000;
       
 18198                     }
       
 18199                     return {
       
 18200                         northing: Math.round(UTMNorthing),
       
 18201                         easting: Math.round(UTMEasting),
       
 18202                         zoneNumber: ZoneNumber,
       
 18203                         zoneLetter: getLetterDesignator(Lat)
       
 18204                     };
       
 18205                 }
       
 18206                 function UTMtoLL(utm) {
       
 18207                     var UTMNorthing = utm.northing;
       
 18208                     var UTMEasting = utm.easting;
       
 18209                     var zoneLetter = utm.zoneLetter;
       
 18210                     var zoneNumber = utm.zoneNumber;
       
 18211                     if (zoneNumber < 0 || zoneNumber > 60) {
       
 18212                         return null;
       
 18213                     }
       
 18214                     var k0 = 0.9996;
       
 18215                     var a = 6378137;
       
 18216                     var eccSquared = 0.00669438;
       
 18217                     var eccPrimeSquared;
       
 18218                     var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));
       
 18219                     var N1, T1, C1, R1, D, M;
       
 18220                     var LongOrigin;
       
 18221                     var mu, phi1Rad;
       
 18222                     var x = UTMEasting - 500000;
       
 18223                     var y = UTMNorthing;
       
 18224                     if (zoneLetter < 'N') {
       
 18225                         y -= 10000000;
       
 18226                     }
       
 18227                     LongOrigin = (zoneNumber - 1) * 6 - 180 + 3;
       
 18228                     eccPrimeSquared = eccSquared / (1 - eccSquared);
       
 18229                     M = y / k0;
       
 18230                     mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
       
 18231                     phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + 151 * e1 * e1 * e1 / 96 * Math.sin(6 * mu);
       
 18232                     N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));
       
 18233                     T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);
       
 18234                     C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);
       
 18235                     R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);
       
 18236                     D = x / (N1 * k0);
       
 18237                     var lat = phi1Rad - N1 * Math.tan(phi1Rad) / R1 * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);
       
 18238                     lat = radToDeg(lat);
       
 18239                     var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);
       
 18240                     lon = LongOrigin + radToDeg(lon);
       
 18241                     var result;
       
 18242                     if (utm.accuracy) {
       
 18243                         var topRight = UTMtoLL({
       
 18244                             northing: utm.northing + utm.accuracy,
       
 18245                             easting: utm.easting + utm.accuracy,
       
 18246                             zoneLetter: utm.zoneLetter,
       
 18247                             zoneNumber: utm.zoneNumber
       
 18248                         });
       
 18249                         result = {
       
 18250                             top: topRight.lat,
       
 18251                             right: topRight.lon,
       
 18252                             bottom: lat,
       
 18253                             left: lon
       
 18254                         };
       
 18255                     } else {
       
 18256                         result = {
       
 18257                             lat: lat,
       
 18258                             lon: lon
       
 18259                         };
       
 18260                     }
       
 18261                     return result;
       
 18262                 }
       
 18263                 function getLetterDesignator(lat) {
       
 18264                     var LetterDesignator = 'Z';
       
 18265                     if (84 >= lat && lat >= 72) {
       
 18266                         LetterDesignator = 'X';
       
 18267                     } else if (72 > lat && lat >= 64) {
       
 18268                         LetterDesignator = 'W';
       
 18269                     } else if (64 > lat && lat >= 56) {
       
 18270                         LetterDesignator = 'V';
       
 18271                     } else if (56 > lat && lat >= 48) {
       
 18272                         LetterDesignator = 'U';
       
 18273                     } else if (48 > lat && lat >= 40) {
       
 18274                         LetterDesignator = 'T';
       
 18275                     } else if (40 > lat && lat >= 32) {
       
 18276                         LetterDesignator = 'S';
       
 18277                     } else if (32 > lat && lat >= 24) {
       
 18278                         LetterDesignator = 'R';
       
 18279                     } else if (24 > lat && lat >= 16) {
       
 18280                         LetterDesignator = 'Q';
       
 18281                     } else if (16 > lat && lat >= 8) {
       
 18282                         LetterDesignator = 'P';
       
 18283                     } else if (8 > lat && lat >= 0) {
       
 18284                         LetterDesignator = 'N';
       
 18285                     } else if (0 > lat && lat >= -8) {
       
 18286                         LetterDesignator = 'M';
       
 18287                     } else if (-8 > lat && lat >= -16) {
       
 18288                         LetterDesignator = 'L';
       
 18289                     } else if (-16 > lat && lat >= -24) {
       
 18290                         LetterDesignator = 'K';
       
 18291                     } else if (-24 > lat && lat >= -32) {
       
 18292                         LetterDesignator = 'J';
       
 18293                     } else if (-32 > lat && lat >= -40) {
       
 18294                         LetterDesignator = 'H';
       
 18295                     } else if (-40 > lat && lat >= -48) {
       
 18296                         LetterDesignator = 'G';
       
 18297                     } else if (-48 > lat && lat >= -56) {
       
 18298                         LetterDesignator = 'F';
       
 18299                     } else if (-56 > lat && lat >= -64) {
       
 18300                         LetterDesignator = 'E';
       
 18301                     } else if (-64 > lat && lat >= -72) {
       
 18302                         LetterDesignator = 'D';
       
 18303                     } else if (-72 > lat && lat >= -80) {
       
 18304                         LetterDesignator = 'C';
       
 18305                     }
       
 18306                     return LetterDesignator;
       
 18307                 }
       
 18308                 function encode(utm, accuracy) {
       
 18309                     var seasting = '' + utm.easting, snorthing = '' + utm.northing;
       
 18310                     return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
       
 18311                 }
       
 18312                 function get100kID(easting, northing, zoneNumber) {
       
 18313                     var setParm = get100kSetForZone(zoneNumber);
       
 18314                     var setColumn = Math.floor(easting / 100000);
       
 18315                     var setRow = Math.floor(northing / 100000) % 20;
       
 18316                     return getLetter100kID(setColumn, setRow, setParm);
       
 18317                 }
       
 18318                 function get100kSetForZone(i) {
       
 18319                     var setParm = i % NUM_100K_SETS;
       
 18320                     if (setParm === 0) {
       
 18321                         setParm = NUM_100K_SETS;
       
 18322                     }
       
 18323                     return setParm;
       
 18324                 }
       
 18325                 function getLetter100kID(column, row, parm) {
       
 18326                     var index = parm - 1;
       
 18327                     var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);
       
 18328                     var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);
       
 18329                     var colInt = colOrigin + column - 1;
       
 18330                     var rowInt = rowOrigin + row;
       
 18331                     var rollover = false;
       
 18332                     if (colInt > Z) {
       
 18333                         colInt = colInt - Z + A - 1;
       
 18334                         rollover = true;
       
 18335                     }
       
 18336                     if (colInt === I || colOrigin < I && colInt > I || (colInt > I || colOrigin < I) && rollover) {
       
 18337                         colInt++;
       
 18338                     }
       
 18339                     if (colInt === O || colOrigin < O && colInt > O || (colInt > O || colOrigin < O) && rollover) {
       
 18340                         colInt++;
       
 18341                         if (colInt === I) {
       
 18342                             colInt++;
       
 18343                         }
       
 18344                     }
       
 18345                     if (colInt > Z) {
       
 18346                         colInt = colInt - Z + A - 1;
       
 18347                     }
       
 18348                     if (rowInt > V) {
       
 18349                         rowInt = rowInt - V + A - 1;
       
 18350                         rollover = true;
       
 18351                     } else {
       
 18352                         rollover = false;
       
 18353                     }
       
 18354                     if (rowInt === I || rowOrigin < I && rowInt > I || (rowInt > I || rowOrigin < I) && rollover) {
       
 18355                         rowInt++;
       
 18356                     }
       
 18357                     if (rowInt === O || rowOrigin < O && rowInt > O || (rowInt > O || rowOrigin < O) && rollover) {
       
 18358                         rowInt++;
       
 18359                         if (rowInt === I) {
       
 18360                             rowInt++;
       
 18361                         }
       
 18362                     }
       
 18363                     if (rowInt > V) {
       
 18364                         rowInt = rowInt - V + A - 1;
       
 18365                     }
       
 18366                     var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);
       
 18367                     return twoLetter;
       
 18368                 }
       
 18369                 function decode(mgrsString) {
       
 18370                     if (mgrsString && mgrsString.length === 0) {
       
 18371                         throw 'MGRSPoint coverting from nothing';
       
 18372                     }
       
 18373                     var length = mgrsString.length;
       
 18374                     var hunK = null;
       
 18375                     var sb = '';
       
 18376                     var testChar;
       
 18377                     var i = 0;
       
 18378                     while (!/[A-Z]/.test(testChar = mgrsString.charAt(i))) {
       
 18379                         if (i >= 2) {
       
 18380                             throw 'MGRSPoint bad conversion from: ' + mgrsString;
       
 18381                         }
       
 18382                         sb += testChar;
       
 18383                         i++;
       
 18384                     }
       
 18385                     var zoneNumber = parseInt(sb, 10);
       
 18386                     if (i === 0 || i + 3 > length) {
       
 18387                         throw 'MGRSPoint bad conversion from: ' + mgrsString;
       
 18388                     }
       
 18389                     var zoneLetter = mgrsString.charAt(i++);
       
 18390                     if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {
       
 18391                         throw 'MGRSPoint zone letter ' + zoneLetter + ' not handled: ' + mgrsString;
       
 18392                     }
       
 18393                     hunK = mgrsString.substring(i, i += 2);
       
 18394                     var set = get100kSetForZone(zoneNumber);
       
 18395                     var east100k = getEastingFromChar(hunK.charAt(0), set);
       
 18396                     var north100k = getNorthingFromChar(hunK.charAt(1), set);
       
 18397                     while (north100k < getMinNorthing(zoneLetter)) {
       
 18398                         north100k += 2000000;
       
 18399                     }
       
 18400                     var remainder = length - i;
       
 18401                     if (remainder % 2 !== 0) {
       
 18402                         throw 'MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters' + mgrsString;
       
 18403                     }
       
 18404                     var sep = remainder / 2;
       
 18405                     var sepEasting = 0;
       
 18406                     var sepNorthing = 0;
       
 18407                     var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;
       
 18408                     if (sep > 0) {
       
 18409                         accuracyBonus = 100000 / Math.pow(10, sep);
       
 18410                         sepEastingString = mgrsString.substring(i, i + sep);
       
 18411                         sepEasting = parseFloat(sepEastingString) * accuracyBonus;
       
 18412                         sepNorthingString = mgrsString.substring(i + sep);
       
 18413                         sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;
       
 18414                     }
       
 18415                     easting = sepEasting + east100k;
       
 18416                     northing = sepNorthing + north100k;
       
 18417                     return {
       
 18418                         easting: easting,
       
 18419                         northing: northing,
       
 18420                         zoneLetter: zoneLetter,
       
 18421                         zoneNumber: zoneNumber,
       
 18422                         accuracy: accuracyBonus
       
 18423                     };
       
 18424                 }
       
 18425                 function getEastingFromChar(e, set) {
       
 18426                     var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);
       
 18427                     var eastingValue = 100000;
       
 18428                     var rewindMarker = false;
       
 18429                     while (curCol !== e.charCodeAt(0)) {
       
 18430                         curCol++;
       
 18431                         if (curCol === I) {
       
 18432                             curCol++;
       
 18433                         }
       
 18434                         if (curCol === O) {
       
 18435                             curCol++;
       
 18436                         }
       
 18437                         if (curCol > Z) {
       
 18438                             if (rewindMarker) {
       
 18439                                 throw 'Bad character: ' + e;
       
 18440                             }
       
 18441                             curCol = A;
       
 18442                             rewindMarker = true;
       
 18443                         }
       
 18444                         eastingValue += 100000;
       
 18445                     }
       
 18446                     return eastingValue;
       
 18447                 }
       
 18448                 function getNorthingFromChar(n, set) {
       
 18449                     if (n > 'V') {
       
 18450                         throw 'MGRSPoint given invalid Northing ' + n;
       
 18451                     }
       
 18452                     var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);
       
 18453                     var northingValue = 0;
       
 18454                     var rewindMarker = false;
       
 18455                     while (curRow !== n.charCodeAt(0)) {
       
 18456                         curRow++;
       
 18457                         if (curRow === I) {
       
 18458                             curRow++;
       
 18459                         }
       
 18460                         if (curRow === O) {
       
 18461                             curRow++;
       
 18462                         }
       
 18463                         if (curRow > V) {
       
 18464                             if (rewindMarker) {
       
 18465                                 throw 'Bad character: ' + n;
       
 18466                             }
       
 18467                             curRow = A;
       
 18468                             rewindMarker = true;
       
 18469                         }
       
 18470                         northingValue += 100000;
       
 18471                     }
       
 18472                     return northingValue;
       
 18473                 }
       
 18474                 function getMinNorthing(zoneLetter) {
       
 18475                     var northing;
       
 18476                     switch (zoneLetter) {
       
 18477                     case 'C':
       
 18478                         northing = 1100000;
       
 18479                         break;
       
 18480                     case 'D':
       
 18481                         northing = 2000000;
       
 18482                         break;
       
 18483                     case 'E':
       
 18484                         northing = 2800000;
       
 18485                         break;
       
 18486                     case 'F':
       
 18487                         northing = 3700000;
       
 18488                         break;
       
 18489                     case 'G':
       
 18490                         northing = 4600000;
       
 18491                         break;
       
 18492                     case 'H':
       
 18493                         northing = 5500000;
       
 18494                         break;
       
 18495                     case 'J':
       
 18496                         northing = 6400000;
       
 18497                         break;
       
 18498                     case 'K':
       
 18499                         northing = 7300000;
       
 18500                         break;
       
 18501                     case 'L':
       
 18502                         northing = 8200000;
       
 18503                         break;
       
 18504                     case 'M':
       
 18505                         northing = 9100000;
       
 18506                         break;
       
 18507                     case 'N':
       
 18508                         northing = 0;
       
 18509                         break;
       
 18510                     case 'P':
       
 18511                         northing = 800000;
       
 18512                         break;
       
 18513                     case 'Q':
       
 18514                         northing = 1700000;
       
 18515                         break;
       
 18516                     case 'R':
       
 18517                         northing = 2600000;
       
 18518                         break;
       
 18519                     case 'S':
       
 18520                         northing = 3500000;
       
 18521                         break;
       
 18522                     case 'T':
       
 18523                         northing = 4400000;
       
 18524                         break;
       
 18525                     case 'U':
       
 18526                         northing = 5300000;
       
 18527                         break;
       
 18528                     case 'V':
       
 18529                         northing = 6200000;
       
 18530                         break;
       
 18531                     case 'W':
       
 18532                         northing = 7000000;
       
 18533                         break;
       
 18534                     case 'X':
       
 18535                         northing = 7900000;
       
 18536                         break;
       
 18537                     default:
       
 18538                         northing = -1;
       
 18539                     }
       
 18540                     if (northing >= 0) {
       
 18541                         return northing;
       
 18542                     } else {
       
 18543                         throw 'Invalid zone letter: ' + zoneLetter;
       
 18544                     }
       
 18545                 }
       
 18546                 return exports;
       
 18547             },
       
 18548             {}
       
 18549         ],
       
 18550         67: [
       
 18551             function (_dereq_, module, exports) {
       
 18552                 module.exports = {
       
 18553                     'name': 'proj4',
       
 18554                     'version': '2.2.1',
       
 18555                     'description': 'Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.',
       
 18556                     'main': 'lib/index.js',
       
 18557                     'directories': {
       
 18558                         'test': 'test',
       
 18559                         'doc': 'docs'
       
 18560                     },
       
 18561                     'scripts': { 'test': './node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js' },
       
 18562                     'repository': {
       
 18563                         'type': 'git',
       
 18564                         'url': 'git://github.com/proj4js/proj4js.git'
       
 18565                     },
       
 18566                     'author': '',
       
 18567                     'license': 'MIT',
       
 18568                     'jam': {
       
 18569                         'main': 'dist/proj4.js',
       
 18570                         'include': [
       
 18571                             'dist/proj4.js',
       
 18572                             'README.md',
       
 18573                             'AUTHORS',
       
 18574                             'LICENSE.md'
       
 18575                         ]
       
 18576                     },
       
 18577                     'devDependencies': {
       
 18578                         'grunt-cli': '~0.1.13',
       
 18579                         'grunt': '~0.4.2',
       
 18580                         'grunt-contrib-connect': '~0.6.0',
       
 18581                         'grunt-contrib-jshint': '~0.8.0',
       
 18582                         'chai': '~1.8.1',
       
 18583                         'mocha': '~1.17.1',
       
 18584                         'grunt-mocha-phantomjs': '~0.4.0',
       
 18585                         'browserify': '~3.24.5',
       
 18586                         'grunt-browserify': '~1.3.0',
       
 18587                         'grunt-contrib-uglify': '~0.3.2',
       
 18588                         'curl': 'git://github.com/cujojs/curl.git',
       
 18589                         'istanbul': '~0.2.4',
       
 18590                         'tin': '~0.4.0'
       
 18591                     },
       
 18592                     'dependencies': { 'mgrs': '0.0.0' }
       
 18593                 };
       
 18594                 return exports;
       
 18595             },
       
 18596             {}
       
 18597         ],
       
 18598         './includedProjections': [
       
 18599             function (_dereq_, module, exports) {
       
 18600                 module.exports = _dereq_('gWUPNW');
       
 18601                 return exports;
       
 18602             },
       
 18603             {}
       
 18604         ],
       
 18605         'gWUPNW': [
       
 18606             function (_dereq_, module, exports) {
       
 18607                 var projs = [
       
 18608                     _dereq_('./lib/projections/tmerc'),
       
 18609                     _dereq_('./lib/projections/utm'),
       
 18610                     _dereq_('./lib/projections/sterea'),
       
 18611                     _dereq_('./lib/projections/stere'),
       
 18612                     _dereq_('./lib/projections/somerc'),
       
 18613                     _dereq_('./lib/projections/omerc'),
       
 18614                     _dereq_('./lib/projections/lcc'),
       
 18615                     _dereq_('./lib/projections/krovak'),
       
 18616                     _dereq_('./lib/projections/cass'),
       
 18617                     _dereq_('./lib/projections/laea'),
       
 18618                     _dereq_('./lib/projections/aea'),
       
 18619                     _dereq_('./lib/projections/gnom'),
       
 18620                     _dereq_('./lib/projections/cea'),
       
 18621                     _dereq_('./lib/projections/eqc'),
       
 18622                     _dereq_('./lib/projections/poly'),
       
 18623                     _dereq_('./lib/projections/nzmg'),
       
 18624                     _dereq_('./lib/projections/mill'),
       
 18625                     _dereq_('./lib/projections/sinu'),
       
 18626                     _dereq_('./lib/projections/moll'),
       
 18627                     _dereq_('./lib/projections/eqdc'),
       
 18628                     _dereq_('./lib/projections/vandg'),
       
 18629                     _dereq_('./lib/projections/aeqd')
       
 18630                 ];
       
 18631                 module.exports = function (proj4) {
       
 18632                     projs.forEach(function (proj) {
       
 18633                         proj4.Proj.projections.add(proj);
       
 18634                     });
       
 18635                 };
       
 18636                 return exports;
       
 18637             },
       
 18638             {
       
 18639                 './lib/projections/aea': 39,
       
 18640                 './lib/projections/aeqd': 40,
       
 18641                 './lib/projections/cass': 41,
       
 18642                 './lib/projections/cea': 42,
       
 18643                 './lib/projections/eqc': 43,
       
 18644                 './lib/projections/eqdc': 44,
       
 18645                 './lib/projections/gnom': 46,
       
 18646                 './lib/projections/krovak': 47,
       
 18647                 './lib/projections/laea': 48,
       
 18648                 './lib/projections/lcc': 49,
       
 18649                 './lib/projections/mill': 52,
       
 18650                 './lib/projections/moll': 53,
       
 18651                 './lib/projections/nzmg': 54,
       
 18652                 './lib/projections/omerc': 55,
       
 18653                 './lib/projections/poly': 56,
       
 18654                 './lib/projections/sinu': 57,
       
 18655                 './lib/projections/somerc': 58,
       
 18656                 './lib/projections/stere': 59,
       
 18657                 './lib/projections/sterea': 60,
       
 18658                 './lib/projections/tmerc': 61,
       
 18659                 './lib/projections/utm': 62,
       
 18660                 './lib/projections/vandg': 63
       
 18661             }
       
 18662         ]
       
 18663     }, {}, [35])(35);
       
 18664 });
       
 18665 !function (root, factory) {
       
 18666     if (true) {
       
 18667         proj4leaflet07x = function (leaflet, proj4) {
       
 18668             return typeof factory === 'function' ? factory(leaflet, proj4) : factory;
       
 18669         }(leaflet, proj4);
       
 18670     } else if (typeof module === 'object' && typeof module.exports === 'object') {
       
 18671         L = leaflet;
       
 18672         proj4 = proj4;
       
 18673         module.exports = factory(L, proj4);
       
 18674     } else {
       
 18675         if (typeof root.L === 'undefined' || typeof root.proj4 === 'undefined')
       
 18676             throw 'Leaflet and proj4 must be loaded first';
       
 18677         factory(root.L, root.proj4);
       
 18678     }
       
 18679 }(this, function (L, proj4) {
       
 18680     L.Proj = {};
       
 18681     L.Proj._isProj4Obj = function (a) {
       
 18682         return typeof a.inverse !== 'undefined' && typeof a.forward !== 'undefined';
       
 18683     };
       
 18684     L.Proj.ScaleDependantTransformation = function (scaleTransforms) {
       
 18685         this.scaleTransforms = scaleTransforms;
       
 18686     };
       
 18687     L.Proj.ScaleDependantTransformation.prototype.transform = function (point, scale) {
       
 18688         return this.scaleTransforms[scale].transform(point, scale);
       
 18689     };
       
 18690     L.Proj.ScaleDependantTransformation.prototype.untransform = function (point, scale) {
       
 18691         return this.scaleTransforms[scale].untransform(point, scale);
       
 18692     };
       
 18693     L.Proj.Projection = L.Class.extend({
       
 18694         initialize: function (a, def) {
       
 18695             if (L.Proj._isProj4Obj(a)) {
       
 18696                 this._proj = a;
       
 18697             } else {
       
 18698                 var code = a;
       
 18699                 if (def) {
       
 18700                     proj4.defs(code, def);
       
 18701                 } else if (proj4.defs[code] === undefined) {
       
 18702                     var urn = code.split(':');
       
 18703                     if (urn.length > 3) {
       
 18704                         code = urn[urn.length - 3] + ':' + urn[urn.length - 1];
       
 18705                     }
       
 18706                     if (proj4.defs[code] === undefined) {
       
 18707                         throw 'No projection definition for code ' + code;
       
 18708                     }
       
 18709                 }
       
 18710                 this._proj = proj4(code);
       
 18711             }
       
 18712         },
       
 18713         project: function (latlng) {
       
 18714             var point = this._proj.forward([
       
 18715                 latlng.lng,
       
 18716                 latlng.lat
       
 18717             ]);
       
 18718             return new L.Point(point[0], point[1]);
       
 18719         },
       
 18720         unproject: function (point, unbounded) {
       
 18721             var point2 = this._proj.inverse([
       
 18722                 point.x,
       
 18723                 point.y
       
 18724             ]);
       
 18725             return new L.LatLng(point2[1], point2[0], unbounded);
       
 18726         }
       
 18727     });
       
 18728     L.Proj.CRS = L.Class.extend({
       
 18729         includes: L.CRS,
       
 18730         options: { transformation: new L.Transformation(1, 0, -1, 0) },
       
 18731         initialize: function (a, b, c) {
       
 18732             var code, proj, def, options;
       
 18733             if (L.Proj._isProj4Obj(a)) {
       
 18734                 proj = a;
       
 18735                 code = proj.srsCode;
       
 18736                 options = b || {};
       
 18737                 this.projection = new L.Proj.Projection(proj);
       
 18738             } else {
       
 18739                 code = a;
       
 18740                 def = b;
       
 18741                 options = c || {};
       
 18742                 this.projection = new L.Proj.Projection(code, def);
       
 18743             }
       
 18744             L.Util.setOptions(this, options);
       
 18745             this.code = code;
       
 18746             this.transformation = this.options.transformation;
       
 18747             if (this.options.origin) {
       
 18748                 this.transformation = new L.Transformation(1, -this.options.origin[0], -1, this.options.origin[1]);
       
 18749             }
       
 18750             if (this.options.scales) {
       
 18751                 this._scales = this.options.scales;
       
 18752             } else if (this.options.resolutions) {
       
 18753                 this._scales = [];
       
 18754                 for (var i = this.options.resolutions.length - 1; i >= 0; i--) {
       
 18755                     if (this.options.resolutions[i]) {
       
 18756                         this._scales[i] = 1 / this.options.resolutions[i];
       
 18757                     }
       
 18758                 }
       
 18759             }
       
 18760         },
       
 18761         scale: function (zoom) {
       
 18762             var iZoom = Math.floor(zoom), baseScale, nextScale, scaleDiff, zDiff;
       
 18763             if (zoom === iZoom) {
       
 18764                 return this._scales[zoom];
       
 18765             } else {
       
 18766                 baseScale = this._scales[iZoom];
       
 18767                 nextScale = this._scales[iZoom + 1];
       
 18768                 scaleDiff = nextScale - baseScale;
       
 18769                 zDiff = zoom - iZoom;
       
 18770                 return baseScale + scaleDiff * zDiff;
       
 18771             }
       
 18772         },
       
 18773         getSize: function (zoom) {
       
 18774             var b = this.options.bounds, s, min, max;
       
 18775             if (b) {
       
 18776                 s = this.scale(zoom);
       
 18777                 min = this.transformation.transform(b.min, s);
       
 18778                 max = this.transformation.transform(b.max, s);
       
 18779                 return L.point(Math.abs(max.x - min.x), Math.abs(max.y - min.y));
       
 18780             } else {
       
 18781                 s = 256 * Math.pow(2, zoom);
       
 18782                 return L.point(s, s);
       
 18783             }
       
 18784         }
       
 18785     });
       
 18786     L.Proj.CRS.TMS = L.Proj.CRS.extend({
       
 18787         options: { tileSize: 256 },
       
 18788         initialize: function (a, b, c, d) {
       
 18789             var code, def, proj, projectedBounds, options;
       
 18790             if (L.Proj._isProj4Obj(a)) {
       
 18791                 proj = a;
       
 18792                 projectedBounds = b;
       
 18793                 options = c || {};
       
 18794                 options.origin = [
       
 18795                     projectedBounds[0],
       
 18796                     projectedBounds[3]
       
 18797                 ];
       
 18798                 L.Proj.CRS.prototype.initialize.call(this, proj, options);
       
 18799             } else {
       
 18800                 code = a;
       
 18801                 def = b;
       
 18802                 projectedBounds = c;
       
 18803                 options = d || {};
       
 18804                 options.origin = [
       
 18805                     projectedBounds[0],
       
 18806                     projectedBounds[3]
       
 18807                 ];
       
 18808                 L.Proj.CRS.prototype.initialize.call(this, code, def, options);
       
 18809             }
       
 18810             this.projectedBounds = projectedBounds;
       
 18811             this._sizes = this._calculateSizes();
       
 18812         },
       
 18813         _calculateSizes: function () {
       
 18814             var sizes = [], crsBounds = this.projectedBounds, projectedTileSize, i, x, y;
       
 18815             for (i = this._scales.length - 1; i >= 0; i--) {
       
 18816                 if (this._scales[i]) {
       
 18817                     projectedTileSize = this.options.tileSize / this._scales[i];
       
 18818                     x = Math.ceil(parseFloat((crsBounds[2] - crsBounds[0]) / projectedTileSize).toPrecision(3)) * projectedTileSize * this._scales[i];
       
 18819                     y = Math.ceil(parseFloat((crsBounds[3] - crsBounds[1]) / projectedTileSize).toPrecision(3)) * projectedTileSize * this._scales[i];
       
 18820                     sizes[i] = L.point(x, y);
       
 18821                 }
       
 18822             }
       
 18823             return sizes;
       
 18824         },
       
 18825         getSize: function (zoom) {
       
 18826             return this._sizes[zoom];
       
 18827         }
       
 18828     });
       
 18829     L.Proj.TileLayer = {};
       
 18830     L.Proj.TileLayer.TMS = L.TileLayer.extend({
       
 18831         options: { continuousWorld: true },
       
 18832         initialize: function (urlTemplate, crs, options) {
       
 18833             var boundsMatchesGrid = true, scaleTransforms, upperY, crsBounds, i;
       
 18834             if (!(crs instanceof L.Proj.CRS.TMS)) {
       
 18835                 throw 'CRS is not L.Proj.CRS.TMS.';
       
 18836             }
       
 18837             L.TileLayer.prototype.initialize.call(this, urlTemplate, options);
       
 18838             this.options.tms = false;
       
 18839             this.crs = crs;
       
 18840             crsBounds = this.crs.projectedBounds;
       
 18841             for (i = this.options.minZoom; i < this.options.maxZoom && boundsMatchesGrid; i++) {
       
 18842                 var gridHeight = (crsBounds[3] - crsBounds[1]) / this._projectedTileSize(i);
       
 18843                 boundsMatchesGrid = Math.abs(gridHeight - Math.round(gridHeight)) > 0.001;
       
 18844             }
       
 18845             if (!boundsMatchesGrid) {
       
 18846                 scaleTransforms = {};
       
 18847                 for (i = this.options.minZoom; i < this.options.maxZoom; i++) {
       
 18848                     upperY = crsBounds[1] + Math.ceil((crsBounds[3] - crsBounds[1]) / this._projectedTileSize(i)) * this._projectedTileSize(i);
       
 18849                     scaleTransforms[this.crs.scale(i)] = new L.Transformation(1, -crsBounds[0], -1, upperY);
       
 18850                 }
       
 18851                 this.crs = new L.Proj.CRS.TMS(this.crs.projection._proj, crsBounds, this.crs.options);
       
 18852                 this.crs.transformation = new L.Proj.ScaleDependantTransformation(scaleTransforms);
       
 18853             }
       
 18854         },
       
 18855         getTileUrl: function (tilePoint) {
       
 18856             var zoom = this._map.getZoom(), gridHeight = Math.ceil((this.crs.projectedBounds[3] - this.crs.projectedBounds[1]) / this._projectedTileSize(zoom));
       
 18857             return L.Util.template(this._url, L.Util.extend({
       
 18858                 s: this._getSubdomain(tilePoint),
       
 18859                 z: this._getZoomForUrl(),
       
 18860                 x: tilePoint.x,
       
 18861                 y: gridHeight - tilePoint.y - 1
       
 18862             }, this.options));
       
 18863         },
       
 18864         _projectedTileSize: function (zoom) {
       
 18865             return this.options.tileSize / this.crs.scale(zoom);
       
 18866         }
       
 18867     });
       
 18868     L.Proj.GeoJSON = L.GeoJSON.extend({
       
 18869         initialize: function (geojson, options) {
       
 18870             this._callLevel = 0;
       
 18871             L.GeoJSON.prototype.initialize.call(this, null, options);
       
 18872             if (geojson) {
       
 18873                 this.addData(geojson);
       
 18874             }
       
 18875         },
       
 18876         addData: function (geojson) {
       
 18877             var crs;
       
 18878             if (geojson) {
       
 18879                 if (geojson.crs && geojson.crs.type === 'name') {
       
 18880                     crs = new L.Proj.CRS(geojson.crs.properties.name);
       
 18881                 } else if (geojson.crs && geojson.crs.type) {
       
 18882                     crs = new L.Proj.CRS(geojson.crs.type + ':' + geojson.crs.properties.code);
       
 18883                 }
       
 18884                 if (crs !== undefined) {
       
 18885                     this.options.coordsToLatLng = function (coords) {
       
 18886                         var point = L.point(coords[0], coords[1]);
       
 18887                         return crs.projection.unproject(point);
       
 18888                     };
       
 18889                 }
       
 18890             }
       
 18891             this._callLevel++;
       
 18892             try {
       
 18893                 L.GeoJSON.prototype.addData.call(this, geojson);
       
 18894             } finally {
       
 18895                 this._callLevel--;
       
 18896                 if (this._callLevel === 0) {
       
 18897                     delete this.options.coordsToLatLng;
       
 18898                 }
       
 18899             }
       
 18900         }
       
 18901     });
       
 18902     L.Proj.geoJson = function (geojson, options) {
       
 18903         return new L.Proj.GeoJSON(geojson, options);
       
 18904     };
       
 18905     L.Proj.ImageOverlay = L.ImageOverlay.extend({
       
 18906         initialize: function (url, bounds, options) {
       
 18907             L.ImageOverlay.prototype.initialize.call(this, url, null, options);
       
 18908             this._projBounds = bounds;
       
 18909         },
       
 18910         _animateZoom: function (e) {
       
 18911             var northwest = L.point(this._projBounds.min.x, this._projBounds.max.y), southeast = L.point(this._projBounds.max.x, this._projBounds.min.y), topLeft = this._projectedToNewLayerPoint(northwest, e.zoom, e.center), size = this._projectedToNewLayerPoint(southeast, e.zoom, e.center).subtract(topLeft), origin = topLeft.add(size._multiplyBy((1 - 1 / e.scale) / 2));
       
 18912             this._image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + this._map.getZoomScale(e.zoom) + ') ';
       
 18913         },
       
 18914         _reset: function () {
       
 18915             var zoom = this._map.getZoom(), pixelOrigin = this._map.getPixelOrigin(), bounds = L.bounds(this._transform(this._projBounds.min, zoom)._subtract(pixelOrigin), this._transform(this._projBounds.max, zoom)._subtract(pixelOrigin)), size = bounds.getSize(), image = this._image;
       
 18916             L.DomUtil.setPosition(image, bounds.min);
       
 18917             image.style.width = size.x + 'px';
       
 18918             image.style.height = size.y + 'px';
       
 18919         },
       
 18920         _projectedToNewLayerPoint: function (point, newZoom, newCenter) {
       
 18921             var topLeft = this._map._getNewTopLeftPoint(newCenter, newZoom).add(this._map._getMapPanePos());
       
 18922             return this._transform(point, newZoom)._subtract(topLeft);
       
 18923         },
       
 18924         _transform: function (p, zoom) {
       
 18925             var crs = this._map.options.crs, transformation = crs.transformation, scale = crs.scale(zoom);
       
 18926             return transformation.transform(p, scale);
       
 18927         }
       
 18928     });
       
 18929     L.Proj.imageOverlay = function (url, bounds, options) {
       
 18930         return new L.Proj.ImageOverlay(url, bounds, options);
       
 18931     };
       
 18932     if (typeof L.CRS !== 'undefined') {
       
 18933         L.CRS.proj4js = function () {
       
 18934             return function (code, def, transformation, options) {
       
 18935                 options = options || {};
       
 18936                 if (transformation) {
       
 18937                     options.transformation = transformation;
       
 18938                 }
       
 18939                 return new L.Proj.CRS(code, def, options);
       
 18940             };
       
 18941         }();
       
 18942     }
       
 18943     return L.Proj;
       
 18944 });
       
 18945 !function (root, factory) {
       
 18946     if (true) {
       
 18947         proj4leaflet10x = function (leaflet, proj4) {
       
 18948             return typeof factory === 'function' ? factory(leaflet, proj4) : factory;
       
 18949         }(leaflet, proj4);
       
 18950     } else if (typeof module === 'object' && typeof module.exports === 'object') {
       
 18951         L = leaflet;
       
 18952         proj4 = proj4;
       
 18953         module.exports = factory(L, proj4);
       
 18954     } else {
       
 18955         if (typeof root.L === 'undefined' || typeof root.proj4 === 'undefined')
       
 18956             throw 'Leaflet and proj4 must be loaded first';
       
 18957         factory(root.L, root.proj4);
       
 18958     }
       
 18959 }(this, function (L, proj4) {
       
 18960     L.Proj = {};
       
 18961     L.Proj._isProj4Obj = function (a) {
       
 18962         return typeof a.inverse !== 'undefined' && typeof a.forward !== 'undefined';
       
 18963     };
       
 18964     L.Proj.Projection = L.Class.extend({
       
 18965         initialize: function (code, def, bounds) {
       
 18966             var isP4 = L.Proj._isProj4Obj(code);
       
 18967             this._proj = isP4 ? code : this._projFromCodeDef(code, def);
       
 18968             this.bounds = isP4 ? def : bounds;
       
 18969         },
       
 18970         project: function (latlng) {
       
 18971             var point = this._proj.forward([
       
 18972                 latlng.lng,
       
 18973                 latlng.lat
       
 18974             ]);
       
 18975             return new L.Point(point[0], point[1]);
       
 18976         },
       
 18977         unproject: function (point, unbounded) {
       
 18978             var point2 = this._proj.inverse([
       
 18979                 point.x,
       
 18980                 point.y
       
 18981             ]);
       
 18982             return new L.LatLng(point2[1], point2[0], unbounded);
       
 18983         },
       
 18984         _projFromCodeDef: function (code, def) {
       
 18985             if (def) {
       
 18986                 proj4.defs(code, def);
       
 18987             } else if (proj4.defs[code] === undefined) {
       
 18988                 var urn = code.split(':');
       
 18989                 if (urn.length > 3) {
       
 18990                     code = urn[urn.length - 3] + ':' + urn[urn.length - 1];
       
 18991                 }
       
 18992                 if (proj4.defs[code] === undefined) {
       
 18993                     throw 'No projection definition for code ' + code;
       
 18994                 }
       
 18995             }
       
 18996             return proj4(code);
       
 18997         }
       
 18998     });
       
 18999     L.Proj.CRS = L.Class.extend({
       
 19000         includes: L.CRS,
       
 19001         options: { transformation: new L.Transformation(1, 0, -1, 0) },
       
 19002         initialize: function (a, b, c) {
       
 19003             var code, proj, def, options;
       
 19004             if (L.Proj._isProj4Obj(a)) {
       
 19005                 proj = a;
       
 19006                 code = proj.srsCode;
       
 19007                 options = b || {};
       
 19008                 this.projection = new L.Proj.Projection(proj, options.bounds);
       
 19009             } else {
       
 19010                 code = a;
       
 19011                 def = b;
       
 19012                 options = c || {};
       
 19013                 this.projection = new L.Proj.Projection(code, def, options.bounds);
       
 19014             }
       
 19015             L.Util.setOptions(this, options);
       
 19016             this.code = code;
       
 19017             this.transformation = this.options.transformation;
       
 19018             if (this.options.origin) {
       
 19019                 this.transformation = new L.Transformation(1, -this.options.origin[0], -1, this.options.origin[1]);
       
 19020             }
       
 19021             if (this.options.scales) {
       
 19022                 this._scales = this.options.scales;
       
 19023             } else if (this.options.resolutions) {
       
 19024                 this._scales = [];
       
 19025                 for (var i = this.options.resolutions.length - 1; i >= 0; i--) {
       
 19026                     if (this.options.resolutions[i]) {
       
 19027                         this._scales[i] = 1 / this.options.resolutions[i];
       
 19028                     }
       
 19029                 }
       
 19030             }
       
 19031             this.infinite = !this.options.bounds;
       
 19032         },
       
 19033         scale: function (zoom) {
       
 19034             var iZoom = Math.floor(zoom), baseScale, nextScale, scaleDiff, zDiff;
       
 19035             if (zoom === iZoom) {
       
 19036                 return this._scales[zoom];
       
 19037             } else {
       
 19038                 baseScale = this._scales[iZoom];
       
 19039                 nextScale = this._scales[iZoom + 1];
       
 19040                 scaleDiff = nextScale - baseScale;
       
 19041                 zDiff = zoom - iZoom;
       
 19042                 return baseScale + scaleDiff * zDiff;
       
 19043             }
       
 19044         },
       
 19045         zoom: function (scale) {
       
 19046             var downScale = this._closestElement(this._scales, scale), downZoom = this._scales.indexOf(downScale), nextZoom, scaleDiff;
       
 19047             if (scale === downScale) {
       
 19048                 return downZoom;
       
 19049             }
       
 19050             nextZoom = downZoom + 1;
       
 19051             scaleDiff = this._scales[nextZoom] - downScale;
       
 19052             return (scale - downScale) / scaleDiff + downZoom;
       
 19053         },
       
 19054         _closestElement: function (array, element) {
       
 19055             var low;
       
 19056             for (var i = array.length; i--;) {
       
 19057                 if (array[i] <= element && (low === undefined || low < array[i])) {
       
 19058                     low = array[i];
       
 19059                 }
       
 19060             }
       
 19061             return low;
       
 19062         }
       
 19063     });
       
 19064     L.Proj.GeoJSON = L.GeoJSON.extend({
       
 19065         initialize: function (geojson, options) {
       
 19066             if (geojson.crs && geojson.crs.type === 'name') {
       
 19067                 var crs = new L.Proj.CRS(geojson.crs.properties.name);
       
 19068                 options = options || {};
       
 19069                 options.coordsToLatLng = function (coords) {
       
 19070                     var point = L.point(coords[0], coords[1]);
       
 19071                     return crs.projection.unproject(point);
       
 19072                 };
       
 19073             }
       
 19074             L.GeoJSON.prototype.initialize.call(this, geojson, options);
       
 19075         }
       
 19076     });
       
 19077     L.Proj.geoJson = function (geojson, options) {
       
 19078         return new L.Proj.GeoJSON(geojson, options);
       
 19079     };
       
 19080     return L.Proj;
       
 19081 });
       
 19082 LeafletCRSProj4Leaflet = function (require, L, proj4) {
       
 19083     return {
       
 19084         load: function () {
       
 19085             console.log('loading lib proj4leaflet ...');
       
 19086             var proj4leaflet = null;
       
 19087             if (L.version.lastIndexOf('0.7', 0) === 0) {
       
 19088                 proj4leaflet = proj4leaflet07x;
       
 19089                 console.log('loaded version for leaflet 0.7.7 ...');
       
 19090             } else if (L.version.lastIndexOf('1.0', 0) === 0) {
       
 19091                 proj4leaflet = proj4leaflet10x;
       
 19092                 console.log('loaded version for leaflet 1.0.0 ...');
       
 19093             } else {
       
 19094                 console.log('version leaflet incompatible !');
       
 19095                 return;
       
 19096             }
       
 19097             L.Proj = proj4leaflet;
       
 19098             return L.Proj;
       
 19099         }
       
 19100     };
       
 19101 }({}, leaflet, proj4);
       
 19102 CommonUtilsRegister = function (proj4) {
       
 19103     var Register = {
       
 19104         isLoaded: false,
       
 19105         get: function (name) {
       
 19106             if (name === '' || name === null || typeof name === 'undefined') {
       
 19107                 return;
       
 19108             }
       
 19109             var s = name.split(':');
       
 19110             if (s.length !== 2) {
       
 19111                 return;
       
 19112             }
       
 19113             var register = s[0];
       
 19114             var code = s[1];
       
 19115             if (!this.hasOwnProperty(register)) {
       
 19116                 return;
       
 19117             }
       
 19118             if (!this[register].hasOwnProperty(code)) {
       
 19119                 return;
       
 19120             }
       
 19121             return this[register][code];
       
 19122         },
       
 19123         load: function () {
       
 19124             if (!this.isLoaded) {
       
 19125                 var registers = [
       
 19126                     'IGNF',
       
 19127                     'EPSG',
       
 19128                     'CRS'
       
 19129                 ];
       
 19130                 for (var i = 0; i < registers.length; i++) {
       
 19131                     var register = registers[i];
       
 19132                     var codes = this[register];
       
 19133                     for (var code in codes) {
       
 19134                         if (codes.hasOwnProperty(code)) {
       
 19135                             var name = register + ':' + code;
       
 19136                             proj4.defs(name, this.get(name));
       
 19137                         }
       
 19138                     }
       
 19139                 }
       
 19140                 this.isLoaded = true;
       
 19141             }
       
 19142         },
       
 19143         EPSG: {
       
 19144             4149: '+title=CH1903 +proj=longlat +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +no_defs ',
       
 19145             4150: '+title=CH1903plus +proj=longlat +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +no_defs ',
       
 19146             4151: '+title=CHTRF95 +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19147             4171: '+title=RGF93 +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19148             4230: '+title=ED50 +proj=longlat +ellps=intl +no_defs ',
       
 19149             4235: '+title=Guyane Francaise +proj=longlat +ellps=intl +no_defs ',
       
 19150             4258: '+title=ETRS89 +proj=longlat +ellps=GRS80 +no_defs ',
       
 19151             4275: '+title=NTF +proj=longlat +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +no_defs ',
       
 19152             4322: '+title=WGS 72 +proj=longlat +ellps=WGS72 +no_defs ',
       
 19153             4326: '+title=WGS 84 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ',
       
 19154             4467: '+proj=utm +zone=21 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19155             4470: '+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19156             4471: '+proj=utm +zone=38 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19157             4474: '+proj=utm +zone=38 +south +ellps=intl +towgs84=-382,-59,-262,0,0,0,0 +units=m +no_defs ',
       
 19158             4558: '+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19159             4559: '+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19160             4621: '+title=Fort Marigot +proj=longlat +ellps=intl +towgs84=137,248,-430,0,0,0,0 +no_defs ',
       
 19161             4622: '+title=Guadeloupe 1948 +proj=longlat +ellps=intl +no_defs ',
       
 19162             4623: '+title=CSG67 +proj=longlat +ellps=intl +towgs84=-186,230,110,0,0,0,0 +no_defs ',
       
 19163             4624: '+title=RGFG95 +proj=longlat +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +no_defs ',
       
 19164             4625: '+title=Martinique 1938 +proj=longlat +ellps=intl +no_defs ',
       
 19165             4626: '+title=Reunion 1947 +proj=longlat +ellps=intl +no_defs ',
       
 19166             4627: '+title=RGR92 +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19167             4628: '+title=Tahiti 52 +proj=longlat +ellps=intl +towgs84=162,117,154,0,0,0,0 +no_defs ',
       
 19168             4629: '+title=Tahaa 54 +proj=longlat +ellps=intl +no_defs ',
       
 19169             4630: '+title=IGN72 Nuku Hiva +proj=longlat +ellps=intl +no_defs ',
       
 19170             4632: '+title=Combani 1950 +proj=longlat +ellps=intl +towgs84=-382,-59,-262,0,0,0,0 +no_defs ',
       
 19171             4633: '+title=IGN56 Lifou +proj=longlat +ellps=intl +no_defs ',
       
 19172             4634: '+title=IGN72 Grand Terre +proj=longlat +ellps=intl +no_defs ',
       
 19173             4637: '+title=Perroud 1950 +proj=longlat +ellps=intl +towgs84=325,154,172,0,0,0,0 +no_defs ',
       
 19174             4638: '+title=Saint Pierre et Miquelon 1950 +proj=longlat +ellps=clrk66 +towgs84=30,430,368,0,0,0,0 +no_defs ',
       
 19175             4640: '+title=RRAF 1991 +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19176             4641: '+title=IGN53 Mare +proj=longlat +ellps=intl +no_defs ',
       
 19177             4645: '+title=RGNC 1991 +proj=longlat +ellps=intl +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19178             4687: '+proj=longlat +ellps=GRS80 +no_defs ',
       
 19179             4662: '+title=IGN72 Grande Terre +proj=longlat +ellps=intl +no_defs ',
       
 19180             4689: '+title=IGN63 Hiva Oa +proj=longlat +ellps=intl +no_defs ',
       
 19181             4690: '+title=Tahiti 79 +proj=longlat +ellps=intl +no_defs ',
       
 19182             4691: '+title=Moorea 87 +proj=longlat +ellps=intl +towgs84=215.525,149.593,176.229,-3.2624,-1.692,-1.1571,10.4773 +no_defs ',
       
 19183             4692: '+title=Maupiti 83 +proj=longlat +ellps=intl +towgs84=217.037,86.959,23.956,0,0,0,0 +no_defs ',
       
 19184             4698: '+title=IGN 1962 Kerguelen +proj=longlat +ellps=intl +towgs84=145,-187,103,0,0,0,0 +no_defs ',
       
 19185             4749: '+title=RGNC91-93 +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs ',
       
 19186             4750: '+title=ST87 Ouvea +proj=longlat +ellps=WGS84 +towgs84=-56.263,16.136,-22.856,0,0,0,0 +no_defs ',
       
 19187             4807: '+title=NTF (Paris) +proj=longlat +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +no_defs ',
       
 19188             2056: '+title=CH1903+ / LV95 +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs ',
       
 19189             2154: '+title=RGF93 / Lambert-93 +proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19190             2213: '+title=ETRS89 / TM 30 NE +proj=tmerc +lat_0=0 +lon_0=30 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs ',
       
 19191             2969: '+title=Fort Marigot / UTM zone 20N +proj=utm +zone=20 +ellps=intl +towgs84=137,248,-430,0,0,0,0 +units=m +no_defs ',
       
 19192             2970: '+title=Guadeloupe 1948 / UTM zone 20N +proj=utm +zone=20 +ellps=intl +units=m +no_defs ',
       
 19193             2971: '+title=CSG67 / UTM zone 22N +proj=utm +zone=22 +ellps=intl +towgs84=-186,230,110,0,0,0,0 +units=m +no_defs ',
       
 19194             2972: '+title=RGFG95 / UTM zone 22N +proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ',
       
 19195             2973: '+title=Martinique 1938 / UTM zone 20N +proj=utm +zone=20 +ellps=intl +units=m +no_defs ',
       
 19196             2975: '+title=RGR92 / UTM zone 40S +proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19197             2976: '+title=Tahiti 52 / UTM zone 6S +proj=utm +zone=6 +south +ellps=intl +towgs84=162,117,154,0,0,0,0 +units=m +no_defs ',
       
 19198             2977: '+title=Tahaa 54 / UTM zone 5S +proj=utm +zone=5 +south +ellps=intl +units=m +no_defs ',
       
 19199             2978: '+title=IGN72 Nuku Hiva / UTM zone 7S +proj=utm +zone=7 +south +ellps=intl +units=m +no_defs ',
       
 19200             2980: '+title=Combani 1950 / UTM zone 38S +proj=utm +zone=38 +south +ellps=intl +towgs84=-382,-59,-262,0,0,0,0 +units=m +no_defs ',
       
 19201             2981: '+title=IGN56 Lifou / UTM zone 58S +proj=utm +zone=58 +south +ellps=intl +units=m +no_defs ',
       
 19202             2982: '+title=IGN72 Grand Terre / UTM zone 58S (deprecated) +proj=utm +zone=58 +south +ellps=intl +units=m +no_defs ',
       
 19203             2984: '+title=RGNC 1991 / Lambert New Caledonia (deprecated) +proj=lcc +lat_1=-20.66666666666667 +lat_2=-22.33333333333333 +lat_0=-21.5 +lon_0=166 +x_0=400000 +y_0=300000 +ellps=intl +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19204             2986: '+title=Terre Adelie 1950 +proj=stere +towgs84=324.9120,153.2820,172.0260 +a=6378388.0000 +rf=297.0000000000000 +lat_0=-90.000000000 +lon_0=140.000000000 +lat_ts=-67.000000000 +k=0.96027295 +x_0=300000.000 +y_0=-2299363.482 +units=m +no_defs',
       
 19205             2987: '+title=Saint Pierre et Miquelon 1950 / UTM zone 21N +proj=utm +zone=21 +ellps=clrk66 +towgs84=30,430,368,0,0,0,0 +units=m +no_defs ',
       
 19206             2989: '+title=RRAF 1991 / UTM zone 20N +proj=utm +zone=20 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19207             2990: '+title=Reunion 1947 / TM Reunion (deprecated) +proj=tmerc +lat_0=-21.11666666666667 +lon_0=55.53333333333333 +k=1 +x_0=50000 +y_0=160000 +ellps=intl +units=m +no_defs ',
       
 19208             2995: '+title=IGN53 Mare / UTM zone 58S +proj=utm +zone=58 +south +ellps=intl +units=m +no_defs ',
       
 19209             3038: '+proj=utm +zone=26 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19210             3039: '+proj=utm +zone=27 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19211             3040: '+proj=utm +zone=28 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19212             3041: '+proj=utm +zone=29 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19213             3045: '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19214             3046: '+proj=utm +zone=34 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19215             3047: '+proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19216             3048: '+proj=utm +zone=36 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19217             3049: '+proj=utm +zone=37 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19218             3050: '+proj=utm +zone=38 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19219             3051: '+proj=utm +zone=39 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19220             3034: '+title=ETRS89 / ETRS-LCC +proj=lcc +lat_1=35 +lat_2=65 +lat_0=52 +lon_0=10 +x_0=4000000 +y_0=2800000 +ellps=GRS80 +units=m +no_defs ',
       
 19221             3035: '+title=ETRS89 / ETRS-LAEA +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs ',
       
 19222             3042: '+title=ETRS89 / ETRS-TM30 +proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ',
       
 19223             3043: '+title=ETRS89 / ETRS-TM31 +proj=utm +zone=31 +ellps=GRS80 +units=m +no_defs ',
       
 19224             3044: '+title=ETRS89 / ETRS-TM32 +proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs ',
       
 19225             25828: '+proj=utm +zone=28 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19226             25829: '+proj=utm +zone=29 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19227             25833: '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19228             25834: '+proj=utm +zone=34 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19229             25835: '+proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19230             25836: '+proj=utm +zone=36 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19231             25837: '+proj=utm +zone=37 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19232             25838: '+proj=utm +zone=38 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19233             3060: '+title=IGN72 Grande Terre / UTM zone 58S +proj=utm +zone=58 +south +ellps=intl +units=m +no_defs ',
       
 19234             3163: '+title=RGNC91-93 / Lambert New Caledonia +proj=lcc +lat_1=-20.66666666666667 +lat_2=-22.33333333333333 +lat_0=-21.5 +lon_0=166 +x_0=400000 +y_0=300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19235             3164: '+title=ST87 Ouvea / UTM zone 58S +proj=utm +zone=58 +south +ellps=WGS84 +towgs84=-56.263,16.136,-22.856,0,0,0,0 +units=m +no_defs ',
       
 19236             3165: '+title=NEA74 Noumea / Noumea Lambert +proj=lcc +lat_1=-22.24469175 +lat_2=-22.29469175 +lat_0=-22.26969175 +lon_0=166.44242575 +x_0=0.66 +y_0=1.02 +ellps=intl +units=m +no_defs ',
       
 19237             3166: '+title=NEA74 Noumea / Noumea Lambert 2 +proj=lcc +lat_1=-22.24472222222222 +lat_2=-22.29472222222222 +lat_0=-22.26972222222222 +lon_0=166.4425 +x_0=8.313000000000001 +y_0=-2.354 +ellps=intl +units=m +no_defs ',
       
 19238             3169: '+title=RGNC91-93 / UTM zone 57S +proj=utm +zone=57 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19239             3170: '+title=RGNC91-93 / UTM zone 58S +proj=utm +zone=58 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19240             3171: '+title=RGNC91-93 / UTM zone 59S +proj=utm +zone=59 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ',
       
 19241             3172: '+title=IGN53 Mare / UTM zone 59S +proj=utm +zone=59 +south +ellps=intl +units=m +no_defs ',
       
 19242             3296: '+title=RGPF / UTM zone 5S +proj=utm +zone=5 +south +ellps=GRS80 +units=m +no_defs ',
       
 19243             3297: '+title=RGPF / UTM zone 6S +proj=utm +zone=6 +south +ellps=GRS80 +units=m +no_defs ',
       
 19244             3298: '+title=RGPF / UTM zone 7S +proj=utm +zone=7 +south +ellps=GRS80 +units=m +no_defs ',
       
 19245             3299: '+title=RGPF / UTM zone 8S +proj=utm +zone=8 +south +ellps=GRS80 +units=m +no_defs ',
       
 19246             3302: '+title=IGN63 Hiva Oa / UTM zone 7S +proj=utm +zone=7 +south +ellps=intl +units=m +no_defs ',
       
 19247             3303: '+title=Fatu Iva 72 / UTM zone 7S +proj=utm +zone=7 +south +ellps=intl +towgs84=347.103,1078.12,2623.92,-33.8875,70.6773,-9.3943,186.074 +units=m +no_defs ',
       
 19248             3304: '+title=Tahiti 79 / UTM zone 6S +proj=utm +zone=6 +south +ellps=intl +units=m +no_defs ',
       
 19249             3305: '+title=Moorea 87 / UTM zone 6S +proj=utm +zone=6 +south +ellps=intl +towgs84=215.525,149.593,176.229,-3.2624,-1.692,-1.1571,10.4773 +units=m +no_defs ',
       
 19250             3306: '+title=Maupiti 83 / UTM zone 5S +proj=utm +zone=5 +south +ellps=intl +towgs84=217.037,86.959,23.956,0,0,0,0 +units=m +no_defs ',
       
 19251             3312: '+title=CSG67 / UTM zone 21N +proj=utm +zone=21 +ellps=intl +towgs84=-186,230,110,0,0,0,0 +units=m +no_defs ',
       
 19252             3313: '+title=RGFG95 / UTM zone 21N +proj=utm +zone=21 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m +no_defs ',
       
 19253             3336: '+title=IGN 1962 Kerguelen / UTM zone 42S +proj=utm +zone=42 +south +ellps=intl +towgs84=145,-187,103,0,0,0,0 +units=m +no_defs ',
       
 19254             3395: '+title=WGS 84 / World Mercator +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19255             3727: '+title=Reunion 1947 / TM Reunion +proj=tmerc +lat_0=-21.11666666666667 +lon_0=55.53333333333333 +k=1 +x_0=160000 +y_0=50000 +ellps=intl +units=m +no_defs ',
       
 19256             21781: '+title=CH1903 / LV03 +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs ',
       
 19257             25830: '+title=ETRS89 / UTM zone 30N +proj=utm +zone=30 +ellps=GRS80 +units=m +no_defs ',
       
 19258             25831: '+title=ETRS89 / UTM zone 31N +proj=utm +zone=31 +ellps=GRS80 +units=m +no_defs ',
       
 19259             25832: '+title=ETRS89 / UTM zone 32N +proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs ',
       
 19260             27561: '+title=NTF (Paris) / Lambert Nord France +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19261             27562: '+title=NTF (Paris) / Lambert Centre France +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19262             27563: '+title=NTF (Paris) / Lambert Sud France +proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.9998774990000001 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19263             27564: '+title=NTF (Paris) / Lambert Corse +proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.9999447100000001 +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19264             27571: '+title=NTF (Paris) / Lambert zone I +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19265             27572: '+title=NTF (Paris) / Lambert zone II +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19266             27573: '+title=NTF (Paris) / Lambert zone III +proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.9998774990000001 +x_0=600000 +y_0=3200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19267             27574: '+title=NTF (Paris) / Lambert zone IV +proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.9999447100000001 +x_0=234.358 +y_0=4185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19268             27581: '+title=NTF (Paris) / France I (deprecated) +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19269             27582: '+title=NTF (Paris) / France II (deprecated) +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19270             27583: '+title=NTF (Paris) / France III (deprecated) +proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.9998774990000001 +x_0=600000 +y_0=3200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19271             27584: '+title=NTF (Paris) / France IV (deprecated) +proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.9999447100000001 +x_0=234.358 +y_0=4185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19272             27591: '+title=NTF (Paris) / Nord France (deprecated) +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19273             27592: '+title=NTF (Paris) / Centre France (deprecated) +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19274             27593: '+title=NTF (Paris) / Sud France (deprecated) +proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.9998774990000001 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19275             27594: '+title=NTF (Paris) / Corse (deprecated) +proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.9999447100000001 +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ',
       
 19276             32601: '+proj=utm +zone=1 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19277             32602: '+proj=utm +zone=2 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19278             32603: '+proj=utm +zone=3 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19279             32604: '+proj=utm +zone=4 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19280             32605: '+proj=utm +zone=5 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19281             32606: '+proj=utm +zone=6 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19282             32607: '+proj=utm +zone=7 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19283             32608: '+proj=utm +zone=8 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19284             32609: '+proj=utm +zone=9 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19285             32610: '+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19286             32611: '+proj=utm +zone=11 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19287             32612: '+proj=utm +zone=12 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19288             32613: '+proj=utm +zone=13 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19289             32614: '+proj=utm +zone=14 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19290             32615: '+proj=utm +zone=15 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19291             32616: '+proj=utm +zone=16 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19292             32617: '+proj=utm +zone=17 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19293             32618: '+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19294             32619: '+proj=utm +zone=19 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19295             32620: '+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19296             32621: '+proj=utm +zone=21 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19297             32622: '+proj=utm +zone=22 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19298             32623: '+proj=utm +zone=23 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19299             32624: '+proj=utm +zone=24 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19300             32625: '+proj=utm +zone=25 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19301             32626: '+proj=utm +zone=26 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19302             32627: '+proj=utm +zone=27 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19303             32628: '+proj=utm +zone=28 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19304             32629: '+proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19305             32630: '+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19306             32631: '+proj=utm +zone=31 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19307             32632: '+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19308             32633: '+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19309             32634: '+proj=utm +zone=34 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19310             32635: '+proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19311             32636: '+proj=utm +zone=36 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19312             32637: '+proj=utm +zone=37 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19313             32638: '+proj=utm +zone=38 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19314             32639: '+proj=utm +zone=39 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19315             32640: '+proj=utm +zone=40 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19316             32641: '+proj=utm +zone=41 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19317             32642: '+proj=utm +zone=42 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19318             32643: '+proj=utm +zone=43 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19319             32644: '+proj=utm +zone=44 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19320             32645: '+proj=utm +zone=45 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19321             32646: '+proj=utm +zone=46 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19322             32647: '+proj=utm +zone=47 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19323             32648: '+proj=utm +zone=48 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19324             32649: '+proj=utm +zone=49 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19325             32650: '+proj=utm +zone=50 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19326             32651: '+proj=utm +zone=51 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19327             32652: '+proj=utm +zone=52 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19328             32653: '+proj=utm +zone=53 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19329             32654: '+proj=utm +zone=54 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19330             32655: '+proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19331             32656: '+proj=utm +zone=56 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19332             32657: '+proj=utm +zone=57 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19333             32658: '+proj=utm +zone=58 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19334             32659: '+proj=utm +zone=59 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19335             32660: '+proj=utm +zone=60 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19336             32661: '+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19337             32662: '+title=WGS 84 / Plate Carree +proj=eqc +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19338             32701: '+proj=utm +zone=1 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19339             32702: '+proj=utm +zone=2 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19340             32703: '+proj=utm +zone=3 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19341             32704: '+proj=utm +zone=4 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19342             32705: '+proj=utm +zone=5 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19343             32706: '+proj=utm +zone=6 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19344             32707: '+proj=utm +zone=7 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19345             32708: '+proj=utm +zone=8 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19346             32709: '+proj=utm +zone=9 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19347             32710: '+proj=utm +zone=10 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19348             32711: '+proj=utm +zone=11 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19349             32712: '+proj=utm +zone=12 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19350             32713: '+proj=utm +zone=13 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19351             32714: '+proj=utm +zone=14 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19352             32715: '+proj=utm +zone=15 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19353             32716: '+proj=utm +zone=16 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19354             32717: '+proj=utm +zone=17 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19355             32718: '+proj=utm +zone=18 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19356             32719: '+proj=utm +zone=19 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19357             32720: '+proj=utm +zone=20 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19358             32721: '+proj=utm +zone=21 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19359             32722: '+proj=utm +zone=22 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19360             32723: '+proj=utm +zone=23 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19361             32724: '+proj=utm +zone=24 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19362             32725: '+proj=utm +zone=25 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19363             32726: '+proj=utm +zone=26 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19364             32727: '+proj=utm +zone=27 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19365             32728: '+proj=utm +zone=28 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19366             32729: '+proj=utm +zone=29 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19367             32730: '+proj=utm +zone=30 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19368             32731: '+proj=utm +zone=31 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19369             32732: '+proj=utm +zone=32 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19370             32733: '+proj=utm +zone=33 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19371             32734: '+proj=utm +zone=34 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19372             32735: '+proj=utm +zone=35 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19373             32736: '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19374             32737: '+proj=utm +zone=37 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19375             32738: '+proj=utm +zone=38 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19376             32739: '+proj=utm +zone=39 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19377             32740: '+proj=utm +zone=40 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19378             32741: '+proj=utm +zone=41 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19379             32742: '+proj=utm +zone=42 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19380             32743: '+proj=utm +zone=43 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19381             32744: '+proj=utm +zone=44 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19382             32745: '+proj=utm +zone=45 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19383             32746: '+proj=utm +zone=46 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19384             32747: '+proj=utm +zone=47 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19385             32748: '+proj=utm +zone=48 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19386             32749: '+proj=utm +zone=49 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19387             32750: '+proj=utm +zone=50 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19388             32751: '+proj=utm +zone=51 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19389             32752: '+proj=utm +zone=52 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19390             32753: '+proj=utm +zone=53 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19391             32754: '+proj=utm +zone=54 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19392             32755: '+proj=utm +zone=55 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19393             32756: '+proj=utm +zone=56 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19394             32757: '+proj=utm +zone=57 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19395             32758: '+proj=utm +zone=58 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19396             32759: '+proj=utm +zone=59 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19397             32760: '+proj=utm +zone=60 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19398             32761: '+proj=stere +lat_0=-90 +lat_ts=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
       
 19399             310024802: '+title=Geoportail - France metropolitaine +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=46.500000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19400             310915814: '+title=Geoportail - Antilles francaises +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=15.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19401             310486805: '+title=Geoportail - Guyane +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=4.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19402             310700806: '+title=Geoportail - Reunion et dependances +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-21.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19403             310702807: '+title=Geoportail - Mayotte +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-12.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19404             310706808: '+title=Geoportail - Saint-Pierre et Miquelon +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=47.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19405             310547809: '+title=Geoportail - Nouvelle-Caledonie +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-22.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19406             310642810: '+title=Geoportail - Wallis et Futuna +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.000000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-14.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19407             310032811: '+title=Geoportail - Polynesie francaise +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-15.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19408             310642812: '+title=Geoportail - Kerguelen +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-49.500000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19409             310642801: '+title=Geoportail - Crozet +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-46.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19410             310642813: '+title=Geoportail - Amsterdam et Saint-Paul +proj=eqc +nadgrids=null +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-38.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19411             310642901: '+title=Geoportail - Monde +proj=mill +towgs84=0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.000000 +a=6378137.0000 +rf=298.2572221010000 +lon_0=0.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19412             5489: '+title=RGAF09 geographiques (dms) +proj=longlat +nadgrids=@null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137 +rf=298.257222101 +units=m +no_defs',
       
 19413             5490: '+title=RGAF09 UTM Nord Fuseau 20 +proj=tmerc +nadgrids=@null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137 +rf=298.257222101 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs'
       
 19414         },
       
 19415         CRS: { 84: '+title=WGS 84 longitude-latitude +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ' },
       
 19416         IGNF: {
       
 19417             AMST63: '+title=Amsterdam 1963 +proj=geocent +towgs84=109.753,-528.133,-362.244,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19418             CROZ63: '+title=Crozet 1963 +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19419             CSG67: '+title=Guyane CSG67 +proj=geocent +towgs84=-193.0660,236.9930,105.4470,0.4814,-0.8074,0.1276,1.564900 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19420             ED50: '+title=ED50 +proj=geocent +towgs84=-84.0000,-97.0000,-117.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19421             ETRS89: '+title=Systeme de reference terrestre Europeen (1989) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19422             GUAD48: '+title=Guadeloupe Ste Anne +proj=geocent +towgs84=-472.2900,-5.6300,-304.1200,0.4362,-0.8374,0.2563,1.898400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19423             GUADFM49: '+title=Guadeloupe Fort Marigot +proj=geocent +towgs84=136.5960,248.1480,-429.7890 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19424             IGN63: '+title=IGN 1963 (Hiva Oa, Tahuata, Mohotani) +proj=geocent +towgs84=410.7210,55.0490,80.7460,-2.5779,-2.3514,-0.6664,17.331100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19425             IGN72: '+title=IGN 1972 Grande-Terre / Ile des Pins +proj=geocent +towgs84=-11.6400,-348.6000,291.6800 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19426             KERG62CAR: '+title=Kerguelen - K0 +proj=geocent +towgs84=144.8990,-186.7700,100.9230 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19427             MART38: '+title=Martinique Fort-Desaix +proj=geocent +towgs84=126.9260,547.9390,130.4090,-2.7867,5.1612,-0.8584,13.822650 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19428             MAYO50: '+title=Mayotte Combani +proj=geocent +towgs84=-599.9280,-275.5520,-195.6650,-0.0835,-0.4715,0.0602,49.281400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19429             MOOREA87: '+title=Moorea 1987 +proj=geocent +towgs84=215.9820,149.5930,176.2290,3.2624,1.6920,1.1571,10.477300 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19430             NTF: '+title=Nouvelle Triangulation Francaise +proj=geocent +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +units=m +no_defs',
       
 19431             NUKU72: '+title=IGN 1972 Nuku Hiva +proj=geocent +towgs84=165.7320,216.7200,180.5050,-0.6434,-0.4512,-0.0791,7.420400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19432             REUN47: '+title=Reunion 1947 +proj=geocent +towgs84=789.5240,-626.4860,-89.9040,0.6006,76.7946,-10.5788,-32.324100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19433             RGF93: '+title=Reseau geodesique francais 1993 +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19434             RGFG95: '+title=Reseau geodesique francais de Guyane 1995 +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19435             RGM04: '+title=RGM04 (Reseau Geodesique de Mayotte 2004) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19436             RGNC: '+title=Reseau Geodesique de Nouvelle-Caledonie +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19437             RGPF: '+title=RGPF (Reseau Geodesique de Polynesie Francaise) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19438             RGR92: '+title=Reseau geodesique Reunion 1992 +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19439             RGSPM06: '+title=Reseau Geodesique Saint-Pierre-et-Miquelon (2006) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19440             RGTAAF07: '+title=Reseau Geodesique des TAAF (2007) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19441             RRAF91: '+title=RRAF 1991 (Reseau de Reference des Antilles Francaises) +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19442             STPL69: '+title=Saint-Paul 1969 +proj=geocent +towgs84=225.571,-346.608,-46.567,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19443             STPM50: '+title=St Pierre et Miquelon 1950 +proj=geocent +towgs84=-95.5930,573.7630,173.4420,-0.9602,1.2510,-1.3918,42.626500 +a=6378206.4000 +rf=294.9786982000000 +units=m +no_defs',
       
 19444             TAHAA: '+title=Raiatea - Tahaa 51-54 (Tahaa, Base Terme Est) +proj=geocent +towgs84=72.4380,345.9180,79.4860,-1.6045,-0.8823,-0.5565,1.374600 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19445             TAHI79: '+title=IGN79 (Tahiti) Iles de la Societe +proj=geocent +towgs84=221.5250,152.9480,176.7680,2.3847,1.3896,0.8770,11.474100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19446             TERA50: '+title=Pointe Geologie - Perroud 1950 +proj=geocent +towgs84=324.9120,153.2820,172.0260 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19447             WALL78: '+title=Wallis-Uvea 1978 (MOP78) +proj=geocent +towgs84=253.0000,-133.0000,-127.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19448             WGS72: '+title=World Geodetic System 1972 +proj=geocent +towgs84=0.0000,12.0000,6.0000 +a=6378135.0000 +rf=298.2600000000000 +units=m +no_defs',
       
 19449             WGS84: '+title=World Geodetic System 1984 +proj=geocent +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19450             AMST63GEO: '+title=Amsterdam 1963 +proj=longlat +towgs84=109.753,-528.133,-362.244,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19451             CROZ63GEO: '+title=Crozet 1963 +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19452             CSG67GEO: '+title=Guyane CSG67 +proj=longlat +towgs84=-193.0660,236.9930,105.4470,0.4814,-0.8074,0.1276,1.564900 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19453             ED50G: '+title=ED50 +proj=longlat +towgs84=-84.0000,-97.0000,-117.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19454             GUAD48GEO: '+title=Guadeloupe Ste Anne +proj=longlat +towgs84=-472.2900,-5.6300,-304.1200,0.4362,-0.8374,0.2563,1.898400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19455             GUADFM49GEO: '+title=Guadeloupe Fort Marigot +proj=longlat +towgs84=136.5960,248.1480,-429.7890 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19456             IGN63GEO: '+title=IGN 1963 (Hiva Oa, Tahuata, Mohotani) +proj=longlat +towgs84=410.7210,55.0490,80.7460,-2.5779,-2.3514,-0.6664,17.331100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19457             IGN72GEO: '+title=IGN 1972 Grande-Terre / Ile des Pins +proj=longlat +towgs84=-11.6400,-348.6000,291.6800 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19458             KERG62GEO: '+title=Kerguelen - K0 +proj=longlat +towgs84=144.8990,-186.7700,100.9230 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19459             MART38GEO: '+title=Martinique Fort-Desaix +proj=longlat +towgs84=126.9260,547.9390,130.4090,-2.7867,5.1612,-0.8584,13.822650 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19460             MAYO50GEO: '+title=Mayotte Combani +proj=longlat +towgs84=-599.9280,-275.5520,-195.6650,-0.0835,-0.4715,0.0602,49.281400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19461             MOOREA87GEO: '+title=Moorea 1987 +proj=longlat +towgs84=215.9820,149.5930,176.2290,3.2624,1.6920,1.1571,10.477300 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19462             NTFG: '+title=Nouvelle Triangulation Francaise Greenwich degres sexagesimaux +proj=longlat +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +units=m +no_defs',
       
 19463             NTFP: '+title=Nouvelle Triangulation Francaise Paris grades +proj=longlat +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +units=m +no_defs',
       
 19464             NUKU72GEO: '+title=IGN 1972 Nuku Hiva +proj=longlat +towgs84=165.7320,216.7200,180.5050,-0.6434,-0.4512,-0.0791,7.420400 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19465             REUN47GEO: '+title=Reunion 1947 +proj=longlat +towgs84=789.5240,-626.4860,-89.9040,0.6006,76.7946,-10.5788,-32.324100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19466             RGF93G: '+title=Reseau geodesique francais 1993 +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19467             RGFG95GEO: '+title=Reseau geodesique francais de Guyane 1995 +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19468             RGM04GEO: '+title=RGM04 (Reseau Geodesique de Mayotte 2004) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19469             RGNCGEO: '+title=Reseau Geodesique de Nouvelle-Caledonie +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19470             RGPFGEO: '+title=RGPF (Reseau Geodesique de Polynesie Francaise) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19471             RGR92GEO: '+title=Reseau geodesique de la Reunion 1992 +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19472             RGSPM06GEO: '+title=Saint-Pierre-et-Miquelon (2006) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19473             RGTAAF07G: '+title=Reseau Geodesique des TAAF (2007) (dms) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19474             STPL69GEO: '+title=Saint-Paul 1969 +proj=longlat +towgs84=225.571,-346.608,-46.567,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19475             STPM50GEO: '+title=St Pierre et Miquelon 1950  +proj=longlat +towgs84=-95.5930,573.7630,173.4420,-0.9602,1.2510,-1.3918,42.626500 +a=6378206.4000 +rf=294.9786982000000 +units=m +no_defs',
       
 19476             TAHAAGEO: '+title=Raiatea - Tahaa 51-54 (Tahaa, Base Terme Est) +proj=longlat +towgs84=72.4380,345.9180,79.4860,-1.6045,-0.8823,-0.5565,1.374600 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19477             TAHI79GEO: '+title=IGN79 (Tahiti) Iles de la Societe +proj=longlat +towgs84=221.5250,152.9480,176.7680,2.3847,1.3896,0.8770,11.474100 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19478             TERA50G: '+title=Pointe Geologie - Perroud 1950 +proj=longlat +towgs84=324.9120,153.2820,172.0260 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19479             WALL78GEO: '+title=Wallis - Uvea 1978 (MOP78) +proj=longlat +towgs84=253.0000,-133.0000,-127.0000 +a=6378388.0000 +rf=297.0000000000000 +units=m +no_defs',
       
 19480             WGS72G: '+title=WGS72 +proj=longlat +towgs84=0.0000,12.0000,6.0000 +a=6378135.0000 +rf=298.2600000000000 +units=m +no_defs',
       
 19481             WGS84G: '+title=World Geodetic System 1984 +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19482             WGS84RRAFGEO: '+title=Reseau de reference des Antilles francaises (1988-1991) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19483             XGEO: '+title=Systeme CIO-BIH +proj=longlat +towgs84=0.0000,0.0000,0.5000,0.0000,0.0000,0.0140,-0.100000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19484             AMST63UTM43S: '+title=Amsterdam 1963 UTM fuseau 43 Sud +proj=tmerc +towgs84=109.753,-528.133,-362.244,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=75.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19485             CROZ63UTM39S: '+title=Crozet 1963 +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=51.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19486             CSG67UTM21: '+title=Guyane CSG67 UTM fuseau 21 +proj=tmerc +towgs84=-193.0660,236.9930,105.4470,0.4814,-0.8074,0.1276,1.564900 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-57.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19487             CSG67UTM22: '+title=Guyane CSG67 UTM fuseau 22 +proj=tmerc +towgs84=-193.0660,236.9930,105.4470,0.4814,-0.8074,0.1276,1.564900 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-51.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19488             GEOPORTALANF: '+title=Geoportail - Antilles francaises +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=15.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19489             GEOPORTALASP: '+title=Geoportail - Amsterdam et Saint-Paul +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-38.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19490             GEOPORTALCRZ: '+title=Geoportail - Crozet +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-46.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19491             GEOPORTALFXX: '+title=Geoportail - France metropolitaine +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=46.500000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19492             GEOPORTALGUF: '+title=Geoportail - Guyane +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=4.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19493             GEOPORTALKER: '+title=Geoportail - Kerguelen +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-49.500000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19494             GEOPORTALMYT: '+title=Geoportail - Mayotte +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-12.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19495             GEOPORTALNCL: '+title=Geoportail - Nouvelle-Caledonie +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-22.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19496             GEOPORTALPYF: '+title=Geoportail - Polynesie francaise +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-15.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19497             GEOPORTALREU: '+title=Geoportail - Reunion et dependances +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-21.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19498             GEOPORTALSPM: '+title=Geoportail - Saint-Pierre et Miquelon +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=47.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19499             GEOPORTALWLF: '+title=Geoportail - Wallis et Futuna +proj=eqc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=0.000000000 +lat_ts=-14.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19500             GUAD48UTM20: '+title=Guadeloupe Ste Anne +proj=tmerc +towgs84=-472.2900,-5.6300,-304.1200,0.4362,-0.8374,0.2563,1.898400 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19501             GUADFM49U20: '+title=Guadeloupe Fort Marigot  +proj=tmerc +towgs84=136.5960,248.1480,-429.7890 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19502             IGN63UTM7S: '+title=IGN 1963 - Hiva Oa, Tahuata, Mohotani - UTM fuseau 7 Sud +proj=tmerc +towgs84=410.7210,55.0490,80.7460,-2.5779,-2.3514,-0.6664,17.331100 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-141.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19503             IGN72UTM58S: '+title=IGN 1972 - UTM fuseau 58 Sud +proj=tmerc +towgs84=-11.6400,-348.6000,291.6800 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=165.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19504             KERG62UTM42S: '+title=Kerguelen 1962 +proj=tmerc +towgs84=144.8990,-186.7700,100.9230 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=69.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19505             LAMB1: '+title=Lambert I +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=49.500000000 +lon_0=0.000000000 +k_0=0.99987734 +lat_1=49.500000000 +x_0=600000.000 +y_0=200000.000 +units=m +no_defs',
       
 19506             LAMB1C: '+title=Lambert I Carto +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=49.500000000 +lon_0=0.000000000 +k_0=0.99987734 +lat_1=49.500000000 +x_0=600000.000 +y_0=1200000.000 +units=m +no_defs',
       
 19507             LAMB2: '+title=Lambert II +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=46.800000000 +lon_0=0.000000000 +k_0=0.99987742 +lat_1=46.800000000 +x_0=600000.000 +y_0=200000.000 +units=m +no_defs',
       
 19508             LAMB2C: '+title=Lambert II Carto +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=46.800000000 +lon_0=0.000000000 +k_0=0.99987742 +lat_1=46.800000000 +x_0=600000.000 +y_0=2200000.000 +units=m +no_defs',
       
 19509             LAMB3: '+title=Lambert III +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=44.100000000 +lon_0=0.000000000 +k_0=0.99987750 +lat_1=44.100000000 +x_0=600000.000 +y_0=200000.000 +units=m +no_defs',
       
 19510             LAMB3C: '+title=Lambert III Carto +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=44.100000000 +lon_0=0.000000000 +k_0=0.99987750 +lat_1=44.100000000 +x_0=600000.000 +y_0=3200000.000 +units=m +no_defs',
       
 19511             LAMB4: '+title=Lambert IV +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=42.165000000 +lon_0=0.000000000 +k_0=0.99994471 +lat_1=42.165000000 +x_0=234.358 +y_0=185861.369 +units=m +no_defs',
       
 19512             LAMB4C: '+title=Lambert IV Carto +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=42.165000000 +lon_0=0.000000000 +k_0=0.99994471 +lat_1=42.165000000 +x_0=234.358 +y_0=4185861.369 +units=m +no_defs',
       
 19513             LAMB93: '+title=Lambert 93 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=46.500000000 +lon_0=3.000000000 +lat_1=44.000000000 +lat_2=49.000000000 +x_0=700000.000 +y_0=6600000.000 +units=m +no_defs',
       
 19514             RGF93CC42: '+title=Lambert conique conforme Zone 1 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=42.000000000 +lon_0=3.000000000 +lat_1=41.200000000 +lat_2=42.800000000 +x_0=1700000.000 +y_0=1200000.000 +units=m +no_defs',
       
 19515             RGF93CC43: '+title=Lambert conique conforme Zone 2 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=43.000000000 +lon_0=3.000000000 +lat_1=42.200000000 +lat_2=43.800000000 +x_0=1700000.000 +y_0=2200000.000 +units=m +no_defs',
       
 19516             RGF93CC44: '+title=Lambert conique conforme Zone 3 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=44.000000000 +lon_0=3.000000000 +lat_1=43.200000000 +lat_2=44.800000000 +x_0=1700000.000 +y_0=3200000.000 +units=m +no_defs',
       
 19517             RGF93CC45: '+title=Lambert conique conforme Zone 4 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=45.000000000 +lon_0=3.000000000 +lat_1=44.200000000 +lat_2=45.800000000 +x_0=1700000.000 +y_0=4200000.000 +units=m +no_defs',
       
 19518             RGF93CC46: '+title=Lambert conique conforme Zone 5 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=46.000000000 +lon_0=3.000000000 +lat_1=45.200000000 +lat_2=46.800000000 +x_0=1700000.000 +y_0=5200000.000 +units=m +no_defs',
       
 19519             RGF93CC47: '+title=Lambert conique conforme Zone 6 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=47.000000000 +lon_0=3.000000000 +lat_1=46.200000000 +lat_2=47.800000000 +x_0=1700000.000 +y_0=6200000.000 +units=m +no_defs',
       
 19520             RGF93CC48: '+title=Lambert conique conforme Zone 7 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=48.000000000 +lon_0=3.000000000 +lat_1=47.200000000 +lat_2=48.800000000 +x_0=1700000.000 +y_0=7200000.000 +units=m +no_defs',
       
 19521             RGF93CC49: '+title=Lambert conique conforme Zone 8 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=49.000000000 +lon_0=3.000000000 +lat_1=48.200000000 +lat_2=49.800000000 +x_0=1700000.000 +y_0=8200000.000 +units=m +no_defs',
       
 19522             RGF93CC50: '+title=Lambert conique conforme Zone 9 +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=50.000000000 +lon_0=3.000000000 +lat_1=49.200000000 +lat_2=50.800000000 +x_0=1700000.000 +y_0=9200000.000 +units=m +no_defs',
       
 19523             LAMBE: '+title=Lambert II etendu +proj=lcc +nadgrids=ntf_r93.gsb,null +wktext +towgs84=-168.0000,-60.0000,320.0000 +a=6378249.2000 +rf=293.4660210000000 +pm=2.337229167 +lat_0=46.800000000 +lon_0=0.000000000 +k_0=0.99987742 +lat_1=46.800000000 +x_0=600000.000 +y_0=2200000.000 +units=m +no_defs',
       
 19524             MART38UTM20: '+title=Martinique Fort-Desaix +proj=tmerc +towgs84=126.9260,547.9390,130.4090,-2.7867,5.1612,-0.8584,13.822650 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19525             MAYO50UTM38S: '+title=Mayotte Combani +proj=tmerc +towgs84=-599.9280,-275.5520,-195.6650,-0.0835,-0.4715,0.0602,49.281400 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=45.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19526             MILLER: '+title=Geoportail - Monde +proj=mill +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lon_0=0.000000000 +x_0=0.000 +y_0=0.000 +units=m +no_defs',
       
 19527             MOOREA87U6S: '+title=Moorea 1987 - UTM fuseau 6 Sud +proj=tmerc +towgs84=215.9820,149.5930,176.2290,3.2624,1.6920,1.1571,10.477300 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-147.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19528             NUKU72U7S: '+title=IGN 1972 Nuku Hiva - UTM fuseau 7 Sud +proj=tmerc +towgs84=165.7320,216.7200,180.5050,-0.6434,-0.4512,-0.0791,7.420400 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-141.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19529             REUN47GAUSSL: '+title=Reunion Gauss Laborde +proj=gstmerc +towgs84=789.5240,-626.4860,-89.9040,0.6006,76.7946,-10.5788,-32.324100 +a=6378388.0000 +rf=297.0000000000000 +lat_0=-21.116666667 +lon_0=55.533333333 +k_0=1.00000000 +x_0=160000.000 +y_0=50000.000 +units=m +no_defs',
       
 19530             RGM04UTM38S: '+title=UTM fuseau 38 Sud (Reseau Geodesique de Mayotte 2004) +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=45.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19531             RGNCUTM57S: '+title=Reseau Geodesique de Nouvelle-Caledonie - UTM fuseau 57 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=159.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19532             RGNCUTM58S: '+title=Reseau Geodesique de Nouvelle-Caledonie - UTM fuseau 58 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=165.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19533             RGNCUTM59S: '+title=Reseau Geodesique de Nouvelle-Caledonie - UTM fuseau 59 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=171.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19534             RGPFUTM5S: '+title=RGPF - UTM fuseau 5 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-153.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19535             RGPFUTM6S: '+title=RGPF - UTM fuseau 6 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-147.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19536             RGPFUTM7S: '+title=RGPF - UTM fuseau 7 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-141.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19537             RGR92UTM40S: '+title=RGR92 UTM fuseau 40 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=57.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19538             RGSPM06U21: '+title=Saint-Pierre-et-Miquelon (2006) UTM Fuseau 21 Nord +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-57.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19539             STPL69UTM43S: '+title=Saint-Paul 1969 UTM fuseau 43 Sud +proj=tmerc +towgs84=225.571,-346.608,-46.567,0,0,0,0 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=75.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19540             STPM50UTM21: '+title=St Pierre et Miquelon 1950 +proj=tmerc +towgs84=-95.5930,573.7630,173.4420,-0.9602,1.2510,-1.3918,42.626500 +a=6378206.4000 +rf=294.9786982000000 +lat_0=0.000000000 +lon_0=-57.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19541             TAHAAUTM05S: '+title=Tahaa 1951 +proj=tmerc +towgs84=72.4380,345.9180,79.4860,-1.6045,-0.8823,-0.5565,1.374600 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-153.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19542             TAHI51UTM06S: '+title=Tahiti-Terme Nord UTM fuseau 6 Sud +proj=tmerc +towgs84=162.0000,117.0000,154.0000 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-147.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19543             TAHI79UTM6S: '+title=Tahiti 1979 +proj=tmerc +towgs84=221.5250,152.9480,176.7680,2.3847,1.3896,0.8770,11.474100 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-147.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19544             TERA50STEREO: '+title=Terre Adelie 1950 +proj=stere +towgs84=324.9120,153.2820,172.0260 +a=6378388.0000 +rf=297.0000000000000 +lat_0=-90.000000000 +lon_0=140.000000000 +lat_ts=-67 +k=0.96027295 +x_0=300000.000 +y_0=-2299363.482 +units=m +no_defs',
       
 19545             UTM01SW84: '+title=World Geodetic System 1984 UTM fuseau 01 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-177.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19546             UTM20W84GUAD: '+title=World Geodetic System 1984 UTM fuseau 20 Nord-Guadeloupe +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19547             UTM20W84MART: '+title=World Geodetic System 1984 UTM fuseau 20 Nord-Martinique +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-63.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19548             UTM22RGFG95: '+title=RGFG95 UTM fuseau 22 Nord-Guyane +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-51.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19549             UTM39SW84: '+title=World Geodetic System 1984 UTM fuseau 39 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=51.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19550             UTM42SW84: '+title=World Geodetic System 1984 UTM fuseau 42 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=69.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19551             UTM43SW84: '+title=World Geodetic System 1984 UTM fuseau 43 Sud +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=75.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19552             WALL78UTM1S: '+title=Wallis-Uvea 1978 (MOP78) UTM 1 SUD +proj=tmerc +towgs84=253.0000,-133.0000,-127.0000 +a=6378388.0000 +rf=297.0000000000000 +lat_0=0.000000000 +lon_0=-177.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=10000000.000 +units=m +no_defs',
       
 19553             ETRS89GEO: '+title=ETRS89 geographiques (dms) +proj=longlat +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +units=m +no_defs',
       
 19554             ETRS89LAEA: '+title=ETRS89 Lambert Azimutal Equal Area +proj=laea +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=52.000000000 +lon_0=10.000000000 +x_0=4321000.000 +y_0=3210000.000 +units=m +no_defs',
       
 19555             ETRS89LCC: '+title=ETRS89 Lambert Conformal Conic +proj=lcc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=52.000000000 +lon_0=9.999999995 +lat_1=35.000000000 +lat_2=65.000000000 +x_0=4000000.000 +y_0=2800000.000 +units=m +no_defs',
       
 19556             UTM26ETRS89: '+title=Europe - de 30d a 24d Ouest +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-27.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19557             UTM27ETRS89: '+title=Europe - de 24d a 18d Ouest +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-21.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19558             UTM28ETRS89: '+title=Europe - de 18d a 12d Ouest +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-15.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19559             UTM29ETRS89: '+title=Europe - de 12d a 6d Ouest +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-9.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19560             UTM30ETRS89: '+title=Europe - de -6d a 0d Ouest +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=-3.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19561             UTM31ETRS89: '+title=Europe - de 0d a 6d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=3.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19562             UTM32ETRS89: '+title=Europe - de 6d a 12d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=9.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19563             UTM33ETRS89: '+title=Europe - de 12d a 18d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=15.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19564             UTM34ETRS89: '+title=Europe - de 18d a 24d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=21.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19565             UTM35ETRS89: '+title=Europe - de 24d a 30d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=27.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19566             UTM36ETRS89: '+title=Europe - de 30d a 36d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=33.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19567             UTM37ETRS89: '+title=Europe - de 36d a 42d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=39.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs',
       
 19568             UTM38ETRS89: '+title=Europe - de 42d a 48d Est +proj=tmerc +nadgrids=null +wktext +towgs84=0.0000,0.0000,0.0000 +a=6378137.0000 +rf=298.2572221010000 +lat_0=0.000000000 +lon_0=45.000000000 +k_0=0.99960000 +x_0=500000.000 +y_0=0.000 +units=m +no_defs'
       
 19569         }
       
 19570     };
       
 19571     return Register;
       
 19572 }(proj4);
       
 19573 LeafletCRSEPSG2154 = function (Config, Register, L) {
       
 19574     var EPSG2154 = {
       
 19575         instance: null,
       
 19576         build: function () {
       
 19577             if (!this.instance) {
       
 19578                 var crs = new L.Proj.CRS('EPSG:2154', Register.get('EPSG:2154'), {
       
 19579                     resolutions: this._getResolutions(),
       
 19580                     origin: this._getOrigin()
       
 19581                 });
       
 19582                 this.instance = crs;
       
 19583             }
       
 19584             return this.instance;
       
 19585         },
       
 19586         _getResolutions: function () {
       
 19587             var resolutions = [];
       
 19588             if (Config.isConfigLoaded()) {
       
 19589                 var o = Config.getTileMatrix('LAMB93');
       
 19590                 resolutions = o.nativeResolutions;
       
 19591             }
       
 19592             if (resolutions.length) {
       
 19593                 return resolutions;
       
 19594             }
       
 19595             return [
       
 19596                 104579.22454989408,
       
 19597                 52277.53235379051,
       
 19598                 26135.487078595408,
       
 19599                 13066.891381800004,
       
 19600                 6533.228604113456,
       
 19601                 3266.5595244626675,
       
 19602                 1633.2660045974187,
       
 19603                 816.6295549860224,
       
 19604                 408.31391467683596,
       
 19605                 204.15674151090204,
       
 19606                 102.07831678324082,
       
 19607                 51.0391448966112,
       
 19608                 25.519569074269395,
       
 19609                 12.759783693647506,
       
 19610                 6.379891635966491,
       
 19611                 3.18994576530532,
       
 19612                 1.5949728694977277,
       
 19613                 0.7974864315474559,
       
 19614                 0.398743214900604,
       
 19615                 0.19937160727567999,
       
 19616                 0.099685803696052,
       
 19617                 0.049842901818919996
       
 19618             ];
       
 19619         },
       
 19620         _getOrigin: function () {
       
 19621             return [
       
 19622                 0,
       
 19623                 12000000
       
 19624             ];
       
 19625         }
       
 19626     };
       
 19627     return EPSG2154;
       
 19628 }(CommonUtilsConfig, CommonUtilsRegister, leaflet);
       
 19629 LeafletCRSEPSG27572 = function (Config, Register, L) {
       
 19630     var EPSG27572 = {
       
 19631         instance: null,
       
 19632         build: function () {
       
 19633             if (!this.instance) {
       
 19634                 var crs = new L.Proj.CRS('EPSG:27572', Register.get('EPSG:27572'), {
       
 19635                     resolutions: this._getResolutions(),
       
 19636                     origin: this._getOrigin()
       
 19637                 });
       
 19638                 this.instance = crs;
       
 19639             }
       
 19640             return this.instance;
       
 19641         },
       
 19642         _getResolutions: function () {
       
 19643             var resolutions = [];
       
 19644             if (Config.isConfigLoaded()) {
       
 19645                 var o = Config.getTileMatrix('LAMB2E');
       
 19646                 if (o && Object.keys(o)) {
       
 19647                     resolutions = o.nativeResolutions;
       
 19648                 }
       
 19649             }
       
 19650             if (resolutions.length) {
       
 19651                 return resolutions;
       
 19652             }
       
 19653             return [
       
 19654                 104579.22454989408,
       
 19655                 52277.53235379051,
       
 19656                 26135.487078595408,
       
 19657                 13066.891381800004,
       
 19658                 6533.228604113456,
       
 19659                 3266.5595244626675,
       
 19660                 1633.2660045974187,
       
 19661                 816.6295549860224,
       
 19662                 408.31391467683596,
       
 19663                 204.15674151090204,
       
 19664                 102.07831678324082,
       
 19665                 51.0391448966112,
       
 19666                 25.519569074269395,
       
 19667                 12.759783693647506,
       
 19668                 6.379891635966491,
       
 19669                 3.18994576530532,
       
 19670                 1.5949728694977277,
       
 19671                 0.7974864315474559,
       
 19672                 0.398743214900604,
       
 19673                 0.19937160727567999,
       
 19674                 0.099685803696052,
       
 19675                 0.049842901818919996
       
 19676             ];
       
 19677         },
       
 19678         _getOrigin: function () {
       
 19679             return [
       
 19680                 0,
       
 19681                 12000000
       
 19682             ];
       
 19683         }
       
 19684     };
       
 19685     return EPSG27572;
       
 19686 }(CommonUtilsConfig, CommonUtilsRegister, leaflet);
       
 19687 LeafletCRSEPSG4326 = function (Config, Register, L) {
       
 19688     var EPSG4326 = {
       
 19689         instance: null,
       
 19690         build: function () {
       
 19691             if (!this.instance) {
       
 19692                 var crs = new L.Proj.CRS('EPSG:4326', Register.get('EPSG:4326'), {
       
 19693                     resolutions: this._getResolutions(),
       
 19694                     origin: [
       
 19695                         -180,
       
 19696                         90
       
 19697                     ]
       
 19698                 });
       
 19699                 this.instance = crs;
       
 19700             }
       
 19701             return this.instance;
       
 19702         },
       
 19703         _getResolutions: function () {
       
 19704             var resolutions = [];
       
 19705             if (Config.isConfigLoaded()) {
       
 19706                 resolutions = Config.getResolutions();
       
 19707             }
       
 19708             if (resolutions.length) {
       
 19709                 return resolutions;
       
 19710             }
       
 19711             return [
       
 19712                 1.40625,
       
 19713                 0.703125,
       
 19714                 0.3515625,
       
 19715                 0.17578125,
       
 19716                 0.087890625,
       
 19717                 0.0439453125,
       
 19718                 0.02197265625,
       
 19719                 0.010986328125,
       
 19720                 0.0054931640625,
       
 19721                 0.00274658203125,
       
 19722                 0.001373291015625,
       
 19723                 0.0006866455078125,
       
 19724                 0.00034332275390625,
       
 19725                 0.000171661376953126,
       
 19726                 0.0000858306884765628,
       
 19727                 0.0000429153442382813,
       
 19728                 0.0000214576721191407,
       
 19729                 0.0000107288360595703,
       
 19730                 0.00000536441802978517,
       
 19731                 0.00000268220901489259,
       
 19732                 0.0000013411045074463,
       
 19733                 6.70552253723145e-7,
       
 19734                 3.3527612686157e-7
       
 19735             ];
       
 19736         },
       
 19737         _getOrigin: function () {
       
 19738         }
       
 19739     };
       
 19740     return EPSG4326;
       
 19741 }(CommonUtilsConfig, CommonUtilsRegister, leaflet);
       
 19742 LeafletCRSCRS = function (Proj4, Register, Epsg2154, Epsg27572, Epsg4326) {
       
 19743     (function () {
       
 19744         Proj4.load();
       
 19745         Register.load();
       
 19746     }());
       
 19747     var CRS = {
       
 19748         EPSG2154: function () {
       
 19749             return Epsg2154.build();
       
 19750         },
       
 19751         EPSG27572: function () {
       
 19752             return Epsg27572.build();
       
 19753         },
       
 19754         EPSG4326: function () {
       
 19755             return Epsg4326.build();
       
 19756         }
       
 19757     };
       
 19758     return CRS;
       
 19759 }(LeafletCRSProj4Leaflet, CommonUtilsRegister, LeafletCRSEPSG2154, LeafletCRSEPSG27572, LeafletCRSEPSG4326);
       
 19760 LeafletControlsMousePosition = function (L, woodman, Gp, RightManagement, ID, MousePositionDOM, PositionFormater, CRS) {
       
 19761     var MousePosition = L.Control.extend({
       
 19762         includes: MousePositionDOM,
       
 19763         options: {
       
 19764             position: 'bottomleft',
       
 19765             collapsed: true,
       
 19766             units: [],
       
 19767             systems: [],
       
 19768             displayAltitude: true,
       
 19769             displayCoordinates: true,
       
 19770             altitude: {
       
 19771                 triggerDelay: 200,
       
 19772                 responseDelay: 500,
       
 19773                 noDataValue: -99999,
       
 19774                 noDataValueTolerance: 90000,
       
 19775                 serviceOptions: {}
       
 19776             }
       
 19777         },
       
 19778         initialize: function (options) {
       
 19779             L.Util.extend(this.options, options);
       
 19780             this._uid = ID.generate();
       
 19781             this._projectionSystems = [];
       
 19782             this._initProjectionSystems();
       
 19783             this._projectionUnits = {};
       
 19784             this._initProjectionUnits();
       
 19785             this._isDesktop = this._detectSupport();
       
 19786             if (this.options.altitude.triggerDelay < 100) {
       
 19787                 this.options.altitude.triggerDelay = 100;
       
 19788             }
       
 19789             this._timer = this.options.altitude.triggerDelay;
       
 19790             this._currentProjectionSystems = this._projectionSystems[0];
       
 19791             this._projectionSystemsContainer = null;
       
 19792             this._currentProjectionType = this._projectionSystems[0].type;
       
 19793             this._currentProjectionUnits = this._projectionUnits[this._currentProjectionType][0].code;
       
 19794             this._projectionUnitsContainer = null;
       
 19795             this._showMousePositionContainer = null;
       
 19796             if (!this.options.displayAltitude && !this.options.displayCoordinates) {
       
 19797                 this.options.displayCoordinates = true;
       
 19798             }
       
 19799             this._noRightManagement = false;
       
 19800             if (this.options.displayAltitude) {
       
 19801                 this._checkRightsManagement();
       
 19802             }
       
 19803             L.Util.setOptions(this, this.options);
       
 19804         },
       
 19805         onAdd: function (map) {
       
 19806             var container = this._container = this._initLayout();
       
 19807             if (!this.options.collapsed) {
       
 19808                 if (this._isDesktop) {
       
 19809                     map.on('mousemove', this.onMouseMove, this);
       
 19810                 } else {
       
 19811                     map.on('move', this.onMapMove, this);
       
 19812                 }
       
 19813             }
       
 19814             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 19815             L.DomEvent.addListener(container, 'mousemove', L.DomEvent.stopPropagation).addListener(container, 'mousemove', L.DomEvent.preventDefault);
       
 19816             return container;
       
 19817         },
       
 19818         onRemove: function (map) {
       
 19819             map.off('mousemove', this.onMouseMove);
       
 19820         },
       
 19821         _initProjectionSystems: function () {
       
 19822             var projectionSystemsByDefault = [
       
 19823                 {
       
 19824                     label: 'Géographique',
       
 19825                     crs: L.CRS.Simple,
       
 19826                     type: 'Geographical'
       
 19827                 },
       
 19828                 {
       
 19829                     label: 'Web Mercator',
       
 19830                     crs: L.CRS.EPSG3395,
       
 19831                     type: 'Metric'
       
 19832                 },
       
 19833                 {
       
 19834                     label: 'Lambert 93',
       
 19835                     crs: CRS.EPSG2154,
       
 19836                     type: 'Metric',
       
 19837                     geoBBox: {
       
 19838                         left: -9.86,
       
 19839                         bottom: 41.15,
       
 19840                         right: 10.38,
       
 19841                         top: 51.56
       
 19842                     }
       
 19843                 },
       
 19844                 {
       
 19845                     label: 'Lambert II étendu',
       
 19846                     crs: CRS.EPSG27572,
       
 19847                     type: 'Metric',
       
 19848                     geoBBox: {
       
 19849                         left: -4.87,
       
 19850                         bottom: 42.33,
       
 19851                         right: 8.23,
       
 19852                         top: 51.14
       
 19853                     }
       
 19854                 }
       
 19855             ];
       
 19856             var systems = this.options.systems;
       
 19857             for (var i = 0; i < systems.length; i++) {
       
 19858                 var sys = systems[i];
       
 19859                 if (!sys.label) {
       
 19860                     continue;
       
 19861                 }
       
 19862                 if (!sys.crs) {
       
 19863                     continue;
       
 19864                 }
       
 19865                 if (!sys.type) {
       
 19866                     sys.type = 'Metric';
       
 19867                 }
       
 19868                 this._projectionSystems.push(systems[i]);
       
 19869                 var found = false;
       
 19870                 for (var j = 0; j < projectionSystemsByDefault.length; j++) {
       
 19871                     var obj = projectionSystemsByDefault[j];
       
 19872                     if (sys.crs === obj.crs) {
       
 19873                         found = true;
       
 19874                     }
       
 19875                 }
       
 19876                 if (!found) {
       
 19877                 }
       
 19878             }
       
 19879             if (this._projectionSystems.length === 0) {
       
 19880                 this._projectionSystems = projectionSystemsByDefault;
       
 19881             }
       
 19882             for (var k = 0; k < this._projectionSystems.length; ++k) {
       
 19883                 this._projectionSystems[k].code = k;
       
 19884             }
       
 19885         },
       
 19886         _initProjectionUnits: function () {
       
 19887             var projectionUnitsByDefault = {
       
 19888                 Geographical: [
       
 19889                     {
       
 19890                         code: 'DEC',
       
 19891                         label: 'degrés décimaux',
       
 19892                         convert: this._displayDEC
       
 19893                     },
       
 19894                     {
       
 19895                         code: 'DMS',
       
 19896                         label: 'degrés sexagésimaux',
       
 19897                         convert: this._displayDMS
       
 19898                     },
       
 19899                     {
       
 19900                         code: 'RAD',
       
 19901                         label: 'radians',
       
 19902                         convert: this._displayRAD
       
 19903                     },
       
 19904                     {
       
 19905                         code: 'GON',
       
 19906                         label: 'grades',
       
 19907                         convert: this._displayGON
       
 19908                     }
       
 19909                 ],
       
 19910                 Metric: [
       
 19911                     {
       
 19912                         code: 'M',
       
 19913                         label: 'mètres',
       
 19914                         convert: this._displayMeter
       
 19915                     },
       
 19916                     {
       
 19917                         code: 'KM',
       
 19918                         label: 'kilomètres',
       
 19919                         convert: this._displayKMeter
       
 19920                     }
       
 19921                 ]
       
 19922             };
       
 19923             var units = this.options.units;
       
 19924             for (var type in projectionUnitsByDefault) {
       
 19925                 if (projectionUnitsByDefault.hasOwnProperty(type)) {
       
 19926                     var found = false;
       
 19927                     for (var j = 0; j < projectionUnitsByDefault[type].length; j++) {
       
 19928                         var obj = projectionUnitsByDefault[type][j];
       
 19929                         for (var i = 0; i < units.length; i++) {
       
 19930                             var unit = units[i];
       
 19931                             if (obj.code === unit) {
       
 19932                                 found = true;
       
 19933                                 if (!this._projectionUnits[type]) {
       
 19934                                     this._projectionUnits[type] = [];
       
 19935                                 }
       
 19936                                 this._projectionUnits[type].push(obj);
       
 19937                             }
       
 19938                         }
       
 19939                     }
       
 19940                     if (!found) {
       
 19941                         this._projectionUnits[type] = projectionUnitsByDefault[type];
       
 19942                     }
       
 19943                 }
       
 19944             }
       
 19945             if (Object.keys(this._projectionUnits).length === 0) {
       
 19946                 this._projectionUnits = projectionUnitsByDefault;
       
 19947             }
       
 19948         },
       
 19949         _checkRightsManagement: function () {
       
 19950             var rightManagement = RightManagement.check({
       
 19951                 key: this.options.apiKey,
       
 19952                 resources: ['SERVICE_CALCUL_ALTIMETRIQUE_RSC'],
       
 19953                 services: ['Elevation']
       
 19954             });
       
 19955             if (!rightManagement) {
       
 19956                 this._noRightManagement = true;
       
 19957             }
       
 19958             if (!this.options.apiKey) {
       
 19959                 this.options.apiKey = rightManagement.key;
       
 19960             }
       
 19961         },
       
 19962         _detectSupport: function () {
       
 19963             var isDesktop = true;
       
 19964             var userAgent = window.navigator.userAgent.toLowerCase();
       
 19965             if (userAgent.indexOf('iphone') !== -1 || userAgent.indexOf('ipod') !== -1 || userAgent.indexOf('ipad') !== -1 || userAgent.indexOf('android') !== -1 || userAgent.indexOf('mobile') !== -1 || userAgent.indexOf('blackberry') !== -1 || userAgent.indexOf('tablet') !== -1 || userAgent.indexOf('phone') !== -1 || userAgent.indexOf('touch') !== -1) {
       
 19966                 isDesktop = false;
       
 19967             }
       
 19968             if (userAgent.indexOf('msie') !== -1 || userAgent.indexOf('trident') !== -1) {
       
 19969                 isDesktop = true;
       
 19970             }
       
 19971             return isDesktop;
       
 19972         },
       
 19973         _initLayout: function () {
       
 19974             var container = this._createMainContainerElement();
       
 19975             var inputShow = this._showMousePositionContainer = this._createShowMousePositionElement();
       
 19976             container.appendChild(inputShow);
       
 19977             if (!this.options.collapsed) {
       
 19978                 inputShow.checked = true;
       
 19979             }
       
 19980             var picto = this._createShowMousePositionPictoElement(this._isDesktop);
       
 19981             container.appendChild(picto);
       
 19982             var panel = this._createMousePositionPanelElement(this.options.displayAltitude, this.options.displayCoordinates);
       
 19983             var settings = this._createMousePositionSettingsElement();
       
 19984             var systems = this._projectionSystemsContainer = this._createMousePositionSettingsSystemsElement(this._projectionSystems);
       
 19985             var units = this._projectionUnitsContainer = this._createMousePositionSettingsUnitsElement(this._projectionUnits[this._currentProjectionType]);
       
 19986             settings.appendChild(systems);
       
 19987             settings.appendChild(units);
       
 19988             panel.appendChild(settings);
       
 19989             container.appendChild(panel);
       
 19990             var center = this._createMapCenter();
       
 19991             var map = this._map;
       
 19992             map.getContainer().appendChild(center);
       
 19993             return container;
       
 19994         },
       
 19995         _setElevationPanel: function (active) {
       
 19996             var div = null;
       
 19997             if (!active) {
       
 19998                 div = L.DomUtil.get(this._addUID('GPmousePositionAltitude'));
       
 19999                 div.style.display = 'none';
       
 20000             }
       
 20001             if (active && this._noRightManagement) {
       
 20002                 div = L.DomUtil.get(this._addUID('GPmousePositionAlt'));
       
 20003                 div.innerHTML = 'no right !';
       
 20004             }
       
 20005         },
       
 20006         _setCoordinatePanel: function (active) {
       
 20007             if (!active) {
       
 20008                 var div = L.DomUtil.get(this._addUID('GPmousePositionCoordinate'));
       
 20009                 div.style.display = 'none';
       
 20010             }
       
 20011         },
       
 20012         _setSettingsPanel: function (active) {
       
 20013             if (!active) {
       
 20014                 var divPicto = L.DomUtil.get('GPshowMousePositionSettingsPicto');
       
 20015                 var divPanel = L.DomUtil.get(this._addUID('GPmousePositionSettings'));
       
 20016                 divPicto.style.display = 'none';
       
 20017                 divPanel.style.display = 'none';
       
 20018             }
       
 20019         },
       
 20020         _setTypeUnitsPanel: function (type) {
       
 20021             var container = this._projectionUnitsContainer;
       
 20022             while (container.firstChild) {
       
 20023                 container.removeChild(container.firstChild);
       
 20024             }
       
 20025             var units = this._projectionUnits[type];
       
 20026             for (var j = 0; j < units.length; j++) {
       
 20027                 var obj = units[j];
       
 20028                 var option = document.createElement('option');
       
 20029                 option.value = obj.code ? obj.code : j;
       
 20030                 option.text = obj.label || j;
       
 20031                 container.appendChild(option);
       
 20032             }
       
 20033             this._currentProjectionType = type;
       
 20034             this._currentProjectionUnits = this._projectionUnits[type][0].code;
       
 20035         },
       
 20036         _displayDEC: function (oLatLng) {
       
 20037             var coordinate = {};
       
 20038             coordinate.lat = PositionFormater.roundToDecimal(oLatLng.lat, 6);
       
 20039             coordinate.lng = PositionFormater.roundToDecimal(oLatLng.lng, 6);
       
 20040             return coordinate;
       
 20041         },
       
 20042         _displayDMS: function (oLatLng) {
       
 20043             var coordinate = {};
       
 20044             coordinate.lat = PositionFormater.decimalLatToDMS(oLatLng.lat);
       
 20045             coordinate.lng = PositionFormater.decimalLongToDMS(oLatLng.lng);
       
 20046             return coordinate;
       
 20047         },
       
 20048         _displayRAD: function (oLatLng) {
       
 20049             var coordinate = {};
       
 20050             coordinate.lat = PositionFormater.decimalToRadian(oLatLng.lat);
       
 20051             coordinate.lng = PositionFormater.decimalToRadian(oLatLng.lng);
       
 20052             return coordinate;
       
 20053         },
       
 20054         _displayGON: function (oLatLng) {
       
 20055             var coordinate = {};
       
 20056             coordinate.lat = PositionFormater.decimalToGrade(oLatLng.lat);
       
 20057             coordinate.lng = PositionFormater.decimalToGrade(oLatLng.lng);
       
 20058             return coordinate;
       
 20059         },
       
 20060         _displayMeter: function (oXY) {
       
 20061             var coordinate = {};
       
 20062             coordinate.x = L.Util.formatNum(oXY.x, 2);
       
 20063             coordinate.y = L.Util.formatNum(oXY.y, 2);
       
 20064             coordinate.unit = 'm';
       
 20065             return coordinate;
       
 20066         },
       
 20067         _displayKMeter: function (oXY) {
       
 20068             var coordinate = {};
       
 20069             coordinate.x = L.Util.formatNum(oXY.x / 1000, 2);
       
 20070             coordinate.y = L.Util.formatNum(oXY.y / 1000, 2);
       
 20071             coordinate.unit = 'km';
       
 20072             return coordinate;
       
 20073         },
       
 20074         _project: function (oLatLng, crs) {
       
 20075             if (typeof crs === 'function') {
       
 20076                 crs = crs();
       
 20077             }
       
 20078             if (typeof crs !== 'object') {
       
 20079                 return;
       
 20080             }
       
 20081             if (crs === L.CRS.Simple) {
       
 20082                 return oLatLng;
       
 20083             }
       
 20084             if (!crs.projection || typeof crs.projection !== 'object') {
       
 20085                 return;
       
 20086             }
       
 20087             var oPoint = crs.projection.project(oLatLng);
       
 20088             if (this._currentProjectionType === 'Geographical') {
       
 20089                 oPoint.lat = oPoint.y;
       
 20090                 oPoint.lng = oPoint.x;
       
 20091             }
       
 20092             if (!oPoint || Object.keys(oPoint).length === 0) {
       
 20093             }
       
 20094             return oPoint;
       
 20095         },
       
 20096         _setCoordinate: function (oLatLng) {
       
 20097             var type = this._currentProjectionSystems.type;
       
 20098             var convert = null;
       
 20099             var units = this._projectionUnits[type];
       
 20100             for (var i = 0; i < units.length; i++) {
       
 20101                 if (units[i].code === this._currentProjectionUnits) {
       
 20102                     convert = units[i].convert;
       
 20103                     break;
       
 20104                 }
       
 20105             }
       
 20106             var coordinate = {};
       
 20107             var oSrs = this._currentProjectionSystems.crs;
       
 20108             if (!oSrs) {
       
 20109                 return;
       
 20110             }
       
 20111             coordinate = convert(this._project(oLatLng, oSrs));
       
 20112             if (!coordinate || Object.keys(coordinate).lenght === 0) {
       
 20113                 return;
       
 20114             }
       
 20115             this.GPdisplayCoords(coordinate);
       
 20116         },
       
 20117         _setElevation: function (oLatLng) {
       
 20118             var delay = this.options.altitude.responseDelay;
       
 20119             var noDataValue = this.options.altitude.noDataValue;
       
 20120             var noDataValueTolerance = this.options.altitude.noDataValueTolerance;
       
 20121             this.GPdisplayElevation(oLatLng, delay, noDataValue, noDataValueTolerance);
       
 20122         },
       
 20123         onMoveStopped: function (oLatLng) {
       
 20124             if (this._noRightManagement) {
       
 20125                 return;
       
 20126             }
       
 20127             this._setElevation(oLatLng);
       
 20128         },
       
 20129         onMouseMove: function (e) {
       
 20130             var self = this;
       
 20131             var oLatLng = e.latlng;
       
 20132             this._setCoordinate(oLatLng);
       
 20133             clearTimeout(this._timer);
       
 20134             this._timer = setTimeout(function () {
       
 20135                 self.onMoveStopped(oLatLng);
       
 20136             }, this.options.altitude.triggerDelay);
       
 20137         },
       
 20138         onMapMove: function () {
       
 20139             var self = this;
       
 20140             var map = this._map;
       
 20141             var oLatLng = map.getCenter();
       
 20142             this._setCoordinate(oLatLng);
       
 20143             clearTimeout(this._timer);
       
 20144             this._timer = setTimeout(function () {
       
 20145                 self.onMoveStopped(oLatLng);
       
 20146             }, this.options.altitude.triggerDelay);
       
 20147         },
       
 20148         onRequestAltitude: function (coordinate, callback) {
       
 20149             if (!coordinate || Object.keys(coordinate).length === 0) {
       
 20150                 return;
       
 20151             }
       
 20152             if (!this.options.displayAltitude) {
       
 20153                 return;
       
 20154             }
       
 20155             if (this._noRightManagement) {
       
 20156                 return;
       
 20157             }
       
 20158             var options = {};
       
 20159             L.Util.extend(options, this.options.altitude.serviceOptions);
       
 20160             L.Util.extend(options, {
       
 20161                 zonly: true,
       
 20162                 positions: [{
       
 20163                         lon: coordinate.lon || coordinate.lng,
       
 20164                         lat: coordinate.lat
       
 20165                     }]
       
 20166             });
       
 20167             L.Util.extend(options, {
       
 20168                 scope: this,
       
 20169                 onSuccess: function (results) {
       
 20170                     if (results && Object.keys(results)) {
       
 20171                         callback.call(this, results.elevations[0].z);
       
 20172                     }
       
 20173                 },
       
 20174                 onFailure: function (error) {
       
 20175                 }
       
 20176             });
       
 20177             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey });
       
 20178             Gp.Services.getAltitude(options);
       
 20179         },
       
 20180         onShowMousePositionClick: function (e) {
       
 20181             var map = this._map;
       
 20182             if (this._showMousePositionContainer.checked) {
       
 20183                 this._isDesktop ? map.off('mousemove', this.onMouseMove, this) : map.off('move', this.onMapMove, this);
       
 20184             } else {
       
 20185                 this._isDesktop ? map.on('mousemove', this.onMouseMove, this) : map.on('move', this.onMapMove, this);
       
 20186             }
       
 20187             this._setElevationPanel(this.options.displayAltitude);
       
 20188             this._setCoordinatePanel(this.options.displayCoordinates);
       
 20189             if (!this.options.displayCoordinates) {
       
 20190                 this._setSettingsPanel(false);
       
 20191             }
       
 20192         },
       
 20193         onMousePositionProjectionSystemChange: function (e) {
       
 20194             var idx = e.target.selectedIndex;
       
 20195             var value = e.target.options[idx].value;
       
 20196             var label = e.target.options[idx].label;
       
 20197             this._setCurrentSystem(value);
       
 20198         },
       
 20199         _setCurrentSystem: function (systemCode) {
       
 20200             var type = null;
       
 20201             for (var i = 0; i < this._projectionSystems.length; ++i) {
       
 20202                 if (this._projectionSystems[i].code == systemCode) {
       
 20203                     type = this._projectionSystems[i].type;
       
 20204                     break;
       
 20205                 }
       
 20206             }
       
 20207             if (!type) {
       
 20208                 return;
       
 20209             }
       
 20210             if (type !== this._currentProjectionType) {
       
 20211                 this._setTypeUnitsPanel(type);
       
 20212             }
       
 20213             this._currentProjectionSystems = this._projectionSystems[Number(systemCode)];
       
 20214             if (!this._isDesktop) {
       
 20215                 this.onMapMove();
       
 20216             }
       
 20217         },
       
 20218         onMousePositionProjectionSystemMouseOver: function (e) {
       
 20219             var map = this._map;
       
 20220             if (!map) {
       
 20221                 return;
       
 20222             }
       
 20223             var systemList = document.getElementById(this._addUID('GPmousePositionProjectionSystem'));
       
 20224             systemList.innerHTML = '';
       
 20225             for (var j = 0; j < this._projectionSystems.length; j++) {
       
 20226                 var proj = this._projectionSystems[j];
       
 20227                 if (proj.geoBBox) {
       
 20228                     if (map.getBounds()._southWest.lng > proj.geoBBox.right || map.getBounds()._southWest.lat > proj.geoBBox.top || map.getBounds()._northEast.lng < proj.geoBBox.left || map.getBounds()._northEast.lat < proj.geoBBox.bottom) {
       
 20229                         if (proj === this._currentProjectionSystems) {
       
 20230                             var option = document.createElement('option');
       
 20231                             option.value = proj.code;
       
 20232                             option.text = proj.label || j;
       
 20233                             option.setAttribute('selected', 'selected');
       
 20234                             option.setAttribute('disabled', 'disabled');
       
 20235                             systemList.appendChild(option);
       
 20236                         }
       
 20237                         continue;
       
 20238                     }
       
 20239                 }
       
 20240                 var option = document.createElement('option');
       
 20241                 option.value = proj.code;
       
 20242                 option.text = proj.label || j;
       
 20243                 if (proj === this._currentProjectionSystems) {
       
 20244                     option.setAttribute('selected', 'selected');
       
 20245                 }
       
 20246                 systemList.appendChild(option);
       
 20247             }
       
 20248         },
       
 20249         onMousePositionProjectionUnitsChange: function (e) {
       
 20250             var idx = e.target.selectedIndex;
       
 20251             var value = e.target.options[idx].value;
       
 20252             var label = e.target.options[idx].label;
       
 20253             this._currentProjectionUnits = value;
       
 20254             if (!this._isDesktop) {
       
 20255                 this.onMapMove();
       
 20256             }
       
 20257         }
       
 20258     });
       
 20259     return MousePosition;
       
 20260 }(leaflet, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, CommonControlsMousePositionDOM, LeafletControlsUtilsPositionFormater, LeafletCRSCRS);
       
 20261 CommonControlsReverseGeocodingDOM = function () {
       
 20262     var ReverseGeocodingDOM = {
       
 20263         _addUID: function (id) {
       
 20264             return id + '-' + this._uid;
       
 20265         },
       
 20266         _createMainContainerElement: function () {
       
 20267             var container = document.createElement('div');
       
 20268             container.id = this._addUID('GPreverseGeocoding');
       
 20269             container.className = 'GPwidget';
       
 20270             return container;
       
 20271         },
       
 20272         _createShowReverseGeocodingElement: function () {
       
 20273             var input = document.createElement('input');
       
 20274             input.id = this._addUID('GPshowReverseGeocoding');
       
 20275             input.type = 'checkbox';
       
 20276             return input;
       
 20277         },
       
 20278         _createShowReverseGeocodingPictoElement: function () {
       
 20279             var self = this;
       
 20280             var label = document.createElement('label');
       
 20281             label.id = this._addUID('GPshowReverseGeocodingPicto');
       
 20282             label.className = 'GPshowAdvancedToolPicto';
       
 20283             label.htmlFor = this._addUID('GPshowReverseGeocoding');
       
 20284             label.title = 'Ouvrir la recherche inverse';
       
 20285             if (label.addEventListener) {
       
 20286                 label.addEventListener('click', function () {
       
 20287                     self.onShowReverseGeocodingClick();
       
 20288                 });
       
 20289             } else if (label.attachEvent) {
       
 20290                 label.attachEvent('onclick', function () {
       
 20291                     self.onShowReverseGeocodingClick();
       
 20292                 });
       
 20293             }
       
 20294             var spanOpen = document.createElement('span');
       
 20295             spanOpen.id = this._addUID('GPshowReverseGeocodingOpen');
       
 20296             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 20297             label.appendChild(spanOpen);
       
 20298             return label;
       
 20299         },
       
 20300         _createReverseGeocodingWaitingElement: function () {
       
 20301             var div = document.createElement('div');
       
 20302             div.id = this._addUID('GPreverseGeocodingCalcWaitingContainer');
       
 20303             div.className = 'GPreverseGeocodingCalcWaitingContainerHidden';
       
 20304             var p = document.createElement('p');
       
 20305             p.className = 'GPreverseGeocodingCalcWaiting';
       
 20306             p.innerHTML = 'Recherche en cours...';
       
 20307             div.appendChild(p);
       
 20308             return div;
       
 20309         },
       
 20310         _createReverseGeocodingResultsPanelElement: function () {
       
 20311             var resultsPanelDiv = document.createElement('div');
       
 20312             resultsPanelDiv.id = this._addUID('GPreverseGeocodingResultsPanel');
       
 20313             resultsPanelDiv.className = 'GPpanel GPreverseGeocodingComponentHidden';
       
 20314             return resultsPanelDiv;
       
 20315         },
       
 20316         _createReverseGeocodingResultsListElement: function () {
       
 20317             var container = document.createElement('div');
       
 20318             container.id = this._addUID('GPreverseGeocodingResultsList');
       
 20319             return container;
       
 20320         },
       
 20321         _createReverseGeocodingResultElement: function (locationDescription, id) {
       
 20322             var context = this;
       
 20323             var container = document.getElementById(this._addUID('GPreverseGeocodingResultsList'));
       
 20324             var div = document.createElement('div');
       
 20325             div.id = this._addUID('ReverseGeocodedLocation_' + id);
       
 20326             div.className = 'GPautoCompleteProposal';
       
 20327             div.innerHTML = locationDescription;
       
 20328             div.title = locationDescription;
       
 20329             if (div.addEventListener) {
       
 20330                 div.addEventListener('mouseover', function (e) {
       
 20331                     context.onReverseGeocodingResultMouseOver(e);
       
 20332                 });
       
 20333                 div.addEventListener('mouseout', function (e) {
       
 20334                     context.onReverseGeocodingResultMouseOut(e);
       
 20335                 });
       
 20336                 div.addEventListener('click', function (e) {
       
 20337                     if (typeof context.onReverseGeocodingResultClick === 'function') {
       
 20338                         context.onReverseGeocodingResultClick(e);
       
 20339                     }
       
 20340                 });
       
 20341             } else if (div.attachEvent) {
       
 20342                 div.attachEvent('onmouseover', function (e) {
       
 20343                     context.onReverseGeocodingResultMouseOver(e);
       
 20344                 });
       
 20345                 div.attachEvent('onmouseout', function (e) {
       
 20346                     context.onReverseGeocodingResultMouseOut(e);
       
 20347                 });
       
 20348                 div.attachEvent('onclick', function (e) {
       
 20349                     if (typeof context.onReverseGeocodingResultClick === 'function') {
       
 20350                         context.onReverseGeocodingResultClick(e);
       
 20351                     }
       
 20352                 });
       
 20353             }
       
 20354             container.appendChild(div);
       
 20355         },
       
 20356         _createReverseGeocodingPanelElement: function () {
       
 20357             var div = document.createElement('div');
       
 20358             div.id = this._addUID('GPreverseGeocodingPanel');
       
 20359             div.className = 'GPpanel';
       
 20360             return div;
       
 20361         },
       
 20362         _createReverseGeocodingPanelHeaderElement: function () {
       
 20363             var container = document.createElement('div');
       
 20364             container.className = 'GPpanelHeader';
       
 20365             return container;
       
 20366         },
       
 20367         _createReverseGeocodingPanelReturnPictoElement: function () {
       
 20368             var self = this;
       
 20369             var divNew = document.createElement('div');
       
 20370             divNew.id = this._addUID('GPreverseGeocodingReturnPicto');
       
 20371             divNew.title = 'Nouvelle recherche';
       
 20372             divNew.className = 'GPreverseGeocodingReturnPictoHidden';
       
 20373             if (divNew.addEventListener) {
       
 20374                 divNew.addEventListener('click', function (e) {
       
 20375                     document.getElementById(self._addUID('GPreverseGeocodingResultsPanel')).className = 'GProuteComponentHidden';
       
 20376                     document.getElementById(self._addUID('GPreverseGeocodingForm')).className = '';
       
 20377                     document.getElementById(self._addUID('GPreverseGeocodingHeaderTitle')).innerHTML = 'Recherche inverse';
       
 20378                     document.getElementById(self._addUID('GPreverseGeocodingReturnPicto')).className = 'GPreverseGeocodingReturnPictoHidden';
       
 20379                     self.onGPreverseGeocodingReturnPictoClick(e);
       
 20380                 });
       
 20381             } else if (divNew.attachEvent) {
       
 20382                 divNew.attachEvent('onclick', function (e) {
       
 20383                     document.getElementById(self._addUID('GPreverseGeocodingResultsPanel')).className = 'GProuteComponentHidden';
       
 20384                     document.getElementById(self._addUID('GPreverseGeocodingForm')).className = '';
       
 20385                     document.getElementById(self._addUID('GPreverseGeocodingHeaderTitle')).innerHTML = 'Recherche inverse';
       
 20386                     document.getElementById(self._addUID('GPreverseGeocodingReturnPicto')).className = 'GPreverseGeocodingReturnPictoHidden';
       
 20387                     self.onGPreverseGeocodingReturnPictoClick(e);
       
 20388                 });
       
 20389             }
       
 20390             return divNew;
       
 20391         },
       
 20392         _createReverseGeocodingPanelTitleElement: function () {
       
 20393             var div = document.createElement('div');
       
 20394             div.className = 'GPpanelTitle';
       
 20395             div.id = this._addUID('GPreverseGeocodingHeaderTitle');
       
 20396             div.innerHTML = 'Recherche inverse';
       
 20397             return div;
       
 20398         },
       
 20399         _createReverseGeocodingPanelCloseElement: function () {
       
 20400             var self = this;
       
 20401             var divClose = document.createElement('div');
       
 20402             divClose.id = this._addUID('GPreverseGeocodingPanelClose');
       
 20403             divClose.className = 'GPpanelClose';
       
 20404             divClose.title = 'Fermer le panneau';
       
 20405             if (divClose.addEventListener) {
       
 20406                 divClose.addEventListener('click', function () {
       
 20407                     document.getElementById(self._addUID('GPshowReverseGeocodingPicto')).click();
       
 20408                 }, false);
       
 20409             } else if (divClose.attachEvent) {
       
 20410                 divClose.attachEvent('onclick', function () {
       
 20411                     document.getElementById(self._addUID('GPshowReverseGeocodingPicto')).click();
       
 20412                 });
       
 20413             }
       
 20414             return divClose;
       
 20415         },
       
 20416         _createReverseGeocodingPanelFormElement: function () {
       
 20417             var self = this;
       
 20418             var form = document.createElement('form');
       
 20419             form.id = this._addUID('GPreverseGeocodingForm');
       
 20420             if (form.addEventListener) {
       
 20421                 form.addEventListener('submit', function (e) {
       
 20422                     e.preventDefault();
       
 20423                     self.onReverseGeocodingSubmit();
       
 20424                 });
       
 20425             } else if (form.attachEvent) {
       
 20426                 form.attachEvent('onsubmit', function (e) {
       
 20427                     e.preventDefault();
       
 20428                     self.onReverseGeocodingSubmit();
       
 20429                 });
       
 20430             }
       
 20431             return form;
       
 20432         },
       
 20433         _createReverseGeocodingFormModeChoiceGeocodingTypeElement: function (resources) {
       
 20434             var context = this;
       
 20435             var div = document.createElement('div');
       
 20436             div.className = 'GPflexInput';
       
 20437             var label = document.createElement('label');
       
 20438             label.className = 'GPreverseGeocodingCodeLabel';
       
 20439             label.innerHTML = 'Recherche par';
       
 20440             label.title = 'Recherche par';
       
 20441             div.appendChild(label);
       
 20442             var select = document.createElement('select');
       
 20443             select.className = 'GPreverseGeocodingCode';
       
 20444             if (select.addEventListener) {
       
 20445                 select.addEventListener('change', function (e) {
       
 20446                     context.onReverseGeocodingTypeChange(e);
       
 20447                 });
       
 20448             } else if (select.attachEvent) {
       
 20449                 select.attachEvent('onchange', function (e) {
       
 20450                     context.onReverseGeocodingTypeChange(e);
       
 20451                 });
       
 20452             }
       
 20453             if (!resources || !Array.isArray(resources)) {
       
 20454                 resources = [
       
 20455                     'StreetAddress',
       
 20456                     'PositionOfInterest',
       
 20457                     'CadastralParcel'
       
 20458                 ];
       
 20459             }
       
 20460             for (var i = 0; i < resources.length; i++) {
       
 20461                 switch (resources[i]) {
       
 20462                 case 'PositionOfInterest':
       
 20463                     var POIOption = document.createElement('option');
       
 20464                     POIOption.value = 'PositionOfInterest';
       
 20465                     POIOption.text = 'Lieux/toponymes';
       
 20466                     select.appendChild(POIOption);
       
 20467                     break;
       
 20468                 case 'StreetAddress':
       
 20469                     var SAOption = document.createElement('option');
       
 20470                     SAOption.value = 'StreetAddress';
       
 20471                     SAOption.text = 'Adresses';
       
 20472                     select.appendChild(SAOption);
       
 20473                     break;
       
 20474                 case 'CadastralParcel':
       
 20475                     var CPOption = document.createElement('option');
       
 20476                     CPOption.value = 'CadastralParcel';
       
 20477                     CPOption.text = 'Parcelles cadastrales';
       
 20478                     select.appendChild(CPOption);
       
 20479                     break;
       
 20480                 case 'Administratif':
       
 20481                     var adminOption = document.createElement('option');
       
 20482                     adminOption.value = 'Administratif';
       
 20483                     adminOption.text = 'Unités administratives';
       
 20484                     select.appendChild(adminOption);
       
 20485                     break;
       
 20486                 default:
       
 20487                     break;
       
 20488                 }
       
 20489             }
       
 20490             div.appendChild(select);
       
 20491             return div;
       
 20492         },
       
 20493         _createReverseGeocodingFormModeChoiceGeocodingDelimitationElement: function (delimitations) {
       
 20494             var context = this;
       
 20495             var div = document.createElement('div');
       
 20496             div.className = 'GPflexInput';
       
 20497             var label = document.createElement('label');
       
 20498             label.className = 'GPreverseGeocodingCodeLabel';
       
 20499             label.innerHTML = 'Délimitation';
       
 20500             label.title = 'Délimitation';
       
 20501             div.appendChild(label);
       
 20502             var select = document.createElement('select');
       
 20503             select.className = 'GPreverseGeocodingCode';
       
 20504             if (select.addEventListener) {
       
 20505                 select.addEventListener('change', function (e) {
       
 20506                     context.onReverseGeocodingDelimitationChange(e);
       
 20507                 });
       
 20508             } else if (select.attachEvent) {
       
 20509                 select.attachEvent('onchange', function (e) {
       
 20510                     context.onReverseGeocodingDelimitationChange(e);
       
 20511                 });
       
 20512             }
       
 20513             if (!delimitations || !Array.isArray(delimitations)) {
       
 20514                 delimitations = [
       
 20515                     'Point',
       
 20516                     'Circle',
       
 20517                     'Extent'
       
 20518                 ];
       
 20519             }
       
 20520             for (var i = 0; i < delimitations.length; i++) {
       
 20521                 switch (delimitations[i].toLowerCase()) {
       
 20522                 case 'point':
       
 20523                     var pointOption = document.createElement('option');
       
 20524                     pointOption.value = 'point';
       
 20525                     pointOption.text = 'Pointer un lieu';
       
 20526                     select.appendChild(pointOption);
       
 20527                     break;
       
 20528                 case 'circle':
       
 20529                     var circleOption = document.createElement('option');
       
 20530                     circleOption.value = 'circle';
       
 20531                     circleOption.text = 'Dessiner un cercle';
       
 20532                     select.appendChild(circleOption);
       
 20533                     break;
       
 20534                 case 'extent':
       
 20535                     var extentOption = document.createElement('option');
       
 20536                     extentOption.value = 'extent';
       
 20537                     extentOption.text = 'Dessiner une emprise';
       
 20538                     select.appendChild(extentOption);
       
 20539                     break;
       
 20540                 default:
       
 20541                     break;
       
 20542                 }
       
 20543             }
       
 20544             div.appendChild(select);
       
 20545             return div;
       
 20546         },
       
 20547         _createReverseGeocodingSubmitFormElement: function () {
       
 20548             var input = document.createElement('input');
       
 20549             input.id = this._addUID('GPreverseGeocodingSubmit');
       
 20550             input.className = 'GPinputSubmit';
       
 20551             input.type = 'submit';
       
 20552             input.value = 'Rechercher';
       
 20553             return input;
       
 20554         }
       
 20555     };
       
 20556     return ReverseGeocodingDOM;
       
 20557 }();
       
 20558 LeafletControlsReverseGeocoding = function (L, P, woodman, Gp, RightManagement, ID, IconDefault, ReverseGeocodingDOM) {
       
 20559     var ReverseGeocoding = L.Control.extend({
       
 20560         includes: ReverseGeocodingDOM,
       
 20561         options: {
       
 20562             position: 'bottomleft',
       
 20563             collapsed: true,
       
 20564             resources: [
       
 20565                 'StreetAddress',
       
 20566                 'PositionOfInterest'
       
 20567             ],
       
 20568             delimitations: [
       
 20569                 'Point',
       
 20570                 'Circle',
       
 20571                 'Extent'
       
 20572             ],
       
 20573             reverseGeocodeOptions: {}
       
 20574         },
       
 20575         initialize: function (options) {
       
 20576             L.Util.extend(this.options, options);
       
 20577             this._noRightManagement = false;
       
 20578             this._servicesRightManagement = {};
       
 20579             this._checkRightsManagement();
       
 20580             this._checkInputOptions();
       
 20581             this._uid = ID.generate();
       
 20582             this._currentGeocodingType = null;
       
 20583             this._initGeocodingType();
       
 20584             this._currentGeocodingDelimitation = null;
       
 20585             this._initGeocodingDelimitation();
       
 20586             this._showReverseGeocodingContainer = null;
       
 20587             this._panelHeaderContainer = null;
       
 20588             this._panelTitleContainer = null;
       
 20589             this._returnPictoContainer = null;
       
 20590             this._formContainer = null;
       
 20591             this._resultsContainer = null;
       
 20592             this._resultsListContainer = null;
       
 20593             this._waitingContainer = null;
       
 20594             this._inputFeaturesLayer = null;
       
 20595             this._inputResultsLayer = null;
       
 20596             this._lastIdLayer = 0;
       
 20597             this._currentIdLayer = 0;
       
 20598             this._currentFeature = null;
       
 20599             this._requestPosition = null;
       
 20600             this._requestCircleFilter = null;
       
 20601             this._requestBboxFilter = null;
       
 20602             this._waiting = false;
       
 20603             this._timer = null;
       
 20604             this._reverseGeocodingLocations = [];
       
 20605         },
       
 20606         onAdd: function (map) {
       
 20607             var container = this._container = this._initLayout();
       
 20608             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 20609             if (map) {
       
 20610                 if (!this.options.collapsed) {
       
 20611                     this._activateMapInteraction(map);
       
 20612                 }
       
 20613             }
       
 20614             return container;
       
 20615         },
       
 20616         onRemove: function () {
       
 20617         },
       
 20618         _checkRightsManagement: function () {
       
 20619             var _resources = [];
       
 20620             var _key;
       
 20621             var _opts = null;
       
 20622             _key = this.options.reverseGeocodeOptions.apiKey;
       
 20623             _opts = this.options.reverseGeocodeOptions.filterOptions;
       
 20624             _resources = _opts ? _opts.type : [];
       
 20625             if (!_resources || _resources.length === 0) {
       
 20626                 _resources = this.options.resources;
       
 20627             }
       
 20628             if (!_resources || _resources.length === 0) {
       
 20629                 _resources = [
       
 20630                     'StreetAddress',
       
 20631                     'PositionOfInterest'
       
 20632                 ];
       
 20633             }
       
 20634             var rightManagementGeocode = RightManagement.check({
       
 20635                 key: _key || this.options.apiKey,
       
 20636                 resources: _resources,
       
 20637                 services: ['Geocode']
       
 20638             });
       
 20639             if (!rightManagementGeocode) {
       
 20640                 this._noRightManagement = true;
       
 20641                 return;
       
 20642             }
       
 20643             if (!this.options.apiKey) {
       
 20644                 this.options.apiKey = rightManagementGeocode.key;
       
 20645             }
       
 20646             if (rightManagementGeocode) {
       
 20647                 this._servicesRightManagement['Geocode'] = rightManagementGeocode['Geocode'];
       
 20648             }
       
 20649         },
       
 20650         _checkInputOptions: function () {
       
 20651             var i;
       
 20652             if (this.options.resources) {
       
 20653                 var resources = this.options.resources;
       
 20654                 if (!Array.isArray(resources)) {
       
 20655                     console.log('[ReverseGeocoding] \'options.resources\' parameter should be an array');
       
 20656                     resources = null;
       
 20657                 }
       
 20658                 var resourcesList = [
       
 20659                     'StreetAddress',
       
 20660                     'PositionOfInterest',
       
 20661                     'CadastralParcel',
       
 20662                     'Administratif'
       
 20663                 ];
       
 20664                 for (i = 0; i < resources.length; i++) {
       
 20665                     if (resourcesList.indexOf(resources[i]) === -1) {
       
 20666                         console.log('[ReverseGeocoding] options.resources : ' + resources[i] + ' is not a resource for reverse geocode');
       
 20667                     }
       
 20668                 }
       
 20669             }
       
 20670             if (this.options.delimitations) {
       
 20671                 var delimitations = this.options.delimitations;
       
 20672                 if (!Array.isArray(delimitations)) {
       
 20673                     console.log('[ReverseGeocoding] \'options.delimitations\' parameter should be an array');
       
 20674                     delimitations = null;
       
 20675                 }
       
 20676                 var delimitationsList = [
       
 20677                     'Circle',
       
 20678                     'Point',
       
 20679                     'Extent'
       
 20680                 ];
       
 20681                 for (i = 0; i < delimitations.length; i++) {
       
 20682                     if (delimitationsList.indexOf(delimitations[i]) === -1) {
       
 20683                         console.log('[ReverseGeocoding] options.delimitations : ' + delimitations[i] + ' is not a delimitation for reverse geocode');
       
 20684                     }
       
 20685                 }
       
 20686             }
       
 20687         },
       
 20688         _initGeocodingType: function () {
       
 20689             this._currentGeocodingType = 'StreetAddress';
       
 20690             var resources = this.options.resources;
       
 20691             if (!resources || resources.length === 0) {
       
 20692                 this.options.resources = [
       
 20693                     'StreetAddress',
       
 20694                     'PositionOfInterest',
       
 20695                     'CadastralParcel'
       
 20696                 ];
       
 20697             }
       
 20698             if (Array.isArray(resources) && resources.length) {
       
 20699                 var noRightsIndexes = [];
       
 20700                 for (var i = 0; i < resources.length; i++) {
       
 20701                     if (this._servicesRightManagement['Geocode'].indexOf(resources[i]) < 0) {
       
 20702                         noRightsIndexes.push(i);
       
 20703                         console.log('[ReverseGeocode] no rights for options.resources : ' + resources[i]);
       
 20704                     }
       
 20705                 }
       
 20706                 if (noRightsIndexes.length !== 0) {
       
 20707                     for (var j = 0; j < noRightsIndexes.length; j++) {
       
 20708                         resources.splice(noRightsIndexes[j], 1);
       
 20709                     }
       
 20710                 }
       
 20711                 if (resources[0] === 'StreetAddress' || resources[0] === 'PositionOfInterest' || resources[0] === 'CadastralParcel' || resources[0] === 'Administratif') {
       
 20712                     this._currentGeocodingType = resources[0];
       
 20713                 }
       
 20714             }
       
 20715             var serviceOptions = this.options.reverseGeocodeOptions;
       
 20716             if (serviceOptions.filterOptions && Array.isArray(serviceOptions.filterOptions.type) && serviceOptions.filterOptions.type.length !== 0) {
       
 20717                 this._currentGeocodingType = serviceOptions.filterOptions.type[0];
       
 20718             }
       
 20719         },
       
 20720         _initGeocodingDelimitation: function () {
       
 20721             this._currentGeocodingDelimitation = 'Point';
       
 20722             var delimitations = this.options.delimitations;
       
 20723             if (!delimitations || delimitations.length === 0) {
       
 20724                 this.options.delimitations = [
       
 20725                     'Point',
       
 20726                     'Circle',
       
 20727                     'Extent'
       
 20728                 ];
       
 20729             }
       
 20730             if (Array.isArray(delimitations) && delimitations.length) {
       
 20731                 var d = delimitations[0].toLowerCase();
       
 20732                 if (d === 'point' || d === 'circle' || d === 'extent') {
       
 20733                     this._currentGeocodingDelimitation = delimitations[0];
       
 20734                 }
       
 20735             }
       
 20736         },
       
 20737         _initLayout: function () {
       
 20738             var container = this._createMainContainerElement();
       
 20739             var inputShow = this._showReverseGeocodingContainer = this._createShowReverseGeocodingElement();
       
 20740             container.appendChild(inputShow);
       
 20741             if (!this.options.collapsed) {
       
 20742                 inputShow.checked = true;
       
 20743             }
       
 20744             var picto = this._createShowReverseGeocodingPictoElement();
       
 20745             container.appendChild(picto);
       
 20746             var reverseGeocodingPanel = this._createReverseGeocodingPanelElement();
       
 20747             var panelHeader = this._panelHeaderContainer = this._createReverseGeocodingPanelHeaderElement();
       
 20748             var returnPicto = this._returnPictoContainer = this._createReverseGeocodingPanelReturnPictoElement();
       
 20749             panelHeader.appendChild(returnPicto);
       
 20750             var panelTitle = this._panelTitleContainer = this._createReverseGeocodingPanelTitleElement();
       
 20751             panelHeader.appendChild(panelTitle);
       
 20752             var closeDiv = this._createReverseGeocodingPanelCloseElement();
       
 20753             panelHeader.appendChild(closeDiv);
       
 20754             reverseGeocodingPanel.appendChild(panelHeader);
       
 20755             var reverseGeocodingForm = this._formContainer = this._createReverseGeocodingPanelFormElement();
       
 20756             reverseGeocodingForm.appendChild(this._createReverseGeocodingFormModeChoiceGeocodingTypeElement(this.options.resources));
       
 20757             reverseGeocodingForm.appendChild(this._createReverseGeocodingFormModeChoiceGeocodingDelimitationElement(this.options.delimitations));
       
 20758             var submit = this._createReverseGeocodingSubmitFormElement();
       
 20759             reverseGeocodingForm.appendChild(submit);
       
 20760             reverseGeocodingPanel.appendChild(reverseGeocodingForm);
       
 20761             var waiting = this._waitingContainer = this._createReverseGeocodingWaitingElement();
       
 20762             reverseGeocodingPanel.appendChild(waiting);
       
 20763             var resultsPanel = this._resultsContainer = this._createReverseGeocodingResultsPanelElement();
       
 20764             var reverseGeocodingResultsList = this._resultsListContainer = this._createReverseGeocodingResultsListElement();
       
 20765             resultsPanel.appendChild(reverseGeocodingResultsList);
       
 20766             reverseGeocodingPanel.appendChild(resultsPanel);
       
 20767             container.appendChild(reverseGeocodingPanel);
       
 20768             return container;
       
 20769         },
       
 20770         _activateMapInteraction: function (map) {
       
 20771             if (this._inputFeaturesLayer === null) {
       
 20772                 this._inputFeaturesLayer = new L.FeatureGroup();
       
 20773                 map.addLayer(this._inputFeaturesLayer);
       
 20774                 var self = this;
       
 20775                 map.on('draw:created', function (e) {
       
 20776                     var layer = e.layer;
       
 20777                     var type = e.layerType;
       
 20778                     self._setFeaturePosition(layer, type);
       
 20779                     self._currentIdLayer = L.Util.stamp(layer);
       
 20780                     self._setFeatureLayer(layer);
       
 20781                 });
       
 20782                 map.on('draw:drawstart', function () {
       
 20783                     self._removeFeatureLayer(self._lastIdLayer);
       
 20784                     self._lastIdLayer = self._currentIdLayer;
       
 20785                 });
       
 20786                 map.on('draw:drawstop', function () {
       
 20787                 });
       
 20788             }
       
 20789             var delimitation = this._currentGeocodingDelimitation.toLowerCase();
       
 20790             switch (delimitation) {
       
 20791             case 'point':
       
 20792                 this._activatePointInteraction(map);
       
 20793                 break;
       
 20794             case 'circle':
       
 20795                 this._activateCircleInteraction(map);
       
 20796                 break;
       
 20797             case 'extent':
       
 20798                 this._activateBoxInteraction(map);
       
 20799                 break;
       
 20800             default:
       
 20801                 break;
       
 20802             }
       
 20803         },
       
 20804         _removeMapInteraction: function (map) {
       
 20805             if (!map) {
       
 20806                 return;
       
 20807             }
       
 20808             if (this._inputFeaturesLayer !== null) {
       
 20809                 map.off('draw:created');
       
 20810                 map.off('draw:drawstart');
       
 20811                 map.off('draw:drawstop');
       
 20812                 map.removeLayer(this._inputFeaturesLayer);
       
 20813                 this._inputFeaturesLayer = null;
       
 20814             }
       
 20815             this._lastIdLayer = this._currentIdLayer = 0;
       
 20816             if (this._currentFeature) {
       
 20817                 this._currentFeature.disable();
       
 20818             }
       
 20819         },
       
 20820         _activatePointInteraction: function (map) {
       
 20821             if (this._currentFeature) {
       
 20822                 this._currentFeature.disable();
       
 20823             }
       
 20824             L.drawLocal.draw.handlers.marker.tooltip.start = 'click map to place search point';
       
 20825             var markerOptions = { repeatMode: true };
       
 20826             this._currentFeature = new L.Draw.Marker(map, markerOptions);
       
 20827             this._currentFeature.enable();
       
 20828         },
       
 20829         _activateCircleInteraction: function (map) {
       
 20830             if (this._currentFeature) {
       
 20831                 this._currentFeature.disable();
       
 20832             }
       
 20833             var circleOptions = { repeatMode: true };
       
 20834             this._currentFeature = new L.Draw.Circle(map, circleOptions);
       
 20835             this._currentFeature.enable();
       
 20836         },
       
 20837         _activateBoxInteraction: function (map) {
       
 20838             if (this._currentFeature) {
       
 20839                 this._currentFeature.disable();
       
 20840             }
       
 20841             var rectangleOptions = { repeatMode: true };
       
 20842             this._currentFeature = new L.Draw.Rectangle(map, rectangleOptions);
       
 20843             this._currentFeature.enable();
       
 20844         },
       
 20845         _setFeaturePosition: function (layer, type) {
       
 20846             var oLatLng = null;
       
 20847             if (type === 'marker') {
       
 20848                 oLatLng = layer.getLatLng();
       
 20849                 this._requestPosition = {
       
 20850                     x: oLatLng.lat,
       
 20851                     y: oLatLng.lng
       
 20852                 };
       
 20853             } else if (type === 'circle') {
       
 20854                 oLatLng = layer.getLatLng();
       
 20855                 this._requestPosition = {
       
 20856                     x: oLatLng.lat,
       
 20857                     y: oLatLng.lng
       
 20858                 };
       
 20859                 this._requestCircleFilter = {
       
 20860                     x: oLatLng.lat,
       
 20861                     y: oLatLng.lng,
       
 20862                     radius: layer.getRadius()
       
 20863                 };
       
 20864             } else if (type === 'rectangle') {
       
 20865                 oLatLng = layer.getBounds();
       
 20866                 var center = {
       
 20867                     lng: (oLatLng.getSouthWest().lng + oLatLng.getNorthEast().lng) / 2,
       
 20868                     lat: (oLatLng.getSouthWest().lat + oLatLng.getNorthEast().lat) / 2
       
 20869                 };
       
 20870                 this._requestPosition = {
       
 20871                     x: center.lat,
       
 20872                     y: center.lng
       
 20873                 };
       
 20874                 this._requestBboxFilter = {
       
 20875                     left: oLatLng.getSouthWest().lat,
       
 20876                     right: oLatLng.getNorthEast().lat,
       
 20877                     bottom: oLatLng.getSouthWest().lng,
       
 20878                     top: oLatLng.getNorthEast().lng
       
 20879                 };
       
 20880             } else {
       
 20881             }
       
 20882         },
       
 20883         _setFeatureLayer: function (layer) {
       
 20884             if (!this._inputFeaturesLayer) {
       
 20885                 return;
       
 20886             }
       
 20887             this._inputFeaturesLayer.addLayer(layer);
       
 20888         },
       
 20889         _removeFeatureLayer: function (id) {
       
 20890             if (!this._inputFeaturesLayer) {
       
 20891                 return;
       
 20892             }
       
 20893             if (id === 0) {
       
 20894                 return;
       
 20895             }
       
 20896             if (!id) {
       
 20897                 this._inputFeaturesLayer.clearLayers();
       
 20898             } else {
       
 20899                 this._inputFeaturesLayer.removeLayer(id);
       
 20900             }
       
 20901         },
       
 20902         _reverseGeocodingRequest: function (settings) {
       
 20903             var map = this._map;
       
 20904             this._removeMapInteraction(map);
       
 20905             var options = {};
       
 20906             L.Util.extend(options, this.options.reverseGeocodeOptions);
       
 20907             L.Util.extend(options, settings);
       
 20908             L.Util.extend(options, {
       
 20909                 apiKey: this.options.apiKey,
       
 20910                 srs: 'EPSG:4326',
       
 20911                 returnFreeForm: false,
       
 20912                 timeOut: 30000,
       
 20913                 protocol: 'XHR'
       
 20914             });
       
 20915             var _type = options.filterOptions.type;
       
 20916             if (this._currentGeocodingDelimitation.toLowerCase() === 'circle' && this._requestCircleFilter) {
       
 20917                 if (this._requestCircleFilter.radius > 1000) {
       
 20918                     this._requestCircleFilter.radius = 1000;
       
 20919                 }
       
 20920                 L.Util.extend(options, {
       
 20921                     filterOptions: {
       
 20922                         type: _type,
       
 20923                         circle: this._requestCircleFilter
       
 20924                     }
       
 20925                 });
       
 20926             }
       
 20927             if (this._currentGeocodingDelimitation.toLowerCase() === 'extent' && this._requestBboxFilter) {
       
 20928                 L.Util.extend(options, {
       
 20929                     filterOptions: {
       
 20930                         type: _type,
       
 20931                         bbox: this._requestBboxFilter
       
 20932                     }
       
 20933                 });
       
 20934             }
       
 20935             this._displayWaitingContainer();
       
 20936             Gp.Services.reverseGeocode(options);
       
 20937         },
       
 20938         _displayGeocodedLocations: function (locations) {
       
 20939             this._clearLocations();
       
 20940             this._clearLocationsFeature();
       
 20941             this._reverseGeocodingLocations = locations;
       
 20942             if (!locations || locations.length === 0) {
       
 20943                 this._clearInputRequest();
       
 20944                 return;
       
 20945             }
       
 20946             this._formContainer.className = 'GPreverseGeocodingComponentHidden';
       
 20947             this._hideWaitingContainer();
       
 20948             this._panelTitleContainer.innerHTML = 'Résultats de la recherche';
       
 20949             this._returnPictoContainer.className = '';
       
 20950             this._resultsContainer.className = 'GPpanel';
       
 20951             this._fillGeocodedLocationListContainer(locations);
       
 20952             this._displayGeocodedLocationsOnMap(locations);
       
 20953             var map = this._map;
       
 20954             map.fitBounds(this._inputResultsLayer.getBounds());
       
 20955         },
       
 20956         _fillGeocodedLocationListContainer: function (locations) {
       
 20957             for (var i = 0; i < locations.length; i++) {
       
 20958                 var location = locations[i];
       
 20959                 var locationDescription = this._fillGeocodedLocationDescription(location);
       
 20960                 if (locationDescription.length !== 0) {
       
 20961                     this._createReverseGeocodingResultElement(locationDescription, i);
       
 20962                 }
       
 20963             }
       
 20964         },
       
 20965         _fillGeocodedLocationDescription: function (location) {
       
 20966             if (!location || !location.placeAttributes) {
       
 20967                 return;
       
 20968             }
       
 20969             var attr = location.placeAttributes;
       
 20970             var locationDescription = '';
       
 20971             switch (location.type) {
       
 20972             case 'StreetAddress':
       
 20973                 if (attr.street) {
       
 20974                     locationDescription += attr.number ? attr.number + ' ' : '';
       
 20975                     locationDescription += attr.street + ', ';
       
 20976                 }
       
 20977                 locationDescription += attr.postalCode + ' ' + attr.commune;
       
 20978                 break;
       
 20979             case 'PositionOfInterest':
       
 20980                 if (location.matchType === 'City' && attr.commune) {
       
 20981                     locationDescription += attr.commune;
       
 20982                     locationDescription += attr.postalCode ? ', ' + attr.postalCode : '';
       
 20983                 } else if (location.matchType === 'Département' && attr.municipality) {
       
 20984                     locationDescription += attr.municipality;
       
 20985                     locationDescription += attr.postalCode ? ', ' + attr.postalCode : '';
       
 20986                 } else if (location.matchType === 'Toponym' && attr.municipality) {
       
 20987                     locationDescription += attr.municipality;
       
 20988                     locationDescription += attr.postalCode ? ', ' + attr.postalCode : '';
       
 20989                     locationDescription += attr.commune ? ' ' + attr.commune : '';
       
 20990                 } else {
       
 20991                     locationDescription += attr.municipality ? attr.municipality : '';
       
 20992                 }
       
 20993                 locationDescription += attr.nature ? ' (' + attr.nature + ') ' : '';
       
 20994                 break;
       
 20995             case 'CadastralParcel':
       
 20996                 locationDescription += attr.cadastralParcel ? attr.cadastralParcel : '';
       
 20997                 locationDescription += attr.municipality ? ' (' + attr.municipality + ')' : '';
       
 20998                 break;
       
 20999             case 'Administratif':
       
 21000                 locationDescription += attr.municipality ? attr.municipality : '';
       
 21001                 if (attr.inseeDepartment) {
       
 21002                     locationDescription += '(Département)';
       
 21003                 } else if (attr.inseeRegion) {
       
 21004                     locationDescription += '(Région)';
       
 21005                 }
       
 21006                 break;
       
 21007             default:
       
 21008                 locationDescription += attr.municipality ? attr.municipality : '';
       
 21009                 break;
       
 21010             }
       
 21011             return locationDescription;
       
 21012         },
       
 21013         _displayGeocodedLocationsOnMap: function (locations) {
       
 21014             var map = this._map;
       
 21015             var self = this;
       
 21016             function _setHighLight(e) {
       
 21017                 var layer = e.target;
       
 21018                 layer.setIcon(new IconDefault('red'));
       
 21019                 var div = L.DomUtil.get('ReverseGeocodedLocation_' + layer.options.id + '-' + self._uid);
       
 21020                 L.DomUtil.addClass(div, 'GPreverseGeocodedLocationHighlight');
       
 21021                 div.scrollIntoView(false);
       
 21022             }
       
 21023             function _resetHighLight(e) {
       
 21024                 var layer = e.target;
       
 21025                 layer.setIcon(new IconDefault('green'));
       
 21026                 var div = L.DomUtil.get('ReverseGeocodedLocation_' + layer.options.id + '-' + self._uid);
       
 21027                 L.DomUtil.removeClass(div, 'GPreverseGeocodedLocationHighlight');
       
 21028             }
       
 21029             this._inputResultsLayer = new L.FeatureGroup();
       
 21030             map.addLayer(this._inputResultsLayer);
       
 21031             for (var i = 0; i < locations.length; i++) {
       
 21032                 var location = locations[i];
       
 21033                 if (!location) {
       
 21034                     continue;
       
 21035                 }
       
 21036                 var options = {
       
 21037                     id: i,
       
 21038                     icon: new IconDefault('green'),
       
 21039                     riseOnHover: true,
       
 21040                     draggable: false,
       
 21041                     clickable: true,
       
 21042                     zIndexOffset: 1000
       
 21043                 };
       
 21044                 var _marker = L.marker(L.latLng(location.position.x, location.position.y), options);
       
 21045                 var popupContent = '<ul>';
       
 21046                 var attributes = location.placeAttributes;
       
 21047                 for (var attr in attributes) {
       
 21048                     if (attributes.hasOwnProperty(attr)) {
       
 21049                         if (attr !== 'bbox') {
       
 21050                             popupContent += '<li>';
       
 21051                             popupContent += '<span class="gp-attname-others-span">' + attr.toUpperCase() + ' : </span>';
       
 21052                             popupContent += attributes[attr];
       
 21053                             popupContent += ' </li>';
       
 21054                         }
       
 21055                     }
       
 21056                 }
       
 21057                 popupContent += ' </ul>';
       
 21058                 _marker.bindPopup(popupContent);
       
 21059                 _marker.on('mouseover', _setHighLight);
       
 21060                 _marker.on('mouseout', _resetHighLight);
       
 21061                 this._inputResultsLayer.addLayer(_marker);
       
 21062             }
       
 21063         },
       
 21064         onShowReverseGeocodingClick: function () {
       
 21065             var map = this._map;
       
 21066             if (this._showReverseGeocodingContainer.checked) {
       
 21067                 this._removeMapInteraction(map);
       
 21068             } else {
       
 21069                 if (!this._waiting && !this._reverseGeocodingLocations.length) {
       
 21070                     this._activateMapInteraction(map);
       
 21071                 }
       
 21072             }
       
 21073         },
       
 21074         onReverseGeocodingTypeChange: function (e) {
       
 21075             var idx = e.target.selectedIndex;
       
 21076             var value = e.target.options[idx].value;
       
 21077             if (!value) {
       
 21078                 return;
       
 21079             }
       
 21080             this._currentGeocodingType = value;
       
 21081         },
       
 21082         onReverseGeocodingDelimitationChange: function (e) {
       
 21083             var idx = e.target.selectedIndex;
       
 21084             var value = e.target.options[idx].value;
       
 21085             if (!value) {
       
 21086                 return;
       
 21087             }
       
 21088             this._currentGeocodingDelimitation = value;
       
 21089             this._clearInputRequest();
       
 21090             var map = this._map;
       
 21091             this._removeMapInteraction(map);
       
 21092             this._activateMapInteraction(map);
       
 21093         },
       
 21094         onGPreverseGeocodingReturnPictoClick: function () {
       
 21095             this._clearLocations();
       
 21096             this._clearLocationsFeature();
       
 21097             this._clearInputRequest();
       
 21098             this._activateMapInteraction(this._map);
       
 21099         },
       
 21100         onReverseGeocodingSubmit: function () {
       
 21101             if (!this._requestPosition) {
       
 21102                 return;
       
 21103             }
       
 21104             if (this._noRightManagement) {
       
 21105                 return;
       
 21106             }
       
 21107             var self = this;
       
 21108             this._reverseGeocodingRequest({
       
 21109                 position: self._requestPosition,
       
 21110                 filterOptions: { type: [self._currentGeocodingType] },
       
 21111                 onSuccess: function (results) {
       
 21112                     if (results) {
       
 21113                         var locations = results.locations;
       
 21114                         self._displayGeocodedLocations(locations);
       
 21115                         self._hideWaitingContainer();
       
 21116                     }
       
 21117                 },
       
 21118                 onFailure: function (error) {
       
 21119                     self._hideWaitingContainer();
       
 21120                     self._clearLocations();
       
 21121                     self._clearLocationsFeature();
       
 21122                     self._clearInputRequest();
       
 21123                 }
       
 21124             });
       
 21125         },
       
 21126         onReverseGeocodingResultClick: function (e) {
       
 21127         },
       
 21128         onReverseGeocodingResultMouseOver: function (e) {
       
 21129             var idx = ID.index(e.target.id);
       
 21130             if (e.target.classList) {
       
 21131                 e.target.classList.add('GPreverseGeocodedLocationHighlight');
       
 21132             }
       
 21133             if (!this._inputResultsLayer) {
       
 21134                 return;
       
 21135             }
       
 21136             this._inputResultsLayer.eachLayer(function (layer) {
       
 21137                 if (layer.options.id === parseInt(idx, 10)) {
       
 21138                     layer.fire('mouseover');
       
 21139                 }
       
 21140             });
       
 21141         },
       
 21142         onReverseGeocodingResultMouseOut: function (e) {
       
 21143             var idx = ID.index(e.target.id);
       
 21144             if (e.target.classList) {
       
 21145                 e.target.classList.remove('GPreverseGeocodedLocationHighlight');
       
 21146             }
       
 21147             if (!this._inputResultsLayer) {
       
 21148                 return;
       
 21149             }
       
 21150             this._inputResultsLayer.eachLayer(function (layer) {
       
 21151                 if (layer.options.id === parseInt(idx, 10)) {
       
 21152                     layer.fire('mouseout');
       
 21153                 }
       
 21154             });
       
 21155         },
       
 21156         _clearLocations: function () {
       
 21157             this._reverseGeocodingLocations = [];
       
 21158             if (this._resultsListContainer) {
       
 21159                 while (this._resultsListContainer.firstChild) {
       
 21160                     this._resultsListContainer.removeChild(this._resultsListContainer.firstChild);
       
 21161                 }
       
 21162             }
       
 21163         },
       
 21164         _clearLocationsFeature: function () {
       
 21165             var map = this._map;
       
 21166             if (this._inputResultsLayer !== null) {
       
 21167                 map.removeLayer(this._inputResultsLayer);
       
 21168                 this._inputResultsLayer = null;
       
 21169             }
       
 21170         },
       
 21171         _clearInputRequest: function () {
       
 21172             this._requestPosition = null;
       
 21173             this._requestCircleFilter = null;
       
 21174             this._requestBboxFilter = null;
       
 21175         },
       
 21176         _displayWaitingContainer: function () {
       
 21177             this._waitingContainer.className = 'GPreverseGeocodingCalcWaitingContainerVisible';
       
 21178             this._waiting = true;
       
 21179             if (this._timer) {
       
 21180                 clearTimeout(this._timer);
       
 21181                 this._timer = null;
       
 21182             }
       
 21183             var context = this;
       
 21184             this._timer = setTimeout(function () {
       
 21185                 if (context._waiting === true) {
       
 21186                     context._hideWaitingContainer();
       
 21187                 } else {
       
 21188                     if (context._timer) {
       
 21189                         clearTimeout(context._timer);
       
 21190                     }
       
 21191                 }
       
 21192             }, 16000);
       
 21193         },
       
 21194         _hideWaitingContainer: function () {
       
 21195             if (this._waiting) {
       
 21196                 this._waitingContainer.className = 'GPreverseGeocodingCalcWaitingContainerHidden';
       
 21197                 this._waiting = false;
       
 21198                 clearTimeout(this._timer);
       
 21199                 this._timer = null;
       
 21200             }
       
 21201         }
       
 21202     });
       
 21203     return ReverseGeocoding;
       
 21204 }(leaflet, leafletDraw, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, LeafletControlsUtilsIconDefault, CommonControlsReverseGeocodingDOM);
       
 21205 CommonControlsRouteDOM = function (ID) {
       
 21206     var RouteDOM = {
       
 21207         _addUID: function (id) {
       
 21208             return id + '-' + this._uid;
       
 21209         },
       
 21210         _createMainContainerElement: function () {
       
 21211             var container = document.createElement('div');
       
 21212             container.id = this._addUID('GProute');
       
 21213             container.className = 'GPwidget';
       
 21214             return container;
       
 21215         },
       
 21216         _createShowRouteElement: function () {
       
 21217             var input = document.createElement('input');
       
 21218             input.id = this._addUID('GPshowRoute');
       
 21219             input.type = 'checkbox';
       
 21220             return input;
       
 21221         },
       
 21222         _createShowRoutePictoElement: function () {
       
 21223             var context = this;
       
 21224             var label = document.createElement('label');
       
 21225             label.id = this._addUID('GPshowRoutePicto');
       
 21226             label.className = 'GPshowAdvancedToolPicto';
       
 21227             label.htmlFor = this._addUID('GPshowRoute');
       
 21228             label.title = 'Ouvrir le calcul d\'itinéraire';
       
 21229             if (label.addEventListener) {
       
 21230                 label.addEventListener('click', function (e) {
       
 21231                     context.onShowRoutePanelClick(e);
       
 21232                 });
       
 21233             } else if (label.attachEvent) {
       
 21234                 label.attachEvent('onclick', function (e) {
       
 21235                     context.onShowRoutePanelClick(e);
       
 21236                 });
       
 21237             }
       
 21238             var spanOpen = document.createElement('span');
       
 21239             spanOpen.id = this._addUID('GPshowRouteOpen');
       
 21240             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 21241             label.appendChild(spanOpen);
       
 21242             return label;
       
 21243         },
       
 21244         _createRoutePanelElement: function () {
       
 21245             var div = document.createElement('div');
       
 21246             div.id = this._addUID('GProutePanel');
       
 21247             div.className = 'GPpanel';
       
 21248             return div;
       
 21249         },
       
 21250         _createRoutePanelHeaderElement: function () {
       
 21251             var self = this;
       
 21252             var container = document.createElement('div');
       
 21253             container.className = 'GPpanelHeader';
       
 21254             var div = document.createElement('div');
       
 21255             div.className = 'GPpanelTitle';
       
 21256             div.innerHTML = 'Calcul d\'itinéraire';
       
 21257             container.appendChild(div);
       
 21258             var divClose = document.createElement('div');
       
 21259             divClose.id = this._addUID('GProutePanelClose');
       
 21260             divClose.className = 'GPpanelClose';
       
 21261             divClose.title = 'Masquer le panneau';
       
 21262             if (divClose.addEventListener) {
       
 21263                 divClose.addEventListener('click', function () {
       
 21264                     document.getElementById(self._addUID('GPshowRoutePicto')).click();
       
 21265                 }, false);
       
 21266             } else if (divClose.attachEvent) {
       
 21267                 divClose.attachEvent('onclick', function () {
       
 21268                     document.getElementById(self._addUID('GPshowRoutePicto')).click();
       
 21269                 });
       
 21270             }
       
 21271             container.appendChild(divClose);
       
 21272             return container;
       
 21273         },
       
 21274         _createRoutePanelFormElement: function () {
       
 21275             var self = this;
       
 21276             var form = document.createElement('form');
       
 21277             form.id = this._addUID('GProuteForm');
       
 21278             form.setAttribute('onkeypress', 'return event.keyCode != 13;');
       
 21279             form.addEventListener('submit', function (e) {
       
 21280                 console.log(e);
       
 21281                 e.preventDefault();
       
 21282                 var points = document.getElementsByClassName(self._addUID('GPlocationPoint'));
       
 21283                 var start = points[0].childNodes[0].id;
       
 21284                 var end = points[points.length - 1].childNodes[0].id;
       
 21285                 var startID = ID.index(start);
       
 21286                 var endID = ID.index(end);
       
 21287                 if (document.getElementById(self._addUID('GPlocationOrigin_' + startID)).value == '' && document.getElementById(self._addUID('GPlocationOriginCoords_' + startID)).value == '' || document.getElementById(self._addUID('GPlocationOrigin_' + endID)).value == '' && document.getElementById(self._addUID('GPlocationOriginCoords_' + endID)).value == '') {
       
 21288                     return false;
       
 21289                 }
       
 21290                 var id;
       
 21291                 document.getElementById(self._addUID('GProuteResultsStages')).innerHTML = '';
       
 21292                 for (var i = 0; i < points.length; i++) {
       
 21293                     var tag = points[i].childNodes[0].id;
       
 21294                     id = ID.index(tag);
       
 21295                     if (document.getElementById(self._addUID('GPlocationPoint_' + id)).className == 'GPflexInput GPlocationStageFlexInput') {
       
 21296                         var resultStage = document.createElement('div');
       
 21297                         resultStage.className = 'GProuteResultsStages';
       
 21298                         var resultStageLabel = document.createElement('div');
       
 21299                         resultStageLabel.className = 'GProuteResultStageLabel';
       
 21300                         resultStageLabel.innerHTML = document.getElementById(self._addUID('GPlocationOriginLabel_' + id)).innerHTML + ' :';
       
 21301                         resultStage.appendChild(resultStageLabel);
       
 21302                         var resultStageValue = document.createElement('div');
       
 21303                         resultStageValue.className = 'GProuteResultStageValue';
       
 21304                         var elementCoords = document.getElementById(self._addUID('GPlocationOriginCoords_' + id));
       
 21305                         var stageCoords = elementCoords.value;
       
 21306                         var visible = elementCoords.className === 'GPlocationOriginVisible' ? true : false;
       
 21307                         if (stageCoords != null && stageCoords != '' && visible) {
       
 21308                             resultStageValue.innerHTML = stageCoords;
       
 21309                         } else {
       
 21310                             resultStageValue.innerHTML = document.getElementById(self._addUID('GPlocationOrigin_' + id)).value;
       
 21311                         }
       
 21312                         resultStage.appendChild(resultStageValue);
       
 21313                         if (resultStageValue.innerHTML != '') {
       
 21314                             document.getElementById(self._addUID('GProuteResultsStages')).appendChild(resultStage);
       
 21315                         }
       
 21316                     }
       
 21317                 }
       
 21318                 var modeComputation = null;
       
 21319                 if (document.getElementById(self._addUID('GProuteComputationSelect'))) {
       
 21320                     var select = document.getElementById(self._addUID('GProuteResultsComputationSelect'));
       
 21321                     select.selectedIndex = document.getElementById(self._addUID('GProuteComputationSelect')).selectedIndex;
       
 21322                     modeComputation = select.options[select.selectedIndex].value;
       
 21323                 }
       
 21324                 var modeTransport = null;
       
 21325                 if (document.getElementById(self._addUID('GProuteTransportCar'))) {
       
 21326                     if (document.getElementById(self._addUID('GProuteTransportCar')).checked) {
       
 21327                         modeTransport = document.getElementById(self._addUID('GProuteTransportCar')).value;
       
 21328                     }
       
 21329                 }
       
 21330                 if (document.getElementById(self._addUID('GProuteTransportPedestrian'))) {
       
 21331                     if (document.getElementById(self._addUID('GProuteTransportPedestrian')).checked) {
       
 21332                         modeTransport = document.getElementById(self._addUID('GProuteTransportPedestrian')).value;
       
 21333                     }
       
 21334                 }
       
 21335                 var exclusions = [];
       
 21336                 var exclusionsElement = document.getElementsByClassName('GProuteExclusionsOption');
       
 21337                 for (var j = 0; j < exclusionsElement.length; j++) {
       
 21338                     id = exclusionsElement[j].htmlFor;
       
 21339                     var el = document.getElementById(id);
       
 21340                     if (!el.checked) {
       
 21341                         exclusions.push(el.value);
       
 21342                     }
       
 21343                 }
       
 21344                 self.onRouteComputationSubmit({
       
 21345                     computation: modeComputation,
       
 21346                     transport: modeTransport,
       
 21347                     exclusions: exclusions
       
 21348                 });
       
 21349                 return false;
       
 21350             });
       
 21351             return form;
       
 21352         },
       
 21353         _createRoutePanelResultsElement: function () {
       
 21354             var container = document.createElement('div');
       
 21355             container.id = this._addUID('GProuteResultsPanel');
       
 21356             container.className = 'GProuteComponentHidden';
       
 21357             container.appendChild(this._createRouteResultsStagesElement());
       
 21358             container.appendChild(this._createRouteResultsElement());
       
 21359             var divBorderUp = document.createElement('div');
       
 21360             divBorderUp.className = 'GPfakeBorder GPfakeBorderLeft';
       
 21361             container.appendChild(divBorderUp);
       
 21362             container.appendChild(this._createRouteShowResultsDetailsElement());
       
 21363             var labelShow = document.createElement('label');
       
 21364             labelShow.htmlFor = this._addUID('GProuteResultsShowDetails');
       
 21365             labelShow.innerHTML = 'Afficher le détail';
       
 21366             container.appendChild(labelShow);
       
 21367             var labelHide = document.createElement('label');
       
 21368             labelHide.htmlFor = this._addUID('GProuteResultsShowDetails');
       
 21369             labelHide.innerHTML = 'Masquer le détail';
       
 21370             container.appendChild(labelHide);
       
 21371             var divBorderDown = document.createElement('div');
       
 21372             divBorderDown.className = 'GPfakeBorder';
       
 21373             container.appendChild(divBorderDown);
       
 21374             container.appendChild(this._createRouteResultsDetailsElement());
       
 21375             return container;
       
 21376         },
       
 21377         _createRouteWaitingElement: function () {
       
 21378             var div = document.createElement('div');
       
 21379             div.id = this._addUID('GProuteCalcWaitingContainer');
       
 21380             div.className = 'GProuteCalcWaitingContainerHidden';
       
 21381             var p = document.createElement('p');
       
 21382             p.className = 'GProuteCalcWaiting';
       
 21383             p.innerHTML = 'Calcul en cours...';
       
 21384             div.appendChild(p);
       
 21385             return div;
       
 21386         },
       
 21387         _createRouteResultsStagesElement: function () {
       
 21388             var div = document.createElement('div');
       
 21389             div.id = this._addUID('GProuteResultsStages');
       
 21390             return div;
       
 21391         },
       
 21392         _createRouteResultsElement: function () {
       
 21393             var self = this;
       
 21394             var container = document.createElement('div');
       
 21395             container.id = this._addUID('GProuteResults');
       
 21396             var divValue = document.createElement('div');
       
 21397             divValue.id = this._addUID('GProuteResultsValues');
       
 21398             container.appendChild(divValue);
       
 21399             var divMode = document.createElement('div');
       
 21400             divMode.id = this._addUID('GProuteResultsMode');
       
 21401             var select = document.createElement('select');
       
 21402             select.id = this._addUID('GProuteResultsComputationSelect');
       
 21403             select.className = 'GPinputSelect';
       
 21404             select.addEventListener('change', function (e) {
       
 21405                 self.onRouteModeComputationChangeAndRun(e);
       
 21406             });
       
 21407             var computes = [
       
 21408                 {
       
 21409                     code: 'fastest',
       
 21410                     label: 'Plus rapide'
       
 21411                 },
       
 21412                 {
       
 21413                     code: 'shortest',
       
 21414                     label: 'Plus court'
       
 21415                 }
       
 21416             ];
       
 21417             for (var i = 0; i < computes.length; i++) {
       
 21418                 var option = document.createElement('option');
       
 21419                 option.value = computes[i].code;
       
 21420                 option.text = computes[i].label;
       
 21421                 select.appendChild(option);
       
 21422             }
       
 21423             divMode.appendChild(select);
       
 21424             container.appendChild(divMode);
       
 21425             var divNew = document.createElement('div');
       
 21426             divNew.id = this._addUID('GProuteResultsNew');
       
 21427             divNew.title = 'Modifier le calcul';
       
 21428             divNew.addEventListener('click', function (e) {
       
 21429                 document.getElementById(self._addUID('GProuteResultsPanel')).className = 'GProuteComponentHidden';
       
 21430                 document.getElementById(self._addUID('GProuteForm')).className = '';
       
 21431                 self.onShowRouteResultsNewClick(e);
       
 21432             });
       
 21433             container.appendChild(divNew);
       
 21434             return container;
       
 21435         },
       
 21436         _addRouteResultsValuesElement: function (distance, duration, fconvert) {
       
 21437             var div = document.getElementById(this._addUID('GProuteResultsValues'));
       
 21438             if (div.childElementCount) {
       
 21439                 while (div.firstChild) {
       
 21440                     div.removeChild(div.firstChild);
       
 21441                 }
       
 21442             }
       
 21443             var containerDistance = document.createElement('div');
       
 21444             containerDistance.className = 'GProuteResultsValue';
       
 21445             var labelDistance = document.createElement('label');
       
 21446             labelDistance.className = 'GProuteResultsValueLabel';
       
 21447             labelDistance.innerHTML = 'Distance :';
       
 21448             containerDistance.appendChild(labelDistance);
       
 21449             var distanceLabel = 0;
       
 21450             var isKm = parseInt(distance / 1000, 10);
       
 21451             if (!isKm) {
       
 21452                 distanceLabel = Math.round(distance) + ' m';
       
 21453             } else {
       
 21454                 var distanceArrondi = Math.round(distance);
       
 21455                 distanceArrondi = distanceArrondi / 1000;
       
 21456                 distanceLabel = distanceArrondi + ' km';
       
 21457             }
       
 21458             var divDistance = document.createElement('div');
       
 21459             divDistance.id = this._addUID('GProuteResultsValueDist');
       
 21460             divDistance.innerHTML = distanceLabel;
       
 21461             containerDistance.appendChild(divDistance);
       
 21462             div.appendChild(containerDistance);
       
 21463             var containerDuration = document.createElement('div');
       
 21464             containerDuration.className = 'GProuteResultsValue';
       
 21465             var labelDuration = document.createElement('label');
       
 21466             labelDuration.className = 'GProuteResultsValueLabel';
       
 21467             labelDuration.innerHTML = 'Durée :';
       
 21468             containerDuration.appendChild(labelDuration);
       
 21469             var divDuration = document.createElement('div');
       
 21470             divDuration.id = this._addUID('GProuteResultsValueDist');
       
 21471             divDuration.innerHTML = fconvert(duration);
       
 21472             containerDuration.appendChild(divDuration);
       
 21473             div.appendChild(containerDuration);
       
 21474             return div;
       
 21475         },
       
 21476         _createRouteShowResultsDetailsElement: function () {
       
 21477             var input = document.createElement('input');
       
 21478             input.id = this._addUID('GProuteResultsShowDetails');
       
 21479             input.type = 'checkbox';
       
 21480             return input;
       
 21481         },
       
 21482         _createRouteResultsDetailsElement: function () {
       
 21483             var div = document.createElement('div');
       
 21484             div.id = this._addUID('GProuteResultsDetails');
       
 21485             return div;
       
 21486         },
       
 21487         _addRouteResultsDetailsElement: function (instructions, fconvert) {
       
 21488             var context = this;
       
 21489             var div = document.getElementById(this._addUID('GProuteResultsDetails'));
       
 21490             if (div.childElementCount) {
       
 21491                 while (div.firstChild) {
       
 21492                     div.removeChild(div.firstChild);
       
 21493                 }
       
 21494             }
       
 21495             var distanceCumul = 0;
       
 21496             var durationCumul = 0;
       
 21497             for (var i = 0; i < instructions.length; i++) {
       
 21498                 var id = i + 1;
       
 21499                 var o = instructions[i];
       
 21500                 var divNum = document.createElement('div');
       
 21501                 divNum.className = 'GProuteResultsDetailsNumber';
       
 21502                 divNum.innerHTML = id + '.';
       
 21503                 div.appendChild(divNum);
       
 21504                 durationCumul += parseFloat(o.duration);
       
 21505                 distanceCumul += parseFloat(o.distance);
       
 21506                 var distance = 0;
       
 21507                 var isCumulKm = parseInt(distanceCumul / 1000, 10);
       
 21508                 if (!isCumulKm) {
       
 21509                     distance = Math.round(distanceCumul) + ' m';
       
 21510                 } else {
       
 21511                     var distanceArrondi = Math.round(distanceCumul);
       
 21512                     distanceArrondi = distanceArrondi / 1000;
       
 21513                     distance = distanceArrondi + ' km';
       
 21514                 }
       
 21515                 var divIns = document.createElement('div');
       
 21516                 divIns.className = 'GProuteResultsDetailsInstruction';
       
 21517                 divIns.id = this._addUID('GProuteResultsDetailsInstruction_' + id);
       
 21518                 divIns.title = 'distance : ' + distance + ' / ' + 'temps : ' + fconvert(durationCumul);
       
 21519                 divIns.innerHTML = o.instruction;
       
 21520                 divIns.addEventListener('mouseover', function (e) {
       
 21521                     context.onRouteResultsDetailsMouseOver(e);
       
 21522                 });
       
 21523                 divIns.addEventListener('mouseout', function (e) {
       
 21524                     context.onRouteResultsDetailsMouseOut(e);
       
 21525                 });
       
 21526                 divIns.addEventListener('click', function (e) {
       
 21527                     if (typeof context.onRouteResultsDetailsClick === 'function') {
       
 21528                         context.onRouteResultsDetailsClick(e);
       
 21529                     }
       
 21530                 });
       
 21531                 div.appendChild(divIns);
       
 21532             }
       
 21533             return div;
       
 21534         },
       
 21535         _createRoutePanelFormPointElement: function (n, text, visibility) {
       
 21536             var context = this;
       
 21537             var div = document.createElement('div');
       
 21538             div.id = 'GProutePoint' + n;
       
 21539             div.className = visibility ? 'GPflexInput GProuteStageFlexInput' : 'GPflexInput GProuteStageFlexInputHidden';
       
 21540             var labelOrigin = document.createElement('label');
       
 21541             labelOrigin.id = 'GProuteOriginLabel' + n;
       
 21542             labelOrigin.htmlFor = 'GProuteOrigin' + n;
       
 21543             labelOrigin.innerHTML = text;
       
 21544             labelOrigin.addEventListener('click', function () {
       
 21545                 var i = this.id.charAt(this.id.length - 1);
       
 21546                 document.getElementById('GProuteOriginCoords' + i).value = '';
       
 21547                 for (var j = 1; j < 8; j++) {
       
 21548                     document.getElementById('GProutePoint' + j).style.display = 'flex';
       
 21549                 }
       
 21550                 document.getElementById('GProuteForm').className = '';
       
 21551                 document.getElementById('GProuteOriginPointer' + i).checked = false;
       
 21552                 document.getElementById('GProuteOrigin' + i).className = 'GProuteOriginVisible';
       
 21553                 document.getElementById('GProuteOriginCoords' + i).className = 'GProuteOriginHidden';
       
 21554             });
       
 21555             div.appendChild(labelOrigin);
       
 21556             var inputOrigin = document.createElement('input');
       
 21557             inputOrigin.id = 'GProuteOrigin' + n;
       
 21558             inputOrigin.className = 'GProuteOriginVisible';
       
 21559             inputOrigin.type = 'text';
       
 21560             inputOrigin.placeholder = 'Saisir une adresse';
       
 21561             inputOrigin.addEventListener('keyup', function (e) {
       
 21562                 var charCode = e.which || e.keyCode;
       
 21563                 if (charCode === 13 || charCode === 10) {
       
 21564                     return;
       
 21565                 }
       
 21566                 var i = this.id.charAt(this.id.length - 1);
       
 21567                 if (document.getElementById('GProuteOrigin' + i).value.length > 2) {
       
 21568                     document.getElementById('GProuteAutoCompleteList' + i).style.display = 'block';
       
 21569                 } else {
       
 21570                     document.getElementById('GProuteAutoCompleteList' + i).style.display = 'none';
       
 21571                 }
       
 21572                 context.onAutoCompleteSearchText(e);
       
 21573             });
       
 21574             inputOrigin.addEventListener('blur', function () {
       
 21575                 var i = this.id.charAt(this.id.length - 1);
       
 21576                 document.getElementById('GProuteAutoCompleteList' + i).style.display = 'none';
       
 21577             });
       
 21578             div.appendChild(inputOrigin);
       
 21579             var inputOriginCoord = document.createElement('input');
       
 21580             inputOriginCoord.id = 'GProuteOriginCoords' + n;
       
 21581             inputOriginCoord.className = 'GProuteOriginHidden';
       
 21582             inputOriginCoord.type = 'text';
       
 21583             inputOriginCoord.disabled = true;
       
 21584             div.appendChild(inputOriginCoord);
       
 21585             var inputOriginPointer = document.createElement('input');
       
 21586             inputOriginPointer.id = 'GProuteOriginPointer' + n;
       
 21587             inputOriginPointer.type = 'checkbox';
       
 21588             div.appendChild(inputOriginPointer);
       
 21589             var labelOriginPointer = document.createElement('label');
       
 21590             labelOriginPointer.id = 'GProuteOriginPointerImg' + n;
       
 21591             labelOriginPointer.htmlFor = 'GProuteOriginPointer' + n;
       
 21592             labelOriginPointer.className = 'GProuteOriginPointerImg';
       
 21593             labelOriginPointer.title = 'Pointer un lieu sur la carte';
       
 21594             labelOriginPointer.addEventListener('click', function (evt) {
       
 21595                 evt.preventDefault();
       
 21596                 evt.stopPropagation();
       
 21597                 var i = this.id.charAt(this.id.length - 1);
       
 21598                 var j;
       
 21599                 for (j = 1; j < 8; j++) {
       
 21600                     if (i != j) {
       
 21601                         document.getElementById('GProuteOriginPointer' + j).checked = false;
       
 21602                         if (document.getElementById('GProuteOriginCoords' + j).value == 'Pointer un lieu sur la carte') {
       
 21603                             document.getElementById('GProuteOriginCoords' + j).value = '';
       
 21604                             document.getElementById('GProuteOrigin' + j).className = 'GProuteOriginVisible';
       
 21605                             document.getElementById('GProuteOriginCoords' + j).className = 'GProuteOriginHidden';
       
 21606                         }
       
 21607                     }
       
 21608                 }
       
 21609                 if (document.getElementById('GProuteOriginPointer' + i).checked) {
       
 21610                     document.getElementById('GProuteOriginCoords' + i).value = '';
       
 21611                     for (j = 1; j < 8; j++) {
       
 21612                         document.getElementById('GProutePoint' + j).style.display = 'flex';
       
 21613                     }
       
 21614                     document.getElementById('GProuteForm').className = '';
       
 21615                     document.getElementById('GProuteOriginPointer' + i).checked = false;
       
 21616                     document.getElementById('GProuteOrigin' + i).className = 'GProuteOriginVisible';
       
 21617                     document.getElementById('GProuteOriginCoords' + i).className = 'GProuteOriginHidden';
       
 21618                 } else {
       
 21619                     document.getElementById('GProuteOriginCoords' + i).value = 'Pointer un lieu sur la carte';
       
 21620                     for (j = 1; j < 8; j++) {
       
 21621                         if (i == j) {
       
 21622                             document.getElementById('GProutePoint' + j).style.display = 'flex';
       
 21623                         } else {
       
 21624                             document.getElementById('GProutePoint' + j).style.display = 'none';
       
 21625                         }
       
 21626                     }
       
 21627                     document.getElementById('GProuteForm').className = 'GProuteFormMini';
       
 21628                     document.getElementById('GProuteOriginPointer' + i).checked = true;
       
 21629                     document.getElementById('GProuteOrigin' + i).className = 'GProuteOriginHidden';
       
 21630                     document.getElementById('GProuteOriginCoords' + i).className = 'GProuteOriginVisible';
       
 21631                 }
       
 21632                 context.onRouteMapPointClick(evt);
       
 21633             });
       
 21634             div.appendChild(labelOriginPointer);
       
 21635             return div;
       
 21636         },
       
 21637         _createRoutePanelFormRemoveStageElement: function (n) {
       
 21638             var context = this;
       
 21639             var divRm = document.createElement('div');
       
 21640             divRm.id = 'GProuteStageRemove' + n;
       
 21641             divRm.className = 'GProuteStageRemove';
       
 21642             divRm.title = 'Supprimer l\'étape';
       
 21643             if (n != 1 && n != 7) {
       
 21644                 divRm.addEventListener('click', function (e) {
       
 21645                     var i = this.id.charAt(this.id.length - 1);
       
 21646                     document.getElementById('GProutePoint' + i).className = 'GPflexInput GProuteStageFlexInputHidden';
       
 21647                     document.getElementById('GProuteOrigin' + i).value = '';
       
 21648                     document.getElementById('GProuteOrigin' + i).className = 'GProuteOriginVisible';
       
 21649                     document.getElementById('GProuteOriginCoords' + i).value = '';
       
 21650                     document.getElementById('GProuteOriginCoords' + i).className = 'GProuteOriginHidden';
       
 21651                     document.getElementById('GProuteStageAdd').style.display = '';
       
 21652                     var exclusionsPictoTop = document.getElementById('GPshowRouteExclusionsPicto').style.top;
       
 21653                     document.getElementById('GPshowRouteExclusionsPicto').style.top = (parseInt(exclusionsPictoTop, 10) - 33).toString() + 'px';
       
 21654                     context.onRouteRemovePointClick(e);
       
 21655                 });
       
 21656             }
       
 21657             return divRm;
       
 21658         },
       
 21659         _createRoutePanelFormAddStageElement: function () {
       
 21660             var context = this;
       
 21661             var divAdd = document.createElement('div');
       
 21662             divAdd.id = 'GProuteStageAdd';
       
 21663             divAdd.title = 'Ajouter une étape';
       
 21664             divAdd.addEventListener('click', function (e) {
       
 21665                 var lastStage = 1;
       
 21666                 var nbStages = 0;
       
 21667                 for (var i = 2; i < 7; i++) {
       
 21668                     if (document.getElementById('GProutePoint' + i).className == 'GPflexInput GProuteStageFlexInputHidden') {
       
 21669                         if (lastStage == 1) {
       
 21670                             lastStage = i;
       
 21671                         }
       
 21672                     } else {
       
 21673                         nbStages++;
       
 21674                     }
       
 21675                 }
       
 21676                 if (lastStage < 7) {
       
 21677                     document.getElementById('GProutePoint' + lastStage).className = 'GPflexInput GProuteStageFlexInput';
       
 21678                     var exclusionsPictoTop = document.getElementById('GPshowRouteExclusionsPicto').style.top;
       
 21679                     document.getElementById('GPshowRouteExclusionsPicto').style.top = (parseInt(exclusionsPictoTop, 10) + 33).toString() + 'px';
       
 21680                 }
       
 21681                 if (nbStages == 4) {
       
 21682                     document.getElementById('GProuteStageAdd').style.display = 'none';
       
 21683                 }
       
 21684                 context.onRouteAddPointClick(e);
       
 21685             });
       
 21686             return divAdd;
       
 21687         },
       
 21688         _createRoutePanelFormAutoCompleteListElement: function (n) {
       
 21689             var context = this;
       
 21690             var div = document.createElement('div');
       
 21691             div.id = 'GProuteAutoCompleteList' + n;
       
 21692             div.className = 'GPadvancedAutoCompleteList';
       
 21693             if (div.addEventListener) {
       
 21694                 div.addEventListener('click', function (e) {
       
 21695                     context.onAutoCompletedResultsItemClick(e);
       
 21696                     document.getElementById('GProuteAutoCompleteList' + n).style.display = 'none';
       
 21697                 }, false);
       
 21698             } else if (div.attachEvent) {
       
 21699                 div.attachEvent('onclick', function (e) {
       
 21700                     context.onAutoCompletedResultsItemClick(e);
       
 21701                     document.getElementById('GProuteAutoCompleteList' + n).style.display = 'none';
       
 21702                 });
       
 21703             }
       
 21704             return div;
       
 21705         },
       
 21706         _createRouteAutoCompletedLocationElement: function (location, n, id) {
       
 21707             var container = document.getElementById('GProuteAutoCompleteList' + n);
       
 21708             var div = document.createElement('div');
       
 21709             div.id = 'AutoCompletedLocation' + id;
       
 21710             div.className = 'GPautoCompleteProposal';
       
 21711             div.innerHTML = location.fullText;
       
 21712             container.appendChild(div);
       
 21713         },
       
 21714         _createRoutePanelFormModeChoiceElement: function () {
       
 21715             var div = document.createElement('div');
       
 21716             div.id = this._addUID('GProuteModeChoice');
       
 21717             return div;
       
 21718         },
       
 21719         _createRoutePanelFormModeChoiceTransportElement: function (transports) {
       
 21720             var context = this;
       
 21721             var div = document.createElement('div');
       
 21722             div.id = this._addUID('GProuteTransportChoice');
       
 21723             var span = document.createElement('span');
       
 21724             span.className = 'GProuteModeLabel';
       
 21725             span.innerHTML = 'Mode de transport';
       
 21726             div.appendChild(span);
       
 21727             for (var i = 0; i < transports.length; i++) {
       
 21728                 var transport = transports[i];
       
 21729                 if (transport === 'Voiture') {
       
 21730                     var inputCar = document.createElement('input');
       
 21731                     inputCar.id = this._addUID('GProuteTransportCar');
       
 21732                     inputCar.type = 'radio';
       
 21733                     inputCar.name = 'GProuteTransport';
       
 21734                     inputCar.value = 'Voiture';
       
 21735                     if (i === 0) {
       
 21736                         inputCar.checked = true;
       
 21737                     }
       
 21738                     if (inputCar.addEventListener) {
       
 21739                         inputCar.addEventListener('change', function (e) {
       
 21740                             context.onRouteModeTransportChange(e);
       
 21741                         });
       
 21742                     } else if (inputCar.attachEvent) {
       
 21743                         inputCar.attachEvent('onchange', function (e) {
       
 21744                             context.onRouteModeTransportChange(e);
       
 21745                         });
       
 21746                     }
       
 21747                     div.appendChild(inputCar);
       
 21748                     var labelCar = document.createElement('label');
       
 21749                     labelCar.className = 'GProuteTransportImg';
       
 21750                     labelCar.htmlFor = this._addUID('GProuteTransportCar');
       
 21751                     labelCar.title = 'Voiture';
       
 21752                     div.appendChild(labelCar);
       
 21753                 }
       
 21754                 if (transport === 'Pieton') {
       
 21755                     var inputPedestrian = document.createElement('input');
       
 21756                     inputPedestrian.id = this._addUID('GProuteTransportPedestrian');
       
 21757                     inputPedestrian.type = 'radio';
       
 21758                     inputPedestrian.name = 'GProuteTransport';
       
 21759                     inputPedestrian.value = 'Pieton';
       
 21760                     if (i === 0) {
       
 21761                         inputPedestrian.checked = true;
       
 21762                     }
       
 21763                     if (inputPedestrian.addEventListener) {
       
 21764                         inputPedestrian.addEventListener('change', function (e) {
       
 21765                             context.onRouteModeTransportChange(e);
       
 21766                         });
       
 21767                     } else if (inputPedestrian.attachEvent) {
       
 21768                         inputPedestrian.attachEvent('onchange', function (e) {
       
 21769                             context.onRouteModeTransportChange(e);
       
 21770                         });
       
 21771                     }
       
 21772                     div.appendChild(inputPedestrian);
       
 21773                     var labelPedestrian = document.createElement('label');
       
 21774                     labelPedestrian.className = 'GProuteTransportImg';
       
 21775                     labelPedestrian.htmlFor = this._addUID('GProuteTransportPedestrian');
       
 21776                     labelPedestrian.title = 'Piéton';
       
 21777                     div.appendChild(labelPedestrian);
       
 21778                 }
       
 21779             }
       
 21780             return div;
       
 21781         },
       
 21782         _createRoutePanelFormModeChoiceComputeElement: function () {
       
 21783             var context = this;
       
 21784             var div = document.createElement('div');
       
 21785             div.id = this._addUID('GProuteComputationChoice');
       
 21786             var span = document.createElement('span');
       
 21787             span.className = 'GProuteModeLabel';
       
 21788             span.innerHTML = 'Mode de calcul';
       
 21789             div.appendChild(span);
       
 21790             var select = document.createElement('select');
       
 21791             select.id = this._addUID('GProuteComputationSelect');
       
 21792             select.className = 'GPinputSelect';
       
 21793             select.addEventListener('change', function (e) {
       
 21794                 context.onRouteModeComputationChange(e);
       
 21795             });
       
 21796             var computes = [
       
 21797                 {
       
 21798                     code: 'fastest',
       
 21799                     label: 'Plus rapide'
       
 21800                 },
       
 21801                 {
       
 21802                     code: 'shortest',
       
 21803                     label: 'Plus court'
       
 21804                 }
       
 21805             ];
       
 21806             for (var i = 0; i < computes.length; i++) {
       
 21807                 var option = document.createElement('option');
       
 21808                 option.value = computes[i].code;
       
 21809                 option.text = computes[i].label;
       
 21810                 select.appendChild(option);
       
 21811             }
       
 21812             div.appendChild(select);
       
 21813             return div;
       
 21814         },
       
 21815         _createShowRouteExclusionsElement: function () {
       
 21816             var input = document.createElement('input');
       
 21817             input.id = this._addUID('GPshowRouteExclusions');
       
 21818             input.type = 'checkbox';
       
 21819             return input;
       
 21820         },
       
 21821         _createShowRouteExclusionsPictoElement: function () {
       
 21822             var context = this;
       
 21823             var label = document.createElement('label');
       
 21824             label.id = this._addUID('GPshowRouteExclusionsPicto');
       
 21825             label.className = 'GPshowMoreOptions GPshowRouteExclusionsPicto';
       
 21826             label.htmlFor = this._addUID('GPshowRouteExclusions');
       
 21827             label.title = 'Exclusions';
       
 21828             label.style.top = '185px';
       
 21829             if (label.addEventListener) {
       
 21830                 label.addEventListener('click', function (e) {
       
 21831                     context.onShowRouteExclusionsClick(e);
       
 21832                 });
       
 21833             } else if (label.attachEvent) {
       
 21834                 label.attachEvent('onclick', function (e) {
       
 21835                     context.onShowRouteExclusionsClick(e);
       
 21836                 });
       
 21837             }
       
 21838             return label;
       
 21839         },
       
 21840         _createRoutePanelFormExclusionsElement: function () {
       
 21841             var div = document.createElement('div');
       
 21842             div.id = this._addUID('GProuteExclusions');
       
 21843             var span = document.createElement('span');
       
 21844             span.className = 'GProuteExclusionsLabel';
       
 21845             span.innerHTML = 'Passages autorisés';
       
 21846             div.appendChild(span);
       
 21847             return div;
       
 21848         },
       
 21849         _createRoutePanelFormExclusionOptionsElement: function (exclusions) {
       
 21850             var context = this;
       
 21851             var div = document.createElement('div');
       
 21852             div.className = 'GProuteExclusionsOptions';
       
 21853             for (var value in exclusions) {
       
 21854                 if (exclusions.hasOwnProperty(value)) {
       
 21855                     var status = exclusions[value];
       
 21856                     switch (value) {
       
 21857                     case 'toll':
       
 21858                         var inputToll = document.createElement('input');
       
 21859                         inputToll.id = this._addUID('GProuteExclusionsToll');
       
 21860                         inputToll.type = 'checkbox';
       
 21861                         inputToll.value = 'Toll';
       
 21862                         inputToll.checked = !status;
       
 21863                         if (inputToll.addEventListener) {
       
 21864                             inputToll.addEventListener('change', function (e) {
       
 21865                                 context.onRouteExclusionsChange(e);
       
 21866                             });
       
 21867                         } else if (inputToll.attachEvent) {
       
 21868                             inputToll.attachEvent('onchange', function (e) {
       
 21869                                 context.onRouteExclusionsChange(e);
       
 21870                             });
       
 21871                         }
       
 21872                         div.appendChild(inputToll);
       
 21873                         var labelToll = document.createElement('label');
       
 21874                         labelToll.className = 'GProuteExclusionsOption';
       
 21875                         labelToll.htmlFor = this._addUID('GProuteExclusionsToll');
       
 21876                         labelToll.innerHTML = 'Péages';
       
 21877                         div.appendChild(labelToll);
       
 21878                         break;
       
 21879                     case 'tunnel':
       
 21880                         var inputTunnel = document.createElement('input');
       
 21881                         inputTunnel.id = this._addUID('GProuteExclusionsTunnel');
       
 21882                         inputTunnel.type = 'checkbox';
       
 21883                         inputTunnel.value = 'Tunnel';
       
 21884                         inputTunnel.checked = !status;
       
 21885                         if (inputTunnel.addEventListener) {
       
 21886                             inputTunnel.addEventListener('change', function (e) {
       
 21887                                 context.onRouteExclusionsChange(e);
       
 21888                             });
       
 21889                         } else if (inputTunnel.attachEvent) {
       
 21890                             inputTunnel.attachEvent('onchange', function (e) {
       
 21891                                 context.onRouteExclusionsChange(e);
       
 21892                             });
       
 21893                         }
       
 21894                         div.appendChild(inputTunnel);
       
 21895                         var labelTunnel = document.createElement('label');
       
 21896                         labelTunnel.className = 'GProuteExclusionsOption';
       
 21897                         labelTunnel.htmlFor = this._addUID('GProuteExclusionsTunnel');
       
 21898                         labelTunnel.innerHTML = 'Tunnels';
       
 21899                         div.appendChild(labelTunnel);
       
 21900                         break;
       
 21901                     case 'bridge':
       
 21902                         var inputBridge = document.createElement('input');
       
 21903                         inputBridge.id = this._addUID('GProuteExclusionsBridge');
       
 21904                         inputBridge.type = 'checkbox';
       
 21905                         inputBridge.value = 'Bridge';
       
 21906                         inputBridge.checked = !status;
       
 21907                         if (inputBridge.addEventListener) {
       
 21908                             inputBridge.addEventListener('change', function (e) {
       
 21909                                 context.onRouteExclusionsChange(e);
       
 21910                             });
       
 21911                         } else if (inputBridge.attachEvent) {
       
 21912                             inputBridge.attachEvent('onchange', function (e) {
       
 21913                                 context.onRouteExclusionsChange(e);
       
 21914                             });
       
 21915                         }
       
 21916                         div.appendChild(inputBridge);
       
 21917                         var labelBridge = document.createElement('label');
       
 21918                         labelBridge.className = 'GProuteExclusionsOption';
       
 21919                         labelBridge.htmlFor = this._addUID('GProuteExclusionsBridge');
       
 21920                         labelBridge.innerHTML = 'Ponts';
       
 21921                         div.appendChild(labelBridge);
       
 21922                         break;
       
 21923                     }
       
 21924                 }
       
 21925             }
       
 21926             return div;
       
 21927         },
       
 21928         _createRouteSubmitFormElement: function () {
       
 21929             var input = document.createElement('input');
       
 21930             input.id = this._addUID('GProuteSubmit');
       
 21931             input.className = 'GPinputSubmit';
       
 21932             input.type = 'submit';
       
 21933             input.value = 'Calculer';
       
 21934             return input;
       
 21935         },
       
 21936         _createRouteFormResetElement: function () {
       
 21937             var self = this;
       
 21938             var divReset = document.createElement('div');
       
 21939             divReset.id = this._addUID('GProuteReset');
       
 21940             divReset.title = 'Réinitialiser les paramètres';
       
 21941             divReset.addEventListener('click', function (e) {
       
 21942                 self.onRouteResetClick(e);
       
 21943             });
       
 21944             return divReset;
       
 21945         }
       
 21946     };
       
 21947     return RouteDOM;
       
 21948 }(CommonUtilsSelectorID);
       
 21949 LeafletControlsRoute = function (L, woodman, Gp, RightManagement, ID, LocationSelector, RouteDOM) {
       
 21950     var Route = L.Control.extend({
       
 21951         includes: RouteDOM,
       
 21952         options: {
       
 21953             position: 'topleft',
       
 21954             collapsed: true,
       
 21955             graphs: [
       
 21956                 'Voiture',
       
 21957                 'Pieton'
       
 21958             ],
       
 21959             exclusions: {
       
 21960                 toll: false,
       
 21961                 tunnel: false,
       
 21962                 bridge: false
       
 21963             },
       
 21964             disableReverse: false,
       
 21965             routeOptions: {},
       
 21966             autocompleteOptions: {}
       
 21967         },
       
 21968         initialize: function (options) {
       
 21969             L.Util.setOptions(this, options);
       
 21970             this._uid = ID.generate();
       
 21971             this._initTransport();
       
 21972             this._initExclusions();
       
 21973             this._initComputation();
       
 21974             this._waitingContainer = null;
       
 21975             this._formRouteContainer = null;
       
 21976             this._resultsRouteContainer = null;
       
 21977             this._isDesktop = this._detectSupport();
       
 21978             this._currentPoints = [];
       
 21979             this._currentTransport = null;
       
 21980             this._currentComputation = null;
       
 21981             this._currentExclusions = [];
       
 21982             this._geojsonRoute = null;
       
 21983             this._geojsonSections = null;
       
 21984             this._waiting = false;
       
 21985             this._timer = null;
       
 21986             this._currentRouteInformations = null;
       
 21987             this._resources = {};
       
 21988             this._noRightManagement = false;
       
 21989             this._checkRightsManagement();
       
 21990         },
       
 21991         onAdd: function (map) {
       
 21992             var container = this._container = this._initLayout(map);
       
 21993             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 21994             return container;
       
 21995         },
       
 21996         onRemove: function () {
       
 21997         },
       
 21998         _initTransport: function () {
       
 21999             this._currentTransport = 'Voiture';
       
 22000             var transport = this.options.graphs;
       
 22001             if (!transport || transport.length === 0) {
       
 22002                 this.options.graphs = [
       
 22003                     'Voiture',
       
 22004                     'Pieton'
       
 22005                 ];
       
 22006             }
       
 22007             if (L.Util.isArray(transport) && transport.length) {
       
 22008                 if (transport[0] === 'Voiture' || transport[0] === 'Pieton') {
       
 22009                     this._currentTransport = transport[0];
       
 22010                 }
       
 22011             }
       
 22012             var serviceOptions = this.options.routeOptions;
       
 22013             if (serviceOptions.graph) {
       
 22014                 this._currentTransport = serviceOptions.graph;
       
 22015             }
       
 22016         },
       
 22017         _initComputation: function () {
       
 22018             this._currentComputation = 'fastest';
       
 22019             var serviceOptions = this.options.routeOptions;
       
 22020             if (serviceOptions.routePreference) {
       
 22021                 this._currentComputation = serviceOptions.routePreference;
       
 22022             }
       
 22023         },
       
 22024         _initExclusions: function () {
       
 22025             this._currentExclusions = [];
       
 22026             var exclusion = this.options.exclusions;
       
 22027             if (!exclusion || Object.keys(exclusion).length === 0) {
       
 22028                 this.options.exclusions = {
       
 22029                     toll: false,
       
 22030                     tunnel: false,
       
 22031                     bridge: false
       
 22032                 };
       
 22033             }
       
 22034             if (exclusion && Object.keys(exclusion).length) {
       
 22035                 for (var k in exclusion) {
       
 22036                     if (exclusion.hasOwnProperty(k)) {
       
 22037                         if (exclusion.k) {
       
 22038                             this._currentExclusions.push(k);
       
 22039                         }
       
 22040                     }
       
 22041                 }
       
 22042             }
       
 22043             var serviceOptions = this.options.routeOptions;
       
 22044             if (L.Util.isArray(serviceOptions.exclusions)) {
       
 22045                 this._currentExclusions = serviceOptions.exclusions;
       
 22046             }
       
 22047         },
       
 22048         _checkRightsManagement: function () {
       
 22049             var _opts = null;
       
 22050             var _res = [];
       
 22051             var _key = null;
       
 22052             _key = this.options.routeOptions.apiKey;
       
 22053             _opts = this.options.routeOptions.filterOptions;
       
 22054             _res = _opts ? _opts.type : [];
       
 22055             if (!_res || _res.length === 0) {
       
 22056                 _res = [
       
 22057                     'Voiture',
       
 22058                     'Pieton'
       
 22059                 ];
       
 22060             }
       
 22061             var rightManagementRoute = RightManagement.check({
       
 22062                 key: _key || this.options.apiKey,
       
 22063                 resources: _res,
       
 22064                 services: ['Itineraire']
       
 22065             });
       
 22066             _key = this.options.autocompleteOptions.apiKey;
       
 22067             _opts = this.options.autocompleteOptions.filterOptions;
       
 22068             _res = _opts ? _opts.type : [];
       
 22069             if (!_res || _res.length === 0) {
       
 22070                 _res = [
       
 22071                     'StreetAddress',
       
 22072                     'PositionOfInterest'
       
 22073                 ];
       
 22074             }
       
 22075             var rightManagementAutoComplete = RightManagement.check({
       
 22076                 key: _key || this.options.apiKey,
       
 22077                 resources: _res,
       
 22078                 services: ['AutoCompletion']
       
 22079             });
       
 22080             if (!rightManagementRoute && !rightManagementAutoComplete) {
       
 22081                 this._noRightManagement = true;
       
 22082             }
       
 22083             if (rightManagementAutoComplete) {
       
 22084                 this._resources['AutoCompletion'] = {};
       
 22085                 this._resources['AutoCompletion']['resources'] = rightManagementAutoComplete['AutoCompletion'];
       
 22086                 this._resources['AutoCompletion']['key'] = rightManagementAutoComplete['key'];
       
 22087             }
       
 22088             if (rightManagementRoute) {
       
 22089                 this._resources['Itineraire'] = {};
       
 22090                 this._resources['Itineraire']['resources'] = rightManagementRoute['Itineraire'];
       
 22091                 this._resources['Itineraire']['key'] = rightManagementRoute['key'];
       
 22092             }
       
 22093         },
       
 22094         _detectSupport: function () {
       
 22095             var isDesktop = true;
       
 22096             var userAgent = window.navigator.userAgent.toLowerCase();
       
 22097             if (userAgent.indexOf('iphone') !== -1 || userAgent.indexOf('ipod') !== -1 || userAgent.indexOf('ipad') !== -1 || userAgent.indexOf('android') !== -1 || userAgent.indexOf('mobile') !== -1 || userAgent.indexOf('blackberry') !== -1 || userAgent.indexOf('tablet') !== -1 || userAgent.indexOf('phone') !== -1 || userAgent.indexOf('touch') !== -1) {
       
 22098                 isDesktop = false;
       
 22099             }
       
 22100             if (userAgent.indexOf('msie') !== -1 || userAgent.indexOf('trident') !== -1) {
       
 22101                 isDesktop = true;
       
 22102             }
       
 22103             return isDesktop;
       
 22104         },
       
 22105         _initLayout: function (map) {
       
 22106             var container = this._createMainContainerElement();
       
 22107             var inputShow = this._showRouteContainer = this._createShowRouteElement();
       
 22108             container.appendChild(inputShow);
       
 22109             if (!this.options.collapsed) {
       
 22110                 inputShow.checked = true;
       
 22111             }
       
 22112             var picto = this._createShowRoutePictoElement();
       
 22113             container.appendChild(picto);
       
 22114             var routePanel = this._createRoutePanelElement();
       
 22115             var routeHeader = this._createRoutePanelHeaderElement();
       
 22116             routePanel.appendChild(routeHeader);
       
 22117             var routeForm = this._formRouteContainer = this._createRoutePanelFormElement();
       
 22118             var points = this._createRoutePanelFormPointsElement(map);
       
 22119             for (var i = 0; i < points.length; i++) {
       
 22120                 routeForm.appendChild(points[i]);
       
 22121             }
       
 22122             var choice = this._createRoutePanelFormModeChoiceElement();
       
 22123             choice.appendChild(this._createRoutePanelFormModeChoiceTransportElement(this.options.graphs));
       
 22124             choice.appendChild(this._createRoutePanelFormModeChoiceComputeElement());
       
 22125             routeForm.appendChild(choice);
       
 22126             routeForm.appendChild(this._createShowRouteExclusionsElement());
       
 22127             routeForm.appendChild(this._createShowRouteExclusionsPictoElement());
       
 22128             var exclusion = this._createRoutePanelFormExclusionsElement();
       
 22129             exclusion.appendChild(this._createRoutePanelFormExclusionOptionsElement(this.options.exclusions));
       
 22130             routeForm.appendChild(exclusion);
       
 22131             var submit = this._createRouteSubmitFormElement();
       
 22132             routeForm.appendChild(submit);
       
 22133             routePanel.appendChild(routeForm);
       
 22134             var routeResults = this._resultsRouteContainer = this._createRoutePanelResultsElement();
       
 22135             routePanel.appendChild(routeResults);
       
 22136             var waiting = this._waitingContainer = this._createRouteWaitingElement();
       
 22137             routePanel.appendChild(waiting);
       
 22138             container.appendChild(routePanel);
       
 22139             return container;
       
 22140         },
       
 22141         _createRoutePanelFormPointsElement: function (map) {
       
 22142             var points = [];
       
 22143             var count = 1;
       
 22144             var start = new LocationSelector({
       
 22145                 apiKey: this.options.apiKey || null,
       
 22146                 tag: {
       
 22147                     id: count,
       
 22148                     unique: this._uid,
       
 22149                     label: 'Départ',
       
 22150                     color: 'blue',
       
 22151                     display: true
       
 22152                 },
       
 22153                 disableReverse: this.options.disableReverse,
       
 22154                 autocompleteOptions: this.options.autocompleteOptions || null
       
 22155             });
       
 22156             start.setMap(map);
       
 22157             points.push(start.getContainer());
       
 22158             this._currentPoints.push(start);
       
 22159             for (count = 2; count < 7; count++) {
       
 22160                 var step = new LocationSelector({
       
 22161                     apiKey: this.options.apiKey || null,
       
 22162                     tag: {
       
 22163                         id: count,
       
 22164                         unique: this._uid,
       
 22165                         label: 'Etape',
       
 22166                         color: 'green',
       
 22167                         display: false,
       
 22168                         removeOption: true
       
 22169                     },
       
 22170                     disableReverse: this.options.disableReverse,
       
 22171                     autocompleteOptions: this.options.autocompleteOptions || null
       
 22172                 });
       
 22173                 step.setMap(map);
       
 22174                 points.push(step.getContainer());
       
 22175                 this._currentPoints.push(step);
       
 22176             }
       
 22177             var end = new LocationSelector({
       
 22178                 apiKey: this.options.apiKey || null,
       
 22179                 tag: {
       
 22180                     id: count,
       
 22181                     unique: this._uid,
       
 22182                     label: 'Arrivée',
       
 22183                     color: 'red',
       
 22184                     display: true,
       
 22185                     addOption: true,
       
 22186                     removeOption: false
       
 22187                 },
       
 22188                 disableReverse: this.options.disableReverse,
       
 22189                 autocompleteOptions: this.options.autocompleteOptions || null
       
 22190             });
       
 22191             end.setMap(map);
       
 22192             points.push(end.getContainer());
       
 22193             this._currentPoints.push(end);
       
 22194             return points;
       
 22195         },
       
 22196         onShowRoutePanelClick: function (e) {
       
 22197             if (!this._geojsonSections) {
       
 22198                 this._clear();
       
 22199             }
       
 22200         },
       
 22201         onRouteModeComputationChange: function (e) {
       
 22202             var idx = e.target.selectedIndex;
       
 22203             var value = e.target.options[idx].value;
       
 22204             if (!value) {
       
 22205                 return;
       
 22206             }
       
 22207             this._currentComputation = value;
       
 22208         },
       
 22209         onRouteModeComputationChangeAndRun: function (e) {
       
 22210             this.onRouteModeComputationChange(e);
       
 22211             this._clearRouteResultsDetails();
       
 22212             this._clearRouteResultsGeometry();
       
 22213             this._clearRouteResultsFeatureGeometry();
       
 22214             this.onRouteComputationSubmit({
       
 22215                 computation: this._currentComputation,
       
 22216                 transport: this._currentTransport,
       
 22217                 exclusions: this._currentExclusions
       
 22218             });
       
 22219         },
       
 22220         onRouteModeTransportChange: function (e) {
       
 22221             var value = e.target.value;
       
 22222             if (!value) {
       
 22223                 return;
       
 22224             }
       
 22225             this._currentTransport = value;
       
 22226         },
       
 22227         onShowRouteExclusionsClick: function (e) {
       
 22228         },
       
 22229         onRouteExclusionsChange: function (e) {
       
 22230             var value = e.target.value;
       
 22231             var checked = e.target.checked;
       
 22232             if (!value) {
       
 22233                 return;
       
 22234             }
       
 22235             var bFound = false;
       
 22236             var iFound = null;
       
 22237             for (var i = 0; i < this._currentExclusions.length; i++) {
       
 22238                 if (this._currentExclusions[i] === value) {
       
 22239                     iFound = i;
       
 22240                     bFound = true;
       
 22241                 }
       
 22242             }
       
 22243             if (!bFound && checked) {
       
 22244                 this._currentExclusions.push(value);
       
 22245             }
       
 22246             if (bFound && !checked) {
       
 22247                 this._currentExclusions[iFound] = null;
       
 22248             }
       
 22249         },
       
 22250         onRouteComputationSubmit: function (options) {
       
 22251             var points = this._currentPoints;
       
 22252             var start = points[0].getCoordinate();
       
 22253             points[0].dragging(false);
       
 22254             var end = points[points.length - 1].getCoordinate();
       
 22255             points[points.length - 1].dragging(false);
       
 22256             var step = [];
       
 22257             for (var i = 1; i < points.length - 1; i++) {
       
 22258                 var coordinate = points[i].getCoordinate();
       
 22259                 points[i].dragging(false);
       
 22260                 if (coordinate) {
       
 22261                     step.push(coordinate);
       
 22262                 }
       
 22263             }
       
 22264             if (this._noRightManagement) {
       
 22265                 return;
       
 22266             }
       
 22267             this._currentTransport = options.transport;
       
 22268             this._currentComputation = options.computation;
       
 22269             this._currentExclusions = options.exclusions;
       
 22270             this._displayWaitingContainer();
       
 22271             var context = this;
       
 22272             this._requestRouting({
       
 22273                 startPoint: start,
       
 22274                 endPoint: end,
       
 22275                 viaPoints: step,
       
 22276                 graph: this._currentTransport,
       
 22277                 routePreference: this._currentComputation,
       
 22278                 exclusions: this._currentExclusions,
       
 22279                 geometryInInstructions: true,
       
 22280                 distanceUnit: 'm',
       
 22281                 onSuccess: function (results) {
       
 22282                     if (results) {
       
 22283                         context._fillRouteResultsDetails(results);
       
 22284                     }
       
 22285                 },
       
 22286                 onFailure: function (error) {
       
 22287                     context._hideWaitingContainer();
       
 22288                     context._clearRouteResultsDetails();
       
 22289                 }
       
 22290             });
       
 22291         },
       
 22292         onShowRouteResultsNewClick: function (e) {
       
 22293             var points = this._currentPoints;
       
 22294             for (var i = 0; i < points.length; i++) {
       
 22295                 points[i].dragging(true);
       
 22296             }
       
 22297             this._clearRouteResultsDetails();
       
 22298             this._clearRouteResultsGeometry();
       
 22299             this._clearRouteResultsFeatureGeometry();
       
 22300         },
       
 22301         onRouteResultsDetailsMouseOver: function (e) {
       
 22302             var idx = ID.index(e.target.id);
       
 22303             if (!this._isDesktop) {
       
 22304                 return;
       
 22305             }
       
 22306             if (!this._geojsonSections) {
       
 22307                 return;
       
 22308             }
       
 22309             this._geojsonSections.eachLayer(function (layer) {
       
 22310                 if (layer.feature.id === parseInt(idx, 10)) {
       
 22311                     layer.setStyle({
       
 22312                         weight: 10,
       
 22313                         color: '#0F9DE8',
       
 22314                         opacity: 0.5
       
 22315                     });
       
 22316                 }
       
 22317             });
       
 22318         },
       
 22319         onRouteResultsDetailsMouseOut: function (e) {
       
 22320             var idx = ID.index(e.target.id);
       
 22321             if (!this._isDesktop) {
       
 22322                 return;
       
 22323             }
       
 22324             if (!this._geojsonSections) {
       
 22325                 return;
       
 22326             }
       
 22327             this._geojsonSections.eachLayer(function (layer) {
       
 22328                 if (layer.feature.id === parseInt(idx, 10)) {
       
 22329                     layer.setStyle({
       
 22330                         color: '#ED7F10',
       
 22331                         weight: 5,
       
 22332                         opacity: 0.75
       
 22333                     });
       
 22334                 }
       
 22335             });
       
 22336         },
       
 22337         onRouteResultsDetailsClick: function (e) {
       
 22338             var idx = ID.index(e.target.id);
       
 22339             var self = this;
       
 22340             if (this._isDesktop) {
       
 22341                 return;
       
 22342             }
       
 22343             if (!this._geojsonSections) {
       
 22344                 return;
       
 22345             }
       
 22346             var newInstruction = e.target.title;
       
 22347             var oldInstruction = e.target.innerHTML;
       
 22348             this._geojsonSections.eachLayer(function (layer) {
       
 22349                 if (layer.feature.id === parseInt(idx, 10)) {
       
 22350                     e.target.innerHTML = newInstruction;
       
 22351                     layer.setStyle({
       
 22352                         weight: 10,
       
 22353                         color: '#0F9DE8',
       
 22354                         opacity: 0.5
       
 22355                     });
       
 22356                 }
       
 22357             });
       
 22358             clearTimeout(1000);
       
 22359             setTimeout(function () {
       
 22360                 self._geojsonSections.eachLayer(function (layer) {
       
 22361                     if (layer.feature.id === parseInt(idx, 10)) {
       
 22362                         e.target.innerHTML = oldInstruction;
       
 22363                         layer.setStyle({
       
 22364                             color: '#ED7F10',
       
 22365                             weight: 5,
       
 22366                             opacity: 0.75
       
 22367                         });
       
 22368                     }
       
 22369                 });
       
 22370             }, 1000);
       
 22371         },
       
 22372         _requestRouting: function (settings) {
       
 22373             if (!settings || Object.keys(settings).length === 0) {
       
 22374                 return;
       
 22375             }
       
 22376             if (!settings.startPoint) {
       
 22377                 return;
       
 22378             }
       
 22379             if (!settings.endPoint) {
       
 22380                 return;
       
 22381             }
       
 22382             if (this._noRightManagement) {
       
 22383                 console.log('no rights for all service !?');
       
 22384                 return;
       
 22385             }
       
 22386             if (!this._resources['Itineraire']) {
       
 22387                 console.log('no rights for this service !?');
       
 22388                 return;
       
 22389             }
       
 22390             var resources = this._resources['Itineraire'].resources;
       
 22391             if (!resources || Object.keys(resources).length === 0) {
       
 22392                 return;
       
 22393             }
       
 22394             var key = this._resources['Itineraire']['key'];
       
 22395             var options = {};
       
 22396             L.Util.extend(options, this.options.routeOptions);
       
 22397             L.Util.extend(options, settings);
       
 22398             var bFound = false;
       
 22399             for (var i = 0; i < resources.length; i++) {
       
 22400                 if (resources[i] === options.graph) {
       
 22401                     bFound = true;
       
 22402                 }
       
 22403             }
       
 22404             if (!bFound) {
       
 22405                 console.log('no rights for this service !?');
       
 22406                 return;
       
 22407             }
       
 22408             L.Util.extend(options, { apiKey: this.options.routeOptions.apiKey || this.options.apiKey || key });
       
 22409             Gp.Services.route(options);
       
 22410         },
       
 22411         _fillRouteResultsDetails: function (results) {
       
 22412             var distance = results.totalDistance;
       
 22413             var duration = results.totalTime;
       
 22414             var instructions = this._simplifiedInstructions(results.routeInstructions);
       
 22415             if (instructions) {
       
 22416                 this._fillRouteResultsDetailsContainer(distance, duration, instructions);
       
 22417             }
       
 22418             var geometry = results.routeGeometry;
       
 22419             if (geometry) {
       
 22420                 this._fillRouteResultsDetailsGeometry(geometry);
       
 22421             }
       
 22422             var bGeometryInstructions = instructions[0].geometry.length !== 0 ? true : false;
       
 22423             if (instructions && bGeometryInstructions) {
       
 22424                 this._fillRouteResultsDetailsFeatureGeometry(instructions);
       
 22425             }
       
 22426             var bbox = results.bbox;
       
 22427             if (bbox) {
       
 22428                 var map = this._map;
       
 22429                 var bounds = L.latLngBounds([
       
 22430                     bbox.bottom,
       
 22431                     bbox.left
       
 22432                 ], [
       
 22433                     bbox.top,
       
 22434                     bbox.right
       
 22435                 ]);
       
 22436                 map.fitBounds(bounds, {
       
 22437                     padding: [
       
 22438                         1,
       
 22439                         1
       
 22440                     ]
       
 22441                 });
       
 22442             }
       
 22443             this._currentRouteInformations = results;
       
 22444             this._formRouteContainer.className = 'GProuteComponentHidden';
       
 22445             this._hideWaitingContainer();
       
 22446             this._resultsRouteContainer.className = '';
       
 22447         },
       
 22448         _fillRouteResultsDetailsContainer: function (distance, duration, instructions) {
       
 22449             this._resultsRouteValuesContainer = this._addRouteResultsValuesElement(distance, duration, this._convertSecondsToTime);
       
 22450             this._resultsRouteDetailsContainer = this._addRouteResultsDetailsElement(instructions, this._convertSecondsToTime);
       
 22451         },
       
 22452         _fillRouteResultsDetailsGeometry: function (geometry) {
       
 22453             this._clearRouteResultsGeometry();
       
 22454             var map = this._map;
       
 22455             var _style = {
       
 22456                 color: '#ff7800',
       
 22457                 weight: 5,
       
 22458                 opacity: 0.65
       
 22459             };
       
 22460             this._geojsonRoute = L.geoJson(geometry, { style: _style }).addTo(map);
       
 22461         },
       
 22462         _fillRouteResultsDetailsFeatureGeometry: function (instructions) {
       
 22463             this._clearRouteResultsFeatureGeometry();
       
 22464             var map = this._map;
       
 22465             var _style = {
       
 22466                 color: '#ED7F10',
       
 22467                 weight: 5,
       
 22468                 opacity: 0.75
       
 22469             };
       
 22470             var _geometry = {
       
 22471                 type: 'FeatureCollection',
       
 22472                 features: []
       
 22473             };
       
 22474             for (var i = 0; i < instructions.length; i++) {
       
 22475                 var o = instructions[i];
       
 22476                 var id = i + 1;
       
 22477                 _geometry.features.push({
       
 22478                     id: id,
       
 22479                     type: 'Feature',
       
 22480                     geometry: o.geometry,
       
 22481                     properties: { popupContent: '(' + id + ') distance : ' + this._convertDistance(o.distance) + ' / temps : ' + this._convertSecondsToTime(o.duration) }
       
 22482                 });
       
 22483             }
       
 22484             var self = this;
       
 22485             function resetHighlight(e) {
       
 22486                 var layer = e.target;
       
 22487                 self._geojsonSections.resetStyle(layer);
       
 22488                 var div = L.DomUtil.get('GProuteResultsDetailsInstruction_' + layer.feature.id + '-' + self._uid);
       
 22489                 L.DomUtil.removeClass(div, 'GProuteResultsDetailsHighlight');
       
 22490             }
       
 22491             function highlightFeature(e) {
       
 22492                 var layer = e.target;
       
 22493                 layer.setStyle({
       
 22494                     weight: 10,
       
 22495                     color: '#0F9DE8',
       
 22496                     opacity: 0.5
       
 22497                 });
       
 22498                 var div = L.DomUtil.get('GProuteResultsDetailsInstruction_' + layer.feature.id + '-' + self._uid);
       
 22499                 L.DomUtil.addClass(div, 'GProuteResultsDetailsHighlight');
       
 22500             }
       
 22501             this._geojsonSections = L.geoJson(_geometry, {
       
 22502                 style: _style,
       
 22503                 onEachFeature: function (feature, layer) {
       
 22504                     layer.on({
       
 22505                         mouseover: highlightFeature,
       
 22506                         mouseout: resetHighlight
       
 22507                     });
       
 22508                     layer.bindPopup(feature.properties.popupContent);
       
 22509                 }
       
 22510             }).addTo(map);
       
 22511         },
       
 22512         _clear: function () {
       
 22513             this._currentTransport = null;
       
 22514             this._currentExclusions = [];
       
 22515             this._currentComputation = null;
       
 22516             this._clearRouteResultsDetails();
       
 22517             this._clearRouteResultsGeometry();
       
 22518             this._clearRouteResultsFeatureGeometry();
       
 22519             for (var i = 0; i < this._currentPoints.length; i++) {
       
 22520                 this._currentPoints[i].clear();
       
 22521             }
       
 22522         },
       
 22523         _clearRouteResultsDetails: function () {
       
 22524             this._currentRouteInformations = null;
       
 22525             if (this._resultsRouteDetailsContainer) {
       
 22526                 var divD = this._resultsRouteDetailsContainer;
       
 22527                 if (divD.childElementCount) {
       
 22528                     while (divD.firstChild) {
       
 22529                         divD.removeChild(divD.firstChild);
       
 22530                     }
       
 22531                 }
       
 22532             }
       
 22533             if (this._resultsRouteValuesContainer) {
       
 22534                 var divV = this._resultsRouteValuesContainer;
       
 22535                 if (divV.childElementCount) {
       
 22536                     while (divV.firstChild) {
       
 22537                         divV.removeChild(divV.firstChild);
       
 22538                     }
       
 22539                 }
       
 22540             }
       
 22541         },
       
 22542         _clearRouteResultsGeometry: function () {
       
 22543             var map = this._map;
       
 22544             if (this._geojsonRoute != null) {
       
 22545                 map.removeLayer(this._geojsonRoute);
       
 22546                 this._geojsonRoute = null;
       
 22547             }
       
 22548         },
       
 22549         _clearRouteResultsFeatureGeometry: function () {
       
 22550             var map = this._map;
       
 22551             if (this._geojsonSections != null) {
       
 22552                 map.removeLayer(this._geojsonSections);
       
 22553                 this._geojsonSections = null;
       
 22554             }
       
 22555         },
       
 22556         _displayWaitingContainer: function () {
       
 22557             this._waitingContainer.className = 'GProuteCalcWaitingContainerVisible';
       
 22558             this._waiting = true;
       
 22559             if (this._timer) {
       
 22560                 clearTimeout(this._timer);
       
 22561                 this._timer = null;
       
 22562             }
       
 22563             var context = this;
       
 22564             this._timer = setTimeout(function () {
       
 22565                 if (context._waiting === true) {
       
 22566                     context._hideWaitingContainer();
       
 22567                 } else {
       
 22568                     if (context._timer) {
       
 22569                         clearTimeout(context._timer);
       
 22570                     }
       
 22571                 }
       
 22572             }, 16000);
       
 22573         },
       
 22574         _hideWaitingContainer: function () {
       
 22575             if (this._waiting) {
       
 22576                 this._waitingContainer.className = 'GProuteCalcWaitingContainerHidden';
       
 22577                 this._waiting = false;
       
 22578                 clearTimeout(this._timer);
       
 22579                 this._timer = null;
       
 22580             }
       
 22581         },
       
 22582         _simplifiedInstructions: function (instructions) {
       
 22583             var newInstructions = [];
       
 22584             var current = instructions[0];
       
 22585             if (instructions.length === 1) {
       
 22586                 newInstructions.push(current);
       
 22587             }
       
 22588             for (var i = 1; i < instructions.length; i++) {
       
 22589                 var o = instructions[i];
       
 22590                 if (o.instruction === current.instruction) {
       
 22591                     current.distance = (parseFloat(o.distance) + parseFloat(current.distance)).toString();
       
 22592                     current.duration = (parseFloat(o.duration) + parseFloat(current.duration)).toString();
       
 22593                     for (var j = 1; j < o.geometry.coordinates.length; j++) {
       
 22594                         current.geometry.coordinates.push(o.geometry.coordinates[j]);
       
 22595                     }
       
 22596                     if (i === instructions.length - 1) {
       
 22597                         newInstructions.push(current);
       
 22598                         current = null;
       
 22599                     }
       
 22600                 } else {
       
 22601                     newInstructions.push(current);
       
 22602                     current = o;
       
 22603                     if (i === instructions.length - 1) {
       
 22604                         newInstructions.push(o);
       
 22605                         current = null;
       
 22606                     }
       
 22607                 }
       
 22608             }
       
 22609             return newInstructions;
       
 22610         },
       
 22611         _convertSecondsToTime: function (duration) {
       
 22612             var time = '';
       
 22613             duration = Math.round(duration);
       
 22614             var hours = Math.floor(duration / (60 * 60));
       
 22615             if (!hours) {
       
 22616                 hours = '00';
       
 22617             }
       
 22618             var divisor4minutes = duration % (60 * 60);
       
 22619             var minutes = Math.floor(divisor4minutes / 60);
       
 22620             if (!minutes) {
       
 22621                 minutes = '00';
       
 22622             }
       
 22623             var divisor4seconds = divisor4minutes % 60;
       
 22624             var seconds = Math.ceil(divisor4seconds);
       
 22625             if (!seconds) {
       
 22626                 seconds = '00';
       
 22627             }
       
 22628             time = hours + 'h ' + minutes + 'm ' + seconds + 's';
       
 22629             return time;
       
 22630         },
       
 22631         _convertDistance: function (distance) {
       
 22632             var d = '';
       
 22633             var distanceKm = parseInt(distance / 1000, 10);
       
 22634             if (!distanceKm) {
       
 22635                 d = parseInt(distance, 10) + ' m';
       
 22636             } else {
       
 22637                 d = distanceKm + ' km';
       
 22638             }
       
 22639             return d;
       
 22640         }
       
 22641     });
       
 22642     return Route;
       
 22643 }(leaflet, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, LeafletControlsLocationSelector, CommonControlsRouteDOM);
       
 22644 CommonControlsSearchEngineDOM = function (ID) {
       
 22645     var SearchEngineDOM = {
       
 22646         _addUID: function (id) {
       
 22647             return id + '-' + this._uid;
       
 22648         },
       
 22649         _createMainContainerElement: function () {
       
 22650             var container = document.createElement('div');
       
 22651             container.id = this._addUID('GPsearchEngine');
       
 22652             container.className = 'GPwidget';
       
 22653             return container;
       
 22654         },
       
 22655         _createShowSearchEngineElement: function () {
       
 22656             var input = document.createElement('input');
       
 22657             input.id = this._addUID('GPshowSearchEngine');
       
 22658             input.type = 'checkbox';
       
 22659             return input;
       
 22660         },
       
 22661         _createShowSearchEnginePictoElement: function () {
       
 22662             var self = this;
       
 22663             var label = document.createElement('label');
       
 22664             label.id = this._addUID('GPshowSearchEnginePicto');
       
 22665             label.className = 'GPshowAdvancedToolPicto';
       
 22666             label.htmlFor = this._addUID('GPshowSearchEngine');
       
 22667             label.title = 'Afficher/masquer la recherche par lieux';
       
 22668             label.addEventListener('click', function () {
       
 22669                 document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22670                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22671                 var showAdvancedSearch = document.getElementById(self._addUID('GPshowAdvancedSearch'));
       
 22672                 if (showAdvancedSearch) {
       
 22673                     showAdvancedSearch.style.display = null;
       
 22674                     document.getElementById(self._addUID('GPadvancedSearchPanel')).style.display = 'none';
       
 22675                 }
       
 22676                 var id = '#GPsearchInput-' + self._uid;
       
 22677                 document.querySelector(id + ' input').disabled = false;
       
 22678                 self.onShowSearchEngineClick();
       
 22679             });
       
 22680             var spanOpen = document.createElement('span');
       
 22681             spanOpen.id = this._addUID('GPshowSearchEngineOpen');
       
 22682             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 22683             label.appendChild(spanOpen);
       
 22684             return label;
       
 22685         },
       
 22686         _createSearchInputElement: function () {
       
 22687             var self = this;
       
 22688             var form = document.createElement('form');
       
 22689             form.id = this._addUID('GPsearchInput');
       
 22690             form.addEventListener('submit', function (e) {
       
 22691                 e.preventDefault();
       
 22692                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'block';
       
 22693                 document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22694                 self.onGeocodingSearchSubmit(e);
       
 22695                 return false;
       
 22696             });
       
 22697             var input = document.createElement('input');
       
 22698             input.id = this._addUID('GPsearchInputText');
       
 22699             input.type = 'text';
       
 22700             input.placeholder = 'Rechercher un lieu, une adresse';
       
 22701             input.autocomplete = 'off';
       
 22702             input.addEventListener('keyup', function (e) {
       
 22703                 var charCode = e.which || e.keyCode;
       
 22704                 if (charCode === 13 || charCode === 10 || charCode === 38 || charCode === 40) {
       
 22705                     return;
       
 22706                 }
       
 22707                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22708                 if (input.value.length > 2) {
       
 22709                     document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'block';
       
 22710                 } else {
       
 22711                     document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22712                 }
       
 22713                 self.onAutoCompleteSearchText(e);
       
 22714             });
       
 22715             input.addEventListener('keydown', function (e) {
       
 22716                 if (true) {
       
 22717                     return;
       
 22718                 }
       
 22719                 var charCode = e.which || e.keyCode;
       
 22720                 var container = document.getElementById(self._addUID('GPautocompleteResults'));
       
 22721                 if (!container) {
       
 22722                     return;
       
 22723                 }
       
 22724                 var curr = container.getElementsByClassName('GPautoCompleteProposal current');
       
 22725                 var list = container.getElementsByClassName('GPautoCompleteProposal');
       
 22726                 var length = list.length;
       
 22727                 if (!length) {
       
 22728                     return;
       
 22729                 }
       
 22730                 var current = null;
       
 22731                 if (!curr.length) {
       
 22732                     current = list[0];
       
 22733                     current.className = 'GPautoCompleteProposal current';
       
 22734                     current.style.color = '#000000';
       
 22735                     current.style['background-color'] = '#CEDBEF';
       
 22736                     return;
       
 22737                 } else {
       
 22738                     current = curr[0];
       
 22739                 }
       
 22740                 var index = parseInt(ID.index(current.id), 10);
       
 22741                 var next = index === length - 1 ? list[0] : list[index + 1];
       
 22742                 var prev = index === 0 ? list[length - 1] : list[index - 1];
       
 22743                 current.style['background-color'] = '';
       
 22744                 current.style.color = '';
       
 22745                 prev.style['background-color'] = '';
       
 22746                 prev.style.color = '';
       
 22747                 next.style['background-color'] = '';
       
 22748                 next.style.color = '';
       
 22749                 switch (charCode) {
       
 22750                 case 38:
       
 22751                     current.className = 'GPautoCompleteProposal';
       
 22752                     prev.className = 'GPautoCompleteProposal current';
       
 22753                     prev.style.color = '#000000';
       
 22754                     prev.style['background-color'] = '#CEDBEF';
       
 22755                     break;
       
 22756                 case 40:
       
 22757                     current.className = 'GPautoCompleteProposal';
       
 22758                     next.className = 'GPautoCompleteProposal current';
       
 22759                     next.style.color = '#000000';
       
 22760                     next.style['background-color'] = '#CEDBEF';
       
 22761                     break;
       
 22762                 case 13:
       
 22763                     current.click(e);
       
 22764                     break;
       
 22765                 }
       
 22766                 current.focus();
       
 22767             });
       
 22768             form.appendChild(input);
       
 22769             var div = document.createElement('div');
       
 22770             div.id = this._addUID('GPsearchInputReset');
       
 22771             div.addEventListener('click', function () {
       
 22772                 document.getElementById(self._addUID('GPsearchInputText')).value = '';
       
 22773                 document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22774                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22775                 self.onSearchResetClick();
       
 22776             });
       
 22777             form.appendChild(div);
       
 22778             return form;
       
 22779         },
       
 22780         _createShowAdvancedSearchElement: function () {
       
 22781             var self = this;
       
 22782             var div = document.createElement('div');
       
 22783             div.id = this._addUID('GPshowAdvancedSearch');
       
 22784             div.className = 'GPshowAdvancedToolPicto';
       
 22785             div.title = 'Ouvrir la recherche avancée';
       
 22786             div.addEventListener('click', function () {
       
 22787                 var id = '#GPsearchInput-' + self._uid;
       
 22788                 document.querySelector(id + ' input').disabled = true;
       
 22789                 document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22790                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22791                 document.getElementById(self._addUID('GPshowAdvancedSearch')).style.display = 'none';
       
 22792                 document.getElementById(self._addUID('GPadvancedSearchPanel')).style.display = 'inline-block';
       
 22793             });
       
 22794             var span = document.createElement('span');
       
 22795             span.id = this._addUID('GPshowAdvancedSearchOpen');
       
 22796             span.className = 'GPshowAdvancedToolOpen';
       
 22797             div.appendChild(span);
       
 22798             return div;
       
 22799         },
       
 22800         _createAdvancedSearchPanelElement: function () {
       
 22801             var div = document.createElement('div');
       
 22802             div.id = this._addUID('GPadvancedSearchPanel');
       
 22803             div.className = 'GPpanel';
       
 22804             div.style.display = 'none';
       
 22805             return div;
       
 22806         },
       
 22807         _createGeocodeResultsElement: function () {
       
 22808             var div = document.createElement('div');
       
 22809             div.id = this._addUID('GPgeocodeResultsList');
       
 22810             div.className = 'GPpanel';
       
 22811             div.style.display = 'none';
       
 22812             div.appendChild(this._createGeocodeResultsHeaderElement());
       
 22813             return div;
       
 22814         },
       
 22815         _createAutoCompleteElement: function () {
       
 22816             var div = document.createElement('div');
       
 22817             div.id = this._addUID('GPautoCompleteList');
       
 22818             div.className = 'GPautoCompleteList';
       
 22819             div.style.display = 'none';
       
 22820             return div;
       
 22821         },
       
 22822         _createAutoCompleteListElement: function () {
       
 22823             var self = this;
       
 22824             var container = document.createElement('div');
       
 22825             container.id = this._addUID('GPautocompleteResults');
       
 22826             if (container.addEventListener) {
       
 22827                 container.addEventListener('click', function (e) {
       
 22828                     self.onAutoCompletedResultsItemClick(e);
       
 22829                     document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22830                 }, false);
       
 22831             } else if (container.attachEvent) {
       
 22832                 container.attachEvent('onclick', function (e) {
       
 22833                     self.onAutoCompletedResultsItemClick(e);
       
 22834                     document.getElementById(self._addUID('GPautoCompleteList')).style.display = 'none';
       
 22835                 });
       
 22836             }
       
 22837             return container;
       
 22838         },
       
 22839         _createAutoCompletedLocationElement: function (location, id) {
       
 22840             var container = document.getElementById(this._addUID('GPautocompleteResults'));
       
 22841             var div = document.createElement('div');
       
 22842             div.id = this._addUID('AutoCompletedLocation_' + id);
       
 22843             div.className = 'GPautoCompleteProposal';
       
 22844             div.innerHTML = location.fullText;
       
 22845             if (div.addEventListener) {
       
 22846                 div.addEventListener('click', function (e) {
       
 22847                     container.click(e);
       
 22848                 }, false);
       
 22849             } else if (div.attachEvent) {
       
 22850                 div.attachEvent('onclick', function (e) {
       
 22851                     container.click(e);
       
 22852                 });
       
 22853             }
       
 22854             container.appendChild(div);
       
 22855         },
       
 22856         _createAdvancedSearchPanelHeaderElement: function () {
       
 22857             var self = this;
       
 22858             var container = document.createElement('div');
       
 22859             container.className = 'GPpanelHeader';
       
 22860             var divTitle = document.createElement('div');
       
 22861             divTitle.className = 'GPpanelTitle';
       
 22862             divTitle.innerHTML = 'Recherche avancée';
       
 22863             container.appendChild(divTitle);
       
 22864             var divClose = document.createElement('div');
       
 22865             divClose.id = this._addUID('GPadvancedSearchClose');
       
 22866             divClose.className = 'GPpanelClose';
       
 22867             divClose.title = 'Fermer la recherche avancée';
       
 22868             if (divClose.addEventListener) {
       
 22869                 divClose.addEventListener('click', function () {
       
 22870                     var id = '#GPsearchInput-' + self._uid;
       
 22871                     document.querySelector(id + ' input').disabled = false;
       
 22872                     document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22873                     document.getElementById(self._addUID('GPshowAdvancedSearch')).style.display = 'inline-block';
       
 22874                     document.getElementById(self._addUID('GPadvancedSearchPanel')).style.display = 'none';
       
 22875                 }, false);
       
 22876             } else if (divClose.attachEvent) {
       
 22877                 divClose.attachEvent('onclick', function () {
       
 22878                     var id = '#GPsearchInput-' + self._uid;
       
 22879                     document.querySelector(id + ' input').disabled = false;
       
 22880                     document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 22881                     document.getElementById(self._addUID('GPshowAdvancedSearch')).style.display = 'inline-block';
       
 22882                     document.getElementById(self._addUID('GPadvancedSearchPanel')).style.display = 'none';
       
 22883                 });
       
 22884             }
       
 22885             container.appendChild(divClose);
       
 22886             return container;
       
 22887         },
       
 22888         _createAdvancedSearchPanelFormElement: function (advancedSearchCodes) {
       
 22889             var self = this;
       
 22890             var form = document.createElement('form');
       
 22891             form.id = this._addUID('GPadvancedSearchForm');
       
 22892             form.addEventListener('submit', function (e) {
       
 22893                 e.preventDefault();
       
 22894                 var data = [];
       
 22895                 var id = '#GPadvancedSearchFilters-' + self._uid;
       
 22896                 var matchesFilters = document.querySelectorAll(id + ' > div > div > input');
       
 22897                 for (var i = 0; i < matchesFilters.length; i++) {
       
 22898                     var element = matchesFilters[i];
       
 22899                     data.push({
       
 22900                         key: element.name,
       
 22901                         value: element.value
       
 22902                     });
       
 22903                 }
       
 22904                 self.onGeocodingAdvancedSearchSubmit(e, data);
       
 22905                 document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'block';
       
 22906                 return false;
       
 22907             });
       
 22908             var div = document.createElement('div');
       
 22909             div.className = 'GPflexInput';
       
 22910             var label = document.createElement('label');
       
 22911             label.className = 'GPadvancedSearchCodeLabel';
       
 22912             label.innerHTML = 'Recherche par';
       
 22913             div.appendChild(label);
       
 22914             var select = this._createAdvancedSearchFormCodeElement(advancedSearchCodes);
       
 22915             div.appendChild(select);
       
 22916             form.appendChild(div);
       
 22917             return form;
       
 22918         },
       
 22919         _createAdvancedSearchFormCodeElement: function (codes) {
       
 22920             var self = this;
       
 22921             var select = document.createElement('select');
       
 22922             select.id = this._addUID('GPadvancedSearchCode');
       
 22923             select.className = 'GPadvancedSearchCode';
       
 22924             select.addEventListener('change', function (e) {
       
 22925                 self.onGeocodingAdvancedSearchCodeChange(e);
       
 22926             }, false);
       
 22927             if (!codes) {
       
 22928                 codes = [
       
 22929                     {
       
 22930                         id: 'PositionOfInterest',
       
 22931                         title: 'Lieux/toponymes'
       
 22932                     },
       
 22933                     {
       
 22934                         id: 'StreetAddress',
       
 22935                         title: 'Adresses'
       
 22936                     },
       
 22937                     {
       
 22938                         id: 'CadastralParcel',
       
 22939                         title: 'Parcelles cadastrales'
       
 22940                     },
       
 22941                     {
       
 22942                         id: 'Administratif',
       
 22943                         title: 'Administratif'
       
 22944                     }
       
 22945                 ];
       
 22946             }
       
 22947             for (var i = 0; i < codes.length; i++) {
       
 22948                 var option = document.createElement('option');
       
 22949                 option.value = codes[i].id;
       
 22950                 option.text = codes[i].title;
       
 22951                 select.appendChild(option);
       
 22952             }
       
 22953             return select;
       
 22954         },
       
 22955         _createAdvancedSearchFormInputElement: function () {
       
 22956             var input = document.createElement('input');
       
 22957             input.type = 'submit';
       
 22958             input.id = this._addUID('GPadvancedSearchSubmit');
       
 22959             input.className = 'GPinputSubmit';
       
 22960             input.value = 'Chercher';
       
 22961             return input;
       
 22962         },
       
 22963         _createAdvancedSearchFormFiltersElement: function () {
       
 22964             var container = document.createElement('div');
       
 22965             container.id = this._addUID('GPadvancedSearchFilters');
       
 22966             return container;
       
 22967         },
       
 22968         _createAdvancedSearchFiltersTableElement: function (code, display) {
       
 22969             var container = document.createElement('div');
       
 22970             container.id = this._addUID(code);
       
 22971             if (!display) {
       
 22972                 container.style.display = 'none';
       
 22973             }
       
 22974             return container;
       
 22975         },
       
 22976         _createAdvancedSearchFiltersAttributElement: function (filterAttributes) {
       
 22977             var container = null;
       
 22978             var name = filterAttributes.name;
       
 22979             var title = filterAttributes.title;
       
 22980             var description = filterAttributes.description;
       
 22981             var code = filterAttributes.code;
       
 22982             var value = filterAttributes.value;
       
 22983             var div = document.createElement('div');
       
 22984             div.className = 'GPflexInput';
       
 22985             var label = document.createElement('label');
       
 22986             label.className = 'GPadvancedSearchFilterLabel';
       
 22987             label.htmlFor = name;
       
 22988             label.title = description || title;
       
 22989             label.innerHTML = title;
       
 22990             div.appendChild(label);
       
 22991             var input = document.createElement('input');
       
 22992             input.id = name;
       
 22993             input.className = 'GPadvancedSearchFilterInput';
       
 22994             input.type = 'text';
       
 22995             input.name = name;
       
 22996             if (value) {
       
 22997                 input.value = value;
       
 22998             }
       
 22999             div.appendChild(input);
       
 23000             container = document.getElementById(this._addUID(code));
       
 23001             if (container) {
       
 23002                 container.appendChild(div);
       
 23003             } else {
       
 23004                 container = div;
       
 23005             }
       
 23006             return container;
       
 23007         },
       
 23008         _createGeocodeResultsHeaderElement: function () {
       
 23009             var self = this;
       
 23010             var container = document.createElement('div');
       
 23011             container.className = 'GPpanelHeader';
       
 23012             var divTitle = document.createElement('div');
       
 23013             divTitle.className = 'GPpanelTitle';
       
 23014             divTitle.innerHTML = 'Résultats de la recherche';
       
 23015             container.appendChild(divTitle);
       
 23016             var divClose = document.createElement('div');
       
 23017             divClose.id = this._addUID('GPgeocodeResultsClose');
       
 23018             divClose.className = 'GPpanelClose';
       
 23019             divClose.title = 'Fermer la fenêtre de résultats';
       
 23020             if (divClose.addEventListener) {
       
 23021                 divClose.addEventListener('click', function () {
       
 23022                     document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 23023                 }, false);
       
 23024             } else if (divClose.attachEvent) {
       
 23025                 divClose.attachEvent('onclick', function () {
       
 23026                     document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 23027                 });
       
 23028             }
       
 23029             container.appendChild(divClose);
       
 23030             return container;
       
 23031         },
       
 23032         _createGeocodeResultsListElement: function () {
       
 23033             var self = this;
       
 23034             var container = document.createElement('div');
       
 23035             container.id = this._addUID('GPgeocodeResults');
       
 23036             if (container.addEventListener) {
       
 23037                 container.addEventListener('click', function (e) {
       
 23038                     if (!e.ctrlKey) {
       
 23039                         document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 23040                     }
       
 23041                     self.onGeocodedResultsItemClick(e);
       
 23042                 }, false);
       
 23043             } else if (container.attachEvent) {
       
 23044                 container.attachEvent('onclick', function (e) {
       
 23045                     if (!e.ctrlKey) {
       
 23046                         document.getElementById(self._addUID('GPgeocodeResultsList')).style.display = 'none';
       
 23047                     }
       
 23048                     self.onGeocodedResultsItemClick(e);
       
 23049                 });
       
 23050             }
       
 23051             return container;
       
 23052         },
       
 23053         _createGeocodedLocationElement: function (location, id) {
       
 23054             var container = document.getElementById(this._addUID('GPgeocodeResults'));
       
 23055             var div = document.createElement('div');
       
 23056             div.id = this._addUID('GeocodedLocation_' + id);
       
 23057             div.className = 'GPautoCompleteProposal';
       
 23058             if (typeof location === 'string') {
       
 23059                 div.innerHTML = location;
       
 23060             } else {
       
 23061                 var places = location.placeAttributes;
       
 23062                 if (places.freeform) {
       
 23063                     div.innerHTML = places.freeform;
       
 23064                 } else if (places.postalCode) {
       
 23065                     div.innerHTML = places.postalCode + ' ' + places.commune;
       
 23066                 } else if (places.cadastralParcel) {
       
 23067                     div.innerHTML = places.cadastralParcel;
       
 23068                 } else {
       
 23069                     div.innerHTML = '...';
       
 23070                 }
       
 23071             }
       
 23072             container.appendChild(div);
       
 23073         }
       
 23074     };
       
 23075     return SearchEngineDOM;
       
 23076 }(CommonUtilsSelectorID);
       
 23077 CommonControlsSearchEngineUtils = function () {
       
 23078     var SearchEngineUtils = {
       
 23079         advancedSearchFiltersByDefault: {
       
 23080             PositionOfInterest: [
       
 23081                 {
       
 23082                     name: 'importance',
       
 23083                     title: 'Importance'
       
 23084                 },
       
 23085                 {
       
 23086                     name: 'nature',
       
 23087                     title: 'Nature'
       
 23088                 },
       
 23089                 {
       
 23090                     name: 'territory',
       
 23091                     title: 'Territoire'
       
 23092                 },
       
 23093                 {
       
 23094                     name: 'insee',
       
 23095                     title: 'Code INSEE'
       
 23096                 },
       
 23097                 {
       
 23098                     name: 'municipality',
       
 23099                     title: 'Ville'
       
 23100                 },
       
 23101                 {
       
 23102                     name: 'department',
       
 23103                     title: 'Département'
       
 23104                 }
       
 23105             ],
       
 23106             StreetAddress: [
       
 23107                 {
       
 23108                     name: 'territory',
       
 23109                     title: 'Territoire'
       
 23110                 },
       
 23111                 {
       
 23112                     name: 'insee',
       
 23113                     title: 'Code INSEE'
       
 23114                 },
       
 23115                 {
       
 23116                     name: 'municipality',
       
 23117                     title: 'Ville'
       
 23118                 },
       
 23119                 {
       
 23120                     name: 'department',
       
 23121                     title: 'Département'
       
 23122                 }
       
 23123             ],
       
 23124             CadastralParcel: [
       
 23125                 {
       
 23126                     name: 'department',
       
 23127                     title: 'Département',
       
 23128                     description: 'Numéro du département (ex: 01, 94)'
       
 23129                 },
       
 23130                 {
       
 23131                     name: 'commune',
       
 23132                     title: 'Code commune (INSEE)',
       
 23133                     description: 'Code commune (INSEE) : 3 chiffres (ex: 067)'
       
 23134                 },
       
 23135                 {
       
 23136                     name: 'absorbedCity',
       
 23137                     title: 'Commune absorbée',
       
 23138                     description: 'Commune absorbée : 3 chiffres (ex: 000, 001)'
       
 23139                 },
       
 23140                 {
       
 23141                     name: 'section',
       
 23142                     title: 'Section',
       
 23143                     description: 'Section : 2 caractères (ex: AA, 0D)'
       
 23144                 },
       
 23145                 {
       
 23146                     name: 'number',
       
 23147                     title: 'Numéro',
       
 23148                     description: 'Numéro de la parcelle : 4 chiffres (ex: 0041, 0250)'
       
 23149                 }
       
 23150             ],
       
 23151             Administratif: [
       
 23152                 {
       
 23153                     name: 'prefecture',
       
 23154                     title: 'Préfecture'
       
 23155                 },
       
 23156                 {
       
 23157                     name: 'inseeRegion',
       
 23158                     title: 'Code région (INSEE)'
       
 23159                 },
       
 23160                 {
       
 23161                     name: 'inseeDepartment',
       
 23162                     title: 'Code département (INSEE)'
       
 23163                 },
       
 23164                 {
       
 23165                     name: 'municipality',
       
 23166                     title: 'Ville'
       
 23167                 }
       
 23168             ]
       
 23169         },
       
 23170         zoomToResultsByDefault: function (info) {
       
 23171             var zoom = 15;
       
 23172             var service = info.service;
       
 23173             var fields = info.fields;
       
 23174             var type = info.type;
       
 23175             var importance = {
       
 23176                 1: 11,
       
 23177                 2: 12,
       
 23178                 3: 13,
       
 23179                 4: 14,
       
 23180                 5: 15,
       
 23181                 6: 16,
       
 23182                 7: 17,
       
 23183                 8: 17
       
 23184             };
       
 23185             if (service === 'SuggestedLocation') {
       
 23186                 if (type === 'PositionOfInterest') {
       
 23187                     zoom = importance[fields.classification];
       
 23188                 }
       
 23189             }
       
 23190             if (service === 'DirectGeocodedLocation') {
       
 23191                 if (type === 'PositionOfInterest') {
       
 23192                     zoom = importance[fields.importance] || 14;
       
 23193                 }
       
 23194             }
       
 23195             if (type === 'StreetAddress') {
       
 23196                 zoom = 17;
       
 23197             }
       
 23198             if (type === 'CadastralParcel') {
       
 23199                 zoom = 17;
       
 23200             }
       
 23201             if (type === 'Administratif') {
       
 23202                 zoom = 12;
       
 23203             }
       
 23204             return zoom;
       
 23205         }
       
 23206     };
       
 23207     return SearchEngineUtils;
       
 23208 }();
       
 23209 LeafletControlsSearchEngine = function (L, woodman, Gp, RightManagement, ID, SearchEngineDOM, SearchEngineUtils) {
       
 23210     var SearchEngine = L.Control.extend({
       
 23211         includes: SearchEngineDOM,
       
 23212         options: {
       
 23213             position: 'topleft',
       
 23214             collapsed: true,
       
 23215             displayInfo: true,
       
 23216             zoomTo: '',
       
 23217             resources: [],
       
 23218             displayAdvancedSearch: true,
       
 23219             advancedSearch: {},
       
 23220             geocodeOptions: {},
       
 23221             autocompleteOptions: {}
       
 23222         },
       
 23223         initialize: function (options) {
       
 23224             L.Util.setOptions(this, options);
       
 23225             this._uid = ID.generate();
       
 23226             this._inputContainer = null;
       
 23227             this._suggestedContainer = null;
       
 23228             this._suggestedLocations = [];
       
 23229             this._geocodedContainer = null;
       
 23230             this._geocodedLocations = [];
       
 23231             this._filterContainer = null;
       
 23232             this._currentGeocodingCode = null;
       
 23233             this._currentGeocodingLocation = null;
       
 23234             this._advancedSearchFilters = {};
       
 23235             this._advancedSearchCodes = [];
       
 23236             this._marker = null;
       
 23237             this._servicesRightManagement = {};
       
 23238             this._noRightManagement = false;
       
 23239             this._checkRightsManagement();
       
 23240         },
       
 23241         onAdd: function () {
       
 23242             this._initAdvancedSearchCodes();
       
 23243             this._initAdvancedSearchFilters();
       
 23244             var container = this._initLayout();
       
 23245             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 23246             return container;
       
 23247         },
       
 23248         onRemove: function () {
       
 23249         },
       
 23250         _checkRightsManagement: function () {
       
 23251             if (!this.options.resources || this.options.resources.length === 0) {
       
 23252                 this.options.resources = [
       
 23253                     'StreetAddress',
       
 23254                     'PositionOfInterest'
       
 23255                 ];
       
 23256             }
       
 23257             var _opts = null;
       
 23258             var _res = [];
       
 23259             var _key = null;
       
 23260             _key = this.options.geocodeOptions.apiKey;
       
 23261             _opts = this.options.geocodeOptions.filterOptions;
       
 23262             _res = _opts ? _opts.type : [];
       
 23263             if (!_res || _res.length === 0) {
       
 23264                 _res = this.options.resources || [
       
 23265                     'StreetAddress',
       
 23266                     'PositionOfInterest'
       
 23267                 ];
       
 23268             }
       
 23269             var rightManagementGeocode = RightManagement.check({
       
 23270                 key: _key || this.options.apiKey,
       
 23271                 resources: _res,
       
 23272                 services: ['Geocode']
       
 23273             });
       
 23274             _key = this.options.autocompleteOptions.apiKey;
       
 23275             _opts = this.options.autocompleteOptions.filterOptions;
       
 23276             _res = _opts ? _opts.type : [];
       
 23277             if (!_res || _res.length === 0) {
       
 23278                 _res = this.options.resources || [
       
 23279                     'StreetAddress',
       
 23280                     'PositionOfInterest'
       
 23281                 ];
       
 23282             }
       
 23283             var rightManagementAutoComplete = RightManagement.check({
       
 23284                 key: _key || this.options.apiKey,
       
 23285                 resources: _res,
       
 23286                 services: ['AutoCompletion']
       
 23287             });
       
 23288             if (!rightManagementGeocode && !rightManagementAutoComplete) {
       
 23289                 this._noRightManagement = true;
       
 23290             }
       
 23291             if (rightManagementAutoComplete) {
       
 23292                 this._servicesRightManagement['AutoCompletion'] = {};
       
 23293                 this._servicesRightManagement['AutoCompletion']['resources'] = rightManagementAutoComplete['AutoCompletion'];
       
 23294                 this._servicesRightManagement['AutoCompletion']['key'] = rightManagementAutoComplete['key'];
       
 23295             }
       
 23296             if (rightManagementGeocode) {
       
 23297                 this._servicesRightManagement['Geocode'] = {};
       
 23298                 this._servicesRightManagement['Geocode']['resources'] = rightManagementGeocode['Geocode'];
       
 23299                 this._servicesRightManagement['Geocode']['key'] = rightManagementGeocode['key'];
       
 23300             }
       
 23301             if (!this.options.advancedSearch || Object.keys(this.options.advancedSearch).length === 0) {
       
 23302                 var r = this._servicesRightManagement['Geocode']['resources'];
       
 23303                 for (var i = 0; i < r.length; i++) {
       
 23304                     var code = r[i];
       
 23305                     this.options.advancedSearch[code] = [];
       
 23306                 }
       
 23307             }
       
 23308         },
       
 23309         _initLayout: function () {
       
 23310             var container = this._createMainContainerElement();
       
 23311             var inputShow = this._createShowSearchEngineElement();
       
 23312             container.appendChild(inputShow);
       
 23313             if (!this.options.collapsed) {
       
 23314                 inputShow.checked = 'true';
       
 23315             }
       
 23316             var picto = this._createShowSearchEnginePictoElement();
       
 23317             container.appendChild(picto);
       
 23318             var search = this._createSearchInputElement();
       
 23319             container.appendChild(search);
       
 23320             if (this.options.displayAdvancedSearch) {
       
 23321                 var advancedShow = this._createShowAdvancedSearchElement();
       
 23322                 container.appendChild(advancedShow);
       
 23323                 var advancedPanel = this._createAdvancedSearchPanelElement();
       
 23324                 var advancedHeader = this._createAdvancedSearchPanelHeaderElement();
       
 23325                 var advancedForm = this._createAdvancedSearchPanelFormElement(this._advancedSearchCodes);
       
 23326                 var advancedFormFilters = this._filterContainer = this._createAdvancedSearchFormFiltersElement();
       
 23327                 this._setFilter(this._advancedSearchCodes[0].id);
       
 23328                 var advancedFormInput = this._createAdvancedSearchFormInputElement();
       
 23329                 advancedForm.appendChild(advancedFormFilters);
       
 23330                 advancedForm.appendChild(advancedFormInput);
       
 23331                 advancedPanel.appendChild(advancedHeader);
       
 23332                 advancedPanel.appendChild(advancedForm);
       
 23333                 container.appendChild(advancedPanel);
       
 23334             }
       
 23335             var autocomplete = this._createAutoCompleteElement();
       
 23336             var autocompleteList = this._suggestedContainer = this._createAutoCompleteListElement();
       
 23337             autocomplete.appendChild(autocompleteList);
       
 23338             container.appendChild(autocomplete);
       
 23339             var geocode = this._createGeocodeResultsElement();
       
 23340             var geocodeList = this._geocodedContainer = this._createGeocodeResultsListElement();
       
 23341             geocode.appendChild(geocodeList);
       
 23342             container.appendChild(geocode);
       
 23343             return container;
       
 23344         },
       
 23345         _initAdvancedSearchCodes: function () {
       
 23346             var advancedSearchCodesByDefault = [
       
 23347                 {
       
 23348                     id: 'PositionOfInterest',
       
 23349                     title: 'Lieux/toponymes'
       
 23350                 },
       
 23351                 {
       
 23352                     id: 'StreetAddress',
       
 23353                     title: 'Adresses'
       
 23354                 },
       
 23355                 {
       
 23356                     id: 'CadastralParcel',
       
 23357                     title: 'Parcelles cadastrales'
       
 23358                 },
       
 23359                 {
       
 23360                     id: 'Administratif',
       
 23361                     title: 'Administratif'
       
 23362                 }
       
 23363             ];
       
 23364             var _resources = Object.keys(this.options.advancedSearch);
       
 23365             for (var i = 0; i < _resources.length; i++) {
       
 23366                 var id = _resources[i];
       
 23367                 for (var j = 0; j < advancedSearchCodesByDefault.length; j++) {
       
 23368                     if (advancedSearchCodesByDefault[j].id === id) {
       
 23369                         this._advancedSearchCodes.push(advancedSearchCodesByDefault[j]);
       
 23370                     }
       
 23371                 }
       
 23372             }
       
 23373             if (this._advancedSearchCodes.length === 0) {
       
 23374                 this._advancedSearchCodes = advancedSearchCodesByDefault;
       
 23375             }
       
 23376         },
       
 23377         _initAdvancedSearchFilters: function () {
       
 23378             var advancedSearchFiltersByDefault = {
       
 23379                 PositionOfInterest: [
       
 23380                     {
       
 23381                         name: 'city',
       
 23382                         title: 'Ville',
       
 23383                         filter: false,
       
 23384                         sep: true
       
 23385                     },
       
 23386                     {
       
 23387                         name: 'importance',
       
 23388                         title: 'Importance',
       
 23389                         filter: true
       
 23390                     },
       
 23391                     {
       
 23392                         name: 'nature',
       
 23393                         title: 'Nature',
       
 23394                         filter: true
       
 23395                     },
       
 23396                     {
       
 23397                         name: 'territory',
       
 23398                         title: 'Territoire',
       
 23399                         filter: true
       
 23400                     },
       
 23401                     {
       
 23402                         name: 'insee',
       
 23403                         title: 'Code commune (INSEE)',
       
 23404                         filter: true
       
 23405                     },
       
 23406                     {
       
 23407                         name: 'department',
       
 23408                         title: 'Département',
       
 23409                         filter: true
       
 23410                     }
       
 23411                 ],
       
 23412                 StreetAddress: [
       
 23413                     {
       
 23414                         name: 'number',
       
 23415                         title: 'Numéro',
       
 23416                         filter: false,
       
 23417                         sep: true
       
 23418                     },
       
 23419                     {
       
 23420                         name: 'street',
       
 23421                         title: 'Rue',
       
 23422                         filter: false,
       
 23423                         sep: true
       
 23424                     },
       
 23425                     {
       
 23426                         name: 'postalCode',
       
 23427                         title: 'Code Postal',
       
 23428                         filter: false,
       
 23429                         sep: true
       
 23430                     },
       
 23431                     {
       
 23432                         name: 'city',
       
 23433                         title: 'Ville',
       
 23434                         filter: false,
       
 23435                         sep: true
       
 23436                     },
       
 23437                     {
       
 23438                         name: 'territory',
       
 23439                         title: 'Territoire',
       
 23440                         filter: true
       
 23441                     },
       
 23442                     {
       
 23443                         name: 'insee',
       
 23444                         title: 'Code commune (INSEE)',
       
 23445                         filter: true
       
 23446                     },
       
 23447                     {
       
 23448                         name: 'department',
       
 23449                         title: 'Département',
       
 23450                         filter: true
       
 23451                     }
       
 23452                 ],
       
 23453                 CadastralParcel: [
       
 23454                     {
       
 23455                         name: 'department',
       
 23456                         title: 'Département',
       
 23457                         filter: false,
       
 23458                         sep: false,
       
 23459                         value: '__'
       
 23460                     },
       
 23461                     {
       
 23462                         name: 'commune',
       
 23463                         title: 'Commune',
       
 23464                         filter: false,
       
 23465                         sep: false,
       
 23466                         value: '___'
       
 23467                     },
       
 23468                     {
       
 23469                         name: 'absorbedCity',
       
 23470                         title: 'Commune absorbée',
       
 23471                         filter: false,
       
 23472                         sep: false,
       
 23473                         value: '___'
       
 23474                     },
       
 23475                     {
       
 23476                         name: 'section',
       
 23477                         title: 'Section',
       
 23478                         filter: false,
       
 23479                         sep: false,
       
 23480                         value: '__'
       
 23481                     },
       
 23482                     {
       
 23483                         name: 'number',
       
 23484                         title: 'Numéro',
       
 23485                         filter: false,
       
 23486                         sep: false,
       
 23487                         value: '____'
       
 23488                     }
       
 23489                 ],
       
 23490                 Administratif: [
       
 23491                     {
       
 23492                         name: 'prefecture',
       
 23493                         title: 'Préfecture',
       
 23494                         filter: true
       
 23495                     },
       
 23496                     {
       
 23497                         name: 'inseeRegion',
       
 23498                         title: 'Code région (INSEE)',
       
 23499                         filter: true
       
 23500                     },
       
 23501                     {
       
 23502                         name: 'inseeDepartment',
       
 23503                         title: 'Code département (INSEE)',
       
 23504                         filter: true
       
 23505                     },
       
 23506                     {
       
 23507                         name: 'city',
       
 23508                         title: 'Ville',
       
 23509                         filter: false,
       
 23510                         sep: true
       
 23511                     }
       
 23512                 ]
       
 23513             };
       
 23514             var advancedSearchFiltersCustom = this.options.advancedSearch;
       
 23515             for (var code in advancedSearchFiltersCustom) {
       
 23516                 if (advancedSearchFiltersCustom.hasOwnProperty(code)) {
       
 23517                     if (!advancedSearchFiltersCustom[code] || advancedSearchFiltersCustom[code].length === 0) {
       
 23518                         advancedSearchFiltersCustom[code] = advancedSearchFiltersByDefault[code];
       
 23519                         continue;
       
 23520                     }
       
 23521                     var filters = advancedSearchFiltersCustom[code];
       
 23522                     for (var i = 0; i < filters.length; i++) {
       
 23523                         var o = filters[i];
       
 23524                         if (!o.hasOwnProperty('filter')) {
       
 23525                             o.filter = o.name === 'municipality' ? false : true;
       
 23526                         }
       
 23527                     }
       
 23528                 }
       
 23529             }
       
 23530             L.Util.extend(this._advancedSearchFilters, advancedSearchFiltersByDefault, advancedSearchFiltersCustom);
       
 23531         },
       
 23532         _setFilter: function (code) {
       
 23533             var container = this._filterContainer;
       
 23534             var codeFound = false;
       
 23535             for (var i = 0; i < this._advancedSearchCodes.length; i++) {
       
 23536                 if (this._advancedSearchCodes[i].id === code) {
       
 23537                     codeFound = true;
       
 23538                     break;
       
 23539                 }
       
 23540             }
       
 23541             if (!codeFound) {
       
 23542                 while (container.firstChild) {
       
 23543                     container.removeChild(container.firstChild);
       
 23544                 }
       
 23545                 return;
       
 23546             }
       
 23547             this._currentGeocodingCode = code;
       
 23548             while (container.firstChild) {
       
 23549                 container.removeChild(container.firstChild);
       
 23550             }
       
 23551             var lstAttributs = this._advancedSearchFilters[code];
       
 23552             if (!lstAttributs || lstAttributs.length === 0) {
       
 23553                 return;
       
 23554             }
       
 23555             var divTable = this._createAdvancedSearchFiltersTableElement(code, true);
       
 23556             for (var j = 0; j < lstAttributs.length; j++) {
       
 23557                 var divFilter = this._createAdvancedSearchFiltersAttributElement(lstAttributs[j]);
       
 23558                 divTable.appendChild(divFilter);
       
 23559             }
       
 23560             container.appendChild(divTable);
       
 23561             return container;
       
 23562         },
       
 23563         _requestAutoComplete: function (settings) {
       
 23564             if (!settings || Object.keys(settings).length === 0) {
       
 23565                 return;
       
 23566             }
       
 23567             if (!settings.text) {
       
 23568                 return;
       
 23569             }
       
 23570             if (this._noRightManagement) {
       
 23571                 console.log('no rights for all service !?');
       
 23572                 return;
       
 23573             }
       
 23574             if (!this._servicesRightManagement['AutoCompletion']) {
       
 23575                 console.log('no rights for this service !?');
       
 23576                 return;
       
 23577             }
       
 23578             var options = {};
       
 23579             L.Util.extend(options, this.options.autocompleteOptions);
       
 23580             L.Util.extend(options, settings);
       
 23581             var resources = this._servicesRightManagement['AutoCompletion'].resources;
       
 23582             if (!resources || Object.keys(resources).length === 0) {
       
 23583                 return;
       
 23584             }
       
 23585             if (resources && L.Util.isArray(resources) && !options.filterOptions) {
       
 23586                 if (!options.filterOptions) {
       
 23587                     options.filterOptions = {};
       
 23588                 }
       
 23589                 options.filterOptions.type = resources;
       
 23590             }
       
 23591             var key = this._servicesRightManagement['AutoCompletion']['key'];
       
 23592             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey || key });
       
 23593             Gp.Services.autoComplete(options);
       
 23594         },
       
 23595         _fillAutoCompletedLocationListContainer: function (locations) {
       
 23596             if (!locations || locations.length === 0) {
       
 23597                 return;
       
 23598             }
       
 23599             var element = this._suggestedContainer;
       
 23600             if (element.childElementCount) {
       
 23601                 while (element.firstChild) {
       
 23602                     element.removeChild(element.firstChild);
       
 23603                 }
       
 23604             }
       
 23605             for (var i = 0; i < locations.length; i++) {
       
 23606                 this._createAutoCompletedLocationElement(locations[i], i);
       
 23607             }
       
 23608             this._suggestedLocations = locations;
       
 23609         },
       
 23610         _requestGeocoding: function (settings) {
       
 23611             if (!settings || Object.keys(settings).length === 0) {
       
 23612                 return;
       
 23613             }
       
 23614             if (!settings.location) {
       
 23615                 return;
       
 23616             }
       
 23617             if (this._noRightManagement) {
       
 23618                 console.log('no rights for all service !?');
       
 23619                 return;
       
 23620             }
       
 23621             if (!this._servicesRightManagement['Geocode']) {
       
 23622                 console.log('no rights for this service !?');
       
 23623                 return;
       
 23624             }
       
 23625             var options = {};
       
 23626             L.Util.extend(options, this.options.geocodeOptions);
       
 23627             L.Util.extend(options, settings);
       
 23628             if (!options.hasOwnProperty('returnFreeForm')) {
       
 23629                 L.Util.extend(options, { returnFreeForm: false });
       
 23630             }
       
 23631             var resources = this._servicesRightManagement['Geocode'].resources;
       
 23632             if (!resources || Object.keys(resources).length === 0) {
       
 23633                 return;
       
 23634             }
       
 23635             if (resources && L.Util.isArray(resources) && !options.filterOptions) {
       
 23636                 if (!options.filterOptions) {
       
 23637                     options.filterOptions = {};
       
 23638                 }
       
 23639                 options.filterOptions.type = resources;
       
 23640             }
       
 23641             var key = this._servicesRightManagement['Geocode']['key'];
       
 23642             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey || key });
       
 23643             Gp.Services.geocode(options);
       
 23644         },
       
 23645         _fillGeocodedLocationListContainer: function (locations) {
       
 23646             if (!locations || locations.length === 0) {
       
 23647                 this._clearGeocodedLocation();
       
 23648                 return;
       
 23649             }
       
 23650             var element = this._geocodedContainer;
       
 23651             if (element.childElementCount) {
       
 23652                 while (element.firstChild) {
       
 23653                     element.removeChild(element.firstChild);
       
 23654                 }
       
 23655             }
       
 23656             for (var i = 0; i < locations.length; i++) {
       
 23657                 this._createGeocodedLocationElement(locations[i], i);
       
 23658             }
       
 23659             this._geocodedLocations = locations;
       
 23660         },
       
 23661         _setLabel: function (label) {
       
 23662             var element = L.DomUtil.get('GPsearchInputText-' + this._uid);
       
 23663             element.value = label || '';
       
 23664         },
       
 23665         _setPosition: function (position, zoom) {
       
 23666             var map = this._map;
       
 23667             map.setZoomAround(L.latLng(position.x, position.y), zoom, true);
       
 23668             map.panTo(L.latLng(position.x, position.y));
       
 23669         },
       
 23670         _getZoom: function (info) {
       
 23671             var map = this._map;
       
 23672             var key = this.options.zoomTo;
       
 23673             var zoom = null;
       
 23674             if (typeof key === 'function') {
       
 23675                 zoom = key.call(this, info);
       
 23676             }
       
 23677             if (typeof key === 'number') {
       
 23678                 zoom = key;
       
 23679             }
       
 23680             if (typeof key === 'string') {
       
 23681                 if (key === 'auto') {
       
 23682                     zoom = SearchEngineUtils.zoomToResultsByDefault(info);
       
 23683                 } else {
       
 23684                     var value = parseInt(key, 10);
       
 23685                     if (!isNaN(value)) {
       
 23686                         zoom = value;
       
 23687                     }
       
 23688                 }
       
 23689             }
       
 23690             Number.isInteger = Number.isInteger || function (value) {
       
 23691                 return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
       
 23692             };
       
 23693             if (!zoom || zoom === '' || !Number.isInteger(zoom)) {
       
 23694                 zoom = map.getZoom();
       
 23695             }
       
 23696             var min = map.getMinZoom();
       
 23697             var max = map.getMaxZoom();
       
 23698             if (zoom < min) {
       
 23699                 zoom = min;
       
 23700             }
       
 23701             if (zoom > max) {
       
 23702                 zoom = max;
       
 23703             }
       
 23704             return zoom;
       
 23705         },
       
 23706         _setMarker: function (position, information, display) {
       
 23707             var map = this._map;
       
 23708             if (this._marker != null) {
       
 23709                 map.removeLayer(this._marker);
       
 23710                 this._marker = null;
       
 23711             }
       
 23712             if (position) {
       
 23713                 var options = {
       
 23714                     clickable: true,
       
 23715                     zIndexOffset: 1000
       
 23716                 };
       
 23717                 this._marker = L.marker(L.latLng(position.x, position.y), options);
       
 23718                 this._marker.addTo(map);
       
 23719                 if (display) {
       
 23720                     var popupContent = null;
       
 23721                     if (typeof information !== 'string') {
       
 23722                         var values = [];
       
 23723                         if (information.service === 'DirectGeocodedLocation') {
       
 23724                             if (information.fields.freeform) {
       
 23725                                 popupContent = information.fields.freeform;
       
 23726                             } else {
       
 23727                                 var attributs = this._advancedSearchFilters[information.type];
       
 23728                                 for (var i = 0; i < attributs.length; i++) {
       
 23729                                     var key = attributs[i].name;
       
 23730                                     var value = information.fields[key];
       
 23731                                     if (typeof value === 'string' || typeof value === 'number') {
       
 23732                                         values.push(value);
       
 23733                                     }
       
 23734                                 }
       
 23735                                 popupContent = values.join(' - ');
       
 23736                             }
       
 23737                         } else if (information.service === 'SuggestedLocation') {
       
 23738                             if (information.fields.fullText) {
       
 23739                                 popupContent = information.fields.fullText;
       
 23740                             } else {
       
 23741                                 values.push(information.fields.street || '');
       
 23742                                 values.push(information.fields.postalCode || '');
       
 23743                                 values.push(information.fields.commune || '');
       
 23744                                 if (information.type === 'PositionOfInterest') {
       
 23745                                     values.push(information.fields.poi || '');
       
 23746                                     values.push(information.fields.kind || '');
       
 23747                                 }
       
 23748                                 popupContent = values.join(' - ');
       
 23749                             }
       
 23750                         } else {
       
 23751                             popupContent = 'sans informations.';
       
 23752                         }
       
 23753                     } else {
       
 23754                         popupContent = information;
       
 23755                     }
       
 23756                     this._marker.bindPopup(popupContent);
       
 23757                 }
       
 23758             }
       
 23759         },
       
 23760         _clearResults: function () {
       
 23761             this._currentGeocodingLocation = null;
       
 23762             this._clearSuggestedLocation();
       
 23763             this._clearGeocodedLocation();
       
 23764             this._setMarker();
       
 23765         },
       
 23766         _clearSuggestedLocation: function () {
       
 23767             this._suggestedLocations = [];
       
 23768             if (this._suggestedContainer) {
       
 23769                 while (this._suggestedContainer.firstChild) {
       
 23770                     this._suggestedContainer.removeChild(this._suggestedContainer.firstChild);
       
 23771                 }
       
 23772             }
       
 23773         },
       
 23774         _clearGeocodedLocation: function () {
       
 23775             this._geocodedLocations = [];
       
 23776             if (this._geocodedContainer) {
       
 23777                 while (this._geocodedContainer.firstChild) {
       
 23778                     this._geocodedContainer.removeChild(this._geocodedContainer.firstChild);
       
 23779                 }
       
 23780             }
       
 23781         },
       
 23782         onShowSearchEngineClick: function () {
       
 23783         },
       
 23784         onSearchResetClick: function () {
       
 23785             this._clearResults();
       
 23786         },
       
 23787         onAutoCompleteSearchText: function (e) {
       
 23788             var value = e.target.value;
       
 23789             if (!value) {
       
 23790                 return;
       
 23791             }
       
 23792             if (this._noRightManagement) {
       
 23793                 return;
       
 23794             }
       
 23795             this._currentGeocodingLocation = value;
       
 23796             if (value.length < 3) {
       
 23797                 return;
       
 23798             }
       
 23799             var context = this;
       
 23800             this._requestAutoComplete({
       
 23801                 text: value,
       
 23802                 onSuccess: function (results) {
       
 23803                     if (results) {
       
 23804                         var locations = results.suggestedLocations;
       
 23805                         context._fillAutoCompletedLocationListContainer(locations);
       
 23806                     }
       
 23807                 },
       
 23808                 onFailure: function (error) {
       
 23809                     context._clearSuggestedLocation();
       
 23810                 }
       
 23811             });
       
 23812         },
       
 23813         onAutoCompletedResultsItemClick: function (e) {
       
 23814             var idx = ID.index(e.target.id);
       
 23815             var label = e.target.innerHTML;
       
 23816             if (!idx) {
       
 23817                 return;
       
 23818             }
       
 23819             var position = {
       
 23820                 x: this._suggestedLocations[idx].position.y,
       
 23821                 y: this._suggestedLocations[idx].position.x
       
 23822             };
       
 23823             var info = {
       
 23824                 service: 'SuggestedLocation',
       
 23825                 type: this._suggestedLocations[idx].type,
       
 23826                 fields: this._suggestedLocations[idx]
       
 23827             };
       
 23828             var zoom = this._getZoom(info);
       
 23829             this._setLabel(label);
       
 23830             this._setPosition(position, zoom);
       
 23831             this._setMarker(position, info, this.options.displayInfo);
       
 23832         },
       
 23833         onGeocodingSearchSubmit: function (e) {
       
 23834             var value = e.target[0].value;
       
 23835             if (!value) {
       
 23836                 return;
       
 23837             }
       
 23838             if (this._noRightManagement) {
       
 23839                 return;
       
 23840             }
       
 23841             this._currentGeocodingLocation = value;
       
 23842             var context = this;
       
 23843             this._requestGeocoding({
       
 23844                 location: value,
       
 23845                 onSuccess: function (results) {
       
 23846                     if (results) {
       
 23847                         var locations = results.locations;
       
 23848                         context._fillGeocodedLocationListContainer(locations);
       
 23849                     }
       
 23850                 },
       
 23851                 onFailure: function (error) {
       
 23852                     context._clearGeocodedLocation();
       
 23853                 }
       
 23854             });
       
 23855         },
       
 23856         onGeocodedResultsItemClick: function (e) {
       
 23857             var idx = ID.index(e.target.id);
       
 23858             var label = e.target.innerHTML;
       
 23859             if (!idx) {
       
 23860                 return;
       
 23861             }
       
 23862             var position = this._geocodedLocations[idx].position;
       
 23863             var info = {
       
 23864                 service: 'DirectGeocodedLocation',
       
 23865                 type: this._geocodedLocations[idx].type,
       
 23866                 fields: this._geocodedLocations[idx].placeAttributes
       
 23867             };
       
 23868             var zoom = this._getZoom(info);
       
 23869             this._setLabel(label);
       
 23870             this._setPosition(position, zoom);
       
 23871             this._setMarker(position, info, this.options.displayInfo);
       
 23872         },
       
 23873         onGeocodingAdvancedSearchCodeChange: function (e) {
       
 23874             var idx = e.target.selectedIndex;
       
 23875             var value = e.target.options[idx].value;
       
 23876             if (!value) {
       
 23877                 return;
       
 23878             }
       
 23879             this._setFilter(value);
       
 23880         },
       
 23881         onGeocodingAdvancedSearchSubmit: function (e, data) {
       
 23882             if (!data || data.length === 0) {
       
 23883                 return;
       
 23884             }
       
 23885             var _filterOptions = {};
       
 23886             _filterOptions['type'] = [this._currentGeocodingCode];
       
 23887             var _location = this._currentGeocodingLocation || '';
       
 23888             if (this._currentGeocodingCode === 'CadastralParcel') {
       
 23889                 _location = '';
       
 23890             }
       
 23891             for (var i = 0; i < data.length; i++) {
       
 23892                 var filter = data[i];
       
 23893                 if (!filter.value) {
       
 23894                     continue;
       
 23895                 }
       
 23896                 var filters = this._advancedSearchFilters[this._currentGeocodingCode];
       
 23897                 for (var j = 0; j < filters.length; j++) {
       
 23898                     var o = filters[j];
       
 23899                     if (o.name === filter.key) {
       
 23900                         if (o.filter) {
       
 23901                             _filterOptions[filter.key] = filter.value;
       
 23902                         } else {
       
 23903                             if (o.value) {
       
 23904                                 var cur = filter.value.length;
       
 23905                                 var max = o.value.length;
       
 23906                                 if (max !== cur) {
       
 23907                                     var masked = max - cur;
       
 23908                                     var filler = o.value.charAt(0);
       
 23909                                     while (filler.length < masked) {
       
 23910                                         filler += filler;
       
 23911                                     }
       
 23912                                     var fillerSlice = filler.slice(0, masked);
       
 23913                                     filter.value = filter.value + fillerSlice;
       
 23914                                 }
       
 23915                                 _location += filter.value;
       
 23916                             } else {
       
 23917                                 if (typeof _location === 'string') {
       
 23918                                     _location = {};
       
 23919                                 }
       
 23920                                 _location[filter.key] = filter.value;
       
 23921                             }
       
 23922                         }
       
 23923                     }
       
 23924                 }
       
 23925             }
       
 23926             var context = this;
       
 23927             this._requestGeocoding({
       
 23928                 location: _location,
       
 23929                 filterOptions: _filterOptions,
       
 23930                 onSuccess: function (results) {
       
 23931                     if (results) {
       
 23932                         var locations = results.locations;
       
 23933                         context._fillGeocodedLocationListContainer(locations);
       
 23934                     }
       
 23935                 },
       
 23936                 onFailure: function (error) {
       
 23937                     context._clearGeocodedLocation();
       
 23938                 }
       
 23939             });
       
 23940         }
       
 23941     });
       
 23942     return SearchEngine;
       
 23943 }(leaflet, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, CommonControlsSearchEngineDOM, CommonControlsSearchEngineUtils);
       
 23944 CommonControlsElevationPathDOM = function () {
       
 23945     var ElevationPathDOM = {
       
 23946         _addUID: function (id) {
       
 23947             return id + '-' + this._uid;
       
 23948         },
       
 23949         _createMainContainerElement: function () {
       
 23950             var container = document.createElement('div');
       
 23951             container.id = this._addUID('GPelevationPath');
       
 23952             container.className = 'GPwidget';
       
 23953             return container;
       
 23954         },
       
 23955         _createShowElevationPathElement: function () {
       
 23956             var input = document.createElement('input');
       
 23957             input.id = this._addUID('GPshowElevationPath');
       
 23958             input.type = 'checkbox';
       
 23959             return input;
       
 23960         },
       
 23961         _createShowElevationPathPictoElement: function () {
       
 23962             var context = this;
       
 23963             var label = document.createElement('label');
       
 23964             label.id = this._addUID('GPshowElevationPathPicto');
       
 23965             label.className = 'GPshowAdvancedToolPicto';
       
 23966             label.htmlFor = this._addUID('GPshowElevationPath');
       
 23967             label.title = 'Calculer un profil';
       
 23968             if (label.addEventListener) {
       
 23969                 label.addEventListener('click', function (e) {
       
 23970                     context.onShowElevationPathClick(e);
       
 23971                 });
       
 23972             } else if (label.attachEvent) {
       
 23973                 label.attachEvent('onclick', function (e) {
       
 23974                     context.onShowElevationPathClick(e);
       
 23975                 });
       
 23976             }
       
 23977             var spanOpen = document.createElement('span');
       
 23978             spanOpen.id = this._addUID('GPshowElevationPathOpen');
       
 23979             spanOpen.className = 'GPshowAdvancedToolOpen';
       
 23980             label.appendChild(spanOpen);
       
 23981             return label;
       
 23982         },
       
 23983         _createElevationPathPanelElement: function () {
       
 23984             var div = document.createElement('div');
       
 23985             div.id = this._addUID('GPelevationPathPanel');
       
 23986             div.className = 'GPpanel';
       
 23987             return div;
       
 23988         },
       
 23989         _createElevationPathPanelHeaderElement: function () {
       
 23990             var self = this;
       
 23991             var container = document.createElement('div');
       
 23992             container.className = 'GPpanelHeader';
       
 23993             var div = document.createElement('div');
       
 23994             div.className = 'GPpanelTitle';
       
 23995             div.innerHTML = 'Profil Altimétrique';
       
 23996             container.appendChild(div);
       
 23997             var divReduce = document.createElement('div');
       
 23998             divReduce.id = this._addUID('GPelevationPathPanelReduce');
       
 23999             divReduce.className = 'GPpanelReduce';
       
 24000             divReduce.title = 'Masquer le panneau';
       
 24001             if (divReduce.addEventListener) {
       
 24002                 divReduce.addEventListener('click', function () {
       
 24003                     if (typeof self.onReduceElevationPathPanelClick === 'function') {
       
 24004                         document.getElementById(self._addUID('GPshowElevationPath')).checked = false;
       
 24005                         self.onReduceElevationPathPanelClick();
       
 24006                     }
       
 24007                 }, false);
       
 24008             } else if (divReduce.attachEvent) {
       
 24009                 divReduce.attachEvent('onclick', function () {
       
 24010                     if (typeof self.onReduceElevationPathPanelClick === 'function') {
       
 24011                         document.getElementById(self._addUID('GPshowElevationPath')).checked = false;
       
 24012                         self.onReduceElevationPathPanelClick();
       
 24013                     }
       
 24014                 });
       
 24015             }
       
 24016             container.appendChild(divReduce);
       
 24017             var divClose = document.createElement('div');
       
 24018             divClose.id = this._addUID('GPelevationPathPanelClose');
       
 24019             divClose.className = 'GPpanelClose';
       
 24020             divClose.title = 'Fermer le panneau';
       
 24021             if (divClose.addEventListener) {
       
 24022                 divClose.addEventListener('click', function () {
       
 24023                     document.getElementById(self._addUID('GPshowElevationPathPicto')).click();
       
 24024                 }, false);
       
 24025             } else if (divClose.attachEvent) {
       
 24026                 divClose.attachEvent('onclick', function () {
       
 24027                     document.getElementById(self._addUID('GPshowElevationPathPicto')).click();
       
 24028                 });
       
 24029             }
       
 24030             container.appendChild(divClose);
       
 24031             return container;
       
 24032         },
       
 24033         _createElevationPathPanelProfilElement: function () {
       
 24034             var div = document.createElement('div');
       
 24035             div.id = 'GPelevationPathProfil';
       
 24036             return div;
       
 24037         },
       
 24038         _createElevationPathWaitingElement: function () {
       
 24039             var div = document.createElement('div');
       
 24040             div.id = this._addUID('GPelevationPathCalcWaitingContainer');
       
 24041             div.className = 'GPelevationPathCalcWaitingContainerHidden';
       
 24042             var p = document.createElement('p');
       
 24043             p.className = 'GPelevationPathCalcWaiting';
       
 24044             p.innerHTML = 'Calcul en cours...';
       
 24045             div.appendChild(p);
       
 24046             return div;
       
 24047         }
       
 24048     };
       
 24049     return ElevationPathDOM;
       
 24050 }();
       
 24051 LeafletControlsElevationPath = function (L, P, woodman, Gp, RightManagement, ID, LocationSelector, PositionFormater, IconDefault, ElevationPathDOM) {
       
 24052     var ElevationPath = L.Control.extend({
       
 24053         includes: ElevationPathDOM,
       
 24054         options: {
       
 24055             position: 'topleft',
       
 24056             active: false,
       
 24057             elevationPathOptions: {},
       
 24058             stylesOptions: {},
       
 24059             displayProfileOptions: {
       
 24060                 apply: null,
       
 24061                 target: null
       
 24062             }
       
 24063         },
       
 24064         initialize: function (options) {
       
 24065             L.Util.setOptions(this, options);
       
 24066             this._uid = ID.generate();
       
 24067             this._initDisplayProfileOptions();
       
 24068             this._showContainer = null;
       
 24069             this._pictoContainer = null;
       
 24070             this._panelContainer = null;
       
 24071             this._profilContainer = null;
       
 24072             this._waitingContainer = null;
       
 24073             this._reducePanel = false;
       
 24074             this._featuresLayer = null;
       
 24075             this._lastIdLayer = 0;
       
 24076             this._currentIdLayer = 0;
       
 24077             this._currentFeature = null;
       
 24078             this._profile = null;
       
 24079             this._marker = null;
       
 24080             this._geometry = null;
       
 24081             this._noRightManagement = false;
       
 24082             this._checkRightsManagement();
       
 24083         },
       
 24084         onAdd: function (map) {
       
 24085             var container = this._container = this._initLayout();
       
 24086             if (map) {
       
 24087                 if (this.options.active) {
       
 24088                     if (this._profile === null) {
       
 24089                         this._panelContainer.style.display = 'none';
       
 24090                     }
       
 24091                     this._activateMapInteraction(map);
       
 24092                 }
       
 24093             }
       
 24094             L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container);
       
 24095             return container;
       
 24096         },
       
 24097         onRemove: function () {
       
 24098         },
       
 24099         _checkRightsManagement: function () {
       
 24100             var rightManagement = RightManagement.check({
       
 24101                 key: this.options.apiKey,
       
 24102                 resources: ['SERVICE_CALCUL_ALTIMETRIQUE_RSC'],
       
 24103                 services: ['ElevationLine']
       
 24104             });
       
 24105             if (!rightManagement) {
       
 24106                 this._noRightManagement = true;
       
 24107             }
       
 24108             if (!this.options.apiKey) {
       
 24109                 this.options.apiKey = rightManagement.key;
       
 24110             }
       
 24111         },
       
 24112         _initDisplayProfileOptions: function () {
       
 24113             var profil = this.options.displayProfileOptions || {};
       
 24114             if (typeof profil === 'undefined' || Object.keys(profil).length === 0) {
       
 24115                 this.options.displayProfileOptions = {
       
 24116                     apply: ElevationPath.DISPLAY_PROFILE_BY_DEFAULT,
       
 24117                     target: null
       
 24118                 };
       
 24119             } else {
       
 24120                 this.options.displayProfileOptions = {};
       
 24121             }
       
 24122             var displayFunction = profil.apply || this.options.displayProfileOptions.apply;
       
 24123             this.options.displayProfileOptions.apply = typeof displayFunction === 'function' ? displayFunction : ElevationPath.DISPLAY_PROFILE_BY_DEFAULT;
       
 24124             var displayContainer = profil.target || this.options.displayProfileOptions.target;
       
 24125             this.options.displayProfileOptions.target = typeof displayContainer === 'undefined' ? null : displayContainer;
       
 24126         },
       
 24127         _initLayout: function () {
       
 24128             var container = this._createMainContainerElement();
       
 24129             var inputShow = this._showContainer = this._createShowElevationPathElement();
       
 24130             container.appendChild(inputShow);
       
 24131             if (this.options.active) {
       
 24132                 this._showContainer.checked = true;
       
 24133             }
       
 24134             var picto = this._pictoContainer = this._createShowElevationPathPictoElement();
       
 24135             container.appendChild(picto);
       
 24136             var panel = this._panelContainer = this._createElevationPathPanelElement();
       
 24137             var header = this._createElevationPathPanelHeaderElement();
       
 24138             panel.appendChild(header);
       
 24139             var profil = this._profilContainer = this._createElevationPathPanelProfilElement();
       
 24140             panel.appendChild(profil);
       
 24141             var waiting = this._waitingContainer = this._createElevationPathWaitingElement();
       
 24142             panel.appendChild(waiting);
       
 24143             container.appendChild(panel);
       
 24144             return container;
       
 24145         },
       
 24146         onShowElevationPathClick: function (e) {
       
 24147             var map = this._map;
       
 24148             if (!this._reducePanel) {
       
 24149                 if (this._showContainer.checked) {
       
 24150                     this._pictoContainer.style.display = 'block';
       
 24151                     this._panelContainer.style.display = 'none';
       
 24152                     this._removeMapInteraction(map);
       
 24153                     this._clear();
       
 24154                 } else {
       
 24155                     if (this._profile === null) {
       
 24156                         this._panelContainer.style.display = 'none';
       
 24157                     }
       
 24158                     this._activateMapInteraction(map);
       
 24159                 }
       
 24160             } else {
       
 24161                 if (this._profile !== null) {
       
 24162                     if (this.options.displayProfileOptions.target === null) {
       
 24163                         this._pictoContainer.style.display = 'none';
       
 24164                     }
       
 24165                     this._panelContainer.style.display = 'block';
       
 24166                 }
       
 24167             }
       
 24168             this._reducePanel = false;
       
 24169         },
       
 24170         onReduceElevationPathPanelClick: function () {
       
 24171             this._reducePanel = true;
       
 24172             this._pictoContainer.style.display = 'block';
       
 24173             this._panelContainer.style.display = 'none';
       
 24174         },
       
 24175         _activateMapInteraction: function (map) {
       
 24176             if (this._featuresLayer === null) {
       
 24177                 this._featuresLayer = new L.FeatureGroup();
       
 24178                 map.addLayer(this._featuresLayer);
       
 24179                 var self = this;
       
 24180                 map.on('draw:created', function (e) {
       
 24181                     self._currentIdLayer = L.Util.stamp(e.layer);
       
 24182                     self._getFeatureGeometry(e.layer);
       
 24183                     self._addFeatureLayer(e.layer);
       
 24184                 });
       
 24185                 map.on('draw:drawstart', function () {
       
 24186                     self._removeFeatureLayer(self._lastIdLayer);
       
 24187                     self._lastIdLayer = self._currentIdLayer;
       
 24188                 });
       
 24189                 map.on('draw:drawstop', function () {
       
 24190                     if (typeof self.options.elevationPathOptions.onSuccess === 'undefined' && self.options.displayProfileOptions.target === null) {
       
 24191                         self._pictoContainer.style.display = 'none';
       
 24192                         self._panelContainer.style.display = 'block';
       
 24193                     }
       
 24194                     self._altiRequest();
       
 24195                 });
       
 24196             }
       
 24197             this._activatePolyLineInteraction(map);
       
 24198         },
       
 24199         _removeMapInteraction: function (map) {
       
 24200             if (!map) {
       
 24201                 return;
       
 24202             }
       
 24203             if (this._featuresLayer !== null) {
       
 24204                 map.off('draw:created');
       
 24205                 map.off('draw:drawstart');
       
 24206                 map.off('draw:drawstop');
       
 24207                 map.removeLayer(this._featuresLayer);
       
 24208                 this._featuresLayer = null;
       
 24209             }
       
 24210             this._lastIdLayer = this._currentIdLayer = 0;
       
 24211             if (this._currentFeature) {
       
 24212                 this._currentFeature.disable();
       
 24213             }
       
 24214         },
       
 24215         _activatePolyLineInteraction: function (map) {
       
 24216             if (this._currentFeature) {
       
 24217                 this._currentFeature.disable();
       
 24218             }
       
 24219             var styles = this.options.stylesOptions || {};
       
 24220             var _shapeOptions = Object.keys(styles).length !== 0 ? styles : {
       
 24221                 stroke: true,
       
 24222                 color: '#C77A04',
       
 24223                 weight: 4,
       
 24224                 opacity: 0.5,
       
 24225                 fill: false
       
 24226             };
       
 24227             this._currentFeature = new L.Draw.Polyline(map, { shapeOptions: _shapeOptions });
       
 24228             this._currentFeature.enable();
       
 24229         },
       
 24230         _getFeatureGeometry: function (layer) {
       
 24231             if (this._geometry !== null) {
       
 24232                 this._geometry = null;
       
 24233             }
       
 24234             this._geometry = [];
       
 24235             var geometry = layer.getLatLngs();
       
 24236             for (var i = 0; i < geometry.length; i++) {
       
 24237                 var LatLng = geometry[i];
       
 24238                 this._geometry.push({
       
 24239                     lon: LatLng.lng,
       
 24240                     lat: LatLng.lat
       
 24241                 });
       
 24242             }
       
 24243         },
       
 24244         _addFeatureLayer: function (layer) {
       
 24245             if (!this._featuresLayer) {
       
 24246                 return;
       
 24247             }
       
 24248             this._featuresLayer.addLayer(layer);
       
 24249         },
       
 24250         _removeFeatureLayer: function (id) {
       
 24251             if (!this._featuresLayer) {
       
 24252                 return;
       
 24253             }
       
 24254             if (id === 0) {
       
 24255                 return;
       
 24256             }
       
 24257             if (!id) {
       
 24258                 this._featuresLayer.clearLayers();
       
 24259             } else {
       
 24260                 this._featuresLayer.removeLayer(id);
       
 24261             }
       
 24262         },
       
 24263         _altiRequest: function () {
       
 24264             if (!this._geometry) {
       
 24265                 return;
       
 24266             }
       
 24267             if (this._noRightManagement) {
       
 24268                 return;
       
 24269             }
       
 24270             var options = {};
       
 24271             L.Util.extend(options, this.options.elevationPathOptions);
       
 24272             L.Util.extend(options, { apiKey: options.apiKey || this.options.apiKey });
       
 24273             var self = this;
       
 24274             L.Util.extend(options, {
       
 24275                 sampling: options.sampling || 200,
       
 24276                 onSuccess: this.options.elevationPathOptions.onSuccess || function (result) {
       
 24277                     if (result) {
       
 24278                         if (self.options.displayProfileOptions.target !== null) {
       
 24279                             self._pictoContainer.style.display = 'block';
       
 24280                             self._panelContainer.style.display = 'block';
       
 24281                         }
       
 24282                         self._displayProfil(result.elevations);
       
 24283                         self._waitingContainer.className = 'GPelevationPathCalcWaitingContainerHidden';
       
 24284                         self._waiting = false;
       
 24285                     }
       
 24286                 },
       
 24287                 onFailure: this.options.elevationPathOptions.onFailure || function (error) {
       
 24288                     self._pictoContainer.style.display = 'block';
       
 24289                     self._panelContainer.style.display = 'none';
       
 24290                     self._waitingContainer.className = 'GPelevationPathCalcWaitingContainerHidden';
       
 24291                     self._waiting = false;
       
 24292                     self._clear();
       
 24293                 }
       
 24294             });
       
 24295             var positions = this._geometry;
       
 24296             L.Util.extend(options, { positions: positions });
       
 24297             this._waitingContainer.className = 'GPelevationPathCalcWaitingContainerVisible';
       
 24298             Gp.Services.getAltitude(options);
       
 24299         },
       
 24300         _computeElevationMeasure: function (elevations) {
       
 24301             var _haversineDistance = function (c1, c2) {
       
 24302                 var lat1 = PositionFormater.decimalToRadian(c1[1]);
       
 24303                 var lat2 = PositionFormater.decimalToRadian(c2[1]);
       
 24304                 var deltaLatBy2 = (lat2 - lat1) / 2;
       
 24305                 var deltaLonBy2 = PositionFormater.decimalToRadian(c2[0] - c1[0]) / 2;
       
 24306                 var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) + Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) * Math.cos(lat1) * Math.cos(lat2);
       
 24307                 return 2 * 6378137 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
       
 24308             };
       
 24309             elevations[0].dist = 0;
       
 24310             var distance = 0;
       
 24311             for (var i = 1; i < elevations.length; i++) {
       
 24312                 distance += _haversineDistance([
       
 24313                     elevations[i].lon,
       
 24314                     elevations[i].lat
       
 24315                 ], [
       
 24316                     elevations[i - 1].lon,
       
 24317                     elevations[i - 1].lat
       
 24318                 ]) / 1000;
       
 24319                 elevations[i].dist = distance;
       
 24320                 elevations[i].lat = Math.round(elevations[i].lat * 10000) / 10000;
       
 24321                 elevations[i].lon = Math.round(elevations[i].lon * 10000) / 10000;
       
 24322             }
       
 24323             var coeffArrond = 100;
       
 24324             if (distance > 100) {
       
 24325                 coeffArrond = 1;
       
 24326             } else if (distance > 10) {
       
 24327                 coeffArrond = 10;
       
 24328             }
       
 24329             for (var j = 0; j < elevations.length; j++) {
       
 24330                 var data = elevations[j];
       
 24331                 if (data.z < 0) {
       
 24332                     data.z = 0;
       
 24333                 }
       
 24334                 data.dist = Math.round(data.dist * coeffArrond) / coeffArrond;
       
 24335             }
       
 24336             return elevations;
       
 24337         },
       
 24338         _displayProfil: function (elevations) {
       
 24339             var data = this._computeElevationMeasure(elevations);
       
 24340             var container = this.options.displayProfileOptions.target;
       
 24341             if (container) {
       
 24342                 container.appendChild(this._panelContainer);
       
 24343             }
       
 24344             container = this._profilContainer;
       
 24345             var context = this;
       
 24346             var displayFunction = this.options.displayProfileOptions.apply;
       
 24347             if (typeof AmCharts !== 'undefined' && typeof d3 !== 'undefined') {
       
 24348             }
       
 24349             displayFunction.call(this, data, container, context);
       
 24350         },
       
 24351         _activateProfilEvent: function (position) {
       
 24352             if (this._profile === null) {
       
 24353                 return;
       
 24354             }
       
 24355             var map = this._map;
       
 24356             var self = this;
       
 24357             if (self._marker) {
       
 24358                 map.removeLayer(self._marker);
       
 24359                 self._marker = null;
       
 24360             }
       
 24361             self._marker = L.marker(L.latLng(position.lat, position.lon), {
       
 24362                 icon: new IconDefault('orange'),
       
 24363                 draggable: false,
       
 24364                 clickable: false,
       
 24365                 zIndexOffset: 1000
       
 24366             });
       
 24367             self._marker.addTo(map);
       
 24368             var changed = function (e) {
       
 24369                 var obj = e.chart.dataProvider[e.index];
       
 24370                 self._marker.setLatLng(L.latLng(obj.lat, obj.lon));
       
 24371                 self._marker.update();
       
 24372             };
       
 24373             self._profile.removeListener('changed', changed);
       
 24374             self._profile.addListener('changed', changed);
       
 24375             var mouseover = function (e) {
       
 24376                 if (self._profile === null) {
       
 24377                     return;
       
 24378                 }
       
 24379                 self._marker = L.marker(L.latLng(position.lat, position.lon), {
       
 24380                     icon: new IconDefault('orange'),
       
 24381                     draggable: false,
       
 24382                     clickable: false,
       
 24383                     zIndexOffset: 1000
       
 24384                 });
       
 24385                 self._marker.addTo(map);
       
 24386             };
       
 24387             var mouseout = function (e) {
       
 24388                 if (self._profile === null) {
       
 24389                     return;
       
 24390                 }
       
 24391                 if (self._marker) {
       
 24392                     map.removeLayer(self._marker);
       
 24393                     self._marker = null;
       
 24394                 }
       
 24395             };
       
 24396             var mousemove = function (e) {
       
 24397                 if (self._profile === null) {
       
 24398                     return;
       
 24399                 }
       
 24400                 if (self._marker) {
       
 24401                     self._marker.setLatLng(L.latLng(e.lat, e.lon));
       
 24402                     self._marker.update();
       
 24403                 }
       
 24404             };
       
 24405         },
       
 24406         _clear: function () {
       
 24407             this._geometry = null;
       
 24408             this._profile = null;
       
 24409             if (this._profilContainer) {
       
 24410                 while (this._profilContainer.firstChild) {
       
 24411                     this._profilContainer.removeChild(this._profilContainer.firstChild);
       
 24412                 }
       
 24413             }
       
 24414             var map = this._map;
       
 24415             if (this._marker) {
       
 24416                 map.removeLayer(this._marker);
       
 24417                 this._marker = null;
       
 24418             }
       
 24419         }
       
 24420     });
       
 24421     ElevationPath.DISPLAY_PROFILE_BY_DEFAULT = function (data, container, context) {
       
 24422         if (container) {
       
 24423             while (container.firstChild) {
       
 24424                 container.removeChild(container.firstChild);
       
 24425             }
       
 24426         }
       
 24427         if (!data) {
       
 24428             return;
       
 24429         }
       
 24430         var sortedElev = JSON.parse(JSON.stringify(data));
       
 24431         sortedElev.sort(function (e1, e2) {
       
 24432             return e1.z - e2.z;
       
 24433         });
       
 24434         var minZ = sortedElev[0].z;
       
 24435         var maxZ = sortedElev[sortedElev.length - 1].z;
       
 24436         var diff = maxZ - minZ;
       
 24437         var dist = data[data.length - 1].dist;
       
 24438         var barwidth = 100 / data.length;
       
 24439         var self = this;
       
 24440         var map = context._map;
       
 24441         var div = document.createElement('div');
       
 24442         div.id = 'profileElevationByDefault';
       
 24443         div.addEventListener('mouseover', function (e) {
       
 24444             var _lon = parseFloat(e.target.dataset['lon']);
       
 24445             var _lat = parseFloat(e.target.dataset['lat']);
       
 24446             if (_lon && _lat) {
       
 24447                 self._marker = L.marker(L.latLng(_lat, _lon), {
       
 24448                     icon: new IconDefault('orange'),
       
 24449                     draggable: false,
       
 24450                     clickable: false,
       
 24451                     zIndexOffset: 1000
       
 24452                 });
       
 24453                 self._marker.addTo(map);
       
 24454             }
       
 24455         });
       
 24456         div.addEventListener('mousemove', function () {
       
 24457         });
       
 24458         div.addEventListener('mouseout', function () {
       
 24459             if (self._marker) {
       
 24460                 map.removeLayer(self._marker);
       
 24461                 self._marker = null;
       
 24462             }
       
 24463         });
       
 24464         container.appendChild(div);
       
 24465         var divZ = document.createElement('div');
       
 24466         divZ.className = 'z-title-vertical';
       
 24467         divZ.innerHTML = minZ + ' / ' + maxZ + ' m';
       
 24468         div.appendChild(divZ);
       
 24469         var ul = document.createElement('ul');
       
 24470         ul.id = 'data-default';
       
 24471         ul.className = 'z-axis x-axis';
       
 24472         div.appendChild(ul);
       
 24473         for (var i = 0; i < data.length; i++) {
       
 24474             var d = data[i];
       
 24475             var li = document.createElement('li');
       
 24476             li.setAttribute('data-z', d.z);
       
 24477             li.setAttribute('data-lon', d.lon);
       
 24478             li.setAttribute('data-lat', d.lat);
       
 24479             li.setAttribute('data-dist', d.dist);
       
 24480             var pct = Math.floor((d.z - minZ) * 100 / diff);
       
 24481             li.setAttribute('class', 'percent v' + pct);
       
 24482             li.title = 'altitude : ' + d.z + 'm';
       
 24483             li.setAttribute('style', 'width: ' + barwidth + '%');
       
 24484             ul.appendChild(li);
       
 24485         }
       
 24486         var divX = document.createElement('div');
       
 24487         divX.className = 'x-title-horizontal';
       
 24488         divX.innerHTML = dist + ' km';
       
 24489         div.appendChild(divX);
       
 24490         context._profile = container;
       
 24491     };
       
 24492     ElevationPath.DISPLAY_PROFILE_RAW = function (data, container, context) {
       
 24493         if (container) {
       
 24494             while (container.firstChild) {
       
 24495                 container.removeChild(container.firstChild);
       
 24496             }
       
 24497         }
       
 24498         var div = document.createElement('textarea');
       
 24499         div.id = 'profilElevationResults';
       
 24500         div.rows = 10;
       
 24501         div.cols = 50;
       
 24502         div.style.width = '100%';
       
 24503         div.innerHTML = JSON.stringify(data, undefined, 4);
       
 24504         container.appendChild(div);
       
 24505         context._profile = container;
       
 24506     };
       
 24507     ElevationPath.DISPLAY_PROFILE_LIB_D3 = function (data, container, context) {
       
 24508         if (typeof d3 === 'undefined') {
       
 24509             console.log('Lib. D3 is not loaded !');
       
 24510             return;
       
 24511         }
       
 24512         if (container) {
       
 24513             while (container.firstChild) {
       
 24514                 container.removeChild(container.firstChild);
       
 24515             }
       
 24516         }
       
 24517         var margin = {
       
 24518             top: 20,
       
 24519             right: 20,
       
 24520             bottom: 30,
       
 24521             left: 40
       
 24522         };
       
 24523         var width = container.clientWidth - margin.left - margin.right;
       
 24524         var height = container.clientHeight - margin.top - margin.bottom;
       
 24525         var x = d3.scale.linear().range([
       
 24526             0,
       
 24527             width
       
 24528         ]);
       
 24529         var y = d3.scale.linear().range([
       
 24530             height,
       
 24531             0
       
 24532         ]);
       
 24533         var xAxis = d3.svg.axis().scale(x).orient('bottom').ticks(5);
       
 24534         var yAxis = d3.svg.axis().scale(y).orient('left').ticks(5);
       
 24535         var line = d3.svg.line().interpolate('basis').x(function (d) {
       
 24536             return x(d.dist);
       
 24537         }).y(function (d) {
       
 24538             return y(d.z);
       
 24539         });
       
 24540         var area = d3.svg.area().interpolate('basis').x(function (d) {
       
 24541             return x(d.dist);
       
 24542         }).y0(height).y1(function (d) {
       
 24543             return y(d.z);
       
 24544         });
       
 24545         var svg = d3.select(container).append('svg').attr('width', width + margin.left + margin.right).attr('height', height + margin.top + margin.bottom).append('g').attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
       
 24546         var xDomain = d3.extent(data, function (d) {
       
 24547             return d.dist;
       
 24548         });
       
 24549         x.domain(xDomain);
       
 24550         var yDomain = [
       
 24551             0,
       
 24552             d3.max(data, function (d) {
       
 24553                 return d.z;
       
 24554             })
       
 24555         ];
       
 24556         y.domain(yDomain);
       
 24557         svg.append('path').datum(data).attr('class', 'area-d3').attr('d', area);
       
 24558         svg.append('g').attr('class', 'x axis-d3').attr('transform', 'translate(0,' + height + ')').call(xAxis).append('text').attr('y', -15).attr('dy', '.71em').attr('x', width).text('Distance (km)');
       
 24559         svg.append('g').attr('class', 'y axis-d3').call(yAxis).append('text').attr('transform', 'rotate(-90)').attr('y', 6).attr('dy', '.71em').text('Altitude (m)');
       
 24560         svg.append('g').attr('class', 'grid-d3 vertical').attr('transform', 'translate(0,' + height + ')').call(xAxis.orient('bottom').tickSize(-height, 0, 0).tickFormat(''));
       
 24561         svg.append('g').attr('class', 'grid-d3 horizontal').call(yAxis.orient('left').tickSize(-width, 0, 0).tickFormat(''));
       
 24562         svg.append('path').datum(data).attr('class', 'line-d3').attr('d', line);
       
 24563         svg.selectAll('circle').data(data).enter().append('circle').attr('cx', function (d) {
       
 24564             return x(d.dist);
       
 24565         }).attr('cy', function (d) {
       
 24566             return y(d.z);
       
 24567         }).attr('r', 0).attr('class', 'circle-d3');
       
 24568         var focus = svg.append('g').style('display', 'none');
       
 24569         focus.append('line').attr('id', 'focusLineX').attr('class', 'focusLine-d3');
       
 24570         focus.append('line').attr('id', 'focusLineY').attr('class', 'focusLine-d3');
       
 24571         focus.append('circle').attr('id', 'focusCircle').attr('r', 4).attr('class', 'circle-d3 focusCircle-d3');
       
 24572         var div = d3.select(container).append('div').attr('class', 'tooltip-d3').style('opacity', 0);
       
 24573         var bisectDist = d3.bisector(function (d) {
       
 24574             return d.dist;
       
 24575         }).left;
       
 24576         var self = this;
       
 24577         var map = context._map;
       
 24578         svg.append('rect').attr('class', 'overlay-d3').attr('width', width).attr('height', height).on('mouseover', function () {
       
 24579             focus.style('display', null);
       
 24580             self._marker = L.marker(L.latLng(data[0].lat, data[0].lon), {
       
 24581                 icon: new IconDefault('orange'),
       
 24582                 draggable: false,
       
 24583                 clickable: false,
       
 24584                 zIndexOffset: 1000
       
 24585             });
       
 24586             self._marker.addTo(map);
       
 24587         }).on('mouseout', function () {
       
 24588             focus.style('display', 'none');
       
 24589             if (self._marker) {
       
 24590                 map.removeLayer(self._marker);
       
 24591                 self._marker = null;
       
 24592             }
       
 24593             div.transition().duration(500).style('opacity', 0);
       
 24594         }).on('mousemove', function () {
       
 24595             var m = d3.mouse(this);
       
 24596             var distance = x.invert(m[0]);
       
 24597             var i = bisectDist(data, distance);
       
 24598             var d0 = data[i - 1];
       
 24599             var d1 = data[i];
       
 24600             var d = distance - d0[0] > d1[0] - distance ? d1 : d0;
       
 24601             var xc = x(d.dist);
       
 24602             var yc = y(d.z);
       
 24603             focus.select('#focusCircle').attr('cx', xc).attr('cy', yc);
       
 24604             focus.select('#focusLineX').attr('x1', xc).attr('y1', y(yDomain[0])).attr('x2', xc).attr('y2', y(yDomain[1]));
       
 24605             focus.select('#focusLineY').attr('x1', x(xDomain[0])).attr('y1', yc).attr('x2', x(xDomain[1])).attr('y2', yc);
       
 24606             self._marker.setLatLng(L.latLng(d.lat, d.lon));
       
 24607             self._marker.update();
       
 24608             div.transition().duration(200).style('opacity', 0.9);
       
 24609             div.html('Alt : ' + d.z + ' m <br/>' + 'Lon : ' + d.lon + ' <br/>' + 'Lat : ' + d.lat).style('left', d3.event.pageX + 'px').style('top', d3.event.pageY - 28 + 'px');
       
 24610         });
       
 24611         context._profile = d3.selectAll('rect.overlay')[0][0];
       
 24612     };
       
 24613     ElevationPath.DISPLAY_PROFILE_LIB_AMCHARTS = function (data, container, context) {
       
 24614         if (typeof AmCharts === 'undefined') {
       
 24615             console.log('Lib. AmCharts is not loaded !');
       
 24616             return;
       
 24617         }
       
 24618         AmCharts.addInitHandler(function () {
       
 24619         });
       
 24620         context._profile = AmCharts.makeChart(container, {
       
 24621             type: 'serial',
       
 24622             pathToImages: 'http://cdn.amcharts.com/lib/3/images/',
       
 24623             categoryField: 'dist',
       
 24624             autoMarginOffset: 0,
       
 24625             marginRight: 10,
       
 24626             marginTop: 10,
       
 24627             startDuration: 0,
       
 24628             color: '#5E5E5E',
       
 24629             fontSize: 10,
       
 24630             theme: 'light',
       
 24631             thousandsSeparator: '',
       
 24632             categoryAxis: {
       
 24633                 color: '#5E5E5E',
       
 24634                 gridPosition: 'start',
       
 24635                 minHorizontalGap: 40,
       
 24636                 tickPosition: 'start',
       
 24637                 title: 'Distance (km)',
       
 24638                 titleColor: '#5E5E5E',
       
 24639                 startOnAxis: true
       
 24640             },
       
 24641             chartCursor: {
       
 24642                 animationDuration: 0,
       
 24643                 bulletsEnabled: true,
       
 24644                 bulletSize: 10,
       
 24645                 categoryBalloonEnabled: false,
       
 24646                 cursorColor: '#F90',
       
 24647                 graphBulletAlpha: 1,
       
 24648                 graphBulletSize: 1,
       
 24649                 zoomable: false
       
 24650             },
       
 24651             trendLines: [],
       
 24652             graphs: [{
       
 24653                     balloonColor: '#CCCCCC',
       
 24654                     balloonText: '<span class=\'altiPathValue\'>[[title]] : [[value]]m</span><br/><span class=\'altiPathCoords\'>(lat: [[lat]] / lon:[[lon]])</span>',
       
 24655                     bullet: 'round',
       
 24656                     bulletAlpha: 0,
       
 24657                     bulletBorderColor: '#FFF',
       
 24658                     bulletBorderThickness: 2,
       
 24659                     bulletColor: '#F90',
       
 24660                     bulletSize: 6,
       
 24661                     hidden: false,
       
 24662                     id: 'AmGraph-1',
       
 24663                     fillAlphas: 0.4,
       
 24664                     fillColors: '#C77A04',
       
 24665                     lineAlpha: 1,
       
 24666                     lineColor: '#C77A04',
       
 24667                     lineThickness: 1,
       
 24668                     title: 'Altitude',
       
 24669                     valueField: 'z'
       
 24670                 }],
       
 24671             guides: [],
       
 24672             valueAxes: [{
       
 24673                     id: 'ValueAxis-1',
       
 24674                     minVerticalGap: 20,
       
 24675                     title: 'Altitude (m)'
       
 24676                 }],
       
 24677             allLabel: [],
       
 24678             balloon: {
       
 24679                 borderColor: '#CCCCCC',
       
 24680                 borderThickness: 1,
       
 24681                 fillColor: '#FFFFFF',
       
 24682                 showBullet: true
       
 24683             },
       
 24684             titles: [],
       
 24685             dataProvider: data
       
 24686         });
       
 24687         var _initPosition = data[0];
       
 24688         context._activateProfilEvent(_initPosition);
       
 24689     };
       
 24690     return ElevationPath;
       
 24691 }(leaflet, leafletDraw, {}, gp, CommonUtilsCheckRightManagement, CommonUtilsSelectorID, LeafletControlsLocationSelector, LeafletControlsUtilsPositionFormater, LeafletControlsUtilsIconDefault, CommonControlsElevationPathDOM);
       
 24692 LeafletControlsLogo = function (L) {
       
 24693     var Logo = L.Control.extend({
       
 24694         options: {
       
 24695             position: 'topright',
       
 24696             picto: null,
       
 24697             url: null,
       
 24698             text: null,
       
 24699             size: '30px'
       
 24700         },
       
 24701         initialize: function (options) {
       
 24702             L.setOptions(this, options);
       
 24703         },
       
 24704         onAdd: function () {
       
 24705             var container = L.DomUtil.create('div', 'gp-control-logo', container);
       
 24706             var bLink = this.options.url || this.options.text ? true : false;
       
 24707             var link = null;
       
 24708             if (bLink) {
       
 24709                 link = L.DomUtil.create('a', '', container);
       
 24710                 link.target = '_blank';
       
 24711                 if (this.options.url) {
       
 24712                     link.href = this.options.url;
       
 24713                     this.options.text ? link.title = this.options.text : null;
       
 24714                 }
       
 24715             }
       
 24716             if (bLink && this.options.text) {
       
 24717                 link.text = this.options.text;
       
 24718             }
       
 24719             var bImage = this.options.picto ? true : false;
       
 24720             var image = null;
       
 24721             if (bImage) {
       
 24722                 if (bLink) {
       
 24723                     image = L.DomUtil.create('img', '', link);
       
 24724                 } else {
       
 24725                     image = L.DomUtil.create('img', '', container);
       
 24726                 }
       
 24727                 image.src = this.options.picto;
       
 24728                 if (typeof this.options.size === 'string') {
       
 24729                     image.style.height = image.style.width = this.options.size;
       
 24730                 } else {
       
 24731                     image.style.height = this.options.size.height;
       
 24732                     image.style.width = this.options.size.width;
       
 24733                 }
       
 24734             }
       
 24735             return container;
       
 24736         }
       
 24737     });
       
 24738     return Logo;
       
 24739 }(leaflet);
       
 24740 LeafletControlsControls = function (LayerSwitcher, Isocurve, MousePosition, ReverseGeocoding, Route, SearchEngine, ElevationPath, Logo) {
       
 24741     var Controls = {
       
 24742         LayerSwitcher: function (options) {
       
 24743             return new LayerSwitcher(options);
       
 24744         },
       
 24745         Isocurve: function (options) {
       
 24746             return new Isocurve(options);
       
 24747         },
       
 24748         MousePosition: function (options) {
       
 24749             return new MousePosition(options);
       
 24750         },
       
 24751         ReverseGeocode: function (options) {
       
 24752             return new ReverseGeocoding(options);
       
 24753         },
       
 24754         Route: function (options) {
       
 24755             return new Route(options);
       
 24756         },
       
 24757         SearchEngine: function (options) {
       
 24758             return new SearchEngine(options);
       
 24759         },
       
 24760         ElevationPath: function (options) {
       
 24761             return new ElevationPath(options);
       
 24762         },
       
 24763         Logo: function (options) {
       
 24764             return new Logo(options);
       
 24765         }
       
 24766     };
       
 24767     return Controls;
       
 24768 }(LeafletControlsLayerSwitcher, LeafletControlsIsocurve, LeafletControlsMousePosition, LeafletControlsReverseGeocoding, LeafletControlsRoute, LeafletControlsSearchEngine, LeafletControlsElevationPath, LeafletControlsLogo);
       
 24769 CommonUtilsLayerUtils = function () {
       
 24770     var LayerUtils = {
       
 24771         getZoomLevelFromScaleDenominator: function (scaleDenominator, crs) {
       
 24772             var resolutionsNatives = {};
       
 24773             switch (crs) {
       
 24774             case 'EPSG:2154':
       
 24775                 resolutionsNatives = {
       
 24776                     0: 104579.224549894,
       
 24777                     1: 52277.5323537905,
       
 24778                     2: 26135.4870785954,
       
 24779                     3: 13066.8913818,
       
 24780                     4: 6533.2286041135,
       
 24781                     5: 3266.5595244627,
       
 24782                     6: 1633.2660045974,
       
 24783                     7: 816.629554986,
       
 24784                     8: 408.3139146768,
       
 24785                     9: 204.1567415109,
       
 24786                     10: 102.0783167832,
       
 24787                     11: 51.0391448966,
       
 24788                     12: 25.5195690743,
       
 24789                     13: 12.7597836936,
       
 24790                     14: 6.379891636,
       
 24791                     15: 3.1899457653,
       
 24792                     16: 1.5949728695,
       
 24793                     17: 0.7974864315,
       
 24794                     18: 0.3987432149,
       
 24795                     19: 0.1993716073,
       
 24796                     20: 0.0996858037,
       
 24797                     21: 0.0498429018
       
 24798                 };
       
 24799                 break;
       
 24800             default:
       
 24801                 resolutionsNatives = {
       
 24802                     0: 156543.033928041,
       
 24803                     1: 78271.51696402048,
       
 24804                     2: 39135.758482010235,
       
 24805                     3: 19567.87924100512,
       
 24806                     4: 9783.93962050256,
       
 24807                     5: 4891.96981025128,
       
 24808                     6: 2445.98490512564,
       
 24809                     7: 1222.99245256282,
       
 24810                     8: 611.49622628141,
       
 24811                     9: 305.7481131407048,
       
 24812                     10: 152.8740565703525,
       
 24813                     11: 76.43702828517624,
       
 24814                     12: 38.21851414258813,
       
 24815                     13: 19.10925707129406,
       
 24816                     14: 9.554628535647032,
       
 24817                     15: 4.777314267823516,
       
 24818                     16: 2.388657133911758,
       
 24819                     17: 1.194328566955879,
       
 24820                     18: 0.5971642834779395,
       
 24821                     19: 0.2985821417389697,
       
 24822                     20: 0.1492910708694849,
       
 24823                     21: 0.0746455354347424
       
 24824                 };
       
 24825                 break;
       
 24826             }
       
 24827             var resolution = scaleDenominator * 0.00028;
       
 24828             for (var index in resolutionsNatives) {
       
 24829                 if (resolutionsNatives.hasOwnProperty(index)) {
       
 24830                     if (resolutionsNatives[index] <= resolution) {
       
 24831                         return index;
       
 24832                     }
       
 24833                 }
       
 24834             }
       
 24835             return 0;
       
 24836         },
       
 24837         getAttributions: function (params) {
       
 24838             var zoom = params.zoom;
       
 24839             var attributions = [];
       
 24840             if (params.originators != null && params.visibility) {
       
 24841                 var drawLogo;
       
 24842                 for (var j = 0, jl = params.originators.length; j < jl; j++) {
       
 24843                     drawLogo = true;
       
 24844                     var originator = params.originators[j];
       
 24845                     var constraints = params.originators[j].constraints || [];
       
 24846                     for (var k = 0, kl = constraints.length; k < kl; k++) {
       
 24847                         var constraint = constraints[k];
       
 24848                         drawLogo = true;
       
 24849                         var minZoomLevel = this.getZoomLevelFromScaleDenominator(constraint.maxScaleDenominator, params.crs);
       
 24850                         var maxZoomLevel = this.getZoomLevelFromScaleDenominator(constraint.minScaleDenominator, params.crs);
       
 24851                         if (minZoomLevel && minZoomLevel > zoom) {
       
 24852                             drawLogo = false;
       
 24853                         }
       
 24854                         if (drawLogo && maxZoomLevel && maxZoomLevel < zoom) {
       
 24855                             drawLogo = false;
       
 24856                         }
       
 24857                         var bbox = constraint.bbox;
       
 24858                         if (drawLogo && bbox) {
       
 24859                             drawLogo = false;
       
 24860                             var viewExtent = params.extent;
       
 24861                             if (viewExtent) {
       
 24862                                 var bounds = [
       
 24863                                     bbox.top,
       
 24864                                     bbox.left,
       
 24865                                     bbox.bottom,
       
 24866                                     bbox.right
       
 24867                                 ];
       
 24868                                 if (this.intersects(viewExtent, bounds)) {
       
 24869                                     drawLogo = true;
       
 24870                                     break;
       
 24871                                 }
       
 24872                             }
       
 24873                         }
       
 24874                     }
       
 24875                     if (drawLogo) {
       
 24876                         var logo = originator.logo;
       
 24877                         var url = originator.url;
       
 24878                         var name = originator.name ? originator.name : '';
       
 24879                         var text = originator.attribution;
       
 24880                         var container = document.createElement('div');
       
 24881                         container.className = 'gp-control-attribution';
       
 24882                         var link = null;
       
 24883                         link = document.createElement('a');
       
 24884                         link.className = 'gp-control-attribution-link';
       
 24885                         link.target = '_blank';
       
 24886                         container.appendChild(link);
       
 24887                         if (url) {
       
 24888                             link.href = url;
       
 24889                         }
       
 24890                         var bImage = logo ? true : false;
       
 24891                         var image = null;
       
 24892                         if (bImage) {
       
 24893                             image = document.createElement('img');
       
 24894                             if (link) {
       
 24895                                 image.className = 'gp-control-attribution-image';
       
 24896                                 link.appendChild(image);
       
 24897                             } else {
       
 24898                                 image.className = '';
       
 24899                                 container.appendChild(image);
       
 24900                             }
       
 24901                             image.src = logo;
       
 24902                             image.title = text || name;
       
 24903                             image.style.height = '30px';
       
 24904                             image.style.width = '30px';
       
 24905                         } else {
       
 24906                             if (name) {
       
 24907                                 link.textContent = name;
       
 24908                             } else if (text) {
       
 24909                                 link.textContent = text;
       
 24910                             } else if (url) {
       
 24911                                 link.textContent = url;
       
 24912                             } else {
       
 24913                                 link.textContent = '';
       
 24914                             }
       
 24915                         }
       
 24916                         attributions.push(container.innerHTML + ' ');
       
 24917                     }
       
 24918                 }
       
 24919             }
       
 24920             return attributions;
       
 24921         },
       
 24922         intersects: function (extent1, extent2) {
       
 24923             var intersectsX = extent1[1] <= extent2[3] && extent2[1] <= extent1[3];
       
 24924             var intersectsY = extent1[2] <= extent2[0] && extent2[2] <= extent1[0];
       
 24925             return intersectsX && intersectsY;
       
 24926         }
       
 24927     };
       
 24928     return LayerUtils;
       
 24929 }();
       
 24930 LeafletLayersLayerConfig = function (woodman, Config, Util) {
       
 24931     var LayerConfig = {
       
 24932         get: function (options) {
       
 24933             var params = {};
       
 24934             if (!Config.isConfigLoaded()) {
       
 24935                 return;
       
 24936             }
       
 24937             params = Config.getLayerParams(options.layer, options.service, options.key);
       
 24938             if (!params) {
       
 24939                 return;
       
 24940             }
       
 24941             params.minZoom = Util.getZoomLevelFromScaleDenominator(params.maxScale) || 1;
       
 24942             params.maxZoom = Util.getZoomLevelFromScaleDenominator(params.minScale) || 21;
       
 24943             return params;
       
 24944         }
       
 24945     };
       
 24946     return LayerConfig;
       
 24947 }({}, CommonUtilsConfig, CommonUtilsLayerUtils);
       
 24948 LeafletLayersLayerEvent = function (woodman, LayerUtil) {
       
 24949     var LayerEvent = {
       
 24950         _id: null,
       
 24951         _attributions: [],
       
 24952         _visibility: true,
       
 24953         _originators: [],
       
 24954         isEnable: function (map) {
       
 24955             if (!map.attributionControl) {
       
 24956                 return false;
       
 24957             }
       
 24958             return true;
       
 24959         },
       
 24960         setVisible: function (visibility) {
       
 24961             this._visibility = visibility;
       
 24962         },
       
 24963         getVisible: function () {
       
 24964             return this._visibility;
       
 24965         },
       
 24966         _onRemoveLayer: function (e) {
       
 24967             if (e.layer._geoportal_id != this._geoportal_id) {
       
 24968                 return;
       
 24969             }
       
 24970             this.setVisible(false);
       
 24971         },
       
 24972         _onAddLayer: function (e) {
       
 24973             if (e.layer._geoportal_id != this._geoportal_id) {
       
 24974                 return;
       
 24975             }
       
 24976             this.setVisible(true);
       
 24977         },
       
 24978         _onMoveEndLayer: function (e) {
       
 24979             this.updateAttributions(this._map, this);
       
 24980         },
       
 24981         updateAttributions: function (map) {
       
 24982             if (!this.isEnable(map)) {
       
 24983                 return;
       
 24984             }
       
 24985             this.removeAttributions(map);
       
 24986             this.addAttributions(map);
       
 24987         },
       
 24988         removeAttributions: function (map) {
       
 24989             if (!this.isEnable(map)) {
       
 24990                 return;
       
 24991             }
       
 24992             for (var i = 0; i < this._attributions.length; i++) {
       
 24993                 map.attributionControl.removeAttribution(this._attributions[i]);
       
 24994             }
       
 24995             if (this._attributions) {
       
 24996                 this._attributions = [];
       
 24997             }
       
 24998         },
       
 24999         addAttributions: function (map) {
       
 25000             if (!this.isEnable(map)) {
       
 25001                 return;
       
 25002             }
       
 25003             var topLeft = map.getBounds().getNorthWest();
       
 25004             var bottomRight = map.getBounds().getSouthEast();
       
 25005             var arrayBounds = [
       
 25006                 topLeft.lat,
       
 25007                 topLeft.lng,
       
 25008                 bottomRight.lat,
       
 25009                 bottomRight.lng
       
 25010             ];
       
 25011             var params = {
       
 25012                 extent: arrayBounds,
       
 25013                 zoom: map.getZoom(),
       
 25014                 originators: this._originators,
       
 25015                 visibility: this._visibility
       
 25016             };
       
 25017             var attributionsOriginators = LayerUtil.getAttributions(params);
       
 25018             if (attributionsOriginators && attributionsOriginators.length !== 0) {
       
 25019                 for (var i = 0; i < attributionsOriginators.length; i++) {
       
 25020                     this._attributions.push(attributionsOriginators[i]);
       
 25021                     map.attributionControl.addAttribution(attributionsOriginators[i]);
       
 25022                 }
       
 25023             }
       
 25024         }
       
 25025     };
       
 25026     return LayerEvent;
       
 25027 }({}, CommonUtilsLayerUtils);
       
 25028 LeafletLayersWMS = function (L, Gp, woodman, LayerEvent) {
       
 25029     var WMS = L.TileLayer.WMS.extend({
       
 25030         includes: LayerEvent,
       
 25031         initialize: function (url, options) {
       
 25032             var settings = {};
       
 25033             L.Util.extend(settings, options.paramsWms, options.paramsNative);
       
 25034             L.TileLayer.WMS.prototype.initialize.call(this, Gp.Helper.normalyzeUrl(url, { 'gp-leaflet-ext': '0.8.1' }, false), settings);
       
 25035             this._originators = options.originators;
       
 25036             this._legends = options.legends;
       
 25037             this._metadata = options.metadata;
       
 25038             this._title = options.title;
       
 25039             this._description = options.description;
       
 25040             this._quicklookUrl = options.quicklookUrl;
       
 25041             this._geoportal_id = 0;
       
 25042         },
       
 25043         onAdd: function (map) {
       
 25044             this._map = map;
       
 25045             this._geoportal_id = L.stamp(this);
       
 25046             L.TileLayer.WMS.prototype.onAdd.call(this, map);
       
 25047             this.setVisible(true);
       
 25048             this.updateAttributions(map);
       
 25049             map.on({
       
 25050                 overlayremove: this._onRemoveLayer,
       
 25051                 overlayadd: this._onAddLayer,
       
 25052                 layerremove: this._onRemoveLayer,
       
 25053                 layeradd: this._onAddLayer,
       
 25054                 moveend: this._onMoveEndLayer
       
 25055             }, this);
       
 25056         },
       
 25057         onRemove: function (map) {
       
 25058             this._map = map;
       
 25059             L.TileLayer.prototype.onRemove.call(this, map);
       
 25060             this.setVisible(false);
       
 25061             this.removeAttributions(map);
       
 25062             map.off({
       
 25063                 overlayremove: this._onRemoveLayer,
       
 25064                 overlayadd: this._onAddLayer,
       
 25065                 layerremove: this._onRemoveLayer,
       
 25066                 layeradd: this._onAddLayer,
       
 25067                 moveend: this._onMoveEndLayer
       
 25068             }, this);
       
 25069         },
       
 25070         getTileUrl: function (tilePoint) {
       
 25071             var lstProjEpsgGeographic = ['EPSG:4326'];
       
 25072             var map = this._map;
       
 25073             var tileSize = this.options.tileSize;
       
 25074             var nwPoint = tilePoint.multiplyBy(tileSize);
       
 25075             var sePoint = nwPoint.add([
       
 25076                 tileSize,
       
 25077                 tileSize
       
 25078             ]);
       
 25079             var nw = this._crs.project(map.unproject(nwPoint, tilePoint.z));
       
 25080             var se = this._crs.project(map.unproject(sePoint, tilePoint.z));
       
 25081             var bbox = this._wmsVersion >= 1.3 && lstProjEpsgGeographic.indexOf(this._crs.code) !== -1 ? [
       
 25082                 se.y,
       
 25083                 nw.x,
       
 25084                 nw.y,
       
 25085                 se.x
       
 25086             ].join(',') : [
       
 25087                 nw.x,
       
 25088                 se.y,
       
 25089                 se.x,
       
 25090                 nw.y
       
 25091             ].join(',');
       
 25092             var url = L.Util.template(this._url, { s: this._getSubdomain(tilePoint) });
       
 25093             return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox;
       
 25094         }
       
 25095     });
       
 25096     return WMS;
       
 25097 }(leaflet, gp, {}, LeafletLayersLayerEvent);
       
 25098 LeafletLayersWMTS = function (L, Gp, woodman, LayerEvent) {
       
 25099     var WMTS = L.TileLayer.extend({
       
 25100         includes: LayerEvent,
       
 25101         defaultWmtsParams: {
       
 25102             service: 'WMTS',
       
 25103             request: 'GetTile',
       
 25104             version: '1.0.0',
       
 25105             layer: '',
       
 25106             style: '',
       
 25107             tilematrixset: 'PM',
       
 25108             format: 'image/jpeg'
       
 25109         },
       
 25110         initialize: function (url, options) {
       
 25111             this._wmtsParams = {};
       
 25112             L.Util.extend(this._wmtsParams, this.defaultWmtsParams, options.paramsWmts);
       
 25113             L.TileLayer.prototype.initialize.call(this, Gp.Helper.normalyzeUrl(url, { 'gp-leaflet-ext': '0.8.1' }, false), options.paramsNative);
       
 25114             this._originators = options.originators;
       
 25115             this._legends = options.legends;
       
 25116             this._metadata = options.metadata;
       
 25117             this._title = options.title;
       
 25118             this._description = options.description;
       
 25119             this._quicklookUrl = options.quicklookUrl;
       
 25120             this._geoportal_id = 0;
       
 25121         },
       
 25122         onAdd: function (map) {
       
 25123             this._map = map;
       
 25124             this._geoportal_id = L.stamp(this);
       
 25125             L.TileLayer.prototype.onAdd.call(this, map);
       
 25126             this.setVisible(true);
       
 25127             this.updateAttributions(map);
       
 25128             map.on({
       
 25129                 overlayremove: this._onRemoveLayer,
       
 25130                 overlayadd: this._onAddLayer,
       
 25131                 layerremove: this._onRemoveLayer,
       
 25132                 layeradd: this._onAddLayer,
       
 25133                 moveend: this._onMoveEndLayer
       
 25134             }, this);
       
 25135         },
       
 25136         onRemove: function (map) {
       
 25137             this._map = map;
       
 25138             L.TileLayer.prototype.onRemove.call(this, map);
       
 25139             this.setVisible(false);
       
 25140             this.removeAttributions(map);
       
 25141             map.off({
       
 25142                 overlayremove: this._onRemoveLayer,
       
 25143                 overlayadd: this._onAddLayer,
       
 25144                 layerremove: this._onRemoveLayer,
       
 25145                 layeradd: this._onAddLayer,
       
 25146                 moveend: this._onMoveEndLayer
       
 25147             }, this);
       
 25148         },
       
 25149         getTileUrl: function (tilePoint) {
       
 25150             var zoom = this._getZoomForUrl();
       
 25151             var url = L.Util.template(this._url, { s: this._getSubdomain(tilePoint) });
       
 25152             return url + L.Util.getParamString(this._wmtsParams, url) + '&tilematrix=' + zoom + '&tilerow=' + tilePoint.y + '&tilecol=' + tilePoint.x;
       
 25153         },
       
 25154         setParams: function (params, noRedraw) {
       
 25155             L.extend(this._wmtsParams, params);
       
 25156             if (!noRedraw) {
       
 25157                 this.redraw();
       
 25158             }
       
 25159             return this;
       
 25160         }
       
 25161     });
       
 25162     return WMTS;
       
 25163 }(leaflet, gp, {}, LeafletLayersLayerEvent);
       
 25164 LeafletLayersLayers = function (L, woodman, LayerConfig, WMS, WMTS) {
       
 25165     var Layers = {
       
 25166         options: {},
       
 25167         params: {},
       
 25168         serviceUrl: 'http://localhost?no-rights-found-for=[{layer}]',
       
 25169         _initLogger: function () {
       
 25170         },
       
 25171         _initOptions: function () {
       
 25172             if (!this.options || Object.keys(this.options) === 0) {
       
 25173                 throw new Error('PARAM_MISSING : options !');
       
 25174             }
       
 25175             if (!this.options.layer) {
       
 25176                 throw new Error('PARAM_MISSING : layer !');
       
 25177             }
       
 25178             if (!this.options.apiKey) {
       
 25179                 console.log('PARAM_MISSING : apiKey !');
       
 25180             }
       
 25181         },
       
 25182         _initParams: function (service) {
       
 25183             if (!service) {
       
 25184                 service = 'WMTS';
       
 25185             }
       
 25186             this.params = LayerConfig.get({
       
 25187                 key: this.options.apiKey,
       
 25188                 layer: this.options.layer,
       
 25189                 service: service
       
 25190             });
       
 25191             if (!this.params || Object.keys(this.params) === 0) {
       
 25192                 this.params = {};
       
 25193                 if (!this.options.apiKey) {
       
 25194                     console.log('WARNING PARAM_MISSING : parameter \'apiKey\' is mandatory if the contract key configuration has not been loaded !');
       
 25195                 }
       
 25196             }
       
 25197         },
       
 25198         WMS: function (options, settings) {
       
 25199             this._initLogger();
       
 25200             this.options = options || {};
       
 25201             this._initOptions();
       
 25202             this.settings = settings || {};
       
 25203             this._initParams('WMS');
       
 25204             var serviceUrl = null;
       
 25205             if (this.params.key || this.options.apiKey) {
       
 25206                 serviceUrl = this.params.url || L.Util.template('http://wxs.ign.fr/{key}/geoportail/r/wms', { key: this.params.key || this.options.apiKey });
       
 25207             } else {
       
 25208                 serviceUrl = L.Util.template(this.serviceUrl, { layer: this.options.layer });
       
 25209             }
       
 25210             var paramsWms = {
       
 25211                 layers: this.options.layer,
       
 25212                 styles: this.params.styles || 'normal',
       
 25213                 format: this.params.format || 'image/jpeg',
       
 25214                 version: this.params.version || '1.3.0'
       
 25215             };
       
 25216             var paramsNative = {
       
 25217                 minZoom: this.params.minZoom || 1,
       
 25218                 maxZoom: this.params.maxZoom || 21
       
 25219             };
       
 25220             L.Util.extend(paramsNative, this.settings);
       
 25221             return new WMS(serviceUrl, {
       
 25222                 paramsNative: paramsNative,
       
 25223                 paramsWms: paramsWms,
       
 25224                 originators: this.params.originators || [],
       
 25225                 legends: this.params.legends || [],
       
 25226                 metadata: this.params.metadata || [],
       
 25227                 title: this.params.title || null,
       
 25228                 description: this.params.description || null,
       
 25229                 quicklookUrl: this.params.quicklookUrl || null
       
 25230             });
       
 25231         },
       
 25232         WMTS: function (options, settings) {
       
 25233             this._initLogger();
       
 25234             this.options = options || {};
       
 25235             this._initOptions();
       
 25236             this.settings = settings || {};
       
 25237             this._initParams('WMTS');
       
 25238             var serviceUrl = null;
       
 25239             if (this.params.key || this.options.apiKey) {
       
 25240                 serviceUrl = this.params.url || L.Util.template('http://wxs.ign.fr/{key}/geoportail/wmts', { key: this.params.key || this.options.apiKey });
       
 25241             } else {
       
 25242                 serviceUrl = L.Util.template(this.serviceUrl, { layer: this.options.layer });
       
 25243             }
       
 25244             var paramsWmts = {
       
 25245                 layer: this.options.layer,
       
 25246                 style: this.params.styles || 'normal',
       
 25247                 format: this.params.format || 'image/jpeg',
       
 25248                 version: this.params.version || '1.0.0',
       
 25249                 tilematrixset: this.params.TMSLink || 'PM'
       
 25250             };
       
 25251             var paramsNative = {
       
 25252                 minZoom: this.params.minZoom || 1,
       
 25253                 maxZoom: this.params.maxZoom || 21
       
 25254             };
       
 25255             L.Util.extend(paramsNative, this.settings);
       
 25256             return new WMTS(serviceUrl, {
       
 25257                 paramsNative: paramsNative,
       
 25258                 paramsWmts: paramsWmts,
       
 25259                 originators: this.params.originators || [],
       
 25260                 legends: this.params.legends || [],
       
 25261                 metadata: this.params.metadata || [],
       
 25262                 title: this.params.title || '',
       
 25263                 description: this.params.description || '',
       
 25264                 quicklookUrl: this.params.quicklookUrl || ''
       
 25265             });
       
 25266         }
       
 25267     };
       
 25268     return Layers;
       
 25269 }(leaflet, {}, LeafletLayersLayerConfig, LeafletLayersWMS, LeafletLayersWMTS);
       
 25270 LeafletGpPluginLeaflet = function (L, P, Gp, Controls, ElevationPath, Layers, CRS, Register) {
       
 25271     Gp.leafletExtVersion = '0.8.1';
       
 25272     Gp.leafletExtDate = '2016-12-02';
       
 25273     Gp.Register = Register;
       
 25274     L.geoportalLayer = Layers;
       
 25275     L.geoportalControl = Controls;
       
 25276     L.geoportalControl.ElevationPath.DISPLAY_PROFILE_LIB_D3 = ElevationPath.DISPLAY_PROFILE_LIB_D3;
       
 25277     L.geoportalControl.ElevationPath.DISPLAY_PROFILE_LIB_AMCHARTS = ElevationPath.DISPLAY_PROFILE_LIB_AMCHARTS;
       
 25278     L.geoportalControl.ElevationPath.DISPLAY_PROFILE_RAW = ElevationPath.DISPLAY_PROFILE_RAW;
       
 25279     L.geoportalControl.ElevationPath.DISPLAY_PROFILE_BY_DEFAULT = ElevationPath.DISPLAY_PROFILE_BY_DEFAULT;
       
 25280     L.geoportalCRS = CRS;
       
 25281     L.geoportalCRS.EPSG2154 = CRS.EPSG2154();
       
 25282     L.geoportalCRS.EPSG27572 = CRS.EPSG27572();
       
 25283     L.geoportalCRS.EPSG4326 = CRS.EPSG4326();
       
 25284     return Gp;
       
 25285 }(leaflet, leafletDraw, gp, LeafletControlsControls, LeafletControlsElevationPath, LeafletLayersLayers, LeafletCRSCRS, CommonUtilsRegister);
       
 25286 window.proj4 = proj4;
       
 25287 
       
 25288 return Gp;
       
 25289 }));