Hi,

I looked in the other threads and cannot find anything about this problem. Maybe it's my misunderstanding of the way to project a point.

I need to convert device's latitude and longitude to my map which is in a 3163 spatial reference.

I do the following :

This sample code always result in returning "nan" information in the resulting AGSpoint x and y coordinates. Because I was not sure how to map X and Y as latitude and longitude I tried to switch lat / long so that X is mapped to longitude and Y mapped to latitude in my origin WGS84 point.

This time, I get results but the resulting point seems to be outside my map's bounds.

Here are my information :

Second try when mapping X with longitude and Y with latitude :

Here are my questions :

- Which way should I map X/Y to lat/long (in all other examples I saw X->lat and Y->lng but it does not give any result)

- Am I doing it the right way or missing anything ?

Thank you very much for your time and answers.

Christophe.

I looked in the other threads and cannot find anything about this problem. Maybe it's my misunderstanding of the way to project a point.

I need to convert device's latitude and longitude to my map which is in a 3163 spatial reference.

I do the following :

- Get the current location from SDK's CoreLocation framework
- When I need to plot a point on current location, I initialize the current lat/long as an AGSPoint with a WGS84 spatial reference.
- Then I project it to the spatial reference 3163 and I add this point to one of my graphic layer

_defaultSpatialRef = [AGSSpatialReference spatialReferenceWithWKID:3163]; AGSGeometryEngine *engine = [AGSGeometryEngine defaultGeometryEngine]; AGSPoint *point = [AGSPoint pointWithX:currentLocation.coordinate.latitude y:currentLocation.coordinate.longitude spatialReference:[AGSSpatialReference spatialReferenceWithWKID:WKID_WGS84]]; AGSPoint *projectedPoint= (AGSPoint*)[engine projectGeometry:point toSpatialReference:_defaultSpatialRef];

This sample code always result in returning "nan" information in the resulting AGSpoint x and y coordinates. Because I was not sure how to map X and Y as latitude and longitude I tried to switch lat / long so that X is mapped to longitude and Y mapped to latitude in my origin WGS84 point.

This time, I get results but the resulting point seems to be outside my map's bounds.

Here are my information :

- location latitude = -22.2682
- location longitude = 166.442

Second try when mapping X with longitude and Y with latitude :

- projected point X = 445586.569662
- projected point Y = 214879.873427

Here are my questions :

- Which way should I map X/Y to lat/long (in all other examples I saw X->lat and Y->lng but it does not give any result)

- Am I doing it the right way or missing anything ?

Thank you very much for your time and answers.

Christophe.

X = Longitude and Y = Latitude.

You are doing it right. I projected point and got slight difference in the result point but it looks correct.

AGSPoint *p = [AGSPoint pointWithX:166.442 y:-22.2682 spatialReference:[AGSSpatialReference wgs84SpatialReference]];

AGSGeometry *pg = [[AGSGeometryEngine defaultGeometryEngine] projectGeometry:p toSpatialReference:[AGSSpatialReference spatialReferenceWithWKID:3163]];

NSLog(@"%@",pg);

//AGSMutablePoint: x = 445554.767830, y = 214880.208082, spatial reference: [AGSSpatialReference: wkid = 3163, wkt = null]

Now, look into why you are getting point out of map's bounds.

What is your map's spatial reference?

Are you creating a graphic with projected point and adding to graphics layer to visualize it?

Regards,

Nimesh