@@ -27,6 +27,7 @@ fn liblrs_python(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
2727 m. add_class :: < AnchorOnLrm > ( ) ?;
2828 m. add_class :: < SegmentOfTraversal > ( ) ?;
2929 m. add_class :: < Builder > ( ) ?;
30+ m. add_class :: < DataIssueReporter > ( ) ?;
3031 Ok ( ( ) )
3132}
3233
@@ -576,15 +577,22 @@ impl Builder {
576577 /// Read the topology from an OpenStreetMap source
577578 ///
578579 /// It reads the nodes, segments and traversals.
579- pub fn read_from_osm (
580+ pub fn read_from_osm < ' py > (
580581 & mut self ,
581582 input_osm_file : PathBuf ,
582583 lrm_tag : String ,
583584 required : Vec < ( String , String ) > ,
584585 to_reject : Vec < ( String , String ) > ,
586+ reporter : Bound < ' py , DataIssueReporter > ,
585587 ) {
586- self . inner
587- . read_from_osm ( & input_osm_file, & lrm_tag, required, to_reject)
588+ let mut reporter = PythonDataIssueReporter ( reporter) ;
589+ self . inner . read_from_osm (
590+ & input_osm_file,
591+ & lrm_tag,
592+ required,
593+ to_reject,
594+ Some ( & mut reporter) ,
595+ )
588596 }
589597
590598 /// Save the lrs to a file
@@ -656,3 +664,52 @@ impl Builder {
656664}
657665
658666define_stub_info_gatherer ! ( stub_info) ;
667+
668+ #[ gen_stub_pyclass]
669+ #[ pyclass( subclass) ]
670+ struct DataIssueReporter { }
671+
672+ #[ pymethods]
673+ impl DataIssueReporter {
674+ #[ new]
675+ fn new ( ) -> Self {
676+ Self { }
677+ }
678+ }
679+
680+ #[ allow( unused_variables) ]
681+ #[ gen_stub_pymethods]
682+ impl liblrs:: DataIssueReporter for DataIssueReporter {
683+ fn report_ignoring_traversal_edges (
684+ & mut self ,
685+ traversal_ref : & str ,
686+ ignored_count : usize ,
687+ total_count : usize ,
688+ first_node : i64 ,
689+ last_node : i64 ,
690+ ) {
691+ }
692+ }
693+
694+ struct PythonDataIssueReporter < ' a > ( Bound < ' a , DataIssueReporter > ) ;
695+ impl liblrs:: DataIssueReporter for PythonDataIssueReporter < ' _ > {
696+ fn report_ignoring_traversal_edges (
697+ & mut self ,
698+ traversal_ref : & str ,
699+ ignored_count : usize ,
700+ total_count : usize ,
701+ first_node : i64 ,
702+ last_node : i64 ,
703+ ) {
704+ let _ = self . 0 . call_method1 (
705+ "report_ignoring_traversal_edges" ,
706+ (
707+ traversal_ref,
708+ ignored_count,
709+ total_count,
710+ first_node,
711+ last_node,
712+ ) ,
713+ ) ;
714+ }
715+ }
0 commit comments