Class DMSOrdinate
- java.lang.Object
-
- org.opensextant.extractors.xcoord.DMSOrdinate
-
public final class DMSOrdinate extends java.lang.Object
DMSOrdinate represents all the various fields a WGS84 cartesian coordinate could have. degree/minute/second, as well as fractional minutes and fractional seconds. Patterns may have symbols which further indicate if a pattern is a literal decimal number (e.g., 33-44, 33.44, 33.444, 33-4444) of if the numbers are in minutes/seconds units (33:44).- Author:
- ubaldino
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DMSOrdinate.Resolution
Resolution field for DMS.ms
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
COORDINATE_SYMBOLS
static java.lang.String[]
degLatFields
static java.lang.String[]
degLonFields
static java.lang.String
EAST
boolean
has_degrees
boolean
has_hemi
boolean
has_minutes
boolean
has_seconds
static java.util.Map<java.lang.String,java.lang.Integer>
HEMI_MAP
static java.lang.String[]
hemiLatFields
static java.lang.String[]
hemiLonFields
Hemisphere
hemisphere
static int
LAT_MAX
static int
LON_MAX
static int
NEG_HEMI
static java.lang.String
NEGATIVE
static int
NO_HEMISPHERE
static int
NO_HEMISPHERE_VALUE
static java.lang.String
NORTH
protected int
offsetDeg
Where does the Degree value begin in text?protected int
offsetHemi
protected int
offsetMatch
protected int
offsetOrdinate
static int
POS_HEMI
static java.lang.String
POSITIVE
static java.lang.String
SOUTH
DMSOrdinate.Resolution
specificity
Specificity is a field resolution, that is how many fields were specified in the match? Ex.java.lang.String
text
static java.lang.String
WEST
-
Constructor Summary
Constructors Constructor Description DMSOrdinate(int deg, int min, int sec, boolean islat, int hemi_sign)
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.DMSOrdinate(int deg, int min, int sec, int msec, boolean islat, int hemi_sign)
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.DMSOrdinate(java.lang.String deg, java.lang.String min, java.lang.String sec, boolean islat, int hemi_sign)
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.DMSOrdinate(java.util.Map<java.lang.String,TextEntity> fieldMatches, java.util.Map<java.lang.String,java.lang.String> fieldVals, boolean islat, java.lang.String t)
DMS ordinates can be made up of degrees, minutes, seconds and then decimal minutes and decimal seconds fractional minutes dddd are formatted as ".dddd" then parsed; ADD to existing minutes fractional seconds dddd are formatted as ".dddd" then parsed; ADD to existing seconds decimal minutes d.ddd..
-
Method Summary
Modifier and Type Method Description boolean
digest_latitude_match()
This should cascade.boolean
digest_longitude_match()
This is a copy of the logic for digest_latitude_match; All I replace is "Lat" with "Lon"static int
get_hemisphere_sign(java.lang.String val)
static java.lang.String
get_hemisphere_symbol(int hemi)
int
getLatHemisphereSign(java.util.Map<java.lang.String,java.lang.String> elements)
int
getLonHemisphereSign(java.util.Map<java.lang.String,java.lang.String> elements)
Given a list of match groups find the first Longitude Hemisphere group hemiLon W, E group used mostly for DMS, DM, DD formats hemiLonSign +, - group allowed only for specific formats; +/- may appear before any number not just coords.double
getValue()
Get the cartesian value for this ordinateboolean
hasDegrees()
boolean
hasHemisphere()
boolean
hasMinutes()
boolean
hasSeconds()
boolean
hasSubDegrees()
boolean
hasSubMinutes()
boolean
hasSubSeconds()
boolean
hasSymbols()
protected void
set_normalized_text()
Get back a normalized version of what you found.void
setRelativeOffsets(int matchStart)
offsets for degree and hemisphere until this point are likely absolute within a document Reset them using this relative offset.double
toDecimal()
toDD() Return the decimal value to the extent it makes sense.boolean
validate()
Unused
-
-
-
Field Detail
-
LAT_MAX
public static final int LAT_MAX
- See Also:
- Constant Field Values
-
LON_MAX
public static final int LON_MAX
- See Also:
- Constant Field Values
-
offsetDeg
protected int offsetDeg
Where does the Degree value begin in text?
-
offsetMatch
protected int offsetMatch
-
offsetOrdinate
protected int offsetOrdinate
-
hemisphere
public Hemisphere hemisphere
-
has_hemi
public boolean has_hemi
-
specificity
public DMSOrdinate.Resolution specificity
Specificity is a field resolution, that is how many fields were specified in the match? Ex. D:M:S.ss match is pretty fine -- sub-second Versus absolute resolution which looks at the significant-figures in the absolute value. Ex. D.dddddddddddd is very fine, too. This can either be coarse or super-fine. Lat/Lon specificity mismatches indicate false-positives, lat(DEG) with a lon(SUBMIN) its unlikely they are valid pair.
-
text
public java.lang.String text
-
has_degrees
public boolean has_degrees
-
has_minutes
public boolean has_minutes
-
has_seconds
public boolean has_seconds
-
degLatFields
public static final java.lang.String[] degLatFields
-
degLonFields
public static final java.lang.String[] degLonFields
-
COORDINATE_SYMBOLS
public static final java.lang.String[] COORDINATE_SYMBOLS
-
WEST
public static final java.lang.String WEST
- See Also:
- Constant Field Values
-
SOUTH
public static final java.lang.String SOUTH
- See Also:
- Constant Field Values
-
NORTH
public static final java.lang.String NORTH
- See Also:
- Constant Field Values
-
EAST
public static final java.lang.String EAST
- See Also:
- Constant Field Values
-
NEGATIVE
public static final java.lang.String NEGATIVE
- See Also:
- Constant Field Values
-
POSITIVE
public static final java.lang.String POSITIVE
- See Also:
- Constant Field Values
-
NO_HEMISPHERE
public static final int NO_HEMISPHERE
- See Also:
- Constant Field Values
-
NO_HEMISPHERE_VALUE
public static final int NO_HEMISPHERE_VALUE
- See Also:
- Constant Field Values
-
POS_HEMI
public static final int POS_HEMI
- See Also:
- Constant Field Values
-
NEG_HEMI
public static final int NEG_HEMI
- See Also:
- Constant Field Values
-
HEMI_MAP
public static final java.util.Map<java.lang.String,java.lang.Integer> HEMI_MAP
-
hemiLatFields
public static final java.lang.String[] hemiLatFields
-
hemiLonFields
public static final java.lang.String[] hemiLonFields
-
offsetHemi
protected int offsetHemi
-
-
Constructor Detail
-
DMSOrdinate
public DMSOrdinate(java.util.Map<java.lang.String,TextEntity> fieldMatches, java.util.Map<java.lang.String,java.lang.String> fieldVals, boolean islat, java.lang.String t) throws NormalizationException
DMS ordinates can be made up of degrees, minutes, seconds and then decimal minutes and decimal seconds fractional minutes dddd are formatted as ".dddd" then parsed; ADD to existing minutes fractional seconds dddd are formatted as ".dddd" then parsed; ADD to existing seconds decimal minutes d.ddd.. are parsed as float, divide by 60 to get # of degrees decimal seconds d.ddd.. "" "" , divide by 3600 to get # of degrees All Constructors must set is_latitude from a given flag. This is used for range validation.- Parameters:
fieldMatches
- the field matchesfieldVals
- the field valsislat
- true if matched part is for latitudet
- the raw text of the matched coordinate- Throws:
NormalizationException
- if coordinate is not valid or unable to normalize
-
DMSOrdinate
@Deprecated public DMSOrdinate(int deg, int min, int sec, boolean islat, int hemi_sign)
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.Only used for literal decimal degrees that require little parsing.- Parameters:
deg
- degreesmin
- minutessec
- secondsislat
- true if match is latitudehemi_sign
- polarity of hemisphere
-
DMSOrdinate
@Deprecated public DMSOrdinate(int deg, int min, int sec, int msec, boolean islat, int hemi_sign)
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.Construct a lat or lon ordinate from given values.- Parameters:
deg
- degreesmin
- minutessec
- secondsmsec
- millisislat
- true if match is latitudehemi_sign
- polarity of hemisphere
-
DMSOrdinate
@Deprecated public DMSOrdinate(java.lang.String deg, java.lang.String min, java.lang.String sec, boolean islat, int hemi_sign) throws java.text.ParseException
Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.Construct a lat or lon ordinate from given values.- Parameters:
deg
- degreesmin
- minutessec
- secondsislat
- isLathemi_sign
- polarity- Throws:
java.text.ParseException
- on parsing error or if values are null
-
-
Method Detail
-
setRelativeOffsets
public void setRelativeOffsets(int matchStart)
offsets for degree and hemisphere until this point are likely absolute within a document Reset them using this relative offset. Offsets will then be relative to text.- Parameters:
matchStart
- offset of match into doc
-
hasHemisphere
public boolean hasHemisphere()
- Returns:
- true if match has Hemisphere
-
getValue
public double getValue()
Get the cartesian value for this ordinate- Returns:
- double
-
set_normalized_text
protected void set_normalized_text()
Get back a normalized version of what you found. Yield zero-padded version of coordinate, e.g., if DMS xdeg M' SS" is parsed we want xxx:MM:SS fully padded 45 33N-00811 given 45:33.00811 normalized, DEG:MIN.mmmmm Full format should be: hDDD.ddd hDDD:MM.mmm hDDD:MM.mmm:SS.sss unlikely -- if this happens -- both fractional minutes and fractional seconds, pattern has errors hDDD:MM:SS.sss .ddd, .mmm, .sss --- as many decimal places as there are h --- +/- hemisphere
-
digest_latitude_match
public boolean digest_latitude_match()
This should cascade.IF Degrees specified, then if minutes, then if seconds...
It would be difficult to skip minutes if DEG and SEC are only fields present.- Returns:
- true if Latitude fields parse properly
-
digest_longitude_match
public boolean digest_longitude_match()
This is a copy of the logic for digest_latitude_match; All I replace is "Lat" with "Lon"- Returns:
- true if longitude fields parse properly
-
hasSymbols
public boolean hasSymbols()
- Returns:
- true if match has symbols
-
get_hemisphere_symbol
public static java.lang.String get_hemisphere_symbol(int hemi)
- Parameters:
hemi
- pos/neg number 1 or -1- Returns:
- +/- symbol
-
get_hemisphere_sign
public static int get_hemisphere_sign(java.lang.String val)
- Parameters:
val
- +/- sign- Returns:
- 1 or -1 polarity
-
getLatHemisphereSign
public int getLatHemisphereSign(java.util.Map<java.lang.String,java.lang.String> elements)
- Parameters:
elements
- list of trimmed components of the match- Returns:
- polarity of hemisphere from fields
- See Also:
getLonHemisphereSign(Map)
-
getLonHemisphereSign
public int getLonHemisphereSign(java.util.Map<java.lang.String,java.lang.String> elements)
Given a list of match groups find the first Longitude Hemisphere group hemiLon W, E group used mostly for DMS, DM, DD formats hemiLonSign +, - group allowed only for specific formats; +/- may appear before any number not just coords. hemiLonPre W, E, +, -- Parameters:
elements
- list of trimmed components of the match- Returns:
- polarity of hemisphere from fields
-
validate
public boolean validate()
Unused- Returns:
-
toDecimal
public double toDecimal()
toDD() Return the decimal value to the extent it makes sense. That is, calculating minutes or seconds where MIN or SEC fields are out of bounds for those units does not make sense, return at least Deg or Deg/Min. Validation of the ordinate is a second step to be done by caller.- Returns:
-
hasDegrees
public boolean hasDegrees()
-
hasSubDegrees
public boolean hasSubDegrees()
-
hasMinutes
public boolean hasMinutes()
-
hasSubMinutes
public boolean hasSubMinutes()
-
hasSeconds
public boolean hasSeconds()
-
hasSubSeconds
public boolean hasSubSeconds()
-
-