org.ka2ddo.yaac.osm
Class Node

java.lang.Object
  extended by org.ka2ddo.yaac.osm.GenericTaggedNode<Node>
      extended by org.ka2ddo.yaac.osm.Node
All Implemented Interfaces:
java.lang.Comparable<Node>

public class Node
extends GenericTaggedNode<Node>
implements java.lang.Comparable<Node>

This class represents a Node element of an OSM file.


Field Summary
 long id
          OpenStreetMap assigned ID number for this Node.
 int latitude
          Latitude in millionths of degrees North.
 int longitude
          Longitude in millionths of degrees East.
 
Fields inherited from class org.ka2ddo.yaac.osm.GenericTaggedNode
decodedtagArray, FIXME, flags, HAS_ID, HAS_ID64, HAS_INTERNET_ACCESS, HAS_TOLL, IS_AREA, IS_BRIDGE, IS_BUILDING, IS_DISUSED, IS_INFERRED_AREA, IS_ISLAND, IS_LIT, IS_ONEWAY, IS_ONEWAY_BACKWARDS, IS_TUNNEL, IS_WATER, RENDERABLE_FLAGS
 
Constructor Summary
Node()
           
 
Method Summary
 int compareTo(Node o2)
          Compares this Node with the specified Node for order.
 Node dup()
          Create a deep copy of this Node.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 int hashCode()
          Returns a hash code value for the object.
 boolean intersects(int lLat, int hLat, int lLon, int hLon)
          Test if this Node intersects the specified axis-aligned bounding box.
static void main(java.lang.String[] args)
          For unit testing of Node class only.
static Node read(java.io.DataInput is)
          Read the next Node from the input stream.
 void reread(java.io.DataInput is)
          Replace the contents of this Node object with the next Node in the input stream.
 java.lang.String toString()
          Generate a String describing this Node.
 void write(java.io.DataOutput os)
          Writes the Node to the specified DataOutput implementing file access object in the YAAC compressed binary map data format.
 void writeGPX(java.io.PrintStream ps)
          Write this Node to the specified stream as the XML tags one element in GPX schema format.
protected  void writeId(java.io.DataOutput dos)
          Append the ID number of this Node to the written binary save stream.
 
Methods inherited from class org.ka2ddo.yaac.osm.GenericTaggedNode
decodedTagArrayToString, ensureElementHasTagArray, getDecodedTagCount, hasDecodedTags, putTag, readTags, writeTags
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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 Detail

Node

public Node()
Method Detail

write

public void write(java.io.DataOutput os)
           throws java.io.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:
java.io.IOException - if write failed for any reason

writeId

protected void writeId(java.io.DataOutput dos)
                throws java.io.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:
java.io.IOException - if ID write fails

read

public static Node read(java.io.DataInput is)
                 throws java.io.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:
java.io.IOException - if read fails

reread

public void reread(java.io.DataInput is)
            throws java.io.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:
java.io.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 java.lang.String toString()
Generate a String describing this Node.

Overrides:
toString in class java.lang.Object
Returns:
descriptive String

compareTo

public int compareTo(Node o2)
Compares this Node with the specified Node for order.

Specified by:
compareTo in interface java.lang.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:
java.lang.NullPointerException - if the specified object is null
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this object.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.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()

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
See Also:
equals(Object)

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(java.io.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(java.lang.String[] args)
                 throws java.io.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:
java.io.IOException - if node file cannot be read for any reason