Skip to content

Commit

Permalink
Add type to geocoding results
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed May 29, 2024
1 parent f78d9c9 commit c27e8ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> modes,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit c27e8ce

Please sign in to comment.