changeset 245:7c5d825a0083

show line and polygon-layer
author fknauft
date Thu, 08 Sep 2011 13:04:48 +0200
parents 57f0dfaf5949
children 83b5d3215c19
files RestDbGisApi.py gis_gui/blocks/layer.js gis_gui/blocks/map.js zpt/GIS_schema_table.zpt zpt/KML_schema_table.zpt
diffstat 5 files changed, 81 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbGisApi.py	Tue Sep 06 12:53:17 2011 +0200
+++ b/RestDbGisApi.py	Thu Sep 08 13:04:48 2011 +0200
@@ -41,12 +41,13 @@
     HTML_schema_usertables = PageTemplateFile('zpt/HTML_schema_usertables', globals())
     
     # and scripts
-    def KML_URL_schema_table(self,schema,table):
+    def KML_URL_schema_table(self,schema,table, useTimestamp=True):
         """KML_URL table function"""
         self.REQUEST.RESPONSE.setHeader("Content-Type", "text/plain")
         id = self.REQUEST.get('id',[])           
         doc = self.REQUEST.get('doc',None)
-        return self.getLiveKmlUrl(schema=schema,table=table)
+   #     return self.getLiveKmlUrl(schema=schema,table=table, useTimestamp=useTimestamp)
+        return self.getLiveKmlUrl(schema=schema,table=table, useTimestamp=False)
 
     #
     # database methods
@@ -189,9 +190,19 @@
             else:
                 # TODO: proper quoting for names
                 qstr += ' ORDER BY "%s"'%sortBy.replace('"','')
-                
-        data = self.executeSQL(qstr,idList)
-        
+        bad_luck=True
+        bl_counter=0        
+        while (bad_luck):
+            try:
+                data = self.executeSQL(qstr,idList)
+                bad_luck=False
+                bl_counter=bl_counter+1
+            except:
+                if (bl_counter<100):
+                    bad_luck=True
+                else:
+                    bad_luck=False
+            
         fieldMap = self.getFieldNameMap(data['fields'])
         try:
             geomstr='select astext(st_simplify(transform(the_geom,4326),0.02)) from "%s"."%s"'%(schema,table)
@@ -361,7 +372,7 @@
                             coord_string+=x_coord+','+y_coord+','+'0 '
                     if coord_string != '':
                             kmlPlace['LinearRing']=coord_string              
-                            kmlPlace['LineColor']=colorField
+                            kmlPlace['lineColor']='#'+colorField+'_'+geomField
                             kmlData.append(kmlPlace)
         #logging.debug("kmlData=%s"%(repr(kmlData)))
         return kmlData
--- a/gis_gui/blocks/layer.js	Tue Sep 06 12:53:17 2011 +0200
+++ b/gis_gui/blocks/layer.js	Thu Sep 08 13:04:48 2011 +0200
@@ -124,7 +124,7 @@
         paramstr += "&connect_line="+params.connect_line;
     }
     var layerurl = "../db/RESTdb/db/public/" + escape(params.table) + "?" + paramstr;
