{ "info": { "author": "Javier Cordero Martinez", "author_email": "jcorderomartinez@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "django-earthdistance\n=====================\n\nUsing PostgreSQL's EarthDistance extension for django >= 1.8 (for older versions see *with_djorm_expressions* branch)\n\nEarthdistance allows to do fast geolocalized queries without using PostGIS\n\n**Tested with python 2.7 and 3.3**\n\n\nUsage\n---------------\n\nCube and EarthDistance extensions must be enabled in postgreSQL BD, so log in\ndatabase using pgsql and install extensions:\n\n.. code:: sql\n\n => create extension cube;\n => create extension earthdistance;\n\n\n\nFilter by rows inside a circunference of radius r\n--------------------------------------------------\n\n.. code:: python\n\n from django.db import models\n\n from django_earthdistance.models import EarthDistanceQuerySet\n\n class MyModel(models.Model):\n latitute = models.FloatField()\n longitude = models.FloatField()\n\n objects = EarthDistanceQuerySet.as_manager()\n\n # Define fields to query in DistanceExpression initialization\n # search with lat=0.2546 and lon=-38.25 and distance 1500 meters\n # use param `annotate` to set a custom field for the distance, `_ed_distance` as default\n\n MyModel.objects.in_distance(1500, fields=['latitude', 'longitude'], points=[0.2546, -38.25])\n\n\nAnnotate each row returned by a query with distance between two points\n----------------------------------------------------------------------\n\n.. code:: python\n\n from django_earthdistance.models import EarthDistance, LlToEarth\n\n MyModel.objects.filter(....).annotate(\n distance=EarthDistance([\n LlToEarth([0.2546, -38.25]),\n LlToEarth(['latitude', 'longitude'])\n ]))\n\n\n\nOptimizing perfomance with indexes\n-----------------------------------\n\nPostgreSQL allow to use GiST indexes with functions results, a good perfomance improvement is to store `ll_to_earth` results in\nan index, `ll_to_earth` is a function that calculates the position of a point on the surface of the earth (assuming earth is \nperfectly spherical)\n\n\n.. code:: sql\n \n -- Example MyModel table is app_mymodel and points columns are latitude and longitude\n CREATE INDEX mymodel_location ON app_mymodel USING gist (ll_to_earth(latitude, longitude));\n\nFor django < 1.7\n~~~~~~~~~~~~~~~~~\n\nAlso, using south is preferred, just add this migration to migrations/ folder and edit it to your needs, index will be created\n\n.. code:: python\n\n class Migration(SchemaMigration):\n\n def forwards(self, orm):\n cursor = connection.cursor()\n cursor.execute(\"CREATE INDEX mymodel_location ON app_mymodel USING gist (ll_to_earth(latitude, longitude));\")\n\n\n def backwards(self, orm):\n # Deleting field 'Venue.coords'\n cursor = connection.cursor()\n cursor.execute(\"DROP INDEX mymodel_location ON app_mymodel;\")\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jneight/django-earthdistance", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "django-earthdistance", "package_url": "https://pypi.org/project/django-earthdistance/", "platform": "", "project_url": "https://pypi.org/project/django-earthdistance/", "project_urls": { "Homepage": "https://github.com/jneight/django-earthdistance" }, "release_url": "https://pypi.org/project/django-earthdistance/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Add support for PostgreSQL earthdistance extension to Django", "version": "1.1.0" }, "last_serial": 4999540, "releases": { "0.1a": [ { "comment_text": "", "digests": { "md5": "5138781ea49158a8ce5b47cc0df9ce73", "sha256": "93516027c3d8725bb97424afb1a3a835dacd965850e041cb202979142a23d24c" }, "downloads": -1, "filename": "django-earthdistance-0.1a.tar.gz", "has_sig": false, "md5_digest": "5138781ea49158a8ce5b47cc0df9ce73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3545, "upload_time": "2013-08-01T16:30:42", "url": "https://files.pythonhosted.org/packages/9c/04/eadcd8bea0e043ebc7b9b99ffb13b02fd40c1ed7c62511c9a63c4bd8a290/django-earthdistance-0.1a.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "fd6b83d53396cf8b5a528be96ba3b87a", "sha256": "f3565dbba1e1e75f8236b237f69c3a810ce3b1c4feb98e813a3a827ab0f12196" }, "downloads": -1, "filename": "django-earthdistance-0.3.tar.gz", "has_sig": false, "md5_digest": "fd6b83d53396cf8b5a528be96ba3b87a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2809, "upload_time": "2013-09-14T15:27:54", "url": "https://files.pythonhosted.org/packages/9d/32/46fd60a1644e8d849beb1fca3df4448a367600869819f950b94be54abc20/django-earthdistance-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "de70c181c2262a6422a5a553715929ab", "sha256": "b6df66eaef1f79fca3dcc4d2f5862fec728a3bb33410059e9fce7717707ec036" }, "downloads": -1, "filename": "django-earthdistance-0.4.tar.gz", "has_sig": false, "md5_digest": "de70c181c2262a6422a5a553715929ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6780, "upload_time": "2013-09-15T13:56:31", "url": "https://files.pythonhosted.org/packages/e6/6a/d5aa195c9878bda98e2091fb32dcb0f342626b891f30cd4ae8f4ae16c63c/django-earthdistance-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "6d8972575e5a5961c8dd6a9ca32a98f9", "sha256": "5a94bd92ee7f25e7c9fb4b647fd74dcb8ea888b09899d26d2e4bf8048c10be61" }, "downloads": -1, "filename": "django-earthdistance-0.5.tar.gz", "has_sig": false, "md5_digest": "6d8972575e5a5961c8dd6a9ca32a98f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8877, "upload_time": "2014-06-08T15:50:12", "url": "https://files.pythonhosted.org/packages/fb/89/8085c91a80121f7ac95fec93adf958a858b2cec0d9e5a17baa095b159260/django-earthdistance-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "54c54e75ba7777c160cd9c9538017648", "sha256": "268b0b069d802e74191371e373d83b86d0f67ff34dce073395947ec121d7c638" }, "downloads": -1, "filename": "django-earthdistance-0.6.tar.gz", "has_sig": false, "md5_digest": "54c54e75ba7777c160cd9c9538017648", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9162, "upload_time": "2014-12-04T18:17:30", "url": "https://files.pythonhosted.org/packages/df/6d/31acab668849a424076618ae1f2fc89019f9d8cc8baa678364d719374604/django-earthdistance-0.6.tar.gz" } ], "1": [ { "comment_text": "", "digests": { "md5": "2780991ab888094087b76d08c1dd8b05", "sha256": "4f41a101ac53c3fa3078057ab5c84ddbf7e24ba00d3b3ffb79e833bcf7869f90" }, "downloads": -1, "filename": "django-earthdistance-1.tar.gz", "has_sig": false, "md5_digest": "2780991ab888094087b76d08c1dd8b05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8226, "upload_time": "2015-08-14T19:10:52", "url": "https://files.pythonhosted.org/packages/00/2b/6580953b80e68b54613bbece16de1c7e2f88d337342f7a1d748e5fdf32df/django-earthdistance-1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "0e39dca8f28c9cf1f3434efe9b07d30c", "sha256": "c42f03eba3b7341c9b977339a0e27edda642211381bf1a78d0194fc41fd97a7a" }, "downloads": -1, "filename": "django-earthdistance-1.1.0.tar.gz", "has_sig": false, "md5_digest": "0e39dca8f28c9cf1f3434efe9b07d30c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8048, "upload_time": "2019-03-28T18:13:43", "url": "https://files.pythonhosted.org/packages/55/b5/d887bac40d37116360f2b20ca64f18049e40fc69e342b8261018f7bed289/django-earthdistance-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0e39dca8f28c9cf1f3434efe9b07d30c", "sha256": "c42f03eba3b7341c9b977339a0e27edda642211381bf1a78d0194fc41fd97a7a" }, "downloads": -1, "filename": "django-earthdistance-1.1.0.tar.gz", "has_sig": false, "md5_digest": "0e39dca8f28c9cf1f3434efe9b07d30c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8048, "upload_time": "2019-03-28T18:13:43", "url": "https://files.pythonhosted.org/packages/55/b5/d887bac40d37116360f2b20ca64f18049e40fc69e342b8261018f7bed289/django-earthdistance-1.1.0.tar.gz" } ] }