Module: TheGeomGeoJSON::ActiveRecord

Defined in:
lib/the_geom_geojson/active_record.rb

Instance Method Summary collapse

Instance Method Details

#the_geomObject



63
64
65
66
67
68
69
# File 'lib/the_geom_geojson/active_record.rb', line 63

def the_geom
  if @the_geom_geojson_dirty
    raise TheGeomGeoJSON::Dirty, "the_geom can't be accessed on #{self.class.name} id #{id.inspect} until it has been saved"
  else
    read_attribute :the_geom
  end
end

#the_geom_geojsonObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/the_geom_geojson/active_record.rb', line 48

def the_geom_geojson
  if @the_geom_geojson_dirty
    @the_geom_geojson_change
  elsif preselected = read_attribute(:the_geom_geojson)
    preselected
  elsif the_geom
    started_at = Time.now
    memo = TheGeomGeoJSON.ewkb_to_geojson the_geom
    if (elapsed = Time.now - started_at) > 0.1
      $stderr.puts "[the_geom_geojson] EWKB->GeoJSON parsing took #{elapsed}s, recommend using #{self.class.name}.with_geojson scope"
    end
    memo
  end
end

#the_geom_geojson=(v) ⇒ Object



42
43
44
45
# File 'lib/the_geom_geojson/active_record.rb', line 42

def the_geom_geojson=(v)
  @the_geom_geojson_dirty = true
  @the_geom_geojson_change = v
end

#the_geom_webmercatorObject



71
72
73
74
75
76
77
# File 'lib/the_geom_geojson/active_record.rb', line 71

def the_geom_webmercator
  if @the_geom_geojson_dirty
    raise TheGeomGeoJSON::Dirty, "the_geom_webmercator can't be accessed on #{self.class.name} id #{id.inspect} until it has been saved"
  else
    read_attribute :the_geom_webmercator
  end
end