projectGeometries WKID:4326 to WKID:3414

4041
5
06-21-2010 10:00 PM
RoystonKoh
New Contributor
Hi guys,

I'm new to ArcGIS as well as iPhone development.
Right now I'm working on a school project and I need to perform this task of converting coords from WKID:4326 WGS84 to WKID:3414 SVY21.

The map service I use is base on WKID:3414 and I'm trying to get Core Location to work thus I need to convert to SVY21 (WKID:3414).

Can someone assist me in creating the function to convert the coords as I do not understand the API documentation with my level of programming knowledge.

geometryServiceTaskWithURL: http://www.onemap.sg/ArcGIS/rest/services/Geometry/GeometryServer

From WKID:4326 to WKID:3414

Would greatly appreciate help.
0 Kudos
5 Replies
NimeshJarecha
Esri Regular Contributor
I would suggest you to look into the GeometryServiceTaskDemo sample app which has a code to buffer the geometries. It will give you an idea to work with geometry service task and similarly you can use projectGeometries:toSpatialReference: method to project the geometry. It get installed with SDK at ~/Library/SDKs/Samples.

Please feel free to let me know if you need any further help!

Regards,
Nimesh
0 Kudos
RoystonKoh
New Contributor
I would suggest you to look into the GeometryServiceTaskDemo sample app which has a code to buffer the geometries. It will give you an idea to work with geometry service task and similarly you can use projectGeometries:toSpatialReference: method to project the geometry. It get installed with SDK at ~/Library/SDKs/Samples.

Please feel free to let me know if you need any further help!

Regards,
Nimesh


Hi Nimesh,

I've looked into GeometryServiceTaskDemo but still do not understand it. I need to mention that this if my first time coding on iPhone so I'm unfamiliar with Objective-C.

You mentioned about projectGeometries:toSpatialReference.
- (NSOperation *) projectGeometries:  (NSArray *)  geometries
toSpatialReference:  (AGSSpatialReference *)  spatialReference  


How should I code the method for my case? I've tried around different code but due to lack of experience with Objective-C I've got no idea how to get it to work.

Your help would be greatly appreciated!

Regards,
Royston
0 Kudos
RoystonKoh
New Contributor
I've coded this assuming from the code I need the coords lon, lat stored in an NSArray and toSpatialReference output Spatial Reference

Thus.

Declare and initialize the output spatial reference.
AGSSpatialReference *osr; 
 osr = [[AGSSpatialReference alloc] initWithWKID:3414
          WKT:@"SVY21"];

I'm not sure how to store lon, lat in NSArray. Currently they are in double.

 double lat = location.coordinate.latitude;
 double lon = location.coordinate.longitude;


Lastly to I need to know how to use that methodd projectGeometries: lon,lat toSpatialReference: osr

Are my codes correct?

Hi Nimesh,

I've looked into GeometryServiceTaskDemo but still do not understand it. I need to mention that this if my first time coding on iPhone so I'm unfamiliar with Objective-C.

You mentioned about projectGeometries:toSpatialReference.
- (NSOperation *) projectGeometries:  (NSArray *)  geometries
toSpatialReference:  (AGSSpatialReference *)  spatialReference  


How should I code the method for my case? I've tried around different code but due to lack of experience with Objective-C I've got no idea how to get it to work.

Your help would be greatly appreciated!

Regards,
Royston
0 Kudos
RoystonKoh
New Contributor
Okay. I think my code was wrong here's the recoded one for AGSSpatialReference.

 AGSSpatialReference *svy21 = [[AGSSpatialReference alloc] initWithWKID:3414
                    WKT:@"PROJCS[\"SVY21 / Singapore TM\",GEOGCS[\"SVY21\",DATUM[\"D_\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",1.366666666666667],PARAMETER[\"central_meridian\",103.8333333333333],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",28001.642],PARAMETER[\"false_northing\",38744.572],UNIT[\"Meter\",1]]"];
 AGSSpatialReference *wgs84 = [[AGSSpatialReference alloc] initWithWKID:4326 
                    WKT:@"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]"]; 
 


I still can't figure out how to use projectGeometries:toSpatialReference method. Pardon me.
0 Kudos
HavenTang
New Contributor
I also want to convert. 
my code is:
    self.gst = [[[AGSGeometryServiceTask alloc] initWithURL:[NSURL URLWithString:kGeometryProjectService]] autorelease];
    AGSSpatialReference *tosr = [[[AGSSpatialReference alloc] initWithWKID:4326 WKT:nil] autorelease];
  
 self.gst.delegate = self;
    
    AGSSpatialReference *fromsr = [[[AGSSpatialReference alloc] initWithWKID:3414 WKT:nil] autorelease];
    AGSPoint *pp = [[AGSPoint alloc] initWithX:26332.346744 y:37434.157586 spatialReference:fromsr];
    [self.gst projectGeometries:[NSArray arrayWithObjects:pp, nil] toSpatialReference:tosr];


after I call the project,  no delegate are triggered.  Do you resolve it?
0 Kudos