+ public static final String P_USE_BUILTIN = "org.simantics.district.maps.prefs.tileserverURL";
+
+ // TODO: fix this, currently copied from MapsServerPreferences
+ public static final String P_DEFAULT_PORT = "org.simantics.maps.server.defaultPort";
+ public static final String P_CURRENT_TM2STYLE = "org.simantics.maps.server.currentTM2Style";
+ public static final String P_SERVER_NODE = "org.simantics.maps.server";
+ public static Preferences getServerPreferences() {
+ return InstanceScope.INSTANCE.getNode(P_SERVER_NODE);
+ }
+
+ public static Preferences getPreferences() {
+ return InstanceScope.INSTANCE.getNode(P_NODE);
+ }
+
+ public static String tileserverURL() {
+ return getPreferences().get(P_TILESERVER_URL, "");
+ }
+
+ public static boolean useBuiltinServer() {
+ return getPreferences().getBoolean(P_USE_BUILTIN, true);
+ }
+
+ public static String possibleBuiltinServerURL() {
+ int port = getServerPreferences().getInt(P_DEFAULT_PORT, 8585);
+ String style = getServerPreferences().get(P_CURRENT_TM2STYLE, "mapbox-studio-osm-bright.tm2");
+ if (port != -1 && style != null) {
+ try {
+ return new URL("http", "localhost", port, "/" + style).toString();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return null;
+ }
+