Class Relation


public class Relation extends GenericTaggedNode<Relation>
This class represents a Relation element of an OSM file.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

    • id

      public int id
      OpenStreetMap database ID key for this Relation.
  • Constructor Details

    • Relation

      public Relation()
  • Method Details

    • writeId

      protected void writeId(DataOutput dos) throws IOException
      Handle writing the ID field to the binary data stream (handles larger ID ranges in varying subclasses).
      Specified by:
      writeId in class GenericTaggedNode<Relation>
      Parameters:
      dos - DataOutput to use to append the binary ID value
      Throws:
      IOException - if write fails for any reason
    • getId

      public Number getId()
      Return the ID of this OSM record as a sub-class of Number.
      Specified by:
      getId in class GenericTaggedNode<Relation>
      Returns:
      Number subclass instance
    • write

      public void write(DataOutput dos) throws IOException
      Write this Relation to the specified stream in a compact binary format.
      Parameters:
      dos - DataOutput to write to
      Throws:
      IOException - if write failed for any reason
    • read

      public static Relation read(DataInput is) throws IOException
      Read a new Relation object from the specified input stream.
      Parameters:
      is - DataInput to read the Relation from
      Returns:
      new Relation object with all sub-elements
      Throws:
      IOException - if read failed for any reason
    • toString

      public String toString()
      Returns a string representation of the Relation object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
    • dup

      public Relation dup()
      Create a deep copy of this Relation. Similar to the Object method clone(), but without the exceptions and casting.
      Specified by:
      dup in class GenericTaggedNode<Relation>
      Returns:
      copy of this Relation
    • writeGPX

      public void writeGPX(PrintStream ps)
      Write this Relation to the specified stream as the XML tags one element in GPX schema format.
      Specified by:
      writeGPX in class GenericTaggedNode<Relation>
      Parameters:
      ps - PrintStream to write to
    • main

      public static void main(String[] args) throws IOException
      for unit testing only of Relation class.
      Parameters:
      args - String array of command-line parameters, [0]: Relation file to read, [1]: numeric Relation ID to check for (-1 means all), [2]: optional "-short" to reduce printed debug output
      Throws:
      IOException - if file can't be read for some reason
    • isOnlyWays

      public boolean isOnlyWays()
      Test if this Relation contains only Ways.
      Returns:
      boolean true if all members are Ways (except for label Nodes), false otherwise