ym4r 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,5 +1,5 @@
1
1
  =YM4R
2
- This is YM4R 0.5.1. YM4R has features to ease the use of the Google Maps Geocoding API and the Yahoo! Maps building block API's from Ruby. It also offers 2 tools to create tiles to be used with user-defined layers in Google Maps. If you are looking to use the main Google Maps API from your Rails application, you should use the YM4R/GM plugin for Rails (http://thepochisuperstarmegashow.com/projects/#ym4r).
2
+ This is YM4R 0.5.2. YM4R has features to ease the use of the Google Maps Geocoding API and the Yahoo! Maps building block API's from Ruby. It also offers 2 tools to create tiles to be used with user-defined layers in Google Maps. If you are looking to use the main Google Maps API from your Rails application, you should use the YM4R/GM plugin for Rails (http://thepochisuperstarmegashow.com/projects/#ym4r).
3
3
 
4
4
  ==Relation between the YM4R gem and the YM4R/GM plugin for Rails
5
5
  They are completely independent from each other.
@@ -88,36 +88,10 @@ Here is an example of request:
88
88
  :query => "chinese")
89
89
  +results+ is a LocalSearch::ResultSet object (subclass of +Array+), containing LocalSearch::Result objects, each containing information about one hit on the Yahoo! local search.
90
90
 
