On 9/6/15 11:28 AM, Demitri Muna wrote:
Hi Ian,

Thanks for the reply.

On Saturday, September 5, 2015 at 11:53:39 AM UTC-4, Ian McCullough wrote:

    Is there some compelling reason you wouldn't just install the
    PostGIS extensions? Assuming there is...


There is; I can't use any of the functionality. My use case is astronomical data where all values are points on a sphere. I can't use the various projections that GIS provides. I investigated the possibility of using GIS tools for astronomical data a few years back, but found it wasn't really appropriate. I actually came across this which I found amusing:

http://lists.osgeo.org/pipermail/postgis-devel/2009-March/005184.html

    Actually, now that I think about it, since you won't be able to
    use them in query expressions anyway, there's probably no reason
    to go to the extra effort of hybrid properties; just make a pure
    python property to do the conversion between the mapped TEXT|BLOB
    column and the Geometry types.


PostrgreSQL has a native "polygon" data type that I'd like to use:

http://www.postgresql.org/docs/current/static/datatype-geometric.html

There is a library that is specifically designed for astronomical data (which indexes points on a sphere):

https://github.com/segasai/q3c

and uses the polygon data type in this function:

q3c_poly_query(ra, dec, poly) -- returns true if ra, dec is within
   the postgresql polygon poly.

This is all I really need. I imagine my class will look something like this:

class Field(Base):
    __tablename__ = 'field'
    __table_args__ = {'autoload' : True}
    polygon_column = ???

Where I can do:

f = Field()
f.polygon = ???

I just don't know what to put into the '???'s.

SQLAlchemy doesn't do much else with types at the most basic level other than pass the data through to the DBAPI, in this case hopefully psycopg2. Feel free to set the column type to NullType and just pass through strings, assuming that's what psycopg2 does here by default, or if you'd like to define your own type that translates some Python value to what psycopg2 expects here, there is UserDefinedType as well as TypeDecorator: http://docs.sqlalchemy.org/en/rel_1_0/core/custom_types.html#types-custom

qc3_poly_query would be a SQL function; any function name is available from func: http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html?highlight=func#sqlalchemy.sql.expression.func





Thanks,
Demitri

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to