blob: 8a271f23e53f4b139702384e16f0f96623a3c563 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
using System.Globalization;
using System.Text.Json.Serialization;
namespace Costasdev.Busurbano.Backend.GraphClient.App;
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; init; }
[JsonPropertyName("code")]
public string? Code { get; init; }
[JsonPropertyName("name")]
public required string Name { get; init; }
[JsonPropertyName("lat")]
public required double Lat { get; init; }
[JsonPropertyName("lon")]
public required double Lon { get; init; }
[JsonPropertyName("routes")]
public List<Route>? Routes { get; init; }
}
public record Route
{
[JsonPropertyName("gtfsId")]
public required string GtfsId { get; init; }
[JsonPropertyName("shortName")]
public required string ShortName { get; init; }
[JsonPropertyName("color")]
public string? Color { get; init; }
[JsonPropertyName("textColor")]
public string? TextColor { get; init; }
}
}
|