SOE and server-side projection - am I missing something?

411
3
10-17-2012 07:44 PM
ericliprandi
New Contributor III
Hi,
We are writing an SOE that returns a geometry. In order to project the geometry to the correct spatial reference, our SOE takes a outSR (output spatial reference) parameter, similar to other esri REST endpoints. For our current test, we pass this as an argument "{"wkid":102100}".
In the SOE, we get an ISpatialReference using Conversion.ToSpatialReference(<the spatial ref argument>). At first glance, it does give us a valid ISpatialReference. When we try to project the geometry to the new spatial reference, it successfully projects the geometry. However, the result of this projection is incorrect. Not by much, but enough that the returned geometry does not line up with other geometries retrieved using the MapServer Query option.
JsonObject sr;
input.TryGetJsonObject("outSR", out sr);
ISpatialReference spatialRef = Conversion.ToSpatialReference(sr.ToJson());
// following returns something like:
// Point - x:2212717.3898518384 y:397180.12340788543
// in NAD_1927_Colorado_North system
IGeometry geometry = GetMyGeometry();
geometry.Project(spatialRef);
// results in: x=-11659158.62928186 y=4927334.9662179118

When we query the MapServer for the same geometry/point, it returns x=-11659216.786233451, y=4927332.1753076809. I am sure this is user error, but a couple of us have looked it and we can't seem to see what's wrong. It's such a simple sequence of code.

Thanks in advance for any help,

Eric.
Tags (2)
0 Kudos
3 Replies
nicogis
MVP Frequent Contributor
you need datum transformation from 102100 to/from NAD_1927_Colorado_North  (I see <> spheroid).


use geometry.ProjectEx ( http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/002m/002m000001rp000000.htm )


IGeometry2 geometry = GetMyGeometry() as IGeometry2;
geometry.ProjectEx(....

0 Kudos
ericliprandi
New Contributor III
Hi,
Thanks for the response. You are correct. We'll need to get the proper transformation. We did follow the example in this post, but it turns out no predefined transformation seems to exist for our sample data spatial reference (NAD_1927_Colorado_North). Its FactoryCode (well-known ID, we assume...) is 0, rendering the code sample ineffective.
Would you or anybody out there have a way to handle generic cases? Any chance that esri already has an API for this? obviously, as stated in the original post, when we use the MapServer Query method, it does the proper projection.

Regards,

Eric.
0 Kudos
nicogis
MVP Frequent Contributor
in IMapServer3

internal static IFeatureClass GetFeatureClass(this IMapServer3 mapServer, int layerID)
        {
            IMapServerDataAccess dataAccess = (IMapServerDataAccess)mapServer;
            return dataAccess.GetDataSource(mapServer.DefaultMapName, layerID) as IFeatureClass;
        }




you have QueryFeatureData2  for query and return with your datum transform and output json
( http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200000p3n000000.htm )

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/0012000009ms000000.htm
0 Kudos