public void AddPoint(IPoint point) { if (point == null) { return; } if (_geometry is IPoint && _actPartNr == 0) { ((IPoint)_geometry).X = point.X; ((IPoint)_geometry).Y = point.Y; ((IPoint)_geometry).Z = point.Z; } else if (_geometry is IMultiPoint) { IMultiPoint mPoint = (IMultiPoint)_geometry; mPoint.AddPoint(point); } else if (_geometry is IPolyline) { IPolyline pLine = (IPolyline)_geometry; if (_actPartNr >= pLine.PathCount) { gView.Framework.Geometry.Path path = new gView.Framework.Geometry.Path(); path.AddPoint(point); pLine.AddPath(path); _actPartNr = pLine.PathCount - 1; } else { pLine[_actPartNr].AddPoint(point); } } else if (_geometry is IPolygon) { IPolygon poly = (IPolygon)_geometry; if (_actPartNr >= poly.RingCount) { Ring ring = new Ring(); ring.AddPoint(point); poly.AddRing(ring); _actPartNr = poly.RingCount - 1; } else { poly[_actPartNr].AddPoint(point); } } }
private void ReadMultiLine(BinaryReader br) { geometry = new Polyline(); for (int i = 0; i < parts; i++) { gView.Framework.Geometry.Path path = new gView.Framework.Geometry.Path(); int vertices = (int)CBF.SwapWord(br.ReadUInt32()); double x = 0.0, y = 0.0; for (int v = 0; v < vertices; v++) { x += (double)br.ReadDecimal(); y += (double)br.ReadDecimal(); path.AddPoint(new Point(x, y)); } ((Polyline)geometry).AddPath(path); } }
static public IGeometry AXL2Geometry(string axl, bool ignoreBuffer) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml("<g>" + axl + "</g>"); AggregateGeometry aGeom = new AggregateGeometry(); IPoint point; XmlNode bufferNode = null; foreach (XmlNode node in doc.ChildNodes[0].ChildNodes) { switch (node.Name) { case "BUFFER": if (!ignoreBuffer) { bufferNode = node; } break; case "POINT": point = PointFromAxl(node); AddSrs(node, point); aGeom.AddGeometry(point); break; case "MULTIPOINT": IMultiPoint mpoint = new MultiPoint(); AddSrs(node, mpoint); foreach (XmlNode pointnode in node.SelectNodes("POINT")) { point = PointFromAxl(pointnode); mpoint.AddPoint(point); } if (mpoint.PointCount == 0) { PointsFromCoords(mpoint, node.SelectSingleNode("COORDS")); } aGeom.AddGeometry(mpoint); break; case "ENVELOPE": IEnvelope envelope = new Envelope( Convert.ToDouble(node.Attributes["minx"].Value.Replace(".", ",")), Convert.ToDouble(node.Attributes["miny"].Value.Replace(".", ",")), Convert.ToDouble(node.Attributes["maxx"].Value.Replace(".", ",")), Convert.ToDouble(node.Attributes["maxy"].Value.Replace(".", ","))); AddSrs(node, envelope); aGeom.AddGeometry(envelope); break; case "POLYLINE": IPolyline pline = new Polyline(); AddSrs(node, pline); foreach (XmlNode pathnode in node.SelectNodes("PATH")) { IPath path = new gView.Framework.Geometry.Path(); foreach (XmlNode pointnode in pathnode.SelectNodes("POINT")) { point = PointFromAxl(pointnode); path.AddPoint(point); } foreach (XmlNode coordnode in pathnode.SelectNodes("COORDS")) { PointsFromCoords(path, coordnode); } pline.AddPath(path); } aGeom.AddGeometry(pline); break; case "POLYGON": IPolygon pgon = new Polygon(); AddSrs(node, pgon); foreach (XmlNode ringnode in node.SelectNodes("RING")) { IRing ring = new gView.Framework.Geometry.Ring(); foreach (XmlNode pointnode in ringnode.SelectNodes("POINT")) { point = PointFromAxl(pointnode); ring.AddPoint(point); } foreach (XmlNode coordnode in ringnode.SelectNodes("COORDS")) { PointsFromCoords(ring, coordnode); } pgon.AddRing(ring); foreach (XmlNode holenode in ringnode.SelectNodes("HOLE")) { IRing hole = new gView.Framework.Geometry.Ring(); foreach (XmlNode pointnode in holenode.SelectNodes("POINT")) { point = PointFromAxl(pointnode); hole.AddPoint(point); } foreach (XmlNode coordnode in holenode.SelectNodes("COORDS")) { PointsFromCoords(hole, coordnode); } pgon.AddRing(hole); } } foreach (XmlNode ringnode in node.SelectNodes("HOLE")) { IRing ring = new gView.Framework.Geometry.Ring(); foreach (XmlNode pointnode in ringnode.SelectNodes("POINT")) { point = PointFromAxl(pointnode); ring.AddPoint(point); } foreach (XmlNode coordnode in ringnode.SelectNodes("COORDS")) { PointsFromCoords(ring, coordnode); } pgon.AddRing(ring); } aGeom.AddGeometry(pgon); break; } } if (aGeom.GeometryCount == 0) { return(null); } if (!ignoreBuffer && bufferNode != null && bufferNode.Attributes["distance"] != null) { try { double dist = Convert.ToDouble(bufferNode.Attributes["distance"].Value); IPolygon polygon = aGeom.Buffer(dist); return(polygon); } catch { } } if (aGeom.GeometryCount == 1) { return(aGeom[0]); } return(aGeom); } catch { return(null); } }