diff --git a/services/importer/lib/importer/fgdb_splitter.rb b/services/importer/lib/importer/fgdb_splitter.rb index 2657680b5b..0d90459690 100644 --- a/services/importer/lib/importer/fgdb_splitter.rb +++ b/services/importer/lib/importer/fgdb_splitter.rb @@ -67,7 +67,7 @@ module CartoDB .select { |line| line =~ /^\d+/ } .map { |line| line.match /\d+: \"?(.*?)\"? \(/ } .map { |line| line[1] } - + fgdb_layers.each do |layer| stdout, stderr, status = Open3.capture3(OGRINFO_BINARY, '-so', source_file.fullpath, layer) number_rows = stdout.split("\n") diff --git a/services/importer/lib/importer/unp.rb b/services/importer/lib/importer/unp.rb index ed90a829e8..e4f65525b1 100644 --- a/services/importer/lib/importer/unp.rb +++ b/services/importer/lib/importer/unp.rb @@ -80,7 +80,8 @@ module CartoDB next if subpath =~ /\.version\.txt/i fullpath = normalize("#{path}/#{subpath}") - (crawl(fullpath, files) and next) if File.directory?(fullpath) + (crawl(fullpath, files) and next) if + File.directory?(fullpath) and !subpath =~ /\.gdb$/i files.push(fullpath) end diff --git a/services/importer/spec/fixtures/filegeodatabase.zip b/services/importer/spec/fixtures/filegeodatabase.zip new file mode 100644 index 0000000000..14f5e84312 Binary files /dev/null and b/services/importer/spec/fixtures/filegeodatabase.zip differ diff --git a/services/importer/spec/fixtures/geopackage.zip b/services/importer/spec/fixtures/geopackage.zip new file mode 100644 index 0000000000..c008b90d8e Binary files /dev/null and b/services/importer/spec/fixtures/geopackage.zip differ diff --git a/services/importer/spec/unit/unp_spec.rb b/services/importer/spec/unit/unp_spec.rb index c5f2da387d..0de33e1e28 100644 --- a/services/importer/spec/unit/unp_spec.rb +++ b/services/importer/spec/unit/unp_spec.rb @@ -25,6 +25,28 @@ describe Unp do FileUtils.rm_rf(unp.temporary_directory) end + it 'extracts the contents of a GPKG file' do + zipfile = zipfile_factory(filename: 'geopackage.zip') + unp = Unp.new + + unp.run(zipfile) + Dir.entries(unp.temporary_directory).should include('geopackage.gpkg') + unp.source_files.length.should eq 2 + (unp.source_files.map { |f| f.layer }).should eq ["pts", "lns"] + FileUtils.rm_rf(unp.temporary_directory) + end + + it 'extracts the contents of a FGDB file' do + zipfile = zipfile_factory(filename: 'filegeodatabase.zip') + unp = Unp.new + + unp.run(zipfile) + Dir.entries(unp.temporary_directory).should include('filegeodatabase.gdb') + unp.source_files.length.should eq 2 + (unp.source_files.map { |f| f.layer }).should eq ["pts", "lns"] + FileUtils.rm_rf(unp.temporary_directory) + end + it 'extracts the contents of a carto file with rar in the name (see #11954)' do zipfile = zipfile_factory(filename: 'this_is_not_a_rar_file.carto') unp = Unp.new @@ -160,6 +182,8 @@ describe Unp do unp.supported?('foo.doc').should eq false unp.supported?('foo.xls').should eq true + unp.supported?('foo.gpkg').should eq true + unp.supported?('foo.gdb').should eq true end end