fairdm.utils.location.db#
The constraints and index a model with a location lists in its own Meta.
Module Contents#
Functions#
Return the check constraints that keep a record’s three location fields consistent. |
|
Return the index that distance lookups on a |
API#
- location_constraints()#
Return the check constraints that keep a record’s three location fields consistent.
An uncertainty is null or zero or more, and an elevation or an uncertainty needs a point. A concrete model lists these in its own
Meta.constraints, because a type that subclassesSamplewithout aMetaof its own would otherwise inherit them onto a table that has none of the columns.Returns: A list of two check constraints, named from the app label and class name of the model that lists them.
- geography_index(name)#
Return the index that distance lookups on a
locationread.The expression has to match the one the lookups cast to, or PostgreSQL will not use it. A model that declares its own
Meta.indexeslists this index there, because aMetathat setsindexesreplaces an inherited list.Args: name: The index name, 30 characters or fewer.
Returns: A GiST index on the location as a geography.