Mercurial > hg > ChinaGisRestApi
changeset 57:b47314bcff37
connect lines works now
author | casties |
---|---|
date | Wed, 20 Oct 2010 18:27:24 +0200 |
parents | 8eca8a1fbf50 |
children | 5ed0769f5ad3 |
files | RestDbGisApi.py zpt/GIS_schema_table.zpt zpt/KML_schema_table.zpt |
diffstat | 3 files changed, 40 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbGisApi.py Tue Oct 19 18:08:49 2010 +0200 +++ b/RestDbGisApi.py Wed Oct 20 18:27:24 2010 +0200 @@ -11,6 +11,7 @@ import re import json import time +import urllib from RestDbInterface import * @@ -52,7 +53,7 @@ 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,id=id,doc=doc) + return self.getLiveKmlUrl(schema=schema,table=table) def checkTableMetaPermission(self,action,schema,table,user=None): @@ -154,10 +155,17 @@ baseUrl = self.absolute_url() return "%s/daten/%s"%(baseUrl,kml) - def getLiveKmlUrl(self,schema='chgis',table='mpdl',id=None,doc=None): + def getLiveKmlUrl(self,schema,table,REQUEST=None): + if REQUEST is None: + REQUEST = self.REQUEST logging.debug("getLiveKmlUrl") baseUrl = self.absolute_url() - return "%s/db/%s/%s?format=KML"%(baseUrl,schema,table) + timestamp = time.time() + params = [p for p in REQUEST.form.items() if p[0] not in ('format','timestamp')] + params.append(('format','KML')) + params.append(('timestamp',timestamp)) + paramstr = urllib.urlencode(params) + return "%s/db/%s/%s?%s"%(baseUrl,schema,table,paramstr) def getDataForGoogleMap(self,schema='chgis',table='mpdl',id=None,doc=None): logging.debug("getDataForGoogleMap") @@ -257,21 +265,23 @@ name = data['fields'][i][0] logging.debug("value=%s"%value) if value != None: - if name.find('name')>-1: - desc += "<name>%s</name>\n"%value - continue - elif name.find('place')>-1: - desc += "<name>%s</name>\n"%value - continue + #if name.find('name')>-1: + # desc += "<name>%s</name>\n"%value + # continue + #elif name.find('place')>-1: + # desc += "<name>%s</name>\n"%value + # continue val = "%s: %s"%(name, value) if val.find('http')>-1: val ='<a href="' + val + '" target="_blank">' + val + '</a>' - desc += kmlEncode(val) + #desc += kmlEncode(val) + desc += val desc += '<br/>\n' - kmlPlace['description'] = "<![CDATA[%s]]>"%desc + #kmlPlace['description'] = "<![CDATA[%s]]>"%desc + kmlPlace['description'] = desc kmlPlace['icon'] = '#marker_icon' kmlPlace['coord_x'] = str(xCoord) kmlPlace['coord_y'] = str(yCoord)
--- a/zpt/GIS_schema_table.zpt Tue Oct 19 18:08:49 2010 +0200 +++ b/zpt/GIS_schema_table.zpt Wed Oct 20 18:27:24 2010 +0200 @@ -1,7 +1,7 @@ <!DOCTYPE html> -<html tal:define="root here/getRestDbUrl; layout python:request.get('layout','pre'); element_id python:request.get('element_id',None); - schema options/schema; table options/table; id python:request.get('id',[]); doc python:request.get('doc',None); - kmlUrl python:here.getLiveKmlUrl(schema=schema,table=table,id=id,doc=doc); +<html tal:define="root here/getRestDbUrl; + schema options/schema; table options/table; + kmlUrl python:here.getLiveKmlUrl(schema=schema,table=table); "> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> @@ -44,8 +44,7 @@ <script src="/chinagis/javascript/labeledMarker.js" type="text/javascript"></script>--> <script type="text/javascript"> var map = null; - function initialize(data) { - kmlURL=initialize.arguments[0]; + function initialize(kmlUrl) { map = new google.maps.Map(document.getElementById("map_canvas")); map.setMapTypeId(google.maps.MapTypeId.TERRAIN); var latlng = new google.maps.LatLng(29,116); @@ -53,7 +52,7 @@ map.setZoom(5); // (Zoom-Level) //geocoder = new google.maps.Geocoder(); - newMarker=new google.maps.KmlLayer(kmlURL); + newMarker=new google.maps.KmlLayer(kmlUrl); newMarker.setMap(map); } </script>
--- a/zpt/KML_schema_table.zpt Tue Oct 19 18:08:49 2010 +0200 +++ b/zpt/KML_schema_table.zpt Wed Oct 20 18:27:24 2010 +0200 @@ -5,27 +5,27 @@ <Document> <Style id="marker_icon"> <IconStyle> - <scale>15</scale> + <scale>1.2</scale> <Icon> <href>http://chinagis.mpiwg-berlin.mpg.de/chinagis/images/dot_red.png</href> </Icon> + <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/> </IconStyle> </Style> <Style id="red_line"> <LineStyle> - <color>red</color> + <color>ff0000ff</color> <width>4</width> </LineStyle> + <PolyStyle> + <color>ff0000ff</color> + </PolyStyle> </Style> <Placemark tal:repeat="place data"> - <description tal:content="place/description"><![CDATA[<b>ERD-0815: ERD-0815</a><br> -Jingshi: Jingshi</a><br> -nma_1898541: nma_1898541</a><br> -Forbidden City: Forbidden City</a><br> -1406: 1406</a><br> -720000: 720000</a><br> -]]></description> - <styleURL tal:content="place/icon">#marker_icon</styleURL> + <description tal:content="place/description"> + ERD-0815: ERD-0815 + </description> + <styleUrl tal:content="place/icon">#marker_icon</styleUrl> <Point> <coordinates tal:content="string:${place/coord_x},${place/coord_y},${place/coord_z}">116.38,39.92,0</coordinates> </Point> @@ -37,8 +37,10 @@ <LineString> <extrude>1</extrude> <tessellate>1</tessellate> - <altitudeMode>absolute</altitudeMode> - <coordinates tal:repeat="place data" tal:content="string:${place/coord_x},${place/coord_y},${place/coord_z}">116.38,39.92,0</coordinates> + <altitudeMode>clampToGround</altitudeMode> + <coordinates> + <tal:span tal:repeat="place data" tal:content="string:${place/coord_x},${place/coord_y},${place/coord_z}">116.38,39.92,0</tal:span> + </coordinates> </LineString> </Placemark> </Document>