Convert data into a FeatureCollection if it is not already.
(self)
| 783 | return requests.get(url).json() |
| 784 | |
| 785 | def convert_to_feature_collection(self) -> None: |
| 786 | """Convert data into a FeatureCollection if it is not already.""" |
| 787 | if self.data["type"] == "FeatureCollection": |
| 788 | return |
| 789 | if not self.embed: |
| 790 | raise ValueError( |
| 791 | "Data is not a FeatureCollection, but it should be to apply " |
| 792 | "style or highlight. Because `embed=False` it cannot be " |
| 793 | "converted into one.\nEither change your geojson data to a " |
| 794 | "FeatureCollection, set `embed=True` or disable styling." |
| 795 | ) |
| 796 | # Catch case when GeoJSON is just a single Feature or a geometry. |
| 797 | if "geometry" not in self.data.keys(): |
| 798 | # Catch case when GeoJSON is just a geometry. |
| 799 | self.data = {"type": "Feature", "geometry": self.data} |
| 800 | self.data = {"type": "FeatureCollection", "features": [self.data]} |
| 801 | |
| 802 | def _validate_function(self, func: Callable, name: str) -> None: |
| 803 | """ |
no outgoing calls