Select to view content in your preferred language

Measurement Dijit show wrong distance on mouse move

3309
18
01-31-2014 09:29 AM
BryanLynn
Deactivated User
We are using the Esri measurement dijit in our site.  We have a map that shows 1000' buffers around certain property types.  When you use the measure tool it reports an incorrect value while moving the mouse.  Once the user double clicks to end the measurement the distance seems correct.  Please see the attached images for more details.

This is causing tremendous confusion amoung our users.

Any suggestions?

Thanks,
Bryan

[ATTACH=CONFIG]31041[/ATTACH] [ATTACH=CONFIG]31042[/ATTACH]
0 Kudos
18 Replies
JeffPace
MVP Alum
We are using the Esri measurement dijit in our site.  We have a map that shows 1000' buffers around certain property types.  When you use the measure tool it reports an incorrect value while moving the mouse.  Once the user double clicks to end the measurement the distance seems correct.  Please see the attached images for more details.

This is causing tremendous confusion amoung our users.

Any suggestions?

Thanks,
Bryan

[ATTACH=CONFIG]31041[/ATTACH] [ATTACH=CONFIG]31042[/ATTACH]


I wonder if it is not doing the geodesic conversion until the onfinish. that would be unfortunate.
0 Kudos
by Anonymous User
Not applicable
Original User: Jian

What's the coordinate system of the map?
0 Kudos
BryanLynn
Deactivated User
The map is in Tennessee State Plane Coordinates - WKID 2915.

And yes, I think it is doing a geodesic measurement until the finish measurement event is called.  At least that is how it appears to me from looking at the JSON request in Fiddler.

Thanks.
0 Kudos
by Anonymous User
Not applicable
Original User: Jian

For coordinate systems other than Web Mercator or geographic CS, this is by design, since there is no better way to do so.
Computing geodesic area/length is only possible with Web Mercator or GCS. Under other CSs, it reprojects the corners (xmin, ymin, xmax, ymax) to GCS, and interpolate the mouse position to find the approximate location under GCS in order to make it possible to calculate geodesic area/length. It is simply not possible to reproject the mouse position point while it's moving. After the drawing ends, as you observed, it shows the accurate result.
The better way is to write a projection conversion for this specific needs.
BTW, your attached image shows 1018feet, instead of 1108.
0 Kudos
BryanLynn
Deactivated User
OK, so I get why you want to do geodesic measurement in a global application that is tracking goods moving around the globe or across the country.  But I just want to measure the distance from here to the grocery store or see how far I ran today.  This seems over complicated to me.

The measure tool should simply use the coordinate system the map is based on.  This would also solve anohter problem I have with the location tool.  We use state plane coordinates because everything in our system is based on that datum.  However, location tool reports lat/lon coordinates - why?.  I can convert them but why should I have to do that, the map already knows what those coordinates are.

Here is a real world example.  The police arrest someone at the corner of A St and B St for selling illegal substances.  They need to know how far it is to the school on A St because within a certain distance the crime carries a different penalty. Click measure length, drop a point at the point of the crime and drag a line to the school property to check the distance.  The also notice a park down the street, move the mouse over the park, check the distance. What about the daycare on B St, a quick mouse over gives me an answer.  Your way requires me to drop 6 different points - 2 for each measurement.

Keep the geodesic measurement for scenarios where it makes sense but allow the user to override it when necessary.

BTW - my image acutally says 1,1018 Feet which makes NO sense in any math I have ever seen. 🙂
0 Kudos
by Anonymous User
Not applicable
Original User: Jian

Just make it clear, measuring using the current map coordinate would not make it more accurate. In most cases, it's worse.
Geodesic gives the best result regardless the extent or zoom level. The problem here is the moving mouse cannot call geometry service frequently. For Web Mercator or GCS, which are the most common use cases, it doesn't have to go through geometry service.
And you can override the result by calling registry.byNode(measurement.resultValue.domNode).setAttribute("content", measurementvalue);
0 Kudos
BryanLynn
Deactivated User
So, I am still confused.  Is the final result a geodesic measurement or a planar measurement?  If the final result is geodesic why does it change so much once I drop the final point?  If the final distance is a planar measurement, why don't we just do a planar measurement from the start?  I get the whole the earth isn't flat, spheroid vs ellipsoid vs surficial distance measurement argument. I am just trying to figure out how and why the tool works like it does.

If I measure a distance along property lines in ArcMap (approx. 200 ft) there is about 1/100th of a foot difference between the planar distance and the goedesic distance.  But with the measure tool in ArcGIS Server JSAPI (and i am not using snapping for this) I get a difference of about 5 feet over the same 200 foot distance until I drop the final point.  Once I drop that final point the distance is with a foot of the reading in ArcMap (will within range considering no snapping and the scale range).  Again ALL of our maps, in both ArcMap and ArcGIS Server are in the same coordinate system - TN State Plane Coordinate System.

It may seem like I am beating a dead horse but this has come up in court cases and it is hard to defend when you see one measurement as you hover and another when you drop the point.  We are required to appear in court several times a year to defend a map that has been used to in a trial - so I kinda need to know how this is working.
0 Kudos
by Anonymous User
Not applicable
Original User: Jian

All results in measurement widget are always geodesic. the moving mouse would have a little off under CSs other than Web Mercator or GCS. The reason is as we discussed, it cannot reproject the moving mouse location on the fly. There are interpolation going on behind the scenes.
For your case, the best thing is to disable the results when mouse is moving.
0 Kudos
BryanLynn
Deactivated User
Thanks for the info.

2 quick questions:
1) I have looked at the API and don't see an option to turn off the result update while the mouse is moving.  Do you have a snippet of code showing how this is done?

2) You have helped me with this one in the past from another post.  I need to override the results to show State Plane Coordinates with the location tool.  I have the following code which worked in the past but now is acting funny.  Basically, I see the info flash into the results pane but then the tool collapses back to the normal results.

            measurement.on("measure-end", function(evt) {
                if (evt.toolName === "location") {
                    var myResult = "TN State Plane Coordinates (XY):<br />";
                    myResult += Math.round(evt.geometry.x).toString() + ", " + Math.round(evt.geometry.y).toString();
                    myResult += "<br><br>";
                    myResult += "Longitude, Latitude:<br />";
                    myResult += evt.target.locationX.toFixed(6).toString() + ", " + evt.target.locationY.toFixed(6).toString();

                    registry.byNode(measurement.resultValue.domNode).setAttribute("content", myResult);
                }
            });
0 Kudos