Skip to content

Commit

Permalink
Fixed #709. The crash happened with shapefiles containing 2.5D geomet…
Browse files Browse the repository at this point in the history
…ries.

Now these files can be importent, but Z coordinates are ignored.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7126 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Aug 6, 2007
1 parent 5e72aed commit 64d0f1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/plugins/spit/qgsshapefile.cpp
Expand Up @@ -123,13 +123,25 @@ bool QgsShapeFile::scanGeometries()

}
}

// a hack to support 2.5D geometries (their wkb is equivalent to 2D variants
// except that the highest bit is set also). For now we will ignore 3rd coordinate.
hasMoreDimensions = false;
if (currentType & 0x80000000)
{
QgsDebugMsg("Got a shapefile with 2.5D geometry.");
currentType &= ~0x80000000;
hasMoreDimensions = true;
}

ogrLayer->ResetReading();
geom_type = geometries[currentType];
if(multi && (geom_type.find("MULTI") == -1))
{
geom_type = "MULTI" + geom_type;
}
delete sg;

// std::cerr << "Geometry type is " << currentType << " (" << geometries[currentType] << ")" << std::endl;
return multi;
}
Expand Down Expand Up @@ -363,6 +375,10 @@ bool QgsShapeFile::insertLayer(QString dbname, QString schema, QString geom_col,

int num = geom->WkbSize();
char * geo_temp = new char[num*3];
// 'GeometryFromText' supports only 2D coordinates
// TODO for proper 2.5D support we would need to use 'GeomFromEWKT'
if (hasMoreDimensions)
geom->setCoordinateDimension(2);
geom->exportToWkt(&geo_temp);
QString geometry(geo_temp);

Expand Down
1 change: 1 addition & 0 deletions src/plugins/spit/qgsshapefile.h
Expand Up @@ -68,6 +68,7 @@ class QgsShapeFile : public QObject
bool valid;
//! Flag to indicate the file contains multiple geometry types
bool isMulti;
bool hasMoreDimensions;
int features;
QString filename;
QString geom_type;
Expand Down

0 comments on commit 64d0f1f

Please sign in to comment.