Skip to content

pybind: Add S2LatLng bindings - #581

Merged
jmr merged 4 commits into
google:masterfrom
deustis:deustis/s2latlng_bindings
May 1, 2026
Merged

jmr merged 4 commits into
google:masterfrom
deustis:deustis/s2latlng_bindings

Conversation

@deustis

@deustis deustis commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Add pybind11 bindings for S2LatLng.

Supports downstream PR for S2CellId.

(Part of a series of addressing #524)

Comment thread src/python/s2latlng_bindings.cc
Comment thread src/python/s2latlng_bindings.cc
Comment thread src/python/s2latlng_bindings.cc Outdated
Comment thread src/python/s2latlng_bindings.cc Outdated
@deustis
deustis marked this pull request as draft April 24, 2026 17:44
…rmalized

- Use absl::StrCat in MaybeThrowNotValid instead of std::ostringstream.
- Change `coords` from a method returning a tuple to a readonly property
  returning R2Point, matching the C++ signature.
- Move `to_string_in_degrees` into the string representation section.
- Add `from_radians_normalized` factory that clamps latitude and wraps
  longitude, accepting any finite values.
@deustis
deustis marked this pull request as ready for review April 24, 2026 18:04
@deustis

deustis commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

@jmr, next installment here. Getting to the fun/useful stuff.

Comment thread src/python/s2latlng_bindings.cc Outdated
Comment thread src/python/README.md Outdated
Comment thread src/python/BUILD.bazel
Comment thread src/python/s2latlng_bindings.cc Outdated
@deustis
deustis requested a review from jmr April 27, 2026 18:11
- Add missing absl/strings BUILD dep to s2latlng_bindings.
- Drop stray "S2LatLng" in README invalid-values example.
- Rename from_radians_normalized to normalized_from_radians for clarity.
@deustis
deustis force-pushed the deustis/s2latlng_bindings branch from 1d18c58 to 70e2c09 Compare April 27, 2026 18:20
@deustis

deustis commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@jmr, let me know if you have any other suggestions on this PR? I'm not sure why the cmake tests are failing...

Comment thread src/python/module.cc
void bind_s1angle(py::module& m);
void bind_s1interval(py::module& m);
void bind_s2point(py::module& m);
void bind_s2latlng(py::module& m);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's keep these sorted alphabetically. You can add // keep-sorted start and // keep-sorted end if you want.

@jmr jmr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can do the sorting change separately.

@jmr
jmr merged commit b68002b into google:master May 1, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants