OpenLayers OpenLayers

Changeset 7972

Show
Ignore:
Timestamp:
09/06/08 13:49:54 (2 years ago)
Author:
tschaub
Message:

Adding a bit of explanation about this calcVincenty function, since distVinventy is not documented otherwise.

Files:

Legend:

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

    r7970 r7972  
    9595 
    9696        function calcVincenty(geometry) { 
     97            /** 
     98             * Note: this function assumes geographic coordinates and 
     99             *     will fail otherwise.  Though not documented anywhere, 
     100             *     OpenLayers.Util.distVincenty takes two objects representing 
     101             *     points with geographic coordinates and returns the geodesic 
     102             *     distance between them (shortest distance between the two 
     103             *     points on a sphere) in *kilometers*. 
     104             * 
     105             * It is important to realize that the segments drawn on the map 
     106             *     are *not* geodesics (or "great circle" segments).  This means 
     107             *     that in general, the measure returned by this function 
     108             *     will not represent the length of segments drawn on the map. 
     109             */ 
    97110            var dist = 0; 
    98111            for (var i = 1; i < geometry.components.length; i++) { 
     
    100113                var second = geometry.components[i]; 
    101114                dist += OpenLayers.Util.distVincenty( 
    102                    new OpenLayers.LonLat(first.x, first.y),  
    103                    new OpenLayers.LonLat(second.x, second.y) 
     115                    {lon: first.x, lat: first.y}, 
     116                    {lon: second.x, lat: second.y} 
    104117                ); 
    105118            } 
     
    118131                if (map.getProjection() == "EPSG:4326") { 
    119132                    out += "<br /> Great Circle Distance: " +  
    120                         calcVincenty(geometry).toFixed(3) + " km";  
     133                        calcVincenty(geometry).toFixed(3) + " km *";  
    121134                }         
    122135            } else { 
     
    162175            </li> 
    163176        </ul> 
     177        <p>* Note that the geometries drawn are planar geometries and the 
     178        metrics returned by the measure control are planar measures.  The 
     179        "great circle" distance does not necessarily represent the length 
     180        of the segments drawn on the map.  Instead, it is a geodesic metric that 
     181        represents the cumulative shortest path between all vertices in the 
     182        geometry were they projected onto a sphere.</p> 
    164183    </div> 
    165184  </body>