private double GetLinearDistance(IMap map, double inputDistance, DistanceTypes distanceType)
{
if (map.SpatialReference == null)
return inputDistance;
DistanceTypes distanceTo = DistanceTypes.Meters; // default to meters
var pcs = map.SpatialReference as IProjectedCoordinateSystem;
if (pcs != null)
{
// need to convert the offset from the input distance type to the spatial reference linear type
distanceTo = GetDistanceType(pcs.CoordinateUnit.FactoryCode);
}
else
{
var gcs = map.SpatialReference as IGeographicCoordinateSystem;
if (gcs != null)
{
distanceTo = GetDistanceType(gcs.CoordinateUnit.FactoryCode);
}
}
var result = GetDistanceFromTo(distanceType, distanceTo, inputDistance);
return result;
}