{"id":16874543,"url":"https://github.com/joway/django-geofield","last_synced_at":"2025-04-11T11:30:23.382Z","repository":{"id":57420225,"uuid":"59495304","full_name":"joway/django-geofield","owner":"joway","description":"A lightweight Django Geo Field to save and handle Geo Points with geohash","archived":false,"fork":false,"pushed_at":"2024-03-12T19:09:19.000Z","size":2279,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:51:09.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/joway/django-geofield","language":"Python","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/joway.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-23T15:41:46.000Z","updated_at":"2019-08-27T11:03:54.000Z","dependencies_parsed_at":"2025-02-19T06:42:05.002Z","dependency_job_id":null,"html_url":"https://github.com/joway/django-geofield","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fdjango-geofield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fdjango-geofield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fdjango-geofield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fdjango-geofield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joway","download_url":"https://codeload.github.com/joway/django-geofield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248383835,"owners_count":21094616,"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-13T15:33:13.039Z","updated_at":"2025-04-11T11:30:23.327Z","avatar_url":"https://github.com/joway.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Django-GeoField\n=====\n![](https://api.travis-ci.org/joway/django-geofield.svg?branch=master)\n\nA lightweight Django Geo Field to save and handle Geo Points. It supports to search the nearby points by their geohash.\n\nQuick start\n-----------\n\n0. Install django-geofield\n\n        pip install django-geofield\n\n1. Define GeoPositionField in your Model like this::\n\n        class Point(models.Model):\n            ...\n            position = GeoPositionField(db_index=True)\n\n2. Run `python manage.py makemigrations` and `python manage.py migrate` to make it effect\n\n3. The field will save a geo point with a string into database like this :\n\n        Point.objects.create(\n                        position=GeoPosition(lat, lon, precision=6))\n\n        'wtmm7w,30.49145747305400533377905958332121372222900390625,120.042387425481223317547119222581386566162109375'\n\n4. If you want to query the points whose geohash is matched exactly with the given point , you can :\n\n        pos = Point.objects.get(id=1)\n\n        points_matched = Point.objects.filter(position__geoprecise=pos.position.geohash)\n\n\n    The '__geoprecise' lookup will find all points have the same geohash.\n\n5. If you want to query the points in expand area to eliminate the geohash's marginal error, you can :\n\n        pos = Point.objects.get(id=1)\n\n        points_matched = Point.objects.filter(position__geosearch=pos.position.geohash)\n\n    The '__geosearch' lookup will find all points have one of 9 ( 1 center point and 8 expand point) geohash .\n\n\n6. If you want to query the points within a specific range , you should lookup the geohash table to get the geohash length you want, then just search the cropped length.\n\n        pos = Point.objects.get(id=1)\n\n        points_matched = Point.objects.filter(position__geosearch=pos.position.geohash[0:4])\n\n    ![](http://images.cnitblog.com/blog/522490/201309/09185913-9f6f65fc3d3c40ecb3328970831c625c.png)\n\n#### PS: \n\nIf you want to limit the distance strictly, you should writer your own codes to filter the result .\n\nAbout GeoHash\n------\n\n[Wikipedia](http://en.wikipedia.org/wiki/Geohash)\n\n\n\n\nSupport\n------\n\npython:\n  - \"2.7\"\n  - \"3.2\"\n  - \"3.3\"\n  - \"3.4\"\n  - \"3.5\"\n  - \"3.5-dev\" # 3.5 development branch\n  - \"nightly\" # currently points to 3.6-dev\n\n\nThanks\n------\n\n[python-geohash](https://github.com/hkwi/python-geohash/blob/master/geohash.py)\n\nLicense\n------\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Fdjango-geofield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoway%2Fdjango-geofield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Fdjango-geofield/lists"}