# SPDX-FileCopyrightText: 2020-2021 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: CC0-1.0

query stopsByCoordinate(
    $lat: Float!,
    $lon: Float!,
    $radius: Int!,
    $maxResults: Int!,
    $placeType: [FilterPlaceType]!
) {
    stopsByRadius: nearest(
        lat: $lat,
        lon: $lon,
        maxDistance: $radius,
        maxResults: $maxResults,
        filterByPlaceTypes: $placeType
    ) {
        edges {
            node {
                stop: place { ...on Stop {
                    id: gtfsId
                    name
                    lat
                    lon
                    vehicleMode
                    parentStation {
                        id: gtfsId
                        name
                        lat
                        lon
                    }
                    routes {
                        type
                        shortName
                        longName
                        color
                        textColor
                        agency {
                            name
                            url
                        }
                    }
                }}
                bikeRentalStation: place { ...rentalVehicleStationFragment }
                rentalVehicle: place { ...rentalVehicleFragment }
            }
        }
    }
}

#include <rentalvehiclefragments.graphql>

fragment rentalVehicleFragment on RentalVehicle {
    allowPickupNow
    availableUntil
    fuel { ...rentalVehicleFuelFragment }
    id: vehicleId
    lat
    lon
    name
    operative
    rentalNetwork { ...rentalNetworkFragment }
    rentalUris { ...rentalUrisFragment }
    vehicleType { ...rentalVehicleTypeFragment }
}

fragment rentalVehicleFuelFragment on RentalVehicleFuel {
    percent
    range
}
