Coder Social home page Coder Social logo

django-pgsphere's Introduction

Django-PgSphere

pgsphere is a django app which makes a few fields available to your models for working with pgsphere.

Currently the only fields available are

  • SBoxField
  • SPointField

SPointField as an inradius lookup whiuch makes cone searches possible:

MyModel.objects.find(location__inradius=((10,20), 1))

where (10,20) is the center of the seach and 1 is the radius, in degrees.

SBoxField as a contains method, which makes it possible to find objects which contain a specific point:

MyOtherModel.objects.filter(area__contains=(20,10))

Where (20,10) is the point in which you want to find MyOtherModels that have an area containing that point.

Installation

  1. Install this package either using pip or setup.py
  2. add pgsphere to your INSTALLED_APPS
  3. Run migrations (insalls the pg_sphere postgresql extension): ./manage.py migrate
  4. Use the fields in your models: from pgsphere.fields import SPointField, SBoxField

Creating indexes

To create an index on a SPointField or SBoxField run the following on your postgresql table:

CREATE INDEX myapp_myapp_myfield ON myapp_mymodel USING GIST (field_name);

Testing

To run the tests, you must have a postgresql server running with pgsphere installed. See the test_settings.py file for connection details.

django-pgsphere's People

Contributors

fingel avatar skorokithakis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.