public static Point2D MetersToLatLon(Point2D point) { double lon = point.X / HalfEarthCircumferenceInMeters * 180.0; double lat = point.Y / HalfEarthCircumferenceInMeters * 180.0; lat = 180 / Math.PI * (2 * Math.Atan(Math.Exp(lat * Math.PI / 180.0)) - Math.PI / 2); return new Point2D(lon, lat); }
/// <summary>${core_Rectangle2D_constructor_Point2D_Point2D_D}</summary> /// <overloads>${core_Rectangle2D_constructor_overloads}</overloads> /// <param name="point1">${core_Rectangle2D_constructor_Point2D_Point2D_param_bottomLeft}</param> /// <param name="point2">${core_Rectangle2D_constructor_Point2D_Point2D_param_topRight}</param> public Rectangle2D(Point2D point1, Point2D point2) { this._x = Math.Min(point1.X, point2.X); this._y = Math.Min(point1.Y, point2.Y); this._width = Math.Max((double)(Math.Max(point1.X, point2.X) - this._x), (double)0.0); this._height = Math.Max((double)(Math.Max(point1.Y, point2.Y) - this._y), (double)0.0); }
private void node_DrawCompleted(object sender, DrawEventArgs e) { Pushpin pushpin = new Pushpin(); //将事件点以图钉样式加到ElementsLayerE上 if (eventPonit.IsChecked == true) { //因为事件点只有一个,因此判断是否存在事件点,如果存在就先将以前的事件点删除 if (flag == true) { elementsLayerE.Children.Clear(); } pushpin.Location = e.Geometry.Bounds.Center; pushpin.Content = "E"; pushpin.Background = new SolidColorBrush(Colors.Red); elementsLayerE.AddChild(pushpin); flag = true; //记录事件点坐标 eventp = pushpin.Location; } //将设施点以图钉样式加到ElementsLayer上 if (FacilityPoint.IsChecked == true) { pushpin.Location = e.Geometry.Bounds.Center; pushpin.Content = "F"; pushpin.Background = new SolidColorBrush(Colors.Purple); elementsLayerF.AddChild(pushpin); //用 points 数组记录设施点坐标 points.Add(pushpin.Location); } }
public static Point2D LatLonToMeters(Point2D point) { double mx = point.X / 180.0 * HalfEarthCircumferenceInMeters; double my = Math.Log(Math.Tan((90 + point.Y) * Math.PI / 360.0)) / (Math.PI / 180.0); my = my / 180.0 * HalfEarthCircumferenceInMeters; return new Point2D(mx, my); }
//清除图层 private void Clear_Click(object sender, RoutedEventArgs e) { arbitraryLayerF.Children.Clear(); arbitraryLayerE.Children.Clear(); featuresLayer.ClearFeatures(); eventp = Point2D.Empty; }
public static Point MapToScreen(Point2D pt2D, Point2D origin, double resolution) { if ((!origin.IsEmpty) && !double.IsNaN(resolution)) { return new Point((pt2D.X - origin.X) / resolution, (origin.Y - pt2D.Y) / resolution); } return new Point(double.NaN, double.NaN); }
/// <summary>${utility_JsonHelper_method_FromPoint2D_D}</summary> public static string FromPoint2D(Point2D point) { if (point.IsEmpty) { return "{}"; //string.Empty? null? } return string.Format(CultureInfo.InvariantCulture, "{{\"x\":{0},\"y\":{1}}}", point.X, point.Y); }
public ISClosestFacility() { InitializeComponent(); eventp = new Point2D(); arbitraryLayerE = this.MyMap.Layers["MyArbitraryLayerE"] as ElementsLayer; arbitraryLayerF = this.MyMap.Layers["MyArbitraryLayerF"] as ElementsLayer; featuresLayer = this.MyMap.Layers["MyFeaturesLayer"] as FeaturesLayer; }
//清除图层上的全部元素并清空点坐标记录 private void Clear_Click(object sender, RoutedEventArgs e) { elementsLayerF.Children.Clear(); elementsLayerE.Children.Clear(); featuresLayer.ClearFeatures(); points.Clear(); eventp = Point2D.Empty; flag = false; }
private static Point2D EdgeIntersection(Point2D p0, Point2D p1, double val, bool horizontal) { Point2D point = new Point2D(p1.X - p0.X, p1.Y - p0.Y); if (horizontal) { return new Point2D(p0.X + ((point.X / point.Y) * (val - p0.Y)), val); } return new Point2D(val, p0.Y + ((point.Y / point.X) * (val - p0.X))); }
internal string GetCoorStr(Point2D p1, Point2D p2) { string str = string.Empty; if (!p1.IsEmpty && !p2.IsEmpty) { str = p1.ToString(CultureInfo.InvariantCulture) + " " + p2.ToString(CultureInfo.InvariantCulture); } return str; }
/// <summary>${core_GeoCircle_constructor_Point2D_double_D}</summary> /// <param>${core_GeoCircle_constructor_Point2D_double_param__center}</param> /// <param>${core_GeoCircle_constructor_Point2D_double_param__radius}</param> public GeoCircle(Point2D _center, double _radius) { this.Parts = new ObservableCollection<Point2DCollection>(); if (_center != null) { this.center = _center; this.radius = _radius; caculateParts(); } }
public static string FromPoint2DWithTag(Point2D point,string tagName,bool isNumber) { if (point.IsEmpty) { return "{}"; //string.Empty? null? } string format; if (isNumber) { format = "{{\"x\":{0},\"y\":{1},\"{2}\":{3}}}"; } else { format = "{{\"x\":{0},\"y\":{1},\"{2}\":\"{3}\"}}"; } return string.Format(CultureInfo.InvariantCulture, format, point.X, point.Y,tagName,point.Tag.ToStringEx()); }
internal static Point Point2DToLogicalPoint(Point2D point) { double num; if (point.Y > 85.051128) { num = 0.0; } else if (point.Y < -85.051128) { num = 1.0; } else { double num2 = Math.Sin((point.X * 3.1415926535897931) / 180.0); num = 0.5 - (Math.Log((1.0 + num2) / (1.0 - num2)) / 12.566370614359173); } return new Point((point.X + 180.0) / 360.0, num); }
/// <summary>${ui_action_DrawRect_constructor_Map_D}</summary> /// <example> /// <code lang="CS"> /// DrawRectangle draw = new DrawRectangle(MyMap,Cursors.Stylus) /// </code> /// </example> /// <param name="map">${ui_action_DrawRect_constructor_Map_param_map}</param> /// <param name="cursor">${ui_action_MapAction_constructor_Map_param_cursor}</param> public DrawRectangle(Map map , Cursor cursor) : base(map , "DrawRectangle" , cursor) { startPt = Point2D.Empty; if (map.Theme == null) { Stroke = new SolidColorBrush(Colors.Green); StrokeThickness = MagicNumber.ACTION_STYLE_DEFAULT_STROKETHICKNESS; Fill = new SolidColorBrush(Colors.Black); Opacity = MagicNumber.ACTION_STYLE_DEFAULT_OPACITY; } else { this.Stroke = map.Theme.Stroke; this.StrokeThickness = map.Theme.StrokeThickness; this.Fill = map.Theme.Fill; this.Opacity = map.Theme.Opacity; } }
private Point2D ClipLineSegment(Point2D p0, Point2D p1, Rectangle2D box) { Point2D point = new Point2D(p1.X, p1.Y); if (p1.X < box.Left) { point = EdgeIntersection(p0, p1, box.Left, false); } else if (p1.X > box.Right) { point = EdgeIntersection(p0, p1, box.Right, false); } if (point.Y < box.Bottom) { return EdgeIntersection(p0, p1, box.Bottom, true); } if (point.Y > box.Top) { point = EdgeIntersection(p0, p1, box.Top, true); } return point; }
private void sqlService_ProcessCompleted(object sender, QueryEventArgs e) { int zMin = Convert.ToInt32(zMinValue.Text); int zMax = Convert.ToInt32(zMaxValue.Text); FeatureCollection fc = e.Result.Recordsets[0].Features; for (int i = 0; i < fc.Count; i++) { GeoPoint gp = fc[i].Geometry as GeoPoint; var z = random.Next(zMin, zMax); Point2D point = new Point2D() { X = gp.X, Y = gp.Y, Tag = z }; inputPoints.Add(point); } InterpolationIDWAnalystParameters idwParams = new InterpolationIDWAnalystParameters() { Bounds = new Rectangle2D(-2640403.6321084504, 1873792.1034850003, 3247669.390292245, 5921501.395578556), OutputDataset = "idwcretepoints", OutputDataSource = "Interpolation", SearchMode=SearchMode.KDTREE_FIXED_RADIUS, InterpolationAnalystType=InterpolationAnalystType.GEOMETRY, InputPoints = inputPoints }; InterpolationAnalystService service = new InterpolationAnalystService(url); service.ProcessCompleted += new EventHandler<InterpolateAnalystArgs>(processCompleted); service.Failed += new EventHandler<SuperMap.Web.Service.ServiceFailedEventArgs>(excuteErrors); service.ProcessAsync(idwParams); }
/// <summary>${controls_InfoWindow_method_ShowInfoWindowPo_D}</summary> /// <param name="loc">${controls_InfoWindow_method_ShowInfoWindow_param_loc}</param> /// <param name="off">${controls_InfoWindow_method_ShowInfoWindow_param_off}</param> public void ShowInfoWindow(Point2D loc, Point off) { this.location = loc; this.offset = off; this.Visibility = Visibility.Visible; //ChangePosition();这句话导致了无法获取对象树中的window对象的问题。 CompositionTarget.Rendering -= new EventHandler(CompositionTarget_Rendering); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); if (isOnApplyTemplate) { AdjustPisition(); } }
/// <summary>${controls_InfoWindow_method_ShowInfoWindowPoint2D_D}</summary> /// <param name="location">${controls_InfoWindow_method_ShowInfoWindow_param_location}</param> public void ShowInfoWindow(Point2D location) { ShowInfoWindow(location, offset); }
private void Activate(Point2D item) { if (Map == null || Map.Layers == null) { return; } ellipse = new Ellipse(); #region 所有风格的控制 ellipse.Stroke = Stroke; ellipse.StrokeThickness = StrokeThickness; ellipse.Fill = Fill; ellipse.StrokeMiterLimit = StrokeMiterLimit; ellipse.StrokeDashOffset = StrokeDashOffset; ellipse.StrokeDashArray = StrokeDashArray; ellipse.StrokeDashCap = StrokeDashCap; ellipse.StrokeEndLineCap = StrokeEndLineCap; ellipse.StrokeLineJoin = StrokeLineJoin; ellipse.StrokeStartLineCap = StrokeStartLineCap; ellipse.Opacity = Opacity; #endregion DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); ellipse.SetValue(ElementsLayer.BBoxProperty, new Rectangle2D(item, item)); DrawLayer.Children.Add(ellipse); isActivated = true; isDrawing = true; }
/// <summary>${ui_action_MapAction_event_onMouseDown_D}</summary> /// <param name="e">${ui_action_MapAction_event_onMouseDown_param_e}</param> public override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { Point2D item = Map.ScreenToMap(e.GetPosition(Map)); startPt = item; if (!isActivated) { this.Activate(item); } e.Handled = true; base.OnMouseLeftButtonDown(e); }
private void Activate() { pentagram = new PolygonElement(); #region 所有风格的控制 pentagram.Stroke = this.Stroke; pentagram.StrokeThickness = this.StrokeThickness; pentagram.Fill = this.Fill; pentagram.FillRule = this.FillRule; pentagram.Opacity = this.Opacity; pentagram.StrokeMiterLimit = this.StrokeMiterLimit; pentagram.StrokeDashOffset = this.StrokeDashOffset; pentagram.StrokeDashArray = this.StrokeDashArray; pentagram.StrokeDashCap = this.StrokeDashCap; pentagram.StrokeEndLineCap = this.StrokeEndLineCap; pentagram.StrokeLineJoin = this.StrokeLineJoin; pentagram.StrokeStartLineCap = this.StrokeStartLineCap; #endregion a0 = new Point2D(); a1 = new Point2D(); a2 = new Point2D(); a3 = new Point2D(); a4 = new Point2D(); points = new Point2DCollection(); pentagram.Point2Ds = points; oldPentagrams = new List<PolygonElement>(); DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); isActivated = true; isDrawing = true; }
public override void OnMouseMove(MouseEventArgs e) { if (isDrawing) { for (int i = 0; i < oldPentagrams.Count - 1; i++) { DrawLayer.Children.Remove(oldPentagrams[i]); } Point2D item = Map.ScreenToMap(e.GetPosition(Map)); #region 五角星算法 maxX = Math.Max(startPt.X, item.X); minX = Math.Min(startPt.X, item.X); maxY = Math.Max(startPt.Y, item.Y); minY = Math.Min(startPt.Y, item.Y); om = Math.Cos((2 * Math.PI) / 5) * (maxY - minY) / 2; a1m = Math.Sin((2 * Math.PI) / 5) * (maxY - minY) / 2; a0x = (maxY - minY) / 2 + minX; a0y = maxY; ox = (maxY - minY) / 2 + minX; oy = maxY + (minY - maxY) / 2; o = new Point2D(ox, oy); a0 = new Point2D(a0x, a0y); a1 = new Point2D(ox - a1m, oy + om); a2 = new Point2D(ox + a1m, oy + om); a3 = new Point2D(ox - Math.Sin(Math.PI / 5) * (maxY - minY) / 2, oy - Math.Cos(Math.PI / 5) * (maxY - minY) / 2); a4 = new Point2D(ox + Math.Sin(Math.PI / 5) * (maxY - minY) / 2, oy - Math.Cos(Math.PI / 5) * (maxY - minY) / 2); points.Clear(); points.Add(a0); points.Add(a3); points.Add(a2); points.Add(a1); points.Add(a4); #endregion //pentagram.Point2Ds = points; DrawLayer.Children.Add(pentagram); oldPentagrams.Add(pentagram);//等待删除 } base.OnMouseMove(e); }
public override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { startPt = Map.ScreenToMap(e.GetPosition(Map)); if (!isActivated) { Activate(); } e.Handled = true; base.OnMouseLeftButtonDown(e); }
private void Activate(Point2D firstPoint) { if (DrawLayer != null) { DrawLayer.Children.Clear(); } if (Map != null) { Map.Layers.Remove(DrawLayer); } DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); Map.Layers.Add(tempLayer); polyline = new PolylineElement(); #region 所有风格的控制 polyline.Stroke = Stroke; polyline.StrokeThickness = StrokeThickness; polyline.StrokeMiterLimit = StrokeMiterLimit; polyline.StrokeDashOffset = StrokeDashOffset; polyline.StrokeDashArray = StrokeDashArray; polyline.StrokeDashCap = StrokeDashCap; polyline.StrokeEndLineCap = StrokeEndLineCap; polyline.StrokeLineJoin = StrokeLineJoin; polyline.StrokeStartLineCap = StrokeStartLineCap; polyline.Opacity = Opacity; polyline.Fill = Fill; polyline.FillRule = FillRule; #endregion points = new Point2DCollection(); polyline.Point2Ds = points; points.Add(firstPoint); points.Add(firstPoint); DrawLayer.Children.Add(polyline); isDrawing = true; isActivated = true; }
public override void OnMouseMove(MouseEventArgs e) { if (isDrawing) { Point2D item = Map.ScreenToMap(e.GetPosition(Map)); if (Math.Round(item.X, 4) == Math.Round(ps[0].X, 4) && Math.Round(item.Y, 4) == Math.Round(ps[0].Y, 4)) { return; } Point2D last = points[points.Count - 1]; points.Remove(last); points.Add(item); //获取移动中的点 Point2D movePoint = Map.ScreenToMap(e.GetPosition(Map)); GeoPoint moveP = new GeoPoint(movePoint.X, movePoint.Y); //算出两点距离 //double moveDistance = Math.Sqrt(Math.Abs(moveP.X - startP.X) + Math.Abs(moveP.Y - startP.Y)); double moveDistance = Math.Sqrt((moveP.X - startP.X) * (moveP.X - startP.X) + (moveP.Y - startP.Y) * (moveP.Y - startP.Y)); // measureMiddleResult.Text = moveDistance.ToString(); measureMiddleResult.Text = string.Format("{0:0.0000}", moveDistance); Point2D middle = new Point2D((movePoint.X + startPoint.X) / 2, (movePoint.Y + startPoint.Y) / 2); // 清除临时TextBlocks,在这里清除能提高效率。 tempLayer.Children.Clear(); tempLayer.AddChild(measureMiddleResult, middle); sumLast = sum + moveDistance; // measureFinallyResult.Text = "总长度:" + s.ToString() + "km"; measureFinallyResult.Text = "总长度:" + string.Format("{0:0.0000}", sumLast) + "km"; } base.OnMouseMove(e); }
public override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { startPoint = Map.ScreenToMap(e.GetPosition(Map)); if (!isActivated) { Activate(startPoint); } else { points.Add(startPoint); } startP = new GeoPoint(startPoint.X, startPoint.Y); //每段分别计算 measureMiddleResult = new TextBlock(); measureMiddleResult.FontWeight = FontWeights.ExtraBlack; measureMiddleResult.Foreground = new SolidColorBrush(Colors.Green); textBlockContainer.Add(measureMiddleResult); for (int k = clickeds; k < textBlockContainer.Count; k++) { if (clickeds == 0) { break; } if (textBlockContainer[k - 1].Text == "") { return; } sum = sum + Convert.ToDouble(textBlockContainer[k - 1].Text); } clickeds++; //记录每个点 ps.Add(startPoint); //第一次开始或者是双击后继续 if (isOver || clickeds <= 1) { sum = 0; DrawLayer.AddChild(measureFinallyResult, startPoint); isOver = false; } if (DrawLayer != null && clickeds > 1) { //重新算中点坐标和距离 Point2D middlePoints = new Point2D((startPoint.X + ps[ps.Count - 2].X) / 2, (startPoint.Y + ps[ps.Count - 2].Y) / 2); double middleDistance = Math.Sqrt((startPoint.X - ps[ps.Count - 2].X) * (startPoint.X - ps[ps.Count - 2].X) + (startPoint.Y - ps[ps.Count - 2].Y) * (startPoint.Y - ps[ps.Count - 2].Y)); TextBlock tb = new TextBlock(); tb.FontWeight = FontWeights.ExtraBlack; tb.Foreground = new SolidColorBrush(Colors.Green); tb.Text = string.Format("{0:0.0000}", middleDistance); DrawLayer.AddChild(tb, middlePoints); } e.Handled = true; base.OnMouseLeftButtonDown(e); }
private Point MapToScreen(Point2D pt) { return CoordinateTransformationHelper.MapToScreen(pt, new Point2D(OriginX, OriginY), this.Resolution); }
void action_DrawCompleted(object sender, DrawEventArgs e) { _elementsLayer.Children.Remove(pushpin); //this.boder.Visibility = Visibility.Collapsed; Route route = new Route(); if (_routeLayer.Features.Count > 0) { Feature f = _routeLayer.Features[0]; route = f.Geometry as Route; } pushpin.IsEnabled = false; pushpin.Location = e.Geometry.Bounds.Center; pushpin.Background = new SolidColorBrush(Colors.Red); pushpin.Content = "O"; _elementsLayer.AddChild(pushpin); _queryPoint = (e.Geometry as GeoPoint).Location; RouteCalculateMeasureParameters param = new RouteCalculateMeasureParameters(); param.IsIgnoreGap = true; param.Point = _queryPoint; param.SourceRoute = route; param.Tolerance = 100; RouteCalculateMeasureService service = new RouteCalculateMeasureService(_serviceUrl); service.ProcessComplated += service_ProcessComplated; service.Failed += service_Failed; service.ProcessAsync(param); }
private static string GetCoorStr(Point2D p) { string str = string.Empty; str = p.ToString(CultureInfo.InvariantCulture); return str; }