Changeset 3276
- Timestamp:
- 28/01/08 12:06:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py
r3265 r3276 10 10 from datetime import datetime, timedelta 11 11 import re 12 import urllib 12 13 from cStringIO import StringIO 13 14 from tempfile import NamedTemporaryFile 15 from cElementTree import Element, ElementTree, XML 14 16 15 17 log = logging.getLogger(__name__) … … 82 84 response.content_type = 'image/png' 83 85 response.content = buf.getvalue() 86 87 def wget(url): 88 socket = None 89 content = None 90 try: 91 socket = urllib.urlopen(url) # open a socket (actually a file-like object) 92 content = socket.read() # read the text in 93 finally: 94 if socket: 95 socket.close() 96 return content 97 98 #------------------------------------------------------------------------------------------------------------------- 84 99 85 100 feature_id = request.params['feature_id'] # get feature ID from HTTP request 86 101 87 ds=csml.parser.Dataset() # parse the dataset 88 ds.parse('/home/users/mkochan/svn-root/kml/csml2kml/etc/pointseries/exampleps.xml') 89 features = ds.featureCollection.featureMembers # isolate the requested feature 90 feature = None 91 for any_feature in features: 102 station_id = 'NA' 103 geoServerURL = 'http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?station_id=' + station_id 104 geoSrResponse = wget(geoServerURL) # get response from GeoServer 105 106 tree = ElementTree(XML(geoSrResponse)) # parse in the feature collection 107 fc = csml.parser.CSMLFeatureCollection() 108 fc.fromXML(tree.getroot()) 109 if not fc: 110 exit() 111 112 feature = None # find the requested feature 113 for any_feature in fc.featureMembers: 92 114 if any_feature.id == feature_id: 93 115 feature = any_feature
Note: See TracChangeset
for help on using the changeset viewer.