Best Practices
SafeSky UAV API - Integration Guide
This pageguide provides developer-orientedarchitectural patterns and best practices for integrating the SafeSky UAV API into custom mission control software, moving-map applications, orand operational dashboards.
Overview
The objectiveSafeSky isAPI enables developers to build aproduction-grade smooth,air scalable,traffic awareness systems that display real-time positions of UAVs, helicopters, general aviation aircraft, and operationallycommercial correcttraffic. This guide addresses the technical challenges of building responsive, scalable traffic layerlayers showingthat crewedmeet aircraft,operational helicopters,aviation and UAV activity in real time.standards.
AReference live reference implementation using these principles is available at:Implementation: https://live.safesky.app
Key Design Goals
1. Recommended Integration Architecture
Dual-Thread Pattern
AImplement robusttraffic integrationretrieval shouldand maintaintelemetry publishing as twoindependent, independentasynchronous executionprocesses. threads:This separation is critical for operational reliability.
1.
┌─────────────────────┐ ┌─────────────────────┐
│ Traffic Retrieval │ │ Telemetry Publisher │
│ Thread GET /v1/uav 2. UAV Publishing Thread
POST /v1/uav │
│ Viewport queries │ │ Position updates │
│ 1Hz polling │ │ 1Hz transmission │
└─────────────────────┘ └─────────────────────┘
↓ ↓
┌────────────────────────────────────┐
│ Application State/Map │
└────────────────────────────────────┘
Architectural Benefits:
SeparatingImplementation theseNote: concernsIn improvessingle-threaded reliability,environments scalability,(e.g., andJavaScript), erroruse handling.separate async tasks or workers to achieve the same isolation.
2. Retrieving Traffic forRetrieval aStrategy
Use
Viewport-Based Queries
For map-based applications, always preferuse viewport-basedbounding box queries insteadthat ofalign radius-basedwith searches.the visible viewport:
GET /v1/uav?viewport=lat_min,lng_min,lat_max,lng_max
Why
Example:
GET /v1/uav?viewport=48.8566,2.3522,48.8766,2.3922
Technical Advantages:
Performance Impact: At high zoom levels (city view), viewport queries arecan preferredreduce
Add
Viewport a Safety MarginPadding (Outset)
Overscan)
AlwaysExtend extendquery thebounds viewport slightly5-15% beyond the visible viewport to improve UX and anticipate edge transitions.
Implementation Example:
const OVERSCAN_FACTOR = 0.10; // 10% padding
function getQueryViewport(mapBounds) {
const latPadding = (mapBounds.north - mapBounds.south) * OVERSCAN_FACTOR;
const lngPadding = (mapBounds.east - mapBounds.west) * OVERSCAN_FACTOR;
return {
lat_min: mapBounds.south - latPadding,
lng_min: mapBounds.west - lngPadding,
lat_max: mapBounds.north + latPadding,
lng_max: mapBounds.east + lngPadding
};
}
Benefits:
Tuning Guidance: Use larger padding (12-15%) for high-speed traffic environments or slower network connections.
Polling Frequency
Recommended margin:interval: 1 second (1Hz)
+5% to +15% on each side of the viewport
This ensures:frequency balances real-time awareness with reasonable bandwidth consumption.
Rationale:
- Aircraft
nearmovingscreenatedges100areknotsstilltravelfetched~50 meters per second No1-secondvisualupdates“pop-in”providewhensmoothpanninginterpolation without perceptible lagBetterAlignsanticipationwithofaviation-gradefast-movingsituationaltrafficawareness requirements
FetchingNetwork slightly more traffic than visible is intentional and recommended.Optimization:
Polling Frequency
RecommendedImplementGETexponentialinterval:backoff1forsecondfailed requestsProvidesConsidersmoothcompressionmotion(gzip/brotli)andfornear-real-time awarenessresponsesSuitableUse HTTP/2 or HTTP/3 where available forbothconnectionUAV and crewed aircraft trafficmultiplexing
3. Publishing UAV Telemetry
UsePublishing
the following endpoint to publish one or more UAVs:
Endpoint
POST /v1/uav
Content-Type: application/json
Publishing Frequency
Batch Publishing (Stronglyfor Recommended)
Fleet Operations
IfWhen managing multiple UAVsUAVs, simultaneously, always publishuse batch publishing by sending an array of telemetry objects in batch using a single POST request.
WhyPerformance batchComparison:
Key Benefits:
- Reduced overhead: Single HTTP
overheadhandshake vs. multiple connections LowerAtomiclatencytimestamps: All UAVs share consistent update timeConsistentLowertimestampslatency:acrossOneUAVsround-trip instead of N round-tripsBetterImprovedscalabilityscalability: Essential forfleetsswarmandoperationsswarms(20+ UAVs)
RecommendedBest approach:Practice:
Example: Batch UAV Publish Payload
[
{
"id": "UAV1",
"latitude": 48.86584,
"longitude": 2.63723,
"altitude": 120,
"course": 205,
"ground_speed": 12,
"status": "AIRBORNE",
"last_update": 1733412793
},
{
"id": "UAV2",
"latitude": 48.87012,
"longitude": 2.64188,
"altitude": 115,
"course": 210,
"ground_speed": 10,
"status": "AIRBORNE",
"last_update": 1733412793
}
]
4. Pre-Flight Visibility
GROUNDED Status)
Status Advertise Before Takeoff
Broadcasting
Before takeoff, it is considered best practice to publish thePublish UAV with:
with statusstatus: = GROUNDED
"GROUNDED"When:
{
"id": "UAV1",
"latitude": 48.86584,
"longitude": 2.63723,
"altitude": 0,
"status": "GROUNDED",
"last_update": 1734537600
}
Operational Rationale:
Why:State Transition:
SwitchTransition to immediately AIRBORNEstatus: "AIRBORNE"afterupon takeoff.takeoff to reflect actual flight status.
Implementation Note: For mission planning applications, this can be automated based on pre-filed flight plans or launch schedules.
5. Smooth Aircraft Motion (Rendering
Client-Side Extrapolation)
Position Extrapolation
Traffic updates arrive at discrete 1-second intervals. To avoidachieve “jumping”smooth icons:
Useimplement extrapolationdead reckoning between updates
ThisAlgorithm:
function extrapolatePosition(aircraft, currentTime) {
const elapsedSeconds = (currentTime - aircraft.last_update) / 1000;
const distanceMeters = aircraft.ground_speed * 0.514444 * elapsedSeconds; // knots to m/s
const deltaLat = distanceMeters * Math.cos(aircraft.course * Math.PI / 180) / 111320;
const deltaLng = distanceMeters * Math.sin(aircraft.course * Math.PI / 180) /
(111320 * Math.cos(aircraft.latitude * Math.PI / 180));
return {
latitude: aircraft.latitude + deltaLat,
longitude: aircraft.longitude + deltaLng
};
}
Rendering Impact:
Smooth,Transformsprofessionaldiscrete position updates into fluid 60fps animation
Limitation: Extrapolation assumes constant velocity and heading. Maneuvering aircraft may show brief position discrepancies until the next update.
6. Traffic Ageing,Aging Uncertainty &and Expiry
Data Freshness Management
Different traffic typessources have different lifetimes.validity windows based on their update characteristics.
Advisory UAV Traffic
ValidValidity:upUp to 2 minutes aftertimestamplastexpiryupdateShouldRationale:remainLowervisiblespeedwithandappropriatepredictable flight patterns
Other
Real-Time Air Traffic (ADS-B, FLARM, ADS-L, etc.)
L)
Uncertainty Visualization
Implementation ShowApproach:
function expandinggetUncertaintyRadius(lastUpdate, currentTime, groundSpeed) {
const ageSeconds = (currentTime - lastUpdate) / 1000;
if (ageSeconds < 30) return 0;
// Assume maximum maneuvering potential
const maxDistanceMeters = groundSpeed * 0.514444 * ageSeconds;
return maxDistanceMeters; // Display as circle aroundradius
last}
known
Purpose:
Visual Design: Use semi-transparent expanding circles that grow linearly with time since last update.
7. Visual RepresentationDesign BestGuidelines
Traffic Icon States
RecommendedImplement progressive visual cues:feedback to communicate data confidence:
Data Freshness States:
┌─────────────┬──────────────┬────────────────┬──────────────┐
│ Current │ Aging │ Uncertain │ Expired │
│ (0-30s) │ (30-45s) │ │ (>45s) │
├─────────────┼──────────────┼────────────────┼──────────────┤
│ Solid icon │ 70% opacity │ + uncertainty │ Remove from │
│ Full color │ Subtle pulse │ circle │ display │
└─────────────┴──────────────┴────────────────┴──────────────┘
Traffic Categorization
Use distinct iconography for different aircraft types:
SolidUAV/Drone:icon:Quadcopterfreshordatafixed-wing silhouetteReducedHelicopter:opacity:Rotor-basedagingicondatawith rotation indicatorExpandingGeneraluncertaintyAviation:circle:SmallsignalaircraftdegradationsilhouetteDistinctCommercial:iconsLargerperaircrafttrafficprofile
Accessibility Note: Ensure icons are distinguishable by shape, not just color, for colorblind users.
8. Icon Sets
Assets
To simplify integration, SafeSky provides ready-to-use trafficoptimized icon sets optimised for maprapid rendering.integration.
📦Download: Icon sets download (placeholder):
https://docs.safesky.app/downloads/iconsets
Includes:Package Contents:
- Formats: SVG (vector) and PNG
formats(raster) MultipleSizes:sizes24×24, 32×32, 48×48, 64×64 pxDarkThemes: Light and dark mode variants
Usage Recommendations:
9. RecommendedConfiguration Reference
Timing Summary
Parameters
10. Reference Implementation
AExplore livea exampleproduction implementingimplementation allof these best practices is available at:patterns:
Live Demo: https://live.safesky.app
The reference implementation demonstrates:
Use the browser developer tools to observe network traffic patterns, polling behavior, and rendering optimizations in a production environment.