Package gov.usgs.earthquake.origin
Class OriginIndexerModule
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.indexer.DefaultIndexerModule
-
- gov.usgs.earthquake.origin.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 Summary
Fields Modifier and Type Field Description static java.lang.String
CONNECT_TIMEOUT_PROPERTY
property for connectTimeoutstatic int
DEFAULT_GEOSERVE_DISTANCE_THRESHOLD
Distance threshold (in km), determines whether to use fe region or nearest place in the event titlestatic java.lang.String
GEOSERVE_DISTANCE_THRESHOLD_PROPERTY
Property for Geoserve distance thresholdstatic java.lang.String
PLACES_ENDPOINT_URL_PROPERTY
Property for places endpoint urlstatic java.lang.String
READ_TIMEOUT_PROPERTY
Properties for readTimeoutstatic java.lang.String
REGIONS_ENDPOINT_URL_PROPERTY
property for regions endpoint url-
Fields inherited from class gov.usgs.earthquake.indexer.DefaultIndexerModule
ANSS_CONTRIBUTOR_WEIGHT, AUTHORITATIVE_EVENT_WEIGHT, AUTHORITATIVE_WEIGHT, DEFAULT_PREFERRED_WEIGHT, IGNORE_REGIONS_PROPERTY, NEIC_CONTRIBUTOR_WEIGHT, SAME_SOURCE_WEIGHT
-
Fields inherited from interface gov.usgs.earthquake.indexer.IndexerModule
LEVEL_DEFAULT, LEVEL_SUPPORTED, LEVEL_UNSUPPORTED
-
-
Constructor Summary
Constructors Constructor Description OriginIndexerModule()
Empty constructor Do nothing, must be configured through bootstrapping before useOriginIndexerModule(GeoservePlacesService geoservePlaces, GeoserveRegionsService geoserveRegions)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
azimuthToDirection(double azimuth)
Converts a decimal degree azimuth to a canonical compass directionvoid
configure(Config config)
Process configuration settings.java.lang.String
formatEventTitle(javax.json.JsonObject feature)
Takes properties from feature and formats them into a stringint
getDistanceThreshold()
java.lang.String
getEventTitle(java.math.BigDecimal latitude, java.math.BigDecimal longitude)
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 nameGeoservePlacesService
getPlacesService()
ProductSummary
getProductSummary(Product product)
Create a ProductSummary from a Product.GeoserveRegionsService
getRegionsService()
int
getSupportLevel(Product product)
This module provides a default level of support for any type of product.static void
main(java.lang.String[] args)
void
setDistanceThreshold(int threshold)
Set the distance threshold to prefer fe region over nearst place in the event titlevoid
setPlacesService(GeoservePlacesService geoservePlaces)
Set the GeoservePlacesService to be used for subsequent calls to GeoServe places endpoint.void
setRegionsService(GeoserveRegionsService geoserveRegions)
Set the geoserveRegions to be used for subsequent calls to GeoServe regions endpoint.-
Methods inherited from class gov.usgs.earthquake.indexer.DefaultIndexerModule
getBaseProductType, getIgnoreRegions, getPreferredWeight, getSignatureVerifier, setSignatureVerifier
-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName, shutdown, startup
-
-
-
-
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
- GeoservePlacesServicegeoserveRegions
- 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 interfaceIndexerModule
- Overrides:
getProductSummary
in classDefaultIndexerModule
- Parameters:
product
- the product to summarize.- Returns:
- ProductSummary for Product object.
- Throws:
java.lang.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 interfaceIndexerModule
- Overrides:
getSupportLevel
in classDefaultIndexerModule
- 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 java.lang.Exception
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultIndexerModule
- 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 degreeslongitude
- event longitude in degrees- Returns:
- {String} event name
- Throws:
java.io.IOException
- if IO error occursjava.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
-
-