# HG changeset patch # User fknauft # Date 1312227327 -7200 # Node ID bdab16f83512f5c51a8741755d09102653dd1e2e # Parent f930ce2583a090061d514c9962bb756da9a6d5b5 show line and polygon-layer diff -r f930ce2583a0 -r bdab16f83512 RestDbGisApi.py --- a/RestDbGisApi.py Thu May 12 16:23:04 2011 +0200 +++ b/RestDbGisApi.py Mon Aug 01 21:35:27 2011 +0200 @@ -196,6 +196,11 @@ try: geomstr='select astext(st_simplify(transform(the_geom,4326),0.02)) from "%s"."%s"'%(schema,table) geomdata=self.executeSQL(geomstr) + teststr=geomdata.values()[1][0] + if (teststr == (u'MULTIPOLYGON EMPTY',)): + geomstr='select astext(st_simplify(transform(the_geom,2333),0.02)) from "%s"."%s"'%(schema,table) + geomdata=self.executeSQL(geomstr) + except: try: geomstr='select chgis.astext(chgis.st_simplify(chgis.transform(the_geom,4326),0.02)) from "%s"."%s"'%(schema,table) @@ -203,7 +208,7 @@ except: geomdata=None - if (gisIdField is None) and (latField is None or lonField is None): + if (gisIdField is None) and (latField is None or lonField is None) and geomField=='point': # no fields given - choose automagically sql = 'SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s' # gis id in metadata first @@ -220,7 +225,7 @@ if len(res['rows']) > 0: lonField = res['rows'][0][0] - if (gisIdField is None) and (latField is None or lonField is None): + if (gisIdField is None) and (latField is None or lonField is None) and geomField=='point': logging.warning("no entry in metadata table for table %s" % table) # still no fields - try field names if 'latitude' in fieldMap and 'longitude' in fieldMap: @@ -244,8 +249,11 @@ # convert data kmlData = [] geom_list = {} - if geomField=='poly' and len(geomdata)>0: + try: + if geomField=='poly' or geomField=='line': geom_list=geomdata.values()[1] + except: + return "no geomdata in RestDbGisApi Line 254" data_list=data['rows'] for k in range (len(data_list)): dataset = data_list[k] @@ -257,7 +265,7 @@ # for dataset in data['rows']: xCoord = 0.0 yCoord = 0.0 - if gisIdIdx is not None: + if gisIdIdx is not None and geomField=='point' : gisID = dataset[gisIdIdx] coords=self.getPointForChGisId(gisID) if coords!=None: @@ -268,14 +276,14 @@ xCoord = dataset[lonIdx] yCoord = dataset[latIdx] - else: + elif geomField=='point' : logging.error("getKMLdata unable to find position") return None - if float(xCoord) == 0.0: + if geomField=='point' : + if float(xCoord) == 0.0: continue - - if float(yCoord) == 0.0: + if float(yCoord) == 0.0: continue kmlPlace = {} @@ -334,7 +342,7 @@ kmlPlace['coord_y'] = str(yCoord) kmlPlace['coord_z'] = '0' kmlData.append(kmlPlace) - if geomField=='poly' and len(geomdata)>0: + if (geomField=='poly' or geomField=='line') and len(geomdata)>0: polys=str(geom_value).split('(') aaa=len(polys) for poly in polys: diff -r f930ce2583a0 -r bdab16f83512 zpt/KML_schema_table.zpt --- a/zpt/KML_schema_table.zpt Thu May 12 16:23:04 2011 +0200 +++ b/zpt/KML_schema_table.zpt Mon Aug 01 21:35:27 2011 +0200 @@ -9,7 +9,7 @@ + + ERD-0815: ERD-0815 @@ -119,9 +137,13 @@ ERD-0815: ERD-0815 - - 116.38,39.92,0 - + + #red_line + + 1 + 1 + 116.38,39.92,0 + Path @@ -136,5 +158,5 @@ - +