Module: ActiveRecord::ConnectionAdapters::PostGIS::ColumnDefinitionUtils
- Defined in:
- lib/active_record/connection_adapters/postgis/table_definition.rb
Class Method Summary collapse
- .default_srid(options) ⇒ Object
- .geo_type(type = "GEOMETRY") ⇒ Object
- .limit_from_options(type, options = {}) ⇒ Object
Class Method Details
.default_srid(options) ⇒ Object
136 137 138 139 |
# File 'lib/active_record/connection_adapters/postgis/table_definition.rb', line 136 def default_srid() # Geography columns default to SRID 4326, geometry columns to 0 [:geographic] ? 4326 : 0 end |
.geo_type(type = "GEOMETRY") ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/active_record/connection_adapters/postgis/table_definition.rb', line 111 def geo_type(type = "GEOMETRY") g_type = type.to_s.delete("_").upcase case g_type when "STPOINT" then "POINT" when "STPOLYGON" then "POLYGON" when "STLINESTRING" then "LINESTRING" when "STMULTIPOINT" then "MULTIPOINT" when "STMULTILINESTRING" then "MULTILINESTRING" when "STMULTIPOLYGON" then "MULTIPOLYGON" when "STGEOMETRYCOLLECTION" then "GEOMETRYCOLLECTION" when "STGEOMETRY" then "GEOMETRY" when "STGEOGRAPHY" then "GEOGRAPHY" else "GEOMETRY" # Default fallback end end |
.limit_from_options(type, options = {}) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/active_record/connection_adapters/postgis/table_definition.rb', line 128 def (type, = {}) has_z = [:has_z] ? "Z" : "" has_m = [:has_m] ? "M" : "" srid = [:srid] || default_srid() field_type = [ type, has_z, has_m ].compact.join "#{field_type},#{srid}" end |