wiki:DeveloperGuidelines/GIS

Version 5 (modified by Fran Boon, 14 years ago) ( diff )

--

DeveloperGuidelines

GIS Module

How to add a new Layer type

Model

models/_gis.py

gis_layer_types=['newlayertype','...']

# Provide layer-specific options in it's own table:
db.define_table('gis_layer_newlayertype',
				SQLField('modified_on','datetime',default=now),
				SQLField('layer',length=64),
				SQLField('field'))
db.gis_layer_newlayertype.layer.requires=IS_IN_DB(db,'gis_layer.uuid','gis_layer.name')

Controller

controllers/gis.py

def map_service_catalogue():
    form=FORM(
        INPUT(_name="field"), # Could also be a SELECT
    )
    if form.accepts(request.vars,session,keepvalues=True):
        elif type_new=="newlayertype":
            db['gis_layer_%s' % type_new].insert(
                layer=id,
                field=form.vars.field
            )

If loading custom JS files when the new Layer is active:

def map_viewing_client():

View

views/map_service_catalogue.html

<tr><td><label>{{=T("field_label")}}</label></td>
<td><input name="field" type="text" value="" />
{{if form.errors.field:}}<div class="error">{{=form.errors.field}}</div>{{pass}}</td></tr>

views/map_viewing_client.html


DeveloperGuidelines

Note: See TracWiki for help on using the wiki.