Select to view content in your preferred language

Standard way to determine spacial reference type

631
2
06-19-2011 11:50 PM
JH2
by
Emerging Contributor
Hi all,

My data is all held in Lat/Longs but I'm using Bing maps.  As a result, I use the:

ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator()

call to convert my Lat/Long to position correctly on Bing and then

ESRI.ArcGIS.Client.Bing.Transform.WebMercatorToGeographic()

to convert back the other way.

I'm aware that other map layers don't use Web Mercator, and I was wondering if there was a standard check that should be used when putting data onto a map e.g.:

if (MyMap.Extent.SpatialReference.WKID == 102100 ||
    MyMap.Extent.SpatialReference.WKID == 102113 ||
    MyMap.Extent.SpatialReference.WKID == 3857)
{
    // we must be in web mercator, so lets convert our point appropriately...
    MapPoint mapPoint = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(GeoPosition.Latitude, GeoPosition.Longitude));
}
else
{
    ....
}


...or is there another way of checking?  Or am I misunderstanding the whole issue?

Any suggestions appreciated!  Sorry for the lack of knowledge

Cheers,
James

P.S. I got the WKID numbers after a bit of searching - perhaps they're not correct, or an incomplete set?
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor

P.S. I got the WKID numbers after a bit of searching - perhaps they're not correct, or an incomplete set?

It's correct and complete 🙂

The SpatialReference Equals method encapsulates the test on the different WebMercator WKID.

i.e. if you have 2 WebMercator spatial references (even with different WKID) sr1.Equals(sr2) returns true.

So one option to avoid hardcoding the 3 possible WKID is :
     if (new SpatialReference(102100).Equals(MyMap.Extent.SpatialReference)) { ......
0 Kudos
JH2
by
Emerging Contributor
Hi Dominique - great - just what I was looking for!
0 Kudos