Changes between Version 7 and Version 8 of DeveloperGuidelines/GIS


Ignore:
Timestamp:
01/04/09 22:31:37 (14 years ago)
Author:
Fran Boon
Comment:

Update for current structure

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/GIS

    v7 v8  
    1414                                SQLField('modified_on','datetime',default=now),
    1515                                SQLField('layer',length=64),
    16                                 SQLField('field'))
     16                                SQLField('newfield'))
    1717db.gis_layer_newlayertype.layer.requires=IS_IN_DB(db,'gis_layer.uuid','gis_layer.name')
    1818}}}
    1919
    2020=== Controller ===
     21New Layer Types & their Fields need adding to several places in the Controller:[[BR]]
    2122{{{controllers/gis.py}}}
    2223{{{
    23 def update_layer():
    24     # If form needs populating:
     24def layer():
     25    # Display method
    2526    elif type=="newlayertype":
    26         field = [""]
    27         subtype=0
    28         options_subtype = [""]
    29         key=0
    30     form=FORM(
    31         INPUT(_name="field"), # Could also be a SELECT
    32     )
    33     if form.accepts(request.vars,session,keepvalues=True):
    34         elif type_new=="newlayertype":
    35             db(db['gis_layer_%s' % type_new].layer==t2.id).select()[0].update_record(
    36                 field=form.vars.field
    37             )
     27        newfield=db(db['gis_layer_%s' % type].layer==t2.id).select(db['gis_layer_%s' % type].ALL)[0].newfield
    3828
    39 def map_service_catalogue():
    40     form=FORM(
    41         INPUT(_name="field"), # Could also be a SELECT
    42     )
    43     if form.accepts(request.vars,session,keepvalues=True):
    44         elif type_new=="newlayertype":
    45             db['gis_layer_%s' % type_new].insert(
    46                 layer=id,
    47                 field=form.vars.field
    48             )
     29def shn_gis_create_layer():
     30    customform=FORM(
     31            INPUT(_name="newfield"),
     32    elif type_new=="newlayertype":
     33        db['gis_layer_%s' % type_new].insert(
     34            layer=id,
     35            newfield=customform.vars.newfield
     36        )
     37
     38def shn_gis_update_layer():
     39    elif type=="newlayertype":
     40        newfield=db(db['gis_layer_%s' % type].layer==t2.id).select(db['gis_layer_%s' % type].ALL)[0].newfield
     41    customform=FORM(
     42            INPUT(_name="newfield"),
     43    elif type_new=="newlayertype":
     44        db['gis_layer_%s' % type_new].insert(
     45            layer=id,
     46            newfield=customform.vars.newfield
     47        )
    4948}}}
    5049If loading custom JS files when the new Layer is active:
    5150{{{
    5251def map_viewing_client():
     52    # Check for enabled Virtual Earth layers
     53    virtualearth=0
     54    for row in layers:
     55        if row.type=="virtualearth":
     56            virtualearth=1
     57    return dict(virtualearth=virtualearth)
    5358}}}
    5459=== View ===
    55 {{{views/gis/map_service_catalogue.html}}} & {{{views/gis/update_layer.html}}}
     60Custom fields need form views creating:[[BR]]
     61{{{views/gis/form_field.html}}}
    5662{{{
    5763<tr><td><label>{{=T("field_label")}}</label></td>
    58 <td><input name="field" type="text" value="" />
    59 {{if form.errors.field:}}<div class="error">{{=form.errors.field}}</div>{{pass}}</td></tr>
     64<td><input name="field" type="text" value="{{try:}}{{=resource.field}}{{except:}}{{pass}}" />
     65{{if customform.errors.field:}}<div class="error">{{=customform.errors.field}}</div>{{pass}}</td></tr>
     66}}}
     67Then adding to the layer CRUD views, such as {{{views/gis/update_layer.html}}}:
     68{{{
     69{{include 'gis/form_field.html'}}
    6070}}}
    6171{{{static/scripts/gis_layers.js}}}
     
    7181{{{
    7282{{elif layer.type=="newlayertype":}}
    73 var newlayertype = new OpenLayers.Layer.newlayertype( "{{=layer.name}}" );
    74 map.addLayer(newlayertype);
     83    var newlayertype = new OpenLayers.Layer.newlayertype( "{{=layer.name}}" );
     84    map.addLayer(newlayertype);
    7585{{pass}}
    7686}}}
    77 If loading custom JS files when the new Layer is active:
     87If loading custom JS files when the new Layer is active:[[BR]]
    7888{{{views/gis/ol_js_loaders.html}}}
    79 
     89{{{
     90{{if virtualearth:}}
     91<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>
     92{{pass}}
     93}}}
    8094----
    8195DeveloperGuidelines