///////// // PolygonRecord PolygonRecord::PolygonRecord(InStream &src) { mParts = 0; mVertices = 0; try { mBoundingRect.mMin[0] = (float)src.ReadDouble(); mBoundingRect.mMin[1] = (float)src.ReadDouble(); mBoundingRect.mMax[0] = (float)src.ReadDouble(); mBoundingRect.mMax[1] = (float)src.ReadDouble(); mNumParts = src.ReadUInt32(); mNumVertices = src.ReadUInt32(); mParts = new uint32_t[mNumParts]; mVertices = new Vec2[mNumVertices]; src.ReadUInt32Arr(mNumParts,mParts); for(int i = 0;i < mNumVertices;i++) { float x = (float)src.ReadDouble(); float y = (float)src.ReadDouble(); mVertices[i] = MakeVec2(x,y); } } catch(...) { delete [] mParts; delete [] mVertices; throw; } }
//////// // FileHeader FileHeader::FileHeader(InStream &src) { uint32_t magic = src.ReadUInt32(); if(magic != 0x0a270000) throw Exception("Not a .shp file"); src.SkipBytes(20); mFileLength = src.ReadUInt32(); SwapByteOrder(mFileLength); mVersion = src.ReadUInt32(); if(mVersion != 1000) throw Exception("Unsupported version"); uint32_t shapeTypeInt = src.ReadUInt32(); if(!IsSupportedShapeType(shapeTypeInt)) throw Exception("Unsupported shape type"); mShapeType = (ShapeType)shapeTypeInt; mBoundingRect.mMin[0] = (float)src.ReadDouble(); mBoundingRect.mMin[1] = (float)src.ReadDouble(); mBoundingRect.mMax[0] = (float)src.ReadDouble(); mBoundingRect.mMax[1] = (float)src.ReadDouble(); mMinZ = (float)src.ReadDouble(); mMaxZ = (float)src.ReadDouble(); mMinM = (float)src.ReadDouble(); mMaxM = (float)src.ReadDouble(); }