Skip to content

Commit

Permalink
adding travis
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Mar 17, 2019
1 parent c1b3110 commit bf375b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: ruby
rvm:
- 2.4

install:
- bundle install

script:
- ruby test/exporter_test.rb
29 changes: 15 additions & 14 deletions lib/mapknitterExporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -289,20 +290,20 @@ 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/<slug>.zip;
# zips up tiles at public/tms/<slug>.zip;
def self.zip_tiles(slug)
rmzip = 'cd public/tms/ && rm '+slug+'.zip && cd ../../'
system(rmzip)
zip = 'cd public/tms/ && ' + self.ulimit + 'zip -rq '+slug+'.zip '+slug+'/ && cd ../../'
system(zip)
end

# generates a tileset at root/public/tms/<slug>/
# generates a tileset at public/tms/<slug>/
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)
Expand Down
4 changes: 2 additions & 2 deletions test/exporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
)
Expand Down

0 comments on commit bf375b6

Please sign in to comment.