Obtaining the difference in latitude and longitude from polygon shifting

2304
6
Jump to solution
04-01-2013 01:59 AM
Labels (1)
StanleyHo
New Contributor III
Hi all,

I want to find the difference (in latitude and longitude format) after shifting a polygon from one point in the map to another. How do I do it?

currently I am using GraphicsLayer->MouseLeftButtonDown event to start the EditGeometry->StartEdit() function.
However, once  EditGeometry->StartEdit() function fired, GraphicsLayer->MouseLeftButtonDown is no longer triggered until EditGeometry->StopEdit() is fired. Thus, I wasn't able to get the mouse coordinate to compute the difference.

Is there any way to get the difference (in Latitude Longitude format)?

thanks
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

If you're handling the EditGeometry.GeometryEdit event that should give you both the new geometry and the old geometry from which you should be able to determine the point to be moved and work out relative to the new geometry where the point should be located.

http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli...

Cheers

Mike

View solution in original post

0 Kudos
6 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

You could use the GeometryService task class and call the DistanceAsync method - which calculates the distance between two geometries: http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli...

The distance can be returned in one of the supported formats as per the LinearUnit enumeration: http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli....

Cheers

Mike
0 Kudos
StanleyHo
New Contributor III
Thanks for your reply.

I understand that the distance method you mentioned can help to calculate the distance between 2 geometry. However, I have 2 problems in using that function.

1) I wasn't able to get the starting geometry as when EditGeometry->StartEdit() function is fired, any GraphicsLayer->MouseLeftButtonDown() event will not be triggered. Hence I can't get the starting corrdinate of initial mouse pointer.

2) The distance that it return is in double of the spatial reference and not in (x,y) or (longitude, latitude) value.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,


1) I wasn't able to get the starting geometry as when EditGeometry->StartEdit() function is fired, any GraphicsLayer->MouseLeftButtonDown() event will not be triggered. Hence I can't get the starting corrdinate of initial mouse pointer.
Please can you provide some more information on what functionality you're trying to achieve?

2) The distance that it return is in double of the spatial reference and not in (x,y) or (longitude, latitude) value.
Can you provide some more information on exactly what measure you would like to obtain? A coordinate pair refers to a specific location, rather than a distance between two locations.

Cheers

Mike
0 Kudos
StanleyHo
New Contributor III
I am trying to do the following:

I have 1 point (P1) a 1 rectangle polygon (R1).
both P1 and R1 is associated.
When I move R1 from 1 place to another (on the map using Editgeometry->Startedit()), P1 will get updated by the distance covered by R1.
P1 is in Longitude and Latitude.

For example:

I will use x,y coordinate for easy illusration

initally
-------
R1 - (3,4), (5,4), (3,2), (5,2)
P1 - (2,4)

I move R1 by (2,3) [move click and move on the map]

new position
--------------
R1 - (5,7), (7,7), (5,5), (7,5)
Since distance covered is random, I can only get the distance covered by the starting and ending point before I know the distance for the new P1 coordinates.
P1 - (4,7) [should be this coordinate after computing]
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

If you're handling the EditGeometry.GeometryEdit event that should give you both the new geometry and the old geometry from which you should be able to determine the point to be moved and work out relative to the new geometry where the point should be located.

http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli...

Cheers

Mike
0 Kudos
StanleyHo
New Contributor III
thanks I manage to get it to work with the GeometryEdit event.
0 Kudos