示例#1
0
        public ShapeFileRW(string filename)
        {
            shapefilename = filename;

            FileStream   fsr = new FileStream(shapefilename, FileMode.Open);
            BinaryReader br  = new BinaryReader(fsr);

            byte[]   buff   = br.ReadBytes(Marshal.SizeOf(typeof(ShapeFileHeader)));
            GCHandle handle = GCHandle.Alloc(buff, GCHandleType.Pinned);

            shapefileheader = (ShapeFileHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ShapeFileHeader));
            handle.Free();//Give control of the buffer back to the GC



            ShapeType = br.ReadInt32();

            buff            = br.ReadBytes(Marshal.SizeOf(typeof(ShapeFileExtent)));
            handle          = GCHandle.Alloc(buff, GCHandleType.Pinned);
            shapefileextent = (ShapeFileExtent)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ShapeFileExtent));
            handle.Free();//Give control of the buffer back to the GC

            LayerExtent = new MapExtent(shapefileextent.Xmin, shapefileextent.Xmax,
                                        shapefileextent.Ymin, shapefileextent.Ymax);

            ReadSpatialObject(br);

            br.Close();
            fsr.Close();
        }
示例#2
0
 public MapPoint(double _x, double _y)
 {
     thispoint    = new SimpleMapPoint(_x, _y);
     ObjectType   = SPATIALOBJECTTYPE.POINT;
     Centroid     = new SimpleMapPoint(_x, _y);
     ObjectExtent = new MapExtent(thispoint, thispoint);
 }
示例#3
0
 public MapPolygon(SimpleMapPoint[] _points)
 {
     points       = _points;
     ObjectType   = SPATIALOBJECTTYPE.POLYGON;
     Centroid     = MapExtent.getCentroid(_points);
     ObjectExtent = new MapExtent(_points);
     Init();
 }
示例#4
0
 private void Init()
 {
     ObjectType   = SPATIALOBJECTTYPE.LINE;
     Centroid     = MapExtent.getCentroid(points);
     ObjectExtent = new MapExtent(points);
 }