com.isti.util.gis
Class IstiRegion

java.lang.Object
  extended by com.isti.util.gis.IstiRegion
Direct Known Subclasses:
IstiRegion.Circle, IstiRegion.Polygon

public class IstiRegion
extends java.lang.Object


Nested Class Summary
static class IstiRegion.Circle
          Circle region.
static class IstiRegion.LatLonPoint
          Latitude/longitude point.
static class IstiRegion.LatLonPolygon
          Latitude/longitude polygon.
static class IstiRegion.Polygon
          Polygon region.
 
Field Summary
static CfgPropValidator ageValidator
          The age validator.
static java.lang.String COORD_BEGIN_CHAR
          The character that comes before the coordinate.
static java.lang.String COORD_END_CHAR
          The character that comes after the coordinate.
static java.lang.String COORD_SEP_CHAR
          The character that separates coordinates.
static java.lang.String DEF_SPECIAL_CHARS_STR
          String of special characters for 'insertQuoteChars()' method.
static double defaultConversionFactor
          The default conversion factor that will be used for strings.
static CfgPropValidator depthValidator
          The depth validator.
static java.lang.String GLOBAL_ALARM_OPTION_GROUP
          The global alarm option group selection text.
static CfgPropValidator magValidator
          The magnitude validator.
static java.lang.String NAME_BEGIN_CHAR
          The character that comes before the name.
static java.lang.String NAME_END_CHAR
          The character that comes after the name.
static java.lang.String OPID_AUDIBLE
          The option ID text of the audible flag.
static java.lang.String OPID_MAG
          The option ID text for the minimum magnitude.
static java.lang.String OPID_MAXAGE
          The option ID text of the maximum age.
static java.lang.String OPID_MAXDEPTH
          The option ID text of the maximum depth.
static java.lang.String OPID_MINDEPTH
          The option ID text of the minimum depth.
static java.lang.String OPID_NAME
          The option ID text for the name.
static java.lang.String OPID_VERIFIED
          The option ID text of the verified flag.
static java.lang.String OPID_VISUAL
          The option ID text of the visual flag.
static java.lang.String OPTION_BEGIN_CHAR
          The character that comes before an option.
static java.lang.String OPTION_END_CHAR
          The character that comes after an option.
static java.lang.String REGION_SEP_CHAR
          The character that separates regions.
protected  java.lang.String regionTextValueStr
          The string representation of the region.
 
Constructor Summary
protected IstiRegion(java.lang.String str)
          Constructs a region.
 
Method Summary
static java.lang.String circleToString(double lat, double lon, double radius)
          Converts the circle and radius to a string with the radius in miles or other unit if the conversion factor has been set.
 java.lang.Object clone()
          Creates a copy of a region.
 boolean contains(double lat, double lon)
          Determines if the specified coordinate is inside of the region.
static java.lang.String coordsToString(double[] llPoints)
          Converts the coordinates to a string.
static java.lang.String coordToString(double lat, double lon)
          Converts the point to a string.
protected  IstiRegion copyOptions(IstiRegion region)
          Copies the opions from the specified region to this region.
static IstiNamedValueComponentPanel createOptionsComponentPanel()
          Creates the options component panel.
static java.lang.String extractRegionName(java.lang.String regionTextStr)
          Parses the region name from the given region-text string.
static java.lang.String floatNumberToString(double value)
          Converts the given float number value to a string where the value displayed will be at least one fractional digit and will always be non-zero as long as the value is greater than zero.
static IstiNamedValueInterface[] getDefaultOptions()
          Gets the default options.
 java.lang.String getName()
          Gets the name of this region.
 IstiNamedValueInterface getOption(java.lang.String name)
          Gets the option value with the specified name.
 java.lang.Number getOptionNumberValue(java.lang.String opid)
          Gets the option number value with the specified name.
 java.lang.String getOptionStringValue(java.lang.String opid)
          Gets the option string value with the specified name.
 java.lang.Object getOptionValue(java.lang.String opid)
          Gets the option value with the specified name.
 java.lang.String getRegionTextValueStr()
          Returns the region-text string used to created this object.
