lib/postgis_functions.rb in nofxx-postgis_adapter-0.5.1 vs lib/postgis_functions.rb in nofxx-postgis_adapter-0.5.5

- old
+ new

@@ -24,16 +24,16 @@ return execute_geometrical_calculation(operation, subjects, options) rescue Exception => e raise StandardError, "#{e}" end - private - - def get_column_name - @geo_column ||= postgis_geoms[:columns][0] + def geo_columns + @geo_columns ||= postgis_geoms[:columns] end + private + # # Construct the PostGIS SQL query # # Returns: # Area/Distance/DWithin/Length/Perimeter => projected units @@ -42,20 +42,21 @@ def construct_geometric_sql(type,geoms,options) not_db, on_db = geoms.partition { |g| g.is_a? Geometry } tables = on_db.map do |t| { :name => t.class.table_name, + :column => t.geo_columns.first, :uid => unique_identifier, :id => t[:id] } end # Implement a better way for options? if options.instance_of? Hash transform = options.delete(:transform) options = nil end - fields = tables.map { |f| "#{f[:uid]}.#{get_column_name}" } # W1.geom + fields = tables.map { |f| "#{f[:uid]}.#{f[:column]}" } # W1.geom fields << not_db.map { |g| "'#{g.as_hex_ewkb}'::geometry"} unless not_db.empty? fields.map! { |f| "ST_Transform(#{f}, #{transform})" } if transform # ST_Transform(W1.geom,x) conditions = tables.map { |f| "#{f[:uid]}.id = #{f[:id]}" } # W1.id = 5 tables.map! { |f| "#{f[:name]} #{f[:uid]}" } # streets W1