Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Mar 28, 2024
1 parent f0aba4b commit 3675226
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
10 changes: 9 additions & 1 deletion docs/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Sections follow that describe particular settings in more depth.
| maxTransferDuration | `duration` | Transfers up to this duration with the default walk speed value will be pre-calculated and included in the Graph. | *Optional* | `"PT30M"` | 2.1 |
| [multiThreadElevationCalculations](#multiThreadElevationCalculations) | `boolean` | Configuring multi-threading during elevation calculations. | *Optional* | `false` | 2.0 |
| [osmCacheDataInMem](#osmCacheDataInMem) | `boolean` | If OSM data should be cached in memory during processing. | *Optional* | `false` | 2.0 |
| osmNaming | `string` | A custom OSM namer to use. | *Optional* | | 1.5 |
| [osmNaming](#osmNaming) | `enum` | A custom OSM namer to use. | *Optional* | `"none"` | 1.5 |
| platformEntriesLinking | `boolean` | Link unconnected entries to public transport platforms. | *Optional* | `false` | 2.0 |
| [readCachedElevations](#readCachedElevations) | `boolean` | Whether to read cached elevation data. | *Optional* | `true` | 2.0 |
| staticBikeParkAndRide | `boolean` | Whether we should create bike P+R stations from OSM data. | *Optional* | `false` | 1.5 |
Expand Down Expand Up @@ -536,6 +536,14 @@ deployment depending on your infrastructure. Set the parameter to `true` to cach
data, and to `false` to read the stream from the source each time.


<h3 id="osmNaming">osmNaming</h3>

**Since version:** `1.5`**Type:** `enum`**Cardinality:** `Optional`**Default value:** `"none"`
**Path:** /
**Enum values:** `none` | `portland` | `sidewalks`

A custom OSM namer to use.

<h3 id="readCachedElevations">readCachedElevations</h3>

**Since version:** `2.0`**Type:** `boolean`**Cardinality:** `Optional`**Default value:** `true`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,7 @@ public void postprocess() {
.max(Comparator.comparingDouble(NamedEdgeGroup::percentInBuffer))
.ifPresent(group -> {
namesApplied.incrementAndGet();
var name = group.name.toString();

sidewalk.setName(
Objects.requireNonNull(
I18NString.of("%s, Percent in buffer: %s".formatted(name, group.percentInBuffer))
)
);
sidewalk.setName(Objects.requireNonNull(group.name));
});

//Keep lambda! A method-ref would cause incorrect class and line number to be logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,28 @@ public static EdgeNamer fromConfig(NodeAdapter root, String parameterName) {
.of(parameterName)
.summary("A custom OSM namer to use.")
.since(OtpVersion.V1_5)
.asString(null);
.asEnum(EdgeNamerType.NONE);
return fromConfig(osmNaming);
}

/**
* Create a custom namer if needed, return null if not found / by default.
*/
public static EdgeNamer fromConfig(String type) {
if (type == null) {
public static EdgeNamer fromConfig(EdgeNamerType type) {
if(type == null{
return new DefaultNamer();
}

return switch (type) {
case "portland" -> new PortlandCustomNamer();
case "sidewalks" -> new SidewalkNamer();
default -> throw new IllegalArgumentException(
String.format("Unknown osmNaming type: '%s'", type)
);
case PORTLAND -> new PortlandCustomNamer();
case SIDEWALKS -> new SidewalkNamer();
case NONE -> new DefaultNamer();
};
}
}

enum EdgeNamerType {
NONE,
PORTLAND,
SIDEWALKS,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.opentripplanner.graph_builder.services.osm;

import org.junit.jupiter.api.Test;

class EdgeNamerTest {

@Test
void nullType(){
var namer = EdgeNamer.EdgeNamerFactory.fromConfig(null);
}

}

0 comments on commit 3675226

Please sign in to comment.