# AeroNavX: Aviation Data & Intelligence Library

AeroNavX is a comprehensive Python library for aviation data analysis, flight route simulation, and calculating emissions using geodesic logic.

## Installation

```bash
pip install aeronavx
```

## Example Usage & Verification

The following example demonstrates route generation and distance calculation.

### Basic Usage (`tutorial.py`)

```python
import aeronavx as anx
from aeronavx import get_airport

# 1. Get Airport Data
ist = get_airport("IST")
lhr = get_airport("LHR")

print(f"Origin: {ist.name} ({ist.country})")
print(f"Dest:   {lhr.name} ({lhr.country})")

# 2. Calculate Distance
dist_km = anx.distance(ist.lat, ist.lon, lhr.lat, lhr.lon, unit='km')
print(f"Distance: {dist_km:.2f} km")

# 3. Flight Time Estimation (at 450 knots)
time_hrs = anx.estimate_flight_time(ist, lhr, speed_kts=450)
print(f"Est. Flight Time: {time_hrs:.2f} hours")
```

### Verified Output

```text
Origin: Istanbul Airport (Turkey)
Dest:   London Heathrow Airport (United Kingdom)
Distance: 2490.12 km
Est. Flight Time: 3.45 hours
```

### Advanced Usage: Emissions & Route Optimization (Verified)

```python
import aeronavx as anx
from aeronavx import get_airport

# Load airports
jfk = get_airport("JFK")
dxb = get_airport("DXB")

# Estimate CO2 for a commercial flight
co2 = anx.estimate_co2_kg_for_segment(jfk.iata_code, dxb.iata_code, code_type="iata")

# Calculate optimal technical stop (Great Circle Midpoint)
mid = anx.midpoint(jfk.latitude, jfk.longitude, dxb.latitude, dxb.longitude)

print(f"Flight: {jfk.name} -> {dxb.name}")
print(f"Est. CO2 Emissions: {co2:.2f} kg/pax")
print(f"Optimal Technical Stop (Midpoint): {mid[0]:.4f}, {mid[1]:.4f}")
```

**Verified Output:**
```text
Flight: John F Kennedy International Airport -> Dubai International Airport
Est. CO2 Emissions: 1265.18 kg/pax
Optimal Technical Stop (Midpoint): 56.0324, 1.2260
```

## Features
*   **Airports**: Search by IATA, ICAO, or city name.
*   **Geodesy**: Haversine, Vincenty, and Great Circle calculations.
*   **Emissions**: Estimate CO2 footprint for flight segments.
*   **Optimization**: Find nearest airports and optimal routes.

## License
MIT
