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 Details

    • PLACES_ENDPOINT_URL_PROPERTY

      public static final String PLACES_ENDPOINT_URL_PROPERTY
      Property for places endpoint url
      See Also:
    • REGIONS_ENDPOINT_URL_PROPERTY

      public static final String REGIONS_ENDPOINT_URL_PROPERTY
      property for regions endpoint url
      See Also:
    • CONNECT_TIMEOUT_PROPERTY

      public static final String CONNECT_TIMEOUT_PROPERTY
      property for connectTimeout
      See Also:
    • READ_TIMEOUT_PROPERTY

      public static final String READ_TIMEOUT_PROPERTY
      Properties for readTimeout
      See Also:
    • GEOSERVE_DISTANCE_THRESHOLD_PROPERTY

      public static final String GEOSERVE_DISTANCE_THRESHOLD_PROPERTY
      Property for Geoserve distance threshold
      See Also:
    • 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:
  • Constructor Details

    • 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 Details

    • 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 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:
      Exception - if error occurs
    • getSupportLevel

      public int getSupportLevel(Product product)
      Description copied from class: DefaultIndexerModule
      This module provides a default level of support for any type of product.
      Specified by:
      getSupportLevel in interface IndexerModule
      Overrides:
      getSupportLevel in class DefaultIndexerModule
      Parameters:
      product - the product to test.
      Returns:
      IndexerModule.LEVEL_DEFAULT.
    • 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 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:
      Exception - if configuration exceptions occur.
    • getEventTitle

      public String getEventTitle(BigDecimal latitude, BigDecimal longitude) throws Exception, 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:
      IOException - if IO error occurs
      Exception
    • formatEventTitle

      public 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 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(String[] args) throws Exception
      Runs an origin indexer module and parses command line arguments
      Parameters:
      args - command line arguments for an indexer
      Throws:
      Exception - on error