Batch merge for rc2 of 2.7. 'svn merge -r7967:HEAD from trunk (Closes #1733) (Closes #1489) (Closes #1639) (Closes #1718) (Closes #1723) (Closes #1732) (Closes #1616) (Closes #1722)
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.7@8012 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -92,6 +92,31 @@
|
||||
|
||||
document.getElementById('noneToggle').checked = true;
|
||||
}
|
||||
|
||||
function calcVincenty(geometry) {
|
||||
/**
|
||||
* Note: this function assumes geographic coordinates and
|
||||
* will fail otherwise. OpenLayers.Util.distVincenty takes
|
||||
* two objects representing points with geographic coordinates
|
||||
* and returns the geodesic distance between them (shortest
|
||||
* distance between the two points on an ellipsoid) in *kilometers*.
|
||||
*
|
||||
* It is important to realize that the segments drawn on the map
|
||||
* are *not* geodesics (or "great circle" segments). This means
|
||||
* that in general, the measure returned by this function
|
||||
* will not represent the length of segments drawn on the map.
|
||||
*/
|
||||
var dist = 0;
|
||||
for (var i = 1; i < geometry.components.length; i++) {
|
||||
var first = geometry.components[i-1];
|
||||
var second = geometry.components[i];
|
||||
dist += OpenLayers.Util.distVincenty(
|
||||
{lon: first.x, lat: first.y},
|
||||
{lon: second.x, lat: second.y}
|
||||
);
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
function handleMeasurements(event) {
|
||||
var geometry = event.geometry;
|
||||
@@ -102,6 +127,10 @@
|
||||
var out = "";
|
||||
if(order == 1) {
|
||||
out += "measure: " + measure.toFixed(3) + " " + units;
|
||||
if (map.getProjection() == "EPSG:4326") {
|
||||
out += "<br /> Great Circle Distance: " +
|
||||
calcVincenty(geometry).toFixed(3) + " km *";
|
||||
}
|
||||
} else {
|
||||
out += "measure: " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>";
|
||||
}
|
||||
@@ -144,6 +173,12 @@
|
||||
<label for="polygonToggle">measure area</label>
|
||||
</li>
|
||||
</ul>
|
||||
<p>* Note that the geometries drawn are planar geometries and the
|
||||
metrics returned by the measure control are planar measures. The
|
||||
"great circle" distance does not necessarily represent the length
|
||||
of the segments drawn on the map. Instead, it is a geodesic metric that
|
||||
represents the cumulative shortest path between all vertices in the
|
||||
geometry were they projected onto a sphere.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user