Changeset 7972
- Timestamp:
- 09/06/08 13:49:54 (2 years ago)
- Files:
-
- trunk/openlayers/examples/measure.html (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/measure.html
r7970 r7972 95 95 96 96 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 */ 97 110 var dist = 0; 98 111 for (var i = 1; i < geometry.components.length; i++) { … … 100 113 var second = geometry.components[i]; 101 114 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} 104 117 ); 105 118 } … … 118 131 if (map.getProjection() == "EPSG:4326") { 119 132 out += "<br /> Great Circle Distance: " + 120 calcVincenty(geometry).toFixed(3) + " km ";133 calcVincenty(geometry).toFixed(3) + " km *"; 121 134 } 122 135 } else { … … 162 175 </li> 163 176 </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> 164 183 </div> 165 184 </body>
