{"id":17919626,"url":"https://github.com/asim/quadtree","last_synced_at":"2026-01-07T17:22:14.673Z","repository":{"id":16179105,"uuid":"18925558","full_name":"asim/quadtree","owner":"asim","description":"Go QuadTree Library","archived":false,"fork":false,"pushed_at":"2025-07-05T15:57:08.000Z","size":17,"stargazers_count":34,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-05T17:05:12.140Z","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/asim.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":"2014-04-18T21:03:26.000Z","updated_at":"2025-07-05T15:56:24.000Z","dependencies_parsed_at":"2023-01-11T19:17:18.575Z","dependency_job_id":null,"html_url":"https://github.com/asim/quadtree","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/asim/quadtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fquadtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fquadtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fquadtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fquadtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asim","download_url":"https://codeload.github.com/asim/quadtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fquadtree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264543556,"owners_count":23625386,"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-10-28T20:18:24.591Z","updated_at":"2026-01-07T17:22:14.663Z","avatar_url":"https://github.com/asim.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QuadTree\n\nA fast, production-ready spatial index for Go. Insert, remove, update, and search millions of points with k-nearest neighbor queries.\n\nUsed for location-based services, game development, spatial analytics, and anywhere you need efficient 2D point lookups.\n\n[![GoDoc](https://pkg.go.dev/badge/github.com/asim/quadtree)](https://pkg.go.dev/github.com/asim/quadtree)\n[![Go Report Card](https://goreportcard.com/badge/github.com/asim/quadtree)](https://goreportcard.com/report/github.com/asim/quadtree)\n\n## Features\n\n- **Fast spatial queries** - K-nearest neighbor search with distance sorting\n- **Full CRUD** - Insert, update, remove, and query points\n- **Persistence** - Built-in file storage with JSON or custom backends\n- **HTTP API** - Ready-to-use REST endpoints for your application\n- **Interactive UI** - Embeddable visualization for debugging and management\n- **Zero dependencies** - Pure Go, no external libraries\n- **Battle-tested** - Used in production for location services\n\n## Install\n\n```bash\ngo get github.com/asim/quadtree\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/asim/quadtree\"\n)\n\nfunc main() {\n    // Create a quadtree covering the world\n    center := quadtree.NewPoint(0, 0, nil)\n    half := quadtree.NewPoint(90, 180, nil)\n    bounds := quadtree.NewAABB(center, half)\n    tree := quadtree.New(bounds, 0, nil)\n\n    // Insert some cities\n    tree.Insert(quadtree.NewPoint(51.5074, -0.1278, \"London\"))\n    tree.Insert(quadtree.NewPoint(48.8566, 2.3522, \"Paris\"))\n    tree.Insert(quadtree.NewPoint(52.5200, 13.4050, \"Berlin\"))\n\n    // Find 2 nearest cities to a point\n    query := quadtree.NewPoint(50.0, 5.0, nil)\n    searchBounds := quadtree.NewAABB(query, query.HalfPoint(500000))\n    \n    for _, p := range tree.KNearest(searchBounds, 2, nil) {\n        fmt.Printf(\"Found: %s\\n\", p.Data().(string))\n    }\n}\n```\n\n## HTTP API\n\nEmbed a REST API in your application:\n\n```go\nimport \"github.com/asim/quadtree\"\n\n// Create tree with persistent storage\ntree := quadtree.New(bounds, 0, nil)\nstore, _ := quadtree.NewFileStore(\"points.json\")\nhandler := quadtree.NewHTTPHandler(tree, store)\n\nhttp.Handle(\"/api/\", http.StripPrefix(\"/api\", handler))\nhttp.ListenAndServe(\":8080\", nil)\n```\n\n**Endpoints:**\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | /points | List all points |\n| POST | /points | Add a point |\n| GET | /points/{id} | Get a point |\n| DELETE | /points/{id} | Delete a point |\n| POST | /search | Search within radius |\n\n## Interactive UI\n\n![QuadTree Viewer](https://github.com/user-attachments/assets/f7f3f3a6-ff29-4a7e-86ed-9dccd579e067)\n\nA built-in visualization UI for debugging and point management:\n\n```go\nimport \"github.com/asim/quadtree/ui\"\n\n// Add UI to your server\nhttp.Handle(\"/\", ui.Handler(ui.DefaultConfig()))\n```\n\nFeatures:\n- Pan/zoom with mouse, touch, keyboard\n- Real-time point visualization\n- CRUD operations via UI\n- Mobile-responsive\n- Customizable appearance\n\n## Standalone Server\n\nRun the included server for quick testing:\n\n```bash\ncd cmd/server\ngo run main.go\n# Visit http://localhost:8080\n```\n\n## Use Cases\n\n- **Location services** - Find nearby restaurants, stores, users\n- **Game development** - Spatial collision detection, entity lookup\n- **Mapping** - Efficient point-of-interest queries\n- **Analytics** - Geospatial data clustering and search\n- **IoT** - Device location tracking and proximity alerts\n\n## Performance\n\nQuadtree provides O(log n) average case for insertions and queries, making it suitable for datasets from thousands to millions of points.\n\n## Examples\n\nSee the [examples directory](./examples) for complete, runnable code:\n\n```bash\ncd examples\ngo run simple.go   # Basic operations\ngo run basic.go    # Real-world cities demo\n```\n\n## Enterprise Support\n\nUsing QuadTree in production? Need custom features, priority support, or consulting?\n\n**[Create an issue](https://github.com/asim/quadtree/issues/new)** or contact for enterprise inquiries.\n\n## License\n\n[Apache 2.0](LICENSE)\n\n---\n\nBuilt by [Asim Aslam](https://github.com/asim) • Part of [Mu.XYZ](https://mu.xyz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasim%2Fquadtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasim%2Fquadtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasim%2Fquadtree/lists"}