Skip to content
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

Add Hamburg OSM mapper #5701

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -945,15 +945,15 @@ the local filesystem.

**Since version:** `2.2` ∙ **Type:** `enum` ∙ **Cardinality:** `Optional` ∙ **Default value:** `"default"`
**Path:** /osm/[0]
**Enum values:** `default` | `norway` | `uk` | `finland` | `germany` | `atlanta` | `houston` | `portland` | `constant-speed-finland`
**Enum values:** `default` | `norway` | `uk` | `finland` | `germany` | `hamburg` | `atlanta` | `houston` | `portland` | `constant-speed-finland`

The named set of mapping rules applied when parsing OSM tags. Overrides the value specified in `osmDefaults`.

<h3 id="od_osmTagMapping">osmTagMapping</h3>

**Since version:** `2.2` ∙ **Type:** `enum` ∙ **Cardinality:** `Optional` ∙ **Default value:** `"default"`
**Path:** /osmDefaults
**Enum values:** `default` | `norway` | `uk` | `finland` | `germany` | `atlanta` | `houston` | `portland` | `constant-speed-finland`
**Enum values:** `default` | `norway` | `uk` | `finland` | `germany` | `hamburg` | `atlanta` | `houston` | `portland` | `constant-speed-finland`

The named set of mapping rules applied when parsing OSM tags.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.opentripplanner.openstreetmap.tagmapping;

import org.opentripplanner.openstreetmap.model.OSMWithTags;

/**
* Modified mapper to allow through traffic for combination access=customers and customers=HVV.
*
* @see GermanyMapper
* @see OsmTagMapper
* @see DefaultMapper
*/
public class HamburgMapper extends GermanyMapper {

@Override
public boolean isGeneralNoThroughTraffic(OSMWithTags way) {
String access = way.getTag("access");
boolean isNoThroughTraffic = doesTagValueDisallowThroughTraffic(access);

return isNoThroughTraffic && !way.isTag("customers", "HVV");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum OsmTagMapperSource {
UK,
FINLAND,
GERMANY,
HAMBURG,
ATLANTA,
HOUSTON,
PORTLAND,
Expand All @@ -22,6 +23,7 @@ public OsmTagMapper getInstance() {
case UK -> new UKMapper();
case FINLAND -> new FinlandMapper();
case GERMANY -> new GermanyMapper();
case HAMBURG -> new HamburgMapper();
case ATLANTA -> new AtlantaMapper();
case HOUSTON -> new HoustonMapper();
case PORTLAND -> new PortlandMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.opentripplanner.openstreetmap.tagmapping;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.opentripplanner.openstreetmap.model.OSMWithTags;

public class HamburgMapperTest {

private HamburgMapper mapper;

@BeforeEach
void createMapper() {
mapper = new HamburgMapper();
}

@Test
public void shouldAllowThroughTraffic_WhenAccessCustomers_AndCustomersHVV() {
OSMWithTags way = new OSMWithTags();
way.addTag("access", "customers");
way.addTag("customers", "HVV");

boolean generalNoThroughTraffic = mapper.isGeneralNoThroughTraffic(way);

assertFalse(
generalNoThroughTraffic,
"access=customers and customers=hvv should not be considered through-traffic"
);
}

@ParameterizedTest
@ValueSource(strings = { "no", "destination", "private", "customers", "delivery" })
public void shouldDisallowThroughTraffic_WhenNoCustomersHVV(String access) {
OSMWithTags way = new OSMWithTags();
way.addTag("access", access);

boolean generalNoThroughTraffic = mapper.isGeneralNoThroughTraffic(way);

assertTrue(
generalNoThroughTraffic,
"access={no, destination, private, customers, delivery} should be blocked in general"
);
}
}
Loading