com.askgeo.flt.base
Class ResultBase

java.lang.Object
  extended by com.askgeo.flt.base.ResultBase
Direct Known Subclasses:
CountryResult, TimeZoneResult, UsCensusResultBase

public abstract class ResultBase
extends java.lang.Object

The base class of all result classes. Each subclass of GeneralMap has a companion result class that is itself a subclass of ResultBase. Those result classes are what are returned when a map is queried.

Maps may be configured so that if a given query point does not lie inside any of the shapes in the map, then it will snap to a nearby shape if it is within a specified distance of the query point. The getIsInside method return whether the query point was inside the shape or not, and the getMinDistanceKm method returns the distance from the query point to the shape in kilometers (or zero if it is inside the shape).


Constructor Summary
ResultBase(int askGeoId, boolean isInside, float minDistanceKm, java.lang.String[] fields, PolygonData polygonData)
           
 
Method Summary
 int getAskGeoId()
          Within each map, every shape has a unique integer ID.
 java.lang.String getDataField(DataFieldInterface e)
          Each map has metadata associated with each shape.
 boolean getIsInside()
          Query points that are not within any of the shapes in the map will snap-to the nearest shape if that shape is within a specified snap-to radius.
 float getMinDistanceKm()
          Query points that are not within any of the shapes in the map will snap-to the nearest shape if that shape is within a specified snap-to radius.
 PolygonData getPolygonData()
          Returns the polygon data for the shape from which this result was built
 java.lang.String getResultField(DataFieldInterface f)
          The AskGeo ID, the isInside boolean, and the minDistanceKm may be accessed by the direct accessors getAskGeoId, getIsInside, and getMinDistanceKm.
 float parseFloatOrNan(java.lang.String text)
          All data fields are stored as strings but many are more useful as numbers.
 int parseIntOrElse(java.lang.String text, int alt)
          All data fields are stored as strings but many are more useful as numbers.
 java.lang.String toString()
          The string representation of a result is a tab-separated concatenation of all the data fields.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultBase

public ResultBase(int askGeoId,
                  boolean isInside,
                  float minDistanceKm,
                  java.lang.String[] fields,
                  PolygonData polygonData)
Method Detail

toString

public java.lang.String toString()
The string representation of a result is a tab-separated concatenation of all the data fields.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the result.

getPolygonData

public PolygonData getPolygonData()
Returns the polygon data for the shape from which this result was built

Returns:
the polygon data.

getAskGeoId

public int getAskGeoId()
Within each map, every shape has a unique integer ID.

Returns:
the ID of the shape from which this result was built.

getIsInside

public boolean getIsInside()
Query points that are not within any of the shapes in the map will snap-to the nearest shape if that shape is within a specified snap-to radius. This method returns whether the this particular query point was inside the shape from which this result was built.

Returns:
whether the query point was inside the shape from which this result was built.

getMinDistanceKm

public float getMinDistanceKm()
Query points that are not within any of the shapes in the map will snap-to the nearest shape if that shape is within a specified snap-to radius. If the query point was inside the shape, this method returns zero. If the query point was outside the shape, this method returns the smallest distance (in km) along the surface of the globe between the query point and the outer boundary of the shape.

Returns:
the distance in kilometers between the query point and the shape, along the shortest path between them.

getResultField

public java.lang.String getResultField(DataFieldInterface f)
The AskGeo ID, the isInside boolean, and the minDistanceKm may be accessed by the direct accessors getAskGeoId, getIsInside, and getMinDistanceKm. They may also be accessed by using this method with the ResultField enum.

Parameters:
f - is a ResultField enum value (either ResultField.AskGeoId, ResultField.IsInside, or ResultField.MinDistanceKm).
Returns:
a string representation of the given result field.

getDataField

public java.lang.String getDataField(DataFieldInterface e)
Each map has metadata associated with each shape. That metadata is returned with results built from that shape. This method gives access to that metadata using a DataField enum. Each map has an public inner enum called DataField. Passing

Parameters:
e - is a DataField enum value from the public inner enum within the map class from which this result was generated.
Returns:
the string representation of the requested data field.

parseFloatOrNan

public float parseFloatOrNan(java.lang.String text)
All data fields are stored as strings but many are more useful as numbers. This method converts a String to a float. If the conversion fails, Float.NaN is returned.

Parameters:
text - the string representation of a float.
Returns:
the float value of this String, or Float.NaN if the conversion fails.

parseIntOrElse

public int parseIntOrElse(java.lang.String text,
                          int alt)
All data fields are stored as strings but many are more useful as numbers. This method converts a String to an int. If the conversion fails, alt is returned.

Parameters:
text - the string representation of a float.
alt - the integer to return if the parsing fails.
Returns:
the float value of this String, or alt if the parsing fails.


Copyright © 2012 Vector Magic, Inc.