예제 #1
0
        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);
                }
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: batuZ/Samples
        private void btnConstructMultiPoint_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();
            multiPoint = gfactory.CreateGeometry(gviGeometryType.gviGeometryMultiPoint, gviVertexAttribute.gviVertexAttributeZMID) as IMultiPoint;
            if (multiPoint == null)
                return;

            point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZMID); //point点属性必须与multiPoint相同,否则加不进去
            for (int i = 0; i < 100; i++)
            {
                point.SetCoords(i, 2 * i, 3 * i, 0, i + 1);
                multiPoint.AddPoint(point);
            }

            GeometryCollection geo = new GeometryCollection();
            // Geometry属性
            geo.Dimension = multiPoint.Dimension;
            if (multiPoint.Envelope != null)
            {
                geo.MaxX = multiPoint.Envelope.MaxX;
                geo.MaxY = multiPoint.Envelope.MaxY;
                geo.MaxZ = multiPoint.Envelope.MaxZ;
                geo.MinX = multiPoint.Envelope.MinX;
                geo.MinY = multiPoint.Envelope.MinY;
                geo.MinZ = multiPoint.Envelope.MinZ;
            }
            geo.GeometryType = multiPoint.GeometryType;
            geo.IsEmpty = multiPoint.IsEmpty;
            geo.IsValid = multiPoint.IsValid;
            geo.VertexAttribute = multiPoint.VertexAttribute;
            geo.HasId = multiPoint.HasId();
            geo.HasM = multiPoint.HasM();
            geo.HasZ = multiPoint.HasZ();
            // GeometryCollection属性
            geo.GeometryCount = multiPoint.GeometryCount;
            geo.IsOverlap = multiPoint.IsOverlap;
            this.propertyGrid1.SelectedObject = geo;
        }