Re: [GeoAlchemy] Returning lat, lon from a point as properties

103 views
Skip to first unread message

Eric Lemoine

unread,
Nov 20, 2012, 2:44:06 AM11/20/12
to geoal...@googlegroups.com
On Mon, Nov 19, 2012 at 11:17 AM, Peter 'mash' Morgan
<pedro...@gmail.com> wrote:
>
>
> Newbie question..
>
> I'm trying to get the lat, lon from a geometry column as a property using GeoAlchemy. Is it possible ?
>
> The code with all the attempts is below..


Doesn't Session.scale(self.wkb_geometry.x) work?


>
> tia
> Pete
>
> class Fix(Base):
> __tablename__ = 'fix'
> fix_pk = Column(Integer(), primary_key=True)
> ident = Column(String(10), index=True, nullable=False)
> wkb_geometry = GeometryColumn(Point(2, srid=FGX_SRID), comparator=PGComparator)
> @property
> def lat(self):
> #return self.wkb_geometry.coords[0]
> #return self.wkb_geometry.x
> return "argh" #Session.scalar(self.wkb_geometry.x)
> @property
> def lon(self):
> return "lon" #str(self.wkb_geometry.coords[1])
> def dic(self):
> return dict(ident=self.ident, nav_type="fix",
> lat=self.lat, lon=self.lon)



--
Eric
Reply all
Reply to author
Forward
0 new messages