## gov.usgs.earthquake.event
Class EventIDAssociator

    java.lang.Object
      gov.usgs.earthquake.event.EventIDAssociator

    public class EventIDAssociator

extends java.lang.Object

Looks for nearby events in the default association window. Will be used by ConvertEDR for determining event associations.

Field Summary
`static java.math.BigDecimal` `DEFAULT_DEPTH_DIFFERENCE`
`static java.math.BigDecimal` `DEFAULT_LOCATION_DIFFERENCE`
`static java.math.BigDecimal` `DEFAULT_MAGNITUDE_DIFFERENCE`
`static java.lang.String` `DEFAULT_SERVICE_URL`
`static java.math.BigDecimal` `DEFAULT_TIME_DIFFERENCE`
`static java.lang.String` `DEPTH_ARGUMENT`
`static java.lang.String` `DEPTH_CHECK_ARGUMENT`
`static java.lang.String` `DEPTH_DIFFERENCE_ARGUMENT`
`static int` `EXIT_EVENT_NOT_FOUND`
`static int` `EXIT_EVENT_NOT_SANE`
`static int` `EXIT_MULTIPLE_EVENTS_FOUND`
`static int` `EXIT_SUCCESS`
`static int` `EXIT_USAGE`
`static java.math.BigDecimal` `KILOMETERS_PER_DEGREE`
`static java.lang.String` `LATITUDE_ARGUMENT`
`static java.lang.String` `LOCATION_CHECK_ARGUMENT`
`static java.lang.String` `LOCATION_DIFFERENCE_ARGUMENT`
`static java.lang.String` `LONGITUDE_ARGUMENT`
`static java.lang.String` `MAGNITUDE_ARGUMENT`
`static java.lang.String` `MAGNITUDE_CHECK_ARGUMENT`
`static java.lang.String` `MAGNITUDE_DIFFERENCE_ARGUMENT`
`static java.lang.String` `NETWORK_ARGUMENT`
`static java.lang.String` `SERVICE_URL_ARGUMENT`
`static java.lang.String` `TIME_ARGUMENT`
`static java.lang.String` `TIME_CHECK_ARGUMENT`
`static java.lang.String` `TIME_DIFFERENCE_ARGUMENT`

Constructor Summary
`EventIDAssociator()`
`EventIDAssociator(EventWebService service, EventComparison nearbyCriteria, EventSanityCheck sanityCheck)` Create a new EventIDAssociator.

Method Summary
`protected java.lang.String` `formatOutput(EventInfo referenceEvent, java.lang.String network, java.util.List<JsonEventInfo> events)` Format main method output based on referenceEvent, search network, and list of found events.
`EventSanityCheck` `getEventSanityCheck()`
`EventWebService` `getEventWebService()`
`protected int` `getExitCode(java.util.List<JsonEventInfo> events)` Determine main method exit code based on list of events.
`EventComparison` `getNearbyCriteria()`
`java.util.List<JsonEvent>` `getNearbyEvents(java.util.Date time, java.math.BigDecimal latitude, java.math.BigDecimal longitude, java.math.BigDecimal depth, java.math.BigDecimal magnitude, java.lang.String network)` Search for nearby events using latitude, longitude, and time.
`java.util.List<JsonEvent>` `getNearbyEvents(EventInfo info, java.lang.String network)` Search for nearby events using an EventInfo object.
`java.util.List<JsonEventInfo>` `getSortedNearbyEvents(EventInfo info, java.lang.String network)` Get nearby events, and sort them based on distance (closest first) from the reference event.
`static void` `main(java.lang.String[] args)`
`protected static EventIDAssociator` `parseEventIDAssociator(java.lang.String[] args)`
`protected static java.lang.String` `parseNetwork(java.lang.String[] args)`
`protected static EventInfo` `parseReferenceEvent(java.lang.String[] args)`
`void` `setEventSanityCheck(EventSanityCheck sanityCheck)`
`void` `setEventWebService(EventWebService service)`
`void` `setNearbyCriteria(EventComparison nearbyCriteria)`
`java.util.List<JsonEventInfo>` `sortEvents(java.util.List<JsonEvent> events, EventInfo referenceEvent)` Sort events based on "distance" from reference event.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### KILOMETERS_PER_DEGREE

    public static final java.math.BigDecimal KILOMETERS_PER_DEGREE

