How to convert ARCGIS AGSPoint to lat-long in iOS ?

5492
3
07-29-2013 08:41 PM
PradeepVishwakarma
New Contributor
Hi frnds,

Anyone know....How to convert ARCGIS AGSPoint to lat-long in iOS ?

I knew ..how to convert lat-long to AGSPoint by this,

  
    AGSPoint *currentPoint = [AGSPoint pointWithX:longValue
                                                                  y:latValue                                   
                                             spatialReference:[AGSSpatialReference wgs84SpatialReference]];

    currentPoint = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:currentPoint
                                                                       toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]];
  
using this code i can find the AGSPoint of any lat-long value...

So what, I have to do to reverse this process or any idea if you know..Help me....
0 Kudos
3 Replies
ChristopherBarger
New Contributor
AGSPoint has x and y properties you can use to access lat/long.

so from your example

AGSPoint *currentPoint = [AGSPoint pointWithX:longValue
y:latValue 
spatialReference:[AGSSpatialReference wgs84SpatialReference]];

currentPoint = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:currentPoint
toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]];

//you could get the lat long back out like so
double long = [currentPoint x];
double lat = [currentPoint y];


Sorry if i am misunderstanding this question.
0 Kudos
PradeepVishwakarma
New Contributor
AGSPoint has x and y properties you can use to access lat/long.

so from your example

AGSPoint *currentPoint = [AGSPoint pointWithX:longValue
y:latValue 
spatialReference:[AGSSpatialReference wgs84SpatialReference]];

currentPoint = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:currentPoint
toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]];

//you could get the lat long back out like so
double long = [currentPoint x];
double lat = [currentPoint y];


Sorry if i am misunderstanding this question.





Yes ...You are right...but  [currentPoint x] and  [currentPoint y] returns  UTM coordinates...so if you know.. how to convert back this to
original lat-long value...Let me know...

For ref.

original lat-long
x=-90.293628 Y=41.713072

later lat-long
x = -10051440.690837, y = 5118095.453266   (UTM)

Thanx for your reply...
0 Kudos
ChristopherBarger
New Contributor
Okay, in order to get the original lat/long values you'll need to project the point back to WGS84 from web mercator. Depending on where and what you need this for it may be easier to store the x/y of the WGS point before you project to web mercator in the first place. Conversely if you don't want to reproject currentPoint, you could just create another AGSPoint to project to WGS84 and grab the x/y from that way.

currentPoint = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:currentPoint
toSpatialReference:[AGSSpatialReference wgs84SpatialReference]];

//these should now yield your original lat/long values.
double long = [currentPoint x];
double lat = [currentPoint y];
0 Kudos