private void UpdateCoordinateReadout(Point point) { var mp = _mapView.ScreenToLocation(point); if (mp == null) { return; } string coordinateReadout; // we can do DD, DMS, GARS, GEOREF, MGRS, USNG, UTM switch (_coordinateReadoutFormat) { case CoordinateReadoutFormat.DD: coordinateReadout = ConvertCoordinate.ToDecimalDegrees(mp, 3); break; case CoordinateReadoutFormat.DMS: coordinateReadout = ConvertCoordinate.ToDegreesMinutesSeconds(mp, 1); break; case CoordinateReadoutFormat.GARS: coordinateReadout = ConvertCoordinate.ToGars(mp); break; case CoordinateReadoutFormat.GEOREF: coordinateReadout = ConvertCoordinate.ToGeoref(mp, 4, true); break; case CoordinateReadoutFormat.MGRS: coordinateReadout = ConvertCoordinate.ToMgrs(mp, MgrsConversionMode.Automatic, 5, true, true); break; case CoordinateReadoutFormat.USNG: coordinateReadout = ConvertCoordinate.ToUsng(mp, 5, true, true); break; case CoordinateReadoutFormat.UTM: coordinateReadout = ConvertCoordinate.ToUtm(mp, UtmConversionMode.None, true); break; default: coordinateReadout = ConvertCoordinate.ToMgrs(mp, MgrsConversionMode.Automatic, 5, true, true); break; } _mapViewModel.CoordinateReadout = coordinateReadout; }
protected string LocationToString(MapPoint location, CoordinateFormat coordinateFormat) { switch (coordinateFormat) { case CoordinateFormat.DecimalDegrees: return(ConvertCoordinate.ToDecimalDegrees(location, 5)); case CoordinateFormat.DegreesDecimalMinutes: return(ConvertCoordinate.ToDegreesDecimalMinutes(location, 3)); case CoordinateFormat.Dms: return(ConvertCoordinate.ToDegreesMinutesSeconds(location, 1)); case CoordinateFormat.Mgrs: return(ConvertCoordinate.ToMgrs(location, MgrsConversionMode.Automatic, 5, true, true)); } return(null); }
private void OnGotoXYCoordinates(object obj) { try { var gitem = obj as GotoItem; var sr = SpatialReferences.Wgs84; if (gitem != null) { MapPoint mp; switch (gitem.Format) { case "DD": mp = ConvertCoordinate.FromDecimalDegrees(gitem.Coordinate, sr); break; case "DDM": mp = ConvertCoordinate.FromDegreesDecimalMinutes(gitem.Coordinate, sr); break; case "DMS": mp = ConvertCoordinate.FromDegreesMinutesSeconds(gitem.Coordinate, sr); break; case "GARS": mp = ConvertCoordinate.FromGars(gitem.Coordinate, sr, GarsConversionMode.Center); break; case "GEOREF": mp = ConvertCoordinate.FromGeoref(gitem.Coordinate, sr); break; case "MGRS": mp = ConvertCoordinate.FromMgrs(gitem.Coordinate, sr, MgrsConversionMode.Automatic); break; case "USNG": mp = ConvertCoordinate.FromUsng(gitem.Coordinate, sr); break; case "UTM": mp = ConvertCoordinate.FromUtm(gitem.Coordinate, sr, UtmConversionMode.None); break; default: mp = ConvertCoordinate.FromDecimalDegrees(gitem.Coordinate, SpatialReferences.Wgs84); break; } if (mp != null) { if (!String.IsNullOrWhiteSpace(gitem.Scale)) { _mapView.SetViewAsync(mp, Convert.ToDouble(gitem.Scale)); } else { _mapView.SetViewAsync(mp); } } else { MessageBox.Show("Failed to convert coordinate."); } } } catch { MessageBox.Show("Failed to convert coordinate."); } }
public string LayTatCa() { List <Feature> lstDM = new List <Feature>(); ConvertCoordinate cv = new ConvertCoordinate(); List <IPosition> coordinates = new List <IPosition>(); double dbLng = 0.0, dbLat = 0.0; //cv.TransMercatorToLatLonInt(419555.992, 2402145.992, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419547.000, 2402132.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419464.000, 2402157.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419320.000, 2402223.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419375.000, 2402033.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419022.000, 2402312.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419046.000, 2402329.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419055.000, 2402348.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419077.000, 2402373.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419198.000, 2402368.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419246.000, 2402390.000, ref dbLat, ref dbLng); //cv.TransMercatorToLatLonInt(419555.992, 2402145.992, ref dbLat, ref dbLng); cv.TransMercatorToLatLonInt(419555.992, 2402145.992, ref dbLat, ref dbLng); Position pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419547.000, 2402132.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419464.000, 2402157.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419320.000, 2402223.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419375.000, 2402033.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419022.000, 2402312.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419046.000, 2402329.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419055.000, 2402348.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419077.000, 2402373.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419198.000, 2402368.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419246.000, 2402390.000, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); cv.TransMercatorToLatLonInt(419555.992, 2402145.992, ref dbLat, ref dbLng); pnt = new Position(dbLat, dbLng); coordinates.Add(pnt); Polygon polygon = new Polygon(new List <LineString> { new LineString(coordinates) }); Dictionary <string, object> properties = new Dictionary <string, object> { { "id", "dm1" }, { "Name", "Sông Lô - Yên Sơn" }, { "DonViKT", "Cty TNHH Hiep Phu" } }; Feature feature = new Feature(polygon, properties); lstDM.Add(feature); return(JsonConvert.SerializeObject(lstDM)); }
public void JumpToPoint(string pointString) { MapPoint point = ConvertCoordinate.FromDecimalDegrees(pointString, RooSceneView.SpatialReference); RooSceneView.SetViewAsync(new Camera(point.Y, point.X, 1000, 0, 0)); }