org.openstreetmap.osmosis.core.domain.v0_5
Class Bound

java.lang.Object
  extended by org.openstreetmap.osmosis.core.domain.v0_5.Entity
      extended by org.openstreetmap.osmosis.core.domain.v0_5.Bound
All Implemented Interfaces:
java.lang.Comparable<Bound>, Storeable

public class Bound
extends Entity
implements java.lang.Comparable<Bound>

A data class representing an OSM data bound element.

Author:
Karl Newman

Constructor Summary
Bound(double right, double left, double top, double bottom, java.lang.String origin)
          Creates a new instance with the specified boundaries.
Bound(StoreReader sr, StoreClassRegister scr)
          Creates a new instance.
Bound(java.lang.String origin)
          Creates a new instance which covers the entire planet.
 
Method Summary
 int compareTo(Bound comparisonBound)
          Compares this bound to the specified bound.
 boolean equals(java.lang.Object o)
          
 double getBottom()
           
 double getLeft()
           
 java.lang.String getOrigin()
           
 double getRight()
           
 double getTop()
           
 EntityType getType()
          Returns the specific data type represented by this entity.
 int hashCode()
          
 Bound intersect(Bound intersectingBound)
          Calculate the intersected area of this with the specified bound.
 void store(StoreWriter sw, StoreClassRegister scr)
          Stores all state to the specified store writer.
 java.lang.Iterable<Bound> toSimpleBound()
          Retrieve a collection of Bound objects which collectively comprise the entirety of this Bound but individually do not cross the antimeridian and thus can be used in simple area operations.
 Bound union(Bound unionBound)
          Calculate the union area of this with the specified bound.
 
Methods inherited from class org.openstreetmap.osmosis.core.domain.v0_5.Entity
addTag, addTags, compareTags, getFormattedTimestamp, getId, getTagList, getTimestamp, getUser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bound

public Bound(java.lang.String origin)
Creates a new instance which covers the entire planet.

Parameters:
origin - The origin (source) of the data, typically a URI

Bound

public Bound(double right,
             double left,
             double top,
             double bottom,
             java.lang.String origin)
Creates a new instance with the specified boundaries.

Parameters:
right - The longitude coordinate of the right (East) edge of the bound
left - The longitude coordinate of the left (West) edge of the bound
top - The latitude coordinate of the top (North) edge of the bound
bottom - The latitude coordinate of the bottom (South) edge of the bound
origin - The origin (source) of the data, typically a URI

Bound

public Bound(StoreReader sr,
             StoreClassRegister scr)
Creates a new instance.

Parameters:
sr - The store to read state from.
scr - Maintains the mapping between classes and their identifiers within the store.
Method Detail

store

public void store(StoreWriter sw,
                  StoreClassRegister scr)
Stores all state to the specified store writer.

Specified by:
store in interface Storeable
Overrides:
store in class Entity
Parameters:
sw - The writer that persists data to an underlying store.
scr - Maintains the mapping between classes and their identifiers within the store.

getType

public EntityType getType()
Returns the specific data type represented by this entity.

Specified by:
getType in class Entity
Returns:
The entity type enum value.

getRight

public double getRight()
Returns:
The right (East) bound longitude

getLeft

public double getLeft()
Returns:
The left (West) bound longitude

getTop

public double getTop()
Returns:
The top (North) bound latitude

getBottom

public double getBottom()
Returns:
The bottom (South) bound latitude

getOrigin

public java.lang.String getOrigin()
Returns:
the origin

intersect

public Bound intersect(Bound intersectingBound)
Calculate the intersected area of this with the specified bound.

Parameters:
intersectingBound - Bound element with which to calculate the intersection
Returns:
Bound Resultant intersection of the two bound object

union

public Bound union(Bound unionBound)
Calculate the union area of this with the specified bound. Not a strict mathematical union, but the smallest rectangular area which includes both bound. Thus, result may include areas not contained in the original bound.

Parameters:
unionBound - Bound element with which to calculate the union
Returns:
Bound Resultant union of the two bound objects

toSimpleBound

public java.lang.Iterable<Bound> toSimpleBound()
Retrieve a collection of Bound objects which collectively comprise the entirety of this Bound but individually do not cross the antimeridian and thus can be used in simple area operations. The degenerate case will return this Bound.

Returns:
Iterable collection of Bound elements

compareTo

public int compareTo(Bound comparisonBound)
Compares this bound to the specified bound. The bound comparison is based on a comparison of area, latitude, and longitude in that order.

Specified by:
compareTo in interface java.lang.Comparable<Bound>
Parameters:
comparisonBound - The bound to compare to.
Returns:
0 if equal, < 0 if this sorts before comparison (this is "smaller"), and > 0 if this sorts before comparison (this is "bigger")

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object