public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return("NA"); } var point = value as IPoint; if (point == null) { return("NA"); } var result = string.Format("{0:0.0#####} {1:0.0#####}", point.Y, point.X); if (point.SpatialReference == null) { return(result); } var cn = point as IConversionNotation; if (cn != null) { switch (CoordinateConversionLibraryConfig.AddInConfig.DisplayCoordinateType) { case CoordinateTypes.DD: result = cn.GetDDFromCoords(6); break; case CoordinateTypes.DDM: result = cn.GetDDMFromCoords(4); break; case CoordinateTypes.DMS: result = cn.GetDMSFromCoords(2); break; //case CoordinateTypes.GARS: // result = cn.GetGARSFromCoords(); // break; case CoordinateTypes.MGRS: result = cn.CreateMGRS(5, true, esriMGRSModeEnum.esriMGRSMode_Automatic); break; case CoordinateTypes.USNG: result = cn.GetUSNGFromCoords(5, true, true); break; case CoordinateTypes.UTM: result = cn.GetUTMFromCoords(esriUTMConversionOptionsEnum.esriUTMAddSpaces | esriUTMConversionOptionsEnum.esriUTMUseNS); break; default: break; } } if (CoordinateConversionLibraryConfig.AddInConfig.IsCustomFormat) { InputFormatHelper inputFormatHelper = new InputFormatHelper(); result = inputFormatHelper.ProcessInput(result); } return(result); }
public string GetInputDisplayString() { string result = "NA"; try { if (Point == null || Point.IsEmpty) { return(result); } result = string.Format("{0:0.0#####} {1:0.0#####}", Point.Y, Point.X); if (Point.SpatialReference == null) { return(result); } var cn = (IConversionNotation)Point; if (cn != null) { switch (CoordinateConversionLibraryConfig.AddInConfig.DisplayCoordinateType) { case CoordinateTypes.DD: result = cn.GetDDFromCoords(6); break; case CoordinateTypes.DDM: result = cn.GetDDMFromCoords(4); break; case CoordinateTypes.DMS: result = cn.GetDMSFromCoords(2); break; //case CoordinateTypes.GARS: // result = cn.GetGARSFromCoords(); // break; case CoordinateTypes.MGRS: result = cn.CreateMGRS(5, true, esriMGRSModeEnum.esriMGRSMode_Automatic); break; case CoordinateTypes.USNG: result = cn.GetUSNGFromCoords(5, true, false); break; case CoordinateTypes.UTM: result = cn.GetUTMFromCoords(esriUTMConversionOptionsEnum.esriUTMAddSpaces); break; default: break; } if (CoordinateConversionLibraryConfig.AddInConfig.IsCustomFormat) { InputFormatHelper inputFormatHelper = new InputFormatHelper(); result = inputFormatHelper.ProcessInput(result); } } } catch { return("NA"); } return(result); }
public string GetInputDisplayString() { if (Point == null) { return("NA"); } var result = string.Format("{0:0.0#####} {1:0.0#####}", Point.Y, Point.X); if (Point.SpatialReference == null) { return(result); } ToGeoCoordinateParameter tgparam = null; try { switch (CoordinateConversionLibraryConfig.AddInConfig.DisplayCoordinateType) { case CoordinateTypes.DD: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.DD); tgparam.NumDigits = 6; result = Point.ToGeoCoordinateString(tgparam); break; case CoordinateTypes.DDM: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.DDM); tgparam.NumDigits = 4; result = Point.ToGeoCoordinateString(tgparam); break; case CoordinateTypes.DMS: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.DMS); tgparam.NumDigits = 2; result = Point.ToGeoCoordinateString(tgparam); break; //case CoordinateTypes.GARS: // tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.GARS); // result = Point.ToGeoCoordinateString(tgparam); // break; case CoordinateTypes.MGRS: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.MGRS); tgparam.Round = false; result = Point.ToGeoCoordinateString(tgparam); break; case CoordinateTypes.USNG: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.USNG); tgparam.NumDigits = 5; tgparam.AddSpaces = false; result = Point.ToGeoCoordinateString(tgparam); break; case CoordinateTypes.UTM: tgparam = new ToGeoCoordinateParameter(GeoCoordinateType.UTM); tgparam.GeoCoordMode = ToGeoCoordinateMode.UtmNorthSouth; result = Point.ToGeoCoordinateString(tgparam); break; default: break; } if (CoordinateConversionLibraryConfig.AddInConfig.IsCustomFormat) { InputFormatHelper inputFormatHelper = new InputFormatHelper(); result = inputFormatHelper.ProcessInput(result); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return("NA"); } return(result); }