Programming API Location

Navigate

    A Location represents a place on the earth. Together with Observations, Locations form a contribution. Location and Observation are separate to enable reusing existing Locations for various Observations.

    Attributes

    Parameter Type Description
    id int Identifies the location in the database.
    name string Short title of the location.
    description string Longer description about the location.
    geometry GEOSGeometry Shape and geographic location.
    created_at datetime Date and time when location was created.
    creator User User who created the location.
    status string Status of the location, must be one of active, review. Defaults to active.
    private boolean Indicates if the location can be reused with other observations. If true, the location is not re-usable, unless private_for_project is set; then the location is re-usable for the specified project.
    private_for_project Project Optional. Indicates the project, in which the location can be used.

    Creating a location instance

    Location.objects.create(**kwargs)

    Parameters
    name: string
    Title for the location.
    description: string
    Optional. A long-form description for the location.
    geometry: GEOSGeometry
    Shape and geographic location.
    creator: User
    User, who creates the location.
    private: boolean
    Optional. Indicates if the location can be reused with other observations. If true the location is not re-usable, unless private_for_project is set; then the location is re-usable for the specified project.
    private_for_project: Project
    Optional. Indicates the project, in which the location can be used.
    Returns

    Location

    Example
    from django.contrib.gis.geos import GEOSGeometry
    from geokey.contributions.models import Location
    
    Location.objects.create(
        name='Buckingham Palace',
        description='You know, the Queen lives here',
        geometry=GEOSGeometry('{ "type": "Point", "coordinates": [ -0.1418781280517578, 51.50128299559082 ] }'),
        creator=user,
        private=False
    )
    

    Accessing model instances

    get_list(user, project_id)

    Returns a list of locations that can be used with the project.

    Parameters
    user: User
    User the location is queried for.
    project_id: integer
    Identifies the project in the database.
    Returns

    django.db.models.query.QuerySet: List of Locations

    get_single(user, project_id, location_id)

    Returns a single location.

    Parameters
    user: User
    User the location is queried for.
    project_id: integer
    Identifies the project in the database.
    location_id: integer
    Identifies the location in the database.
    Returns

    Location

    Raises
    PermissionDenied
    If the the location can not be used with the project.