diff --git a/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java b/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java index b80efab77b5..a15bf2f838e 100644 --- a/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java +++ b/src/main/java/org/opentripplanner/apis/transmodel/model/stop/QuayType.java @@ -380,20 +380,21 @@ public static GraphQLObjectType create( .name("flexibleArea") .description("Geometry for flexible area.") .type(GeoJSONCoordinatesScalar.getGraphQGeoJSONCoordinatesScalar()) - .dataFetcher(environment -> - ( - environment.getSource() instanceof AreaStop areaStop - ? areaStop.getGeometry().getCoordinates() - : null - ) - ) + .dataFetcher(environment -> { + if (environment.getSource() instanceof AreaStop areaStop) { + return areaStop.getGeometry().getCoordinates(); + } else if (environment.getSource() instanceof GroupStop groupStop) { + return groupStop.getEncompassingAreaGeometry().getCoordinates(); + } + return null; + }) .build() ) .field( GraphQLFieldDefinition .newFieldDefinition() .name("flexibleGroup") - .description("the Quays part of an flexible group.") + .description("the Quays part of a flexible group.") .type(GraphQLList.list(REF)) .dataFetcher(environment -> ( diff --git a/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java b/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java index 1e6eb1979bb..5bc8d63679a 100644 --- a/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java +++ b/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java @@ -62,6 +62,7 @@ StopLocation map(FlexibleStopPlace flexibleStopPlace) { List stops = new ArrayList<>(); TransitMode flexibleStopTransitMode = mapTransitMode(flexibleStopPlace); var areas = flexibleStopPlace.getAreas().getFlexibleAreaOrFlexibleAreaRefOrHailAndRideArea(); + ArrayList areaGeometries = new ArrayList<>(); for (var area : areas) { if (!(area instanceof FlexibleArea flexibleArea)) { issueStore.add( @@ -76,6 +77,7 @@ StopLocation map(FlexibleStopPlace flexibleStopPlace) { } Geometry flexibleAreaGeometry = mapGeometry(flexibleArea); + areaGeometries.add(flexibleAreaGeometry); if (shouldAddStopsFromArea(flexibleArea, flexibleStopPlace)) { stops.addAll( @@ -100,7 +102,8 @@ StopLocation map(FlexibleStopPlace flexibleStopPlace) { // get the ids for the area and stop place correct var builder = stopModelBuilder .groupStop(idFactory.createId(flexibleStopPlace.getId())) - .withName(new NonLocalizedString(flexibleStopPlace.getName().getValue())); + .withName(new NonLocalizedString(flexibleStopPlace.getName().getValue())) + .withEncompassingAreaGeometries(areaGeometries); stops.forEach(builder::addLocation); return builder.build(); } diff --git a/src/main/java/org/opentripplanner/transit/model/site/GroupStop.java b/src/main/java/org/opentripplanner/transit/model/site/GroupStop.java index ac3cca3dd13..f2baf84b5c3 100644 --- a/src/main/java/org/opentripplanner/transit/model/site/GroupStop.java +++ b/src/main/java/org/opentripplanner/transit/model/site/GroupStop.java @@ -24,6 +24,8 @@ public class GroupStop private final I18NString name; private final GeometryCollection geometry; + private final GeometryCollection encompassingAreaGeometry; + private final WgsCoordinate centroid; GroupStop(GroupStopBuilder builder) { @@ -33,6 +35,7 @@ public class GroupStop this.geometry = builder.geometry(); this.centroid = Objects.requireNonNull(builder.centroid()); this.stopLocations = builder.stopLocations(); + this.encompassingAreaGeometry = builder.encompassingAreaGeometry(); } public static GroupStopBuilder of(FeedScopedId id, IntSupplier indexCounter) { @@ -79,6 +82,10 @@ public Geometry getGeometry() { return geometry; } + public Geometry getEncompassingAreaGeometry() { + return encompassingAreaGeometry; + } + @Override public boolean isPartOfStation() { return false; diff --git a/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java b/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java index 5e0dc596eba..b474658f5ec 100644 --- a/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java +++ b/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java @@ -1,5 +1,6 @@ package org.opentripplanner.transit.model.site; +import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.function.IntSupplier; @@ -26,6 +27,11 @@ public class GroupStopBuilder extends AbstractEntityBuilder geometries) { + this.encompassingAreaGeometry = + new GeometryCollection( + geometries.toArray(new Geometry[0]), + GeometryUtils.getGeometryFactory() + ); + return this; + } + public I18NString name() { return name; } @@ -90,6 +105,10 @@ public GeometryCollection geometry() { return geometry; } + public GeometryCollection encompassingAreaGeometry() { + return encompassingAreaGeometry; + } + public WgsCoordinate centroid() { return centroid; } diff --git a/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql b/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql index 9b49283c180..25cf95ca2f9 100644 --- a/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql +++ b/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql @@ -579,7 +579,7 @@ type Quay implements PlaceInterface { ): [EstimatedCall!]! @timingData "Geometry for flexible area." flexibleArea: Coordinates - "the Quays part of an flexible group." + "the Quays part of a flexible group." flexibleGroup: [Quay] id: ID! "List of journey patterns servicing this quay"