lib/postgis_functions.rb in nofxx-postgis_adapter-0.3.1 vs lib/postgis_functions.rb in nofxx-postgis_adapter-0.3.3

- old
+ new

@@ -9,17 +9,17 @@ # http://nofxx.lighthouseapp.com/projects/20712-postgisadapter # # # Some links: # -# PostGis Manual - http://postgis.refractions.net/documentation/manual-svn/ch07.html +# PostGis Manual - http://postgis.refractions.net/documentation/manual-svn/ch07.html # Earth Spheroid - http://en.wikipedia.org/wiki/Figure_of_the_Earth # -# + module PostgisFunctions + # WGS84 Spheroid EARTH_SPHEROID = "'SPHEROID[\"GRS-80\",6378137,298.257222101]'" # SRID => 4326 - #EARTH_SPHEROID = "'SPHEROID[\"IERS_2003\",6378136.6,298.25642]'" # SRID => def postgis_calculate(operation, subjects, options = {}) subjects = [subjects] unless subjects.respond_to?(:map) return execute_geometrical_calculation(operation, subjects, options) rescue Exception => e @@ -27,19 +27,19 @@ end private def get_column_name - @geo_column ||= postgis_geoms[:columns].first + @geo_column ||= postgis_geoms[:columns] end # - # Construct the postgis sql query + # Construct the PostGIS SQL query # - # Area return in square feet - # Distance/DWithin/Length/Perimeter — in projected units. - # DistanceSphere/Spheroid — in meters. + # Returns: + # Area/Distance/DWithin/Length/Perimeter => projected units + # DistanceSphere/Spheroid => meters # def construct_geometric_sql(type,geoms,options) tables = geoms.map do |t| { :name => t.class.table_name, @@ -54,11 +54,11 @@ end fields = tables.map { |f| "#{f[:uid]}.#{get_column_name}" } # W1.geom 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 + tables.map! { |f| "#{f[:name]} #{f[:uid]}" } # streets W1 # # Data => SELECT Func(A,B) # BBox => SELECT (A <=> B) # Func => SELECT Func(Func(A)) @@ -147,10 +147,10 @@ #ST_AsEWKT #ST_AsHEXEWKB #ST_AsGML #ST_AsKML #ST_AsSVG -# +# #EARTH_SPHEROID = "'SPHEROID[\"IERS_2003\",6378136.6,298.25642]'" # SRID => # def distance_convert(value, unit, from = nil) # factor = case unit # when :km, :kilo then 1 # when :miles,:mile then 0.62137119 # when :cm, :cent then 0.1