public Site saveMapProjectInfo() { Site site = new Site(); //site.Project = txtboxProjName.Text.ToString(); //site.Name = txtBoxBeachName.Text.ToString(); if (txtBeachAngle.Text == string.Empty) site.Orientation = double.NaN; else site.Orientation = Convert.ToDouble(txtBeachAngle.Text.ToString()); if (textBoxCurrLat.Text == string.Empty || textBoxCurrLng.Text == string.Empty) { site.Location.Latitude = double.NaN; site.Location.Longitude = double.NaN; } else { //site.Location.Latitude = sitelocation.Lat; //site.Location.Longitude = sitelocation.Lng; site.Location.Latitude = Convert.ToDouble(textBoxCurrLat.Text); site.Location.Longitude = Convert.ToDouble(textBoxCurrLng.Text); } if (firstBeachMarker == null) { site.LeftMarker.Latitude = double.NaN; site.LeftMarker.Longitude = double.NaN; } else { site.LeftMarker.Latitude = firstBeachMarker.Position.Lat;//marker1.Lat; site.LeftMarker.Longitude = firstBeachMarker.Position.Lng;//marker1.Lng; } if (secondBeachMarker == null) { site.RightMarker.Latitude = double.NaN; site.RightMarker.Longitude = double.NaN; } else { site.RightMarker.Latitude = secondBeachMarker.Position.Lat;//marker2.Lat; site.RightMarker.Longitude = secondBeachMarker.Position.Lng;//marker2.Lng; } if (waterMarker == null) { site.WaterMarker.Latitude = double.NaN; site.WaterMarker.Longitude = double.NaN; } else { site.WaterMarker.Latitude = waterMarker.Position.Lat;//watermark.Lat; site.WaterMarker.Longitude = waterMarker.Position.Lng;//watermark.Lng; } return site; }
public VBCommon.Interfaces.IBeachSite Clone() { Site site = new Site(); site.BeachName = _name; site.Orientation = _orientation; site.Location.Latitude = _location.Latitude; site.Location.Longitude = _location.Longitude; site.LeftMarker.Latitude = _markerLeft.Latitude; site.LeftMarker.Longitude = _markerLeft.Longitude; site.RightMarker.Latitude = _markerRight.Latitude; site.RightMarker.Longitude = _markerRight.Longitude; site.WaterMarker.Latitude = _watermarker.Latitude; site.WaterMarker.Longitude = _watermarker.Longitude; return site; }
private void btnSelectWater_Click(object sender, EventArgs e) { try { if ((firstBeachMarker == null) || (secondBeachMarker == null)) return; btnSelectWater.Enabled = true; string addMarker = "Add Water Marker"; string removeMarker = "Remove Water Marker"; //GMap.NET.Point pointH2O = new GMap.NET.Point(); GMap.NET.Point pointH20 = new GMap.NET.Point(); //GMapNET.Point pointPerpendicular = new GMapNET.Point(); //GMap.NET.Point pointPerpendicular = new GMap.NET.Point(); if (btnSelectWater.Text == addMarker) { waterMarker = new GMapMarkerGoogleGreen(currentMarker.Position); //waterMarker = new GMapMarkerGoogleGreen(MainMap.CurrentPosition); //MainMap.Markers.Add(waterMarker); top.Markers.Add(waterMarker); btnSelectWater.Text = removeMarker; pointH20 = MainMap.FromLatLngToLocal(waterMarker.Position); //pointPerpendicular = CoordinatePerpendicular(); } else { btnSelectWater.Text = addMarker; //MainMap.Markers.Remove(waterMarker); top.Markers.Remove(waterMarker); waterMarker = null; txtBeachAngle.Text = string.Empty; return; } ////////////////////////////////////////////// GMap.NET.Point pointA = MainMap.FromLatLngToLocal(firstBeachMarker.Position); GMap.NET.Point pointB = MainMap.FromLatLngToLocal(secondBeachMarker.Position); GMap.NET.Point pointWM = MainMap.FromLatLngToLocal(waterMarker.Position); //GMapNET.Point pointA = MainMap.FromLatLngToLocal(firstBeachMarker.Position); //GMapNET.Point pointB = MainMap.FromLatLngToLocal(secondBeachMarker.Position); int side = CoordinatePerpendicular(); ////rotate marker points thru -pi/2 since we want due N as zero //GMap.NET.Point Aprime = rotatePt(-Math.PI / 2, pointA); //GMap.NET.Point Bprime = rotatePt(-Math.PI / 2, pointB); //GMap.NET.Point WMprime = rotatePt(-Math.PI / 2, pointWM); //returns negative angles ccw from pos x axis thru -pi (quads I and II), //returns positive angles cw from pos x axis thru pi (quads IV and III) double angle = Math.Atan2(pointB.Y - pointA.Y, pointB.X - pointA.X); double deg = RadianToDegree((float)angle); //double angle = Math.Atan2(Bprime.Y - Aprime.Y, Bprime.X - Aprime.X); //double deg = RadianToDegree((float)angle); //slope //double deltaX = Bprime.X - Aprime.X; //double slope = double.NaN; //if (deltaX != 0) slope = (Bprime.Y - Aprime.Y) / deltaX; double deltaX = pointB.X - pointA.X; double slope = double.NaN; if (deltaX != 0) slope = (pointB.Y - pointA.Y) / deltaX; //negates order of pts for angle calc; computes -90 < deg < 90 if (slope.Equals(double.NaN)) { deg = 90.0; if (pointA.Y > pointB.Y) deg = -90; } else if (slope > 0) { if (deg < 0) deg = deg + 180.0; } else if (slope < 0) { if (deg > 0) deg = deg - 180.0; } else { deg = 0.0; } //get angle relative to N (N==0deg) and relative to side of line user selects if (side > 0) { deg = deg + 90.0; //translate quadrant i to quadrant iii in ccw direction (i.e., make 135 == -270) //correct??? makes MC's angles as documented. //if (deg > 90.0 && deg <= 135.0) deg = deg - 360.0; } else { deg = deg - 90.0; } txtBeachAngle.Text = deg.ToString("####0.##"); _site = new Site(); _site.Orientation = deg; _site.Location.Latitude = Convert.ToDouble(textBoxCurrLat.Text); _site.Location.Longitude = Convert.ToDouble(textBoxCurrLng.Text); _site.LeftMarker.Latitude = firstBeachMarker.Position.Lat;//marker1.Lat; _site.LeftMarker.Longitude = firstBeachMarker.Position.Lng;//marker1.Long; _site.RightMarker.Latitude = secondBeachMarker.Position.Lat;//marker2.Lat; _site.RightMarker.Longitude = secondBeachMarker.Position.Lng;//marker2.Long; _site.WaterMarker.Latitude = waterMarker.Position.Lat;//watermark.Lat; _site.WaterMarker.Longitude = waterMarker.Position.Lng;//watermark.Long; if (_plugin != null) { //VBCommon.Interfaces.IBeachSite site = _plugin as VBCommon.Interfaces.IBeachSite; _plugin.Site = _site.Clone(); } } catch (Exception ex) { string message = ex.Message; } return; }