Skip to content

Conversation

@rubenpoppe
Copy link

Fully implement S2R2Rect with testing

return math.Max(i.Lo, math.Min(i.Hi, p))
}

func (i Interval) Project(p float64) float64 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Document all public methods. You can take inspiration from the cpp implementation at https://github.com/google/s2geometry/blob/ac448e2e939863dfefdeb6500ea74fda92d8187c/src/s2/r1interval.h#L172, but make sure you follow https://go.dev/doc/comment#func.

s2/r2rect.go Outdated
return r.CapBound().CellUnionBound()
}

// func (r R2Rect) ContainsPoint(p Point) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these commented out?

s2/r2rect.go Outdated
return r.CapBound().CellUnionBound()
}

// func (r R2Rect) ContainsPoint(p Point) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Collaborator

@jmr jmr left a comment

Choose a reason for hiding this comment

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

Before I get too far into the details, why do you want this?

Are you just checking things off the "done" list, or do you have a use case?

This class isn't really used much. There was once an idea that the geometry library would handle both planar and spherical geometry, but the planar part isn't well developed.

The comments say it's a "stopgap measure" (which is admittedly now 20 years old).

https://github.com/google/s2geometry/blob/ac448e2e939863dfefdeb6500ea74fda92d8187c/src/s2/s2r2rect.h#L39

}

func (i Interval) Project(p float64) float64 {
if p < i.Lo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's clampInt, add clamp there if #256 doesn't get merged first.

geo/s2/util.go

Line 29 in fd65259

func clampInt(x, lo, hi int) int {

}
}

func (r Rect) Vertex(k int) Point {
Copy link
Collaborator

Choose a reason for hiding this comment

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

All public functions should be directly tested.

return Point{r.X.ClampPoint(p.X), r.Y.ClampPoint(p.Y)}
}

func (r Rect) Project(p Point) Point {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function doesn't come from C++ as far as I can see.

@jmr
Copy link
Collaborator

jmr commented Jan 8, 2026

Tests are broken, but should be fixed by #255.

@rubenpoppe
Copy link
Author

Before I get too far into the details, why do you want this?

Are you just checking things off the "done" list, or do you have a use case?

Hi @jmr, I don't have a specific use case, just checking off indeed. If you want to put this on hold or drop it, it's fine by me.

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.

3 participants