[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: [postgis-users] PostGIS on Rails (IvyGIS) implementation...
From: Robert Thau <rst () alum ! mit ! edu>
Date: 2006-04-20 19:19:04
Message-ID: 17479.57000.436920.806173 () panix2 ! panix ! com
[Download RAW message or body]
Sean Gillies wrote:
> Nice work! How did you get PostGIS geometries to work with Active
> Record? Or do you work around?
Well, here's most of the "Park" model from the "Canada" sample app:
class Park < ActiveRecord::Base
include IvyGIS::GISRecord
geometry_column :the_geom, IvyGIS::MultiPolygon
def self.find_by_list_params(params)
self.find :all,
:select => "id, name_e, " +
"simplify(the_geom, #{params[:scale].to_f/2}) as the_geom",
:conditions => (located_by params, 'the_geom')
end
end
What "geometry_column" does is arrange for WKB parsing and rendering
when translating the column of that name to the corresponding attribute.
You can also invoke the parser directly, a la
IvyGIS::Polygon.new(my_computed_wkb)
if you have a computed column with a name you haven't predeclared.
Note the somewhat awkward business of "simplify"ing the geometry
column for display --- I didn't want to do that in Ruby. (The SVG/VML
rendering is slow enough! If it was only SVG, I'd be very likely
using PostGIS's own SVG rendering --- it's not hard to write in Ruby,
but for large collections of geometries, it's slower than you'd like).
Hope this helps --- and sorry for breaking threading; I subscribed
to the list in digest mode.
rst
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic