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

Oasis - Build spatial index for charge stations based on Google::S2 #239

Closed
CodeBear801 opened this issue Mar 20, 2020 · 1 comment
Closed
Assignees
Labels
NewFeature New feature or feature improvement Prototype Proof of concept

Comments

@CodeBear801
Copy link

CodeBear801 commented Mar 20, 2020

Subtask of #231, implements #236

image

  • It loads points data from previous step and build spatial index to answer nearbyQuery
  • It requires to record pre-processing data to files, so next time just need load data back to re-build spatial information
@CodeBear801
Copy link
Author

CodeBear801 commented Mar 23, 2020

Code saving:

Print Cells in sorted distance

func cellIDFromString(s string) s2.CellID {
	level := len(s) - 2
	if level < 0 || level > 30 {
		return s2.CellID(0)
	}
	face := int(s[0] - '0')
	if face < 0 || face > 5 || s[1] != '/' {
		return s2.CellID(0)
	}
	id := s2.CellIDFromFace(face)
	for i := 2; i < len(s); i++ {
		childPos := s[i] - '0'
		if childPos < 0 || childPos > 3 {
			return s2.CellID(0)
		}
		id = id.Children()[childPos]
	}
	return id
}

	keys := make([]string, 0, len(cellID2PointIDs))
	for k := range cellID2PointIDs {
		keys = append(keys, k.String())
	}
	sort.Strings(keys)
	for _, kStr := range keys {
		k := cellIDFromString(kStr)
		fmt.Printf("%d : {", k)
		for i, p := range cellID2PointIDs[k] {
			if i != 0 {
				fmt.Printf(",")
			}
			fmt.Printf("%d", p)
		}
		fmt.Printf("}, // %v \n", k)
	}

CodeBear801 added a commit that referenced this issue Mar 24, 2020
@CodeBear801 CodeBear801 added the Prototype Proof of concept label Mar 25, 2020
@CodeBear801 CodeBear801 added the NewFeature New feature or feature improvement label Mar 26, 2020
CodeBear801 added a commit that referenced this issue Mar 30, 2020
* feat: implement spartial index query based on google::s2
issue: #239
CodeBear801 added a commit that referenced this issue Apr 1, 2020
* feat: implement spatial index query based on google::s2
issue: #239
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NewFeature New feature or feature improvement Prototype Proof of concept
Projects
None yet
Development

No branches or pull requests

1 participant