qibla-dart/.github/wiki/guides/advanced.md
Aric Camarata cc3c227d2d
feat: surface-area parity audit vs qibla-js (v1.0.1) (#1)
* chore: surface-area parity audit vs qibla-js, bump to v1.0.1

Full gap analysis: qibla-dart already matches @acamarata/qibla on all five
public functions (qiblaAngle, compassDir, compassName, qiblaGreatCircle,
distanceKm) and three constants (kaabaLat, kaabaLng, earthRadiusKm).
No runtime gaps found; 48/48 tests pass unchanged.

Patch bump documents the audit and closes T-E10-01 (Mega Phase 1).

* docs: add CHANGELOG.md for v1.0.1 release

* chore: polish pubspec, add wiki docs
2026-05-29 06:49:15 -04:00

50 lines
1.3 KiB
Markdown

# Advanced Usage
## Great-Circle Path
Compute N interpolated waypoints along the great-circle route from your location to the Ka'bah:
```dart
import 'package:qibla/qibla.dart';
void main() {
// 5 waypoints from New York to Makkah
final path = greatCirclePath(40.7128, -74.0060, kaabaLat, kaabaLng, 5);
for (final point in path) {
print('${point.latitude.toStringAsFixed(4)}, ${point.longitude.toStringAsFixed(4)}');
}
}
```
The path uses spherical linear interpolation (Slerp) and returns `n` evenly spaced coordinates including the start and end points.
## Custom Destination
`distanceKm` and `greatCirclePath` work with any two points, not just the Ka'bah:
```dart
// Distance between two mosques
final km = distanceKm(51.5074, -0.1278, 40.7128, -74.0060);
print('London to New York: ${km.toStringAsFixed(0)} km');
// Path from Istanbul to Makkah
final path = greatCirclePath(41.0082, 28.9784, kaabaLat, kaabaLng, 10);
```
## Flutter Compass Widget Integration
```dart
import 'package:qibla/qibla.dart';
// In a StatefulWidget with device compass heading:
Widget buildQiblaArrow(double deviceHeading, double lat, double lng) {
final qibla = qiblaAngle(lat, lng);
final arrowRotation = (qibla - deviceHeading) * (pi / 180);
return Transform.rotate(
angle: arrowRotation,
child: const Icon(Icons.navigation, size: 48),
);
}
```