Mercurial > hg > ChinaGisRestApi
diff RestDbGisApi.py @ 263:3a10287447b1
Integration von Europeana4D UserInterface
author | fknauft |
---|---|
date | Thu, 01 Dec 2011 13:48:56 +0100 |
parents | 6613b9204bda |
children | 52b1247140b7 |
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