${WP_WP_core_Point2D_Title}
${WP_WP_core_Point2D_Description}
private void Activate(Point2D firstPoint) { DrawLayer = new ElementsLayer(); if (Map.Layers == null) { return; } Map.Layers.Add(DrawLayer); 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 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>${WP_core_Rectangle2D_constructor_Point2D_Point2D_D}</summary> /// <param name="point1">${WP_core_Rectangle2D_constructor_Point2D_Point2D_param_bottomLeft}</param> /// <param name="point2">${WP_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); }
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 Activate(Point2D item) { if (Map == null || Map.Layers == null) { return; } DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); rectangle = new Rectangle(); rectangle.Stroke = this.Stroke; rectangle.StrokeThickness = this.StrokeThickness; rectangle.StrokeMiterLimit = this.StrokeMiterLimit; rectangle.StrokeDashOffset = this.StrokeDashOffset; rectangle.StrokeDashArray = this.StrokeDashArray; rectangle.StrokeDashCap = this.StrokeDashCap; rectangle.StrokeEndLineCap = this.StrokeEndLineCap; rectangle.StrokeLineJoin = this.StrokeLineJoin; rectangle.StrokeStartLineCap = this.StrokeStartLineCap; rectangle.Opacity = this.Opacity; rectangle.Fill = this.Fill; rectangle.SetValue(ElementsLayer.BBoxProperty , new Rectangle2D(item , item)); DrawLayer.Children.Add(rectangle); isActivated = true; isDrawing = true; }
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; }
public static Point MapToScreen(Point2D pt2D, Point2D origin, double resolution) { if ((!Point2D.IsNullOrEmpty(origin)) && !double.IsNaN(resolution)) { return new Point((pt2D.X - origin.X) / resolution, (origin.Y - pt2D.Y) / resolution); } return new Point(double.NaN, double.NaN); }
/// <summary>${WP_core_GeoCircle_constructor_Point2D_double_D}</summary> /// <param>${WP_core_GeoCircle_constructor_Point2D_double_param__center}</param> /// <param>${WP_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(); } }
//计算parts private void caculateParts() { double unitsAngle = 360 / 72; double startAngle = 0; double unitsPI = Math.PI / 180; this.parts.Clear(); Point2DCollection item = new Point2DCollection(); for (int i = 0; i < 72; i++) { Point2D p = new Point2D(Math.Cos(startAngle * unitsPI) * this.radius + center.X, Math.Sin(startAngle * unitsPI) * this.radius + center.Y); item.Add(p); startAngle += unitsAngle; } this.parts.Add(item); }
/// <summary> /// ${WP_core_Point2D_method_IsNullOrEmpty_D} /// </summary> /// <param name="point">${WP_core_Point2D_method_IsNullOrEmpty_param_point}</param> /// <returns>${WP_core_Point2D_method_IsNullOrEmpty_return}</returns> public static bool IsNullOrEmpty(Point2D point) { if (point == null) { return true; } if (point.X.ValueCheck() && point.Y.ValueCheck()) { return false; } else { return true; } }
private void Activate(Point2D item) { if (this.map == null || this.map.Layers == null) { return; } DrawLayer = new ElementsLayer(); this.map.Layers.Add(DrawLayer); rectangle = new Rectangle(); rectangle.SetValue(ElementsLayer.BBoxProperty , new Rectangle2D(item , item)); DrawLayer.Children.Add(rectangle); isActivated = true; isDrawing = true; }
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> public DrawRectangle(Map map ) : base(map , "DrawRectangle") { 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 void Activate(Point2D firstPoint) { if (Map == null || Map.Layers == null) { return; } DrawLayer = new ElementsLayer(); Map.Layers.Add(DrawLayer); startPoint = firstPoint; polygon = new PolygonElement(); #region 所有风格的控制 polygon.Stroke = this.Stroke; polygon.StrokeThickness = this.StrokeThickness; polygon.StrokeMiterLimit = this.StrokeMiterLimit; polygon.StrokeDashOffset = this.StrokeDashOffset; polygon.StrokeDashArray = this.StrokeDashArray; polygon.StrokeDashCap = this.StrokeDashCap; polygon.StrokeEndLineCap = this.StrokeEndLineCap; polygon.StrokeLineJoin = this.StrokeLineJoin; polygon.StrokeStartLineCap = this.StrokeStartLineCap; polygon.Opacity = this.Opacity; polygon.Fill = this.Fill; polygon.FillRule = this.FillRule; #endregion points = new Point2DCollection(); polygon.Point2Ds = points; points.Add(firstPoint); points.Add(firstPoint); points.Add(firstPoint); DrawLayer.Children.Add(polygon); isDrawing = true; isActivated = true; }
private static Point2D StringToPoint2D(string value) { if (string.IsNullOrEmpty(value)) { return Point2D.Empty; } string[] array = value.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 2) { return Point2D.Empty; } bool success = true; double[] valuesArray = new double[2]; for (int i = 0; i < 2; i++) { double convertValue = 0; if (!double.TryParse(array[i], out convertValue)) { success = false; break; } else { valuesArray[i] = convertValue; } } if (success) { Point2D point = new Point2D(valuesArray[0], valuesArray[1]); return point; } else { return Point2D.Empty; } }
private void CompassButton_Click_1(object sender, RoutedEventArgs e) { if (_canPan) { _canPan = false; Point2D pointLonLat = new Point2D(102.95, 30.3); Point2D pointM = MercatorUtility.LatLonToMeters(pointLonLat); MyMap.ZoomToLevel(8, pointM); Feature earthquake = new Feature(); earthquake.Style = App.Current.Resources["MyMarkerStyle"] as MarkerStyle; earthquake.Geometry = new GeoPoint(pointM); _fLayer.AddFeature(earthquake); _addFeature = new DispatcherTimer(); _addFeature.Interval = new TimeSpan(0, 0, 0, 0, 500); _addFeature.Tick += _addFeature_Tick; _addFeature.Start(); } }
private static string GetCoorStr(Point2D p) { string str = string.Empty; str = p.ToString(CultureInfo.InvariantCulture); return str; }
/// <summary>${WP_core_Rectangle2D_constructor_Point2D_Double_D}</summary> /// <param name="bottomLeft">${WP_core_Rectangle2D_constructor_Point2D_Double_param_bottomLeft}</param> /// <param name="width">${WP_core_Rectangle2D_constructor_Point2D_Double_param_width}</param> /// <param name="height">${WP_core_Rectangle2D_constructor_Point2D_Double_param_height}</param> public Rectangle2D(Point2D bottomLeft, double width, double height) : this(bottomLeft.X, bottomLeft.Y, bottomLeft.X + width, bottomLeft.Y + height) { }
/// <summary>${WP_core_Rectangle2D_method_containsPoint2D_D}</summary> /// <returns>${WP_core_Rectangle2D_method_containsPoint2D_return_sl}</returns> /// <param name="point">${WP_core_Rectangle2D_method_containsPoint2D_param_point}</param> public bool Contains(Point2D point) { return this.Contains(point.X, point.Y); }
/// <summary>${WP_core_Rectangle2D_method_union_Point2D_D}</summary> /// <overloads>${WP_core_Rectangle2D_method_union_overloads}</overloads> /// <param name="point">${WP_core_Rectangle2D_method_union_Point2D_param_point}</param> /// <returns>${WP_core_Rectangle2D_method_union_return}</returns> public Rectangle2D Union(Point2D point) { return this.Union(new Rectangle2D(point, point)); }
/// <summary>${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_double_D}</summary> /// <param name="element">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param> /// <param name="location">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_param_location}</param> /// <param name="referenceLength">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_double_param_referenceLength}</param> public void AddChild(UIElement element, Point2D location, double referenceLength) { element.SetValue(ReferLengthProperty, referenceLength); AddChild(element, new Rectangle2D(location, location)); }
private void LocationChanged(GeoCoordinate position) { Dispatcher.BeginInvoke(async() => { CompassMarkerStyle style = _compassFeature.Style as CompassMarkerStyle; GeoPoint location = _compassFeature.Geometry as GeoPoint; Point2D locationOffer = await LocationOffer(new Point2D(position.Longitude, position.Latitude)); Point2D met = MercatorUtility.LatLonToMeters(new Point2D(locationOffer.X, locationOffer.Y)); location.Location = new Point2D(met.X, met.Y); if (_needPan) { if (Math.Abs(position.Longitude - _location.X) > 0.005 || Math.Abs(position.Latitude - _location.Y) > 0.005) { MyMap.PanTo(location.Location); } _needPan = false; } _location = new Point2D(position.Longitude, position.Latitude); }); }
private void Init(Point2D firstPoint) { if (_isInited) { return; } Deactivate(); _line = new Feature(); GeoLine line = new GeoLine(); line.Parts = new System.Collections.ObjectModel.ObservableCollection<Point2DCollection>(); line.Parts.Add(_points); PredefinedLineStyle style = new PredefinedLineStyle(); style.Stroke = new SolidColorBrush(Colors.Red); style.StrokeThickness = 2; style.Symbol = PredefinedLineStyle.LineSymbol.Solid; _line.Geometry = line; _line.Style = style; _fLayer.AddFeature(_line); TextBlock first = new TextBlock(); _distanceList.Add(first); first.FontWeight = FontWeights.ExtraBlack; first.Foreground = new SolidColorBrush(Colors.Black); first.Text = "起点"; _eLayer.AddChild(first, firstPoint); _points.Add(firstPoint); _distances.Add(0); _isInited = true; }
private Point MapToScreen(Point2D pt) { return CoordinateTransformationHelper.MapToScreen(pt, new Point2D(OriginX, OriginY), this.Resolution); }
private async Task<Point2D> LocationOffer(Point2D location) { string url = string.Format(CultureInfo.InvariantCulture,"http://42.120.50.220:7080/MapFactoryServices/GPSService?x={0}&y={1}", location.X.ToString(), location.Y.ToString()); HttpWebRequest request = HttpWebRequest.CreateHttp(url); TaskFactory factory = new TaskFactory(); try { HttpWebResponse response = (HttpWebResponse)await factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null); StreamReader reader = new StreamReader(response.GetResponseStream()); string result = await reader.ReadToEndAsync(); reader.Dispose(); response.Dispose(); response.Close(); request.Abort(); if (!string.IsNullOrEmpty(result)) { string[] array = result.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2) { double x = 0; double y = 0; if (double.TryParse(array[0], out x) && double.TryParse(array[1], out y)) { return new Point2D(x, y); } } } } catch { } return Point2D.Empty; }
private static bool IsWithin(Point2D p, Rectangle2D e) { return ((((p.X >= e.Left) && (p.Y >= e.Bottom)) && (p.X <= e.Right)) && (p.Y <= e.Top)); }
/// <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) { startPt = Map.ScreenToMap(e.GetPosition(Map)); if (!isActivated) { Activate(); } e.Handled = true; base.OnMouseLeftButtonDown(e); }
protected override Size ArrangeOverride(Size finalSize) { double resolution = this.Resolution; Point2D origin = new Point2D(this.OriginX, this.OriginY); Rectangle2D clipBox = new Rectangle2D( origin.X - (resolution * 4191.0), origin.Y - (resolution * 4191.0), origin.X + (resolution * 4191.0), origin.Y + (resolution * 4191.0)); if (this.Layer is ElementsLayer) (Layer as ElementsLayer).BoundsCollection.Clear(); if (this.Layer is ElementsLayer) orignalBounds.Clear(); bool istrue = this.Layer is ElementsLayer ? (this.Layer as ElementsLayer).IsAutoAvoidance : false; if (istrue) { foreach (UIElement element in base.Children) { Rectangle2D b = GetBounds(element); double referenceLength = (Layer as ElementsLayer).GetReferenceLength(element) * resolution; if (b.BottomLeft == b.TopRight) { b = new Rectangle2D(b.Left - (referenceLength) / 2, b.Bottom - (element.DesiredSize.Height * resolution) / 2, b.Left + (referenceLength) / 2, b.Bottom + (element.DesiredSize.Height * resolution) / 2); } orignalBounds.Add(b); } } foreach (UIElement element in base.Children) { if (element.Visibility != Visibility.Visible) { continue; } if (element is FeatureElement) { this.ArrangeFeature(element as FeatureElement, clipBox); continue; } if (element is ShapeElement) { this.ArrangeShapeBase(element as ShapeElement, clipBox); continue; } Rectangle2D b = GetBounds(element); if (istrue) { if (b.BottomLeft == b.TopRight) { b = new Rectangle2D(b.Left - (element.DesiredSize.Width * resolution) / 2, b.Bottom - (element.DesiredSize.Height * resolution) / 2, b.Left + (element.DesiredSize.Width * resolution) / 2, b.Bottom + (element.DesiredSize.Height * resolution) / 2); } bool isIntersect; bool isGetNewBounds; double referenceLength = (Layer as ElementsLayer).GetReferenceLength(element) * resolution; Size referenceSize = (Layer as ElementsLayer).GetReferenceSize(element); b = isBoundsChange(b, referenceLength, referenceSize, out isIntersect, out isGetNewBounds); if (isIntersect) { if (isGetNewBounds) { (element as UIElement).Opacity = 1; } else { (element as UIElement).Opacity = 0; } } else { (element as UIElement).Opacity = 1; } (Layer as ElementsLayer).BoundsCollection.Add(element, b); } if (!Rectangle2D.IsNullOrEmpty(b)) { double pixelX = (b.Left - origin.X) / resolution; double pixelY = (origin.Y - b.Top) / resolution; double pixelWidth = b.Width / resolution; double pixelHeight = b.Height / resolution; //&& if (this.Layer is TiledLayer) { pixelWidth++; pixelHeight++; element.UseLayoutRounding = false; } if (((!double.IsInfinity(pixelWidth) && !double.IsInfinity(pixelHeight)) && (!double.IsInfinity(pixelX) && !double.IsInfinity(pixelY))) && ((!double.IsNaN(pixelWidth) && !double.IsNaN(pixelHeight)) && (!double.IsNaN(pixelX) && !double.IsNaN(pixelY)))) { double width; double height; if (((element is FrameworkElement) && (pixelWidth != 0.0)) && (pixelHeight != 0.0)) { (element as FrameworkElement).Width = pixelWidth; (element as FrameworkElement).Height = pixelHeight; } if ((pixelWidth != 0.0) || (pixelHeight != 0.0)) { element.Arrange(new Rect(pixelX, pixelY, pixelWidth, pixelHeight)); continue; } //相当于左上,右下,中心等位置的设定。 //设在某个点,bbox的宽和高都是0,比如pushpin\textbox等 switch (((HorizontalAlignment)element.GetValue(FrameworkElement.HorizontalAlignmentProperty))) { case HorizontalAlignment.Left: width = element.DesiredSize.Width; break; case HorizontalAlignment.Right: width = 0.0; break; default: width = element.DesiredSize.Width * 0.5; break; } switch (((VerticalAlignment)element.GetValue(FrameworkElement.VerticalAlignmentProperty))) { case VerticalAlignment.Top: height = element.DesiredSize.Height; break; case VerticalAlignment.Bottom: height = 0.0; break; default: height = element.DesiredSize.Height * 0.5; break; } element.Arrange(new Rect(new Point(pixelX - width, pixelY - height), element.DesiredSize)); } } } return base.ArrangeOverride(finalSize); }
private void EndDistance(Point2D endPoint) { if (_isInited && _points.Count > 0) { TextBlock text = new TextBlock(); _distanceList.Add(text); text.FontWeight = FontWeights.ExtraBlack; text.Foreground = new SolidColorBrush(Colors.Orange); _eLayer.AddChild(text, endPoint); Point2D lastPoint = _points[_points.Count - 1]; double nowDistance = Math.Sqrt((endPoint.X - lastPoint.X) * (endPoint.X - lastPoint.X) + (endPoint.Y - lastPoint.Y) * (endPoint.Y - lastPoint.Y)); double lastDistance = 0; double.TryParse(_distanceList[_distanceList.Count - 1].Text, out lastDistance); double distance = nowDistance + lastDistance; text.Text = string.Format("总长度:{0}公里", distance.ToString("0.0")); _points.Add(endPoint); _isInited = false; } }
/// <summary>${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_D}</summary> /// <param name="element">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_pararm_element}</param> /// <param name="location">${WP_mapping_ArbitraryLayer_method_addChild_UIElement_Point2D_param_location}</param> public void AddChild(UIElement element, Point2D location) { AddChild(element, new Rectangle2D(location, location)); }