OpenLayers OpenLayers

Changeset 99

Show
Ignore:
Timestamp:
05/17/06 11:51:37 (3 years ago)
Author:
euzuro
Message:

Replace all instances and usages of LatLon to LonLat

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/example.html

    r94 r99  
    2121                 
    2222            map.addLayer(layer); 
    23             map.setCenter(new OpenLayers.LatLon(0, 0), 0); 
     23            map.setCenter(new OpenLayers.LonLat(0, 0), 0); 
    2424            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
    2525        } 
  • trunk/openlayers/google.html

    r31 r99  
    2727                {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} ); 
    2828                 
    29             map.setCenter(new OpenLayers.LatLon(lat, lon), zoom); 
     29            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
    3030            map.addLayer(layer); 
    3131            map.addLayer(gmap); 
  • trunk/openlayers/lib/OpenLayers/Control/PanZoom.js

    r51 r99  
    6666                var center = this.map.getCenter(); 
    6767                this.map.setCenter( 
    68                   new OpenLayers.LatLon(center.lat + (resolution * 50),  
    69                                         center.lon 
    70                                        ) 
    71                                   ); 
     68                  new OpenLayers.LonLat(center.lon,  
     69                                        center.lat + (resolution * 50)) 
     70                                       ); 
    7271                break; 
    7372            case "pandown":  
     
    7574                var center = this.map.getCenter(); 
    7675                this.map.setCenter( 
    77                   new OpenLayers.LatLon(center.lat - (resolution * 50),  
    78                                         center.lon 
    79                                        ) 
    80                                   ); 
     76                  new OpenLayers.LonLat(center.lon, 
     77                                        center.lat - (resolution * 50)) 
     78                                       ); 
    8179                break; 
    8280            case "panleft":  
     
    8482                var center = this.map.getCenter(); 
    8583                this.map.setCenter( 
    86                   new OpenLayers.LatLon(center.lat,  
    87                                         center.lon - (resolution * 50) 
    88                                        ) 
    89                                   ); 
     84                  new OpenLayers.LonLat(center.lon - (resolution * 50),  
     85                                        center.lat) 
     86                                       ); 
    9087                break; 
    9188            case "panright":  
     
    9390                var center = this.map.getCenter(); 
    9491                this.map.setCenter( 
    95                   new OpenLayers.LatLon(center.lat,  
    96                                         center.lon + (resolution * 50) 
    97                                        ) 
    98                                   ); 
     92                  new OpenLayers.LonLat(center.lon + (resolution * 50), 
     93                                        center.lat) 
     94                                       ); 
    9995                break; 
    10096            case "zoomin": this.map.zoomIn(); break; 
  • trunk/openlayers/lib/OpenLayers/Map.js

    r93 r99  
    4646    controls: null, 
    4747 
    48     // OpenLayers.LatLon 
     48    // OpenLayers.LonLat 
    4949    center: null, 
    5050 
     
    173173 
    174174    /** 
    175     * @return {OpenLayers.LatLon
     175    * @return {OpenLayers.LonLat
    176176    */ 
    177177    getCenter: function () { 
     
    220220    * @param {OpenLayers.Pixel} point 
    221221    * 
    222     * @return {OpenLayers.LatLon}  
    223     */ 
    224     getLatLonFromPixel: function (point) { 
     222    * @return {OpenLayers.LonLat}  
     223    */ 
     224    getLonLatFromPixel: function (point) { 
    225225        var center = this.getCenter();        //map center lat/lon 
    226226        var res  = this.getResolution(); 
     
    230230        var delta_y = point.y - (size.h / 2); 
    231231         
    232         return new OpenLayers.LatLon(  
    233             center.lat - delta_y * res,  
    234             center.lon + delta_x * res ); 
    235     }, 
    236  
    237     /** 
    238     * @param {OpenLayers.LatLon} latlon 
     232        return new OpenLayers.LonLat(center.lon + delta_x * res , 
     233                                     center.lat - delta_y * res);  
     234    }, 
     235 
     236    /** 
     237    * @param {OpenLayers.LonLat} lonlat 
    239238    * @param {int} zoom 
    240239    */ 
    241     setCenter: function (latlon, zoom) { 
     240    setCenter: function (lonlat, zoom) { 
    242241        if (this.center) { // otherwise there's nothing to move yet 
    243             this.moveLayerContainer(latlon); 
    244         } 
    245         this.center = latlon.copyOf(); 
     242            this.moveLayerContainer(lonlat); 
     243        } 
     244        this.center = lonlat.copyOf(); 
    246245        var zoomChanged = null; 
    247246        if (zoom != null && zoom != this.zoom  
     
    309308        this.zoom = this.getZoomForExtent( fullExtent ); 
    310309        this.setCenter( 
    311           new OpenLayers.LatLon( 
    312             (fullExtent.minlat+fullExtent.maxlat)/2,  
    313             (fullExtent.minlon+fullExtent.maxlon)/2 
    314           ) 
    315         ); 
    316     }, 
    317  
    318     /** 
    319     * @param {OpenLayers.LatLon} latlon 
    320     */ 
    321     moveLayerContainer: function (latlon) { 
     310          new OpenLayers.LonLat((fullExtent.minlon+fullExtent.maxlon)/2, 
     311                                (fullExtent.minlat+fullExtent.maxlat)/2) 
     312                               ); 
     313    }, 
     314 
     315    /** 
     316    * @param {OpenLayers.LonLat} lonlat 
     317    */ 
     318    moveLayerContainer: function (lonlat) { 
    322319        var container = this.layerContainerDiv; 
    323320        var resolution = this.getResolution(); 
    324321 
    325         var deltaX = Math.round((this.center.lon - latlon.lon) / resolution); 
    326         var deltaY = Math.round((this.center.lat - latlon.lat) / resolution); 
     322        var deltaX = Math.round((this.center.lon - lonlat.lon) / resolution); 
     323        var deltaY = Math.round((this.center.lat - lonlat.lat) / resolution); 
    327324      
    328325        var offsetLeft = parseInt(container.style.left); 
     
    337334    */ 
    338335    defaultDblClick: function (evt) { 
    339         var newCenter = this.getLatLonFromPixel( evt.xy );  
     336        var newCenter = this.getLonLatFromPixel( evt.xy );  
    340337        this.setCenter(newCenter, this.zoom + 1); 
    341338    }, 
     
    360357            var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, 
    361358                                             size.h / 2 + deltaY); 
    362             var newCenter = this.getLatLonFromPixel( newXY );  
     359            var newCenter = this.getLonLatFromPixel( newXY );  
    363360            this.setCenter(newCenter); 
    364361            this.mouseDragStart = evt.xy.copyOf(); 
  • trunk/openlayers/lib/OpenLayers/Marker.js

    r89 r99  
    22OpenLayers.Marker.prototype = { 
    33     
    4     // icon: {OpenLayers.Icon} for marker 
     4    /** @type OpenLayers.Icon */ 
    55    icon: null, 
    66 
    7     // latlon: {OpenLayers.LatLon} location of object 
    8     latlon: null, 
    9      
     7    /** location of object 
     8    * @type OpenLayers.LonLat */ 
     9    lonlat: null, 
    1010     
    1111    /** the data object associated with the marker 
     
    1313    data: null, 
    1414     
    15     // events 
     15    /** @type */ 
    1616    events: null, 
    1717     
    18     // map 
     18    /** @type OpenLayers.Map */ 
    1919    map: null, 
    2020     
    21     initialize: function(icon, latlon) { 
     21 
     22    /**  
     23    * @param {OpenLayers.Icon} icon 
     24    * @param {OpenLayers.LonLat lonlat 
     25    */ 
     26    initialize: function(icon, lonlat) { 
    2227        this.icon = icon; 
    23         this.latlon = latlon
     28        this.lonlat = lonlat
    2429    }, 
    2530 
     31    /** 
     32    */ 
    2633    draw: function() { 
    2734        var resolution = this.map.getResolution(); 
    2835        var extent = this.map.getExtent(); 
    29         if (this.latlon.lat > extent.minlat &&  
    30                this.latlon.lat < extent.maxlat && 
    31                this.lonlon.lon > extent.minlon &&  
    32                this.lonlon.lon < extent.maxlon) { 
     36        if ( (this.lonlat.lat > extent.minlat) 
     37             && (this.lonlat.lat < extent.maxlat) 
     38             && (this.lonlat.lon > extent.minlon) 
     39             && (this.lonlat.lon < extent.maxlon)) { 
     40 
    3341            var pixel = new OpenLayers.Pixel( 
    34                           resolution * (this.latlon.lon - extent.minlon), 
    35                           resolution * (extent.maxlat - this.latlon.lat) 
     42                          resolution * (this.lonlat.lon - extent.minlon), 
     43                          resolution * (extent.maxlat - this.lonlat.lat) 
    3644                          ); 
    3745            // need to account for how much layer has moved... 
  • trunk/openlayers/lib/OpenLayers/Tile.js

    r52 r99  
    2525    /** 
    2626    * @param {OpenLayers.Layer} layer 
    27     * @param {OpenLayers.LatLon} coord 
     27    * @param {OpenLayers.LonLat} coord 
    2828    */    
    2929    initialize: function(bounds,url,size) { 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r95 r99  
    149149* @class This class represents a latitude and longitude pair 
    150150*/ 
    151 OpenLayers.LatLon = Class.create(); 
    152 OpenLayers.LatLon.prototype = { 
     151OpenLayers.LonLat = Class.create(); 
     152OpenLayers.LonLat.prototype = { 
    153153 
    154154    /** 
     
    158158    * @param {float} lon 
    159159    */ 
    160     initialize: function(lat, lon) { 
     160    initialize: function(lon, lat) { 
    161161        this.lat = lat; 
    162162        this.lon = lon; 
     
    164164     
    165165    /**  
    166     * @return String representation of OpenLayers.LatLon object.  
     166    * @return String representation of OpenLayers.LonLat object.  
    167167    *         (ex. "lat=42,lon=5") 
    168168    * @type String 
    169169    */ 
    170170    toString:function() { 
    171         return ("lat=" + this.lat + ",lon=" + this.lon); 
    172     }, 
    173  
    174     /**  
    175     * @return Shortened String representation of OpenLayers.LatLon object.  
     171        return ("lon=" + this.lon + ",lat=" + this.lat); 
     172    }, 
     173 
     174    /**  
     175    * @return Shortened String representation of OpenLayers.LonLat object.  
    176176    *         (ex. "42,5") 
    177177    * @type String 
    178178    */ 
    179179    toShortString:function() { 
    180         return (this.lat + ", " + this.lon); 
    181     }, 
    182  
    183     /**  
    184     * @return New OpenLayers.LatLon object with the same lat and lon values 
    185     * @type OpenLayers.LatLon 
     180        return (this.lon + ", " + this.lat); 
     181    }, 
     182 
     183    /**  
     184    * @return New OpenLayers.LonLat object with the same lat and lon values 
     185    * @type OpenLayers.LonLat 
    186186    */ 
    187187    copyOf:function() { 
    188         return new OpenLayers.LatLon(this.lat, this.lon); 
    189     }, 
    190  
    191     /**  
    192     * @param {OpenLayers.LatLon} ll 
    193     * 
    194     * @return a LatLon object with the difference between the two coords 
     188        return new OpenLayers.LonLat(this.lon, this.lat); 
     189    }, 
     190 
     191    /**  
     192    * @param {OpenLayers.LonLat} ll 
     193    * 
     194    * @return an OpenLayers.LonLat object with the difference between the two coords 
    195195    * @type OpenLayers.Pixel 
    196196    */ 
    197197    diff:function(ll) { 
    198         return new OpenLayers.LatLon(this.lat - ll.lat, this.lon - ll.lon); 
    199     }, 
    200  
    201     /**  
    202     * @param {OpenLayers.LatLon} ll 
    203     * @returns Boolean value indicating whether the passed-in OpenLayers.LatLon 
     198        return new OpenLayers.LonLat(this.lon - ll.lon, this.lat - ll.lat); 
     199    }, 
     200 
     201    /**  
     202    * @param {OpenLayers.LonLat} ll 
     203    * @returns Boolean value indicating whether the passed-in OpenLayers.LonLat 
    204204    *          object has the same lat and lon components as this 
    205205    * 
     
    211211     
    212212    /** @type String */ 
    213     CLASS_NAME: "OpenLayers.LatLon
    214 }; 
    215  
    216 /** Alternative constructor that builds a new OpenLayers.LatLon from a  
     213    CLASS_NAME: "OpenLayers.LonLat
     214}; 
     215 
     216/** Alternative constructor that builds a new OpenLayers.LonLat from a  
    217217*    parameter string 
    218218*  
    219219* @constructor 
    220220*  
    221 * @param {String} str Comma-separated coordinate string. (ex. "40,5") 
    222 * 
    223 * @returns New OpenLayers.LatLon object built from the passed-in String. 
    224 * @type OpenLayers.LatLon 
    225 */ 
    226 OpenLayers.LatLon.fromString = function(str) { 
     221* @param {String} str Comma-separated Lon,Lat coordinate string. (ex. "5,40") 
     222* 
     223* @returns New OpenLayers.LonLat object built from the passed-in String. 
     224* @type OpenLayers.LonLat 
     225*/ 
     226OpenLayers.LonLat.fromString = function(str) { 
    227227    var pair = str.split(","); 
    228     return new OpenLayers.LatLon(pair[1], pair[0]); 
     228    return new OpenLayers.LonLat(pair[0], pair[1]); 
    229229}; 
    230230 
  • trunk/openlayers/tests/list-tests.html

    r98 r99  
    11<ul id="testlist"> 
    2     <li>test_LatLon.html</li> 
     2    <li>test_LonLat.html</li> 
    33    <li>test_Pixel.html</li> 
    44    <li>test_Icon.html</li> 
  • trunk/openlayers/tests/test_LonLat.html

    r22 r99  
    33  <script src="../lib/OpenLayers.js"></script> 
    44  <script type="text/javascript"><!-- 
    5     var latlon;  
    6     function test_01_LatLon_constructor (t) { 
     5    var lonlat;  
     6    function test_01_LonLat_constructor (t) { 
    77    t.plan( 3 ); 
    8         latlon = new OpenLayers.LatLon(5,6); 
    9         t.ok( latlon instanceof OpenLayers.LatLon, "new OpenLayers.LatLon returns LatLon object" ); 
    10         t.eq( latlon.lat, 5, "latlon.lat is set correctly"); 
    11         t.eq( latlon.lon, 6, "latlon.lon is set correctly"); 
     8        lonlat = new OpenLayers.LonLat(6, 5); 
     9        t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" ); 
     10        t.eq( lonlat.lat, 5, "lonlat.lat is set correctly"); 
     11        t.eq( lonlat.lon, 6, "lonlat.lon is set correctly"); 
    1212    } 
    1313  // --> 
  • trunk/openlayers/tests/test_Map.html

    r66 r99  
    2424        t.plan(5); 
    2525        map = new OpenLayers.Map($('map')); 
    26         map.setCenter(new OpenLayers.LatLon(1,2), 0); 
    27         t.ok( map.getCenter() instanceof OpenLayers.LatLon, "map.getCenter returns a LatLon"); 
     26        map.setCenter(new OpenLayers.LonLat(2,1), 0); 
     27        t.ok( map.getCenter() instanceof OpenLayers.LonLat, "map.getCenter returns a LonLat"); 
    2828        t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter"); 
    2929        t.eq( map.getResolution(), map.maxResolution, "map.getResolution() == map.maxResolution"); 
     
    5757        t.plan(4); 
    5858        map = new OpenLayers.Map($('map')); 
    59         map.setCenter(new OpenLayers.LatLon(1,2), 0); 
     59        map.setCenter(new OpenLayers.LonLat(2, 1), 0); 
    6060        map.zoomIn(); 
    6161        t.eq( map.getZoom(), 1, "map.zoom is correct after calling setCenter,zoom in"); 
     
    7272            t.ok(true, "zoomend event was triggered " + this.count + " times"); 
    7373            }); 
    74         map.setCenter(new OpenLayers.LatLon(1,2), 0); 
     74        map.setCenter(new OpenLayers.LonLat(2, 1), 0); 
    7575        map.zoomIn(); 
    7676        map.zoomOut(); 
  • trunk/openlayers/tests/test_Marker.html

    r87 r99  
    77    function test_01_Marker_constructor (t) { 
    88        t.plan( 5 ); 
    9         marker = new OpenLayers.Marker(new OpenLayers.Icon(),new OpenLayers.LatLon(1,2)); 
     9        marker = new OpenLayers.Marker(new OpenLayers.Icon(),new OpenLayers.LonLat(2,1)); 
    1010        t.ok( marker instanceof OpenLayers.Marker, "new OpenLayers.Marker returns Marker object" ); 
    1111        t.ok( marker.icon instanceof OpenLayers.Icon, "new marker.Icon returns Icon object" ); 
    12         t.ok( marker.latlon instanceof OpenLayers.LatLon, "new marker.latlon returns LatLon object" ); 
    13         t.eq( marker.latlon.lat, 1, "marker.latlon.lat returns correct lat" ); 
    14         t.eq( marker.latlon.lon, 2, "marker.latlon.lon returns correct lon" ); 
     12        t.ok( marker.lonlat instanceof OpenLayers.LonLat, "new marker.lonlat returns LonLat object" ); 
     13        t.eq( marker.lonlat.lat, 1, "marker.lonlat.lat returns correct lat" ); 
     14        t.eq( marker.lonlat.lon, 2, "marker.lonlat.lon returns correct lon" ); 
    1515    } 
    1616