comparison 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
comparison
equal deleted inserted replaced
270:3a5d51c60e40 273:d1b43624cc63
146 146
147 147
148 def getLiveKmlUrl(self,schema,table,useTimestamp=True,REQUEST=None): 148 def getLiveKmlUrl(self,schema,table,useTimestamp=True,REQUEST=None):
149 return self.getLiveUrl(schema,table,useTimestamp,REQUEST) 149 return self.getLiveUrl(schema,table,useTimestamp,REQUEST)
150 150
151 def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red_big"): 151 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=''):
152 """returns data structure for KML template""" 152 """returns data structure for KML template"""
153 logging.debug("getKMLDATA")
153 logging.debug("getKMLdata gid=%s lat=%s lon=%s sortBy=%s geom=%s color=%s"%(gisIdField,latField,lonField,sortBy,geomField,colorField)) 154 logging.debug("getKMLdata gid=%s lat=%s lon=%s sortBy=%s geom=%s color=%s"%(gisIdField,latField,lonField,sortBy,geomField,colorField))
154 if geomField is None: 155 if geomField is None:
155 geomField="point" 156 geomField="point"
156 if colorField is None: 157 if colorField is None:
157 colorField="red" 158 colorField="red"
320 from_year = '' 321 from_year = ''
321 until_year = '' 322 until_year = ''
322 sql = "SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s" 323 sql = "SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s"
323 # from_year and until_year in metadata first 324 # from_year and until_year in metadata first
324 try: 325 try:
325 res = self.executeSQL(sql, (table,'from_year')) 326 res = self.executeSQL(sql, (table,from_year_name))
326 if len(res['rows']) > 0: 327 if len(res['rows']) > 0:
327 from_year = res['rows'][0][0] 328 from_year = res['rows'][0][0]
328 except: 329 except:
329 from_year = "from_year_dummy" 330 from_year = "from_year_dummy"
330 try: 331 try:
331 res = self.executeSQL(sql, (table,'until_year')) 332 res = self.executeSQL(sql, (table,until_year_name))
332 if len(res['rows']) > 0: 333 if len(res['rows']) > 0:
333 until_year = res['rows'][0][0] 334 until_year = res['rows'][0][0]
334 except: 335 except:
335 until_year = "until_year_dummy" 336 until_year = "until_year_dummy"
336 337
338 #DW added for testing E4D with names
339 from_year=from_year_name
340 until_year=until_year_name
341
342 logging.debug("from_year:"+from_year)
343 logging.debug("until_year:"+until_year)
337 for i in range (len(dataset)): 344 for i in range (len(dataset)):
338 value = dataset[i] 345 value = dataset[i]
339 346
340 name = data['fields'][i][0] 347 name = data['fields'][i][0]
341 #logging.debug("value=%s"%value) 348 #logging.debug("value=%s"%value)
347 #elif name.find('place')>-1: 354 #elif name.find('place')>-1:
348 # desc += "<name>%s</name>\n"%value 355 # desc += "<name>%s</name>\n"%value
349 # continue 356 # continue
350 357
351 val = "%s: %s"%(name, value) 358 val = "%s: %s"%(name, value)
359 logging.debug(name)
352 value=unicode(value) 360 value=unicode(value)
353 if name == from_year: 361 if name == from_year:
354 beg_yr= value 362 beg_yr= value
355 if name == until_year: 363 if name == until_year:
356 end_yr=value 364 end_yr=value
614 isLoadReady=self.RESTwrite2File(self.daten,kmlFileName,kml4Marker) 622 isLoadReady=self.RESTwrite2File(self.daten,kmlFileName,kml4Marker)
615 623
616 return kmlFileName 624 return kmlFileName
617 625
618 def trydatahas_key(self,data,index,key_string): 626 def trydatahas_key(self,data,index,key_string):
627 logging.debug("trying:"+key_string)
619 try: 628 try:
620 return data[index].has_key(key_string) 629 return data[index].has_key(key_string)
621 except: 630 except:
622 return 'false' 631 return 'false'
623 632