diff RestDbGisApi.py @ 273:d1b43624cc63

some hacks to make the european4D connection work
author dwinter
date Thu, 23 Feb 2012 11:44:38 +0100
parents 52b1247140b7
children 55bc9972fb1b
line wrap: on
line diff
--- a/RestDbGisApi.py	Fri Jan 27 20:02:41 2012 +0100
+++ b/RestDbGisApi.py	Thu Feb 23 11:44:38 2012 +0100
@@ -148,8 +148,9 @@
     def getLiveKmlUrl(self,schema,table,useTimestamp=True,REQUEST=None):
         return self.getLiveUrl(schema,table,useTimestamp,REQUEST)
 
-    def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red_big"):
+    def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red_big",from_year_name='from_year',until_year_name=''):
         """returns data structure for KML template"""
+        logging.debug("getKMLDATA")
         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"
@@ -322,18 +323,24 @@
             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
             try:
-                res = self.executeSQL(sql, (table,'from_year'))
+                res = self.executeSQL(sql, (table,from_year_name))
                 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'))
+                res = self.executeSQL(sql, (table,until_year_name))
                 if len(res['rows']) > 0:
                     until_year = res['rows'][0][0]
             except:
                     until_year = "until_year_dummy"
+                    
+            #DW added for testing E4D with names        
+            from_year=from_year_name
+            until_year=until_year_name
             
+            logging.debug("from_year:"+from_year)
+            logging.debug("until_year:"+until_year)
             for i in range (len(dataset)):
                 value = dataset[i]
                 
@@ -349,6 +356,7 @@
                     #    continue
                     
                     val = "%s: %s"%(name, value)
+                    logging.debug(name)
                     value=unicode(value)
                     if name == from_year:
                        beg_yr= value
@@ -616,6 +624,7 @@
         return kmlFileName
     
     def trydatahas_key(self,data,index,key_string):
+        logging.debug("trying:"+key_string)
         try:
             return data[index].has_key(key_string) 
         except: