1

I'm having some issues creating a GML-based point reference using ROME. My code will (hopefully!) explain what I'm trying to do better:

public static void geoRSSTest() {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");

    // Set some simple fields
    feed.setTitle("Sample Feed");
    feed.setLink("http://example.com");
    feed.setDescription("This is a sample RSS feed");

    // Create list of entries
    List entries = new ArrayList();
    SyndEntry entry;

    // Create entry
    entry = new SyndEntryImpl();
    entry.setTitle("Sample Entry");
    entry.setPublishedDate(new Date());

    // Add positional information
    GeoRSSModule geoRSSModule = new GMLModuleImpl();
    geoRSSModule.setPosition(new Position(54.2, 12.4));
    entry.getModules().add(geoRSSModule);

    // Add entry to the list
    entries.add(entry);

    // Add entry to the feed
    feed.setEntries(entries);

    // Write to console
    SyndFeedOutput sfo = new SyndFeedOutput();
    try {
        System.out.println(sfo.outputString(feed));
    } catch (FeedException ex) {
        System.err.println(ex);
    }
}

With the above code, I get the following XML printed to the console:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Sample Feed</title>
    <link>http://example.com</link>
    <description>This is a sample RSS feed</description>
    <item>
      <title>Sample Entry</title>
      <pubDate>Tue, 26 May 2015 12:57:50 GMT</pubDate>
      <dc:date>2015-05-26T12:57:50Z</dc:date>
    </item>
  </channel>
</rss>

As you can see, there is no positional information.

However, changing GMLModuleImpl() to SimpleModuleImpl() gives the following:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" version="2.0">
  <channel>
    <title>Sample Feed</title>
    <link>http://example.com</link>
    <description>This is a sample RSS feed</description>
    <item>
      <title>Sample Entry</title>
      <pubDate>Tue, 26 May 2015 12:57:50 GMT</pubDate>
      <dc:date>2015-05-26T12:57:50Z</dc:date>
      <georss:point>54.2 12.4</georss:point>
    </item>
  </channel>
</rss>

As can be seen, there is now a <georss:point> element.

I am using Rome 1.5.0 with Rome Modules 1.5.0 through Netbeans 8.0.2.

Have I missed anything out when attempting to create location information using GMLModuleImpl()?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.