Reference
Main application file for the gis intro app.
The module contains the main flask application and all routes. It also contains some helper functions to build a polygon from form data and to retrieve site names and site documents from the database.
© 2026 University of Glasgow Licensed under the BSD 3-Clause License
addbothy()
Creates a new bothy document.
Processes the bothy form and creates a new bothy representation as a dictionary,
inserts the new record and returns the map page with all bothies and sites.
N.B. Form validation is non existent. Consider wtf forms.
Source code in app.py
addsite()
Creates a new site document.
Processes the site form and creates a new site representation as a dictionary, inserts the new record and returns the map page with all bothies and sites. N.B. Form validation is non existent. Consider wtf forms.
Source code in app.py
bothyform()
build_polygon(longitude, latitude)
Converts a string of longitudes and latitudes to a polygon specification.
:param longitude: a csv string of longitudes for all points specified that will have a trailing comma and may or may not have the same point at the start and end (i.e., polygon may not be closed off) :param latitude: a csv string of latitudes for all points specified that will have a trailing comma and may or may not have the same point at the start and end (i.e., polygon may not be closed off)
:return: an array of point arrays defining the polygon :rtype: Array
Source code in app.py
results()
Returns a map of bothies and sites.
POST: Process the search form and return a page with a map showing bothies that match the search criteria. Search criteria can be a name, a circle defined by a centre point and radius, or a site defined by a polygon. If no search criteria is provided, no bothies are returned, but sites will be shown. N.B. Form validation is non existent. Consider wtf forms.
GET: Return a page with a map showing all bothies and sites.
Source code in app.py
retrieve_site_names()
returns a list of site names.
Finds all the site documents with just the property name field key and value and pulls out the property name field value.
:return: a unique list of site names excluding any empty names :rtype: Array
Source code in app.py
retrieve_sites()
Returns all site documents.
:return: all site documents without the id field :rtype: Cursor
search()
Returns the search form page with a dropdown of site names to search within.