forked from nofxx/ym4r
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of tests for the Mapping Object of GoogleMaps.
Addition of a tiler, which gets data form WMS servers and tiles it accoriding to the Google Maps scheme. Addition of some code to support the easy manipulation of pre-tiledlayers (tiled with the tiler above) as well as layers directly from WMS servers.
- Loading branch information
gvellut
committed
Jun 8, 2006
1 parent
05933d7
commit a81b7fe
Showing
6 changed files
with
321 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
module Ym4r | ||
module GoogleMaps | ||
#Map types of the map | ||
class GMapType | ||
include MappingObject | ||
|
||
G_NORMAL_MAP = Variable.new("GMapType.G_NORMAL_MAP") | ||
G_SATELLITE_MAP = Variable.new("GMapType.G_SATELLITE_MAP") | ||
G_HYBRID_MAP = Variable.new("GMapType.G_HYBRID_MAP") | ||
|
||
attr_accessor :layers, :name, :projection | ||
|
||
def initialize(layers, name, projection = GMercatorProjection.new,options = {}) | ||
@layers = layers | ||
end | ||
|
||
def create | ||
"new GMapType(#{javascriptify_variable(Array(layers))}, #{javascriptify_variable(projection)}, #{javascriptify_variable(name)}, #{javascriptify_variable(options)})" | ||
end | ||
end | ||
|
||
class GMercatorProjection | ||
include MappingObject | ||
|
||
attr_accessor :n | ||
|
||
def initialize(n = nil) | ||
@n = n | ||
end | ||
|
||
def create | ||
if n.nil? | ||
return "G_NORMAL_MAP.getProjection()" | ||
else | ||
"new GMercatorProjection(#{@n})" | ||
end | ||
end | ||
end | ||
|
||
class GTileLayer | ||
include MappingObject | ||
|
||
attr_accessor :opacity, :zoom_inter, :copyright | ||
|
||
def initialize(zoom_inter = 0..17, copyright= ['prefix' => '', 'copyright_texts' => [""]], opacity = 1.0) | ||
@opacity = opacity | ||
@zoom_inter = zoom_inter | ||
@copyright = copyright | ||
end | ||
|
||
def create | ||
"addPropertiesToLayer(new GTileLayer(new GCopyrightCollection(\"\"),#{zoom_inter.begin},#{zoom_inter.end}),#{get_tile_url}, function(a,b) {return #{MappingObject.javascriptify_variable(@copyright)};}, function() {return #{@opacity};})" | ||
end | ||
|
||
#for subclasses to implement | ||
def get_tile_url | ||
end | ||
end | ||
|
||
class PreTiledLayer < GTileLayer | ||
include MappingObject | ||
|
||
attr_accessor :base_url, :format | ||
|
||
def initialize(base_url, format = "png", zoom_inter = 0..17, copyright = ['prefix' => '', 'copyright_texts' => [""]], opacity = 1.0) | ||
super(zoom_inter, copyright, opacity) | ||
@base_url = base_url | ||
@format = format | ||
end | ||
|
||
#returns the code to determine the url to fetch the tile. Follows the convention adopted by the tiler: {base_url}/tile_{b}_{a.x}_{a.y}.{format} | ||
def get_tile_url | ||
"function(a,b,c) { return '#{@base_url}/tile_' + b + '_' + a.x + '_' + a.y + '.#{@format}';}" | ||
end | ||
end | ||
|
||
#needs to modify the wms-gs.js script for this to work : check with the people who wrote it if it is ok | ||
#needs to include the JavaScript file wms-gs.js for this to work | ||
#see http://docs.codehaus.org/display/GEOSDOC/Google+Maps | ||
class WMSLayer < GTileLayer | ||
include MappingObject | ||
|
||
attr_accessor :base_url, :layers, :styles, :format | ||
|
||
def initialize(base_url, layers, styles = "", format= "png", zoom_inter = 0..17, copyright = ['prefix' => '', 'copyright_texts' => [""]], opacity = 1.0) | ||
super(zoom_inter, copyright, opacity) | ||
@base_url = base_url | ||
@layers = layers | ||
@styles = styles | ||
@format = format | ||
end | ||
|
||
def get_tile_url | ||
"CustomGetTileUrl" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.