use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.
the class LocationItemTest method testDistance.
@Test
public void testDistance() {
PointType pointParis = new PointType("48.8566140,2.3522219");
PointType pointBerlin = new PointType("52.5200066,13.4049540");
LocationItem locationParis = new LocationItem("paris");
locationParis.setState(pointParis);
LocationItem locationBerlin = new LocationItem("berlin");
locationBerlin.setState(pointBerlin);
DecimalType distance = locationParis.distanceFrom(locationParis);
assertEquals(distance.intValue(), 0);
double parisBerlin = locationParis.distanceFrom(locationBerlin).doubleValue();
assertEquals(parisBerlin, 878400, 50);
}
use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.
the class I18nProviderImplTest method assertThatDefaultLocaleWillBeUsed.
@Test
public void assertThatDefaultLocaleWillBeUsed() {
i18nProviderImpl.modified(new Hashtable<String, Object>());
PointType location = i18nProviderImpl.getLocation();
Locale setLocale = i18nProviderImpl.getLocale();
assertNull(location);
assertThat(i18nProviderImpl.getTimeZone(), is(TimeZone.getDefault().toZoneId()));
assertThat(setLocale, is(Locale.getDefault()));
}
use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.
the class I18nProviderImplTest method assertThatDefaultLocaleWillBeUsedAndLocationIsSet.
@Test
public void assertThatDefaultLocaleWillBeUsedAndLocationIsSet() {
Hashtable<String, Object> conf = new Hashtable<>();
conf.put(LOCATION, LOCATION_DARMSTADT);
i18nProviderImpl.modified(conf);
PointType location = i18nProviderImpl.getLocation();
Locale setLocale = i18nProviderImpl.getLocale();
assertThat(location.toString(), is(LOCATION_DARMSTADT));
assertThat(setLocale, is(Locale.getDefault()));
}
use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.
the class AstroDiscoveryService method startScan.
@Override
protected void startScan() {
logger.debug("Starting Astro discovery scan");
PointType location = locationProvider.getLocation();
if (location == null) {
logger.debug("LocationProvider.getLocation() is not set -> Will not provide any discovery results");
return;
}
createResults(location);
}
use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.
the class MapviewRenderer method renderWidget.
@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
Mapview mapview = (Mapview) w;
String snippet = getSnippet("mapview");
snippet = StringUtils.replace(snippet, "%category%", getCategory(w));
snippet = StringUtils.replace(snippet, "%label%", getLabel(w));
snippet = StringUtils.replace(snippet, "%format%", getFormat());
// Process the color tags
snippet = processColor(w, snippet);
State state = itemUIRegistry.getState(mapview);
if (state instanceof PointType) {
PointType pointState = (PointType) state;
double latitude = pointState.getLatitude().doubleValue();
double longitude = pointState.getLongitude().doubleValue();
snippet = StringUtils.replace(snippet, "%lat%", Double.toString(latitude));
snippet = StringUtils.replace(snippet, "%lon%", Double.toString(longitude));
snippet = StringUtils.replace(snippet, "%lonminus%", Double.toString(longitude - 0.01));
snippet = StringUtils.replace(snippet, "%lonplus%", Double.toString(longitude + 0.01));
snippet = StringUtils.replace(snippet, "%latminus%", Double.toString(latitude - 0.01));
snippet = StringUtils.replace(snippet, "%latplus%", Double.toString(latitude + 0.01));
}
int height = mapview.getHeight();
if (height == 0) {
// set default height to something viewable
height = 4;
}
height = height * 36;
snippet = StringUtils.replace(snippet, "%height%", Integer.toString(height));
sb.append(snippet);
return null;
}
Aggregations