Skip to content

Commit

Permalink
Merge pull request #2469 from rouault/fix_CPL_length
Browse files Browse the repository at this point in the history
CPL_length(): fix unchecked cast to OGRGeometryCollection
  • Loading branch information
edzer authored Nov 2, 2024
2 parents 0d1a48b + fdfbf98 commit 5f44d8d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gdal_geom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
}
break;
default: {
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

0 comments on commit 5f44d8d

Please sign in to comment.