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
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
FieldsModifier and TypeFieldDescriptionstatic final String
property for connectTimeoutstatic final int
Distance threshold (in km), determines whether to use fe region or nearest place in the event titlestatic final String
Property for Geoserve distance thresholdstatic final String
Property for places endpoint urlstatic final String
Properties for readTimeoutstatic final String
property for regions endpoint urlFields 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
ConstructorsConstructorDescriptionEmpty constructor Do nothing, must be configured through bootstrapping before useOriginIndexerModule
(GeoservePlacesService geoservePlaces, GeoserveRegionsService geoserveRegions) Constructor -
Method Summary
Modifier and TypeMethodDescriptionazimuthToDirection
(double azimuth) Converts a decimal degree azimuth to a canonical compass directionvoid
Process configuration settings.formatEventTitle
(javax.json.JsonObject feature) Takes properties from feature and formats them into a stringint
getEventTitle
(BigDecimal latitude, 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 namegetProductSummary
(Product product) Create a ProductSummary from a Product.int
getSupportLevel
(Product product) This module provides a default level of support for any type of product.static void
Runs an origin indexer module and parses command line argumentsvoid
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 Details
-
PLACES_ENDPOINT_URL_PROPERTY
Property for places endpoint url- See Also:
-
REGIONS_ENDPOINT_URL_PROPERTY
property for regions endpoint url- See Also:
-
CONNECT_TIMEOUT_PROPERTY
property for connectTimeout- See Also:
-
READ_TIMEOUT_PROPERTY
Properties for readTimeout- See Also:
-
GEOSERVE_DISTANCE_THRESHOLD_PROPERTY
Property for Geoserve distance threshold- See Also:
-
DEFAULT_GEOSERVE_DISTANCE_THRESHOLD
public static final int DEFAULT_GEOSERVE_DISTANCE_THRESHOLDDistance 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
- GeoservePlacesServicegeoserveRegions
- GeoserveRegionsService
-
-
Method Details
-
getPlacesService
- Returns:
- The places service currently being used to return nearby places
-
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
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:
Exception
- if error occurs
-
getSupportLevel
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
Set the GeoservePlacesService to be used for subsequent calls to GeoServe places endpoint.- Parameters:
geoservePlaces
- The GeoservePlacesService to use
-
setRegionsService
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
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:
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 degreeslongitude
- event longitude in degrees- Returns:
- {String} event name
- Throws:
IOException
- if IO error occursException
-
formatEventTitle
Takes properties from feature and formats them into a string- Parameters:
feature
- feature to format- Returns:
- string with distance, direction, name, and admin
-
azimuthToDirection
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
Runs an origin indexer module and parses command line arguments- Parameters:
args
- command line arguments for an indexer- Throws:
Exception
- on error
-