Skip to content
Permalink
Browse files

Fixed #709. The crash happened with shapefiles containing 2.5D geomet…

…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
wonder committed Aug 6, 2007
1 parent 5e72aed commit 64d0f1fe665093369f90eb45b4a30214068b4fc1
Showing with 17 additions and 0 deletions.
  1. +16 −0 src/plugins/spit/qgsshapefile.cpp
  2. +1 −0 src/plugins/spit/qgsshapefile.h
@@ -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;
}
@@ -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);

@@ -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;

0 comments on commit 64d0f1f

Please sign in to comment.
You can’t perform that action at this time.