Skip to main content

Coordinates Type

The Coordinates type represents a geographic point using latitude and longitude coordinates.

Type Definition

"""
Represents a geographic point using latitude and longitude coordinates.
"""
type Coordinates {
"""
The latitude component of the coordinates in decimal degrees.
Positive values indicate North, negative values indicate South.
Range: -90 to 90
"""
latitude: Float

"""
The longitude component of the coordinates in decimal degrees.
Positive values indicate East, negative values indicate West.
Range: -180 to 180
"""
longitude: Float
}

Fields

FieldTypeDescription
latitudeFloatOptional. Latitude in decimal degrees (-90 to 90)
longitudeFloatOptional. Longitude in decimal degrees (-180 to 180)

Example Query

query GetTrackerLocation {
tracker(id: "123") {
latestLocation {
location {
latitude
longitude
}
}
}
}

Validation

The API enforces the following validation rules for coordinates:

  1. Latitude Range
if latitude is not None and not -90 <= latitude <= 90:
raise ValueError("Latitude must be between -90 and 90 degrees")
  1. Longitude Range
if longitude is not None and not -180 <= longitude <= 180:
raise ValueError("Longitude must be between -180 and 180 degrees")

Best Practices

  1. Precision

    • Store coordinates with at least 6 decimal places
    • Round displayed values based on accuracy needs
  2. Validation

    • Always validate coordinate ranges
    • Handle missing coordinates gracefully
  3. Performance

    • Include only needed fields in queries
    • Consider caching geocoded results