@@ -5,6 +5,9 @@ use crate::geodesic_capability as caps;
55use crate :: geomath;
66use std:: collections:: HashMap ;
77
8+ /// A geodesic line.
9+ ///
10+ /// Facilitates the determination of a series of points on a single geodesic.
811#[ derive( Copy , Clone , PartialEq , PartialOrd , Debug ) ]
912pub struct GeodesicLine {
1013 tiny_ : f64 , // This should be moved to consts
@@ -47,6 +50,26 @@ pub struct GeodesicLine {
4750}
4851
4952impl GeodesicLine {
53+ /// Create a new geodesic line from an initial point and azimuth.
54+ ///
55+ /// # Arguments
56+ /// - geod - geodesic parameters
57+ /// - lat1 - initial latitude (degrees)
58+ /// - lon1 - initial longitude (degrees)
59+ /// - azi1 - initial azimuth (degrees)
60+ /// - caps - bitor'ed combination of [capabilities](caps); defaults to `STANDARD | DISTANCE_IN`
61+ /// - `caps |= LATITUDE` for the latitude lat2; this is added automatically
62+ /// - `caps |= LONGITUDE` for the longitude lon2
63+ /// - `caps |= AZIMUTH` for the azimuth azi2; this is added automatically
64+ /// - `caps |= DISTANCE` for the distance s12
65+ /// - `caps |= REDUCEDLENGTH` for the reduced length m12
66+ /// - `caps |= GEODESICSCALE` for the geodesic scales M12 and M21
67+ /// - `caps |= AREA` for the area S12
68+ /// - `caps |= DISTANCE_IN` permits the length of the geodesic to be given in terms of s12;
69+ /// without this capability the length can only be specified in terms of arc length
70+ /// - `caps |= ALL` for all of the above
71+ /// - salp1 - sine of initial azimuth
72+ /// - calp1 - cosine of initial azimuth
5073 pub fn new (
5174 geod : & geodesic:: Geodesic ,
5275 lat1 : f64 ,
@@ -197,7 +220,46 @@ impl GeodesicLine {
197220 }
198221 }
199222
200- /// returns (a12, lat2, lon2, azi2, s12, m12, M12, M21, S12)
223+ /// Place a point at a given distance along this line.
224+ ///
225+ /// # Arguments
226+ /// - arcmode - Indicates if s12_a12 is an arc length (true) or distance (false)
227+ /// - s12_a12 - Distance to point (meters) or arc length (degrees); can be negative
228+ /// - outmask - bitor'ed combination of [capabilities](caps) defining which values to return
229+ /// - `outmask |= LATITUDE` for the latitude lat2
230+ /// - `outmask |= LONGITUDE` for the longitude lon2
231+ /// - `outmask |= AZIMUTH` for the azimuth azi2
232+ /// - `outmask |= DISTANCE` for the distance s12
233+ /// - `outmask |= REDUCEDLENGTH` for the reduced length m12
234+ /// - `outmask |= GEODESICSCALE` for the geodesic scales M12 and M21
235+ /// - `outmask |= ALL` for all of the above
236+ /// - `outmask |= LONG_UNROLL` to unroll lon2 (instead of reducing it to the range [−180°, 180°])
237+ ///
238+ /// # Returns
239+ /// Values are [f64::NAN] if not supported by the specified capabilities.
240+ /// - a12 arc length between point 1 and point 2 (degrees)
241+ /// - lat2 latitude of point 2 (degrees)
242+ /// - lon2 longitude of point 2 (degrees)
243+ /// - azi2 (forward) azimuth at point 2 (degrees)
244+ /// - s12 distance between point 1 and point 2 (meters)
245+ /// - m12 reduced length of geodesic (meters)
246+ /// - M12 geodesic scale of point 2 relative to point 1 (dimensionless)
247+ /// - M21 geodesic scale of point 1 relative to point 2 (dimensionless)
248+ /// - S12 area under the geodesic (meters<sup>2</sup>)
249+ ///
250+ /// # Example
251+ /// ```rust
252+ /// use geographiclib_rs::{Geodesic, GeodesicLine, geodesic_capability as caps};
253+ /// let g = Geodesic::wgs84();
254+ /// let outmask = caps::LATITUDE | caps::LONGITUDE | caps::AZIMUTH | caps::DISTANCE_IN;
255+ /// let line = GeodesicLine::new(&g, -11.95887, -116.94513, 92.712619830452549, Some(outmask), None, None);
256+ /// let (_, lat2, lon2, azi2, _, _, _, _, _) = line._gen_position(false, 13834722.5801401374, outmask);
257+ ///
258+ /// use approx::assert_relative_eq;
259+ /// assert_relative_eq!(lat2, 4.57352, epsilon=1e-13);
260+ /// assert_relative_eq!(lon2, 7.16501, epsilon=1e-13);
261+ /// assert_relative_eq!(azi2, 78.64960934409585, epsilon=1e-13);
262+ /// ```
201263 pub fn _gen_position (
202264 & self ,
203265 arcmode : bool ,
0 commit comments