/// <summary> /// Checks if a spatial reference is unprojected WGS84. /// </summary> /// <param name="sr">spatial reference to check</param> /// <returns>true if the spatial reference is WGS84, false if not</returns> public static bool IsWGS84(ISpatialReference sr) { IClone wgs84 = (IClone)EsriUtilities.GetWGS84(); IClone targetDatum = (IClone)EsriUtilities.GetDatum(sr); return((targetDatum).IsEqual(wgs84)); }
/// <summary> /// Gets a list of all geotransforms that use the provided spatial reference and unprojected /// WGS84 /// </summary> /// <param name="sr">spatial reference to look for</param> /// <returns>List of applicable IGeoTransformation objects</returns> public static List <IGeoTransformation> GetTransformations(ISpatialReference sr) { GeoTransformationComparer transComparer = new GeoTransformationComparer(); IClone wgs84 = (IClone)EsriUtilities.GetWGS84(); IClone targetDatum = (IClone)EsriUtilities.GetDatum(sr); List <IGeoTransformation> transList = new List <IGeoTransformation>(); ISpatialReferenceFactory2 srFactory = new SpatialReferenceEnvironmentClass(); ISet transSet = srFactory.GetPredefinedGeographicTransformations(); IGeoTransformation trans; ISpatialReference fromDatum; ISpatialReference toDatum; for (int i = 0; i < transSet.Count; i++) { trans = (IGeoTransformation)transSet.Next(); trans.GetSpatialReferences(out fromDatum, out toDatum); if (wgs84.IsEqual((IClone)fromDatum) || wgs84.IsEqual((IClone)toDatum)) { if (targetDatum.IsEqual((IClone)fromDatum) || targetDatum.IsEqual((IClone)toDatum)) { transList.Add(trans); } } } transList.Sort(transComparer.Compare); return(transList); }