From c27e8ce6f729054ad120c29ac21c6b8f870f05f5 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Wed, 29 May 2024 10:33:14 +0200 Subject: [PATCH] Add type to geocoding results --- .../java/org/opentripplanner/ext/geocoder/StopCluster.java | 7 +++++++ .../opentripplanner/ext/geocoder/StopClusterMapper.java | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/ext/java/org/opentripplanner/ext/geocoder/StopCluster.java b/src/ext/java/org/opentripplanner/ext/geocoder/StopCluster.java index 4c51c7586dd..30647cc7b20 100644 --- a/src/ext/java/org/opentripplanner/ext/geocoder/StopCluster.java +++ b/src/ext/java/org/opentripplanner/ext/geocoder/StopCluster.java @@ -31,9 +31,15 @@ public record Agency(FeedScopedId id, String name) {} */ public record FeedPublisher(String name) {} + public enum LocationType { + STATION, + STOP, + } + public record Location( FeedScopedId id, @Nullable String code, + LocationType type, String name, Coordinate coordinate, Collection modes, @@ -43,6 +49,7 @@ public record Location( public Location { Objects.requireNonNull(id); Objects.requireNonNull(name); + Objects.requireNonNull(type); Objects.requireNonNull(coordinate); Objects.requireNonNull(modes); Objects.requireNonNull(agencies); diff --git a/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java b/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java index bb8f0e72bbe..de8d2681fd9 100644 --- a/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java +++ b/src/ext/java/org/opentripplanner/ext/geocoder/StopClusterMapper.java @@ -1,5 +1,8 @@ package org.opentripplanner.ext.geocoder; +import static org.opentripplanner.ext.geocoder.StopCluster.LocationType.STATION; +import static org.opentripplanner.ext.geocoder.StopCluster.LocationType.STOP; + import com.google.common.collect.Iterables; import java.util.Collection; import java.util.List; @@ -129,6 +132,7 @@ StopCluster.Location toLocation(FeedScopedId id) { return new StopCluster.Location( loc.getId(), loc.getCode(), + STOP, loc.getName().toString(), new StopCluster.Coordinate(loc.getLat(), loc.getLon()), modes, @@ -150,6 +154,7 @@ StopCluster.Location toLocation(FeedScopedId id) { return new StopCluster.Location( group.getId(), group.getCode(), + STATION, group.getName().toString(), new StopCluster.Coordinate(group.getLat(), group.getLon()), modes,