Validate an iterable with possibly nested lists of coordinate pairs.
(
locations: TypeMultiLine,
)
| 134 | |
| 135 | |
| 136 | def validate_multi_locations( |
| 137 | locations: TypeMultiLine, |
| 138 | ) -> Union[List[List[float]], List[List[List[float]]]]: |
| 139 | """Validate an iterable with possibly nested lists of coordinate pairs.""" |
| 140 | locations = if_pandas_df_convert_to_numpy(locations) |
| 141 | _validate_locations_basics(locations) |
| 142 | try: |
| 143 | float(next(iter(next(iter(next(iter(locations))))))) # type: ignore |
| 144 | except (TypeError, StopIteration): |
| 145 | # locations is a list of coordinate pairs |
| 146 | return [validate_location(coord_pair) for coord_pair in locations] # type: ignore |
| 147 | else: |
| 148 | # locations is a list of a list of coordinate pairs, recurse |
| 149 | return [validate_locations(lst) for lst in locations] # type: ignore |
| 150 | |
| 151 | |
| 152 | def if_pandas_df_convert_to_numpy(obj: Any) -> Any: |