From: Dan Karran Date: Mon, 11 Jun 2007 21:19:25 +0000 (+0000) Subject: #499: Making GeoRSS class more reusable and stopping geotags being added if there... X-Git-Tag: live~8392 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/eada120ffac9f6b6ecb3db1fe1c4397cb6c0bd44?hp=5ef2e8f6616a6e6e931cfe760cffd2228a78ed20;ds=sidebyside #499: Making GeoRSS class more reusable and stopping geotags being added if there is no geodata to be represented. The only reference I can find to code using this class currently is the GPX GeoRSS generator which doesn't specify any parameters, so it shouldn't matter that I have added a title parameter before the description parameter. --- diff --git a/lib/osm.rb b/lib/osm.rb index 33a6f2c57..57714c68e 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -241,7 +241,7 @@ module OSM end class GeoRSS - def initialize(description='OpenStreetMap GPS Traces') + def initialize(feed_title='OpenStreetMap GPS Traces', feed_description='OpenStreetMap GPS Traces', feed_url='http://www.openstreetmap.org/traces/') @doc = XML::Document.new @doc.encoding = 'UTF-8' @@ -252,14 +252,14 @@ module OSM @channel = XML::Node.new 'channel' rss << @channel title = XML::Node.new 'title' - title << 'OpenStreetMap GPS Traces' + title << feed_title @channel << title description_el = XML::Node.new 'description' @channel << description_el - description_el << description + description_el << feed_description link = XML::Node.new 'link' - link << 'http://www.openstreetmap.org/traces/' + link << feed_url @channel << link image = XML::Node.new 'image' @channel << image @@ -276,7 +276,7 @@ module OSM height << '100' image << height link = XML::Node.new 'link' - link << 'http://www.openstreetmap.org/traces/' + link << feed_url image << link end @@ -298,13 +298,17 @@ module OSM pubDate << timestamp.xmlschema item << pubDate - lat_el = XML::Node.new 'geo:lat' - lat_el << latitude.to_s - item << lat_el + if latitude + lat_el = XML::Node.new 'geo:lat' + lat_el << latitude.to_s + item << lat_el if lat_el + end - lon_el = XML::Node.new 'geo:long' - lon_el << longitude.to_s - item << lon_el + if longitude + lon_el = XML::Node.new 'geo:long' + lon_el << longitude.to_s + item << lon_el + end @channel << item end