Class GeocoordMatch

  • All Implemented Interfaces:
    Geocoding, LatLon

    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 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.
    • Constructor Detail

      • GeocoordMatch

        public GeocoordMatch​(int x1,
                             int x2)
        a TextMatch that represents a coordinate found in free text.
    • 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 interface Geocoding
        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 interface Geocoding
        Returns:
        int number of whole meters of precision
      • setPrecision

        public void setPrecision​(int m)
        Sets the precision.
        Specified by:
        setPrecision in interface Geocoding
        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.
        Specified by:
        isPlace in interface Geocoding
        Returns:
        true. a Coordinate is a 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 interface Geocoding
        Returns:
        true.
      • isCountry

        public boolean isCountry()
        Checks if is country.
        Specified by:
        isCountry in interface Geocoding
        Returns:
        false. coordinates are not country objects.
      • isAdministrative

        public boolean isAdministrative()
        Checks if is administrative.
        Specified by:
        isAdministrative in interface Geocoding
        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 interface Geocoding
        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 interface Geocoding
        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 interface Geocoding
        Parameters:
        cc - the new country code
      • setCountry

        public void setCountry​(Country c)
        Sets the country.
        Specified by:
        setCountry in interface Geocoding
        Parameters:
        c - the new country
      • getAdmin1

        public java.lang.String getAdmin1()
        Gets the admin 1.
        Specified by:
        getAdmin1 in interface Geocoding
        Returns:
        null unless related place is set, then ADM1 code is inferred from related place.
      • getAdmin2

        public java.lang.String getAdmin2()
        Gets the admin 2.
        Specified by:
        getAdmin2 in interface Geocoding
        Returns:
        null
      • getFeatureClass

        public java.lang.String getFeatureClass()
        Gets the feature class.
        Specified by:
        getFeatureClass in interface Geocoding
        Returns:
        "S"
      • getFeatureCode

        public java.lang.String getFeatureCode()
        Gets the feature code.
        Specified by:
        getFeatureCode in interface Geocoding
        Returns:
        "COORD"
      • getPlaceID

        public java.lang.String getPlaceID()
        Gets the place ID.
        Specified by:
        getPlaceID in interface Geocoding
        Returns:
        "Place ID" -- normalized coordinate text
      • getPlaceName

        public java.lang.String getPlaceName()
        Gets the place name.
        Specified by:
        getPlaceName in interface Geocoding
        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 interface Geocoding
        Parameters:
        n - the new place name
      • getMethod

        public java.lang.String getMethod()
        Returns the exact pattern that matched.
        Specified by:
        getMethod in interface Geocoding
        Returns:
        Pattern ID
      • setMethod

        public void setMethod​(java.lang.String patId)
        This reuses TextMatch.pattern_id attr; Use get/setMethod() or pattern_id as needed.
        Specified by:
        setMethod in interface Geocoding
        Parameters:
        patId - pattern ID
      • getLatitude

        public double getLatitude()
        Gets the latitude.
        Specified by:
        getLatitude in interface LatLon
        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 interface LatLon
        Returns:
        lon in degrees
      • setLatitude

        public void setLatitude​(double y)
        Sets the latitude.
        Specified by:
        setLatitude in interface LatLon
        Parameters:
        y - decimal latitude
      • setLongitude

        public void setLongitude​(double x)
        Sets the longitude.
        Specified by:
        setLongitude in interface LatLon
        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 interface Geocoding
        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 interface Geocoding
        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 interface Geocoding
        Returns:
        true, if successful
      • getAdmin1PostalCode

        public java.lang.String getAdmin1PostalCode()
        State-level postal code, the corresponds usually to ADM1.
        Specified by:
        getAdmin1PostalCode in interface Geocoding
        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 interface Geocoding
        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 interface Geocoding
        Parameters:
        c - the new confidence