Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address #2466, incorporate #2468 and #2469 #2470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-19

* fix ambiguities in `CPL_area` and `CPL_length` revealed in testing with GDAL 3.10.0 release candidates ; #2466, #2468, #2429

* improve test on empty geometries, which changed in 1.0-18; #2463

* `gdal_utils()` `ogrinfo` has an argument `read_only` which, when `TRUE` (or `options` includes `"-ro"`), opens a datasource in read-only mode (#2460; `sf` did this before 1.0-17); by default a datasource is opened in update (read-write) mode (since sf 1.0-17; #2420)
Expand Down
24 changes: 18 additions & 6 deletions src/gdal_geom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ Rcpp::NumericVector CPL_area(Rcpp::List sfc) {
for (size_t i = 0; i < g.size(); i++) {
if (g[i]->getDimension() == 2) {
OGRwkbGeometryType gt = OGR_GT_Flatten(g[i]->getGeometryType());
if (gt == wkbMultiSurface || gt == wkbMultiPolygon) {
// PR 2468
// if (gt == wkbMultiSurface || gt == wkbMultiPolygon) {
Comment on lines +15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't bring much, right ?

Suggested change
// PR 2468
// if (gt == wkbMultiSurface || gt == wkbMultiPolygon) {

if (OGR_GT_IsSubClassOf(gt, wkbGeometryCollection)) {
// will match OGRMultiPolygon, OGRMultiSurface and OGRGeometryCollection
OGRGeometryCollection *gc = (OGRGeometryCollection *) g[i];
out[i] = gc->get_Area();
} else {
} else if (OGR_GT_IsSurface(gt)) {
OGRSurface *surf = (OGRSurface *) g[i];
out[i] = surf->get_Area();
}
} else
} else {
out[i] = 0.0; // not supposed to happen, but who knows...
}
} else
out[i] = 0.0;
OGRGeometryFactory::destroyGeometry(g[i]);
}
Expand Down Expand Up @@ -63,8 +68,15 @@ Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
}
break;
default: {
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();
// PR 2469
/* OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();*/
Comment on lines +71 to +73
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// PR 2469
/* OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();*/

if (OGR_GT_IsSubClassOf(gt, wkbGeometryCollection)) {
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();
} else {
out[i] = 0.0;
}
}
}
OGRGeometryFactory f;
Expand Down
Loading