fixed export deletion routes

This commit is contained in:
Jeffrey Warren
2014-12-10 17:07:28 +00:00
committed by jywarren
parent 9db3e63e0d
commit feaeebbc5b
19 changed files with 9 additions and 158 deletions

View File

@@ -402,7 +402,7 @@ class BetaController < ApplicationController
export.jpg = false
export.save
directory = Rails.root+"/public/warps/"+map.name+"/"
directory = Rails.root.to_s+"/public/warps/"+map.name+"/"
stdin, stdout, stderr = Open3.popen3('rm -r '+directory.to_s)
puts stdout.readlines
puts stderr.readlines

View File

@@ -162,117 +162,6 @@ class Map < ActiveRecord::Base
end
end
# composite in infrared data to make an NRG
def composite(export_type,band_id)
# create an export based on the last normal export and start tracking status:
unless export = self.get_export(export_type) # searches only "normal" exports
export = Export.new({:map_id => self.id,:status => 'starting'})
end
export.export_type = 'nrg'
export.bands_string = 'nrg:'+band_id.to_s
export.status = 'starting'
export.tms = false
export.geotiff = false
export.zip = false
export.jpg = false
export.save
band_map = Map.find(band_id)
path = "public/warps/"+self.name+"/"
band_path = "public/warps/"+band_map.name+"/"
stdin, stdout, stderr = Open3.popen3('rm -r public/tms/'+self.name+"-nrg/")
puts stdout.readlines
puts stderr.readlines
stdin, stdout, stderr = Open3.popen3('rm '+path+self.name+"-nrg.tif")
puts stdout.readlines
puts stderr.readlines
stdin, stdout, stderr = Open3.popen3('rm '+path+self.name+"-nrg.jpg")
puts stdout.readlines
puts stderr.readlines
gdalbuildvrt = "gdalbuildvrt "+path+self.name+"-nrg.vrt "+path+self.name+"-geo.tif "+band_path+band_map.name+"-geo.tif"
puts gdalbuildvrt
system(Gdal.ulimit+gdalbuildvrt)
# edit the XML file here - swap band #s and remove alpha layer
#require "rexml/document"
file = File.new( path+self.name+"-nrg.vrt" )
doc = REXML::Document.new file
bands = []
#doc.elements.each('VRTDataset/VRTRasterBand/SimpleSource/SourceBand') do |n|
# first, remove infrared SimpleSources from bands 2 and 3, visible from SimpleSource band 1
index = 0
doc.elements.each('VRTDataset/VRTRasterBand') do |rasterband|
sourceindex = 0
rasterband.elements.each('SimpleSource') do |source|
if index == 0 # if R band
if sourceindex == 0 # remove visible source
source.remove
else
# leave infrared "red" band
# ...but maybe this is wrong, we should blend all 3?
end
elsif index > 0 # if G,B,A band
if sourceindex == 1 # remove infrared source
source.remove
else
source.elements.each("SourceBand") do |band|
band.text = band.text.to_i-1 # decrement band
end
end
end
sourceindex += 1
end
rasterband.remove if index == 3 # delete alpha band
index += 1
end
# write VRT to log:
# puts doc
# Write the result back into the VRT file.
formatter = REXML::Formatters::Default.new
file = File.open( path+self.name+"-nrg.vrt", "w") do |f|
formatter.write(doc, f)
end
geotiff_location = path+self.name+"-nrg.tif"
gdalwarp = "gdalwarp "+path+self.name+"-nrg.vrt "+geotiff_location
puts gdalwarp
system(Gdal.ulimit+gdalwarp)
info = (`identify -quiet -format '%b,%w,%h' #{geotiff_location}`).split(',')
puts info
export = self.get_export(export_type)
if info[0] != ''
export.geotiff = true
export.size = info[0]
export.width = info[1]
export.height = info[2]
export.cm_per_pixel = 0 #100.0000/pxperm must get from gdalinfo?
export.status = 'tiling'
export.save
end
puts '> generating tiles'
# make tiles:
google_api_key = APP_CONFIG["google_maps_api_key"]
gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'-nrg" -g "'+google_api_key+'" '+Rails.root.to_s+'/public/warps/'+self.name+'/'+self.name+'-nrg.tif '+Rails.root.to_s+'/public/tms/'+self.name+"-nrg/"
# puts gdal2tiles
# puts system('which gdal2tiles.py')
system(Gdal.ulimit+gdal2tiles)
export.tms = true
export.status = 'generating jpg'
export.save
export.jpg = true if self.generate_jpg("nrg")
export.status = 'complete'
export.save
end
# for sparklines graph display
def images_histogram
hist = []
@@ -360,7 +249,7 @@ class Map < ActiveRecord::Base
composite_location
end
# generates a tileset at Rails.root/public/tms/<map_name>/
# generates a tileset at Rails.root.to_s/public/tms/<map_name>/
def generate_tiles
google_api_key = APP_CONFIG["google_maps_api_key"]
gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'" -g "'+google_api_key+'" '+Rails.root.to_s+'/public/warps/'+self.name+'/'+self.name+'-geo.tif '+Rails.root.to_s+'/public/tms/'+self.name+"/"

View File

@@ -183,7 +183,7 @@ class Warpable < ActiveRecord::Base
}
}
else
File.copy(Rails.root+'/public'+self.image.image_file_name,local_location)
File.copy(Rails.root.to_s+'/public'+self.image.image_file_name,local_location)
end
points = ""

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'

View File

@@ -1 +0,0 @@
curl http://localhost:3010/messages/import

6
script/rails Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'