Search in sources :

Example 6 with GWTLatLng

use of org.opennms.features.poller.remote.gwt.client.GWTLatLng in project opennms by OpenNMS.

the class DefaultLocationDataService method updateGeolocations.

/**
 * <p>updateGeolocations</p>
 */
public void updateGeolocations() {
    LOG.info("geolocating monitoring location definitions");
    final Collection<OnmsMonitoringLocation> definitions = m_monitoringLocationDao.findAll();
    for (final OnmsMonitoringLocation def : definitions) {
        final GWTLatLng latLng = getLatLng(def, true);
        if (latLng != null) {
            def.setLatitude(latLng.getLatitude().floatValue());
            def.setLongitude(latLng.getLongitude().floatValue());
            if (m_save) {
                m_monitoringLocationDao.saveOrUpdate(def);
            }
        }
    }
    LOG.info("finished geolocating monitoring location definitions");
    updateGeolocationsComplete();
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 7 with GWTLatLng

use of org.opennms.features.poller.remote.gwt.client.GWTLatLng in project opennms by OpenNMS.

the class DefaultLocationDataService method getLocationInfo.

private LocationInfo getLocationInfo(final OnmsMonitoringLocation def, final StatusDetails monitorStatus) {
    GWTLatLng latLng = getLatLng(def, false);
    if (latLng == null) {
        LOG.debug("no geolocation or coordinates found, using OpenNMS World HQ");
        latLng = new GWTLatLng(35.715751, -79.16262);
    }
    final GWTMarkerState state = new GWTMarkerState(def.getLocationName(), latLng, Status.UNKNOWN);
    Set<String> tags = new TreeSet<String>();
    if (def.getTags() != null) {
        for (String tag : def.getTags()) {
            tags.add(tag);
        }
    }
    final LocationInfo locationInfo = new LocationInfo(def.getLocationName(), def.getMonitoringArea(), def.getGeolocation(), latLng.getCoordinates(), def.getPriority(), state, null, tags);
    state.setStatus(monitorStatus.getStatus());
    locationInfo.setStatusDetails(monitorStatus);
    // LOG.debug("getLocationInfo({}) returning {}", def.getLocationName(), locationInfo);
    return locationInfo;
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) TreeSet(java.util.TreeSet) GWTMarkerState(org.opennms.features.poller.remote.gwt.client.GWTMarkerState) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Example 8 with GWTLatLng

use of org.opennms.features.poller.remote.gwt.client.GWTLatLng in project opennms by OpenNMS.

the class GeocodingHandler method handle.

/**
 * <p>handle</p>
 *
 * @param def a {@link OnmsMonitoringLocation} object.
 */
@Override
public void handle(final OnmsMonitoringLocation def) {
    final GWTLatLng latLng = m_locationDataService.getLatLng(def, false);
    if (latLng != null) {
        def.setLatitude(latLng.getLatitude().floatValue());
        def.setLongitude(latLng.getLongitude().floatValue());
    }
    final Date now = new Date();
    if (now.getTime() - m_date.getTime() >= 500) {
        m_eventService.addEventUserSpecific(new GeocodingUpdatingRemoteEvent(m_count, m_size));
        LOG.debug("initializing locations ({}/{})", m_count, m_size);
        m_date = now;
    }
    m_count++;
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) GeocodingUpdatingRemoteEvent(org.opennms.features.poller.remote.gwt.client.remoteevents.GeocodingUpdatingRemoteEvent) Date(java.util.Date)

Example 9 with GWTLatLng

use of org.opennms.features.poller.remote.gwt.client.GWTLatLng in project opennms by OpenNMS.

the class BoundsBuilderTest method testAddOnePoint.

@Test
public void testAddOnePoint() {
    BoundsBuilder bldr = new BoundsBuilder();
    GWTLatLng origin = new GWTLatLng(0.0, 0.0);
    bldr.extend(origin);
    assertEquals(new GWTBounds(origin, origin), bldr.getBounds());
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) GWTBounds(org.opennms.features.poller.remote.gwt.client.GWTBounds) BoundsBuilder(org.opennms.features.poller.remote.gwt.client.utils.BoundsBuilder) Test(org.junit.Test)

Example 10 with GWTLatLng

use of org.opennms.features.poller.remote.gwt.client.GWTLatLng in project opennms by OpenNMS.

the class TestMapquestGeocoder method testSuccessfulLookup.

@Test
public void testSuccessfulLookup() throws Exception {
    if (shouldRun()) {
        Geocoder geocoder = new MapquestGeocoder();
        final GWTLatLng remote = geocoder.geocode("220 Chatham Business Dr, Pittsboro, NC 27312");
        final GWTLatLng local = new GWTLatLng(35.71735, -79.16181);
        assertEquals(local.hashCode(), remote.hashCode());
        assertEquals(local, remote);
    }
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) Test(org.junit.Test)

Aggregations

GWTLatLng (org.opennms.features.poller.remote.gwt.client.GWTLatLng)10 Test (org.junit.Test)4 InputStream (java.io.InputStream)2 ElementTree (net.simon04.jelementtree.ElementTree)2 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)2 Date (java.util.Date)1 TreeSet (java.util.TreeSet)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 GWTBounds (org.opennms.features.poller.remote.gwt.client.GWTBounds)1 GWTMarkerState (org.opennms.features.poller.remote.gwt.client.GWTMarkerState)1 LocationInfo (org.opennms.features.poller.remote.gwt.client.location.LocationInfo)1 GeocodingUpdatingRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.GeocodingUpdatingRemoteEvent)1 BoundsBuilder (org.opennms.features.poller.remote.gwt.client.utils.BoundsBuilder)1 GeocoderException (org.opennms.features.poller.remote.gwt.server.geocoding.GeocoderException)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1 Transactional (org.springframework.transaction.annotation.Transactional)1