Skip to content

Commit

Permalink
Set bogus name to false when updating a StreetEdge's name
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Dec 9, 2024
1 parent e0422cd commit cf27135
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,17 @@ public String getDefaultName() {
*/
public abstract I18NString getName();

// TODO Add comments about what a "bogus name" is.
/**
* Returns true if this edge has a generated name that is derived from its properties,
* like "path", "stairs" or "tunnel".
* <p>
* Returns false if the field reflects the real world name, like "Fifth Avenue",
* "Hauptstraße" or "Øvre Holmegate".
*/
public boolean hasBogusName() {
return false;
}

// The next few functions used to live in EdgeNarrative, which has now been
// removed
// @author mattwigway

public LineString getGeometry() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.impl.PackedCoordinateSequence;
import org.opentripplanner.framework.geometry.CompactLineStringUtils;
Expand Down Expand Up @@ -82,14 +79,14 @@ public class StreetEdge

/**
* bicycleSafetyWeight = length * bicycleSafetyFactor. For example, a 100m street with a safety
* factor of 2.0 will be considered in term of safety cost as the same as a 200m street with a
* factor of 2.0 will be considered in terms of safety cost as the same as a 200m street with a
* safety factor of 1.0.
*/
private float bicycleSafetyFactor;

/**
* walkSafetyFactor = length * walkSafetyFactor. For example, a 100m street with a safety
* factor of 2.0 will be considered in term of safety cost as the same as a 200m street with a
* factor of 2.0 will be considered in terms of safety cost as the same as a 200m street with a
* safety factor of 1.0.
*/
private float walkSafetyFactor;
Expand Down Expand Up @@ -446,8 +443,15 @@ public I18NString getName() {
return this.name;
}

/**
* Update the name of the edge after it has been constructed. This method also sets the bogusName
* property to false, indicating to the code that maps from edges to steps that this is a real
* street name.
* @see Edge#hasBogusName()
*/
public void setName(I18NString name) {
this.name = name;
this.flags = BitSetUtils.set(flags, HASBOGUSNAME_FLAG_INDEX, false);
}

public boolean hasBogusName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void postprocess() {
assertNotEquals(sidewalk.edge.getName(), pryorStreet.edge.getName());
builder.postProcess(new SidewalkNamer());
assertEquals(sidewalk.edge.getName(), pryorStreet.edge.getName());
assertFalse(sidewalk.edge.hasBogusName());
}

private static class ModelBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void enterStation() {
var walkSteps = buildWalkSteps(builder);
assertEquals(2, walkSteps.size());
var enter = walkSteps.get(1);
assertEquals(enter.getRelativeDirection(), ENTER_STATION);
assertEquals(ENTER_STATION, enter.getRelativeDirection());
}

@Test
Expand All @@ -54,7 +54,7 @@ void exitStation() {
var walkSteps = buildWalkSteps(builder);
assertEquals(3, walkSteps.size());
var enter = walkSteps.get(2);
assertEquals(enter.getRelativeDirection(), EXIT_STATION);
assertEquals(EXIT_STATION, enter.getRelativeDirection());
}

@Test
Expand All @@ -64,7 +64,7 @@ void signpostedPathway() {
var walkSteps = buildWalkSteps(builder);
assertEquals(2, walkSteps.size());
var step = walkSteps.get(1);
assertEquals(step.getRelativeDirection(), FOLLOW_SIGNS);
assertEquals(FOLLOW_SIGNS, step.getRelativeDirection());
assertEquals(sign, step.getDirectionText().toString());
}

Expand Down

0 comments on commit cf27135

Please sign in to comment.