Ejemplo n.º 1
0
        private void btnConstructPolyline_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();

            point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            polyline = gfactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;

            int length = 100;
            for (int i = 0; i < length; i++)
            {
                point.SetCoords(i, 2 * i, 0, 0, i + 1);
                polyline.AppendPoint(point);
            }
            if (polyline == null)
                return;

            CompoundLine geo = new CompoundLine();
            // Geometry属性
            geo.Dimension = polyline.Dimension;
            if (polyline.Envelope != null)
            {
                geo.MaxX = polyline.Envelope.MaxX;
                geo.MaxY = polyline.Envelope.MaxY;
                geo.MaxZ = polyline.Envelope.MaxZ;
                geo.MinX = polyline.Envelope.MinX;
                geo.MinY = polyline.Envelope.MinY;
                geo.MinZ = polyline.Envelope.MinZ;
            }
            geo.GeometryType = polyline.GeometryType;
            geo.IsEmpty = polyline.IsEmpty;
            geo.IsValid = polyline.IsValid;
            geo.VertexAttribute = polyline.VertexAttribute;
            geo.HasId = polyline.HasId();
            geo.HasM = polyline.HasM();
            geo.HasZ = polyline.HasZ();
            // Curve属性
            geo.IsClosed = polyline.IsClosed;
            geo.Length = polyline.Length;
            if (polyline.StartPoint != null)
            {
                geo.StartPointX = polyline.StartPoint.X;
                geo.StartPointY = polyline.StartPoint.Y;
                geo.StartPointZ = polyline.StartPoint.Z;
            }
            if (polyline.EndPoint != null)
            {
                geo.EndPointX = polyline.EndPoint.X;
                geo.EndPointY = polyline.EndPoint.Y;
                geo.EndPointZ = polyline.EndPoint.Z;
            }
            // CompoundLine属性
            geo.PointCount = polyline.PointCount;
            geo.SegmentCount = polyline.SegmentCount;

            this.propertyGrid1.SelectedObject = geo;
        }
Ejemplo n.º 2
0
        private void btnConstructCompoundLine_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();

            IPoint point1 = gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
            point1.SetCoords(3.56, 4, 5, 0, 1);
            IPoint point2 = gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
            point2.SetCoords(1, -1, 0, 0, 2);
            IPoint point3 = gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
            point3.SetCoords(2, 0, 0, 0, 3);

            circularArc = gfactory.CreateGeometry(gviGeometryType.gviGeometryCircularArc, gviVertexAttribute.gviVertexAttributeZ) as ICirculeArc;
            circularArc.ConstructThreePoints(point1, point2, point3);
            if (circularArc == null)
                return;

            compoundLine = gfactory.CreateGeometry(gviGeometryType.gviGeometryCompoundLine, gviVertexAttribute.gviVertexAttributeZ) as ICompoundLine;
            compoundLine.AppendSegment(circularArc);
            if (compoundLine == null)
                return;

            CompoundLine geo = new CompoundLine();
            // Geometry属性
            geo.Dimension = compoundLine.Dimension;
            if (compoundLine.Envelope != null)
            {
                geo.MaxX = compoundLine.Envelope.MaxX;
                geo.MaxY = compoundLine.Envelope.MaxY;
                geo.MaxZ = compoundLine.Envelope.MaxZ;
                geo.MinX = compoundLine.Envelope.MinX;
                geo.MinY = compoundLine.Envelope.MinY;
                geo.MinZ = compoundLine.Envelope.MinZ;
            }
            geo.GeometryType = compoundLine.GeometryType;
            geo.IsEmpty = compoundLine.IsEmpty;
            geo.IsValid = compoundLine.IsValid;
            geo.VertexAttribute = compoundLine.VertexAttribute;
            geo.HasId = compoundLine.HasId();
            geo.HasM = compoundLine.HasM();
            geo.HasZ = compoundLine.HasZ();
            // Curve属性
            geo.IsClosed = compoundLine.IsClosed;
            geo.Length = compoundLine.Length;
            if (compoundLine.StartPoint != null)
            {
                geo.StartPointX = compoundLine.StartPoint.X;
                geo.StartPointY = compoundLine.StartPoint.Y;
                geo.StartPointZ = compoundLine.StartPoint.Z;
            }
            if (compoundLine.EndPoint != null)
            {
                geo.EndPointX = compoundLine.EndPoint.X;
                geo.EndPointY = compoundLine.EndPoint.Y;
                geo.EndPointZ = compoundLine.EndPoint.Z;
            }
            // CompoundLine属性
            geo.PointCount = compoundLine.PointCount;
            geo.SegmentCount = compoundLine.SegmentCount;

            this.propertyGrid1.SelectedObject = geo;
        }