Skip to content

Commit

Permalink
Merge pull request #4507 from OSGeo/backport-4506-to-release/3.3
Browse files Browse the repository at this point in the history
[Backport release/3.3] GML: fix warning when reading .gfs file with a polyhedral surface
  • Loading branch information
rouault authored Sep 18, 2021
2 parents 30bf833 + 4a9078b commit bde282d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
24 changes: 12 additions & 12 deletions gdal/ogr/ogr_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ typedef enum
wkbCurve = 13, /**< Curve (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurface = 14, /**< Surface (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurface = 15,/**< a contiguous collection of polygons, which share common boundary segments,
* ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
* ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTIN = 16, /**< a PolyhedralSurface consisting only of Triangle patches
* ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangle = 17, /**< a Triangle. ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
* ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTriangle = 17, /**< a Triangle. ISO SQL/MM Part 3. GDAL &gt;= 2.3 */

wkbNone = 100, /**< non-standard, for pure attribute records */
wkbLinearRing = 101, /**< non-standard, just for createGeometry() */
Expand All @@ -384,9 +384,9 @@ typedef enum
wkbMultiSurfaceZ = 1012, /**< wkbMultiSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbCurveZ = 1013, /**< wkbCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceZ = 1014, /**< wkbSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceZ = 1015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINZ = 1016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleZ = 1017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbPolyhedralSurfaceZ = 1015, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTINZ = 1016, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTriangleZ = 1017, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */

wkbPointM = 2001, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbLineStringM = 2002, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
Expand All @@ -402,9 +402,9 @@ typedef enum
wkbMultiSurfaceM = 2012, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurveM = 2013, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceM = 2014, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceM = 2015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINM = 2016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleM = 2017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbPolyhedralSurfaceM = 2015, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTINM = 2016, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTriangleM = 2017, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */

wkbPointZM = 3001, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbLineStringZM = 3002, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
Expand All @@ -420,9 +420,9 @@ typedef enum
wkbMultiSurfaceZM = 3012, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurveZM = 3013, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceZM = 3014, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceZM = 3015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINZM = 3016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleZM = 3017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbPolyhedralSurfaceZM = 3015, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTINZM = 3016, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
wkbTriangleZM = 3017, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */

#if defined(DOXYGEN_SKIP)
// Sphinx doesn't like 0x8000000x constants
Expand Down
27 changes: 19 additions & 8 deletions gdal/ogr/ogrsf_frmts/gml/gmlfeatureclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "cpl_minixml.h"
#include "cpl_string.h"
#include "ogr_core.h"
#include "ogr_p.h"
#include "ogr_geometry.h"

CPL_CVSID("$Id$")
Expand Down Expand Up @@ -468,6 +469,18 @@ bool GMLFeatureClass::InitializeFromXML( CPLXMLNode *psRoot )
const char *pszGPath = "";
int nGeomType = wkbUnknown;

const auto FlattenGeomTypeFromInt = [] (int eType)
{
eType = eType & (~wkb25DBitInternalUse);
if( eType >= 1000 && eType < 2000 ) // ISO Z.
return eType - 1000;
if( eType >= 2000 && eType < 3000 ) // ISO M.
return eType - 2000;
if( eType >= 3000 && eType < 4000 ) // ISO ZM.
return eType - 3000;
return eType;
};

CPLXMLNode *psThis = nullptr;
for( psThis = psRoot->psChild; psThis != nullptr; psThis = psThis->psNext )
{
Expand All @@ -484,11 +497,10 @@ bool GMLFeatureClass::InitializeFromXML( CPLXMLNode *psRoot )
if( pszType != nullptr && !EQUAL(pszType, "0") )
{
nGeomType = atoi(pszType);
const OGRwkbGeometryType nFlattenGeomType =
wkbFlatten(nGeomType);
const int nFlattenGeomType = FlattenGeomTypeFromInt(nGeomType);
if( nGeomType != 0 &&
!(nFlattenGeomType >= wkbPoint &&
nFlattenGeomType <= wkbMultiSurface) )
!(nFlattenGeomType >= static_cast<int>(wkbPoint) &&
nFlattenGeomType <= static_cast<int>(wkbTIN)) )
{
nGeomType = wkbUnknown;
CPLError(CE_Warning, CPLE_AppDefined,
Expand Down Expand Up @@ -571,17 +583,16 @@ bool GMLFeatureClass::InitializeFromXML( CPLXMLNode *psRoot )
if( pszGeometryType != nullptr && !EQUAL(pszGeometryType, "0") )
{
nGeomType = atoi(pszGeometryType);
const OGRwkbGeometryType nFlattenGeomType =
wkbFlatten(nGeomType);
const int nFlattenGeomType = FlattenGeomTypeFromInt(nGeomType);
if( nGeomType == 100 || EQUAL(pszGeometryType, "NONE") )
{
bHasValidGeometryElementPath = false;
bHasFoundGeomType = false;
break;
}
else if( nGeomType != 0 &&
!(nFlattenGeomType >= wkbPoint &&
nFlattenGeomType <= wkbMultiSurface) )
!(nFlattenGeomType >= static_cast<int>(wkbPoint) &&
nFlattenGeomType <= static_cast<int>(wkbTIN)) )
{
nGeomType = wkbUnknown;
CPLError(CE_Warning, CPLE_AppDefined,
Expand Down

0 comments on commit bde282d

Please sign in to comment.