AGSLocator, AGSLocatorDelegate, AGSAddressCandidate.. Tutorial

1215
3
03-30-2010 05:06 AM
ChanceYohman
New Contributor
AGSSpatialReference, & AGSPoint Tutorial Version 1.03.30.2010 (sorry, I use versioning numbers that make sense to me :])

Questions/Comments

1) This code is far from perfect. Memory leaks, etc. may be present. If you see something wrong, then please try to fix it and let me know.

2) I welcome someone to GUI-ify this. Right now, I'm traversing the object model. Either someone can wrap this with a GUI, or I'll do it later.

3) I've only been coding in Objective-C for 3 months now, but it seems the documentation should make it clear to beginners that init* methods can only be used on [AGS* alloc]. See code for examples in viewDidLoad in AGSAddressCandidateViewController.m, e.g. line 44.

4) Why does AGSPoint lack a spatial reference property? It would be helpful, if that or AGSLocator had a spatial reference. This way programmers would know the projection of coordinates coming back to them. Plus, IPoint in the ArcObjects model has a spatial reference property.

5) Why is there a difference in precision between the x & y properties of AGSPoint and its CGPoint property's x & y properties? Please see lines 75-79 of AGSAddressCandidateViewController.m .

6) I've brought this up before, but it looks like AGSAddressCandidate's attributes property has replaced the address property. Address's count is 0 for any AGSAddressCandidate I have seen, while attribute's count is non-zero. I take that back. The above is true for AGSAddressCandidates returned from locationsForAddress calls, while the reverse appears true for addressForLocation calls. Can anyone explain why there is a difference?

Thanks for reading and any responses you may have. 🙂
0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
4) Why does AGSPoint lack a spatial reference property? It would be helpful, if that or AGSLocator had a spatial reference. This way programmers would know the projection of coordinates coming back to them. Plus, IPoint in the ArcObjects model has a spatial reference property.

[Nimesh] I�??m not clear about your question. You mean to ask why the spatial reference property of the returned location points (AGSPoint) is null or AGSPoint itself does not have a spatial reference property based on the doc (http://help.esri.com/en/ArcGIsmobile/9.4/apis/iPhone/Reference/Classes/AGSPoint.html)?

The AGSPoint does have a spatial reference property. If you change the code line (127 and 172) as following then you will see the location point�??s spatial reference information.

NSLog(@"Address Candidate @ (%f,%f,%@)",[location x], [location y], [location spatialReference]);

5) Why is there a difference in precision between the x & y properties of AGSPoint and its CGPoint property's x & y properties? Please see lines 75-79 of AGSAddressCandidateViewController.m .

[Nimesh] We�??ll look into this.

6) I've brought this up before, but it looks like AGSAddressCandidate's attributes property has replaced the address property. Address's count is 0 for any AGSAddressCandidate I have seen, while attribute's count is non-zero. I take that back. The above is true for AGSAddressCandidates returned from locationsForAddress calls, while the reverse appears true for addressForLocation calls. Can anyone explain why there is a difference?

[Nimesh] The Reverse Geocode  (addressForLocation) candidates does not have attributes property. You can verify it from the REST endpoint and REST documentation.

Reverse Geocode:
http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA/GeocodeServer/reverseGeoco...

Reverse Geocode REST API Doc:
http://tasks.arcgisonline.com/ArcGIS/SDK/REST/reverse.html

Hope this helps!

Regards,
Nimesh
0 Kudos
ChanceYohman
New Contributor
4) Why does AGSPoint lack a spatial reference property? It would be helpful, if that or AGSLocator had a spatial reference. This way programmers would know the projection of coordinates coming back to them. Plus, IPoint in the ArcObjects model has a spatial reference property.

[Nimesh] I�??m not clear about your question. You mean to ask why the spatial reference property of the returned location points (AGSPoint) is null or AGSPoint itself does not have a spatial reference property based on the doc (http://help.esri.com/en/ArcGIsmobile/9.4/apis/iPhone/Reference/Classes/AGSPoint.html)?

The AGSPoint does have a spatial reference property. If you change the code line (127 and 172) as following then you will see the location point�??s spatial reference information.

NSLog(@"Address Candidate @ (%f,%f,%@)",[location x], [location y], [location spatialReference]);


[Chance] I agree it's there, but a few issues with it:

1) It's not explicitly documented:

http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/Classes/AGSPoint.html

Implied by the initializers, but not written in as a property.

2) Sample output from line 127:

2010-04-05 10:50:13.754 AGSAddressCandidate[438:207] Address Candidate @ (-77.036696,38.897101,(null))

While the property is there, it's not being set.

Sample output from line 172:

2010-04-05 10:50:13.407 AGSAddressCandidate[438:207] Address Candidate @ (-149.687617,69.136652,AGSSpatialReference: wkid = 4326, wkt = null)

Better, but the well known type is still not being set.
0 Kudos
NimeshJarecha
Esri Regular Contributor
The documentation will be updated. The Address Candidate�??s spatial reference property issue is already been logged in our system.

Regards,
Nimesh
0 Kudos