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();
}
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;
}
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++;
}
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());
}
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);
}
}
Aggregations