Returns a GeoJSON-compatible representation of the geometry.
(self, encoder: Any | None = None)
| 603 | |
| 604 | @_utils.accept_opt_prefix('opt_encoder') |
| 605 | def encode(self, encoder: Any | None = None) -> dict[str, Any]: |
| 606 | """Returns a GeoJSON-compatible representation of the geometry.""" |
| 607 | if not getattr(self, '_type', None): |
| 608 | return super().encode(encoder) |
| 609 | |
| 610 | result = {'type': self._type} |
| 611 | if self._type == 'GeometryCollection': |
| 612 | result['geometries'] = self._geometries |
| 613 | else: |
| 614 | result['coordinates'] = self._coordinates |
| 615 | |
| 616 | if self._proj is not None: |
| 617 | result['crs'] = {'type': 'name', 'properties': {'name': self._proj}} |
| 618 | |
| 619 | if self._geodesic is not None: |
| 620 | result['geodesic'] = self._geodesic |
| 621 | |
| 622 | if self._evenOdd is not None: |
| 623 | result['evenOdd'] = self._evenOdd |
| 624 | |
| 625 | return result |
| 626 | |
| 627 | def encode_cloud_value(self, encoder: Any) -> Any: |
| 628 | """Returns a server-side invocation of the appropriate constructor.""" |