15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/ffi-ogr/http_reader.rb', line 15
def read(url, writeable=false)
file_extension = url.split('.').last
driver = OGR::DRIVER_TYPES[file_extension]
if driver.nil?
unless url =~ /FeatureServer/
raise RuntimeError.new "File type not supported."
else
file_extension = 'json'
driver = OGR::DRIVER_TYPES[file_extension]
end
end
http_data = Faraday.get(url).body
ogr_driver = OGR::FFIOGR::OGRGetDriverByName driver
data_source = OGR::FFIOGR::OGR_Dr_Open ogr_driver, http_data, TF_MAP[writeable]
OGR::Tools.cast_data_source data_source
end
|