lib/tasks/mapfile.rake in gb_mapfish_appserver-0.0.6 vs lib/tasks/mapfile.rake in gb_mapfish_appserver-0.0.7
- old
+ new
@@ -49,17 +49,17 @@
topic.geolion_gdd_internet = @map.web.metadata['geolion_gdd_internet']
topic.minscale = @map.web.metadata['gb_minscale']
topic.main_layer = true if topic.main_layer.nil?
topic.save!
- topic.topics_layers.destroy_all
- topic.categories_topics.destroy_all
Layer.unused.destroy_all
SublayerGroup.unused.destroy_all
category = @map.web.metadata['gb_category'] || 'Uncategorized'
- topic.categories << Category.find_or_create_by_title(category)
+ if topic.categories.empty?
+ topic.categories << Category.find_or_create_by_title(category)
+ end
sublayer_groups = {}
#Show Symbols
#@map.symbolset.symbols.each do |symbol|
@@ -141,12 +141,13 @@
unless dbonly
#Info & Legend
mkdir_p File.dirname(layer.info_file_auto)
+ display_only = (mlayer.type == MS_LAYER_RASTER && mlayer.connectiontype != MS_WMS) || mlayer.type == MS_LAYER_ANNOTATION
if queryable
- if mlayer.type == MS_LAYER_RASTER || mlayer.type == MS_LAYER_ANNOTATION
+ if display_only
puts "Warning: Raster/Anntotation layer '#{layer.name}' is queryable (TEMPLATE #{mlayer.template})"
end
#puts "Creating #{layer.info_file_auto}"
fields = layer.ident_fields.split(',') rescue []
aliases = if fields.empty?
@@ -154,21 +155,21 @@
[]
else
layer.alias_fields.split(',')
end
infotab_template = "_infotable_auto"
- template = File.open(File.join(File.dirname(__FILE__), 'templates', "#{infotab_template}.html.erb")).read
+ template = File.open(File.join(Rails.root, 'lib', 'tasks', 'templates', "#{infotab_template}.html.erb")).read
template = ERB.new(template, nil, '<>')
File.open(layer.info_file_auto, 'w') do |file|
file << template.result(binding)
end
end
# Layer legend
legend_icon_path = File.join(Rails.root, 'public', 'images', 'custom', topic_name.downcase)
mkdir_p legend_icon_path
- if mlayer.type != MS_LAYER_RASTER && mlayer.type != MS_LAYER_ANNOTATION
+ if !display_only
#puts "Creating #{layer.legend_file_auto}"
File.open(layer.legend_file_auto, 'w') do |file|
file << "<table class='legtab'>\n"
mlayer.classes.each_with_index do |lclass, i|
#Symbol size for Polygon and Line layers
@@ -211,15 +212,18 @@
end
end
end
#topics_layers
- tl = topic.topics_layers.build(:layer => layer)
+ tl = topic.topics_layers.where(:layer_id => layer).first || topic.topics_layers.build(:layer => layer)
tl.queryable = queryable
tl.visini = mlayer.status == MS_ON
tl.wms_sort = layerno
- tl.leg_sort = mlayer.metadata['gb_leg_sort'] || layerno*100
- tl.toc_sort = mlayer.metadata['gb_toc_sort'] || layerno*100
+ #Do now overwrite values changed manually in the DB:
+ tl.leg_sort = mlayer.metadata['gb_leg_sort'] if mlayer.metadata['gb_leg_sort']
+ tl.toc_sort = mlayer.metadata['gb_toc_sort'] if mlayer.metadata['gb_toc_sort']
+ tl.leg_sort ||= layerno*100
+ tl.toc_sort ||= layerno*100
tl.save!
end
unless dbonly
#Legend Template