用心计较般般错 安心自守事事宽

cgl 坚持、努力终有所获
  新随笔  :: 管理

              string str =_Path+"\\"+ _Name;

            string str =_Path+"\\"+ _Name;

            IntPtr tShapePtr = ShapeLib.SHPOpen(str+".shp","rb+");

            //其中 "rb+"代表可读 可写。

            IntPtr tDBFPtr = ShapeLib.DBFOpen((str) + ".dbf","rb+");

            int iShape = 0;

            for (int i = 0; i < _Rows; i++)

                {

                    for (int j = 0; j < _Cols; j++)

                    {

                        double[] pX=null;

                        double[] pY=null;

                        getPolygon(i,j,ref pX,ref pY);

                        IntPtr tPolygon = ShapeLib.SHPCreateSimpleObject(ShapeLib.ShapeType.Polygon, pX.Length, pX, pY, null);

                        if (tPolygon!=IntPtr.Zero)

                        {

                            ShapeLib.SHPWriteObject(tShapePtr, iShape, tPolygon);

                            ShapeLib.DBFWriteIntegerAttribute(tDBFPtr, iShape, 0, iShape);

                            ShapeLib.SHPDestroyObject(tPolygon);

                        }

                        iShape++;

                    }

                }

            ShapeLib.SHPClose(tShapePtr);

            ShapeLib.DBFClose(tDBFPtr);