edu.ucsb.adl.middleware
Class Query.SpatialConstraint

java.lang.Object
  |
  +--edu.ucsb.adl.middleware.Query.Constraint
        |
        +--edu.ucsb.adl.middleware.Query.SimpleConstraint
              |
              +--edu.ucsb.adl.middleware.Query.SpatialConstraint
Enclosing class:
Query

public static final class Query.SpatialConstraint
extends Query.SimpleConstraint

A spatial (i.e., geographic) constraint.


Nested Class Summary
static class Query.SpatialConstraint.Vertex
          A polygon vertex.
 
Field Summary
static int BOX
          Identifies the box type of target region.
static int POLYGON
          Identifies the spherical polygon type of target region.
 
Fields inherited from class edu.ucsb.adl.middleware.Query.SimpleConstraint
m_bucket, m_field, m_operator
 
Fields inherited from class edu.ucsb.adl.middleware.Query.Constraint
m_parent
 
Constructor Summary
Query.SpatialConstraint(java.lang.String bucket, Query.Field field, java.lang.String operator, double northBoundary, double southBoundary, double eastBoundary, double westBoundary)
          Constructs a SpatialConstraint whose target region is a box.
Query.SpatialConstraint(java.lang.String bucket, Query.Field field, java.lang.String operator, double northBoundary, double southBoundary, double eastBoundary, double westBoundary, Query.SpatialConstraint.Vertex[] vertices)
          Constructs a SpatialConstraint whose target region is a spherical polygon.
 
Method Summary
 double getEastBoundary()
          Returns the east boundary of the target region.
 double getNorthBoundary()
          Returns the north boundary of the target region.
 double getSouthBoundary()
          Returns the south boundary of the target region.
 int getType()
          Returns the target region type.
 Query.SpatialConstraint.Vertex[] getVertices()
          Returns the vertices of a polygon target region.
 double getWestBoundary()
          Returns the west boundary of the target region.
 java.lang.String toHTML(java.lang.String mapServerURL)
          Converts the constraint to HTML.
 java.lang.String toXML(int level)
          Converts the constraint to XML.
 
Methods inherited from class edu.ucsb.adl.middleware.Query.SimpleConstraint
commonFieldsToXML, getBucket, getField, getOperator
 
Methods inherited from class edu.ucsb.adl.middleware.Query.Constraint
getParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOX

public static final int BOX
Identifies the box type of target region.

See Also:
Constant Field Values

POLYGON

public static final int POLYGON
Identifies the spherical polygon type of target region.

See Also:
Constant Field Values
Constructor Detail

Query.SpatialConstraint

public Query.SpatialConstraint(java.lang.String bucket,
                               Query.Field field,
                               java.lang.String operator,
                               double northBoundary,
                               double southBoundary,
                               double eastBoundary,
                               double westBoundary)
Constructs a SpatialConstraint whose target region is a box.

Parameters:
bucket - The bucket to constrain, e.g., "geographic-locations".
field - The field to constrain, or null.
operator - The constraint operator, e.g., "overlaps".
northBoundary - The north boundary of the box in degrees north of the equator.
southBoundary - The south boundary of the box in degrees north of the equator.
eastBoundary - The east boundary of the box in degrees east of the Greenwich meridian.
westBoundary - The west boundary of the box in degrees east of the Greenwich meridian.
Throws:
java.lang.IllegalArgumentException - If any of the boundary coordinates is invalid.
java.lang.NullPointerException - If bucket or operator are null.

Query.SpatialConstraint

public Query.SpatialConstraint(java.lang.String bucket,
                               Query.Field field,
                               java.lang.String operator,
                               double northBoundary,
                               double southBoundary,
                               double eastBoundary,
                               double westBoundary,
                               Query.SpatialConstraint.Vertex[] vertices)
Constructs a SpatialConstraint whose target region is a spherical polygon.

Parameters:
bucket - The bucket to constrain, e.g., "geographic-locations".
field - The field to constrain, or null.
operator - The constraint operator, e.g., "overlaps".
northBoundary - The north boundary of the polygon's bounding box in degrees north of the equator.
southBoundary - The south boundary of the polygon's bounding box in degrees north of the equator.
eastBoundary - The east boundary of the polygon's bounding box in degrees east of the Greenwich meridian.
westBoundary - The west boundary of the polygon's bounding box in degrees east of the Greenwich meridian.
vertices - The vertices of the polygon in counterclockwise order. The array should not be modified after calling this method.
Throws:
java.lang.IllegalArgumentException - If any of the boundary coordinates is invalid, if vertices has fewer than three elements, or if any vertex coordinate is invalid. Note that it is not checked that the polygon is in fact simple. Nor is it checked that the bounding coordinates do in fact define the polygon's bounding box.
java.lang.NullPointerException - If any argument other than field, or any element of vertices, is null.
Method Detail

getType

public int getType()
Returns the target region type.

Returns:
The target region type.

getNorthBoundary

public double getNorthBoundary()
Returns the north boundary of the target region.

Returns:
The boundary coordinate.

getSouthBoundary

public double getSouthBoundary()
Returns the south boundary of the target region.

Returns:
The boundary coordinate.

getEastBoundary

public double getEastBoundary()
Returns the east boundary of the target region.

Returns:
The boundary coordinate.

getWestBoundary

public double getWestBoundary()
Returns the west boundary of the target region.

Returns:
The boundary coordinate.

getVertices

public Query.SpatialConstraint.Vertex[] getVertices()
Returns the vertices of a polygon target region.

Returns:
The vertices, which should not be modified.

toHTML

public java.lang.String toHTML(java.lang.String mapServerURL)
Converts the constraint to HTML.

Specified by:
toHTML in class Query.Constraint
Parameters:
mapServerURL - The template URL of a map server or null.
Returns:
An HTML fragment consisting of one or more <li> elements.

toXML

public java.lang.String toXML(int level)
Converts the constraint to XML.

Specified by:
toXML in class Query.Constraint
Parameters:
level - The current indentation level; should be nonnegative.
Returns:
An XML fragment.