### DEFAULT_TIME_DIFFERENCE

    public static final java.math.BigDecimal DEFAULT_TIME_DIFFERENCE

### DEFAULT_LOCATION_DIFFERENCE

    public static final java.math.BigDecimal DEFAULT_LOCATION_DIFFERENCE

### DEFAULT_MAGNITUDE_DIFFERENCE

    public static final java.math.BigDecimal DEFAULT_MAGNITUDE_DIFFERENCE

### DEFAULT_DEPTH_DIFFERENCE

    public static final java.math.BigDecimal DEFAULT_DEPTH_DIFFERENCE

### EXIT_SUCCESS

    public static final int EXIT_SUCCESS

See Also:
  Constant Field Values

### EXIT_EVENT_NOT_FOUND

    public static final int EXIT_EVENT_NOT_FOUND

See Also:
  Constant Field Values

### EXIT_EVENT_NOT_SANE

    public static final int EXIT_EVENT_NOT_SANE

See Also:
  Constant Field Values

### EXIT_MULTIPLE_EVENTS_FOUND

    public static final int EXIT_MULTIPLE_EVENTS_FOUND

See Also:
  Constant Field Values

### EXIT_USAGE

    public static final int EXIT_USAGE

See Also:
  Constant Field Values

### SERVICE_URL_ARGUMENT

    public static final java.lang.String SERVICE_URL_ARGUMENT

See Also:
  Constant Field Values

### DEFAULT_SERVICE_URL

    public static final java.lang.String DEFAULT_SERVICE_URL

See Also:
  Constant Field Values

### TIME_ARGUMENT

    public static final java.lang.String TIME_ARGUMENT

See Also:
  Constant Field Values

### LATITUDE_ARGUMENT

    public static final java.lang.String LATITUDE_ARGUMENT

See Also:
  Constant Field Values

### LONGITUDE_ARGUMENT

    public static final java.lang.String LONGITUDE_ARGUMENT

See Also:
  Constant Field Values

### DEPTH_ARGUMENT

    public static final java.lang.String DEPTH_ARGUMENT

See Also:
  Constant Field Values

### MAGNITUDE_ARGUMENT

    public static final java.lang.String MAGNITUDE_ARGUMENT

See Also:
  Constant Field Values

### NETWORK_ARGUMENT

    public static final java.lang.String NETWORK_ARGUMENT

See Also:
  Constant Field Values

### TIME_DIFFERENCE_ARGUMENT

    public static final java.lang.String TIME_DIFFERENCE_ARGUMENT

See Also:
  Constant Field Values

### LOCATION_DIFFERENCE_ARGUMENT

    public static final java.lang.String LOCATION_DIFFERENCE_ARGUMENT

See Also:
  Constant Field Values

### DEPTH_DIFFERENCE_ARGUMENT

    public static final java.lang.String DEPTH_DIFFERENCE_ARGUMENT

See Also:
  Constant Field Values

### MAGNITUDE_DIFFERENCE_ARGUMENT

    public static final java.lang.String MAGNITUDE_DIFFERENCE_ARGUMENT

See Also:
  Constant Field Values

### TIME_CHECK_ARGUMENT

    public static final java.lang.String TIME_CHECK_ARGUMENT

See Also:
  Constant Field Values

### LOCATION_CHECK_ARGUMENT

    public static final java.lang.String LOCATION_CHECK_ARGUMENT

See Also:
  Constant Field Values

### DEPTH_CHECK_ARGUMENT

    public static final java.lang.String DEPTH_CHECK_ARGUMENT

See Also:
  Constant Field Values