91
- ===Tiling: Generating tiles to be used with pretiled layers in Google Maps
92
-
93
- The YM4R library provides 2 tools to generate tiles. They are in the +tools+ directory of the YM4R gem distribution.
94
-
95
- ====tile_wms.rb
96
- This is to generate tiles from an already existing WMS server. It can be useful if you don't want to setup a permanent WMS server but still want to display your geographic data files (any format compatible with your WMS server can then be used). It can also be used to cache data from public servers, which can sometimes be very slow to answer requests. Run <tt>ruby tile_wms.rb -h</tt> to know what the options are. Most are self-explanatory, although the <tt>-g</tt> (<tt>--gmap-setting</tt>) needs to be explained in more details. It uses the data that comes from this tool: http://www.onnyturf.com/google/latlontotile.html. Basically you need to center the map at the zoom you need to get your desired extent. When you are satisfied, the tool will give you the following data: the X and Y values of the upper left corner tile, 17 minus the zoom level (this is because the V2 of the Google Maps API reversed the zoom order), the number of horizontal and vertical tiles that you want. You will then pass to the <tt>-g</tt> option 5 integers in the order previously described, for example:
97
- -g 300,383,7,3,2
98
- About the zoom level, if the tools tells you 7, you should pass 10 (17 - 7) to the <tt>-g</tt> option.
99
-
100
- Note that the zoom levels passed to the <tt>-z</tt> argument must be greater or equal to the zoom level passed to the <tt>-g</tt> argument.
101
-
102
- ====tile_image.rb
103
- This is to generate tiles from a local image. You will need the RMagick library for it to work. Basically, you should use this tool: http://open.atlas.free.fr/GMapsTransparenciesImgOver.php. You should have an image that will be displayed at the lowest zoom level that you want and use it with this tool. You can translate and scale the image until you are statisfied. When you are, you must click a link to gather information about the transformation needed for your image. You will need to pass this data to the <tt>-p</tt> option of the tool in the following order: X and Y of the top left corner of the map, 17 minus the zoom level, X and Y padding, scale. So for example, you will have the following argument:
104
- -p 2503,3667,4,241,115,0.8702928870292888
105
- Again, about the zoom level, if the tool tells you 7, you should pass 10 (17 - 7) to the <tt>-p</tt> option.
106
-
107
- About the padding, I had a slight problem on Firefox: I needed to substract 10 to the X and Y paddings given by the online tool to have the correct one to pass to the <tt>-p</tt> option. Maybe it has something to do with the 10-pixel bands at the top and left of the page.
108
-
109
- You should pass as many images to the tool as you have zoom levels in the <tt>-z</tt> argument: Each image will be used for one zoom level. The string order of the names of the image files must match the order of their corresponding zoom level. Moreover, each image should be exactly twice bigger (in both width and height) than the one in the zoom level immediately preceding it. Also note that the zoom levels passed to the <tt>-z</tt> argument must be greater or equal to the zoom level passed to the <tt>-p</tt> argument.
110
-
111
- By default, the tool will generate transparent borders. You can pass 4 integers (R, G, B and A) from 0 to 255 to the -b option to change that:
112
- -b 255,123,456,42
113
-
114
- Here is an example of command line execution using the image at http://open.atlas.free.fr/GMapsTransparenciesImgOver.php. If you place it over the satellite images, you would get the following parameters: 2503,3667,13,149,76,1.0 (I have accounted for both the reversing of the zoom for v2 and the 10-pixel drift of the padding in Firefox). I have also created another version of the image, at double the size in width and height. Normally you should do the opposite: Get the highest resolution possible (if you scan the map) and downsize it for all the desired zoom levels until you get the image to use in this online tool (lowest zoom level). If you use vector graphics, you can easily create versions at different resolutions. I placed the 2 images (called MAP_zoom1.jpg for the smallest and MAP_zoom2.jpg for the biggest) in directory <tt>./input</tt>. And I launch the tool like this:
115
- ruby tile_image.rb -o ./tiles -z 13..14 -p 2503,3667,13,149,76,1.0 ./input/*
116
- This will create tiles of the image for zoom levels 13 and 14. It should take just a few seconds.
117
91
 
118
92
  ==Changes since last version
119
- - Repackaging of the Google Maps web app related functionnalities to a separate plugin
120
- - Suppression of support for the JS Flash API, since it was limited anyway and has not been updated in a while.
93
+ - Removed the tilers. They are now in a separately downloadable package.
94
+ - Changed the Yahoo App Id
121
95
 
122
96
  ==TODO
123
97
  - Add more tests
@@ -1,5 +1,5 @@
1
1
  module Ym4r
2
2
  module YahooMaps
3
- APP_ID = "YahooMaps4Ruby"
3
+ APP_ID = "YellowMaps4R"
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ spec = Gem::Specification::new do |s|
24
24
  s.platform = Gem::Platform::RUBY
25
25
 
26
26
  s.name = 'ym4r'
27
- s.version = "0.5.1"
27
+ s.version = "0.5.2"
28
28
  s.summary = "Helping the use of Google Maps and Yahoo! Maps API's from Ruby and Rails"
29
29
  s.description = <<EOF
30
30
  EOF
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ym4r
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.1
7
- date: 2006-07-09 00:00:00 +05:00
6
+ version: 0.5.2
7
+ date: 2006-07-22 00:00:00 +05:00
8
8
  summary: Helping the use of Google Maps and Yahoo! Maps API's from Ruby and Rails
9
9
  require_paths:
10
10
  - lib
@@ -34,8 +34,6 @@ files:
34
34
  - lib/ym4r/yahoo_maps.rb
35
35
  - lib/ym4r/google_maps/api_key.rb
36
36
  - lib/ym4r/google_maps/geocoding.rb
37
- - lib/ym4r/google_maps/image_tiler.rb
38
- - lib/ym4r/google_maps/wms_tiler.rb
39
37
  - lib/ym4r/yahoo_maps/app_id.rb
40
38
  - lib/ym4r/yahoo_maps/building_block.rb
41
39
  - lib/ym4r/yahoo_maps/building_block/exception.rb
@@ -44,8 +42,6 @@ files:
44
42
  - lib/ym4r/yahoo_maps/building_block/map_image.rb
45
43
  - lib/ym4r/yahoo_maps/building_block/traffic.rb
46
44
  - lib/ym4r/google_maps/config/config.yml
47
- - tools/tile_image.rb
48
- - tools/tile_wms.rb
49
45
  - test/test_geocoding.rb
50
46
  - test/test_gm_geocoding.rb
51
47
  - test/test_local_search.rb
@@ -1,107 +0,0 @@
1
- require 'RMagick'
2
-
3
- module Ym4r
4
- module GoogleMaps
5
- module Tiler
6
- module ImageTiler
7
- class Point < Struct.new(:x,:y)
8
- def -(point)
9
- Point.new(x - point.x , y - point.y)
10
- end
11
- def +(point)
12
- Point.new(x + point.x , y + point.y)
13
- end
14
- def *(scale)
15
- Point.new(scale * x,scale * y)
16
- end
17
- def to_s
18
- "Point #{x} #{y}"
19
- end
20
- end
21
-
22
- class TileParam < Struct.new(:ul_corner,:zoom,:padding,:scale)
23
- end
24
-
25
- TILE_SIZE = 256
26
-
27
- def self.get_tiles(output_dir, input_files, tile_param, zooms, bg_color = Magick::Pixel.new(255,255,255,0), format = "png")
28
- #order the input files: string order.
29
- sorted_input_files = input_files.sort
30
-
31
- #Whatever the zoom level, the tiles must cover the same surface : we get the surface of the furthest zoom.
32
- furthest_dimension_tiles = get_dimension_tiles(sorted_input_files[0],tile_param)
33
- puts furthest_dimension_tiles.to_s
34
-
35
- zooms.each do |zoom|
36
- next if zoom < tile_param.zoom
37
- return if (input_file = sorted_input_files.shift).nil?
38
-
39
- image = Magick::ImageList::new(input_file)
40
- image.scale!(tile_param.scale)
41
- image_size = Point.new(image.columns , image.rows)
42
-
43
- factor = 2 ** (zoom - tile_param.zoom)
44
-
45
- #index of the upper left corner for the current zoom
46
- start = tile_param.ul_corner * factor
47
- dimension_tiles = furthest_dimension_tiles * factor
48
- dimension_tiles_pixel = dimension_tiles * TILE_SIZE
49
- padding = tile_param.padding * factor
50
-
51
- puts "Padding" + padding.to_s
52
- puts "Size " + image_size.to_s
53
- puts "Dimension " + dimension_tiles_pixel.to_s
54
-
55
- #create an image at dimension_tiles_pixel ; copy the current image there (a bit inefficient memory wise even if it simplifies )
56
- image_with_padding = Magick::Image.new(dimension_tiles_pixel.x, dimension_tiles_pixel.y) do
57
- self.background_color = bg_color
58
- end
59
-
60
- image_with_padding.import_pixels(padding.x,padding.y,image_size.x,image_size.y,"RGBA",image.export_pixels(0,0,image_size.x,image_size.y,"RGBA"))
61
-
62
- image_with_padding.write(output_dir + "/tile_glob_#{zoom}.png")
63
-
64
- total_tiles = dimension_tiles.x * dimension_tiles.y
65
-
66
- counter = Point.new(0,0)
67
-
68
- cur_tile = Point.new(start.x,start.y)
69
-
70
- 1.upto(total_tiles) do |tile|
71
- #progress column by column
72
- if counter.y == dimension_tiles.y
73
- counter.x += 1
74
- counter.y = 0
75
- cur_tile.x += 1
76
- cur_tile.y = start.y
77
- end
78
-
79
- pt_nw = counter * TILE_SIZE
80
-
81
- tile_image = Magick::Image.new(TILE_SIZE,TILE_SIZE)
82
- tile_image.import_pixels(0,0,TILE_SIZE,TILE_SIZE,"RGBA",image_with_padding.export_pixels(pt_nw.x,pt_nw.y,TILE_SIZE,TILE_SIZE,"RGBA"))
83
- tile_image.write("#{output_dir}/tile_#{zoom}_#{cur_tile.x}_#{cur_tile.y}.#{format}")
84
-
85
- counter.y += 1
86
- cur_tile.y += 1
87
-
88
- end
89
- end
90
- end
91
-
92
-
93
- def self.get_dimension_tiles(file,tile_param)
94
- #Get the size of the first input_file
95
- image = Magick::ImageList::new(file)
96
- image.scale!(tile_param.scale)
97
- image_size = Point.new(image.columns , image.rows)
98
- puts "ISize " + image_size.to_s
99
- ending = tile_param.padding + image_size
100
- puts "Ending " + ending.to_s
101
- Point.new((ending.x / TILE_SIZE.to_f).ceil,(ending.y / TILE_SIZE.to_f).ceil)
102
- end
103
-
104
- end
105
- end
106
- end
107
- end
@@ -1,157 +0,0 @@
1
- require 'open-uri'
2
-
3
- module Ym4r
4
- module GoogleMaps
5
- module Tiler
6
- module WmsTiler
7
- #Contains LatLon coordinates
8
- class LatLng < Struct.new(:lat,:lng)
9
- end
10
-
11
- #Contain projected coordinates (in pixel or meter)
12
- class Point < Struct.new(:x,:y)
13
- end
14
-
15
- #Structure that contains configuration data for the WMS tiler
16
- class FurthestZoom < Struct.new(:ul_corner, :zoom, :tile_size)
17
- end
18
-
19
- #The size of a Google Maps tile. There are square so only one size.
20
- TILE_SIZE = 256
21
-
22
- #Defines a Simple Mercator projection for one level of Google Maps zoom.
23
- class MercatorProjection
24
- DEG_2_RAD = Math::PI / 180
25
- WGS84_SEMI_MAJOR_AXIS = 6378137.0
26
- WGS84_ECCENTRICITY = 0.0818191913108718138
27
-
28
- attr_reader :zoom, :size, :pixel_per_degree, :pixel_per_radian, :origin
29
-
30
- def initialize(zoom)
31
- @zoom = zoom
32
- @size = TILE_SIZE * (2 ** zoom)
33
- @pixel_per_degree = @size / 360.0
34
- @pixel_per_radian = @size / (2 * Math::PI)
35
- @origin = Point.new(@size / 2 , @size / 2)
36
- end
37
-
38
- def borne(number, inf, sup)
39
- if(number < inf)
40
- inf
41
- elsif(number > sup)
42
- sup
43
- else
44
- number
45
- end
46
- end
47
-
48
- #Transforms LatLon coordinate into pixel coordinates in the Google Maps sense
49
- #See http://www.math.ubc.ca/~israel/m103/mercator/mercator.html for details
50
- def latlng_to_pixel(latlng)
51
- answer = Point.new
52
- answer.x = (@origin.x + latlng.lng * @pixel_per_degree).round
53
- sin = borne(Math.sin(latlng.lat * DEG_2_RAD),-0.9999,0.9999)
54
- answer.y = (@origin.y + 0.5 * Math.log((1 + sin) / (1 - sin)) * -@pixel_per_radian).round
55
- answer
56
- end
57
-
58
- #Transforms pixel coordinates in the Google Maps sense to LatLon coordinates
59
- def pixel_to_latlng(point)
60
- answer = LatLng.new
61
- lng = (point.x - @origin.x) / @pixel_per_degree;
62
- answer.lng = lng - (((lng + 180)/360).round * 360)
63
- lat = (2 * Math.atan(Math.exp((point.y - @origin.y) / -@pixel_per_radian))- Math::PI / 2) / DEG_2_RAD
64
- answer.lat = borne(lat,-90,90)
65
- answer
66
- end
67
-
68
- #Projects LatLon coordinates in the WGS84 datum to meter coordinates using the Simple Mercator projection
69
- def self.latlng_to_meters(latlng)
70
- answer = Point.new
71
- answer.x = WGS84_SEMI_MAJOR_AXIS * latlng.lng * DEG_2_RAD
72
- lat_rad = latlng.lat * DEG_2_RAD
73
- answer.y = WGS84_SEMI_MAJOR_AXIS * Math.log(Math.tan((lat_rad + Math::PI / 2) / 2) * ( (1 - WGS84_ECCENTRICITY * Math.sin(lat_rad)) / (1 + WGS84_ECCENTRICITY * Math.sin(lat_rad))) ** (WGS84_ECCENTRICITY/2))
74
- answer
75
- end
76
- end
77
-
78
- #Get tiles from a WMS server
79
- def self.get_tiles(output_dir, url, furthest_zoom, zooms, layers, geographic = false, epsg = 54004, styles = "", format = "png")
80
-
81
- unless geographic
82
- srs_str = epsg
83
- else
84
- srs_str = 4326 #Geographic WGS84
85
- end
86
-
87
- base_url = url << "?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1&LAYERS=#{layers}&STYLES=#{styles}&BGCOLOR=0xFFFFFF&FORMAT=image/#{format}&TRANSPARENT=TRUE&WIDTH=#{TILE_SIZE}&HEIGHT=#{TILE_SIZE}&SRS=EPSG:#{srs_str}&reaspect=false"
88
-
89
- zooms.each do |zoom|
90
- next if zoom < furthest_zoom.zoom
91
-
92
- proj = MercatorProjection.new(zoom)
93
-
94
- #from mapki.com
95
- factor = 2 ** (zoom - furthest_zoom.zoom)
96
-
97
- #index of the upper left corner
98
- x_start = furthest_zoom.ul_corner.x * factor
99
- y_start = furthest_zoom.ul_corner.y * factor
100
-
101
- x_tiles = furthest_zoom.tile_size.x * factor
102
- y_tiles = furthest_zoom.tile_size.y * factor
103
-
104
- total_tiles = x_tiles * y_tiles
105
-
106
- x_counter = 0
107
- y_counter = 0
108
-
109
- x_tile = x_start
110
- y_tile = y_start
111
-
112
- 1.upto(total_tiles) do |tile|
113
- #progress column by column
114
- if y_counter == y_tiles
115
- x_counter += 1
116
- y_counter = 0
117
- x_tile += 1
118
- y_tile = y_start
119
- end
120
-
121
- pt_sw = Point.new( (x_start + x_counter) * TILE_SIZE, (y_start + (y_counter + 1)) * TILE_SIZE) #y grows southbound
122
- pt_ne = Point.new((x_start + (x_counter + 1)) * TILE_SIZE, (y_start + y_counter) * TILE_SIZE)
123
-
124
- ll_sw = proj.pixel_to_latlng(pt_sw)
125
- ll_ne = proj.pixel_to_latlng(pt_ne)
126
-
127
- unless geographic
128
- pt_sw = MercatorProjection.latlng_to_meters(ll_sw)
129
- pt_ne = MercatorProjection.latlng_to_meters(ll_ne)
130
- bbox_str = "#{pt_sw.x},#{pt_sw.y},#{pt_ne.x},#{pt_ne.y}"
131
- else
132
- bbox_str = "#{ll_sw.lon},#{ll_sw.lat},#{ll_ne.lon},#{ll_ne.lat}"
133
- end
134
-
135
- request_url = "#{base_url}&BBOX=#{bbox_str}"
136
-
137
- begin
138
- open("#{output_dir}/tile_#{zoom}_#{x_tile}_#{y_tile}.#{format}","wb") do |f|
139
- f.write open(request_url).read
140
- end
141
- rescue Exception => e
142
- puts e
143
- raise
144
- end
145
-
146
- y_counter += 1
147
- y_tile += 1
148
-
149
- end
150
- end
151
- end
152
- end
153
- end
154
- end
155
- end
156
-
157
-
@@ -1,67 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
-
3
- require 'ym4r/google_maps/image_tiler'
4
- include Ym4r::GoogleMaps::Tiler
5
-
6
- require 'optparse'
7
- require 'ostruct'
8
-
9
- OptionParser.accept(Range, /(\d+)\.\.(\d+)/) do |range,start,finish|
10
- Range.new(start.to_i,finish.to_i)
11
- end
12
-
13
- OptionParser.accept(ImageTiler::TileParam, /(\d+),(\d+),(\d+),(\d+),(\d+),([\d.]+)/) do |setting,l_corner, u_corner, zoom, padding_x, padding_y, scale|
14
- ImageTiler::TileParam.new(ImageTiler::Point.new(l_corner.to_i,u_corner.to_i),zoom.to_i,ImageTiler::Point.new(padding_x.to_i,padding_y.to_i),scale.to_f)
15
- end
16
-
17
- OptionParser.accept(Magick::Pixel,/(\d+),(\d+),(\d+),(\d+)/) do |pixel, r,g,b,a|
18
- Magick::Pixel.new(r.to_f,g.to_f,b.to_f,a.to_f)
19
- end
20
-
21
- options = OpenStruct.new
22
- #set some defaults
23
- options.format = "png"
24
- options.zoom_range = 0..17
25
- options.bg_color = Magick::Pixel.new(255,255,255,255)
26
-
27
- opts = OptionParser.new do |opts|
28
- opts.banner = "Image Tiler for Google Maps\nUsage: tile_image.rb [options]\nExample: tile_image.rb -o ./tiles -z 11..12 -p 602,768,11,78,112,1.91827348 ./input_files/*.jpg"
29
- opts.separator ""
30
- opts.on("-o","--output OUTPUT_DIR","Directory where the tiles will be created") do |dir|
31
- options.output_dir = dir
32
- end
33
- opts.on("-f","--format FORMAT","Image format in which to get the file (gif, jpeg, png...). Is png by default") do |format|
34
- options.format = format
35
- end
36
- opts.on("-z","--zooms ZOOM_RANGE",Range,"Range of zoom values at which the tiles must be generated. Is 0..17 by default") do |range|
37
- options.zoom_range = range
38
- end
39
- opts.on("-p","--tile-param PARAM",ImageTiler::TileParam,"Corner coordinates, furthest zoom level, padding in X and Y, scale") do |tp|
40
- options.tile_param = tp
41
- end
42
- opts.on("-b","--background COLOR",Magick::Pixel,"Background color components. Is fully transparent par default") do |bg|
43
- options.bg_color = bg
44
- end
45
- opts.on_tail("-h", "--help", "Show this message") do
46
- puts opts
47
- exit
48
- end
49
- end
50
-
51
- opts.parse!(ARGV)
52
-
53
- #test the presence of all the options and exit with an error message
54
- error = []
55
- error << "No output directory defined (-o,--output)" if options.output_dir.nil?
56
- error << "No tile parameter defined (-p,--tile-param)" if options.tile_param.nil?
57
- error << "No input files defined" if ARGV.empty?
58
-
59
- unless error.empty?
60
- puts error * "\n" + "\n\n"
61
- puts opts
62
- exit
63
- end
64
-
65
- ImageTiler.get_tiles(options.output_dir,ARGV,options.tile_param,options.zoom_range,options.bg_color,options.format)
66
-
67
-
@@ -1,79 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
-
3
- require 'ym4r/google_maps/wms_tiler'
4
- include Ym4r::GoogleMaps::Tiler
5
-
6
- require 'optparse'
7
- require 'ostruct'
8
-
9
- OptionParser.accept(Range, /(\d+)\.\.(\d+)/) do |range,start,finish|
10
- Range.new(start.to_i,finish.to_i)
11
- end
12
-
13
- OptionParser.accept(WmsTiler::FurthestZoom, /(\d+),(\d+),(\d+),(\d+),(\d+)/) do |setting,l_corner, u_corner, zoom, width, height|
14
- WmsTiler::FurthestZoom.new(WmsTiler::Point.new(l_corner.to_i,u_corner.to_i),zoom.to_i,WmsTiler::Point.new(width.to_i,height.to_i))
15
- end
16
-
17
- options = OpenStruct.new
18
- #set some defaults
19
- options.format = "png"
20
- options.zoom_range = 0..17
21
- options.styles = ""
22
- options.srs = 54004
23
- options.geographic = false
24
-
25
- opts = OptionParser.new do |opts|
26
- opts.banner = "WMS Tiler for Google Maps\nUsage: tile_wms.rb [options]\nExample: tile_wms.rb -o ./tiles -u http://localhost:8080/geoserver/wms -l \"topp:states\" -z 11..12 -g 602,768,11,3,3"
27
- opts.separator ""
28
- opts.on("-o","--output OUTPUT_DIR","Directory where the tiles will be created") do |dir|
29
- options.output_dir = dir
30
- end
31
- opts.on("-u","--url WMS_SERVICE","URL to the WMS server") do |url|
32
- options.url = url
33
- end
34
- opts.on("-l","--layers LAYERS","String of comma-separated layer names") do |layers|
35
- options.layers = layers
36
- end
37
- opts.on("-s","--styles STYLES","String of comma-separated style names. Is empty by default") do |styles|
38
- options.styles = styles
39
- end
40
- opts.on("-f","--format FORMAT","Image format in which to get the file (gif, jpeg, png...). Is png by default") do |format|
41
- options.format = format
42
- end
43
- opts.on("-z","--zooms ZOOM_RANGE",Range,"Range of zoom values at which the tiles must be generated. Is 0..17 by default") do |range|
44
- options.zoom_range = range
45
- end
46
- opts.on("-g","--gmap-setting SETTING",WmsTiler::FurthestZoom,"Corner coordinates, furthest zoom level, tile width and height") do |fz|
47
- options.furthest_zoom = fz
48
- end
49
- opts.on("-w","--[no-]geographic","Query the WMS server with LatLon coordinates instead of using the Mercator projection") do |g|
50
- options.geographic = g
51
- end
52
- opts.on("-e", "--epsg SRS","SRS to query the WMS server. Should be a the SRS id of a Simple Mercator projection. Can vary between WMS servers. Is 54004 (Simple Mercator for Mapserver) by default. For GeoServer use 41001.") do |srs|
53
- options.srs = srs
54
-
55
- end
56
- opts.on_tail("-h", "--help", "Show this message") do
57
- puts opts
58
- exit
59
- end
60
- end
61
-
62
- opts.parse!(ARGV)
63
-
64
- #test the presence of all the options and exit with an error message
65
- error = []
66
- error << "No output directory defined (-o,--output)" if options.output_dir.nil?
67
- error << "No WMS URL defined (-u,--url)" if options.url.nil?
68
- error << "No Google Maps setting defined (-g,--gmap-setting)" if options.furthest_zoom.nil?
69
- error << "No WMS layer defined (-l,--layers)" if options.layers.nil?
70
-
71
- unless error.empty?
72
- puts error * "\n" + "\n\n"
73
- puts opts
74
- exit
75
- end
76
-
77
- WmsTiler.get_tiles(options.output_dir,options.url,options.furthest_zoom,options.zoom_range,options.layers,options.geographic,options.srs,options.styles,options.format)
78
-
79
-