Skip to content

Conversation

@rouault
Copy link
Contributor

@rouault rouault commented Dec 16, 2025

Copy link
Member

@pramsey pramsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LgTM

@rouault
Copy link
Contributor Author

rouault commented Dec 16, 2025

Note GEOS current behavior regarding empty geometries and distance reflects JTS one (CC @dr-jts )

}
if(geom[0]->isEmpty() || geom[1]->isEmpty()) {
return 0.0;
return std::numeric_limits<double>::quiet_NaN();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is (/was?) a PostGIS page that explains this difference between the GEOS and SFCGAL backends. GEOS returned 0 (before this PR), while SFCGAL returned Inf.
When I asked why Inf rather than NaN, I was told that:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with Inf too

@rouault rouault changed the title DistanceOp::distance(): make it return NaN instead of 0 if one of the geometry is empty DistanceOp::distance(): make it return +inf instead of 0 if one of the geometry is empty Dec 18, 2025
@rouault
Copy link
Contributor Author

rouault commented Dec 18, 2025

Changed to returning +Inf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling Distance on an empty geometry returns 0

5 participants