Opened 12 years ago

Closed 12 years ago

#343 closed defect (fixed)

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

Reported by: christinebao Owned by: Christine Bao
Priority: P2 Milestone: Future
Component: Widgets Version: 1.1.1
Severity: Major Keywords: Measure
Cc: Jenny He, arthur.liu@… Browser: All
External ID: 1281984 Operating System: All
state: 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.

Attachments (1)

MeasureArea.patch (722 bytes) - added by christinebao 12 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by christinebao

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.

Changed 12 years ago by christinebao

Attachment: MeasureArea.patch added

comment:2 Changed 12 years ago by christinebao

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

comment:3 Changed 12 years ago by liuar

Reviewed. Please submit the code. Thanks.

comment:4 Changed 12 years ago by christinebao

Resolution: fixed
state: NewCommitted
Status: newclosed

Commit the patch to fix this defect.

Note: See TracTickets for help on using tickets.