Module: ArcGISKmzFeatures

Defined in:
lib/spatial_features/import/arcgis_kmz_features.rb

Defined Under Namespace

Classes: UpdateError

Instance Method Summary collapse

Instance Method Details

#update_features!Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 5

def update_features!
  @feature_error_messages = []
  kml_array = []
  cache_kml = ''

  Array(arcgis_kmz_url).each do |url|
    kml_array << open_kmz_url(url)
    cache_kml << kml_array.last.to_s
  end

  if has_spatial_features_hash?
    new_features_hash = Digest::MD5.hexdigest(cache_kml) if cache_kml.present?

    if new_features_hash != self.features_hash
      replace_features(kml_array)
      update_attributes(:features_hash => new_features_hash)
    else
      return false
    end
  else
    replace_features(kml_array)
  end

  return true
end