Skip to content

Commit

Permalink
Tag 2.1.2RC4
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.osgeo.org/gdal/tags/2.1.2@35891 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
rouault committed Oct 24, 2016
2 parents 06aedaa + acc44e9 commit 2c53c02
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 26 deletions.
1 change: 1 addition & 0 deletions gdal/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ The 2.1.1 release is a bug fix release.
== Utilities ==
* gdal_polygonize.py: explicitly set output layer geometry type to be polygon (#6530)
* gdalwarp: do not densify cutlines by default when CUTLINE_BLEND_DIST is used (#6507)
* gdalwarp: fix failure with cutline on a layer of touching polygons (#6694)

== GDAL drivers ==

Expand Down
74 changes: 53 additions & 21 deletions gdal/apps/gdalwarp_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,50 @@ GDALDatasetH GDALWarp( const char *pszDest, GDALDatasetH hDstDS, int nSrcCount,
return (bHasGotErr) ? NULL : hDstDS;
}

/************************************************************************/
/* ValidateCutline() */
/************************************************************************/

static bool ValidateCutline(OGRGeometryH hGeom)
{
OGRwkbGeometryType eType = wkbFlatten(OGR_G_GetGeometryType( hGeom ));
if( eType == wkbMultiPolygon )
{
for( int iGeom = 0; iGeom < OGR_G_GetGeometryCount( hGeom ); iGeom++ )
{
OGRGeometryH hPoly = OGR_G_GetGeometryRef(hGeom,iGeom);
if( !ValidateCutline(hPoly) )
return false;
}
}
else if( eType == wkbPolygon )
{
if( OGRGeometryFactory::haveGEOS() && !OGR_G_IsValid(hGeom) )
{
char *pszWKT = NULL;
OGR_G_ExportToWkt( hGeom, &pszWKT );
CPLDebug("GDALWARP", "WKT = \"%s\"", pszWKT ? pszWKT : "(null)");
//fprintf(stderr, "WKT = \"%s\"\n", pszWKT ? pszWKT : "(null)");
CPLFree( pszWKT );

if( CPLTestBool(CPLGetConfigOption("GDALWARP_IGNORE_BAD_CUTLINE", "NO")) )
CPLError(CE_Warning, CPLE_AppDefined, "Cutline polygon is invalid.");
else
{
CPLError(CE_Failure, CPLE_AppDefined, "Cutline polygon is invalid.");
return false;
}
}
}
else
{
CPLError( CE_Failure, CPLE_AppDefined, "Cutline not of polygon type." );
return false;
}

return true;
}

/************************************************************************/
/* LoadCutline() */
/* */
Expand Down Expand Up @@ -1475,6 +1519,12 @@ LoadCutline( const char *pszCutlineDSName, const char *pszCLayer,
goto error;
}

if( !ValidateCutline(hGeom) )
{
OGR_F_Destroy( hFeat );
goto error;
}

OGRwkbGeometryType eType = wkbFlatten(OGR_G_GetGeometryType( hGeom ));

if( eType == wkbPolygon )
Expand All @@ -1489,12 +1539,6 @@ LoadCutline( const char *pszCutlineDSName, const char *pszCLayer,
OGR_G_GetGeometryRef(hGeom,iGeom) );
}
}
else
{
CPLError( CE_Failure, CPLE_AppDefined, "Cutline not of polygon type." );
OGR_F_Destroy( hFeat );
goto error;
}

OGR_F_Destroy( hFeat );
}
Expand Down Expand Up @@ -2339,22 +2383,10 @@ TransformCutlineToSource( GDALDatasetH hSrcDS, void *hCutline,
return CE_Failure;
}
}
else if( OGRGeometryFactory::haveGEOS() && !OGR_G_IsValid(hMultiPolygon) )
else if( !ValidateCutline(hMultiPolygon) )
{
char *pszWKT = NULL;
OGR_G_ExportToWkt( hMultiPolygon, &pszWKT );
CPLDebug("GDALWARP", "WKT = \"%s\"", pszWKT ? pszWKT : "(null)");
//fprintf(stderr, "WKT = \"%s\"\n", pszWKT ? pszWKT : "(null)");
CPLFree( pszWKT );

if( CPLTestBool(CPLGetConfigOption("GDALWARP_IGNORE_BAD_CUTLINE", "NO")) )
CPLError(CE_Warning, CPLE_AppDefined, "Cutline is not valid after transformation");
else
{
CPLError(CE_Failure, CPLE_AppDefined, "Cutline is not valid after transformation");
OGR_G_DestroyGeometry( hMultiPolygon );
return CE_Failure;
}
OGR_G_DestroyGeometry( hMultiPolygon );
return CE_Failure;
}

/* -------------------------------------------------------------------- */
Expand Down
8 changes: 4 additions & 4 deletions gdal/frmts/rmf/rmfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,10 @@ do { \
poDS->pszUnitType = CPLStrdup( RMF_UnitsM );
break;
case 1:
poDS->pszUnitType = CPLStrdup( RMF_UnitsCM );
poDS->pszUnitType = CPLStrdup( RMF_UnitsDM );
break;
case 2:
poDS->pszUnitType = CPLStrdup( RMF_UnitsDM );
poDS->pszUnitType = CPLStrdup( RMF_UnitsCM );
break;
case 3:
poDS->pszUnitType = CPLStrdup( RMF_UnitsMM );
Expand Down Expand Up @@ -1872,9 +1872,9 @@ GDALDataset *RMFDataset::Create( const char * pszFilename,
// Elevation units
if ( EQUAL(poDS->pszUnitType, RMF_UnitsM) )
poDS->sHeader.iElevationUnit = 0;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsCM) )
poDS->sHeader.iElevationUnit = 1;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsDM) )
poDS->sHeader.iElevationUnit = 1;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsCM) )
poDS->sHeader.iElevationUnit = 2;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsMM) )
poDS->sHeader.iElevationUnit = 3;
Expand Down
2 changes: 1 addition & 1 deletion gdal/gcore/gdal_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

#ifndef GDAL_RELEASE_DATE
# define GDAL_RELEASE_DATE 20161021
# define GDAL_RELEASE_DATE 20161024
#endif
#ifndef GDAL_RELEASE_NAME
# define GDAL_RELEASE_NAME "2.1.2"
Expand Down

0 comments on commit 2c53c02

Please sign in to comment.