You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning 1: us_counties_20m.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
This warning came in with #8483, but for all I can tell, there's nothing wrong with the geometry in that file (ids 1524 and 1973 in the 1:20m file at least). Looking at the relevant code:
for (int iRing = 1; iRing < psShape->nParts; iRing++)
{
tabPolygons[iRing]->getEnvelope(&sCurEnvelope);
if (!sFirstEnvelope.Intersects(sCurEnvelope))
{
// If the envelopes of the rings don't intersect,
// then it is clearly a multi-part polygon
bUseSlowMethod = true;
break;
}
else
{
// Otherwise take 4 points at each extremity of
// the inner rings and check if there are in the
// outer ring. If none are within it, then it is
// very likely a outer ring (or an invalid ring
// which is neither a outer nor a inner ring)
auto poRing = tabPolygons[iRing]->getExteriorRing();
constauto nNumPoints = poRing->getNumPoints();
OGRPoint p;
OGRPoint leftPoint(
std::numeric_limits<double>::infinity(), 0);
OGRPoint rightPoint(
-std::numeric_limits<double>::infinity(), 0);
OGRPoint bottomPoint(
0, std::numeric_limits<double>::infinity());
OGRPoint topPoint(
0, -std::numeric_limits<double>::infinity());
for (int iPoint = 0; iPoint < nNumPoints - 1;
++iPoint)
{
poRing->getPoint(iPoint, &p);
if (p.getX() < leftPoint.getX() ||
(p.getX() == leftPoint.getX() &&
p.getY() < leftPoint.getY()))
{
leftPoint = p;
}
if (p.getX() > rightPoint.getX() ||
(p.getX() == rightPoint.getX() &&
p.getY() > rightPoint.getY()))
{
rightPoint = p;
}
if (p.getY() < bottomPoint.getY() ||
(p.getY() == bottomPoint.getY() &&
p.getX() > bottomPoint.getX()))
{
bottomPoint = p;
}
if (p.getY() > topPoint.getY() ||
(p.getY() == topPoint.getY() &&
p.getX() < topPoint.getX()))
{
topPoint = p;
}
}
if (!poRing->isPointInRing(&leftPoint) &&
!poRing->isPointInRing(&rightPoint) &&
!poRing->isPointInRing(&bottomPoint) &&
!poRing->isPointInRing(&topPoint))
{
bUseSlowMethod = true;
break;
}
}
}
it says it's checking that points are in the "exterior ring", but near as I can tell the polygons in tabPolygons are all individual rings, so the exterior ring of any of those is polygons is itself. Is perhaps the correct line instead:
auto poRing = tabPolygons[0]->getExteriorRing();
? Otherwise, am I missing something here as to why the warning is actually correct?
The text was updated successfully, but these errors were encountered:
With GDAL >=3.7.3, I'm seeing the following when loading any of the US Census Bureau county borders files, for instance the 1:20m file:
This warning came in with #8483, but for all I can tell, there's nothing wrong with the geometry in that file (ids 1524 and 1973 in the 1:20m file at least). Looking at the relevant code:
gdal/ogr/ogrsf_frmts/shape/shape2ogr.cpp
Lines 352 to 418 in 6133cf3
it says it's checking that points are in the "exterior ring", but near as I can tell the polygons in
tabPolygons
are all individual rings, so the exterior ring of any of those is polygons is itself. Is perhaps the correct line instead:? Otherwise, am I missing something here as to why the warning is actually correct?
The text was updated successfully, but these errors were encountered: