source: Dev/trunk/src/client/dojox/geo/openlayers/_base.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.2 KB
Line 
1define(["dojo/_base/lang"], function(lang){
2       
3        var openlayers = lang.getObject("dojox.geo.openlayers", true);
4        /*===== openlayers = dojox.geo.openlayers; =====*/
5       
6        openlayers.BaseLayerType = {
7                // summary:
8                //              Defines the base layer types to be used at Map construction time or
9                //              with the setBaseLayerType function.
10                // description:
11                //              This object defines the base layer types to be used at Map construction
12                //              time or with the setBaseLayerType function.
13
14                // OSM: String
15                //              The Open Street Map base layer type selector.
16                OSM: "OSM",
17
18                // WMS: String
19                //              The Web Map Server base layer type selector.
20                WMS: "WMS",
21
22                // GOOGLE: String
23                //              The Google base layer type selector.
24                GOOGLE: "Google",
25
26                // VIRTUAL_EARTH: String
27                //              The Virtual Earth base layer type selector.
28                VIRTUAL_EARTH: "VirtualEarth",
29
30                // BING: String
31                //              Same as Virtual Earth
32                BING: "VirtualEarth",
33
34                // YAHOO: String
35                //              The Yahoo base layer type selector.
36                YAHOO: "Yahoo",
37
38                // ARCGIS: String
39                //              The ESRI ARCGis base layer selector.
40                ARCGIS: "ArcGIS"
41        };
42
43        openlayers.EPSG4326 = new OpenLayers.Projection("EPSG:4326");
44
45        var re = /^\s*(\d{1,3})[D°]\s*(\d{1,2})[M']\s*(\d{1,2}\.?\d*)\s*(S|"|'')\s*([NSEWnsew]{0,1})\s*$/i;
46        openlayers.parseDMS = function(v, toDecimal){
47                // summary:
48                //              Parses the specified string and returns degree minute second or decimal degree.
49                // description:
50                //              Parses the specified string and returns degree minute second or decimal degree.
51                // v: String
52                //              The string to parse
53                // toDecimal: Boolean
54                //              Specifies if the result should be returned in decimal degrees or in an array
55                //              containing the degrees, minutes, seconds values.
56                // returns: Float|Array
57                //              the parsed value in decimal degrees or an array containing the degrees, minutes, seconds values.
58
59                var res = re.exec(v);
60                if(res == null || res.length < 5){
61                        return parseFloat(v);
62                }
63                var d = parseFloat(res[1]);
64                var m = parseFloat(res[2]);
65                var s = parseFloat(res[3]);
66                var nsew = res[5];
67                if(toDecimal){
68                        var lc = nsew.toLowerCase();
69                        var dd = d + (m + s / 60.0) / 60.0;
70                        if(lc == "w" || lc == "s"){
71                                dd = -dd;
72                        }
73                        return dd;
74                }
75                return [d, m, s, nsew];
76        };
77       
78        return openlayers;
79});
Note: See TracBrowser for help on using the repository browser.