{"id":13411576,"url":"https://github.com/hailocab/go-geoindex","last_synced_at":"2026-02-15T13:11:51.890Z","repository":{"id":26230904,"uuid":"29677651","full_name":"hailocab/go-geoindex","owner":"hailocab","description":"Go native library for fast point tracking and K-Nearest queries","archived":false,"fork":false,"pushed_at":"2018-02-20T21:58:39.000Z","size":55,"stargazers_count":355,"open_issues_count":2,"forks_count":49,"subscribers_count":64,"default_branch":"master","last_synced_at":"2024-10-25T04:09:49.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hailocab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-22T12:26:17.000Z","updated_at":"2024-08-18T17:09:28.000Z","dependencies_parsed_at":"2022-08-17T20:21:37.990Z","dependency_job_id":null,"html_url":"https://github.com/hailocab/go-geoindex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hailocab%2Fgo-geoindex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hailocab%2Fgo-geoindex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hailocab%2Fgo-geoindex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hailocab%2Fgo-geoindex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hailocab","download_url":"https://codeload.github.com/hailocab/go-geoindex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618635,"owners_count":20320269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:14.652Z","updated_at":"2026-02-15T13:11:46.865Z","avatar_url":"https://github.com/hailocab.png","language":"Go","funding_links":[],"categories":["数据结构与算法","Go","Data Structures and Algorithms","Data Structures","others","数据结构","\u003cspan id=\"数据结构-data-structures\"\u003e数据结构 Data Structures\u003c/span\u003e","Generators","数据结构`go语言实现的数据结构与算法`","Data Integration Frameworks","Uncategorized"],"sub_categories":["杂项数据结构和算法","Miscellaneous Data Structures and Algorithms","Advanced Console UIs","Standard CLI","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI"],"readme":"# Geo Index\n\nGeo Index library\n\n## Overview\n\nSplits the earth surface in a grid. At each cell we can store data, such as list of points, count of points, etc. It can do KNearest and Range queries. For more detailed description check https://sudo.hailoapp.com/services/2015/02/18/geoindex/ .\n\n### Demo\n\nhttp://go-geoindex.appspot.com/static/nearest.html - Click to select the nearest points.\n\nhttp://go-geoindex.appspot.com/static/cluster.html - A map with 100K points around the world. Zoom in and out to cluster. \n\n### API\n\n```go\n    type Driver struct {\n        lat float64\n        lon float64\n        id string\n        canAcceptJobs bool\n    }\n\n    // Implement Point interface\n    func (d *Driver) Lat() float64 { return d.lat }\n    func (d *Driver) Lon() float64 { return d.lon }\n    func (d *Driver) Id() string { return d.id }\n\n    // create points index with resolution (cell size) 0.5 km\n    index := NewPointsIndex(Km(0.5))\n\n    // Adds a point in the index, if a point with the same id exists it's removed and the new one is added\n    index.Add(\u0026Driver{\"id1\", lat, lng, true})\n    index.Add(\u0026Driver{\"id2\", lat, lng, false})\n\n    // Removes a point from the index by id\n    index.Remove(\"id1\")\n\n    // get the k-nearest points to a point, within some distance\n    points := index.KNearest(\u0026GeoPoint{id, lat, lng}, 5, Km(5), func(p Point) bool {\n        return p.(* Driver).canAcceptJobs\n    })\n\n    // get the points within a range on the map\n    points := index.Range(topLeftPoint, bottomRightPoint)\n```\n\n### Index types\n\nThere are several index types\n\n```go\n    NewPointsIndex(Km(0.5)) // Creates index that maintains points\n    NewExpiringPointsIndex(Km(0.5), Minutes(5)) // Creates index that expires the points after some interval\n    NewCountIndex(Km(0.5)) // Creates index that maintains counts of the points in each cell\n    NewExpiringCountIndex(Km(0.5), Minutes(15)) // Creates index that maintains expiring count\n    NewClusteringIndex() // index that clusters the points at different zoom levels, so we can create maps\n    NewExpiringClusteringIndex(Minutes(15)) // index that clusters and expires the points at different zoom levels\n                                            // so we can create real time maps of customer request, etc in the driver app\n```\n\n### Performance Benchmarks\n\n    BenchmarkClusterIndexAdd                    500000          5395 ns/op\n    BenchmarkClusterIndexStreetRange            100000         22207 ns/op\n    BenchmarkClusterIndexCityRange              100000         16389 ns/op\n    BenchmarkClusterIndexEuropeRange            50000          36559 ns/op\n\n    BenchmarkExpiringClusterIndexAdd            300000          7124 ns/op\n    BenchmarkExpiringClusterIndexStreetRange    50000          27030 ns/op\n    BenchmarkExpiringClusterIndexCityRange      100000         22185 ns/op\n    BenchmarkExpiringClusterIndexEuropeRange    30000          52080 ns/op\n\n    BenchmarkCountIndexAdd                      1000000         1670 ns/op\n    BenchmarkCountIndexCityRange                100000         20325 ns/op\n\n    BenchmarkExpiringCountIndexAdd              500000          2808 ns/op\n    BenchmarkExpiringCountIndexRange            50000          35791 ns/op\n\n    BenchmarkPointIndexRange                    100000         15945 ns/op\n    BenchmarkPointIndexAdd                      1000000         2416 ns/op\n    BenchmarkPointIndexKNearest                 100000         13788 ns/op\n\n    BenchmarkExpiringPointIndexAdd              500000          4324 ns/op\n    BenchmarkExpiringPointIndexKNearest         100000         15638 ns/op\n    BenchmarkExpiringPointIndexRange            100000         20386 ns/op\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhailocab%2Fgo-geoindex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhailocab%2Fgo-geoindex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhailocab%2Fgo-geoindex/lists"}