Locations represent ground positions or areas that satellites can access. Brahe provides two fundamental location types—points and polygons—with full GeoJSON interoperability and extensible metadata support.
All location types implement the AccessibleLocation trait, which provides a common interface for coordinate access, property management, and GeoJSON import/export. This design allows you to work with different location geometries through a unified API.
Coordinate Units
All coordinates are specified in geodetic longitude (λ), latitude (φ), and altitude (h) using the WGS84 reference frame. All units are in degrees (for λ and φ) and meters (for h) for consistency with the GeoJSON standard.
A PointLocation represents a single geodetic point on Earth's surface. This is the most common location type, used for ground stations, cities, or specific observation points.
usebraheasbh;usebh::utils::Identifiable;usebh::AccessibleLocation;fnmain(){bh::initialize_eop().unwrap();// Create location (longitude, latitude, altitude in meters)// San Francisco, CAletsf=bh::PointLocation::new(-122.4194,// longitude in degrees37.7749,// latitude in degrees0.0// altitude in meters).with_name("San Francisco");letgeodetic=sf.center_geodetic();println!("Location: {}",sf.get_name().unwrap_or_default());println!("Longitude: {:.4} deg",geodetic[0]);println!("Latitude: {:.4} deg",geodetic[1]);}
importbraheasbhbh.initialize_eop()location=bh.PointLocation(-122.4194,37.7749,0.0)# Access in degreesprint(f"Longitude: {location.longitude(bh.AngleFormat.DEGREES)} deg")print(f"Latitude: {location.latitude(bh.AngleFormat.DEGREES)} deg")print(f"Altitude: {location.altitude()} m")# Shorthand access (in degrees)print(f"Lon (deg): {location.lon:.6f}")print(f"Lat (deg): {location.lat:.6f}")# Get geodetic array [lat, lon, alt] in radians and metersgeodetic=location.center_geodetic()print(f"Geodetic: [{geodetic[0]:.6f}, {geodetic[1]:.6f}, {geodetic[2]:.1f}]")# Get ECEF Cartesian position [x, y, z] in metersecef=location.center_ecef()print(f"ECEF: [{ecef[0]:.1f}, {ecef[1]:.1f}, {ecef[2]:.1f}] m")
usebraheasbh;usebh::AccessibleLocation;fnmain(){bh::initialize_eop().unwrap();letlocation=bh::PointLocation::new(-122.4194,37.7749,0.0);// Access geodetic coordinates (in degrees)letgeodetic=location.center_geodetic();println!("Longitude: {:.4} deg",geodetic[0]);println!("Latitude: {:.4} deg",geodetic[1]);println!("Altitude: {:.1} m",geodetic[2]);// Get ECEF Cartesian position [x, y, z] in metersletecef=location.center_ecef();println!("ECEF: [{:.1}, {:.1}, {:.1}] m",ecef[0],ecef[1],ecef[2]);}
A PolygonLocation represents a closed polygon area on Earth's surface. This is useful for imaging regions, coverage zones, or geographic areas of interest.
usebraheasbh;usebh::utils::Identifiable;usebh::AccessibleLocation;usenalgebraasna;fnmain(){bh::initialize_eop().unwrap();// Define polygon vertices (lon, lat, alt in degrees and meters)letvertices=vec![na::SVector::<f64,3>::new(-122.5,37.7,0.0),na::SVector::<f64,3>::new(-122.35,37.7,0.0),na::SVector::<f64,3>::new(-122.35,37.8,0.0),na::SVector::<f64,3>::new(-122.5,37.8,0.0),na::SVector::<f64,3>::new(-122.5,37.7,0.0),];letpolygon=bh::PolygonLocation::new(vertices).unwrap().with_name("SF Region");letcenter=polygon.center_geodetic();println!("Name: {}",polygon.get_name().unwrap_or_default());println!("Vertices: {}",polygon.num_vertices());println!("Center: ({:.4}, {:.4})",center[0],center[1]);}
importbraheasbhbh.initialize_eop()location=(bh.PointLocation(-122.4194,37.7749,0.0).with_name("San Francisco").with_id(1))# Export to GeoJSON dictgeojson=location.to_geojson()print("Exported GeoJSON:")print(geojson)# The output includes all properties and identifiers# Can be loaded back with from_geojson()reloaded=bh.PointLocation.from_geojson(geojson)print(f"\nReloaded: {reloaded.get_name()} (ID: {reloaded.get_id()})")
usebraheasbh;usebh::utils::Identifiable;usebh::AccessibleLocation;fnmain(){bh::initialize_eop().unwrap();letlocation=bh::PointLocation::new(-122.4194,37.7749,0.0).with_name("San Francisco").with_id(1);// Export to GeoJSONletgeojson=location.to_geojson();println!("Exported GeoJSON:");println!("{}",geojson);// The output includes all properties and identifiers// Can be loaded back with from_geojson()letreloaded=bh::PointLocation::from_geojson(&geojson).unwrap();println!("\nReloaded: {} (ID: {})",reloaded.get_name().unwrap_or_default(),reloaded.get_id().unwrap_or(0));}
Exported GeoJSON:
{"geometry":{"coordinates":[-122.4194,37.7749,0.0],"type":"Point"},"properties":{"id":1,"name":"San Francisco","uuid":"019d1879-9bfa-7852-9ab9-0a57218b1ee6"},"type":"Feature"}
Reloaded: San Francisco (ID: 1)