Hi all,
I am testing geoalchemy a bit and I have a problem working with the
geometry attributes (x,y, wkt).
Whenever I do something like db_session.scalar(location.geom.x), I get a
segmentation fault. I tried already debugging it, but I am unable to
find the cause. My code for testing:
def test():
from database import db_session
location = db_session.query(GeoViaah).filter(GeoViaah.id==1).first()
print "Location: id %s parent_id %s type %s" % (
location.id,
location.parent_id,
location.type)
print db_session.scalar(location.geom.x) # segfault here
if __name__ == '__main__':
test()
The model:
class GeoViaah(Base):
__tablename__ = 'geo_viaah'
__table_args__ = {'schema':'viaah'}
pkey = Column('pkey', Integer, primary_key=True)
id = Column('viaah_id', Integer, nullable=False)
parent_id = Column('viaah_parent_id', Integer)
type = Column('viaah_type', Integer)
east = Column('easting', Numeric)
north = Column('northing', Numeric)
geom = GeometryColumn('geom', Point(2, 4326), comparator=PGComparator)
deleted = Column('deleted', Boolean, default=False)
def __init__(self, id=None, parent_id=None, type=None):
self.id = id
self.parent_id= parent_id
self.type = type
and the database connection and session definition:
engine = create_engine('postgresql://bar:foo@localhost/geodb', echo=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False, bind=engine))
metadata = MetaData(engine)
Base = declarative_base(metadata=metadata)
Before the segfault in the console output:
2010-05-10 11:55:44,971 INFO sqlalchemy.engine.base.Engine.0x...abd0
SELECT ST_X(GeomFromWKB(%(param_1)s, %(GeomFromWKB_1)s)) AS x_1
2010-05-10 11:55:44,972 INFO sqlalchemy.engine.base.Engine.0x...abd0
{'GeomFromWKB_1': 4326, 'param_1': <read-only buffer for 0x7f88495033b0,
size 21, offset 0 at 0xafa3b0>}
My system is Ubuntu 8.04 x64 server edition and python2.5. Sqlalchemy is
0.6 and Geoalchemy is 0.2. Post
Does someone have a clue whats going on? From the tutorial this should
be easy enough?!
Many thanks
Frank
--
Frank BRONIEWSKI
METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN
tél.:
+352 26 74 94 - 28
fax.:
+352 26 74 94 99
http://www.metrico.lu