Package s3 :: Module s3gis :: Class GIS
[frames] | no frames]

Class GIS

source code

object --+
         |
        GIS

GeoSpatial functions

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
download_kml(self, record_id, filename, session_id_name, session_id)
Download a KML file: - unzip it if-required - follow NetworkLinks recursively if-required
source code
 
fetch_kml(self, url, filepath, session_id_name, session_id)
Fetch a KML file:
source code
 
get_bounds(self, features=None, bbox_min_size=None, bbox_inset=None)
Calculate the Bounds of a list of Point Features, suitable for setting map bounds.
source code
 
get_parent_bounds(self, parent=None)
Get bounds from the specified (parent) location and its ancestors.
source code
 
get_parent_per_level(self, results, feature_id, feature=None, ids=True, names=True)
Adds ancestor of requested feature for each level to supplied dict.
source code
 
update_table_hierarchy_labels(self, tablename=None)
Re-set table options that depend on location_hierarchy
source code
 
get_location_hierarchy(self, level=None, location=None)
Returns the location hierarchy and it's labels
source code
 
get_strict_hierarchy(self, location=None)
Returns the strict hierarchy value from the current config.
source code
 
get_max_hierarchy_level(self)
Returns the deepest level key (i.e.
source code
 
get_all_current_levels(self, level=None)
Get the current hierarchy levels plus non-hierarchy levels.
source code
 
get_relevant_hierarchy_levels(self, as_dict=False)
Get current location hierarchy levels relevant for the user
source code
 
get_parent_country(self, location, key_type="id")
Returns the parent country for a given record
source code
 
get_default_country(self, key_type="id")
Returns the default country for the active gis_config
source code
 
get_features_in_polygon(self, location, tablename=None, category=None)
Returns a gluon.sql.Rows of Features within a Polygon.
source code
 
get_features_in_radius(self, lat, lon, radius, tablename=None, category=None)
Returns Features within a Radius (in km) of a LatLon Location
source code
 
get_latlon(self, feature_id, filter=False)
Returns the Lat/Lon for a Feature
source code
 
import_admin_areas(self, source="gadmv1", countries=[], levels=["L0","L1","L2"])
Import Admin Boundaries into the Locations table
source code
 
import_gadm1(self, ogr, level="L1", countries=[])
Import L1 Admin Boundaries into the Locations table from GADMv1 - designed to be called from import_admin_areas() - assumes a fresh database with just Countries imported
source code
 
import_geonames(self, country, level=None)
Import Locations from the Geonames database
source code
 
show_map(self, id="default_map", height=None, width=None, bbox={}, lat=None, lon=None, zoom=None, projection=None, add_feature=False, add_feature_active=False, add_line=False, add_line_active=False, add_polygon=False, add_polygon_active=False, add_circle=False, add_circle_active=False, features=None, feature_queries=None, feature_resources=None, wms_browser={}, catalogue_layers=False, legend=False, toolbar=False, area=False, color_picker=False, clear_layers=None, nav=None, print_control=None, print_mode=False, save=False, search=False, mouse_position=None, overview=None, permalink=None, scaleline=None, zoomcontrol=None, zoomWheelEnabled=True, mgrs={}, window=False, window_hide=False, closable=True, maximizable=True, collapsed=False, callback="DEFAULT", plugins=None)
Returns the HTML to display a map
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
gps_symbols() source code
 
geocode(address, postcode=None, Lx_ids=None, geocoder=None)
Geocode an Address - used by S3LocationSelector settings.get_gis_geocode_imported_addresses
source code
 
geocode_r(lat, lon)
Reverse Geocode a Lat/Lon...
source code
 
get_bearing(lat_start, lon_start, lat_end, lon_end)
Given a Start & End set of Coordinates, return a Bearing Formula from: http://www.movable-type.co.uk/scripts/latlong.html
source code
 
get_children(id, level=None)
Return a list of IDs of all GIS Features which are children of the requested feature, using Materialized path for retrieving the children
source code
 
get_parents(feature_id, feature=None, ids_only=False)
Returns a list containing ancestors of the requested feature.
source code
 
set_config(config_id=None, force_update_cache=False)
Reads the specified GIS config from the DB, caches it in response.
source code
 
get_config()
Returns the current GIS config structure.
source code
 
get_countries(key_type="id")
Returns country code or L0 location id versus name for all countries.
source code
 
get_country(key, key_type="id")
Returns country name for given code or id from L0 locations.
source code
 
get_polygon_from_bounds(bbox)
Given a gis_location record or a bounding box dict with keys lon_min, lon_max, lat_min, lat_max, construct a WKT polygon with points at the corners.
source code
 
get_bounds_from_radius(lat, lon, radius)
Compute a bounding box given a Radius (in km) of a LatLon Location
source code
 
get_locations(table, query, join=True, geojson=True)
Returns the locations for an XML export - used by GIS.get_location_data() and S3PivotTable.geojson()
source code
 
get_location_data(resource, attr_fields=None, count=None)
Returns the locations, markers and popup tooltips for an XML export e.g.
source code
 
get_marker(controller=None, function=None, filter=None)
Returns a Marker dict...
source code
 
get_style(layer_id=None, aggregate=None)
Returns a Style dict...
source code
 
get_screenshot(config_id, temp=True, height=None, width=None)
Save a Screenshot of a saved map
source code
 
get_shapefile_geojson(resource)
Lookup Shapefile Layer polygons once per layer and not per-record
source code
 
get_theme_geojson(resource)
Lookup Theme Layer polygons once per layer and not per-record
source code
 
greatCircleDistance(lat1, lon1, lat2, lon2, quick=True)
Calculate the shortest distance (in km) over the earth's sphere between 2 points Formulae from: http://www.movable-type.co.uk/scripts/latlong.html (NB We could also use PostGIS functions, where possible, instead of this query)
source code
 
create_poly(feature)
Create a .poly file for OpenStreetMap exports http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format
source code
 
export_admin_areas(countries=[], levels=("L0","L1","L2","L3"), format="geojson", simplify=0.01, precision=4)
Export admin areas to /static/cache for use by interactive web-mapping services - designed for use by the Vulnerability Mapping
source code
 
import_gadm1_L0(ogr, countries=[])
Import L0 Admin Boundaries into the Locations table from GADMv1 - designed to be called from import_admin_areas() - assumes that basic prepop has been done, so that no new records need to be created
source code
 
import_gadm2(ogr, level="L0", countries=[])
Import Admin Boundaries into the Locations table from GADMv2 - designed to be called from import_admin_areas() - assumes that basic prepop has been done, so that no new L0 records need to be created
source code
 
latlon_to_wkt(lat, lon)
Convert a LatLon to a WKT string
source code
 
parse_location(wkt, lon=None, lat=None)
Parses a location from wkt, returning wkt, lat, lon, bounding box and type.
source code
 
update_location_tree(feature=None, all_locations=False, propagating=False)
Update GIS Locations' Materialized path, Lx locations, Lat/Lon & the_geom
source code
 
wkt_centroid(form)
OnValidation callback: If a WKT is defined: validate the format, calculate the LonLat of the Centroid, and set bounds Else if a LonLat is defined: calculate the WKT for the Point.
source code
 
query_features_by_bbox(lon_min, lat_min, lon_max, lat_max)
Returns a query of all Locations inside the given bounding box
source code
 
get_features_by_bbox(lon_min, lat_min, lon_max, lat_max)
Returns Rows of Locations whose shape intersects the given bbox.
source code
 
get_features_by_shape(shape)
Returns Rows of locations which intersect the given shape.
source code
 
get_features_by_latlon(lat, lon)
Returns a generator of locations whose shape intersects the given LatLon.
source code
 
get_features_by_feature(feature)
Returns all Locations whose geometry intersects the given feature.
source code
 
set_all_bounds()
Sets bounds for all locations without them.
source code
 
simplify(wkt, tolerance=None, preserve_topology=True, output="wkt", precision=None)
Simplify a complex Polygon using the Douglas-Peucker algorithm - NB This uses Python, better performance will be gained by doing this direct from the database if you are using PostGIS: ST_Simplify() is available as db(query).select(table.the_geom.st_simplify(tolerance).st_astext().with_alias('wkt')).first().wkt db(query).select(table.the_geom.st_simplify(tolerance).st_asgeojson().with_alias('geojson')).first().geojson
source code
Class Variables
  disable_update_location_tree = False
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

gps_symbols()
Static Method

source code 

download_kml(self, record_id, filename, session_id_name, session_id)

source code 

Download a KML file:
    - unzip it if-required
    - follow NetworkLinks recursively if-required

Save the file to the /uploads folder

Designed to be called asynchronously using:
    current.s3task.async("download_kml", [record_id, filename])

@param record_id: id of the record in db.gis_layer_kml
@param filename: name to save the file as
@param session_id_name: name of the session
@param session_id: id of the session

@ToDo: Pass error messages to Result & have JavaScript listen for these

fetch_kml(self, url, filepath, session_id_name, session_id)

source code 

Fetch a KML file:

  • unzip it if-required
  • follow NetworkLinks recursively if-required

Returns a file object

Designed as a helper function for download_kml()

geocode(address, postcode=None, Lx_ids=None, geocoder=None)
Static Method

source code 

Geocode an Address
- used by S3LocationSelector
          settings.get_gis_geocode_imported_addresses

@param address: street address
@param postcode: postcode
@param Lx_ids: list of ancestor IDs
@param geocoder: which geocoder service to use

geocode_r(lat, lon)
Static Method

source code 

Reverse Geocode a Lat/Lon
- used by S3LocationSelector

get_bearing(lat_start, lon_start, lat_end, lon_end)
Static Method

source code 

Given a Start & End set of Coordinates, return a Bearing Formula from: http://www.movable-type.co.uk/scripts/latlong.html

get_bounds(self, features=None, bbox_min_size=None, bbox_inset=None)

source code 

            Calculate the Bounds of a list of Point Features, suitable for
            setting map bounds. If no features are supplied, the current map
            configuration bounds will be returned.
            e.g. When a map is displayed that focuses on a collection of points,
                 the map is zoomed to show just the region bounding the points.
            e.g. To use in GPX export for correct zooming
`
            Ensure a minimum size of bounding box, and that the points
            are inset from the border.

            @param features: A list of point features
            @param bbox_min_size: Minimum bounding box - gives a minimum width
                   and height in degrees for the region shown.
                   Without this, a map showing a single point would not show any
                   extent around that point.
            @param bbox_inset: Bounding box insets - adds a small amount of
                   distance outside the points.
                   Without this, the outermost points would be on the bounding
                   box, and might not be visible.
            @return: An appropriate map bounding box, as a dict:
                   dict(lon_min=lon_min, lat_min=lat_min,
                        lon_max=lon_max, lat_max=lat_max)

            @ToDo: Support Polygons (separate function?)
        

get_parent_bounds(self, parent=None)

source code 

Get bounds from the specified (parent) location and its ancestors. This is used to validate lat, lon, and bounds for child locations.

Caution: This calls update_location_tree if the parent bounds are not set. During prepopulate, update_location_tree is disabled, so unless the parent contains its own bounds (i.e. they do not need to be propagated down from its ancestors), this will not provide a check on location nesting. Prepopulate data should be prepared to be correct. A set of candidate prepopulate data can be tested by importing after prepopulate is run.

Parameters:
  • parent - A location_id to provide bounds suitable for validating child locations
Returns:
bounding box and parent location name, as a list: [lat_min, lon_min, lat_max, lon_max, parent_name]

To Do: Support Polygons (separate function?)

get_children(id, level=None)
Static Method

source code 

Return a list of IDs of all GIS Features which are children of the requested feature, using Materialized path for retrieving the children

This has been chosen over Modified Preorder Tree Traversal for greater efficiency: http://eden.sahanafoundation.org/wiki/HaitiGISToDo#HierarchicalTrees

Returns:
Rows object containing IDs & Names Note: This does NOT include the parent location itself

get_parents(feature_id, feature=None, ids_only=False)
Static Method

source code 

Returns a list containing ancestors of the requested feature.

If the caller already has the location row, including path and parent fields, they can supply it via feature to avoid a db lookup.

If ids_only is false, each element in the list is a gluon.sql.Row containing the gis_location record of an ancestor of the specified location.

If ids_only is true, just returns a list of ids of the parents. This avoids a db lookup for the parents if the specified feature has a path.

List elements are in the opposite order as the location path and exclude the specified location itself, i.e. element 0 is the parent and the last element is the most distant ancestor.

Assists lazy update of a database without location paths by calling update_location_tree to get the path.

Note that during prepopulate, update_location_tree is disabled, in which case this will only return the immediate parent.

get_parent_per_level(self, results, feature_id, feature=None, ids=True, names=True)

source code 

Adds ancestor of requested feature for each level to supplied dict.

If the caller already has the location row, including path and parent fields, they can supply it via feature to avoid a db lookup.

If a dict is not supplied in results, one is created. The results dict is returned in either case.

If ids=True and names=False (used by old S3LocationSelectorWidget): For each ancestor, an entry is added to results, like ancestor.level : ancestor.id

If ids=False and names=True (used by address_onvalidation): For each ancestor, an entry is added to results, like ancestor.level : ancestor.name

If ids=True and names=True (used by new S3LocationSelectorWidget): For each ancestor, an entry is added to results, like ancestor.level : {name : ancestor.name, id: ancestor.id}

update_table_hierarchy_labels(self, tablename=None)

source code 

Re-set table options that depend on location_hierarchy

Only update tables which are already defined

set_config(config_id=None, force_update_cache=False)
Static Method

source code 

Reads the specified GIS config from the DB, caches it in response.

Passing in a false or non-existent id will cause the personal config, if any, to be used, else the site config (uuid SITE_DEFAULT), else their fallback values defined in this class.

If force_update_cache is true, the config will be read and cached in response even if the specified config is the same as what's already cached. Used when the config was just written.

The config itself will be available in response.s3.gis.config. Scalar fields from the gis_config record and its linked gis_projection record have the same names as the fields in their tables and can be accessed as response.s3.gis.<fieldname>.

Returns the id of the config it actually used, if any.

To Do: Merge configs for Event

get_config()
Static Method

source code 

Returns the current GIS config structure.

To Do: Config() class

get_location_hierarchy(self, level=None, location=None)

source code 

Returns the location hierarchy and it's labels

@param: level - a specific level for which to lookup the label
@param: location - the location_id to lookup the location for
                   currently only the actual location is supported
                   @ToDo: Do a search of parents to allow this
                          lookup for any location

get_strict_hierarchy(self, location=None)

source code 

Returns the strict hierarchy value from the current config.

get_max_hierarchy_level(self)

source code 

Returns the deepest level key (i.e. Ln) in the current hierarchy.
- used by gis_location_onvalidation()

get_all_current_levels(self, level=None)

source code 

Get the current hierarchy levels plus non-hierarchy levels.

get_relevant_hierarchy_levels(self, as_dict=False)

source code 

Get current location hierarchy levels relevant for the user

get_countries(key_type="id")
Static Method

source code 

Returns country code or L0 location id versus name for all countries.

The lookup is cached in the session

If key_type is "code", these are returned as an OrderedDict with country code as the key. If key_type is "id", then the location id is the key. In all cases, the value is the name.

get_country(key, key_type="id")
Static Method

source code 

Returns country name for given code or id from L0 locations.

The key can be either location id or country code, as specified by key_type.

get_parent_country(self, location, key_type="id")

source code 

Returns the parent country for a given record

To Do: Optimise to not use try/except

get_default_country(self, key_type="id")

source code 

Returns the default country for the active gis_config

get_features_in_polygon(self, location, tablename=None, category=None)

source code 

Returns a gluon.sql.Rows of Features within a Polygon. The Polygon can be either a WKT string or the ID of a record in the gis_location table

Currently unused.

To Do: Optimise to not use try/except

get_polygon_from_bounds(bbox)
Static Method

source code 

Given a gis_location record or a bounding box dict with keys lon_min, lon_max, lat_min, lat_max, construct a WKT polygon with points at the corners.

get_bounds_from_radius(lat, lon, radius)
Static Method

source code 

Compute a bounding box given a Radius (in km) of a LatLon Location

Note the order of the parameters.

@return a dict containing the bounds with keys min_lon, max_lon, min_lat, max_lat

See: http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates

get_features_in_radius(self, lat, lon, radius, tablename=None, category=None)

source code 

Returns Features within a Radius (in km) of a LatLon Location

Unused

get_latlon(self, feature_id, filter=False)

source code 

Returns the Lat/Lon for a Feature

used by display_feature() in gis controller

Parameters:
  • feature_id - the feature ID
  • filter - Filter out results based on deployment_settings

get_locations(table, query, join=True, geojson=True)
Static Method

source code 

Returns the locations for an XML export
- used by GIS.get_location_data() and S3PivotTable.geojson()

@ToDo: Support multiple locations for a single resource
       (e.g. a Project working in multiple Communities)

get_location_data(resource, attr_fields=None, count=None)
Static Method

source code 

Returns the locations, markers and popup tooltips for an XML export e.g. Feature Layers or Search results (Feature Resources) e.g. Exports in KML, GeoRSS or GPX format

Called by S3REST: S3Resource.export_tree()

get_marker(controller=None, function=None, filter=None)
Static Method

source code 

Returns a Marker dict
- called by xml.gis_encode() for non-geojson resources
- called by S3Map.widget() if no marker_fn supplied

get_style(layer_id=None, aggregate=None)
Static Method

source code 

Returns a Style dict
- called by S3Report.geojson()

get_screenshot(config_id, temp=True, height=None, width=None)
Static Method

source code 

Save a Screenshot of a saved map

Requires: PhantomJS http://phantomjs.org Selenium https://pypi.python.org/pypi/selenium

get_shapefile_geojson(resource)
Static Method

source code 

Lookup Shapefile Layer polygons once per layer and not per-record

Called by S3REST: S3Resource.export_tree()

To Do: Vary simplification level & precision by Zoom level

  • store this in the style?

get_theme_geojson(resource)
Static Method

source code 

Lookup Theme Layer polygons once per layer and not per-record

Called by S3REST: S3Resource.export_tree()

To Do: Vary precision by Lx

  • store this (& tolerance map) in the style?

greatCircleDistance(lat1, lon1, lat2, lon2, quick=True)
Static Method

source code 

Calculate the shortest distance (in km) over the earth's sphere between 2 points Formulae from: http://www.movable-type.co.uk/scripts/latlong.html (NB We could also use PostGIS functions, where possible, instead of this query)

create_poly(feature)
Static Method

source code 

Create a .poly file for OpenStreetMap exports http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format

export_admin_areas(countries=[], levels=("L0","L1","L2","L3"), format="geojson", simplify=0.01, precision=4)
Static Method

source code 

Export admin areas to /static/cache for use by interactive web-mapping services
- designed for use by the Vulnerability Mapping

@param countries: list of ISO2 country codes
@param levels: list of which Lx levels to export
@param format: Only GeoJSON supported for now (may add KML &/or OSM later)
@param simplify: tolerance for the simplification algorithm. False to disable simplification
@param precision: number of decimal points to include in the coordinates

import_admin_areas(self, source="gadmv1", countries=[], levels=["L0","L1","L2"])

source code 

Import Admin Boundaries into the Locations table

@param source - Source to get the data from.
                Currently only GADM is supported: http://gadm.org
@param countries - List of ISO2 countrycodes to download data for
                   defaults to all countries
@param levels - Which levels of the hierarchy to import.
                defaults to all 3 supported levels

import_gadm1_L0(ogr, countries=[])
Static Method

source code 

Import L0 Admin Boundaries into the Locations table from GADMv1
- designed to be called from import_admin_areas()
- assumes that basic prepop has been done, so that no new records need to be created

@param ogr - The OGR Python module
@param countries - List of ISO2 countrycodes to download data for
                   defaults to all countries

import_gadm1(self, ogr, level="L1", countries=[])

source code 

Import L1 Admin Boundaries into the Locations table from GADMv1
- designed to be called from import_admin_areas()
- assumes a fresh database with just Countries imported

@param ogr - The OGR Python module
@param level - "L1" or "L2"
@param countries - List of ISO2 countrycodes to download data for
                   defaults to all countries

import_gadm2(ogr, level="L0", countries=[])
Static Method

source code 

Import Admin Boundaries into the Locations table from GADMv2
- designed to be called from import_admin_areas()
- assumes that basic prepop has been done, so that no new L0 records need to be created

@param ogr - The OGR Python module
@param level - The OGR Python module
@param countries - List of ISO2 countrycodes to download data for
                   defaults to all countries

@ToDo: Complete this
    - not currently possible to get all data from the 1 file easily
    - no ISO2
    - needs updating for gis_location_tag model
    - only the lowest available levels accessible
    - use GADMv1 for L0, L1, L2 & GADMv2 for specific lower?

import_geonames(self, country, level=None)

source code 

Import Locations from the Geonames database

Parameters:
  • country - the 2-letter country code
  • level - the ADM level to import

    Designed to be run from the CLI Levels should be imported sequentially. It is assumed that L0 exists in the DB already L1-L3 may have been imported from Shapefiles with Polygon info Geonames can then be used to populate the lower levels of hierarchy

latlon_to_wkt(lat, lon)
Static Method

source code 

Convert a LatLon to a WKT string

>>> s3gis.latlon_to_wkt(6, 80)
'POINT(80 6)'

parse_location(wkt, lon=None, lat=None)
Static Method

source code 

Parses a location from wkt, returning wkt, lat, lon, bounding box and type. For points, wkt may be None if lat and lon are provided; wkt will be generated. For lines and polygons, the lat, lon returned represent the shape's centroid. Centroid and bounding box will be None if Shapely is not available.

update_location_tree(feature=None, all_locations=False, propagating=False)
Static Method

source code 

Update GIS Locations' Materialized path, Lx locations, Lat/Lon & the_geom

@param feature: a feature dict to update the tree for
- if not provided then update the whole tree
@param all_locations: passed to recursive calls to indicate that this
is an update of the whole tree. Used to avoid repeated attempts to
update hierarchy locations with missing data (e.g. lacking some
ancestor level).
@param propagating: passed to recursive calls to indicate that this
is a propagation update. Used to avoid repeated attempts to
update hierarchy locations with missing data (e.g. lacking some
ancestor level).

returns the path of the feature

Called onaccept for locations (async, where-possible)

wkt_centroid(form)
Static Method

source code 

OnValidation callback:
If a WKT is defined: validate the format,
    calculate the LonLat of the Centroid, and set bounds
Else if a LonLat is defined: calculate the WKT for the Point.

query_features_by_bbox(lon_min, lat_min, lon_max, lat_max)
Static Method

source code 

Returns a query of all Locations inside the given bounding box

get_features_by_bbox(lon_min, lat_min, lon_max, lat_max)
Static Method

source code 

Returns Rows of Locations whose shape intersects the given bbox.

get_features_by_shape(shape)
Static Method

source code 

Returns Rows of locations which intersect the given shape.

Relies on Shapely for wkt parsing and intersection.

To Do: provide an option to use PostGIS/Spatialite

get_features_by_latlon(lat, lon)
Static Method

source code 

Returns a generator of locations whose shape intersects the given LatLon.

Relies on Shapely.

To Do: provide an option to use PostGIS/Spatialite

get_features_by_feature(feature)
Static Method

source code 

Returns all Locations whose geometry intersects the given feature.

Relies on Shapely.

To Do: provide an option to use PostGIS/Spatialite

set_all_bounds()
Static Method

source code 

Sets bounds for all locations without them.

If shapely is present, and a location has wkt, bounds of the geometry are used. Otherwise, the (lat, lon) are used as bounds.

simplify(wkt, tolerance=None, preserve_topology=True, output="wkt", precision=None)
Static Method

source code 

Simplify a complex Polygon using the Douglas-Peucker algorithm
- NB This uses Python, better performance will be gained by doing
     this direct from the database if you are using PostGIS:
ST_Simplify() is available as
db(query).select(table.the_geom.st_simplify(tolerance).st_astext().with_alias('wkt')).first().wkt
db(query).select(table.the_geom.st_simplify(tolerance).st_asgeojson().with_alias('geojson')).first().geojson

@param wkt: the WKT string to be simplified (usually coming from a gis_location record)
@param tolerance: how aggressive a simplification to perform
@param preserve_topology: whether the simplified geometry should be maintained
@param output: whether to output as WKT or GeoJSON format
@param precision: the number of decimal places to include in the output

show_map(self, id="default_map", height=None, width=None, bbox={}, lat=None, lon=None, zoom=None, projection=None, add_feature=False, add_feature_active=False, add_line=False, add_line_active=False, add_polygon=False, add_polygon_active=False, add_circle=False, add_circle_active=False, features=None, feature_queries=None, feature_resources=None, wms_browser={}, catalogue_layers=False, legend=False, toolbar=False, area=False, color_picker=False, clear_layers=None, nav=None, print_control=None, print_mode=False, save=False, search=False, mouse_position=None, overview=None, permalink=None, scaleline=None, zoomcontrol=None, zoomWheelEnabled=True, mgrs={}, window=False, window_hide=False, closable=True, maximizable=True, collapsed=False, callback="DEFAULT", plugins=None)

source code 

Returns the HTML to display a map

Normally called in the controller as: map = gis.show_map()
In the view, put: {{=XML(map)}}

@param id: ID to uniquely identify this map if there are several on a page
@param height: Height of viewport (if not provided then the default deployment setting is used)
@param width: Width of viewport (if not provided then the default deployment setting is used)
@param bbox: default Bounding Box of viewport (if not provided then the Lat/Lon/Zoom are used) (Dict):
    {"lon_min" : float,
     "lat_min" : float,
     "lon_max" : float,
     "lat_max" : float,
     }
@param lat: default Latitude of viewport (if not provided then the default setting from the Map Service Catalogue is used)
@param lon: default Longitude of viewport (if not provided then the default setting from the Map Service Catalogue is used)
@param zoom: default Zoom level of viewport (if not provided then the default setting from the Map Service Catalogue is used)
@param projection: EPSG code for the Projection to use (if not provided then the default setting from the Map Service Catalogue is used)
@param add_feature: Whether to include a DrawFeature control to allow adding a marker to the map
@param add_feature_active: Whether the DrawFeature control should be active by default
@param add_polygon: Whether to include a DrawFeature control to allow drawing a polygon over the map
@param add_polygon_active: Whether the DrawFeature control should be active by default
@param add_circle: Whether to include a DrawFeature control to allow drawing a circle over the map
@param add_circle_active: Whether the DrawFeature control should be active by default
@param features: Simple Features to overlay on Map (no control over appearance & not interactive)
    [wkt]
@param feature_queries: Feature Queries to overlay onto the map & their options (List of Dicts):
    [{"name"   : T("MyLabel"), # A string: the label for the layer
      "query"  : query,        # A gluon.sql.Rows of gis_locations, which can be from a simple query or a Join.
                               # Extra fields can be added for 'popup_url', 'popup_label' & either
                               # 'marker' (url/height/width) or 'shape' (with optional 'colour' & 'size')
      "active" : True,         # Is the feed displayed upon load or needs ticking to load afterwards?
      "marker" : None,         # Optional: A per-Layer marker query or marker_id for the icon used to display the feature
      "opacity" : 1,           # Optional
      "cluster_attribute",     # Optional
      "cluster_distance",      # Optional
      "cluster_threshold"      # Optional
      }]
@param feature_resources: REST URLs for (filtered) resources to overlay onto the map & their options (List of Dicts):
    [{"name"      : T("MyLabel"), # A string: the label for the layer
      "id"        : "search",     # A string: the id for the layer (for manipulation by JavaScript)
      "active"    : True,         # Is the feed displayed upon load or needs ticking to load afterwards?
      EITHER:
      "layer_id"  : 1,            # An integer: the layer_id to load (optional alternative to specifying URL/tablename/marker)
      "filter"    : "filter",     # A string: an optional URL filter which *replaces* any in the layer
      OR:
      "tablename" : "module_resource", # A string: the tablename (used to determine whether to locate via location_id or site_id)
      "url"       : "/eden/module/resource.geojson?filter", # A URL to load the resource

      "marker"    : None,         # Optional: A per-Layer marker dict for the icon used to display the feature (overrides layer_id if-set)
      "opacity"   : 1,            # Optional (overrides layer_id if-set)
      "cluster_attribute",        # Optional (overrides layer_id if-set)
      "cluster_distance",         # Optional (overrides layer_id if-set)
      "cluster_threshold",        # Optional (overrides layer_id if-set)
      "dir",                      # Optional (overrides layer_id if-set)
      "style",                    # Optional (overrides layer_id if-set)
      }]
@param wms_browser: WMS Server's GetCapabilities & options (dict)
    {"name": T("MyLabel"),     # Name for the Folder in LayerTree
     "url": string             # URL of GetCapabilities
     }
@param catalogue_layers: Show all the enabled Layers from the GIS Catalogue
                         Defaults to False: Just show the default Base layer
@param legend: True: Show the GeoExt Legend panel, False: No Panel, "float": New floating Legend Panel
@param toolbar: Show the Icon Toolbar of Controls
@param area: Show the Area tool on the Toolbar
@param color_picker: Show the Color Picker tool on the Toolbar (used for S3LocationSelector...pick up in postprocess)
                     If a style is provided then this is used as the default style
@param nav: Show the Navigation controls on the Toolbar
@param save: Show the Save tool on the Toolbar
@param search: Show the Geonames search box (requires a username to be configured)
@param mouse_position: Show the current coordinates in the bottom-right of the map. 3 Options: 'normal', 'mgrs', False (defaults to checking deployment_settings, which defaults to 'normal')
@param overview: Show the Overview Map (defaults to checking deployment_settings, which defaults to True)
@param permalink: Show the Permalink control (defaults to checking deployment_settings, which defaults to True)
@param scaleline: Show the ScaleLine control (defaults to checking deployment_settings, which defaults to True)
@param zoomcontrol: Show the Zoom control (defaults to checking deployment_settings, which defaults to True)
@param mgrs: Use the MGRS Control to select PDFs
    {"name": string,           # Name for the Control
     "url": string             # URL of PDF server
     }
    @ToDo: Also add MGRS Search support: http://gxp.opengeo.org/master/examples/mgrs.html
@param window: Have viewport pop out of page into a resizable window
@param window_hide: Have the window hidden by default, ready to appear (e.g. on clicking a button)
@param closable: In Window mode, whether the window is closable or not
@param collapsed: Start the Tools panel (West region) collapsed
@param callback: Code to run once the Map JavaScript has loaded
@param plugins: an iterable of objects which support the following methods:
                    .extend_gis_map(map)
                Client-side portion suppoprts the following methods:
                    .addToMapWindow(items)
                    .setup(map)


Class Variable Details

disable_update_location_tree

Value:
False