On Sep 11, 2009, at 12:44 PM, Matt King wrote:

>
> On Sep 11, 2009, at 10:40 AM, Dan Kubb (dkubb) wrote:
>
>> Does dm-geokit do what you need?  There's a few forks on github, but
>> I'm not sure which one is the "official" one, but it looks like Matt
>> King's is the one with the most recent development:
>>
>> http://github.com/mattking17/dm-geokit
>
> No, it doesn't do any PostGIS stuff, and for that matter it's not
> ready to use for anything quite yet :-)
>
> Will post to the list when it's ready to go though...
>

Thank you.

What I'm looking to do is use the geometry functions to find items  
(points, linestrings, polygons) within a boundary (polygon).  Also  
will need to be able to transform dissimilar reference systems to a  
common datum before doing the searches.

I've started to look into doing a postgis adapter and have a couple of  
questions.

First, postgis adds a geometry column using SELECT AddGeometryColumn,  
example:

SELECT AddGeometryColumn ('hello','poi','poi_geom',-1,'POINT',2);

To extend datamapper's property would mean monkey patching  
Migrations.  Would it be better to create a separate method instead?   
For example instead of:

property :geom, Geometry, :type => Point2d, :srid => 1234, :index =>  
true

do something like:

geometry :geom, Point2d, :srid => 1234

Best practices recommend indexing geometries, so would it be kosher to  
have "geometry" method default to index => true?  Or would it be less  
confusing to keep "property"'s default of index => false?

Finally, postgis adds several dozen SQL functions.  What's the best  
way to present these spatial functions?  Here's an example query to  
find any points within 3km of a coastline:

# this example is from section 1.3.2 of "PostGIS in Action"
# http://www.manning.com/obe/PostGIS_MEAPCH01.pdf
SELECT p.poi_name, round(CAST(ST_Distance(p.poi_geom, c.line_geom) /  
1000 As numeric),2) As dist_km
FROM hello.poi As p
INNER JOIN hello.coastline As c ON ST_DWithin(c.line_geom, p.poi_geom,  
1000*3);

I haven't been able to visualize what the datamapper syntax should be  
for a complex query like this.  About the best that I can see is to  
get the points within.  I don't see how to calculate the dist_km.

class Coastline
   include DataMapper::Resource
   property :id, Serial
   geometry :line_geom, Linestring
end

class Poi
   include DataMapper::Resource
   property :id, Serial
   property :name, String
   geometry :geom, Point2d
end

points_within_3km = Poi.all(:spatial_within => [Coastline, :line_geom,  
1000*3])

Open for any ideas.

TIA,
Roy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to