diff --git a/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.dbf b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.dbf new file mode 100644 index 000000000000..463b29ccf894 Binary files /dev/null and b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.dbf differ diff --git a/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.prj b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.prj new file mode 100644 index 000000000000..5ded4bcacb7e --- /dev/null +++ b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.prj @@ -0,0 +1 @@ +GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shp b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shp new file mode 100644 index 000000000000..37b1cfd0db6b Binary files /dev/null and b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shp differ diff --git a/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shx b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shx new file mode 100644 index 000000000000..7b5166173bbe Binary files /dev/null and b/autotest/ogr/data/shp/cb_2022_us_county_20m_extract.shx differ diff --git a/autotest/ogr/ogr_shape.py b/autotest/ogr/ogr_shape.py index 6dce6906bf06..5d23cc29fb02 100755 --- a/autotest/ogr/ogr_shape.py +++ b/autotest/ogr/ogr_shape.py @@ -1048,6 +1048,16 @@ def test_ogr_shape_read_multipolygon_as_invalid_polygon(): ) +def test_ogr_shape_read_multipolygon_as_invalid_polygon_no_warning(): + + ds = ogr.Open("data/shp/cb_2022_us_county_20m_extract.shp") + lyr = ds.GetLayer(0) + gdal.ErrorReset() + with gdal.quiet_errors(): + lyr.GetNextFeature() + assert gdal.GetLastErrorMsg() == "" + + ############################################################################### # Test alternate date formatting (#2746) diff --git a/ogr/ogrsf_frmts/shape/shape2ogr.cpp b/ogr/ogrsf_frmts/shape/shape2ogr.cpp index 0689f20bedab..cb1d009d7cf6 100644 --- a/ogr/ogrsf_frmts/shape/shape2ogr.cpp +++ b/ogr/ogrsf_frmts/shape/shape2ogr.cpp @@ -348,6 +348,7 @@ OGRGeometry *SHPReadOGRObject(SHPHandle hSHP, int iShape, SHPObject *psShape, // Only inner rings OGREnvelope sFirstEnvelope; OGREnvelope sCurEnvelope; + auto poExteriorRing = tabPolygons[0]->getExteriorRing(); tabPolygons[0]->getEnvelope(&sFirstEnvelope); for (int iRing = 1; iRing < psShape->nParts; iRing++) { @@ -406,10 +407,10 @@ OGRGeometry *SHPReadOGRObject(SHPHandle hSHP, int iShape, SHPObject *psShape, topPoint = p; } } - if (!poRing->isPointInRing(&leftPoint) && - !poRing->isPointInRing(&rightPoint) && - !poRing->isPointInRing(&bottomPoint) && - !poRing->isPointInRing(&topPoint)) + if (!poExteriorRing->isPointInRing(&leftPoint) && + !poExteriorRing->isPointInRing(&rightPoint) && + !poExteriorRing->isPointInRing(&bottomPoint) && + !poExteriorRing->isPointInRing(&topPoint)) { bUseSlowMethod = true; break; diff --git a/port/cpl_string.cpp b/port/cpl_string.cpp index fc7d47a90668..430b19d9ee42 100644 --- a/port/cpl_string.cpp +++ b/port/cpl_string.cpp @@ -338,7 +338,6 @@ char **CSLLoad2(const char *pszFname, int nMaxLines, int nMaxCols, int nLines = 0; int nAllocatedLines = 0; - CPLErrorReset(); while (!VSIFEofL(fp) && (nMaxLines == -1 || nLines < nMaxLines)) { const char *pszLine = CPLReadLine2L(fp, nMaxCols, papszOptions);