From ef2df90ffb195edcddd701511dc5953c7baa63af Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Fri, 26 Dec 2025 15:56:09 +0100 Subject: Move OpenTripPlanner source to separate package --- .../Queries/StopTile.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopTile.cs (limited to 'src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopTile.cs') diff --git a/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopTile.cs b/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopTile.cs new file mode 100644 index 0000000..792d19e --- /dev/null +++ b/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopTile.cs @@ -0,0 +1,76 @@ +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Costasdev.Busurbano.Sources.OpenTripPlannerGql.Queries; + +public class StopTileRequestContent : IGraphRequest +{ + public record Bbox(double MinLon, double MinLat, double MaxLon, double MaxLat); + + public static string Query(Bbox bbox) + { + return string.Create(CultureInfo.InvariantCulture, $@" + query Query {{ + stopsByBbox( + minLat: {bbox.MinLat:F6} + minLon: {bbox.MinLon:F6} + maxLon: {bbox.MaxLon:F6} + maxLat: {bbox.MaxLat:F6} + ) {{ + gtfsId + code + name + lat + lon + routes {{ + gtfsId + shortName + color + textColor + }} + }} + }} + "); + } +} + +public class StopTileResponse : AbstractGraphResponse +{ + [JsonPropertyName("stopsByBbox")] + public List? StopsByBbox { get; set; } + + public record Stop + { + [JsonPropertyName("gtfsId")] + public required string GtfsId { get; set; } + + [JsonPropertyName("code")] + public string? Code { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("lat")] + public required double Lat { get; set; } + + [JsonPropertyName("lon")] + public required double Lon { get; set; } + + [JsonPropertyName("routes")] + public List? Routes { get; set; } + } + + public record Route + { + [JsonPropertyName("gtfsId")] + public required string GtfsId { get; set; } + [JsonPropertyName("shortName")] + public required string ShortName { get; set; } + + [JsonPropertyName("color")] + public string? Color { get; set; } + + [JsonPropertyName("textColor")] + public string? TextColor { get; set; } + } +} -- cgit v1.3