Geographic support

From Sanet

Jump to: navigation, search


Geographic support


Sanet has support for geographic maps, but it's not enabled by default, because it is useful only if the networks spans multiple locations, and it requires access to Google Maps.

Geographic maps are rendered using Google's Maps API [1]. For this reason, if you want to use Sanet's geographic features you MUST be sure your browser is supported and can access to Google's sites.

Sanet can assign geographic coordinates to the following resource types:

If a resource has no geographic informations, its position on the map is computed from its parent resource.

If a node is not positioned, it will be placed in the position of the container being displayed. If a Container is not positioned, it will be placed at the position of the site.


Enable geo support

Modify $SANET_HOME/ and add the geo application to the list of installed applications.

Add the following lines:

if not 'geo' in INSTALLED_APPS: 

Save the configuration file and update the database configuration:

python syncdb

Global Geo settings

These are the global parameters used by the geo app.

Parameter Description
GEO_DEFAULT_SITE_POSITION Default coordinates (latitude and longitude) of any resource when geographic informations are not found.
GEO_USE_PARENT_POSITION If True, every unpositioned resource is placed at the same coordinates of it's parent resource (container or site), and this position is saved in the DB. When False, the web interface tries to place unpositioned resource but geographic informations are not saved on DB.

The default value for GEO_DEFAULT_SITE_POSITION is:

GEO_DEFAULT_SITE_POSITION = {'lat': 44.4942132, 'lng': 11.3464736 }

Web pages settings

The information block used to show geographic maps is called googlemap. This block can be used inside containers and nodes.

In order to show the block inside the page of a resource you have to modify the RESOURCE_PAGE_BLOCKS parameter.

This is an example:

RESOURCE_PAGE_BLOCKS['container'].append( { 'name':'geoinfo' , 'descr': 'Geo' , 'blocks': [ 'googlemap' ]}, )
RESOURCE_PAGE_BLOCKS['node'     ].append( { 'name':'geoinfo' , 'descr': 'Geo' , 'blocks': [ 'googlemap' ]}, )

These lines add a new page section with label Geo inside containers' page and nodes' page.

CLI commands

The position of items is changed whenever the item is moved in the map. You can also change the position of one or more items via the CLI, using the following commands:

 node <node1>
   geoposition <lat> <lon>
 tree <name>
  container <name>
   geoposition <lat> <lon>

Assigns a coordinate to a node or a container

 geo copy node <node1> node <node2>                                        

Copy node1's coordinates to node2

 geo copy node <node> container tree <tree> <container>

Copy node's coordinates to every resource (node and containers) inside container

 geo copy container tree <tree name> <container> all

Copy container's coordinates to every subresource (subnode and subcontainers).

Personal tools