Opened 13 years ago

Closed 13 years ago

# Measure: Area is wrong when unit of Map CS is feet

Reported by: Owned by: christinebao Christine Bao P2 Future Widgets 1.1.1 Major Measure Jenny He, arthur.liu@… All 1281984 All Committed

## Description

From Autodesk QA report:

Steps:

1. Open one flexible web layout which Unit of CS is feet.
2. Measure -> Draw one triangle

Check the number of area and the value is wrong.

### comment:1 by christinebao, 13 years ago

Tech diagnosis:
The code for measure area is:

```    updateMarker: function(marker, geom) {
if (!marker) {
return;
}
var quantity, from, to;
var v = geom.getVertices();
var map = this.getMap();
var proj = map.oMapOL.baseLayer.projection;
if (geom.CLASS_NAME.indexOf('LineString') != -1) {
from = this.getMap().geoToPix(v[0].x,v[0].y);
to = this.getMap().geoToPix(v[1].x,v[1].y);
at = {x: (from.x + to.x) / 2, y: (from.y + to.y) / 2};
quantity = geom.getGeodesicLength(proj);

measureUnits = Fusion.METERS;
if (measureUnits != this.units) {
quantity = Fusion.convert(measureUnits, this.units, quantity);
}
} else {
var cg = geom.getCentroid();
at = this.getMap().geoToPix(cg.x, cg.y);
quantity = geom.getGeodesicArea(proj);
//TODO: result is in square meters - convert to other units?
}
if (quantity > 1) {
marker.setQuantity(quantity);
this.positionMarker(marker, at);
}
},
```

Please note: there is a TODO here: result is in square meters - convert to other units?

As the map unit is feet, and length is measured in feed, it's better to convert the area from square meters to square feets.

Add the code to fix this defect:

```           quantity = geom.getGeodesicArea(proj);

measureUnits = Fusion.METERS;
if (measureUnits != this.units) {
var rate = Fusion.convert(measureUnits, this.units, 1);
quantity = quantity * rate * rate;
}
```

In this way, the quantity is coverted to square feets if needed.

### comment:2 by christinebao, 13 years ago

Attach patch http://trac.osgeo.org/fusion/attachment/ticket/343/MeasureArea.patch for fixing this defect. Please review. Thank you!

### comment:3 by liuar, 13 years ago

Reviewed. Please submit the code. Thanks.

### comment:4 by christinebao, 13 years ago

Resolution: → fixed New → Committed new → closed

Commit the patch to fix this defect.

Note: See TracTickets for help on using tickets.