Ticket #366 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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@… External ID: 1307260,1394066
state: Committed Browser: All
Operating System: All

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

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

Change History

Changed 3 years ago by liuar

  • cc jie.tan@… added; jennyhe removed
  • version changed from 1.1.1 to 2.0 - beta
  • external_id changed from 1307260,1272713 to 1307260,1394066
  • milestone changed from Future to 2.0

[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.

Changed 3 years ago by liuar

Changed 3 years ago by liuar

  • status changed from new to closed
  • state changed from New to Committed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.