Ruby-TileCache
by Pascal Ehlert, ODAdata http://ruby-tilecache.rubyforge.org
ruby-tilecache is an implementation of TileCache from MetaCarta, written in pure Ruby. It allows you to cache image tiles either rendered by MapScript or taken from another source. Additionally, it supports meta-tiling which nearly eliminates label duplication issues because of the tiling.
-
See description.
require 'tile_cache' class MapController < ApplicationController # This action handles WMS GetMap requests def wms wms = TileCache::Services::WMS.new(params) map = wms.get_map render :text => map.data, :content_type => map.layer.format end end
-
RMagick for meta-tiling support
-
Ruby-MapScript for Mapserver layers
-
sudo gem install ruby-mapscript
If you are in a Rails environment, ruby-tilecache looks for a configuration file in config/tilecache.yml, otherwise it searches ~/.tilecache.yml and /etc/tilecache.yml.
As the name suggests, the file format should be YAML, here is an example configuration:
cache: type: DiskCache root: '../tmp/mapcache' basic: type: MapServer mapfile: app/map/nic.map layers: NIC2,NIC1 maxresolution: 0.01991484375 levels: 5 extension: jpeg metatile: true metabuffer: 0, 0 bbox: -87.6903, 10.7075, -82.5921, 15.0259
In a Rails environment relative paths always refer to RAILS_ROOT, in other environments you should use absolute paths.
Copyright © 2008 Pascal Ehlert, ODAdata
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.