Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to plot some AGSSimpleMarkerSymbol's in a AGSGraphicsLayer. The issue I'm running into is that the data I'm starting with are GPS coordinates (lat/lon). I'm using AGSPoint to plot the data, however, AGSPoint wants x and y points - not lat/lon.

My question is, how do I convert my GPS coordinates to x and y points?

share|improve this question
2  
D'oh... I had the lat/lon reversed in the x and y. My code is now: [AGSPoint pointWithX:[lon doubleValue] y:[lat doubleValue] spatialReference:self.mapView.spatialReference]; –  Cole Jan 22 '13 at 20:11

2 Answers 2

up vote 3 down vote accepted

Basically you want to use the projectGeometry method from the AGSGeometryEngine class to convert from the GPS coordinate system to the coordinate system used by your map. Use the defaultGeometryEngine for this.

Assuming your GPS is giving you WGS-84 coordinates you could do something like this:

CLLocation* gpsLocation = ....

// create a AGSPoint from the GPS coordinates
AGSPoint* gpsPoint = [[AGSPoint alloc] initWithX:gpsLocation.coordinate.longitude
                                               y:gpsLocation.coordinate.latitude
                                spatialReference:[AGSSpatialReference wgs84SpatialReference]];

AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine];

// convert GPS WGS-84 coordinates to the map's spatial reference
// (assuming self.mapView is your AGSMapView for your map)
AGSPoint* mapPoint = (AGSPoint*) [engine projectGeometry:gpsPoint 
                                      toSpatialReference:self.mapView.spatialReference];
share|improve this answer
    
The full list of supported coordinate systems can be found here: resources.arcgis.com/en/help/coordinate-systems/mobilegcs.html –  progrmr Jul 11 '14 at 14:42
    
I am using ArcGIS iOS SDK in my app, I want to track the GPS path. I read the location updates from locationManager API from Apple which returns a lat * long. Can I assume that its spatial reference wgs84SpatialReference. In simple words I have used your code above & how can I confirm if the conversion took place as desired? Plz help –  Dinakar 2 days ago
    
No need to assume, Apple documented that CLLocationCoordinate2D is in WGS-84 frame of reference. –  progrmr 2 days ago

The two numerals before the decimal point and those after are minutes, the two/three numerals at the front are degrees, i.e. 32 degrees, 46.4270 minutes, 117 degrees, 04.3785 minutes, etc. You can convert these to decimal degrees after loading doesn't need three lines but hopefully this makes the process clearer

share|improve this answer
    
I'd guess the original poster has already solved his problem. –  BradHards Jan 20 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.