Osmarender/Frollo

From OpenStreetMap Wiki
Jump to navigation Jump to search

broom

This article or section may contain out-of-date information. The information may no longer be correct, or may no longer have relevance.
If you know about the current state of affairs, please help keep everyone informed by updating this information. (Discussion)

Frollo is no longer needed for OSM v0.5

Frollo is a pre-processor for Osmarender that sorts segments within ways. While it has been specifically designed to help Osmarender, it is usable as a standalone processor for any application that can benefit from better sorted segments in ways.

Frollo does three things:

  1. It sorts segments into a linear sequence. It prefers from-to connectedness over the given sort order of <seg> elements within ways.
  2. All segments that are pointing in the wrong direction are annotated with osma:reverse='1' to indicate that they should be processed the other way round. Note: it is the <seg> element of the way that is annotated because a <segment> might be used by more than one way, and may be correct in one and reversed in the other.
  3. Non-contiguous segments within a way are annotated with osma:sub-path='1'. This indicates discontinuities and logically breaks a way into a series of sub-ways or sub-paths. The first <seg> of each way is always flagged as the start of a sub-path.

Download

Frollo comprises two xsl templates that need to be run one after the other.

Get them from here: http://svn.openstreetmap.org/applications/rendering/osmarender4/frollo/

An xsl processor (xmlstarlet, xalan, etc) is required to be able to run the templates.

Usage

$ xmlstarlet tr frollo1.xsl data.osm /tmp/temp.osm
$ xmlstarlet tr frollo2.xsl /tmp/temp.osm data.osm

Output

In addition to sorting the <seg> elements within each way, Frollo adds the following attributes to the file:

  • <osm xmlns:osma="http://wiki.openstreetmap.org/index.php/Osmarender/Frollo/1.0"> This is the uri for the osma namespace.
  • <osm osma:frollo='1'> This attribute just indicates that the file has been frolloised.
  • <seg osma:reverse='1'> This attribute indicates that the segment is pointing the wrong way. The segment should be processed as if it were the the other way around.
  • <seg osma:sub-path='1'> This attribute indicates that the segment is the start of a new sub-path. Typically there are not other segments connecting to it. However, there is one exception to this rule. When a set of segments form a loop, one segment in the loop will be flagged as the start of a sub-path.
  • <seg osma:fromCount='n'> A count of the number of segments in this way that connect to the from end of this segment.
  • <seg osma:toCount='n'> A count of the number of segments in this way that connect to the to end of this segment.

Limitations

  • Xalan-j experiences a stack-overflow if it tries to process ways that contain more than about 100 segments. Other xsl processors seem better able to cope with long ways. Xmlstarlet is a decent alternative to Xalan if you encounter this problem. If you have no choice then you can edit frollo2.xsl and make the following change which will cause Frollo to only sort the first 100 segments in the way, the remainder being left unsorted.
    • from: <xsl:variable name='maximumNumberOfSegs' select='"800"'/>
    • to: <xsl:variable name='maximumNumberOfSegs' select='"100"'/>