-    //alert(layerurl);
+    console.debug("layerurl: ",layerurl);
     jQuery.get(layerurl, function(data, textStatus, XMLHttpRequest) {
         // function after load kml url finished
         console.debug("kml url loaded! this=", this, " data=", data, " ("+typeof(data)+")");
--- a/gis_gui/blocks/map.js	Tue Sep 06 12:53:17 2011 +0200
+++ b/gis_gui/blocks/map.js	Thu Sep 08 13:04:48 2011 +0200
@@ -215,7 +215,7 @@
             // render layer
             if (google != null) {
                 var newMarker=new google.maps.KmlLayer(kmlURL);
-                console.debug("new marker layer=",newMarker);
+                console.debug("new marker layer no",i,"=",newMarker);
                 console.debug("           map=",map);
                 newMarker.setMap(map);
                 console.debug("Map-Update finished");
--- a/zpt/GIS_schema_table.zpt	Tue Sep 06 12:53:17 2011 +0200
+++ b/zpt/GIS_schema_table.zpt	Thu Sep 08 13:04:48 2011 +0200
@@ -2,8 +2,8 @@
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
   tal:define="root here/getRestDbUrl;
-        schema options/schema; table options/table;
-        kmlUrl python:here.getLiveKmlUrl(schema=schema,table=table);
+        schema options/schema; table options/table; useTimestamp options/useTimestamp;
+        kmlUrl python:here.getLiveKmlUrl(schema=schema,table=table, useTimestamp=useTimestamp);
 ">
  <head>
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
--- a/zpt/KML_schema_table.zpt	Tue Sep 06 12:53:17 2011 +0200
+++ b/zpt/KML_schema_table.zpt	Thu Sep 08 13:04:48 2011 +0200
@@ -100,28 +100,79 @@
     <Style id="red_line">
       <LineStyle>
         <color>ff0000ff</color>
+        <width>2</width>
+      </LineStyle>
+    </Style>
+      <Style id="green_line">
+      <LineStyle>
+        <color>ff00ff00</color>
+        <width>2</width>
+      </LineStyle>
+    </Style>
+   <Style id="black_line">
+      <LineStyle>
+        <color>ff000000</color>
+        <width>2</width>
+      </LineStyle>
+    </Style>
+   <Style id="violett_line">
+      <LineStyle>
+        <color>ffff00ff</color>
+        <width>2</width>
+      </LineStyle>
+    </Style>
+   <Style id="blue_line">
+      <LineStyle>
+        <color>ffff0000</color>
+        <width>2</width>
+      </LineStyle>
+    </Style>
+    <Style id="red_big_line">
+      <LineStyle>
+        <color>ff0000ff</color>
         <width>4</width>
       </LineStyle>
-      <PolyStyle>
-        <color>ff0000ff</color>
-      </PolyStyle>
+    </Style>
+      <Style id="green_big_line">
+      <LineStyle>
+        <color>ff00ff00</color>
+        <width>4</width>
+      </LineStyle>
+    </Style>
+   <Style id="black_big_line">
+      <LineStyle>
+        <color>ff000000</color>
+        <width>4</width>
+      </LineStyle>
+    </Style>
+   <Style id="violett_big_line">
+      <LineStyle>
+        <color>ffff00ff</color>
+        <width>4</width>
+      </LineStyle>
+    </Style>
+   <Style id="blue_big_line">
+      <LineStyle>
+        <color>ffff0000</color>
+        <width>4</width>
+      </LineStyle>
     </Style>
     <Style id="blue_poly">
       <LineStyle>
-        <color>0000ffff</color>
+        <color>ffff0000</color>
         <width>2</width>
       </LineStyle>
       <PolyStyle>
-        <color>0000ffff</color>
+        <color>ffff0000</color>
       </PolyStyle>
     </Style>
     <Style id="black_poly">
       <LineStyle>
-        <color>000000ff</color>
+        <color>ff000000</color>
         <width>2</width>
       </LineStyle>
       <PolyStyle>
-        <color>000000ff</color>
+        <color>ff000000</color>
       </PolyStyle>
     </Style>
     <Placemark tal:repeat="place data" tal:condition="python:here.trydatahas_key(data,0,'icon')">
@@ -134,11 +185,11 @@
       </Point>
     </Placemark>
     <Placemark tal:repeat="place data" tal:condition="python:here.trydatahas_key(data,0,'LinearRing')">
+      <name>Border-Line</name>
       <description tal:content="place/description" >
       ERD-0815: ERD-0815
       </description>
-<!--      <styleUrl tal:content="place/icon" >#red_line</styleUrl> -->
-      <styleUrl >#red_line</styleUrl> 
+      <styleUrl tal:content="place/lineColor" >#red_line</styleUrl>
       <LineString>
        <extrude>1</extrude>
        <tessellate>1</tessellate>