Class: SpatialFeatures::Importers::KMLFile

Inherits:
KML
  • Object
show all
Defined in:
lib/spatial_features/importers/kml_file.rb

Direct Known Subclasses

Geomark, KMLFileArcGIS

Constant Summary

Constants inherited from KML

SpatialFeatures::Importers::KML::COORDINATES_WITH_ALTITUDE, SpatialFeatures::Importers::KML::IMAGE_METADATA_KEYS

Instance Attribute Summary

Attributes inherited from Base

#errors, #source_identifier

Instance Method Summary collapse

Methods inherited from Base

create_all, #features

Constructor Details

#initialize(path_or_url, **options) ⇒ KMLFile

Returns a new instance of KMLFile.



4
5
6
7
8
9
10
# File 'lib/spatial_features/importers/kml_file.rb', line 4

def initialize(path_or_url, **options)
  path = Download.open_each(path_or_url, unzip: [/\.kml$/], downcase: true).first
  super ::File.read(path), base_dir: Pathname.new(path).dirname, **options
rescue SocketError, Errno::ECONNREFUSED, OpenURI::HTTPError
  url = URI(path_or_url)
  raise ImportError, "KML server is not responding. Ensure server is running and accessible at #{[url.scheme, "//#{url.host}", url.port].select(&:present?).join(':')}."
end

Instance Method Details

#cache_keyObject



12
13
14
# File 'lib/spatial_features/importers/kml_file.rb', line 12

def cache_key
  @cache_key ||= Digest::MD5.hexdigest(@data)
end