changeset 150:96311f3d627b

polygon-Layers
author fknauft
date Fri, 04 Feb 2011 16:46:50 +0100
parents 143b67a139f9
children 348a11a5e49c
files RestDbGisApi.py
diffstat 1 files changed, 32 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbGisApi.py	Thu Feb 03 14:02:05 2011 +0100
+++ b/RestDbGisApi.py	Fri Feb 04 16:46:50 2011 +0100
@@ -239,7 +239,18 @@
         
         # convert data
         kmlData = []
-        for dataset in data['rows']:
+        
+        if geomField=='poly' and len(geomdata)>0:
+                geom_list=geomdata.values()[1]
+        data_list=data['rows']
+        for k in range (len(data_list)):
+            dataset = data_list[k]
+            if len(geom_list)>k:
+                    geom_value = geom_list[k]
+        
+        
+        
+  #      for dataset in data['rows']:
             xCoord = 0.0
             yCoord = 0.0
             if gisIdIdx is not None:
@@ -267,12 +278,15 @@
             
             # description
             desc = ''
-            i = -1
-            for value in dataset:
-                i += 1
+           
+ 
+            for i in range (len(dataset)):
+                value = dataset[i]
+                
                 name = data['fields'][i][0]
                 #logging.debug("value=%s"%value)
-                if value != None:
+                if name != 'the_geom':
+                  if value != None:
                     #if name.find('name')>-1:
                     #    desc += "<name>%s</name>\n"%value
                     #    continue
@@ -289,33 +303,38 @@
                     desc += '<br/>\n'
                       
             #kmlPlace['description'] = "<![CDATA[%s]]>"%desc
-            kmlPlace['description'] = desc
+            
                   
             if geomField=='point':
+                kmlPlace['description'] = desc
                 kmlPlace['icon'] = '#marker_icon_'+colorField
                 kmlPlace['coord_x'] = str(xCoord)
                 kmlPlace['coord_y'] = str(yCoord)
                 kmlPlace['coord_z'] = '0'
                 kmlData.append(kmlPlace)
             if geomField=='poly' and len(geomdata)>0:
-                geom_list=geomdata.values()
-                polys=str(geom_list[1]).split('(')
+                polys=str(geom_value).split('(')
                 aaa=len(polys)
                 for poly in polys:
+                    kmlPlace = {}
+                    kmlPlace['description'] = desc
                     coords=poly.replace(')','').split(',')
+                    coord_string=''
                     if len(coords)>1:
-                        coord_string=''
                         for coord in coords:
                             coord=coord.split(' ')
                             try:
                                 x_coord=coord[0]
+                                if x_coord=='121.675615842265':
+                                    a='pause'
                                 y_coord=coord[1]
                             except:
                                 break
-                            coord_string+=x_coord+','+y_coord+','+'0 \n'
-                        kmlPlace['LinearRing']=coord_string              
-                        kmlPlace['LineColor']=colorField
-                        kmlData.append(kmlPlace)
+                            coord_string+=x_coord+','+y_coord+','+'0 '
+                    if coord_string != '':
+                            kmlPlace['LinearRing']=coord_string              
+                            kmlPlace['LineColor']=colorField
+                            kmlData.append(kmlPlace)
         #logging.debug("kmlData=%s"%(repr(kmlData)))
         return kmlData