Class Node

All Implemented Interfaces:
Serializable, Comparable<Node>

public class Node extends GenericTaggedNode<Node> implements Comparable<Node>, Serializable
This class represents a Node element of an OSM file.
Author:
Andrew Pavlin, KA2DDO
See Also:
  • Field Details

    • id

      public long id
      OpenStreetMap assigned ID number for this Node.
    • latitude

      public int latitude
      Latitude in millionths of degrees North.
    • longitude

      public int longitude
      Longitude in millionths of degrees East.
  • Constructor Details

    • Node

      public Node()
  • Method Details

    • write

      public void write(DataOutput os) throws IOException
      Writes the Node to the specified DataOutput implementing file access object in the YAAC compressed binary map data format.
      Parameters:
      os - DataOutput object to write to
      Throws:
      IOException - if write failed for any reason
    • writeId

      protected void writeId(DataOutput dos) throws IOException
      Append the ID number of this Node to the written binary save stream.
      Specified by:
      writeId in class GenericTaggedNode<Node>
      Parameters:
      dos - DataOutput to use to append the binary ID value
      Throws:
      IOException - if ID write fails
    • getId

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

      public static Node read(DataInput is) throws IOException
      Read the next Node from the input stream.
      Parameters:
      is - DataInput to read the Node from
      Returns:
      newly created Node object read from the stream
      Throws:
      IOException - if read fails
    • reread

      public void reread(DataInput is) throws IOException
      Replace the contents of this Node object with the next Node in the input stream.
      Parameters:
      is - DataInput to read the next Node from
      Throws:
      IOException - if read fails
    • reread

      public void reread(NonshareableBufferedDataInputStream is) throws IOException
      Replace the contents of this Node object with the next Node in the input stream.
      Parameters:
      is - DataInput to read the next Node from
      Throws:
      IOException - if read fails
    • intersects

      public boolean intersects(int lLat, int hLat, int lLon, int hLon)
      Test if this Node intersects the specified axis-aligned bounding box.
      Parameters:
      lLat - minimum latitude in millionths of degrees North
      hLat - maximum latitude in millionths of degrees North
      lLon - minimum longitude in millionths of degrees East
      hLon - maximum longitude in millionths of degrees East
      Returns:
      boolean true if this Node is contained entirely inside the bounding box
    • toString

      public String toString()
      Generate a String describing this Node.
      Overrides:
      toString in class Object
      Returns:
      descriptive String
    • compareTo

      public int compareTo(Node o2)
      Compares this Node with the specified Node for order.
      Specified by:
      compareTo in interface Comparable<Node>
      Parameters:
      o2 - the Node to be compared.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      Throws:
      NullPointerException - if the specified object is null
      ClassCastException - if the specified object's type prevents it from being compared to this object.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
      See Also:
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
      See Also:
    • dup

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

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

      public static void main(String[] args) throws IOException
      For unit testing of Node class only.
      Parameters:
      args - String array of parameters. [0] is path of node file to read, [1] is optional -quiet flag to suppress most printed output
      Throws:
      IOException - if node file cannot be read for any reason