Mercurial > hg > ChinaGisRestApi
changeset 264:52b1247140b7
Multilayer for Europeana4D
author | fknauft |
---|---|
date | Wed, 25 Jan 2012 19:33:19 +0100 |
parents | 3a10287447b1 |
children | c46c369764e9 |
files | RestDbGisApi.py RestDbInterface.py gis_gui/blocks/home.html.pt gis_gui/blocks/home.js gis_gui/blocks/layer.js gis_gui/blocks/map.html.pt gis_gui/blocks/map.js gis_gui/lib/blocks.js zpt/KML_schema_table.zpt |
diffstat | 9 files changed, 111 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbGisApi.py Thu Dec 01 13:48:56 2011 +0100 +++ b/RestDbGisApi.py Wed Jan 25 19:33:19 2012 +0100 @@ -315,18 +315,25 @@ desc = '' timestring = '' - beg_yr = '' - end_yr = '' + beg_yr = '-9999' + end_yr = '9999' 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] + try: + res = self.executeSQL(sql, (table,'from_year')) + if len(res['rows']) > 0: + from_year = res['rows'][0][0] + except: + from_year = "from_year_dummy" + try: + res = self.executeSQL(sql, (table,'until_year')) + if len(res['rows']) > 0: + until_year = res['rows'][0][0] + except: + until_year = "until_year_dummy" + for i in range (len(dataset)): value = dataset[i] @@ -371,11 +378,10 @@ #kmlPlace['description'] = "<![CDATA[%s]]>"%desc - if beg_yr!='': - if end_yr!='': + if end_yr!='9999': kmlPlace['TimeSpan0'] = '%s'%beg_yr kmlPlace['TimeSpan1'] = '%s'%end_yr - else: + else: kmlPlace['TimeStamp'] = '%s'%beg_yr if geomField=='point':
--- a/RestDbInterface.py Thu Dec 01 13:48:56 2011 +0100 +++ b/RestDbInterface.py Wed Jan 25 19:33:19 2012 +0100 @@ -396,7 +396,8 @@ attrString=attrString+"ST_AsText("+name[0]+")," not_added=False if not_added: - attrString=attrString+name[0]+"," + if name[0].find('pg.dropped')==-1: + attrString=attrString+name[0]+"," attrString=str(attrString).rsplit(",",1)[0] #to remove last "," if sortBy: data = self.executeSQL('select %s from "%s"."%s" order by %s'%(attrString,schema,table,sortBy))
--- a/gis_gui/blocks/home.html.pt Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/blocks/home.html.pt Wed Jan 25 19:33:19 2012 +0100 @@ -7,41 +7,41 @@ <ul class="account_menu"> <li> Create <ul> - <li> Workspace </li> +<!-- <li> Workspace </li> --> <li> Table </li> <!-- <li> View </li> --> </ul></li> <li> Open <ul> - <li> Workspace </li> +<!-- <li> Workspace </li> --> <li> Table </li> <!-- <li> View </li> --> </ul></li> - <li> Search +<!-- <li> Search <ul> <li> locally </li> <li> globally </li> - </ul></li> + </ul></li> --> - <li> Account + <!-- <li> Account <ul> <li> Settings </li> <li> Workspaces </li> <li> <a href="#" rel="facebox"> Messages</a> </li> <li onClick="jQuery.facebox('asdaasd')"> Logout </li> - </ul></li> + </ul></li> --> </ul> </tal:block> <tal:block metal:fill-slot="content"> <div class="subscreen main"> <!-- subscreen main --> <div class="task_select"> - <div class="task search_button"> +<!-- <div class="task search_button"> <img src="icons/search.png"/> Search - </div> + </div> --> <div class="task create_button"> <img src="icons/table.png"/> Create @@ -51,14 +51,14 @@ <img src="icons/workspace.png"/> Open </div> - <div class="task"> +<!-- <div class="task"> <img src="icons/workspace.png"/> Account - </div> - <div class="task notes_button"> + </div> --> +<!-- <div class="task notes_button"> <img src="icons/messages.png"/> Notes - </div> + </div> --> </div> </div> <!-- subscreen main --> @@ -74,10 +74,10 @@ <img src="icons/table.png"/> View </div> --> - <div class="task create_workspace_button"> +<!-- <div class="task create_workspace_button"> <img src="icons/workspace.png"/> Workspace - </div> + </div> --> <div class="task create_map_button"> <img src="icons/map.png"/> Map @@ -94,9 +94,9 @@ <div class="task create_table_file_button"> <img src="icons/table.png" />From data file </div> - <div class="task create_table_view_button"> + <!-- <div class="task create_table_view_button"> <img src="icons/table.png" />From other table - </div> + </div> --> </div> </div> <!-- subscreen create --> @@ -127,14 +127,32 @@ <p>Table <i class="tablename"/> exists. Do you want to replace it?</p> </div> + <!-- subscreen create map --> + <div class="subscreen create_map" style="display: none;"> + <div class="task_select"> + <div class="task create_map_empty_button"> + <img src="icons/map.png" />Empty Map + </div> + </div> + </div> + + <!-- subscreen create --> + <div class="subscreen create_map_task create_map_empty" style="display:none"> + Name + <br/> + <input name="create_map_name" class="create_map_name" type="text" value=""/> + <br/> + <input type="button" value="Create" class="create_map_file_create_button"/> + </div> + <div class="subscreen open" style="display:none;" > <!-- subscreen open --> <div class="task_select"> - <div class="task open_workspace_button"> + <!-- <div class="task open_workspace_button"> <img src="icons/workspace.png"/> Workspace - </div> + </div> --> <div class="task open_table_button"> <img src="icons/table.png"/> Table
--- a/gis_gui/blocks/home.js Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/blocks/home.js Wed Jan 25 19:33:19 2012 +0100 @@ -134,10 +134,8 @@ $(uploadForm).iframePostForm({ post: blocks.checkTableSubmitFn(segment), complete: blocks.checkTableCompleteFn(segment,uploadForm) - }); - + }); }); - homeblock.find(".create_table_empty_create_button").live("click", function() { // switchSubscreens(homeblock, 'open', 'main'); clearAllTasks(); @@ -146,7 +144,32 @@ var tablefile = $(this).parent().find(".create_table_file").val(); var newblock = blocks.addTableBlock("blocks/table.html?table="+escape(tablename),"table", tablename); }); - + + // create map menu + homeblock.find(".create_map_button").live("click", function() { + // homeblock.find(".task[id*=open_]").removeClass("selected"); + homeblock.find(".create_map_button").addClass("selected"); + homeblock.find(".subscreen.create_map").fadeIn(); + }); + homeblock.find(".create_map_empty_button").live("click", function() { + // homeblock.find(".task[id*=open_]").removeClass("selected"); + clearTasks(".create_map",".create_map_task"); + homeblock.find(".create_map_empty_button").addClass("selected"); +// homeblock.find(".subscreen.create_map_empty").fadeIn(); + var params = {"type": "layer", "color_field":"red","geometry_field":"point"}; + var mapblock = blocks.addMapBlock("blocks/map.html?","map",null,params); + }); +/* homeblock.find(".create_map_empty_create_button").live("click", function() { + // switchSubscreens(homeblock, 'open', 'main'); + clearAllTasks(); + foldBlock($(this).parents().filter(".block")); + var mapname = $(this).parent().find(".create_map_name").val(); + var mapfile = $(this).pa + rent().find(".create_map_file").val(); + var newblock = blocks.addMapBlock("blocks/map.html?"); + }); +*/ + // SEARCH homeblock.find(".search_button").live('click', function(){ clearAllTasks();
--- a/gis_gui/blocks/layer.js Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/blocks/layer.js Wed Jan 25 19:33:19 2012 +0100 @@ -94,6 +94,7 @@ // create map button $(be).find(".map_create_button").click(function() { console.debug("layer create map. this=",this," block=",block); + params = block.readLayerParams(be,params); var mapblock = blocks.addMapBlock("blocks/map.html?layer="+escape(params.name),"map",null,params); }); // reload button (upper right corner of Block)
--- a/gis_gui/blocks/map.html.pt Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/blocks/map.html.pt Wed Jan 25 19:33:19 2012 +0100 @@ -56,6 +56,8 @@ <p><input type="button" class="map_update_button" value="Update map" /><br /> <!-- <input type="button" class="map_newwindow_button" value="Open map in new Window" /></p> --> + <input type="button" class="map_e4D_button" value="Open Map in Europeana4D" /></p> + </div> </div>
--- a/gis_gui/blocks/map.js Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/blocks/map.js Wed Jan 25 19:33:19 2012 +0100 @@ -41,6 +41,16 @@ params = block.readMapParams(); map=block.updateMap(be,params); }); + // e4D button + $(be).find(".map_e4D_button").click(function () { + console.debug("map to e4D"); + params = block.readMapParams(); + layers = []; + for (var i = 0; i < params.map_layers.length; i++) { + layers[i]= params.map_layers[i].layer.table; + } + map=blocks.e4DOpen("Europeana4D",layers); + }); // new window button /* $(be).find(".map_newwindow_button").click(function () {
--- a/gis_gui/lib/blocks.js Thu Dec 01 13:48:56 2011 +0100 +++ b/gis_gui/lib/blocks.js Wed Jan 25 19:33:19 2012 +0100 @@ -109,25 +109,22 @@ jQuery.getJSON(url,callback); }; -guiBlocks.prototype.e4DOpen = function(titel,table){ - var e4D_URL="http://mappit.mpiwg-berlin.mpg.de:8080/e4D"; +guiBlocks.prototype.e4DOpen = function(titel,tables){ + 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();} + var layer_URL = ""; + + for (var i=0;i<tables.length;i++){ + if (i!=0) {e4D_URL=e4D_URL+"&";} + layer_URL= "http://mappit.mpiwg-berlin.mpg.de/db/RESTdb/db/public/" + escape(tables[i]) + "?" + paramstr; + e4D_URL=e4D_URL+"kml"+[i+1]+"='"+layer_URL+"'&source"+[i+1]+"="+[i+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; + /* });*/ }; @@ -141,7 +138,7 @@ url: url, data: ds, success: function(msg){ - console.debug("PUT success msg=",msg); + console.debug("PUT success msg=",msg); this.storeId = storeItem; } });
--- a/zpt/KML_schema_table.zpt Thu Dec 01 13:48:56 2011 +0100 +++ b/zpt/KML_schema_table.zpt Wed Jan 25 19:33:19 2012 +0100 @@ -195,9 +195,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/lineColor" >#red_line</styleUrl>