### MAGNITUDE_CHECK_ARGUMENT

    public static final java.lang.String MAGNITUDE_CHECK_ARGUMENT

See Also:
  Constant Field Values

Constructor Detail

### EventIDAssociator

    public EventIDAssociator()
                      throws java.net.MalformedURLException

Throws:
  `java.net.MalformedURLException`

### EventIDAssociator

    public EventIDAssociator(EventWebService service,
                             EventComparison nearbyCriteria,
                             EventSanityCheck sanityCheck)

  Create a new EventIDAssociator.

  Parameters:
    `service` - the event webservice to use.

Method Detail

### getNearbyEvents

    public java.util.List<JsonEvent> getNearbyEvents(java.util.Date time,
                                                     java.math.BigDecimal latitude,
                                                     java.math.BigDecimal longitude,
                                                     java.math.BigDecimal depth,
                                                     java.math.BigDecimal magnitude,
                                                     java.lang.String network)
                                              throws java.lang.Exception

  Search for nearby events using latitude, longitude, and time.

  Parameters:
    `latitude` - the latitude.
    `longitude` - the longitude.
    `time` - the time.
  Returns:
    a list of nearby events.
  Throws:
    `java.lang.Exception`

### getNearbyEvents

    public java.util.List<JsonEvent> getNearbyEvents(EventInfo info,
                                                     java.lang.String network)
                                              throws java.lang.Exception

  Search for nearby events using an EventInfo object.

  Parameters:
    `info` - used for latitude, longitude, time.
    `network` - search for events from a specific network, null for all networks.
  Returns:
  Throws:
    `java.lang.Exception`

### sortEvents

    public java.util.List<JsonEventInfo> sortEvents(java.util.List<JsonEvent> events,
                                                    EventInfo referenceEvent)

  Sort events based on "distance" from reference event.

  Parameters:
    `events` - events to sort.
    `referenceEvent` - event used for comparison.
  Returns:
    sorted list of JsonEventInfo objects, with EventComparison and Distance filled in.

### getSortedNearbyEvents

    public java.util.List<JsonEventInfo> getSortedNearbyEvents(EventInfo info,
                                                               java.lang.String network)
                                                        throws java.lang.Exception

  Get nearby events, and sort them based on distance (closest first) from the reference event.

  Parameters:
    `info` - the reference event information.
    `network` - the network to search, or null for all.
  Returns:
    a sorted list of nearby events, closest first.
  Throws:
    `java.lang.Exception`

### main

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

  Throws:
    `java.lang.Exception`

### parseReferenceEvent

    protected static EventInfo parseReferenceEvent(java.lang.String[] args)

### parseNetwork

    protected static java.lang.String parseNetwork(java.lang.String[] args)

### parseEventIDAssociator

    protected static EventIDAssociator parseEventIDAssociator(java.lang.String[] args)
                                                       throws java.net.MalformedURLException

  Throws:
    `java.net.MalformedURLException`

### getExitCode

    protected int getExitCode(java.util.List<JsonEventInfo> events)

  Determine main method exit code based on list of events.

  Parameters:
    `events` - list of events
  Returns:
    exit code.

### formatOutput

    protected java.lang.String formatOutput(EventInfo referenceEvent,
                                            java.lang.String network,
                                            java.util.List<JsonEventInfo> events)

  Format main method output based on referenceEvent, search network, and list of found events.

  Parameters:
    `referenceEvent` - the reference event information (search).
    `network` - network that was searched
    `events` - found events
  Returns:
    geojson formatted output.

### getEventWebService

    public EventWebService getEventWebService()

### setEventWebService

    public void setEventWebService(EventWebService service)

### getNearbyCriteria

    public EventComparison getNearbyCriteria()

### setNearbyCriteria

    public void setNearbyCriteria(EventComparison nearbyCriteria)

### getEventSanityCheck

    public EventSanityCheck getEventSanityCheck()

### setEventSanityCheck

    public void setEventSanityCheck(EventSanityCheck sanityCheck)