Setting Geofence Boundaries
📖 Scenario: You are programming a drone to fly safely within a specific area. To keep the drone from flying too far, you need to set up geofence boundaries. These boundaries tell the drone where it can and cannot go.
🎯 Goal: Build a program that defines a geofence area using coordinates, sets a maximum allowed distance from the center, checks if a given drone position is inside the geofence, and prints the result.
📋 What You'll Learn
Create a dictionary called
geofence_center with keys 'latitude' and 'longitude' and exact values 37.7749 and -122.4194Create a variable called
max_distance_km and set it to 5Write a function called
is_inside_geofence that takes lat and lon and returns true if the distance from geofence_center is less than or equal to max_distance_km, otherwise falsePrint the result of
is_inside_geofence(37.7790, -122.4183)💡 Why This Matters
🌍 Real World
Drones need geofence boundaries to avoid flying into restricted or dangerous areas, ensuring safety and compliance with regulations.
💼 Career
Understanding how to set and check geofence boundaries is important for drone software developers, UAV operators, and anyone working with autonomous flying devices.
Progress0 / 4 steps