[CDBI] Working with OGC geometry data types...

Judd Taylor judd at marine.usf.edu
Tue Feb 28 17:41:22 GMT 2006


I'm pretty new to cdbi, and I got a question on how to work with the Open
Geospatial Consortium (OGC) geometry data types now present in MySQL and
other databases.

Basically, the OGC geometry data type is a binary datatype that can
represent all sorts of geometries (points, lines, etc).

However, I don't want to deal with this thing as binary, since I don't want
to maintain code for doing things that the database itself can do. When I
pull the value, I want it's Well Known Text representation (aka WKT), which
is easily done in a simple modification to the SQL select statement:

SELECT AsText(geometry) FROM __TABLE__;

When I input values to the database, I want to use the WKT format as well,
which needs another function:

INSERT INTO geom VALUES (GeomFromText('POINT(1 1)'));

In summary, I just want $class->geometry() to return text, and
$class->insert({ geometry => 'POINT(1 1)' }) to work.

What's the best way I can do this through Cdbi? Accessors, triggers, or
something else?

Thanks,
    Judd Taylor

PS: I can give links to relevant docs on these things from OGC and MySQL to
save time if you want, but they probably aren't necessary.

______________________________
Judd Taylor
Computer Research Specialist
Institute for Marine Remote Sensing
University of South Florida
140 7th Ave. South
St Petersburg, FL 33701
(727) 553-1186
(727) 553-1103 (fax)
judd at marine.usf.edu





More information about the ClassDBI mailing list