Class GeocoordMatch
- java.lang.Object
-
- org.opensextant.extraction.TextEntity
-
- org.opensextant.extraction.TextMatch
-
- org.opensextant.extractors.xcoord.GeocoordMatch
-
public class GeocoordMatch extends TextMatch implements Geocoding
GeocoordMatch holds all the annotation data for the actual raw and normalized coordinate.- Author:
- ubaldino
- See Also:
base class
-
-
Field Summary
Fields Modifier and Type Field Description int
cce_family_id
The cce family id.java.lang.String
cce_variant
The cce variant.protected java.lang.String
coord_text
Just the coordinate text normalized.protected int
dashCount
count dashes other than hemispheres, +/-.protected java.util.List<GeocoordMatch>
interpretations
The interpretations.protected java.lang.String
lat_text
The lat text.protected java.lang.String
lon_text
The lon text.protected int
offsetSeparator
The offset separator.GeocoordPrecision
precision
inherent precision of the coordinate matched.protected java.lang.String
separator
The separator.java.lang.String[]
separators
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
-
-
Constructor Summary
Constructors Constructor Description GeocoordMatch(int x1, int x2)
a TextMatch that represents a coordinate found in free text.
-
Method Summary
Modifier and Type Method Description void
addNearByPlace(Place location)
Adds the near by place.void
addOtherInterpretation(GeocoordMatch m2)
The current instance is the main match.Place
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
copyMetadata(GeocoordMatch m)
Copy metadata.boolean
evaluateInvalidDashes(java.util.Map<java.lang.String,java.lang.String> fields)
Evaluate DMS patterns only...java.lang.String
formatLatitude()
Format latitude.java.lang.String
formatLongitude()
Format longitude.java.lang.String
formatPrecision()
Precision value is in Meters.java.lang.String
getAdmin1()
Gets the admin 1.java.lang.String
getAdmin1Name()
Null implementation -- Geocoding interface.java.lang.String
getAdmin1PostalCode()
State-level postal code, the corresponds usually to ADM1.java.lang.String
getAdmin2()
Gets the admin 2.java.lang.String
getAdmin2Name()
Null implementation -- Geocoding interface Coordinates from XCoord do not automatically report name of admin boundaries.java.lang.String
getAdminName()
GeoBase interface.int
getConfidence()
TOOD: convey a realistic confidence metric for what was actually matched.java.lang.String
getCountryCode()
Gets the country code.java.lang.String
getFeatureClass()
Gets the feature class.java.lang.String
getFeatureCode()
Gets the feature code.double
getLatitude()
Gets the latitude.java.lang.String
getLatText()
Gets the lat text.double
getLongitude()
Gets the longitude.java.lang.String
getLonText()
Gets the lon text.java.lang.String
getMethod()
Returns the exact pattern that matched.java.util.List<Place>
getNearByPlaces()
Gets the near by places.java.util.List<GeocoordMatch>
getOtherInterpretations()
Gets the other interpretations.java.lang.String
getPlaceID()
Gets the place ID.java.lang.String
getPlaceName()
Gets the place name.java.lang.String
getPlacePostalCode()
City-level postal code, that may be something like a zip.int
getPrecision()
Gets the precision.Place
getRelatedPlace()
Gets the related place.java.lang.String
gridzone()
Identifies the 100KM quad in which this point is contained.boolean
hasCoordinate()
Checks for coordinate.boolean
hasMinutes()
Checks for minutes.boolean
hasOtherIterpretations()
Checks for other interpretations.boolean
hasSeconds()
Checks for seconds.boolean
isAdministrative()
Checks if is administrative.boolean
isBalanced()
Checks if is balanced.boolean
isCoordinate()
Note the coordinate nature of this TextMatch/Geocoding takes precedence over other flags isPlace, isCountry, etc.boolean
isCountry()
Checks if is country.boolean
isPlace()
Checks if is place.boolean
isZero()
Convenience method for determining if XY = 0,0.void
setAdmin1PostalCode(java.lang.String c)
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
setCountry(Country c)
Sets the country.void
setCountryCode(java.lang.String cc)
Sets the country code.void
setLatitude(double y)
Sets the latitude.void
setLatitude(java.lang.String decval)
Sets the latitude.void
setLatLon(LatLon yx)
If you are given a vetted XY, use that.void
setLongitude(double x)
Sets the longitude.void
setLongitude(java.lang.String decval)
Sets the longitude.void
setMethod(java.lang.String patId)
This reuses TextMatch.pattern_id attr; Use get/setMethod() or pattern_id as needed.void
setPlaceName(java.lang.String n)
Sets the place name.void
setPlacePostalCode(java.lang.String c)
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(java.util.Map<java.lang.String,TextEntity> fields)
Sets the separator.java.lang.String
toMGRS()
Convert the current coordinate to MGRS.-
Methods inherited from class org.opensextant.extraction.TextMatch
copy, defaultMatchId, 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 Detail
-
coord_text
protected java.lang.String coord_text
Just the coordinate text normalized.
-
lat_text
protected java.lang.String lat_text
The lat text.
-
lon_text
protected java.lang.String lon_text
The lon text.
-
cce_family_id
public int cce_family_id
The cce family id.
-
cce_variant
public java.lang.String cce_variant
The cce variant.
-
precision
public GeocoordPrecision precision
inherent precision of the coordinate matched.
-
dashCount
protected int dashCount
count dashes other than hemispheres, +/-.
-
separators
public final java.lang.String[] separators
The separators.
-
offsetSeparator
protected int offsetSeparator
The offset separator.
-
separator
protected java.lang.String separator
The separator.
-
interpretations
protected java.util.List<GeocoordMatch> interpretations
The interpretations.
-
-
Method Detail
-
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
public void setLatLon(LatLon yx)
If you are given a vetted XY, use that.- Parameters:
yx
- latlon
-
getAdminName
public java.lang.String 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
public void copyMetadata(GeocoordMatch m)
Copy metadata.- Parameters:
m
- the match to copy
-
setCoordinate
public void setCoordinate(DMSOrdinate _lat, DMSOrdinate _lon)
Set the ordinates back on the match; general filters are assessed.- Parameters:
_lat
- lat obj_lon
- lon obj
-
setSeparator
protected void setSeparator(java.util.Map<java.lang.String,TextEntity> fields)
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
public boolean evaluateInvalidDashes(java.util.Map<java.lang.String,java.lang.String> fields) throws NormalizationException
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
public void setLatitude(java.lang.String decval)
Sets the latitude.- Parameters:
decval
- decimal lat
-
setLongitude
public void setLongitude(java.lang.String decval)
Sets the longitude.- Parameters:
decval
- decimal lon
-
formatLatitude
public java.lang.String formatLatitude()
Format latitude.- Returns:
- formatted lat based on lat precision
-
formatLongitude
public java.lang.String formatLongitude()
Format longitude.- Returns:
- formatted longitude base on lon precision
-
formatPrecision
public java.lang.String 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
public java.lang.String toMGRS()
Convert the current coordinate to MGRS.- Returns:
- string version of MGRS
-
gridzone
public java.lang.String 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
public void addOtherInterpretation(GeocoordMatch m2)
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
public java.util.List<GeocoordMatch> 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
public void addNearByPlace(Place location)
Adds the near by place.- Parameters:
location
- the location
-
getNearByPlaces
public java.util.List<Place> getNearByPlaces()
Gets the near by places.- Returns:
- the near by places
-
setRelatedPlace
public void setRelatedPlace(Place location)
Sets the related place.- Parameters:
location
- the new related place
-
getRelatedPlace
public Place getRelatedPlace()
Gets the related place.- Returns:
- the related place
-
getCountryCode
public java.lang.String 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
public void setCountryCode(java.lang.String cc)
Sets the country code.- Specified by:
setCountryCode
in interfaceGeocoding
- Parameters:
cc
- the new country code
-
setCountry
public void setCountry(Country c)
Sets the country.- Specified by:
setCountry
in interfaceGeocoding
- Parameters:
c
- the new country
-
getAdmin1
public java.lang.String getAdmin1()
Gets the admin 1.
-
getAdmin2
public java.lang.String getAdmin2()
Gets the admin 2.
-
getFeatureClass
public java.lang.String getFeatureClass()
Gets the feature class.- Specified by:
getFeatureClass
in interfaceGeocoding
- Returns:
- "S"
-
getFeatureCode
public java.lang.String getFeatureCode()
Gets the feature code.- Specified by:
getFeatureCode
in interfaceGeocoding
- Returns:
- "COORD"
-
getPlaceID
public java.lang.String getPlaceID()
Gets the place ID.- Specified by:
getPlaceID
in interfaceGeocoding
- Returns:
- "Place ID" -- normalized coordinate text
-
getPlaceName
public java.lang.String getPlaceName()
Gets the place name.- Specified by:
getPlaceName
in interfaceGeocoding
- Returns:
- the place name is the coordinate as specified by the original data.
-
setPlaceName
public void setPlaceName(java.lang.String n)
Sets the place name.- Specified by:
setPlaceName
in interfaceGeocoding
- Parameters:
n
- the new place name
-
getMethod
public java.lang.String getMethod()
Returns the exact pattern that matched.
-
setMethod
public void setMethod(java.lang.String patId)
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
public java.lang.String getLatText()
Gets the lat text.- Returns:
- text of the latitude
-
getLonText
public java.lang.String 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
public java.lang.String 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
public java.lang.String 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
public Place 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
public java.lang.String getAdmin1PostalCode()
State-level postal code, the corresponds usually to ADM1.- Specified by:
getAdmin1PostalCode
in interfaceGeocoding
- Returns:
- the admin 1 postal code
-
getPlacePostalCode
public java.lang.String 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
public void setAdmin1PostalCode(java.lang.String c)
Sets the admin 1 postal code.- Parameters:
c
- the new admin 1 postal code
-
setPlacePostalCode
public void setPlacePostalCode(java.lang.String c)
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
-
-