Permalink
Browse files

reinstated code for adding canvas layer

  • Loading branch information...
1 parent 4b7e77a commit 0a287542de743b6ef7a2e50d392ae8cd24afee56 @mholling committed Jun 29, 2012
Showing with 35 additions and 24 deletions.
  1. +2 −0 README.markdown
  2. +33 −24 nswtopo.rb
View
@@ -219,6 +219,8 @@ If you include a PNG image named `canvas.png` in the map directory, it will be a
Generating your own vegetation layer can be accomplished using the 'color range' selection tool in Photoshop, for example, or other similar selection tools. (Selecting on a single channel, such as green or magenta, may be helpful.) You can also create additional vegetation markings (e.g. for the distinctive, nasty heath that sometimes appears in ACT rogaines) using the aerial imagery.
+If you wish to create your canvas at a lower resolution, it is fine to resample (resize) the aerial image to smaller pixel count before selecting and colouring the vegetation. However, it is important that you *resample the image by changing its resolution* (usually shown in pixels/inch), rather than by changing the width and height.
+
## Plantations
If you include the `plantation` layer, a representation of pine forest plantations will be added to your map in darker green. The accuracy of this layer is not guaranteed however.
View
@@ -726,7 +726,7 @@ def download(label, options, map)
end
module RasterRenderer
- def default_resolution(label, option, map)
+ def default_resolution(label, options, map)
params["resolution"] || map.scale / 12500.0
end
@@ -1423,6 +1423,12 @@ def embed_image(label, options, map, dimensions, resolution, temp_dir)
class CanvasServer < Server
include NoDownload
include RasterRenderer
+
+ def default_resolution(label, options, map)
+ canvas_path = File.join Dir.pwd, "#{label}.png"
+ raise BadLayerError.new("#{label}.png not found") unless File.exists? canvas_path
+ map.scale * 0.01 / %x[convert "#{canvas_path}" -units PixelsPerCentimeter -format "%[resolution.x]" info:].to_f
+ end
end
class AnnotationServer < Server
@@ -1864,13 +1870,6 @@ def self.run
vegetation_server = VegetationServer.new(config["vegetation"])
layers = {
- "reference-topo-1" => {
- "server" => lpi_ortho,
- "image" => "/OTDF_Imagery/NSWTopoS2v2.ecw",
- "otdf" => true,
- "ext" => "png",
- "resolution" => 4.0,
- },
"reference-topo-2" => {
"server" => sixmaps,
"service" => "NSWTopo",
@@ -1879,6 +1878,13 @@ def self.run
"resolution" => 2.0,
"background" => "white",
},
+ "reference-topo-1" => {
+ "server" => lpi_ortho,
+ "image" => "/OTDF_Imagery/NSWTopoS2v2.ecw",
+ "otdf" => true,
+ "ext" => "png",
+ "resolution" => 4.0,
+ },
"aerial-lpi-eastcoast" => {
"server" => lpi_ortho,
"image" => "/Imagery/lr94ortho1m.ecw",
@@ -1925,13 +1931,13 @@ def self.run
# "service" => "LPI_Imagery_Best",
# "ext" => "jpg",
# },
+ "vegetation" => {
+ "server" => vegetation_server,
+ },
"canvas" => {
"server" => canvas_server,
"ext" => "png",
},
- "vegetation" => {
- "server" => vegetation_server,
- },
"plantation" => {
"server" => atlas,
"service" => "Economy_Forestry",
@@ -1966,18 +1972,18 @@ def self.run
"labels" => %w[Labels],
},
},
+ "relief" => {
+ "server" => oneearth_relief,
+ "clips" => %w[topographic.HydroArea topographic.VSS_Oceans],
+ "ext" => "png",
+ },
"holdings" => {
"server" => sixmaps,
"service" => "LHPA",
"ext" => "svg",
"layers" => %w[Holdings],
"labels" => %w[Holdings],
},
- "relief" => {
- "server" => oneearth_relief,
- "clips" => %w[topographic.HydroArea topographic.VSS_Oceans],
- "ext" => "png",
- },
"declination" => {
"server" => declination_server,
},
@@ -1986,23 +1992,27 @@ def self.run
},
}
- includes = (%w[topographic] + config["include"]).map { |label_or_hash| [ *label_or_hash ].flatten }
- layers.each do |label, options|
- includes.each { |match, resolution| options.merge!("resolution" => resolution) if label[match] && resolution }
- end
- labels = layers.keys.select { |label| includes.any? { |match, _| label[match] } }
+ includes = %w[topographic]
+ includes << "canvas" if File.exists? "canvas.png"
(config["overlays"] || {}).each do |filename_or_path, options|
label = File.split(filename_or_path).last.partition(/\.\w+$/).first
layers.merge! label => (options || {}).merge("server" => OverlayServer.new, "path" => filename_or_path)
- labels << label
+ includes << label
end
if config["controls"]["file"]
layers.merge! "controls" => { "server" => control_server}
- labels << "controls"
+ includes << "controls"
end
+ includes += config["include"]
+ includes.map! { |label_or_hash| [ *label_or_hash ].flatten }
+ layers.each do |label, options|
+ includes.each { |match, resolution| options.merge!("resolution" => resolution) if label[match] && resolution }
+ end
+ labels = layers.keys.select { |label| includes.any? { |match, _| label[match] } }
+
puts "Map details:"
puts " name: #{map.name}"
puts " size: %imm x %imm" % map.extents.map { |extent| 1000 * extent / map.scale }
@@ -2108,7 +2118,6 @@ def self.run
NSWTopo.run
end
-# TODO: reinstate CanvasServer
# TODO: put layer opacities in consistent location, use style="opacity:0.2" for use with inkscape
# TODO: split shaded-relief into sun and shade layers for individual adjustment

0 comments on commit 0a28754

Please sign in to comment.