diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
| commit | a304c24b32c0327436bbd8c2853e60668e161b42 (patch) | |
| tree | 08f65c05daca134cf4d2e4f779bd15d98fd66370 /src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs | |
| parent | 120a3c6bddd0fb8d9fa05df4763596956554c025 (diff) | |
Rename a lot of stuff, add Santiago real time
Diffstat (limited to 'src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs')
| -rw-r--r-- | src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs new file mode 100644 index 0000000..fad28eb --- /dev/null +++ b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopTile.cs @@ -0,0 +1,76 @@ +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Enmarcha.Sources.OpenTripPlannerGql.Queries; + +public class StopTileRequestContent : IGraphRequest<StopTileRequestContent.Bbox> +{ + 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<Stop>? 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<Route>? 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; } + } +} |
