changeset 255:ec7b63319fad

GIS-Links from MPDL-Documents now served by Mappit-Server
author fknauft
date Wed, 28 Sep 2011 17:43:50 +0200
parents 901c1f745d13
children cb953cc153a6
files RestDbGisApi.py zpt/KML_schema_table.zpt
diffstat 2 files changed, 24 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbGisApi.py	Wed Sep 28 15:09:14 2011 +0200
+++ b/RestDbGisApi.py	Wed Sep 28 17:43:50 2011 +0200
@@ -159,7 +159,7 @@
         idList = None
         if ids is not None:
             qstr += ' WHERE '
-            if table=='mpdl':
+            if schema=='mpdl':
                 qstr += 'mpdl_xmlsource_id IN ('
             else:
                 qstr += 'CAST(id AS text) IN ('
@@ -187,7 +187,7 @@
                 bad_luck=False
                 bl_counter=bl_counter+1
             except:
-                if (bl_counter<100):
+                if (bl_counter<5):
                     bad_luck=True
                 else:
                     bad_luck=False
@@ -216,15 +216,14 @@
             res = self.executeSQL(sql, (table,'gis_id'))
             if len(res['rows']) > 0:
                 gisIdField = res['rows'][0][0]
-            else:
-                # latitude in metadata
-                res = self.executeSQL(sql, (table,'coord_lat'))
-                if len(res['rows']) > 0:
-                    latField = res['rows'][0][0]
-                    # longitude in metadata
-                    res = self.executeSQL(sql, (table,'coord_lon'))
-                    if len(res['rows']) > 0:
-                        lonField = res['rows'][0][0]
+            # latitude in metadata
+            res = self.executeSQL(sql, (table,'coord_lat'))
+            if len(res['rows']) > 0:
+                latField = res['rows'][0][0]
+                # longitude in metadata
+            res = self.executeSQL(sql, (table,'coord_lon'))
+            if len(res['rows']) > 0:
+                lonField = res['rows'][0][0]
                         
         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)
@@ -266,14 +265,17 @@
   #      for dataset in data['rows']:
             xCoord = 0.0
             yCoord = 0.0
-            if gisIdIdx is not None and geomField=='point' :
+            if gisIdIdx != None and geomField=='point' :
                 gisID = dataset[gisIdIdx]
-                coords=self.getPointForChGisId(gisID)
-                if coords!=None:
-                    xCoord=coords[0]
-                    yCoord=coords[1]
-                    
-            elif latIdx is not None:
+                if gisID != " ":
+                    coords=self.getPointForChGisId(gisID)
+                    if coords!=None:
+                        xCoord=coords[0]
+                        yCoord=coords[1]
+                elif latIdx != None:
+                    xCoord = dataset[lonIdx]
+                    yCoord = dataset[latIdx]    
+            elif latIdx != None:
                 xCoord = dataset[lonIdx]
                 yCoord = dataset[latIdx]
                 
--- a/zpt/KML_schema_table.zpt	Wed Sep 28 15:09:14 2011 +0200
+++ b/zpt/KML_schema_table.zpt	Wed Sep 28 17:43:50 2011 +0200
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:tal="http://xml.zope.org/namespaces/tal" 
   tal:define="gisIdField python:request.get('gis_id_field',None); colorField python:request.get('color_field','red');
-  latField python:request.get('lat_field',None); lonField python:request.get('lon_field',None); geomField python:request.get('geometry_field','poly');
-  sortBy python:request.get('sort_field',1);
+  latField python:request.get('lat_field',None); lonField python:request.get('lon_field',None); geomField python:request.get('geometry_field','point');
+  sortBy python:request.get('sort_field',1); ids python:request.get('id');
   schema options/schema; table options/table; 
-  data python:here.getKmlData(schema=schema,table=table,sortBy=sortBy,gisIdField=gisIdField,latField=latField,lonField=lonField,geomField=geomField,colorField=colorField ); 
+  data python:here.getKmlData(schema=schema,table=table,sortBy=sortBy,ids=ids,gisIdField=gisIdField,latField=latField,lonField=lonField,geomField=geomField,colorField=colorField ); 
   withLine python:request.get('connect_line',None);">
   <Document>
     <Style id="marker_icon_red">
@@ -176,14 +176,12 @@
       </PolyStyle>
     </Style>
     <Placemark tal:repeat="place data" tal:condition="python:here.trydatahas_key(data,0,'icon')">
-   <!--
       <description tal:content="place/description">
       ERD-0815: ERD-0815
       </description>
       <styleUrl tal:content="place/icon" >#marker_icon_red</styleUrl>
       <Point tal:condition="python:place.has_key('icon')">
-     --> 
-      <Point>
+        <extrude>1</extrude>
         <coordinates tal:content="string:${place/coord_x},${place/coord_y},${place/coord_z}">116.38,39.92,0</coordinates>
       </Point>
     </Placemark>