2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.astro.internal.config;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * Astro Thing configuration.
21 * @author Gerhard Riegler - Initial contribution
24 public class AstroThingConfig {
25 public static final String GEOLOCATION = "geolocation";
26 public static final String USE_METEOROLOGICAL_SEASON = "useMeteorologicalSeason";
27 public @Nullable String geolocation;
28 public @Nullable Double altitude;
29 public @Nullable Double latitude;
30 public @Nullable Double longitude;
31 public boolean useMeteorologicalSeason;
32 public int interval = 300;
35 * Splits the geolocation into latitude and longitude.
37 public void parseGeoLocation() {
38 if (geolocation != null) {
39 String[] geoParts = geolocation.split(",");
40 if (geoParts.length >= 2) {
41 latitude = toDouble(geoParts[0]);
42 longitude = toDouble(geoParts[1]);
44 if (geoParts.length == 3) {
45 altitude = toDouble(geoParts[2]);
50 private @Nullable Double toDouble(String value) {
52 return Double.parseDouble(value.trim());
53 } catch (NumberFormatException ex) {