private CoordinateType GetCoordinateType(string input, out ESRI.ArcGIS.Geometry.IPoint point)
{
point = new PointClass();
var cn = point as IConversionNotation;
Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(t);
ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory;
// Use the enumeration to create an instance of the predefined object.
IGeographicCoordinateSystem geographicCS =
srFact.CreateGeographicCoordinateSystem((int)
esriSRGeoCSType.esriSRGeoCS_WGS1984);
point.SpatialReference = geographicCS;
try
{
cn.PutCoordsFromDD(input);
return CoordinateType.DD;
}
catch { }
try
{
cn.PutCoordsFromDDM(input);
return CoordinateType.DDM;
}
catch { }
try
{
cn.PutCoordsFromDMS(input);
return CoordinateType.DMS;
}
catch { }
try
{
cn.PutCoordsFromGARS(esriGARSModeEnum.esriGARSModeCENTER, input);
return CoordinateType.GARS;
}
catch { }
try
{
cn.PutCoordsFromGARS(esriGARSModeEnum.esriGARSModeLL, input);
return CoordinateType.GARS;
}
catch { }
CoordinateGARS gars;
if(CoordinateGARS.TryParse(input, out gars))
{
try
{
cn.PutCoordsFromGARS(esriGARSModeEnum.esriGARSModeCENTER, gars.ToString("", new CoordinateGARSFormatter()));
return CoordinateType.GARS;
}
catch { }
}
try
{
cn.PutCoordsFromMGRS(input, esriMGRSModeEnum.esriMGRSMode_Automatic);
return CoordinateType.MGRS;
}
catch { }
try
{
cn.PutCoordsFromMGRS(input, esriMGRSModeEnum.esriMGRSMode_NewStyle);
return CoordinateType.MGRS;
}
catch { }
try
{
cn.PutCoordsFromMGRS(input, esriMGRSModeEnum.esriMGRSMode_NewWith180InZone01);
return CoordinateType.MGRS;
}
catch { }
try
{
cn.PutCoordsFromMGRS(input, esriMGRSModeEnum.esriMGRSMode_OldStyle);
return CoordinateType.MGRS;
}
catch { }
try
{
cn.PutCoordsFromMGRS(input, esriMGRSModeEnum.esriMGRSMode_OldWith180InZone01);
return CoordinateType.MGRS;
}
catch { }
// mgrs try parse
CoordinateMGRS mgrs;
if (CoordinateMGRS.TryParse(input, out mgrs))
{
try
{
cn.PutCoordsFromMGRS(mgrs.ToString("", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_NewStyle);
return CoordinateType.MGRS;
}
catch { }
}
try
{
cn.PutCoordsFromUSNG(input);
return CoordinateType.USNG;
}
catch { }
CoordinateUSNG usng;
if(CoordinateUSNG.TryParse(input, out usng))
{
try
{
cn.PutCoordsFromUSNG(usng.ToString("", new CoordinateMGRSFormatter()));
return CoordinateType.USNG;
}
catch { }
}
try
{
cn.PutCoordsFromUTM(esriUTMConversionOptionsEnum.esriUTMAddSpaces, input);
return CoordinateType.UTM;
}
catch { }
try
{
cn.PutCoordsFromUTM(esriUTMConversionOptionsEnum.esriUTMNoOptions, input);
return CoordinateType.UTM;
}
catch { }
try
{
cn.PutCoordsFromUTM(esriUTMConversionOptionsEnum.esriUTMUseNS, input);
return CoordinateType.UTM;
}
catch { }
CoordinateUTM utm;
if(CoordinateUTM.TryParse(input, out utm))
{
try
{
cn.PutCoordsFromUTM(esriUTMConversionOptionsEnum.esriUTMNoOptions, utm.ToString("", new CoordinateUTMFormatter()));
return CoordinateType.UTM;
}
catch { }
}
return CoordinateType.Unknown;
}