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

Calculate S2 of polygon with OOM Error in golang #329

Closed
gzqlovemxq opened this issue Sep 7, 2023 · 2 comments
Closed

Calculate S2 of polygon with OOM Error in golang #329

gzqlovemxq opened this issue Sep 7, 2023 · 2 comments

Comments

@gzqlovemxq
Copy link

gzqlovemxq commented Sep 7, 2023

I use golang to calaulate a s2 cells of a polygon
[[104.3694198,30.2951281],[104.3633136,30.2962483],[104.365088,30.2959228],[104.3694198,30.2951281]]

And I found it usually happened when the area of polygon is very small.

Is there any bug for S2 Golang with handling this scenario?

        s2Points := make([]s2.Point, 0, len(coords))
	for _, points := range coords {
		for i := 0; i < len(points)-1; i++ {
			s2Points = append(s2Points, s2.PointFromLatLng(s2.LatLngFromDegrees(points[i][1], points[i][0])))
		}
	}

	s2Loop := s2.LoopFromPoints(s2Points)
	if err := s2Loop.Validate(); err != nil {
		return nil, err
	}

	if ok, err := isCCWOrder(coords); err != nil {
		return nil, err
	} else if !ok {
		s2Loop.Invert()
	}

	rc := &s2.RegionCoverer{MinLevel: 14, MaxLevel: 14, MaxCells: 1e7}
	cells := rc.Covering(s2Loop)
@smcallis
Copy link
Collaborator

smcallis commented Sep 7, 2023

The Go fork of S2 is maintained at https://github.com/golang/geo, I'd recommend opening this issue over there for better visibility.

@gzqlovemxq
Copy link
Author

gzqlovemxq commented Sep 11, 2023

Got it, have moved with this issue and Thank for your advising.

@smcallis smcallis closed this as completed Oct 2, 2023
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

No branches or pull requests

2 participants