MCPcopy Create free account
hub / github.com/MongoEngine/mongoengine / _geo_indices

Method _geo_indices

mongoengine/base/document.py:1027–1061  ·  view source on GitHub ↗
(cls, inspected=None, parent_field=None)

Source from the content-addressed store, hash-verified

1025
1026 @classmethod
1027 def _geo_indices(cls, inspected=None, parent_field=None):
1028 inspected = inspected or []
1029 geo_indices = []
1030 inspected.append(cls)
1031
1032 geo_field_type_names = (
1033 "EmbeddedDocumentField",
1034 "GeoPointField",
1035 "PointField",
1036 "LineStringField",
1037 "PolygonField",
1038 )
1039
1040 geo_field_types = tuple(_import_class(field) for field in geo_field_type_names)
1041
1042 for field in cls._fields.values():
1043 if not isinstance(field, geo_field_types):
1044 continue
1045
1046 if hasattr(field, "document_type"):
1047 field_cls = field.document_type
1048 if field_cls in inspected:
1049 continue
1050
1051 if hasattr(field_cls, "_geo_indices"):
1052 geo_indices += field_cls._geo_indices(
1053 inspected, parent_field=field.db_field
1054 )
1055 elif field._geo_index:
1056 field_name = field.db_field
1057 if parent_field:
1058 field_name = f"{parent_field}.{field_name}"
1059 geo_indices.append({"fields": [(field_name, field._geo_index)]})
1060
1061 return geo_indices
1062
1063 @classmethod
1064 def _lookup_field(cls, parts):

Calls 1

_import_classFunction · 0.90