Mercurial > hg > ChinaGisRestApi
changeset 249:bba7dd7b6b4c
Layer gui reordered, point order can be defined
author | fknauft |
---|---|
date | Mon, 19 Sep 2011 14:16:03 +0200 |
parents | fcb7876178d1 |
children | d7ceeb8ccbd7 |
files | RestDbGisApi.py gis_gui/blocks/layer.html.pt gis_gui/blocks/layer.js gis_gui/blocks/map.js |
diffstat | 4 files changed, 44 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbGisApi.py Fri Sep 16 10:59:10 2011 +0200 +++ b/RestDbGisApi.py Mon Sep 19 14:16:03 2011 +0200 @@ -165,7 +165,7 @@ def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red"): """returns data structure for KML template""" - logging.debug("getKMLdata gid=%s lat=%s lon=%s geom=%s color=%s"%(gisIdField,latField,lonField,geomField,colorField)) + logging.debug("getKMLdata gid=%s lat=%s lon=%s sortBy=%s geom=%s color=%s"%(gisIdField,latField,lonField,sortBy,geomField,colorField)) if geomField is None: geomField="point" if colorField is None: @@ -188,6 +188,8 @@ # add sort clause if sortBy == 1: qstr += ' ORDER BY 1' + elif sortBy == 'Default': + qstr += ' ORDER BY 1' else: # TODO: proper quoting for names qstr += ' ORDER BY "%s"'%sortBy.replace('"','')
--- a/gis_gui/blocks/layer.html.pt Fri Sep 16 10:59:10 2011 +0200 +++ b/gis_gui/blocks/layer.html.pt Mon Sep 19 14:16:03 2011 +0200 @@ -3,7 +3,7 @@ <tal:block metal:fill-slot="icon"> L </tal:block> - <tal:block metal:fill-slot="title"> Map layer for table <i tal:content="table"/></tal:block> + <tal:block metal:fill-slot="title"> Map table <i tal:content="table"/> to new layer</tal:block> <tal:block metal:fill-slot="menu"> @@ -22,28 +22,28 @@ </div> <div class="mapping_info" id="map_info"> - <h3>Map layer</h3> <table> <tr> - <th> Layer Name </th> + <th> Layer name </th> <td><input type="text" class="layer_name" tal:attributes="value string:${table}_layer1"/></td> </tr> <tr> - <th> Source Table </th> + <th> Source table </th> <td> <span tal:content="table"/> <input type="button" value="Open table" class="layer_open_table_button"/></td> </tr> </table> - <h3> Mapping </h3> + <h3> Mapping options</h3> <table> <tr> <th> Position </th> <td> <select class="layer_position_select"><option>None</option></select> </td> </tr> - <tr> <th> Color </th> <td> <select class="layer_color_select"><option selected>red</option><option>red_big</option><option>green</option><option>green_big</option><option>black</option><option>black_big</option><option>violett</option><option>violett_big</option><option>blue</option><option>blue_big</option></select></td> </tr> <!-- <tr> <th> Geometry </th> <td> <select class="layer_geom_select"><option selected>point</option><option>poly</option><option>line</option></select></td> </tr> --> <tr> <th> Geometry </th> <td> <select class="layer_geom_select"><option selected>point</option><option>line</option></select></td> </tr> + <tr> <th> Sort by </th> <td> <select class="layer_sort_select"><option selected>ID</option></select></td> </tr> + <tr> <td colspan="2"> <input class="layer_line_checkbox" type="checkbox"/> connect points with a line </td></tr> <tr> <th> Label </th> <td> <select class="layer_label_select"><option>None</option></select> </td> </tr> + <tr> <th> Color </th> <td> <select class="layer_color_select"><option selected>red</option><option>red_big</option><option>green</option><option>green_big</option><option>black</option><option>black_big</option><option>violett</option><option>violett_big</option><option>blue</option><option>blue_big</option></select></td> </tr> <tr> <th> Size </th> <td> <select class="layer_size_select"><option>None</option></select></td> </tr> <tr> <th> Shape </th> <td> <select class="layer_shape_select"><option>None</option></select> </td> </tr> - <tr> <td colspan="2"> <input class="layer_line_checkbox" type="checkbox"/> connect markers with a line </td></tr> </table> <br/> <input type="button" value="Update layer" class="layer_update_button"/>
--- a/gis_gui/blocks/layer.js Fri Sep 16 10:59:10 2011 +0200 +++ b/gis_gui/blocks/layer.js Mon Sep 19 14:16:03 2011 +0200 @@ -20,38 +20,50 @@ } $(this).find("option").filter(function(){return $(this).text() == params.position_field;}).attr("selected","true"); }); - $(be).find(".layer_label_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", + + $(be).find(".layer_geom_select").attr("element","<select id='geom'><option selected>point</option><option>poly</option><option>line</option></select>"); + params.geometry_field = "point"; + + $(be).find(".layer_sort_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", function() { $(this).find("option:first").before('<option>Default</option>'); + if (!params.position_field) { + params.position_field = "Default"; + } + $(this).find("option").filter(function(){return $(this).text() == params.position_field;}).attr("selected","true"); + }); + + $(be).find(".layer_line_checkbox").attr("checked", params.connect_line); + + $(be).find(".layer_label_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", + function() { + $(this).find("option:first").before('<option>None</option>'); if (!params.label_field) { - params.label_field = "Default"; + params.label_field = "None"; } $(this).find("option").filter(function(){return $(this).text() == params.label_field;}).attr("selected","true"); }); + + $(be).find(".layer_color_select").attr("element","<select id='color'><option selected>red</option><option>blue</option><option>black</option><option>green</option><option>violett</option></select>"); + params.color_field = "red"; + $(be).find(".layer_size_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", function() { - $(this).find("option:first").before('<option>Default</option>'); + $(this).find("option:first").before('<option>None</option>'); if (!params.size_field) { - params.size_field = "Default"; + params.size_field = "None"; } $(this).find("option").filter(function(){return $(this).text() == params.size_field;}).attr("selected","true"); }); - $(be).find(".layer_geom_select").attr("element","<select id='geom'><option selected>point</option><option>poly</option><option>line</option></select>"); - params.geometry_field = "point"; - - $(be).find(".layer_color_select").attr("element","<select id='color'><option selected>red</option><option>blue</option><option>black</option><option>green</option><option>violett</option></select>"); - params.color_field = "red"; - $(be).find(".layer_shape_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", function() { - $(this).find("option:first").before('<option>Default</option>'); + $(this).find("option:first").before('<option>None</option>'); if (!params.shape_field) { - params.shape_field = "Default"; + params.shape_field = "None"; } $(this).find("option").filter(function(){return $(this).text() == params.shape_field;}).attr("selected","true"); }); - $(be).find(".layer_line_checkbox").attr("checked", params.connect_line); // show block $(be).fadeIn(); @@ -98,12 +110,13 @@ } params.name = $(elem).find(".layer_name").val(); params.position_field = $(elem).find(".layer_position_select").val(); + params.geometry_field = $(elem).find(".layer_geom_select").val(); + params.sort_field = $(elem).find(".layer_sort_select").val(); + params.connect_line = $(elem).find(".layer_line_checkbox").attr("checked"); params.label_field = $(elem).find(".layer_label_select").val(); params.size_field = $(elem).find(".layer_size_select").val(); params.color_field = $(elem).find(".layer_color_select").val(); - params.geometry_field = $(elem).find(".layer_geom_select").val(); params.shape_field = $(elem).find(".layer_shape_select").val(); - params.connect_line = $(elem).find(".layer_line_checkbox").attr("checked"); return params; }; @@ -120,6 +133,9 @@ if (params.geometry_field!="None"){ paramstr += "&geometry_field="+params.geometry_field; } + if (params.sort_field!="None"){ + paramstr += "&sort_field="+params.sort_field; + } if (params.connect_line) { paramstr += "&connect_line="+params.connect_line; }
--- a/gis_gui/blocks/map.js Fri Sep 16 10:59:10 2011 +0200 +++ b/gis_gui/blocks/map.js Mon Sep 19 14:16:03 2011 +0200 @@ -197,6 +197,9 @@ if (params.geometry_field != "Default") { paramstr += "&geometry_field="+params.geometry_field; } + if (params.sort_field != "Default") { + paramstr += "&sort_field="+params.sort_field; + } if (params.connect_line) { paramstr += "&connect_line="+params.connect_line; }