Пример #1
0
	///////////
	// RecordHeader
	RecordHeader::RecordHeader(InStream &src)
	{
		mIndex = src.ReadUInt32();
		SwapByteOrder(mIndex);
		
		mLength = src.ReadUInt32();
		SwapByteOrder(mLength);
		
		uint32_t shapeTypeInt = src.ReadUInt32();
		if(!IsSupportedShapeType(shapeTypeInt))
			throw Exception("Unsupported shape type");
		
		mShapeType = (ShapeType)shapeTypeInt;
	}
Пример #2
0
	////////
	// 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();
	}
Пример #3
0
void LcfReader::Read<uint32_t>(std::vector<uint32_t> &buffer, size_t size) {
	buffer.clear();
	size_t items = size / 4;
	for (unsigned int i = 0; i < items; ++i) {
		uint32_t val;
		Read(&val, 4, 1);
		SwapByteOrder(val);
		buffer.push_back(val);
	}
}
Пример #4
0
void LcfReader::Read<int32_t>(std::vector<int32_t> &buffer, size_t size) {
	buffer.clear();
	size_t items = size / 4;
	for (unsigned int i = 0; i < items; ++i) {
		int32_t val;
		Read(&val, 4, 1);
		SwapByteOrder(val);
		buffer.push_back(val);
	}
	if (size % 4 != 0) {
		Seek(size % 4, FromCurrent);
		buffer.push_back(0);
	}
}
Пример #5
0
void LcfReader::Read<uint32_t>(uint32_t& ref) {
	Read(&ref, 4, 1);
	SwapByteOrder(ref);
}
Пример #6
0
void LcfReader::Read<int16_t>(int16_t& ref) {
	Read(&ref, 2, 1);
	SwapByteOrder(ref);
}
Пример #7
0
void LcfReader::Read<double>(double& ref) {
	Read(&ref, 8, 1);
	SwapByteOrder(ref);
}