forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'entur/via' into gtfs-pass-through-thomas
- Loading branch information
Showing
157 changed files
with
4,504 additions
and
1,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 45 additions & 73 deletions
118
src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
src/main/java/org/opentripplanner/apis/transmodel/mapping/PassThroughLocationMapper.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.opentripplanner.apis.transmodel.mapping; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
import java.time.Duration; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.opentripplanner.apis.transmodel.model.plan.TripQuery; | ||
import org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType; | ||
import org.opentripplanner.apis.transmodel.support.OneOfInputValidator; | ||
import org.opentripplanner.routing.api.request.via.PassThroughViaLocation; | ||
import org.opentripplanner.routing.api.request.via.ViaLocation; | ||
import org.opentripplanner.routing.api.request.via.VisitViaLocation; | ||
import org.opentripplanner.transit.model.framework.FeedScopedId; | ||
|
||
class TripViaLocationMapper { | ||
|
||
static List<ViaLocation> mapToViaLocations(final List<Map<String, Object>> via) { | ||
return via.stream().map(TripViaLocationMapper::mapViaLocation).collect(toList()); | ||
} | ||
|
||
/** | ||
* @deprecated Legacy passThrough, use via instead | ||
*/ | ||
@Deprecated | ||
static List<ViaLocation> toLegacyPassThroughLocations( | ||
final List<Map<String, Object>> passThroughPoints | ||
) { | ||
return passThroughPoints | ||
.stream() | ||
.map(TripViaLocationMapper::mapLegacyPassThroughViaLocation) | ||
.collect(toList()); | ||
} | ||
|
||
private static ViaLocation mapViaLocation(Map<String, Object> inputMap) { | ||
var fieldName = OneOfInputValidator.validateOneOf( | ||
inputMap, | ||
TripQuery.FIELD_VIA, | ||
ViaLocationInputType.FIELD_VISIT, | ||
ViaLocationInputType.FIELD_PASS_THROUGH | ||
); | ||
|
||
Map<String, Object> value = (Map<String, Object>) inputMap.get(fieldName); | ||
|
||
return switch (fieldName) { | ||
case ViaLocationInputType.FIELD_VISIT -> mapVisitViaLocation(value); | ||
case ViaLocationInputType.FIELD_PASS_THROUGH -> mapPassThroughViaLocation(value); | ||
default -> throw new IllegalArgumentException("Unknown field: " + fieldName); | ||
}; | ||
} | ||
|
||
private static VisitViaLocation mapVisitViaLocation(Map<String, Object> inputMap) { | ||
var label = (String) inputMap.get(ViaLocationInputType.FIELD_LABEL); | ||
var minimumWaitTime = (Duration) inputMap.get(ViaLocationInputType.FIELD_MINIMUM_WAIT_TIME); | ||
var stopLocationIds = mapStopLocationIds(inputMap); | ||
return new VisitViaLocation(label, minimumWaitTime, stopLocationIds, List.of()); | ||
} | ||
|
||
private static PassThroughViaLocation mapPassThroughViaLocation(Map<String, Object> inputMap) { | ||
var label = (String) inputMap.get(ViaLocationInputType.FIELD_LABEL); | ||
var stopLocationIds = mapStopLocationIds(inputMap); | ||
return new PassThroughViaLocation(label, stopLocationIds); | ||
} | ||
|
||
private static List<FeedScopedId> mapStopLocationIds(Map<String, Object> map) { | ||
var c = (Collection<String>) map.get(ViaLocationInputType.FIELD_STOP_LOCATION_IDS); | ||
return c.stream().map(TransitIdMapper::mapIDToDomain).toList(); | ||
} | ||
|
||
/** | ||
* @deprecated Legacy passThrough, use via instead | ||
*/ | ||
@Deprecated | ||
private static ViaLocation mapLegacyPassThroughViaLocation(Map<String, Object> inputMap) { | ||
final String name = (String) inputMap.get("name"); | ||
final List<FeedScopedId> stopLocationIds = | ||
((List<String>) inputMap.get("placeIds")).stream() | ||
.map(TransitIdMapper::mapIDToDomain) | ||
.toList(); | ||
return new PassThroughViaLocation(name, stopLocationIds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...el/util/EncodedPolylineBeanWithStops.java → ...amework/EncodedPolylineBeanWithStops.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelDirectives.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.opentripplanner.apis.transmodel.model.framework; | ||
|
||
import graphql.introspection.Introspection; | ||
import graphql.schema.GraphQLDirective; | ||
|
||
public class TransmodelDirectives { | ||
|
||
public static final GraphQLDirective TIMING_DATA = GraphQLDirective | ||
.newDirective() | ||
.name("timingData") | ||
.description("Add timing data to prometheus, if Actuator API is enabled") | ||
.validLocation(Introspection.DirectiveLocation.FIELD_DEFINITION) | ||
.build(); | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/opentripplanner/apis/transmodel/model/framework/TransmodelScalars.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.opentripplanner.apis.transmodel.model.framework; | ||
|
||
import graphql.schema.GraphQLObjectType; | ||
import graphql.schema.GraphQLScalarType; | ||
import org.opentripplanner.apis.transmodel.model.scalars.DoubleFunctionFactory; | ||
import org.opentripplanner.apis.transmodel.model.scalars.LocalTimeScalarFactory; | ||
import org.opentripplanner.apis.transmodel.model.scalars.TimeScalarFactory; | ||
import org.opentripplanner.framework.graphql.scalar.DateScalarFactory; | ||
import org.opentripplanner.framework.graphql.scalar.DurationScalarFactory; | ||
|
||
/** | ||
* This class contains all Transmodel custom scalars, except the | ||
* {@link org.opentripplanner.apis.transmodel.support.GqlUtil#dateTimeScalar}. | ||
*/ | ||
public class TransmodelScalars { | ||
|
||
public static final GraphQLScalarType DATE_SCALAR; | ||
public static final GraphQLScalarType DOUBLE_FUNCTION_SCALAR; | ||
public static final GraphQLScalarType LOCAL_TIME_SCALAR; | ||
public static final GraphQLObjectType TIME_SCALAR; | ||
public static final GraphQLScalarType DURATION_SCALAR; | ||
|
||
static { | ||
DATE_SCALAR = DateScalarFactory.createTransmodelDateScalar(); | ||
DOUBLE_FUNCTION_SCALAR = DoubleFunctionFactory.createDoubleFunctionScalar(); | ||
LOCAL_TIME_SCALAR = LocalTimeScalarFactory.createLocalTimeScalar(); | ||
TIME_SCALAR = TimeScalarFactory.createSecondsSinceMidnightAsTimeObject(); | ||
DURATION_SCALAR = DurationScalarFactory.createDurationScalar(); | ||
} | ||
} |
Oops, something went wrong.