@@ -7,8 +7,10 @@ use liblrs::lrs::LrmHandle;
77use liblrs:: lrs:: { LrsBase , Properties } ;
88use liblrs:: lrs_ext:: * ;
99use pyo3:: { exceptions:: PyTypeError , prelude:: * } ;
10+ use pyo3_stub_gen:: { define_stub_info_gatherer, derive:: * } ;
1011
1112/// Holds the whole Linear Referencing System.
13+ #[ gen_stub_pyclass]
1214#[ pyclass]
1315pub struct Lrs {
1416 lrs : ExtLrs ,
@@ -30,6 +32,7 @@ fn liblrs_python(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
3032
3133#[ derive( Clone , Copy , Debug ) ]
3234/// A geographical [`Point`], it can be either a projected or spherical coordinates.
35+ #[ gen_stub_pyclass]
3336#[ pyclass]
3437pub struct Point {
3538 /// Position on x-axis or `longitude`.
@@ -40,6 +43,7 @@ pub struct Point {
4043 pub y : f64 ,
4144}
4245
46+ #[ gen_stub_pymethods]
4347#[ pymethods]
4448impl Point {
4549 #[ new]
@@ -90,6 +94,7 @@ impl From<Point> for geo_types::Coord {
9094
9195#[ derive( Clone , Debug ) ]
9296/// A Node is a topological element of the [`Lrs`] that represents a intersection (or an extremity) of an [`Lrm`]
97+ #[ gen_stub_pyclass]
9398#[ pyclass]
9499pub struct Node {
95100 /// Identifies this [`Node`].
@@ -117,6 +122,7 @@ impl From<&liblrs::lrs::Node> for Node {
117122/// A segment is a topological element of the [`Lrs`] that represents a piece of the [`Curve`] of an [`Lrm`]
118123///
119124/// It has a start and end [`Node`].
125+ #[ gen_stub_pyclass]
120126#[ pyclass]
121127pub struct Segment {
122128 /// Identifies this [`Segment`]
@@ -146,6 +152,7 @@ impl From<&liblrs::lrs::Segment> for Segment {
146152
147153#[ pyclass]
148154#[ derive( Clone , Debug ) ]
155+ #[ gen_stub_pyclass]
149156/// Represent a position on an [`LrmScale`] relative as an `offset` to an [`Anchor`].
150157pub struct LrmScaleMeasure {
151158 #[ pyo3( get, set) ]
@@ -174,6 +181,7 @@ impl From<&LrmScaleMeasure> for liblrs::lrm_scale::LrmScaleMeasure {
174181 }
175182}
176183
184+ #[ gen_stub_pymethods]
177185#[ pymethods]
178186impl LrmScaleMeasure {
179187 #[ new]
@@ -191,6 +199,7 @@ impl LrmScaleMeasure {
191199}
192200
193201#[ derive( Clone , Copy ) ]
202+ #[ gen_stub_pyclass]
194203#[ pyclass]
195204/// A traversal is composed by segments
196205pub struct SegmentOfTraversal {
@@ -202,6 +211,7 @@ pub struct SegmentOfTraversal {
202211 pub reversed : bool ,
203212}
204213
214+ #[ gen_stub_pymethods]
205215#[ pymethods]
206216impl SegmentOfTraversal {
207217 #[ new]
@@ -223,6 +233,7 @@ impl From<SegmentOfTraversal> for liblrs::builder::SegmentOfTraversal {
223233}
224234
225235#[ derive( Clone , Copy , Debug ) ]
236+ #[ gen_stub_pyclass]
226237#[ pyclass]
227238/// The linear position of an anchor doesn’t always match the measured distance
228239/// For example if a road was transformed into a bypass, resulting in a longer road,
@@ -238,6 +249,7 @@ pub struct AnchorOnLrm {
238249 pub distance_along_lrm : f64 ,
239250}
240251
252+ #[ gen_stub_pymethods]
241253#[ pymethods]
242254impl AnchorOnLrm {
243255 #[ new]
@@ -263,6 +275,7 @@ impl From<AnchorOnLrm> for liblrs::builder::AnchorOnLrm {
263275}
264276
265277#[ derive( Debug ) ]
278+ #[ gen_stub_pyclass]
266279#[ pyclass]
267280/// An `Anchor` is a reference point for a given [`Curve`].
268281/// It can be a milestone, a bridge…
@@ -303,6 +316,7 @@ impl From<&liblrs::lrm_scale::Anchor> for Anchor {
303316 }
304317}
305318
319+ #[ gen_stub_pyclass]
306320#[ pyclass]
307321/// The result of a projection onto an [`LrmScale`].
308322pub struct LrmProjection {
@@ -330,11 +344,12 @@ impl From<&liblrs::lrs::LrmProjection> for LrmProjection {
330344 }
331345}
332346
347+ #[ gen_stub_pymethods]
333348#[ pymethods]
334349impl Lrs {
335350 /// Load the data.
336351 #[ new]
337- pub fn load ( data : & [ u8 ] ) -> PyResult < Lrs > {
352+ pub fn load ( # [ gen_stub ( override_type ( type_repr = "bytes" ) ) ] data : & [ u8 ] ) -> PyResult < Lrs > {
338353 ExtLrs :: load ( data)
339354 . map ( |lrs| Self { lrs } )
340355 . map_err ( |e| PyTypeError :: new_err ( e. to_string ( ) ) )
@@ -462,11 +477,13 @@ impl Lrs {
462477 }
463478}
464479
480+ #[ gen_stub_pyclass]
465481#[ pyclass]
466482struct Builder {
467483 inner : liblrs:: builder:: Builder < ' static > ,
468484}
469485
486+ #[ gen_stub_pymethods]
470487#[ pymethods]
471488impl Builder {
472489 #[ new]
@@ -637,3 +654,5 @@ impl Builder {
637654 . unwrap ( )
638655 }
639656}
657+
658+ define_stub_info_gatherer ! ( stub_info) ;
0 commit comments