Project AgsPoint (spatial reference 4326 to spatial reference 102100)

8442
26
10-18-2010 08:52 AM
KOLDODUARTE
New Contributor
Hi all

We need to project the x and y obtained from the ESRI_Places_World/GeocodeServer and show it as a graph into a base map with spatial reference 102100.

We tested with:

AGSPoint *pt = addressCandidate.location;
AGSMutablePoint *newPoint = [AGSMutablePoint pointWithX:pt.x y:pt.y spatialReference:self.mapView.spatialReference];


But this not works.

Do you have any idea?

BR,
Koldo
0 Kudos
26 Replies
DiveshGoyal
Esri Regular Contributor
You cannot just assign a different spatial reference to existing coordinate values. You need to actually project the coordinate values.

The Geocode Service can project the values for you. All you need to do is use locationsForAddress:returnFields: outSpatialReference:  and specify the spatial reference in which you want the results.
0 Kudos
KOLDODUARTE
New Contributor
Hi technobrat,

Now I running with this code:

[self.locator locationsForAddress:addresses returnFields:outFields outSpatialReference:self.mapView.spatialReference];


... but the X & Y value for the set Point are the same, the coordinates are not changed... any idea?

Best Regards & Thanks,
Koldo
0 Kudos
KOLDODUARTE
New Contributor
Hi all,

With this code:
[self.locator locationsForAddress:addresses returnFields:outFields outSpatialReference:self.mapView.spatialReference];


The point puts on the center of the map, just in Africa. Any idea?

Thanks & Best Regards,
Koldo.
0 Kudos
DiveshGoyal
Esri Regular Contributor
Hmm, not sure why you're still having problems.

Can you print the point to the console and see if the x,y, and spatial ref values look okay. Use NSLog(@"Point: %@", point);
0 Kudos
KOLDODUARTE
New Contributor
Hmm, not sure why you're still having problems.

Can you print the point to the console and see if the x,y, and spatial ref values look okay. Use NSLog(@"Point: %@", point);


Ok... the console prints this:
2010-10-31 17:05:26.223 iWatch[470:207] Point: AGSPoint: x = -1.785897, y = 43.031819, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null]
0 Kudos
DiveshGoyal
Esri Regular Contributor
Is it possible that your Geocode service is on an ArcGIS Server older than 9.3.1?

The 102100 spatial reference was introduced at 9.3.1. Older servers dont understand it.
0 Kudos
KOLDODUARTE
New Contributor
Thanks for the response Technobrat.

However, we are using a 931 ESRI geocode server:
http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Places_World/GeocodeServer

Indeed, we are trying some other alternatives as reproject the coordinates with the geometry service task:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project

Here we are facing another issue. We are not able to get the projected points to WKID:102100 using the delegate method:

- (void)geometryServiceTask:(AGSGeometryServiceTask *)geometryServiceTask operation:(NSOperation *)op didReturnProjectedGeometries:(NSArray *)newGeometry


Doesn´t this method have the input spatial reference as a parameter?

Any help will be appreciate it.

Cheers!

Koldo
0 Kudos
DiveshGoyal
Esri Regular Contributor
Ok. I am stumped. I'm not sure why your 931 Geocode Service does not give you back the correctly projected results.

For using the Geometry Service, your input geometries must have a valid spatial reference. Without this info, the geometry service cannot truly project your geometries.

If you're still having problems, I can take a look at your code to see what might be going on.
0 Kudos
AlbertoTelletxea
New Contributor
Ok. I am stumped. I'm not sure why your 931 Geocode Service does not give you back the correctly projected results.

For using the Geometry Service, your input geometries must have a valid spatial reference. Without this info, the geometry service cannot truly project your geometries.

If you're still having problems, I can take a look at your code to see what might be going on.


Hi Technobrat

I am following the thread of Koldo. He is my colleague. I have prepared a XCode Project with the ESRI Sample project "GeocodingDemo". But I cannot upload it. The zip file is just 1,5Mb. If you provide me a mail I can forward it to you.
However, I am going to explain briefly what I did in the code to reproduce the issue.

I have just changed the base map (tiled) layer of the project "GeocodingDemo" to the one we use in our project, http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
with spatial reference: 102100.

Then in the GeocodingDemoViewController.m I write the following line to request the locations to the geolocator service:
[self.locator locationsForAddress:addresses returnFields:outFields outSpatialReference:self.mapView.spatialReference];


The result of this is that the address points are located at (0,0) in the map. The method is not properly using the outSpatialReference parameter.

Please let us know if the description of the issue is clear enough. And again if you provide me a mail I can forward to you the XCode Project.

Thanks in advance and best regards.

Alberto
0 Kudos