Skip to content

New argument to process OGR JSON blocks#4573

Merged
hobu merged 3 commits intoPDAL:masterfrom
ibell13:OGR-geometry
Dec 26, 2024
Merged

New argument to process OGR JSON blocks#4573
hobu merged 3 commits intoPDAL:masterfrom
ibell13:OGR-geometry

Conversation

@ibell13
Copy link
Contributor

@ibell13 ibell13 commented Dec 10, 2024

Creating a new class that resolves #4548; the OGRSpec class processes a JSON specification for reading geometry with OGR at the time an argument is added, rather than during a stage's execution.

Right now, the class

  • takes a string argument
  • parses it
  • validates it into a JSON
  • gets all OGR-specified polygons as PDAL Polygons, stores them

This covers the needs of most stages that could potentially use an OGR datasource, like readers.ept and readers.copc. It's implemented there, as well as in filters.geomdistance (where it only uses a single polygon from the container we create). It still needs to be added to filters.crop, readers.tindex and filters.overlay but that should be trivial.

Right now, it could use some reworking to allow non-Polygon geometries to be specified. This might be nice for consistency's sake, for the few times this gets used currently (or maybe future additions, like 2.5D polygons?). I've been having some trouble designing a good solution for that, though.

@hobu hobu added the feature label Dec 12, 2024
@hobu hobu added this to the 2.9.0 milestone Dec 12, 2024
@ibell13 ibell13 marked this pull request as ready for review December 13, 2024 18:11
Copy link
Contributor

@abellgithub abellgithub left a comment

Choose a reason for hiding this comment

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

This is very nice.

void parse();

template <typename T>
void assignJSON(const NL::json& field, T& to)
Copy link
Contributor

Choose a reason for hiding this comment

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

More natural is to return the item from the function call. So then it's like what you're calling below field.get<T>().

s = s.substr(pos + 1);
std::stringstream msg;

msg << "Failed to parse JSON field with error: " << s;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know the field name? Can you tell someone?

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 tried to get it to do that, but I think the function would have to take both item.key() & item.value() for that. unless there's some other way to dereference the json iterator that I missed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I should see what an actual error looks like :)

@hobu hobu mentioned this pull request Dec 18, 2024
@hobu hobu merged commit a7df552 into PDAL:master Dec 26, 2024
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.

Support OGR feature selections for any geometry definitions

3 participants