static java.lang.String insertQuoteChars(java.lang.String dataStr)
          Returns a string with a backslash quote character ('\') inserted in front of each occurance of a "special" character in the given source string.
static IstiRegion parse(java.lang.String str)
          Parses a string representation of a region.
static IstiRegion parse(java.lang.String str, boolean allowGenericFlag)
          Parses a string representation of a region.
protected  void parseOptions(java.lang.String str)
          Parses the string for options.
static IstiRegion[] parseRegions(java.lang.String str)
          Parses a string representation any number of regions.
static java.lang.String radiusToString(double radius)
          Converts the radious to a string.
static java.lang.String removeQuoteChars(java.lang.String dataStr)
          Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'.
static java.lang.String replaceRegionName(java.lang.String regionTextStr, java.lang.String newNameStr)
          Replaces the region name in the given region-text string (or enters the given name if the region had none).
protected  boolean setOptionValue(java.lang.String optionStr)
          Sets the option value.
static IstiRegion.LatLonPoint stringToCoord(java.lang.String str)
          Converts the string to coordinate.
static double[] stringToCoords(java.lang.String str)
          Converts the string to coordinates.
static double stringToRadius(java.lang.String str)
          Converts the string containing a radius in miles or other unit if the conversion factor has been set to a radius in meters.
 java.lang.String toString()
          Returns a string representation of the region.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultConversionFactor

public static final double defaultConversionFactor
The default conversion factor that will be used for strings. The default is miles.

See Also:
Constant Field Values

NAME_BEGIN_CHAR

public static final java.lang.String NAME_BEGIN_CHAR
The character that comes before the name.

See Also:
Constant Field Values

NAME_END_CHAR

public static final java.lang.String NAME_END_CHAR
The character that comes after the name.

See Also:
Constant Field Values

COORD_BEGIN_CHAR

public static final java.lang.String COORD_BEGIN_CHAR
The character that comes before the coordinate.

See Also:
Constant Field Values

COORD_END_CHAR

public static final java.lang.String COORD_END_CHAR
The character that comes after the coordinate.

See Also:
Constant Field Values

COORD_SEP_CHAR

public static final java.lang.String COORD_SEP_CHAR
The character that separates coordinates.

See Also:
Constant Field Values

REGION_SEP_CHAR

public static final java.lang.String REGION_SEP_CHAR
The character that separates regions.

See Also:
Constant Field Values

OPTION_BEGIN_CHAR

public static final java.lang.String OPTION_BEGIN_CHAR
The character that comes before an option.

See Also:
Constant Field Values

OPTION_END_CHAR

public static final java.lang.String OPTION_END_CHAR
The character that comes after an option.

See Also:
Constant Field Values

DEF_SPECIAL_CHARS_STR

public static final java.lang.String DEF_SPECIAL_CHARS_STR
String of special characters for 'insertQuoteChars()' method.

See Also:
Constant Field Values

regionTextValueStr

protected final java.lang.String regionTextValueStr
The string representation of the region.


OPID_NAME

public static final java.lang.String OPID_NAME
The option ID text for the name.

See Also:
Constant Field Values

OPID_MAG

public static final java.lang.String OPID_MAG
The option ID text for the minimum magnitude.


OPID_MINDEPTH

public static final java.lang.String OPID_MINDEPTH
The option ID text of the minimum depth.

See Also:
Constant Field Values

OPID_MAXDEPTH

public static final java.lang.String OPID_MAXDEPTH
The option ID text of the maximum depth.

See Also:
Constant Field Values

OPID_MAXAGE

public static final java.lang.String OPID_MAXAGE
The option ID text of the maximum age.

See Also:
Constant Field Values

OPID_VERIFIED

public static final java.lang.String OPID_VERIFIED
The option ID text of the verified flag.

See Also:
Constant Field Values

OPID_AUDIBLE

public static final java.lang.String OPID_AUDIBLE
The option ID text of the audible flag.

See Also:
Constant Field Values

OPID_VISUAL

public static final java.lang.String OPID_VISUAL
The option ID text of the visual flag.

See Also:
Constant Field Values

GLOBAL_ALARM_OPTION_GROUP

public static final java.lang.String GLOBAL_ALARM_OPTION_GROUP
The global alarm option group selection text.

See Also:
Constant Field Values

magValidator

public static final CfgPropValidator magValidator
The magnitude validator.


depthValidator

public static final CfgPropValidator depthValidator
The depth validator.


ageValidator

public static final CfgPropValidator ageValidator
The age validator.

Constructor Detail

IstiRegion

protected IstiRegion(java.lang.String str)
Constructs a region.

Parameters:
str - string representation of the region.
Method Detail

getDefaultOptions

public static IstiNamedValueInterface[] getDefaultOptions()
Gets the default options.

Returns:
the default options.

createOptionsComponentPanel

public static IstiNamedValueComponentPanel createOptionsComponentPanel()
Creates the options component panel.

Returns:
the options component panel.

circleToString

public static java.lang.String circleToString(double lat,
                                              double lon,
                                              double radius)
Converts the circle and radius to a string with the radius in miles or other unit if the conversion factor has been set.

Parameters:
lat - the latitude of the point.
lon - the longitude of the point.
radius - the radius of the circle in meters.
Returns:
a string representation of the region specifed by the coordinates.
See Also:
defaultConversionFactor.

clone

public java.lang.Object clone()
Creates a copy of a region.

Overrides:
clone in class java.lang.Object
Returns:
a copy of the region.

contains

public boolean contains(double lat,
                        double lon)
Determines if the specified coordinate is inside of the region.

Parameters:
lat - the latitude of the point.
lon - the longitude of the point.
Returns:
true if the point is inside the region, false otherwise.

coordsToString

public static java.lang.String coordsToString(double[] llPoints)
Converts the coordinates to a string.

Parameters:
llPoints - the coordinates, in the format [lat0, lon0, lat1, lon1, ... ].
Returns:
a string representation of the region specifed by the coordinates.

coordToString

public static java.lang.String coordToString(double lat,
                                             double lon)
Converts the point to a string.

Parameters:
lat - the latitude of the point.
lon - the longitude of the point.
Returns:
a string representation of the point.

floatNumberToString

public static java.lang.String floatNumberToString(double value)
Converts the given float number value to a string where the value displayed will be at least one fractional digit and will always be non-zero as long as the value is greater than zero.

Parameters:
value - the number value.
Returns:
A string representing the number.

getName

public java.lang.String getName()
Gets the name of this region.

Returns:
the name of this region.

getRegionTextValueStr

public java.lang.String getRegionTextValueStr()
Returns the region-text string used to created this object.

Returns:
The region-text string used to created this object.

getOption

public IstiNamedValueInterface getOption(java.lang.String name)
Gets the option value with the specified name.

Parameters:
name - the option name.
Returns:
the option value or null if not found.

getOptionNumberValue

public java.lang.Number getOptionNumberValue(java.lang.String opid)
Gets the option number value with the specified name.

Parameters:
opid - the option ID.
Returns:
the option number value or null if not found.

getOptionStringValue

public java.lang.String getOptionStringValue(java.lang.String opid)
Gets the option string value with the specified name.

Parameters:
opid - the option ID.
Returns:
the option string value or null if not found.

getOptionValue

public java.lang.Object getOptionValue(java.lang.String opid)
Gets the option value with the specified name.

Parameters:
opid - the option ID.
Returns:
the option value or null if not found.

parse

public static IstiRegion parse(java.lang.String str,
                               boolean allowGenericFlag)
Parses a string representation of a region.

Parameters:
str - a string representation of a region.
allowGenericFlag - true to allow "generic" region object to be created; false for only circle or polygon region object.
Returns:
a region object or null if invalid string.

parse

public static IstiRegion parse(java.lang.String str)
Parses a string representation of a region.

Parameters:
str - a string representation of a region.
Returns:
a region or null if invalid string.

parseRegions

public static IstiRegion[] parseRegions(java.lang.String str)
Parses a string representation any number of regions.

Parameters:
str - a string representation of the regions.
Returns:
an array of regions or an empty array if invalid string.

radiusToString

public static java.lang.String radiusToString(double radius)
Converts the radious to a string.

Parameters:
radius - the radius of the circle in meters.
Returns:
a string representation of the radius.

stringToCoord

public static IstiRegion.LatLonPoint stringToCoord(java.lang.String str)
Converts the string to coordinate.

Parameters:
str - the string representation of the coordinate.
Returns:
the coordinate or null if error.

stringToCoords

public static double[] stringToCoords(java.lang.String str)
Converts the string to coordinates.

Parameters:
str - the string representation of the coordinates.
Returns:
the coordinates or null if error.

stringToRadius

public static double stringToRadius(java.lang.String str)
Converts the string containing a radius in miles or other unit if the conversion factor has been set to a radius in meters.

Parameters:
str - the string representation of the coordinates and radius.
Returns:
the radius.
See Also:
defaultConversionFactor.

extractRegionName

public static java.lang.String extractRegionName(java.lang.String regionTextStr)
Parses the region name from the given region-text string.

Parameters:
regionTextStr - region-text string to parse.
Returns:
The region name, or an empty string if none found.

replaceRegionName

public static java.lang.String replaceRegionName(java.lang.String regionTextStr,
                                                 java.lang.String newNameStr)
Replaces the region name in the given region-text string (or enters the given name if the region had none).

Parameters:
regionTextStr - region-text string to use.
newNameStr - new region name.
Returns:
A new string containing the region-text with the new name entered into it.

toString

public final java.lang.String toString()
Returns a string representation of the region.

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

copyOptions

protected IstiRegion copyOptions(IstiRegion region)
Copies the opions from the specified region to this region.

Parameters:
region - the region to copy the options from.
Returns:
this region.

parseOptions

protected final void parseOptions(java.lang.String str)
Parses the string for options.

Parameters:
str - the string representation of the region.

setOptionValue

protected boolean setOptionValue(java.lang.String optionStr)
Sets the option value.

Parameters:
optionStr - the option string.
Returns:
true if successful, false if the string could not be converted to the proper type.

insertQuoteChars

public static java.lang.String insertQuoteChars(java.lang.String dataStr)
Returns a string with a backslash quote character ('\') inserted in front of each occurance of a "special" character in the given source string.

Parameters:
dataStr - the data source string.
Returns:
a new string with its "special" characters quoted, or the original string if no matching "special" characters were found.

removeQuoteChars

public static java.lang.String removeQuoteChars(java.lang.String dataStr)
Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'. The sequences \t, \n, and \r are converted to the ASCII characters tab, newline, and carriage return, respectively.

Parameters:
dataStr - the data source string.
Returns:
a new string with the quote characters removed, or the original string if no quote characters were found.