-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make debug UI background layers configurable with new file debug-ui-config.json
#6295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
769e380
77fdc5e
c0b4243
6ae498d
a934342
25b4fee
9bd492a
441711b
2f0692b
57c6593
c6c6c3b
8395345
d831ec4
2ac997f
a83afac
9230aa3
20696c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| package org.opentripplanner.standalone.config; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we put this inside the debugui package inside the config package (same question for other configs)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea and have just followed the pattern that was there before. I would like to separate refactoring from the feature development. If we can come to an agreement how the packages should be structured I'm happy to change it in a follow up PR. |
||
|
|
||
| import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_7; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.node.MissingNode; | ||
| import java.util.List; | ||
| import org.opentripplanner.standalone.config.debuguiconfig.BackgroundTileLayer; | ||
| import org.opentripplanner.standalone.config.framework.json.NodeAdapter; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * This class is an object representation of the 'debug-ui-config.json'. | ||
| */ | ||
| public class DebugUiConfig { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(DebugUiConfig.class); | ||
|
|
||
| public static final DebugUiConfig DEFAULT = new DebugUiConfig( | ||
| MissingNode.getInstance(), | ||
| "DEFAULT", | ||
| false | ||
| ); | ||
|
|
||
| /** | ||
| * The node adaptor kept for reference and (de)serialization. | ||
| */ | ||
| private final NodeAdapter root; | ||
| private final List<BackgroundTileLayer> additionalBackgroundLayers; | ||
|
|
||
| public DebugUiConfig(JsonNode node, String source, boolean logUnusedParams) { | ||
| this(new NodeAdapter(node, source), logUnusedParams); | ||
| } | ||
|
|
||
| /** protected to give unit-test access */ | ||
| DebugUiConfig(NodeAdapter root, boolean logUnusedParams) { | ||
| this.root = root; | ||
|
|
||
| this.additionalBackgroundLayers = | ||
| root | ||
| .of("additionalBackgroundLayers") | ||
| .since(V2_7) | ||
| .summary("Additional background raster map layers.") | ||
| .description( | ||
| """ | ||
| Add additional background layers that will appear in the Debug UI as one of the choices. | ||
|
|
||
| Currently only raster tile layers are supported. | ||
| """ | ||
| ) | ||
| .asObjects( | ||
| List.of(), | ||
| node -> | ||
| new BackgroundTileLayer( | ||
| node | ||
| .of("name") | ||
| .since(V2_7) | ||
| .summary("Name to appear in the layer selector.") | ||
| .asString(), | ||
| node | ||
| .of("templateUrl") | ||
| .since(V2_7) | ||
| .summary( | ||
| """ | ||
| The [Maplibre-compatible template URL](https://maplibre.org/maplibre-native/ios/api/tile-url-templates.html) | ||
| for the raster layer, for example `https://examples.com/tiles/{z}/{x}/{y}.png`. | ||
| """ | ||
| ) | ||
| .asString(), | ||
| node.of("tileSize").since(V2_7).summary("Size of the tile in pixels.").asInt(256), | ||
| node | ||
| .of("attribution") | ||
| .since(V2_7) | ||
| .summary("Attribution for the map data.") | ||
| .asString("© OpenTripPlanner") | ||
| ) | ||
| ); | ||
|
|
||
| if (logUnusedParams) { | ||
| root.logAllWarnings(LOG::warn); | ||
| } | ||
| } | ||
|
|
||
| public NodeAdapter asNodeAdapter() { | ||
| return root; | ||
| } | ||
|
|
||
| public List<BackgroundTileLayer> additionalBackgroundLayers() { | ||
| return additionalBackgroundLayers; | ||
| } | ||
|
|
||
| /** | ||
| * If {@code true} the config is loaded from file, in not the DEFAULT config is used. | ||
| */ | ||
| public boolean isDefault() { | ||
| return root.isEmpty(); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if any unknown or invalid parameters were encountered while loading the configuration. | ||
| */ | ||
| public boolean hasUnknownParameters() { | ||
| return root.hasUnknownParameters(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.debuguiconfig seems like a bit of repetition (however the same repetition seems to be done for other configs as well for some reason). Perhaps config.debugui/debugclient)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For go or bad, I want to follow the previous naming pattern.
If we can agree to a new structure, I'm happy to make a follow up.