Module: ActiveRecord::PostgreSQLExtensions::PostGIS

Defined in:
lib/active_record/postgresql_extensions/postgis.rb

Class Method Summary collapse

Class Method Details

.UNKNOWN_SRIDObject



47
48
49
50
51
52
53
# File 'lib/active_record/postgresql_extensions/postgis.rb', line 47

def UNKNOWN_SRID
  return @UNKNOWN_SRID if defined?(@UNKNOWN_SRID)

  @UNKNOWN_SRID = if self.UNKNOWN_SRIDS
    self.UNKNOWN_SRIDS[:geometry]
  end
end

.UNKNOWN_SRIDSObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_record/postgresql_extensions/postgis.rb', line 29

def UNKNOWN_SRIDS
  return @UNKNOWN_SRIDS if defined?(@UNKNOWN_SRIDS)

  @UNKNOWN_SRIDS = if !self.VERSION
    nil
  elsif self.VERSION[:lib] >= '2.0'
    {
      :geography => 0,
      :geometry  => 0
    }.freeze
  else
    {
      :geography =>  0,
      :geometry  => -1
    }.freeze
  end
end

.VERSIONObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_record/postgresql_extensions/postgis.rb', line 6

def VERSION
  return @VERSION if defined?(@VERSION)

  @VERSION = if (version_string = ::ActiveRecord::Base.connection.select_rows("SELECT postgis_full_version()").flatten.first).present?
    hash = {
      :use_stats => version_string =~ /USE_STATS/
    }

    {
      :lib => /POSTGIS="([^"]+)"/,
      :geos => /GEOS="([^"]+)"/,
      :proj => /PROJ="([^"]+)"/,
      :libxml => /LIBXML="([^"]+)"/
    }.each do |k, v|
      hash[k] = version_string.scan(v).flatten.first
    end

    hash.freeze
  else
    nil
  end
end