diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a1d085a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: ruby +rvm: + - 2.4 + +install: + - bundle install + +script: + - ruby test/exporter_test.rb diff --git a/lib/mapknitterExporter.rb b/lib/mapknitterExporter.rb index 41db527..fa13509 100644 --- a/lib/mapknitterExporter.rb +++ b/lib/mapknitterExporter.rb @@ -81,7 +81,7 @@ def self.generate_perspectival_distort(pxperm, path, nodes_array, id, image_file } else require "fileutils" - FileUtils.cp(root + img_url, local_location) + FileUtils.cp(img_url, local_location) end points = "" @@ -233,12 +233,12 @@ def self.distort_warpables(scale, images, export, slug) img_coords = generate_perspectival_distort( scale, slug, - image.nodes_array, - id, - image.filename, - image.url, - image.height, - image.width + image[:nodes_array], + image[:id], + image[:filename], + image[:url], + image[:height], + image[:width] ) puts '- '+img_coords.to_s all_coords << img_coords @@ -258,7 +258,7 @@ def self.generate_composite_tiff(coords, origin, placed_warpables, slug, ordered maxlat = nil maxlon = nil placed_warpables.each do |warpable| - warpable.nodes_array.each do |n| + warpable[:nodes_array].each do |n| minlat = n[:lat] if minlat == nil || n[:lat] < minlat minlon = n[:lon] if minlon == nil || n[:lon] < minlon maxlat = n[:lat] if maxlat == nil || n[:lat] > maxlat @@ -271,12 +271,13 @@ def self.generate_composite_tiff(coords, origin, placed_warpables, slug, ordered warpables = placed_warpables.sort{|a,b|b.poly_area <=> a.poly_area} end warpables.each do |warpable| - geotiffs += ' '+directory+warpable.id.to_s+'-geo.tif' + wid = warpable[:id].to_s + geotiffs += ' '+directory+wid+'-geo.tif' if first - gdalwarp = "gdalwarp -s_srs EPSG:3857 -te "+minlon.to_s+" "+minlat.to_s+" "+maxlon.to_s+" "+maxlat.to_s+" "+directory+warpable.id.to_s+'-geo.tif '+directory+slug+'-geo.tif' + gdalwarp = "gdalwarp -s_srs EPSG:3857 -te "+minlon.to_s+" "+minlat.to_s+" "+maxlon.to_s+" "+maxlat.to_s+" "+directory+wid+'-geo.tif '+directory+slug+'-geo.tif' first = false else - gdalwarp = "gdalwarp "+directory+warpable.id.to_s+'-geo.tif '+directory+slug+'-geo.tif' + gdalwarp = "gdalwarp "+directory+wid+'-geo.tif '+directory+slug+'-geo.tif' end puts gdalwarp system(self.ulimit+gdalwarp) @@ -289,12 +290,12 @@ def self.generate_composite_tiff(coords, origin, placed_warpables, slug, ordered def self.generate_tiles(key, slug, root) key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key == "" # ugh, let's clean this up! key = key || "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" - gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:3857 -t "'+slug+'" -g "'+key+'" '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/tms/'+slug+"/" + gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:3857 -t "'+slug+'" -g "'+key+'" '+'public/warps/'+slug+'/'+slug+'-geo.tif '+'public/tms/'+slug+"/" puts gdal2tiles system(self.ulimit+gdal2tiles) end - # zips up tiles at root/public/tms/.zip; + # zips up tiles at public/tms/.zip; def self.zip_tiles(slug) rmzip = 'cd public/tms/ && rm '+slug+'.zip && cd ../../' system(rmzip) @@ -302,7 +303,7 @@ def self.zip_tiles(slug) system(zip) end - # generates a tileset at root/public/tms// + # generates a tileset at public/tms// def self.generate_jpg(slug, root) imageMagick = 'convert -background white -flatten '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/warps/'+slug+'/'+slug+'.jpg' system(self.ulimit+imageMagick) diff --git a/test/exporter_test.rb b/test/exporter_test.rb index 46f8041..7a74589 100644 --- a/test/exporter_test.rb +++ b/test/exporter_test.rb @@ -70,7 +70,7 @@ def test_all_functions # break this into separate parts origin = MapKnitterExporter.distort_warpables( scale, - [image], + [image], # TODO: here it also expects image to have a nodes_array object export, slug ) @@ -84,7 +84,7 @@ def test_all_functions # break this into separate parts assert MapKnitterExporter.generate_composite_tiff( warpable_coords, origin, - [{nodes_array: nodes_array}], # here it wants a collection of objects, each with a nodes_array + [{nodes_array: nodes_array}], # TODO: here it wants a collection of objects, each with a nodes_array slug, ordered )