Opened 15 years ago
Closed 15 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
- Set the measure type to Distance and Area
- click to add two points
- 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)
Change History (3)
comment:1 by , 15 years ago
Cc: | added; removed |
---|---|
External ID: | 1307260,1272713 → 1307260,1394066 |
Milestone: | Future → 2.0 |
Version: | 1.1.1 → 2.0 - beta |
by , 15 years ago
Attachment: | Measure.patch added |
---|
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
state: | New → Committed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
[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.