Opened 12 years ago

Closed 12 years ago

#366 closed defect (fixed)

Measure: wrong length and segments displayed when measure with a line

Reported by: liuar Owned by: madair
Priority: P2 Milestone: 2.0
Component: Widgets Version: 2.0 - beta
Severity: Major Keywords:
Cc: kathy.feng@…, jie.tan@… Browser: All
External ID: 1307260,1394066 Operating System: All
state: Committed

Description

  1. Set the measure type to Distance and Area
  2. click to add two points
  3. a line is added to be measured


Result: there are 2 segments appear, total length = 2 * segment length

Expected: only 1 segment appear, total length isn't doubled.

If measure on Bing maps, there will be an un-caughted exception.

Attachments (1)

Measure.patch (495 bytes ) - added by liuar 12 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 by liuar, 12 years ago

Cc: jie.tan@… added; jennyhe removed
External ID: 1307260,12727131307260,1394066
Milestone: Future2.0
Version: 1.1.12.0 - beta

[Analysis]

If the measure type is set to Area, a polygon will e created no matter how many point are added. For instance, if user adds two points Point(0,0) and Point(1,1) into the map, measure widget will create a polygon Polygon((0,0) (1,1) (0,0))) which is not a valid polygon at all.

In Measure.js, var cg = geom.getCentroid(), which used the polygon's area as a divisor in the implement. The cg.x and cg.y will be NaN and cause the exception in Bing map.

[Solution]

Check the geom's area before calcaulate the centroid. If the area equals to zero, that means that the geom is invalid, and we just ignore the followed opertionations.

by liuar, 12 years ago

Attachment: Measure.patch added

comment:2 by liuar, 12 years ago

Resolution: fixed
state: NewCommitted
Status: newclosed
Note: See TracTickets for help on using tickets.