@@ -108,32 +108,38 @@ def validate(self, max_errors=20) -> ValidationResult:
108108 is_valid = len (unmatched ) == 0
109109 if not is_valid :
110110 unmatched_list = list (unmatched )
111- displayed_unmatched = ', ' .join (map (str , unmatched_list [:20 ]))
111+ num_unmatched = len (unmatched_list )
112+ limit = min (num_unmatched , 20 )
113+ displayed_unmatched = ', ' .join (map (str , unmatched_list [:limit ]))
112114 self .errors .append (
113115 f"All _u_id's in edges should be part of _id's mentioned in nodes. "
114- f"Showing 20 out of { len (unmatched )} unmatched _u_id's: { displayed_unmatched } "
116+ f"Showing { '20' if num_unmatched > 20 else 'all' } out of { len (unmatched )} unmatched _u_id's: { displayed_unmatched } "
115117 )
116118
117119 # Do all node references in _v_id exist in nodes?
118120 unmatched = node_ids_edges_v - node_ids
119121 is_valid = len (unmatched ) == 0
120122 if not is_valid :
121123 unmatched_list = list (unmatched )
122- displayed_unmatched = ', ' .join (map (str , unmatched_list [:20 ]))
124+ num_unmatched = len (unmatched_list )
125+ limit = min (num_unmatched , 20 )
126+ displayed_unmatched = ', ' .join (map (str , unmatched_list [:limit ]))
123127 self .errors .append (
124128 f"All _v_id's in edges should be part of _id's mentioned in nodes. "
125- f"Showing 20 out of { len (unmatched )} unmatched _v_id's: { displayed_unmatched } "
129+ f"Showing { '20' if num_unmatched > 20 else 'all' } out of { len (unmatched )} unmatched _v_id's: { displayed_unmatched } "
126130 )
127131
128132 # Do all node references in _w_id exist in nodes?
129133 unmatched = node_ids_zones_w - node_ids
130134 is_valid = len (unmatched ) == 0
131135 if not is_valid :
132136 unmatched_list = list (unmatched )
133- displayed_unmatched = ', ' .join (map (str , unmatched_list [:20 ]))
137+ num_unmatched = len (unmatched_list )
138+ limit = min (num_unmatched , 20 )
139+ displayed_unmatched = ', ' .join (map (str , unmatched_list [:limit ]))
134140 self .errors .append (
135141 f"All _w_id's in zones should be part of _id's mentioned in nodes. "
136- f"Showing 20 out of { len (unmatched )} unmatched _w_id's: { displayed_unmatched } "
142+ f"Showing { '20' if num_unmatched > 20 else 'all' } out of { len (unmatched )} unmatched _w_id's: { displayed_unmatched } "
137143 )
138144
139145 # Geometry validation: check geometry type in each file and test if coordinates make a shape that is reasonable geometric shape according to the Simple Feature Access standard
@@ -143,8 +149,14 @@ def validate(self, max_errors=20) -> ValidationResult:
143149 OSW_DATASET [osw_file ].is_valid == False )]
144150 is_valid = len (invalid_geojson ) == 0
145151 if not is_valid :
152+ invalid_ids = list (set (invalid_geojson ['_id' ]))
153+ num_invalid = len (invalid_ids )
154+ limit = min (num_invalid , 20 )
155+ displayed_invalid = ', ' .join (map (str , invalid_ids [:min (num_invalid , limit )]))
146156 self .errors .append (
147- f"Invalid { osw_file } geometries found, id's of invalid geometries: { set (invalid_geojson ['_id' ])} " )
157+ f"Showing { '20' if num_invalid > 20 else 'all' } out of { num_invalid } invalid { osw_file } geometries, "
158+ f"id's of invalid geometries: { displayed_invalid } "
159+ )
148160
149161 # Validate OSW external extensions
150162 for file in validator .externalExtensions :
0 commit comments