Class DMSOrdinate
java.lang.Object
org.opensextant.extractors.xcoord.DMSOrdinate
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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String[]
static final String[]
static final String[]
static final String
boolean
boolean
boolean
boolean
static final String[]
static final String[]
static final int
static final int
static final int
static final String
static final int
static final int
static final String
protected int
Where does the Degree value begin in text?protected int
protected int
static final int
static final String
static final String
Specificity is a field resolution, that is how many fields were specified in the match? Ex.static final String
-
Constructor Summary
ConstructorDescriptionDMSOrdinate
(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
(String deg, String min, String sec, boolean islat, int hemi_sign) Deprecated.For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.DMSOrdinate
(Map<String, TextEntity> fieldMatches, Map<String, String> fieldVals, boolean islat, 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 TypeMethodDescriptionboolean
This should cascade.boolean
This is a copy of the logic for digest_latitude_match; All I replace is "Lat" with "Lon"static int
static String
get_hemisphere_symbol
(int hemi) int
getLatHemisphereSign
(Map<String, String> elements) int
getLonHemisphereSign
(Map<String, 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
boolean
boolean
boolean
boolean
boolean
boolean
boolean
protected void
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
toDD() Return the decimal value to the extent it makes sense.
-
Field Details
-
LAT_MAX
public static final int LAT_MAX- See Also:
-
LON_MAX
public static final int LON_MAX- See Also:
-
offsetDeg
protected int offsetDegWhere does the Degree value begin in text? -
offsetOrdinate
protected int offsetOrdinate -
hemisphere
-
has_hemi
public boolean has_hemi -
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
-
has_degrees
public boolean has_degrees -
has_minutes
public boolean has_minutes -
has_seconds
public boolean has_seconds -
degLatFields
-
degLonFields
-
COORDINATE_SYMBOLS
-
WEST
- See Also:
-
SOUTH
- See Also:
-
NORTH
- See Also:
-
EAST
- See Also:
-
NEGATIVE
- See Also:
-
POSITIVE
- See Also:
-
NO_HEMISPHERE
public static final int NO_HEMISPHERE- See Also:
-
NO_HEMISPHERE_VALUE
public static final int NO_HEMISPHERE_VALUE- See Also:
-
POS_HEMI
public static final int POS_HEMI- See Also:
-
NEG_HEMI
public static final int NEG_HEMI- See Also:
-
HEMI_MAP
-
hemiLatFields
-
hemiLonFields
-
offsetHemi
protected int offsetHemi
-
-
Constructor Details
-
DMSOrdinate
public DMSOrdinate(Map<String, TextEntity> fieldMatches, Map<String, throws NormalizationExceptionString> fieldVals, boolean islat, 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.. 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.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.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(String deg, String min, String sec, boolean islat, int hemi_sign) throws 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:
ParseException
- on parsing error or if values are null
-
-
Method Details
-
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
- Parameters:
hemi
- pos/neg number 1 or -1- Returns:
- +/- symbol
-
get_hemisphere_sign
- Parameters:
val
- +/- sign- Returns:
- 1 or -1 polarity
-
getLatHemisphereSign
- Parameters:
elements
- list of trimmed components of the match- Returns:
- polarity of hemisphere from fields
- See Also:
-
getLonHemisphereSign
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
-
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()
-