Giter VIP home page Giter VIP logo

django-postgres-geometry's Introduction

django-postgres-geometry

Exposes Postgres geometry types into Django model's fields. This package doesn't need any extra PostgreSQL extensions to be installed, it uses just the built-in geometry types.

Installation

Install the package with:

pip install git+https://github.com/expobrain/django-postgres-geometry

Usage

This packages provides the following type of fields:

  • PointField a single point in the plane
  • SegmentField a two-points segment
  • SegmentPathField a path defined by two or more points
  • PolygonField a self closing polygon defined by two or more points; the first and last point must be equal
  • BoxField a box defined by te upper-right and lower-left corners ins this; the box can be defined by any pair of corners but on retrieve the box will be always re-calculated as upper-right and lower-left corners
  • CircleField a circle defined by a center and a radius

All fields returns Point instances except for CircleField which return a Circle instance.

The fields acts like a common Django's field with the same set of arguments and keywords. See the Django's model field reference.

Tests

To run the unit tests you need a PostgreSQL instance up and running on your localhost. Update the settings_tests.py file to accomodate your needs. The tests can be run with:

python manage.py test --settings=settings_test

Todo

  • implement get_prep_lookup() functions
  • do not require a PostgreSQL instance to run the unit tests
  • extend the support of geometry types to other backends as well (SQLite, MySQL, etc.)

Changelog

0.1.3

  • Do not fail if database has PostGIS extensions

0.1.2

  • fixed validator on PolygonField: minimum number of points for a polygon is 3 not 4

0.1.1

  • Fixed Polygon field validation: a polygon must have a minimum of 3 points and removed check of last point is equal to the first point

0.1

  • First release with all the PostgreSQL geometrics types implemented except the SQL filtering support

django-postgres-geometry's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-postgres-geometry's Issues

Django 1.7 and AttributeError in migrations

Hi!

Trying to run manage.py migrate I get this:

AttributeError: 'BoxField' object has no attribute '_get_prep_value'

There appears to be some change between Django 1.6 and Django 1.7 wrt how fields work, as this is ok with 1.6.

Any clues on this?

Thanks!

PS.
I was thinking this might be related to slots and/or metaclasses, but I'm able to copypaste the missing method from PointMixin into BoxField without an AttributeError so it's not exactly that...

`Value is not a valid point` error on PointField when empty string is used

Submitting an empty string for the geometry_point field using the following definition results in a Value is not a valid point error:

geometry_point = fields.PointField(
    help_text='Use a cartesian-based coordinate, e.g. (60,-12)',
    blank=True,
    null=True
)

Screenshot below of relevant code. Line 237 can be changed to if isinstance(value, Point) or not value: to get rid of the error.

screen shot 2015-03-09 at 4 24 37 pm

Data types coming out of the db

Hi!

When creating a box, it's ok to pass Points to the model constructor, but when queried the data comes back as text. Do you have plans to fix this? What would you accept in a PR; the use of regexps to transform the string into tuples/Points or do you have cleaner ideas?

Thanks!

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.