Class GeocoordMatch
java.lang.Object
org.opensextant.extraction.TextEntity
org.opensextant.extraction.TextMatch
org.opensextant.extractors.xcoord.GeocoordMatch
- All Implemented Interfaces:
Comparable<TextMatch>
,Geocoding
,LatLon
,MatchSchema
GeocoordMatch holds all the annotation data for the actual raw and normalized
coordinate.
- Author:
- ubaldino
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionint
The cce family id.The cce variant.protected String
Just the coordinate text normalized.protected int
count dashes other than hemispheres, +/-.protected List<GeocoordMatch>
The interpretations.protected String
The lat text.protected String
The lon text.protected int
The offset separator.inherent precision of the coordinate matched.protected String
The separator.final String[]
The separators.Fields inherited from class org.opensextant.extraction.TextMatch
pattern_id, producer, type
Fields inherited from class org.opensextant.extraction.TextEntity
end, is_duplicate, is_overlap, is_submatch, match_id, postChar, preChar, start, text
Fields inherited from interface org.opensextant.data.MatchSchema
VAL_COORD, VAL_COUNTRY, VAL_PLACE, VAL_POSTAL, VAL_TAXON
-
Constructor Summary
ConstructorDescriptionGeocoordMatch
(int x1, int x2) a TextMatch that represents a coordinate found in free text. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNearByPlace
(Place location) Adds the near by place.void
The current instance is the main match.asPlace()
Create a Place version of this coordinate -- that is, once we've found the coordinate match if the match data is no longer needed we can produce a geodetic Place from the TextMatch.void
Copy metadata.boolean
evaluateInvalidDashes
(Map<String, String> fields) Evaluate DMS patterns only...boolean
evaluateInvalidPunct
(Map<String, String> fieldValues) Test punctuation separators.Format latitude.Format longitude.Precision value is in Meters.Gets the admin 1.Null implementation -- Geocoding interface.State-level postal code, the corresponds usually to ADM1.Gets the admin 2.Null implementation -- Geocoding interface Coordinates from XCoord do not automatically report name of admin boundaries.GeoBase interface.int
TOOD: convey a realistic confidence metric for what was actually matched.Gets the country code.Gets the feature class.Gets the feature code.double
Gets the latitude.Gets the lat text.double
Gets the longitude.Gets the lon text.Returns the exact pattern that matched.Gets the near by places.Gets the other interpretations.Gets the place ID.Gets the place name.City-level postal code, that may be something like a zip.int
Gets the precision.Gets the related place.gridzone()
Identifies the 100KM quad in which this point is contained.boolean
Checks for coordinate.boolean
Checks for minutes.boolean
Checks for other interpretations.boolean
Checks for seconds.boolean
Checks if is administrative.boolean
Checks if is balanced.boolean
Note the coordinate nature of this TextMatch/Geocoding takes precedence over other flags isPlace, isCountry, etc.boolean
Checks if is country.boolean
isPlace()
Checks if is place.boolean
isZero()
Convenience method for determining if XY = 0,0.void
Sets the admin 1 postal code.void
setBalanced
(boolean b) Allow pattern rules to determine by any means if match is balanced.void
setConfidence
(int c) Sets the confidence.void
setCoordinate
(DMSOrdinate _lat, DMSOrdinate _lon) Set the ordinates back on the match; general filters are assessed.void
Sets the country.void
setCountryCode
(String cc) Sets the country code.void
setLatitude
(double y) Sets the latitude.void
setLatitude
(String decval) Sets the latitude.void
If you are given a vetted XY, use that.void
setLongitude
(double x) Sets the longitude.void
setLongitude
(String decval) Sets the longitude.void
This reuses TextMatch.pattern_id attr; Use get/setMethod() or pattern_id as needed.void
Sets the place name.void
Sets the place postal code.void
setPrecision
(int m) Sets the precision.void
setRelatedPlace
(Place location) Sets the related place.protected void
setRelativeOffset
(int s) Note: this should only be called once.protected void
setSeparator
(Map<String, TextEntity> fields) Sets the separator.toMGRS()
Convert the current coordinate to MGRS.Methods inherited from class org.opensextant.extraction.TextMatch
compareTo, copy, defaultMatchId, getContentId, getMatchId, getTextnorm, getType, isDefault, isFilteredOut, isSame, isSameNorm, setFilteredOut, setType, toString
Methods inherited from class org.opensextant.extraction.TextEntity
contains, copy, getContext, getContextAfter, getContextBefore, getLength, getText, isAfter, isASCII, isBefore, isLeftMatch, isLower, isMixedCase, isOverlap, isRightMatch, isSameMatch, isUpper, isWithin, isWithinChars, setContext, setContext, setText, setTextOnly
-
Field Details
-
coord_text
Just the coordinate text normalized. -
lat_text
The lat text. -
lon_text
The lon text. -
cce_family_id
public int cce_family_idThe cce family id. -
cce_variant
The cce variant. -
precision
inherent precision of the coordinate matched. -
dashCount
protected int dashCountcount dashes other than hemispheres, +/-. -
separators
The separators. -
offsetSeparator
protected int offsetSeparatorThe offset separator. -
separator
The separator. -
interpretations
The interpretations.
-
-
Constructor Details
-
GeocoordMatch
public GeocoordMatch(int x1, int x2) a TextMatch that represents a coordinate found in free text.
-
-
Method Details
-
isZero
public boolean isZero()Convenience method for determining if XY = 0,0.- Returns:
- true, if is zero
-
setBalanced
public void setBalanced(boolean b) Allow pattern rules to determine by any means if match is balanced.- Parameters:
b
- if coordinate has balanced data/resolution e.g., MGRS with even digits of offset
-
isBalanced
public boolean isBalanced()Checks if is balanced.- Returns:
- true, if is balanced
-
setLatLon
If you are given a vetted XY, use that.- Parameters:
yx
- latlon
-
getAdminName
GeoBase interface.- Specified by:
getAdminName
in interfaceGeocoding
- Returns:
- null always. The raw matched object does not automatically provide an admin name. Override if other behavior is desired.
-
copyMetadata
Copy metadata.- Parameters:
m
- the match to copy
-
setCoordinate
Set the ordinates back on the match; general filters are assessed.- Parameters:
_lat
- lat obj_lon
- lon obj
-
setSeparator
Sets the separator.- Parameters:
fields
- regex fields to search
-
setRelativeOffset
protected void setRelativeOffset(int s) Note: this should only be called once.- Parameters:
s
- offset position
-
evaluateInvalidDashes
Evaluate DMS patterns only... evaluate if match contains dashes as field separators or as hemispheres. Or both. If match contains dash sep on lat, but not in lon, then the match is invalid. This suggests the match is not a geocoordinate.- Returns:
- true if coordinate is invalid because
- Throws:
NormalizationException
- the normalization exception
-
hasMinutes
public boolean hasMinutes()Checks for minutes.- Returns:
- if match has minutes
-
hasSeconds
public boolean hasSeconds()Checks for seconds.- Returns:
- if match has seconds
-
setLatitude
Sets the latitude.- Parameters:
decval
- decimal lat
-
setLongitude
Sets the longitude.- Parameters:
decval
- decimal lon
-
formatLatitude
Format latitude.- Returns:
- formatted lat based on lat precision
-
formatLongitude
Format longitude.- Returns:
- formatted longitude base on lon precision
-
formatPrecision
Precision value is in Meters. No more than 0.001 METER is really relevant -- since this is really information extraction it is very doubtful that you will have any confidence about extraction millimeter accuracy.- Returns:
- string number of whole meters of precision
-
getPrecision
public int getPrecision()Gets the precision.- Specified by:
getPrecision
in interfaceGeocoding
- Returns:
- int number of whole meters of precision
-
setPrecision
public void setPrecision(int m) Sets the precision.- Specified by:
setPrecision
in interfaceGeocoding
- Parameters:
m
- the new precision
-
toMGRS
Convert the current coordinate to MGRS.- Returns:
- string version of MGRS
-
gridzone
Identifies the 100KM quad in which this point is contained.- Returns:
- GZ MGRS GZD and Quad prefix. This is a unique 100KM square.
-
addOtherInterpretation
The current instance is the main match. But should you be able to parse out additional interpretations, add them- Parameters:
m2
- secondary match
-
hasOtherIterpretations
public boolean hasOtherIterpretations()Checks for other interpretations.- Returns:
- true, if original match has multiple interpretations/normalizations.
-
getOtherInterpretations
Gets the other interpretations.- Returns:
- list of other interpreted matches
-
isPlace
public boolean isPlace()Checks if is place. -
isCoordinate
public boolean isCoordinate()Note the coordinate nature of this TextMatch/Geocoding takes precedence over other flags isPlace, isCountry, etc.- Specified by:
isCoordinate
in interfaceGeocoding
- Returns:
- true.
-
isCountry
public boolean isCountry()Checks if is country. -
isAdministrative
public boolean isAdministrative()Checks if is administrative.- Specified by:
isAdministrative
in interfaceGeocoding
- Returns:
- true, if is administrative
-
getConfidence
public int getConfidence()TOOD: convey a realistic confidence metric for what was actually matched. e.g. MGRS confidence when there are multiple interpretations may result in lower confidence or whenever the parser suspects there is a typo in the match or if the match contains items that are characteristic of false positives.- Specified by:
getConfidence
in interfaceGeocoding
- Returns:
- the confidence
-
addNearByPlace
Adds the near by place.- Parameters:
location
- the location
-
getNearByPlaces
Gets the near by places.- Returns:
- the near by places
-
setRelatedPlace
Sets the related place.- Parameters:
location
- the new related place
-
getRelatedPlace
Gets the related place.- Returns:
- the related place
-
getCountryCode
Gets the country code.- Specified by:
getCountryCode
in interfaceGeocoding
- Returns:
- null unless related place is set, then country code is inferred from related place.
-
setCountryCode
Sets the country code.- Specified by:
setCountryCode
in interfaceGeocoding
- Parameters:
cc
- the new country code
-
setCountry
Sets the country.- Specified by:
setCountry
in interfaceGeocoding
- Parameters:
c
- the new country
-
getAdmin1
Gets the admin 1. -
getAdmin2
Gets the admin 2. -
getFeatureClass
Gets the feature class.- Specified by:
getFeatureClass
in interfaceGeocoding
- Returns:
- "S"
-
getFeatureCode
Gets the feature code.- Specified by:
getFeatureCode
in interfaceGeocoding
- Returns:
- "COORD"
-
getPlaceID
Gets the place ID.- Specified by:
getPlaceID
in interfaceGeocoding
- Returns:
- "Place ID" -- normalized coordinate text
-
getPlaceName
Gets the place name.- Specified by:
getPlaceName
in interfaceGeocoding
- Returns:
- the place name is the coordinate as specified by the original data.
-
setPlaceName
Sets the place name.- Specified by:
setPlaceName
in interfaceGeocoding
- Parameters:
n
- the new place name
-
getMethod
Returns the exact pattern that matched. -
setMethod
This reuses TextMatch.pattern_id attr; Use get/setMethod() or pattern_id as needed. -
getLatitude
public double getLatitude()Gets the latitude.- Specified by:
getLatitude
in interfaceLatLon
- Returns:
- lat in degrees
-
getLatText
Gets the lat text.- Returns:
- text of the latitude
-
getLonText
Gets the lon text.- Returns:
- text of the longitude
-
getLongitude
public double getLongitude()Gets the longitude.- Specified by:
getLongitude
in interfaceLatLon
- Returns:
- lon in degrees
-
setLatitude
public void setLatitude(double y) Sets the latitude.- Specified by:
setLatitude
in interfaceLatLon
- Parameters:
y
- decimal latitude
-
setLongitude
public void setLongitude(double x) Sets the longitude.- Specified by:
setLongitude
in interfaceLatLon
- Parameters:
x
- the new longitude
-
getAdmin1Name
Null implementation -- Geocoding interface. Coordinates from XCoord do not automatically report name of admin boundaries.- Specified by:
getAdmin1Name
in interfaceGeocoding
- Returns:
- the admin 1 name
-
getAdmin2Name
Null implementation -- Geocoding interface Coordinates from XCoord do not automatically report name of admin boundaries.- Specified by:
getAdmin2Name
in interfaceGeocoding
- Returns:
- the admin 2 name
-
asPlace
Create a Place version of this coordinate -- that is, once we've found the coordinate match if the match data is no longer needed we can produce a geodetic Place from the TextMatch. This is helpful when you are more interested in the Place metadata, e.g. plot the TextMatch; enrich the TextMatch, etc But note, if you need match confidence, match offsets, etc. you retain this TextMatch instance- Returns:
- the place
-
hasCoordinate
public boolean hasCoordinate()Checks for coordinate.- Specified by:
hasCoordinate
in interfaceGeocoding
- Returns:
- true, if successful
-
getAdmin1PostalCode
State-level postal code, the corresponds usually to ADM1.- Specified by:
getAdmin1PostalCode
in interfaceGeocoding
- Returns:
- the admin 1 postal code
-
getPlacePostalCode
City-level postal code, that may be something like a zip. Thinking world-wide, not everyone calls these zipcodes, as in the US.- Specified by:
getPlacePostalCode
in interfaceGeocoding
- Returns:
- the place postal code
-
setAdmin1PostalCode
Sets the admin 1 postal code.- Parameters:
c
- the new admin 1 postal code
-
setPlacePostalCode
Sets the place postal code.- Parameters:
c
- the new place postal code
-
setConfidence
public void setConfidence(int c) Sets the confidence.- Specified by:
setConfidence
in interfaceGeocoding
- Parameters:
c
- the new confidence
-
evaluateInvalidPunct
Test punctuation separators.- Parameters:
fieldValues
-- Returns:
- true if pattern match contains asymmetric punctuation
- Throws:
NormalizationException
-