Mercurial > hg > ChinaGisRestApi
changeset 263:3a10287447b1
Integration von Europeana4D UserInterface
author | fknauft |
---|---|
date | Thu, 01 Dec 2011 13:48:56 +0100 |
parents | 6613b9204bda |
children | 52b1247140b7 |
files | RestDbGisApi.py RestDbInterface.py gis_gui/blocks/layer.html.pt gis_gui/blocks/table.html.pt gis_gui/blocks/tablestructure.js gis_gui/lib/blocks.js zpt/KML_schema_table.zpt |
diffstat | 7 files changed, 55 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbGisApi.py Tue Nov 01 18:04:26 2011 +0100 +++ b/RestDbGisApi.py Thu Dec 01 13:48:56 2011 +0100 @@ -16,7 +16,6 @@ from RestDbInterface import * - def kmlEncode(s): """returns string encoded for displaying in KML attribute""" res = s.replace("'","__Apostroph__") @@ -55,7 +54,9 @@ "gis_id": "text", "coord_lat": "numeric", "coord_lon": "numeric", - "the_geom": "the_geom" + "the_geom": "the_geom", + "from_year":"text", + "until_year":"text" } def getTableOwner(self,schema,table): @@ -242,6 +243,7 @@ lonField = 'y_coord' else: logging.error("getKMLdata unable to find position fields") + self.REQUEST.RESPONSE.write("Please define Position field") return None @@ -315,6 +317,16 @@ timestring = '' beg_yr = '' end_yr = '' + from_year = '' + until_year = '' + sql = "SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s" + # from_year and until_year in metadata first + res = self.executeSQL(sql, (table,'from_year')) + if len(res['rows']) > 0: + from_year = res['rows'][0][0] + res = self.executeSQL(sql, (table,'until_year')) + if len(res['rows']) > 0: + until_year = res['rows'][0][0] for i in range (len(dataset)): value = dataset[i] @@ -331,9 +343,9 @@ val = "%s: %s"%(name, value) value=unicode(value) - if name == 'beg_yr': + if name == from_year: beg_yr= value - if name == 'end_yr': + if name == until_year: end_yr=value # If there is a link within the description data, create a valid href if value.find('http://')>-1: @@ -361,9 +373,10 @@ if beg_yr!='': if end_yr!='': - kmlPlace['TimeSpan'] = '<begin>%s</begin><end>%s</end>'%(beg_yr,end_yr) + kmlPlace['TimeSpan0'] = '%s'%beg_yr + kmlPlace['TimeSpan1'] = '%s'%end_yr else: - kmlPlace['TimeStamp'] = '<when>%s</when>'%beg_yr + kmlPlace['TimeStamp'] = '%s'%beg_yr if geomField=='point': kmlPlace['description'] = "<![CDATA[%s]]>"%desc
--- a/RestDbInterface.py Tue Nov 01 18:04:26 2011 +0100 +++ b/RestDbInterface.py Thu Dec 01 13:48:56 2011 +0100 @@ -647,6 +647,11 @@ else: val = None + if val!=None: + a=val.rfind('.0') + b=len(val) + if a==b-2: + val=val.rpartition('.')[0] data.append(val) if not hasData:
--- a/gis_gui/blocks/layer.html.pt Tue Nov 01 18:04:26 2011 +0100 +++ b/gis_gui/blocks/layer.html.pt Thu Dec 01 13:48:56 2011 +0100 @@ -41,9 +41,10 @@ <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> <th> Point-/Line-Color </th> <td> <select class="layer_linecolor_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> Polygon-Fill-Color </th> <td> <select class="layer_fillcolor_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> Point-Size by </th> <td> <select class="layer_size_select"><option>None</option></select></td> </tr> + <tr> <th> Point-Shape by </th> <td> <select class="layer_shape_select"><option>None</option></select> </td> </tr> </table> <br/> <input type="button" value="Update layer" class="layer_update_button"/>
--- a/gis_gui/blocks/table.html.pt Tue Nov 01 18:04:26 2011 +0100 +++ b/gis_gui/blocks/table.html.pt Thu Dec 01 13:48:56 2011 +0100 @@ -27,6 +27,8 @@ </div> <br/> <input type="button" value="Create map layer" class="" tal:attributes="onClick string:blocks.addLayerBlock('blocks/layer.html?table=$table','layer','${table}')"/> + <br/> + <input type="button" value="Open Map in Europeana4D" class="" tal:attributes='onClick string:blocks.e4DOpen("Europeana4D","${table}")'/> </div> </tal:block>
--- a/gis_gui/blocks/tablestructure.js Tue Nov 01 18:04:26 2011 +0100 +++ b/gis_gui/blocks/tablestructure.js Thu Dec 01 13:48:56 2011 +0100 @@ -27,7 +27,7 @@ var row = []; for (var i = 0; i < fields.length; i++) { colheads.push({'sTitle': fields[i].name}); - row.push(getHtmlSelectFromList(['text','number','gis_id','coord_lat','coord_lon','the_geom','id'],fields[i].type,'class="type_'+fields[i].name+'"')); + row.push(getHtmlSelectFromList(['text','number','gis_id','coord_lat','coord_lon','the_geom','id','from_year','until_year'],fields[i].type,'class="type_'+fields[i].name+'"')); } // Add DataTables functionality $(tbl).dataTable({
--- a/gis_gui/lib/blocks.js Tue Nov 01 18:04:26 2011 +0100 +++ b/gis_gui/lib/blocks.js Thu Dec 01 13:48:56 2011 +0100 @@ -26,6 +26,7 @@ } + /* * guiBlocks base */ @@ -108,6 +109,27 @@ jQuery.getJSON(url,callback); }; +guiBlocks.prototype.e4DOpen = function(titel,table){ + var e4D_URL="http://mappit.mpiwg-berlin.mpg.de:8080/e4D"; + var paramstr = "format=KML"; +// var layer_URL = "http://chinagis-develop.mpiwg-berlin.mpg.de:9080/db/RESTdb/db/public/" + escape(table) + "?" + paramstr; + var layer_URL = "http://mappit.mpiwg-berlin.mpg.de/db/RESTdb/db/public/" + escape(table) + "?" + paramstr; + var kml_URL = ""; + /* jQuery.get(layerurl, function (data, textStatus, XMLHttpRequest) { + // function after load kml url finished + console.debug("kml url loaded! this=", this ); + console.debug(" data=", data ); + console.debug(" data type=", typeof(data)); + if (typeof(data) == "string") { + kml_URL = data; + }*/ + e4D_URL=e4D_URL+"?kml1="+layer_URL+"&source1=1"; + console.debug(" e4D_URL=", e4D_URL ); + var newwindow=window.open(e4D_URL,"Mappit@Europeana4D","height=800,width=900"); + if (window.focus) {newwindow.focus();} + return false; + /* });*/ +}; guiBlocks.Block.prototype.storeBlock = function(storeTag) { var storeType = this.params.type;
--- a/zpt/KML_schema_table.zpt Tue Nov 01 18:04:26 2011 +0100 +++ b/zpt/KML_schema_table.zpt Thu Dec 01 13:48:56 2011 +0100 @@ -179,9 +179,9 @@ <description tal:content="place/description"> ERD-0815: ERD-0815 </description> - <TimeStamp tal:content="place/TimeStamp" tal:condition="python:here.trydatahas_key(data,0,'TimeStamp')"> + <TimeStamp tal:condition="python:here.trydatahas_key(data,0,'TimeStamp')"><when tal:content="place/TimeStamp"></when> </TimeStamp> - <TimeSpan tal:content="place/TimeSpan" tal:condition="python:here.trydatahas_key(data,0,'TimeSpan')"> + <TimeSpan tal:condition="python:here.trydatahas_key(data,0,'TimeSpan0')"><begin tal:content="place/TimeSpan0" ></begin><end tal:content="place/TimeSpan1"></end> </TimeSpan> <styleUrl tal:content="place/icon" >#marker_icon_red</styleUrl>