From Gustavo Wagner, fixed bugs in reading M records from shapefile

This commit is contained in:
Robert Osfield
2007-12-09 16:38:33 +00:00
parent e2ad20a887
commit 8648cd12ea
3 changed files with 30 additions and 27 deletions

View File

@@ -747,21 +747,6 @@ PointZ::PointZ(const PointZ &p):
PointZ::~PointZ() {}
bool PointZ::read( int fd )
{
if( readVal<Double>( fd, x, LittleEndian ) == false ) return false;
if( readVal<Double>( fd, y, LittleEndian ) == false ) return false;
if( readVal<Double>( fd, z, LittleEndian ) == false ) return false;
if( readVal<Double>( fd, m, LittleEndian ) == false ) return false;
return true;
}
void PointZ::print()
{
printf( " %G %G %G (%G)\n", x, y, z, m );
}
bool PointZRecord::read( int fd )
{
RecordHeader rh;
if( rh.read(fd) == false )
@@ -774,9 +759,27 @@ bool PointZRecord::read( int fd )
if( shapeType != ShapeTypePointZ )
return false;
return pointZ.read(fd);
if( readVal<Double>( fd, x, LittleEndian ) == false )
return false;
if( readVal<Double>( fd, y, LittleEndian ) == false )
return false;
if( readVal<Double>( fd, z, LittleEndian ) == false )
return false;
// Sometimes, M field is not supplied
if( rh.contentLength >= 18 )
if( readVal<Double>( fd, m, LittleEndian ) == false )
return false;
return true;
}
void PointZ::print()
{
printf( " %G %G %G (%G)\n", x, y, z, m );
}
MultiPointZ::MultiPointZ():
ShapeObject(ShapeTypeMultiPointZ),
@@ -900,12 +903,18 @@ PolyLineZ::PolyLineZ(const PolyLineZ &p):
points = new Point[numPoints];
zArray = new Double[numPoints];
mArray = new Double[numPoints];
for( i = 0; i < numPoints; i++ )
{
points[i] = p.points[i];
zArray[i] = p.zArray[i];
mArray[i] = p.mArray[i];
}
// Sometimes, M Array is not present on the file
if( p.mArray != NULL )
{
mArray = new Double[numPoints];
for( i = 0; i < numPoints; i++ )
mArray[i] = p.mArray[i];
}
}

View File

@@ -298,12 +298,6 @@ struct PointZ : public ShapeObject
void print();
};
struct PointZRecord
{
PointZ pointZ;
bool read( int fd );
};
struct MultiPointZ: public ShapeObject
{
Box bbox;

View File

@@ -141,9 +141,9 @@ ESRIShapeParser::ESRIShapeParser( const std::string fileName, bool useDouble ):
case ESRIShape::ShapeTypePointZ :
{
std::vector<ESRIShape::PointZ> ptzs;
ESRIShape::PointZRecord pointZRecord;
while( pointZRecord.read(fd) )
ptzs.push_back( pointZRecord.pointZ );
ESRIShape::PointZ pointZ;
while( pointZ.read( fd ) )
ptzs.push_back( pointZ );
_process( ptzs );
}
break;