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; }
private static Point2DCollection ClipRing(Point2DCollection ring, Edge edge) { if ((ring == null) || (ring.Count < 2)) { return null; } Point2DCollection points = new Point2DCollection(); Point2D lastPoint = ring[ring.Count - 1]; for (int i = 0; i < ring.Count; i++) { Point2D point = ring[i]; if (Inside(point, edge)) { if (Inside(lastPoint, edge)) { points.Add(point); } else { Point2D item = EdgeIntersection(lastPoint, point, edge); points.Add(item); points.Add(point); } } else if (Inside(lastPoint, edge)) { Point2D item = EdgeIntersection(lastPoint, point, edge); points.Add(item); } lastPoint = point; } return points; }
/// <summary> /// Divide a polygon by a path.(point2DCollection) /// </summary> /// <param name="path">the path.</param> /// <param name="polygon">the polygon to divide.</param> public void DividedBy(Point2DCollection path, Polygon2D polygon) { int a = polygon.HasVertex(path.FirstPoint); int b = polygon.HasVertex(path.LastPoint); if (a == Polygon2D.NoSuchPoint || b == Polygon2D.NoSuchPoint) { throw (new ArgumentException()); } if (a > b) { int tmp = a; a = b; b = tmp; } Point2DCollection p2 = new Point2DCollection(); Point2DCollection p1 = new Point2DCollection(); for (int i = 0; i < polygon.VertexCount; i++) { if (i <= a || i >= b) { p1.Add(polygon.GetPoint(i)); } if (i >= a && i <= b) { p2.Add(polygon.GetPoint(i)); } } for (int i = 1; i < path.Count - 1; i++) { p1.Add(path[i], a + i); p2.Add(path[i], 0); Parent.AddInner(path[i]); } if (p1.Count > p2.Count) { SubDivision.Add(new Polygon2D(p1)); SubDivision.Add(new Polygon2D(p2)); } else { SubDivision.Add(new Polygon2D(p2)); SubDivision.Add(new Polygon2D(p1)); } }
private void CreateRectangle(Point2D p1, Point2D p2) { double xmin = Math.Min(p1.X, p2.X); double xmax = Math.Max(p1.X, p2.X); double ymin = Math.Min(p1.Y, p2.Y); double ymax = Math.Max(p1.Y, p2.Y); Point2DCollection ps = new Point2DCollection(); ps.Add(new Point2D(xmin, ymin)); ps.Add(new Point2D(xmin, ymax)); ps.Add(new Point2D(xmax, ymax)); ps.Add(new Point2D(xmax, ymin)); ps.Add(new Point2D(xmin, ymin)); this.Parts.Add(ps); }
/// <summary>${core_Point2DCollectionConverter_method_ConvertFrom_D}</summary> /// <param name="value">${core_Point2DCollectionConverter_method_ConvertFrom_param_value}</param> /// <param name="context">${core_Point2DCollectionConverter_method_ConvertFrom_param_context}</param> /// <param name="culture">${core_Point2DCollectionConverter_method_ConvertFrom_param_culture}</param> /// <returns>${core_Point2DCollectionConverter_method_ConvertFrom_return}</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string str = value as string; if (str == null) { throw new NotSupportedException(); } Point2DCollection points = new Point2DCollection(); Point2DConverter converter = new Point2DConverter(); int num = -1; for (int i = 0; i < (str.Length + 1); i++) { if ((i >= str.Length) || char.IsWhiteSpace(str[i])) { int startIndex = num + 1; int length = i - startIndex; if (length >= 1) { string str2 = str.Substring(startIndex, length); points.Add((Point2D)converter.ConvertFrom(str2)); } num = i; } } return points; }
/// <summary>${core_GeoRegion_method_clone_D}</summary> public override Geometry Clone() { GeoRegion region = new GeoRegion(); if (this.Parts != null) { foreach (Point2DCollection points in this.Parts) { if (points != null) { Point2DCollection item = new Point2DCollection(); foreach (Point2D point in points) { if (point != null) { item.Add(point.Clone()); } } region.Parts.Add(item); continue; } region.Parts.Add(null); } } return region; }
internal GeoRegion ToGeoRegion() { if (this.Parts != null) { List<Point2DCollection> pss = new List<Point2DCollection>(); Point2DCollection copy = new Point2DCollection(); foreach (Point2D item in this.Points) { copy.Add(item); } for (int i = 0; i < this.Parts.Count; i++) { Point2DCollection temp = new Point2DCollection(); for (int j = 0; j < this.Parts[i]; j++) { temp.Add(copy[j]); } pss.Add(temp); copy.RemoveRange(0, this.Parts[i]); } GeoRegion region = new GeoRegion(); foreach (Point2DCollection item in pss) { region.Parts.Add(item); } return region; } return null; }
private void CreateRing() { this.Parts.Clear(); if (!double.IsNaN(Radius) && Radius > 0 && Center != null && PointCount > 2) { Point2DCollection pnts = new Point2DCollection(); for (int i = 0; i < PointCount; i++) { double rad = 2 * Math.PI / PointCount * i; double x = Math.Cos(rad) * radius + Center.X; double y = Math.Sin(rad) * radius + Center.Y; pnts.Add(new Point2D(x, y)); } double x0 = radius + Center.X; double y0 = Center.Y; pnts.Add(new Point2D(x0, y0)); this.Parts.Add(pnts); } }
private Polygon2D FlipArea(GhostTriangle2D a, GhostTriangle2D b, Polygon2D poly) { if (!isNeighbor(a, b)) { throw (new ArgumentException()); } Map(a, b); Point2DCollection points = new Point2DCollection(4); points.Add(poly.GetPoint(a.C)); points.Add(poly.GetPoint(a.A)); points.Add(poly.GetPoint(b.C)); points.Add(poly.GetPoint(b.B)); Polygon2D polygon = new Polygon2D(points); return(polygon); }
public Point2DCollection ReadPoint2DCollection() { Point2DCollection points = new Point2DCollection(); int count = ReadInt(); for (int i = 0; i < count; i++) { points.Add(ReadPoint2D()); } return(points); }
/// <summary> /// Convert this line segment to a path. Instert some new points. /// </summary> /// <param name="ExtraPoints">the number of extra points to insert.</param> /// <returns>the path.</returns> public Point2DCollection ToPath(int ExtraPoints) { if (ExtraPoints < 0) { throw (new ArgumentException()); } Point2DCollection points = new Point2DCollection(); points.Add(this.FirstPoint); for (int i = 1; i <= ExtraPoints; i++) { double d = (double)i / (double)(ExtraPoints + 1); points.Add(this.GetPoint(d)); } points.Add(this.LastPoint); return(points); }
public override bool Split(float[] @params, out Curve[] subCurves) { @params = ValidateParams(@params); if (!Closed) { if (@params.Length == 0) { subCurves = new Curve[0]; return(false); } subCurves = new Curve[@params.Length + 1]; for (int i = 0; i < @params.Length + 1; i++) { float ps = (i == 0 ? StartParam : @params[i - 1]); float pe = (i == @params.Length ? EndParam : @params[i]); Point2DCollection newPoints = new Point2DCollection(); foreach (float p in ParamIterator(ps, pe)) { newPoints.Add(GetPointAtParam(p)); } subCurves[i] = new Polyline(newPoints); } return(true); } else { if (@params.Length < 2) { subCurves = new Curve[0]; return(false); } subCurves = new Curve[@params.Length]; for (int i = 0; i < @params.Length; i++) { float ps = @params[i]; float pe = (i == @params.Length - 1 ? @params[0] : @params[i + 1]); Point2DCollection newPoints = new Point2DCollection(); foreach (float p in ParamIterator(ps, pe)) { newPoints.Add(GetPointAtParam(p)); } subCurves[i] = new Polyline(newPoints); } return(true); } }
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; }
//计算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); }
internal Point2DCollection Clip(Point2DCollection line) { Point2DCollection newLine = new Point2DCollection(); IList<Point2DCollection> list = this.ClipPointCollection(line, this.boundary); if ((list != null) && (list.Count > 0)) { foreach (Point2DCollection points in list) { foreach (Point2D item in points) { newLine.Add(item); } } } return newLine; }
private void GeometryThiessenAnalyst_Click(object sender, RoutedEventArgs e) { Point2DCollection points = new Point2DCollection(); points.Add(new Point2D(5472.712382, -2189.15344)); points.Add(new Point2D(4707.299652, -1229.476725)); points.Add(new Point2D(5450.34263, -2070.794081)); points.Add(new Point2D(5447.671615, -2255.928819)); points.Add(new Point2D(5357.895026, -1965.022579)); points.Add(new Point2D(5317.70775, -2521.162355)); GeometryThiessenAnalystParameters thiessenParams = new GeometryThiessenAnalystParameters(); thiessenParams.Points = points; thiessenParams.CreateResultDataset = true; thiessenParams.ResultDatasetName = ""; thiessenParams.ResultDatasourceName = "Changchun"; thiessenParams.ReturnResultRegion = true; thiessenParams.ClipRegion = null; ThiessenAnalystService thiessenService = new ThiessenAnalystService(url2); thiessenService.ProcessAsync(thiessenParams); thiessenService.ProcessCompleted += new EventHandler<ThiessenAnalystEventArgs>(ThiessenAnalyst_ProcessCompleted); thiessenService.Failed += new EventHandler<ServiceFailedEventArgs>(ThiessenAnalyst_Failed); }
private Point2D CalcPolygonCenter() { Point2DCollection point2Ds = new Point2DCollection(); Rectangle2D bounds = this.Bounds; Point2D center = Point2D.Empty; if (this.Parts == null || this.Parts.Count == 0 || Rectangle2D.IsNullOrEmpty(bounds)) { return center; } int[] parts = new int[this.Parts.Count]; int point2DCount = 0; foreach (var item in this.Parts) { foreach (var item1 in item) { point2Ds.Add(item1); } parts[point2DCount] = item.Count; point2DCount++; } int i, crossNum, totalPoints; double x1, y1, x2, y2; double x3, y3, x4, y4; double dist, maxLength; int maxSegmentNo; double sign1 = 0, sign2 = 0; bool bAddRepPoint; int n = 0; int m = 0; int lPointCount = 0; double yMax; double yMin; int polyCountsMax = parts[0]; int flag = 0; for (n = 0; n < parts.Length; n++) { if (polyCountsMax <= parts[n]) { polyCountsMax = parts[n]; flag = n; } } for (n = 0; n < flag; n++) { lPointCount += parts[n]; } yMax = point2Ds[lPointCount].Y; yMin = point2Ds[lPointCount].Y; for (m = 0; m < parts[flag]; m++) { if (yMax <= point2Ds[lPointCount + m].Y) { yMax = point2Ds[lPointCount + m].Y; } if (yMin >= point2Ds[lPointCount + m].Y) { yMin = point2Ds[lPointCount + m].Y; } } y1 = (yMax + yMin) / 2; y2 = y1; x1 = bounds.BottomLeft.X - Math.Abs(bounds.TopRight.X - bounds.BottomLeft.X); x2 = bounds.TopRight.X + Math.Abs(bounds.TopRight.X - bounds.BottomLeft.X); Point2D pntResult; totalPoints = 0; crossNum = 0; double[] pSPointX = new double[1]; double y0 = 0; for (int n1 = 0; n1 < parts.Length; n1++) { int crossOfN = 0; for (int j1 = 1; j1 < parts[n1]; j1++) { x3 = point2Ds[totalPoints + j1 - 1].X; y3 = point2Ds[totalPoints + j1 - 1].Y; x4 = point2Ds[totalPoints + j1].X; y4 = point2Ds[totalPoints + j1].Y; if (((y4 - y3) > SMALL_VALUE) || ((y4 - y3) < -SMALL_VALUE)) { bAddRepPoint = true; if (((y3 - y1) > -SMALL_VALUE) && ((y3 - y1) < SMALL_VALUE)) { y1 = y3; y2 = y1; } else if (((y4 - y1) > -SMALL_VALUE) && ((y4 - y1) < SMALL_VALUE)) { y1 = y4; y2 = y1; } int nSpy = -1; if (j1 == 1) { sign1 = point2Ds[totalPoints + parts[n1] - 2].Y - point2Ds[totalPoints].Y; nSpy = parts[n1] - 2; } else { sign1 = (point2Ds[totalPoints + j1 - 2].Y - point2Ds[totalPoints + j1 - 1].Y); nSpy = j1 - 2; } sign2 = y4 - y3; if (((y3 - y1) > -SMALL_VALUE) && ((y3 - y1) < SMALL_VALUE)) { while ((sign1 > -SMALL_VALUE) && (sign1 < SMALL_VALUE)) { nSpy--; if (nSpy < 0) { nSpy = parts[n1] - 2; } sign1 = point2Ds[totalPoints + nSpy].Y - point2Ds[totalPoints + j1 - 1].Y; } bAddRepPoint = ((sign1 * sign2) > 0); } } else { bAddRepPoint = false; } if ((bAddRepPoint) && (this.IntersectLineSect(x1, y1, x2, y2, x3, y3, x4, y4, out pntResult))) { double[] tempPointX = new double[crossNum + 1]; int iLength = pSPointX.Length; Array.Copy(pSPointX, 0, tempPointX, 0, iLength); pSPointX = tempPointX; pSPointX[crossNum] = pntResult.X; crossOfN++; crossNum++; if (crossOfN > 1 && pSPointX[crossNum - 1] == pSPointX[crossNum - 2] && (y0 - y3) * (y4 - y3) < 0) { crossNum--; crossOfN--; } y0 = y3; } } if (crossNum - 1 >= 0 && crossNum - 1 < pSPointX.Length && pSPointX[crossNum - 1] == pSPointX[0]) { y0 = point2Ds[totalPoints + 1].Y; y3 = point2Ds[totalPoints].Y; y4 = point2Ds[totalPoints + parts[n1] - 1].Y; if ((y0 - y3) * (y4 - y3) < 0) { crossNum--; } } totalPoints = totalPoints + Math.Abs(parts[n1]); } if (((crossNum % 2) == 0) && (crossNum >= 2)) { this.QuickSort(pSPointX, 0, (crossNum - 1)); maxLength = -1.7E+308; maxSegmentNo = -1; for (i = 0; i <= (crossNum / 2 - 1); i++) { dist = pSPointX[2 * i + 1] - pSPointX[2 * i]; if (dist > maxLength) { maxLength = dist; maxSegmentNo = i; } } center.X = (pSPointX[2 * maxSegmentNo + 1] + pSPointX[2 * maxSegmentNo]) / 2; center.Y = y1; } return center; }
/// <summary> /// Divide a sub polygon by a line segment. /// </summary> /// <param name="lineSegment">the line segment.</param> /// <param name="poly">the polygon to divide.</param> /// <returns>one of the sub polygon divided from the polygon.</returns> internal Polygon2D DividedBy(LineSegment2D lineSegment, Polygon2D poly) { if (poly.isDiagonal(lineSegment)) { int a = poly.HasVertex(lineSegment.FirstPoint); int b = poly.HasVertex(lineSegment.LastPoint); if (a > b) { int tmp = a; a = b; b = tmp; } Point2DCollection p2 = new Point2DCollection(b - a + 1); Point2DCollection p1 = new Point2DCollection(poly.VertexCount - p2.Size + 2); for (int i = 0; i < poly.VertexCount; i++) { if (i <= a || i >= b) { p1.Add(poly.GetPoint(i)); } if (i >= a && i <= b) { p2.Add(poly.GetPoint(i)); } } if (p1.Count > p2.Count) { SubDivision.Add(new Polygon2D(p1)); return(new Polygon2D(p2)); } else { SubDivision.Add(new Polygon2D(p2)); return(new Polygon2D(p1)); } } else if (lineSegment.Intersects(poly)) { Point2DCollection Points = new Point2DCollection(2); for (int i = 0; i < poly.VertexCount; i++) { LineSegment2D border = poly.GetEdge(i); Point2D p = lineSegment.GetIntersectPoint(border); if (p.isRegular) { Points.DistinctAdd(p); } } Debug.Assert(Points.Count == 2); if (poly.HasVertex(Points[0]) == Polygon2D.NoSuchPoint) { poly.Add(Points[0], poly.OnEdge(Points[0])); Parent.AddInner(Points[0]); this.InnerPoints.DistinctAdd(Points[0]); } if (poly.HasVertex(Points[1]) == Polygon2D.NoSuchPoint) { poly.Add(Points[1], poly.OnEdge(Points[1])); Parent.AddInner(Points[1]); this.InnerPoints.DistinctAdd(Points[1]); } LineSegment2D line = new LineSegment2D(Points[0], Points[1]); return(DividedBy(line, poly)); } else { return(poly); } }
//将地物添加到图层中 private void polygon_DrawCompleted(object sender, DrawEventArgs e) { //将绘制的地物显示在FeaturesLayer中 GeoRegion region = e.Geometry as GeoRegion; Feature f = new Feature(); f.Geometry = region; f.Style = new PredefinedFillStyle() { Fill = new SolidColorBrush(Colors.Green) }; drawLayer.Features.Add(f); //记录所绘制地物的点坐标 Point2DCollection ps = new Point2DCollection(); for (int i = 0; i < region.Parts.Count; i++) { for (int j = 0; j < region.Parts[i].Count; j++) { ps.Add(new Point2D(region.Parts[i][j].X, region.Parts[i][j].Y)); } } //将客户端地物转换成服务端几何类型 ServerGeometry Addshape = new ServerGeometry { Feature = ServerFeatureType.Polygon, Point2Ds = ps }; Entity entity = new Entity { Shape = Addshape }; AddEntityParameters parameters = new AddEntityParameters { MapName = "Changchun", LayerName = "Vegetable@Changchun", Entity = entity }; //与服务器交互 AddEntityService editService = new AddEntityService("http://localhost:7080/demo"); editService.ProcessAsync(parameters); editService.Failed += new EventHandler<ServiceFailedEventArgs>(Service_Failed); editService.ProcessCompleted += new EventHandler<EditEventArgs>(Service_ProcessCompleted); }
public override async Task Apply(CADDocument doc, params string[] args) { Editor ed = doc.Editor; ed.PickedSelection.Clear(); var p1 = await ed.GetPoint("First point: "); if (p1.Result != ResultMode.OK) { return; } Point2D pt = p1.Value; Polyline consPoly = new Polyline(new Point2D[] { pt, pt }); consPoly.Closed = true; doc.Jigged.Add(consPoly); Point2DCollection points = new Point2DCollection(); points.Add(pt); bool done = false; while (!done) { PointOptions options = new PointOptions("Next point: ", pt, (p) => consPoly.Points[consPoly.Points.Count - 1] = p); options.AddKeyword("End", true); var pNext = await ed.GetPoint(options); if (pNext.Result == ResultMode.OK) { pt = pNext.Value; consPoly.Points.Add(pt); points.Add(pt); } else if (pNext.Result == ResultMode.Cancel) { doc.Jigged.Remove(consPoly); return; } else if (pNext.Result == ResultMode.Keyword) { if (points.Count < 2) { doc.Jigged.Remove(consPoly); return; } if (pNext.Keyword == "End") { done = true; } } } doc.Jigged.Remove(consPoly); Hatch newItem = new Hatch(points); doc.Model.Add(newItem); }
internal GeoLine ToGeoLine() { if (this.Parts != null) { List<Point2DCollection> pss = new List<Point2DCollection>(); Point2DCollection copy = new Point2DCollection(); foreach (Point2D item in this.Point2Ds) { copy.Add(item); } for (int i = 0; i < this.Parts.Count; i++) { Point2DCollection temp = new Point2DCollection(); for (int j = 0; j < this.Parts[i]; j++) { temp.Add(copy[j]); } pss.Add(temp); copy.RemoveRange(0, this.Parts[i]);//把前面的删除 } //把Point2Ds根据Parts分成一段一段的 GeoLine line = new GeoLine(); foreach (Point2DCollection item in pss) { line.Parts.Add(item); } return line; } return null; }
//编辑地物形状 private void editEntity_GeometryEdit(object sender, SuperMap.Web.Actions.Edit.GeometryEditEventArgs e) { if (e.Action == SuperMap.Web.Actions.Edit.GeometryEditAction.EditCompleted) { Point2DCollection ps = new Point2DCollection(); //记录编辑后的地物结点 GeoRegion region = e.Feature.Geometry as GeoRegion; for (int i = 0; i < region.Parts.Count; i++) { for (int j = 0; j < region.Parts[i].Count; j++) { ps.Add(new Point2D(region.Parts[i][j].X, region.Parts[i][j].Y)); } } shape = new ServerGeometry { Feature = ServerFeatureType.Polygon, Point2Ds = ps }; Entity entity = new Entity { Shape = shape, ID = entityID }; UpdateEntityParameters parameters = new UpdateEntityParameters { MapName = "Changchun", LayerName = "Vegetable@changchun", Entity = entity }; //与服务器交互更新地物形状 UpdateEntityService updateEntityService = new UpdateEntityService("http://localhost:7080/demo"); updateEntityService.ProcessAsync(parameters); updateEntityService.Failed += new EventHandler<ServiceFailedEventArgs>(Service_Failed); updateEntityService.ProcessCompleted += new EventHandler<EditEventArgs>(Service_ProcessCompleted); } }
private IList<Point2DCollection> ClipPointCollection(Point2DCollection points, Rectangle2D box) { List<Point2DCollection> list = new List<Point2DCollection>(); Rectangle2D rect = points.GetBounds(); if (((rect.Right < box.Left) || (rect.Top < box.Bottom)) || ((rect.Left > box.Right) || (rect.Bottom > box.Top))) { return null; }//全部在外 if (((rect.Left >= box.Left) && (rect.Bottom >= box.Bottom)) && ((rect.Right <= box.Right) && (rect.Top <= box.Top))) { list.Add(points); return list; }//全部在内 if (points.Count < 2) { return null; } Point2DCollection item = null; bool flag = IsWithin(points[0], box); if (flag) { item = new Point2DCollection(); list.Add(item); item.Add(points[0]); } for (int i = 0; i < (points.Count - 1); i++) { Point2D point = points[i]; Point2D p = points[i + 1]; bool flag2 = IsWithin(p, box); if (flag && flag2) { item.Add(p); } else { if (flag != flag2) { if (flag) { item.Add(this.ClipLineSegment(point, p, box)); } else { item = new Point2DCollection(); list.Add(item); item.Add(this.ClipLineSegment(p, point, box)); item.Add(p); } } else { Rectangle2D box3 = new Rectangle2D(Math.Min(point.X, p.X), Math.Min(point.Y, p.Y), Math.Max(point.X, p.X), Math.Max(point.Y, p.Y)); if (box3.IntersectsWith(box)) { item = new Point2DCollection(); list.Add(item); Point2D point3 = EdgeIntersection(point, p, box.Left, false); Point2D point4 = EdgeIntersection(point, p, box.Right, false); Point2D point5 = EdgeIntersection(point, p, box.Bottom, true); Point2D point6 = EdgeIntersection(point, p, box.Top, true); if ((point6.X >= box.Left) && (point6.X <= box.Right)) { item.Add(point6); } if ((point5.X >= box.Left) && (point5.X <= box.Right)) { item.Add(point5); } if ((point4.Y >= box.Bottom) && (point4.Y <= box.Top)) { item.Add(point4); } if ((point3.Y >= box.Bottom) && (point3.Y <= box.Top)) { item.Add(point3); } if (item.Count < 2) { list.Remove(item); } } } flag = flag2; } } for (int j = list.Count - 1; j >= 0; j--) { Point2DCollection points3 = list[j]; if (points3.Count < 2) { list.RemoveAt(j); } } if (list.Count == 0) { return null; } return list; }
internal Route ToRoute() { if (this.Parts != null) { Route route = new Route(); route.Parts = new ObservableCollection<Point2DCollection>(); int index = 0; foreach (var part in this.Parts) { Point2DCollection collection = new Point2DCollection(); for (int i = index; i < index + part; i++) { collection.Add(this.Points[i]); } route.Parts.Add(collection); } route.MinM = ((ServerRoute)this).MinM; route.MaxM = ((ServerRoute)this).MaxM; route.Length = ((ServerRoute)this).Length; return route; } return null; }
private Dictionary<string, string> GetParameters(QueryByGeometryParameters parameters) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); Point2DCollection gps = new Point2DCollection(); if (parameters.Geometry is GeoLine) { string method = "QueryByLine"; dictionary.Add("map", parameters.MapName); dictionary.Add("method", method); foreach (Point2DCollection g in (parameters.Geometry as GeoLine).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } } else if (parameters.Geometry is GeoRegion) { string method = "QueryByPolygen"; dictionary.Add("map", parameters.MapName); dictionary.Add("method", method); foreach (Point2DCollection g in (parameters.Geometry as GeoRegion).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } } else if (parameters.Geometry is GeoCircle) { string method = "QueryByPolygen"; dictionary.Add("map", parameters.MapName); dictionary.Add("method", method); foreach (Point2DCollection g in (parameters.Geometry as GeoCircle).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } } else if (parameters.Geometry is GeoPoint) { string method = "QueryByPoint"; dictionary.Add("map", parameters.MapName); dictionary.Add("method", method); dictionary.Add("point", JsonHelper.FromPoint2D(((GeoPoint)parameters.Geometry).Bounds.Center)); dictionary.Add("tolerance", "0"); dictionary.Add("queryParam", QueryParam.ToJson(parameters.QueryParam)); dictionary.Add("trackingLayerIndex", "-1"); dictionary.Add("userID", string.Format("\"{0}\"", Guid.NewGuid())); return dictionary; } dictionary.Add("points", JsonHelper.FromPoint2DCollection(gps)); dictionary.Add("queryParam", QueryParam.ToJson(parameters.QueryParam)); dictionary.Add("trackingLayerIndex", "-1"); dictionary.Add("userID", string.Format("\"{0}\"", Guid.NewGuid())); return dictionary; }
/// <summary>${core_GeoRegion_method_GetBounds_D}</summary> public Rectangle2D GetBounds() { Point2DCollection point2Ds = new Point2DCollection(); Rectangle2D bounds = this.Bounds; int[] parts = new int[this.Parts.Count]; int point2DCount = 0; foreach (var item in this.Parts) { foreach (var item1 in item) { point2Ds.Add(item1); } parts[point2DCount] = item.Count; point2DCount++; } if (point2Ds == null || point2Ds.Count == 0) { //throw new IllegalArgumentException(resource.getMessage("Geometry.getBounds.nopoints")); // % return Rectangle2D.Empty; } else { double left, bottom, right, top; left = point2Ds[0].X; bottom = point2Ds[0].Y; right = left; top = bottom; int iLength = point2Ds.Count; for (int i = 1; i < iLength; i++) { if (point2Ds[i].X < left) { left = point2Ds[i].X; } if (point2Ds[i].Y < bottom) { bottom = point2Ds[i].Y; } if (point2Ds[i].X > right) { right = point2Ds[i].X; } if (point2Ds[i].Y > top) { top = point2Ds[i].Y; } } return new Rectangle2D(left, bottom, right, top); } }
private Dictionary<string, string> GetParameters(MeasureParameters parameters) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); Point2DCollection gps = new Point2DCollection(); if (parameters.Geometry is GeoLine) { string method = "MeasureDistance"; dictionary.Add("method", method); dictionary.Add("mapName", parameters.MapName); Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("mapName", parameters.MapName); foreach (Point2DCollection g in (parameters.Geometry as GeoLine).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } dict.Add("points", JsonHelper.FromPoint2DCollection(gps)); dictionary.Add("params", Bridge.CreateParams(method, dict)); } else if (parameters.Geometry is GeoRegion) { string method = "MeasureArea"; dictionary.Add("method", method); dictionary.Add("mapName", parameters.MapName); Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("mapName", parameters.MapName); foreach (Point2DCollection g in (parameters.Geometry as GeoRegion).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } dict.Add("points", JsonHelper.FromPoint2DCollection(gps)); dictionary.Add("params", Bridge.CreateParams(method, dict)); } return dictionary; }
private void MyMap_ViewBoundsChanged(object sender, ViewBoundsEventArgs e) { #region Ellipse Ellipse myellipse = new Ellipse(); myellipse.Fill = new SolidColorBrush(Colors.Red); Rectangle2D ellbounds = new Rectangle2D(119.5, 21, 122.5, 26); this.arbitrarylayer.AddChild(myellipse, ellbounds); MyEllipseStory.Stop(); Storyboard.SetTarget(myDoubleAnimation, myellipse); MyEllipseStory.Begin(); #endregion #region Pushpin Pushpin beijing = new Pushpin(); beijing.Location = new Point2D(116.2, 39.6); this.arbitrarylayer.AddChild(beijing); Pushpin ulanBator = new Pushpin(); ulanBator.Location = new Point2D(106.5, 47.6); ulanBator.Background = new SolidColorBrush(Colors.Blue); this.arbitrarylayer.AddChild(ulanBator); Pushpin moscow = new Pushpin(); moscow.Location = new Point2D(37.4, 55.5); moscow.Background = new SolidColorBrush(Colors.Yellow); this.arbitrarylayer.AddChild(moscow); Pushpin prague = new Pushpin(); prague.Location = new Point2D(14.3, 50.1); prague.Background = new SolidColorBrush(Colors.Orange); this.arbitrarylayer.AddChild(prague); Pushpin berlin = new Pushpin(); berlin.Location = new Point2D(13.3, 52.3); berlin.Background = new SolidColorBrush(Colors.Purple); this.arbitrarylayer.AddChild(berlin); #endregion #region PolygonElement PolygonElement line = new PolygonElement(); line.Stroke = new SolidColorBrush(Colors.Yellow); line.StrokeThickness = 3; line.Opacity = 1; line.StrokeDashArray = new DoubleCollection { 3, 3 }; line.StrokeEndLineCap = PenLineCap.Triangle; Point2DCollection points = new Point2DCollection(); points.Add(new Point2D(121.3, 25)); points.Add(new Point2D(116.2, 39.6)); points.Add(new Point2D(106.5, 47.6)); points.Add(new Point2D(37.4, 55.5)); points.Add(new Point2D(14.3, 50.1)); points.Add(new Point2D(13.3, 52.3)); points.Add(new Point2D(0.1, 51.3)); line.Point2Ds = points; this.arbitrarylayer.AddChild(line); #endregion #region PolygonElement PolygonElement polygon = new PolygonElement(); polygon.Stroke = new SolidColorBrush(Colors.Purple); polygon.Opacity = 0.5; polygon.Fill = this.British; Point2DCollection gonpoints = new Point2DCollection(); gonpoints.Add(new Point2D(-8, 61)); gonpoints.Add(new Point2D(-6, 55)); gonpoints.Add(new Point2D(-8, 50)); gonpoints.Add(new Point2D(2, 50)); gonpoints.Add(new Point2D(1, 61)); polygon.Point2Ds = gonpoints; this.arbitrarylayer.AddChild(polygon); #endregion #region Button Button btn = new Button(); btn.Height = 32; btn.Width = 32; btn.Content = "点击"; btn.Click += new RoutedEventHandler(btn_Click); Rectangle2D btnbounds = new Rectangle2D(95, 29, 115, 38); btn.SetValue(ElementsLayer.BBoxProperty, btnbounds); this.arbitrarylayer.AddChild(btn); #endregion }
private void endDraw(bool isCancel = false) { Rectangle2D bounds = this.map.Bounds; if (bounds.IsEmpty || bounds.Width == 0.0 || bounds.Height == 0.0) { return; } GeoRegion geoRegion = new GeoRegion();//构造返回的Geometry Point2DCollection geoPoints = new Point2DCollection(); geoPoints.Add(bounds.BottomLeft); geoPoints.Add(new Point2D(bounds.Right, bounds.Bottom)); geoPoints.Add(bounds.TopRight); geoPoints.Add(new Point2D(bounds.Left, bounds.Top)); geoPoints.Add(bounds.BottomLeft);//需要添加起始点做为最后一个点 geoRegion.Parts.Add(geoPoints); DrawEventArgs args2 = new DrawEventArgs { Geometry = geoRegion }; Deactivate(); OnDrawCompleted(args2); }
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); polygon = new PolygonElement(); #region 所有风格的控制 polygon.Stroke = Stroke; polygon.StrokeThickness = StrokeThickness; polygon.StrokeMiterLimit = StrokeMiterLimit; polygon.StrokeDashOffset = StrokeDashOffset; polygon.StrokeDashArray = StrokeDashArray; polygon.StrokeDashCap = StrokeDashCap; polygon.StrokeEndLineCap = StrokeEndLineCap; polygon.StrokeLineJoin = StrokeLineJoin; polygon.StrokeStartLineCap = StrokeStartLineCap; polygon.Opacity = Opacity; polygon.Fill = Fill; polygon.FillRule = FillRule; #endregion points = new Point2DCollection(); polygon.Point2Ds = points; points.Add(firstPoint); points.Add(firstPoint); DrawLayer.Children.Add(polygon); isDrawing = true; isActivated = true; }
private Point2DCollection GetPoint2Ds(string[] val) { Point2DCollection col = new Point2DCollection(); if (val != null) { for (int i = 0; i < val.Length; i += 2) { col.Add(new Point2D(double.Parse(val[i], CultureInfo.InvariantCulture), double.Parse(val[i + 1], CultureInfo.InvariantCulture))); } } return col; }
private void Activate(Point2D firstPoint) { _polygon = new PolygonElement(); _textBlockContainer = new List<TextBlock>(); #region 所有风格的控制 _polygon.Stroke = Stroke; _polygon.StrokeThickness = StrokeThickness; _polygon.StrokeMiterLimit = StrokeMiterLimit; _polygon.StrokeDashOffset = StrokeDashOffset; _polygon.StrokeDashArray = StrokeDashArray; _polygon.StrokeDashCap = StrokeDashCap; _polygon.StrokeEndLineCap = StrokeEndLineCap; _polygon.StrokeLineJoin = StrokeLineJoin; _polygon.StrokeStartLineCap = StrokeStartLineCap; _polygon.Opacity = Opacity; _polygon.Fill = Fill; _polygon.FillRule = FillRule; #endregion _points = new Point2DCollection(); _polygon.Point2Ds = _points; _points.Add(firstPoint); _pointsCount++; _points.Add(firstPoint.Clone()); _pointsCount++; DrawLayer.Children.Add(_polygon); TextBlock textBlock = new TextBlock(); textBlock.FontWeight = FontWeights.ExtraBlack; textBlock.Foreground = new SolidColorBrush(Colors.White); textBlock.Text = "起点"; _textBlockContainer.Add(textBlock); DrawLayer.AddChild(textBlock, firstPoint); _isActivated = true; }
private IList<Point2DCollection> ClipPointCollection(Point2DCollection points, Rectangle2D box) { List<Point2DCollection> list = new List<Point2DCollection>(); Rectangle2D rect = points.GetBounds(); if (((rect.Right < box.Left) || (rect.Top < box.Bottom)) || ((rect.Left > box.Right) || (rect.Bottom > box.Top))) { return null; }//全部在外,不相交 if (box.Contains(rect)) { list.Add(points); return list; }//全部在内 if (points.Count < 2) { return null; } Point2DCollection item = null; bool flag = box.Contains(points[0]); if (flag) { item = new Point2DCollection(); list.Add(item); item.Add(points[0]); }//第一个点在内 for (int i = 0; i < (points.Count - 1); i++) { Point2D head = points[i]; Point2D end = points[i + 1]; bool flag2 = box.Contains(end); if (flag && flag2) { item.Add(end); }//同时在内。那么else则有三种情况,head内end外,head外edn内,hean外end外 else { if (flag != flag2) { if (flag) { item.Add(this.ClipLineSegment(head, end, box)); }//head内end外,添加交点 else { item = new Point2DCollection(); list.Add(item); item.Add(this.ClipLineSegment(head, end, box)); item.Add(end); }//head外edn内,添加交点和end点 } else { Rectangle2D segmentBox = new Rectangle2D(Math.Min(head.X, end.X), Math.Min(head.Y, end.Y), Math.Max(head.X, end.X), Math.Max(head.Y, end.Y)); if (segmentBox.IntersectsWith(box)) { item = new Point2DCollection(); list.Add(item); //与四条边框求交点,在中间就添加上去 Point2D point3 = EdgeIntersection(head, end, box.Left, false); Point2D point4 = EdgeIntersection(head, end, box.Right, false); Point2D point5 = EdgeIntersection(head, end, box.Bottom, true); Point2D point6 = EdgeIntersection(head, end, box.Top, true); if ((point6.X >= box.Left) && (point6.X <= box.Right)) { item.Add(point6); } if ((point5.X >= box.Left) && (point5.X <= box.Right)) { item.Add(point5); } if ((point4.Y >= box.Bottom) && (point4.Y <= box.Top)) { item.Add(point4); } if ((point3.Y >= box.Bottom) && (point3.Y <= box.Top)) { item.Add(point3); } if (item.Count < 2) { list.Remove(item); } }//hean外end外,添加两个交点 } flag = flag2; } } for (int j = list.Count - 1; j >= 0; j--) { Point2DCollection pts = list[j]; if (pts.Count < 2) { list.RemoveAt(j); } } if (list.Count == 0) { return null; } return list; }
private void MyMap_Loaded(object sender, RoutedEventArgs e) { #region 使用预定义点符号 Feature featurePoint = new Feature(); GeoPoint point = new GeoPoint(); point.X = 116.2; point.Y = 39.6; PredefinedMarkerStyle simpleMarkerStyle = new PredefinedMarkerStyle(); simpleMarkerStyle.Color = new SolidColorBrush(Colors.Red); simpleMarkerStyle.Size = 20; simpleMarkerStyle.Symbol = SuperMap.Web.Core.PredefinedMarkerStyle.MarkerSymbol.Star; featurePoint.Style = simpleMarkerStyle; featurePoint.Geometry = point; featuresLayer.Features.Add(featurePoint); #endregion #region 使用预定义线符号 Feature featureLine = new Feature(); Point2DCollection points = new Point2DCollection(); points.Add(new Point2D(116.2, 39.6)); points.Add(new Point2D(90, 50)); points.Add(new Point2D(50, 25)); points.Add(new Point2D(-80, 45)); points.Add(new Point2D(-100, 38)); ObservableCollection<Point2DCollection> path = new ObservableCollection<Point2DCollection>(); path.Add(points); GeoLine geoLine = new GeoLine(); geoLine.Parts = path; PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle(); simpleLineStyle.Stroke = new SolidColorBrush(Colors.Black); simpleLineStyle.StrokeThickness = 1; simpleLineStyle.StrokeDashArray = new DoubleCollection { 3, 1 }; featureLine.Geometry = geoLine; featureLine.Style = simpleLineStyle; featuresLayer.Features.Add(featureLine); #endregion #region 使用预定义面符号 Feature featureRegion = new Feature(); Point2DCollection pointsRegion = new Point2DCollection(); pointsRegion.Add(new Point2D(-8, 61)); pointsRegion.Add(new Point2D(-6, 55)); pointsRegion.Add(new Point2D(-8, 50)); pointsRegion.Add(new Point2D(2, 50)); pointsRegion.Add(new Point2D(1, 61)); pointsRegion.Add(new Point2D(-8, 61)); ObservableCollection<Point2DCollection> pRegion = new ObservableCollection<Point2DCollection>(); pRegion.Add(pointsRegion); GeoRegion geoRegion = new GeoRegion(); geoRegion.Parts = pRegion; PredefinedFillStyle simpleFillStyle = new PredefinedFillStyle(); simpleFillStyle.StrokeThickness = 1; simpleFillStyle.Stroke = new SolidColorBrush(Colors.Black); simpleFillStyle.Fill = new SolidColorBrush(Colors.Yellow); featureRegion.Geometry = geoRegion; featureRegion.Style = simpleFillStyle; featuresLayer.Features.Add(featureRegion); #endregion #region 添加文本 Feature featureText = new Feature(); GeoPoint text = new GeoPoint(); text.X = 5; text.Y = 10; TextStyle textStyle = new TextStyle(); textStyle.Text = "Africa"; textStyle.FontSize = 40; textStyle.Foreground = new SolidColorBrush(Colors.Blue); featureText.Geometry = text; featureText.Style = textStyle; featuresLayer.Features.Add(featureText); #endregion }
private Dictionary<string, string> GetParameters(EntityBufferQueryParameters parameters) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); Point2DCollection gps = new Point2DCollection(); if (parameters.Geometry is GeoPoint) { string method = "PointEntityBufferQuery"; dictionary.Add("method", method); dictionary.Add("mapName", parameters.MapName); Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("mapName", parameters.MapName); dict.Add("point", JsonHelper.FromGeoPoint(parameters.Geometry as GeoPoint)); dict.Add("fromLayer", parameters.FromLayer); dict.Add("bufferParam", BufferAnalystParam.ToJson(parameters.BufferParam)); dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam)); dict.Add("queryMode", ((int)parameters.QueryMode).ToString()); dictionary.Add("params", Bridge.CreateParams(method, dict)); } else if (parameters.Geometry is GeoLine) { string method = "LineEntityBufferQuery"; dictionary.Add("method", method); dictionary.Add("mapName", parameters.MapName); Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("mapName", parameters.MapName); foreach (Point2DCollection g in (parameters.Geometry as GeoLine).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } dict.Add("points", JsonHelper.FromPoint2DCollection(gps)); dict.Add("fromLayer", parameters.FromLayer); dict.Add("bufferParam", BufferAnalystParam.ToJson(parameters.BufferParam)); dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam)); dict.Add("queryMode", ((int)parameters.QueryMode).ToString()); dictionary.Add("params", Bridge.CreateParams(method, dict)); } else if (parameters.Geometry is GeoRegion) { string method = "PolygonEntityBufferQuery"; dictionary.Add("method", method); dictionary.Add("mapName", parameters.MapName); Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("mapName", parameters.MapName); foreach (Point2DCollection g in (parameters.Geometry as GeoRegion).Parts) { for (int i = 0; i < g.Count; i++) { gps.Add(g[i]); } } dict.Add("points", JsonHelper.FromPoint2DCollection(gps)); dict.Add("fromLayer", parameters.FromLayer); dict.Add("bufferParam", BufferAnalystParam.ToJson(parameters.BufferParam)); dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam)); dict.Add("queryMode", ((int)parameters.QueryMode).ToString()); dictionary.Add("params", Bridge.CreateParams(method, dict)); } return dictionary; }
/// <summary>${iServer2_Utility_method_GeometryToServerGeometry_D}</summary> /// <param name="geo">${iServer2_Utility_method_GeometryToServerGeometry_param_geo}</param> /// <returns>${iServer2_Utility_method_GeometryToServerGeometry_return}</returns> public static ServerGeometry ToServerGeometry(this Geometry geo) { if (geo == null) { return null; } ServerGeometry sg = new ServerGeometry(); Point2DCollection list = new Point2DCollection(); List<int> parts = new List<int>(); if (geo is GeoRegion) { for (int i = 0; i < ((GeoRegion)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoRegion)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoRegion)geo).Parts[i][j].X, ((GeoRegion)geo).Parts[i][j].Y)); } parts.Add(((GeoRegion)geo).Parts[i].Count); } sg.Feature = ServerFeatureType.Polygon; } if (geo is GeoCircle) { for (int i = 0; i < ((GeoCircle)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoCircle)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoCircle)geo).Parts[i][j].X, ((GeoCircle)geo).Parts[i][j].Y)); } parts.Add(((GeoCircle)geo).Parts[i].Count); } sg.Feature = ServerFeatureType.Polygon; } if (geo is GeoLine) { for (int i = 0; i < ((GeoLine)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoLine)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoLine)geo).Parts[i][j].X, ((GeoLine)geo).Parts[i][j].Y)); } parts.Add(((GeoLine)geo).Parts[i].Count); } sg.Feature = ServerFeatureType.Line; } if (geo is GeoPoint) { list.Add(new Point2D(((GeoPoint)geo).X, ((GeoPoint)geo).Y)); parts.Add(list.Count); sg.Feature = ServerFeatureType.Point; } sg.Point2Ds = list; sg.Parts = parts; sg.Id = -1; return sg; }
/// <summary>${REST_Bridge_method_GeometryToServerGeometry_D}</summary> /// <returns>${REST_Bridge_method_GeometryToServerGeometry_return}</returns> /// <param name="geo">${REST_Bridge_method_GeometryToServerGeometry_param_geo}</param> public static ServerGeometry ToServerGeometry(this SuperMap.WinRT.Core.Geometry geo) { if (geo == null) { return null; } ServerGeometry sg = new ServerGeometry(); Point2DCollection list = new Point2DCollection(); List<int> parts = new List<int>(); if (geo is GeoRegion) { for (int i = 0; i < ((GeoRegion)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoRegion)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoRegion)geo).Parts[i][j].X, ((GeoRegion)geo).Parts[i][j].Y)); } parts.Add(((GeoRegion)geo).Parts[i].Count); } sg.Type = ServerGeometryType.REGION; } if (geo is GeoCircle) { for (int i = 0; i < ((GeoCircle)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoCircle)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoCircle)geo).Parts[i][j].X, ((GeoCircle)geo).Parts[i][j].Y)); } parts.Add(((GeoCircle)geo).Parts[i].Count); } sg.Type = ServerGeometryType.REGION; } if (geo is GeoLine) { for (int i = 0; i < ((GeoLine)geo).Parts.Count; i++) { for (int j = 0; j < ((GeoLine)geo).Parts[i].Count; j++) { list.Add(new Point2D(((GeoLine)geo).Parts[i][j].X, ((GeoLine)geo).Parts[i][j].Y)); } parts.Add(((GeoLine)geo).Parts[i].Count); } sg.Type = ServerGeometryType.LINE; } if (geo is GeoPoint) { list.Add(new Point2D(((GeoPoint)geo).X, ((GeoPoint)geo).Y)); parts.Add(list.Count); sg.Type = ServerGeometryType.POINT; } sg.Points = list; sg.Parts = parts; sg.ID = -1; return sg; }