Class: OpenPlaces::Geo

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/open_places/geo.rb

Direct Known Subclasses

Country, Lake, Park, Place, Province, River

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.FIELDSObject



37
38
39
40
41
# File 'app/models/open_places/geo.rb', line 37

def self.FIELDS
  @fields ||= ["id","geotype", "subtype", "scalerank", "code", "name", "short_name", "long_name",
  "country_name", "country_code", "province_name", "province_code", "continent", "region_un", "subregion", "region_wb",
  "latitude", "longitude", "x_min", "y_min", "x_max", "y_max", "bbox","latlng", "geom", "tsvector","area", "slug", "path"]
end

.GEO_FIELDSObject



43
44
45
# File 'app/models/open_places/geo.rb', line 43

def self.GEO_FIELDS
  @geofields ||= ['geom', 'latlng', 'bbox', 'x_min', 'y_min', 'x_max', 'y_max', 'tsvector']
end

.IMPORT_FIELDSObject



47
48
49
# File 'app/models/open_places/geo.rb', line 47

def self.IMPORT_FIELDS
  @import_fields ||= self.FIELDS - ['geom', 'latlng', 'bbox', 'id', 'short_name', 'long_name', 'slug', 'path']
end

Instance Method Details

#geocode_recordObject



29
30
31
32
33
34
35
# File 'app/models/open_places/geo.rb', line 29

def geocode_record
  if latitude_changed? && longitude_changed?
    reverse_geocode
  elsif long_name_changed?
    geocode
  end
end