Class OriginIndexerModule

  • All Implemented Interfaces:
    IndexerModule, Configurable

    public class OriginIndexerModule
    extends DefaultIndexerModule
    Class for summarizing "origin" type products during the indexing process. Specifically this implementation uses a GeoservePlacesService to augment the properties on the product to include a "title" property if one is not already present. This module may be configured with the following properties: `endpointUrl` `connectTimeout`, and `readTimeout`.
    • Field Detail

      • PLACES_ENDPOINT_URL_PROPERTY

        public static final java.lang.String PLACES_ENDPOINT_URL_PROPERTY
        Property for places endpoint url
        See Also:
        Constant Field Values
      • REGIONS_ENDPOINT_URL_PROPERTY

        public static final java.lang.String REGIONS_ENDPOINT_URL_PROPERTY
        property for regions endpoint url
        See Also:
        Constant Field Values
      • CONNECT_TIMEOUT_PROPERTY

        public static final java.lang.String CONNECT_TIMEOUT_PROPERTY
        property for connectTimeout
        See Also:
        Constant Field Values
      • READ_TIMEOUT_PROPERTY

        public static final java.lang.String READ_TIMEOUT_PROPERTY
        Properties for readTimeout
        See Also:
        Constant Field Values
      • GEOSERVE_DISTANCE_THRESHOLD_PROPERTY

        public static final java.lang.String GEOSERVE_DISTANCE_THRESHOLD_PROPERTY
        Property for Geoserve distance threshold
        See Also:
        Constant Field Values
      • DEFAULT_GEOSERVE_DISTANCE_THRESHOLD

        public static final int DEFAULT_GEOSERVE_DISTANCE_THRESHOLD
        Distance threshold (in km), determines whether to use fe region or nearest place in the event title
        See Also:
        Constant Field Values
    • Constructor Detail

      • OriginIndexerModule

        public OriginIndexerModule()
        Empty constructor Do nothing, must be configured through bootstrapping before use
      • OriginIndexerModule

        public OriginIndexerModule​(GeoservePlacesService geoservePlaces,
                                   GeoserveRegionsService geoserveRegions)
        Constructor
        Parameters:
        geoservePlaces - GeoservePlacesService
        geoserveRegions - GeoserveRegionsService
    • Method Detail

      • getPlacesService

        public GeoservePlacesService getPlacesService()
        Returns:
        The places service currently being used to return nearby places
      • getRegionsService

        public GeoserveRegionsService getRegionsService()
        Returns:
        The regions service currently being used to return fe regions
      • getDistanceThreshold

        public int getDistanceThreshold()
        Returns:
        The distance threshold currently being used to default to FE region
      • getProductSummary

        public ProductSummary getProductSummary​(Product product)
                                         throws java.lang.Exception
        Description copied from class: DefaultIndexerModule
        Create a ProductSummary from a Product. Uses the ProductSummary(Product) constructor, which copies product information. Checks whether product is within its authoritative region, and if so boosts preferredWeight by AUTHORITATIVE_WEIGHT.
        Specified by:
        getProductSummary in interface IndexerModule
        Overrides:
        getProductSummary in class DefaultIndexerModule
        Parameters:
        product - the product to summarize.
        Returns:
        ProductSummary for Product object.
        Throws:
        java.lang.Exception - if error occurs
      • setPlacesService

        public void setPlacesService​(GeoservePlacesService geoservePlaces)
        Set the GeoservePlacesService to be used for subsequent calls to GeoServe places endpoint.
        Parameters:
        geoservePlaces - The GeoservePlacesService to use
      • setRegionsService

        public void setRegionsService​(GeoserveRegionsService geoserveRegions)
        Set the geoserveRegions to be used for subsequent calls to GeoServe regions endpoint.
        Parameters:
        geoserveRegions - The GeoserveRegions to use
      • setDistanceThreshold

        public void setDistanceThreshold​(int threshold)
        Set the distance threshold to prefer fe region over nearst place in the event title
        Parameters:
        threshold - The distance threshold to use
      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Description copied from class: DefaultConfigurable
        Process configuration settings. Called before startup().
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class DefaultIndexerModule
        Parameters:
        config - the Config object with settings.
        Throws:
        java.lang.Exception - if configuration exceptions occur.
      • getEventTitle

        public java.lang.String getEventTitle​(java.math.BigDecimal latitude,
                                              java.math.BigDecimal longitude)
                                       throws java.lang.Exception,
                                              java.io.IOException
        Get the event title based on the name and location of the nearest place, or if the nearest place is outside of the distance threshold return the fe region name
        Parameters:
        latitude - event latitude in degrees
        longitude - event longitude in degrees
        Returns:
        {String} event name
        Throws:
        java.io.IOException - if IO error occurs
        java.lang.Exception
      • formatEventTitle

        public java.lang.String formatEventTitle​(javax.json.JsonObject feature)
        Takes properties from feature and formats them into a string
        Parameters:
        feature - feature to format
        Returns:
        string with distance, direction, name, and admin
      • azimuthToDirection

        public java.lang.String azimuthToDirection​(double azimuth)
        Converts a decimal degree azimuth to a canonical compass direction
        Parameters:
        azimuth - The degrees azimuth to be converted
        Returns:
        {String} The canonical compass direction for the given input azimuth
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception