Module: Model::Location

Extended by:
ActiveSupport::Concern
Included in:
Ship::Location
Defined in:
app/models/ship/model/location.rb

Instance Method Summary collapse

Instance Method Details

#geoObject

todo 依赖 rails profiled



43
44
45
46
47
48
49
50
# File 'app/models/ship/model/location.rb', line 43

def geo
  result = QqMapHelper.geocoder(lat: lat, lng: lng)
  r = result['address_component']
  area = Profiled::Area.sure_find [r['province'], r['city'], r['district']]
  self.area = area
  self.save
  result
end

#geo_laterObject



38
39
40
# File 'app/models/ship/model/location.rb', line 38

def geo_later
  LocationGeoJob.perform_later(self)
end

#position_textObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/ship/model/location.rb', line 22

def position_text
  if line.new_record?
    count = line.locations.size
  else
    count = line.locations_count
  end

  if position == 1
    '起点'
  elsif position >= count
    '终点'
  else
    "途经点#{position}"
  end
end