Snapping: rounding down of the geometry vertices

1853
1
02-23-2016 02:50 PM
YohanBienvenue
Occasional Contributor II

We noticed that when we are using the Measurement widget to measure surfaces, while in snapping mode, the result always seems a bit off from the true surface measure. Not by much, but enough to matter since the users often use the widget to measure land areas and the result does not correspond to the surface annotation in the map for this land.

After some investigation, I noticed that when snapping we seem to be losing some precision. It seems the vertices of the polygon are rounded down after the second decimals (compared to the actual feature vertices for this land). Is there a way to avoid this rounding down to improve the Measurement widget precision, or improve any other measurement involving geometry obtained by snapping to lines in the map?

Here's an example (in squared meters)

2016-02-23_17-16-56.png

It was even worse before because the widget only displayed one decimal by default, but even after I modified the numberPattern of the widget to add an extra decimal, it's not enough. It will display 502.06m instead of the true 501.98m value (and compared to the 501.9m annotation in the map). Like I said, not much, but I still wanted to ask the question. Can I prevent this rounding down when using snapping? Many thanks.

            this.esriMeasurement = new Measurement({
              map: this.map,
              defaultAreaUnit: units.SQUARE_METERS,
              defaultLengthUnit: units.METERS,
              pointSymbol: new PictureMarkerSymbol("images/esriGreenPin16x26.png", 16, 26),
              numberPattern: "#,###,###,##0.00"
0 Kudos
1 Reply
YohanBienvenue
Occasional Contributor II

After some more investigation in the code of SnappingManager, I see that the issue only happens at the intersection of two lines. Anywhere else along a line all the decimals are present in the snappingPoint.

It looks like there is some math in the _getSnappingPoint function to figure out where the snappingPoint should be when two lines intersect. Somewhere in this calculation precision is lost and returns a point which is a bit offset from the true feature point. Unfortunately when you measure surfaces, it is these corner snappingPoints that are sent to the geometry service, which are a bit offset from the true feature geometry vertices. Generating this small error.

Note that decreasing the snapping tolerance does not help. Even with a tolerance of 1 pixel, this lost of precision still happens when snapping at line intersections.

I don't know where to go from here.

0 Kudos