Changeset 3370 for DPPP


Ignore:
Timestamp:
11/02/08 16:50:18 (12 years ago)
Author:
mkochan
Message:

Added parsing station features in Station.py

Location:
DPPP/kml/csml2kml
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/csml2kml/Station.py

    r3365 r3370  
    1111    '''Represents a ground meteorological station, identified by id, with description (desc), located at (lon,lat)''' 
    1212 
    13     def __init__(self, id = None, desc = None, lon = None, lat = None): 
     13    def __init__(self, id = None, desc = None, lon = None, lat = None, csmlFeatureIds = None): 
    1414        ''' 
    1515        The initialiser. It is possible (and typical) not to initialise using it but rather leave 
     
    1919        self.desc = desc 
    2020        self.lon = lon; self.lat = lat 
     21        self.csmlFeatureIds = csmlFeatureIds 
    2122 
    2223    def parseString(self, str): 
     
    2526 
    2627    def parseXML(self, stationElement): 
    27         (stationNameElement, stationIDElement, locationElement) = stationElement.getchildren() 
     28        (stationNameElement, stationIDElement, locationElement, featuresElement) = stationElement.getchildren() 
    2829        pointElement = locationElement.getchildren()[0] 
    2930        posElement = pointElement.getchildren()[0] 
     
    3132        self.id = stationElement.get('{http://www.opengis.net/gml}id') 
    3233        self.desc = stationNameElement.text 
     34        self.csmlFeatureIds = [] 
     35        for stationsFeatureElement in featuresElement.getchildren(): 
     36            (featureIdElement, featureTypeElement) = stationsFeatureElement.getchildren() 
     37            self.csmlFeatureIds.append(featureIdElement.text) 
    3338 
    3439    def __repr__(self): 
    35         return '<np:Station> %s ("%s") located at (%f, %f)' % (self.id, self.desc, self.lon, self.lat) 
     40        return '<np:Station> %s ("%s") located at (%f, %f) with %d features.' % ( 
     41            self.id, self.desc, self.lon, self.lat, len(self.csmlFeatureIds) 
     42            ) 
    3643 
    3744class WFSStationCollection: 
     
    5360        Use if your WFS subset of XML is stored in an ElementTree.Element object. 
    5461        ''' 
    55         for featureMember in featureCollectionElement.getchildren(): 
    56             stationElement = featureMember.getchildren()[0] 
    57             station = NPStation() 
    58             station.parseXML(stationElement) 
    59             self.stations.append(station) 
     62        featureMembersElement = featureCollectionElement.getchildren()[0] 
     63        for npStationElement in featureMembersElement.getchildren(): 
     64            npStation = NPStation() 
     65            npStation.parseXML(npStationElement) 
     66            self.stations.append(npStation) 
  • DPPP/kml/csml2kml/python/csml2kml/tests/testStation.py

    r3365 r3370  
    55 
    66# Get XML response from a GeoServer via HTTP 
    7 geoServerUrl = 'http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations' 
     7geoServerUrl = 'http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations_with_features' 
    88geoServerResponse = wget(geoServerUrl) 
    99 
     
    1616 
    1717# Each station is a NPStation object, which is a representation of a <np:Station> XML element. 
     18print str(len(npStations)) + ' stations.' 
    1819for npStation in npStations: 
    1920    print npStation 
  • DPPP/kml/csml2kml/python/notes.txt

    r3369 r3370  
    66 
    77---------------------------------------------------------------------------------------------------------------------------- 
    8 || psOntoWMS.py / 
    9  
    10 [O] Tidy up. 
     8|| _ / 
    119     
    1210---------------------------------------------------------------------------------------------------------------------------- 
     
    1412[+] Assertion and type checking in Python 
    1513[o] Resolve slow functioning of wget() 
    16 [o] Resolve outstanding issues in pylons controllers 
     14[o] Use Element.find(...) in parsing XML -- investigate how to do it easily with namespaces 
     15    (otherwise need code to translate between the "namespace:name" notation and "{namespace_path}name" notation). 
     16[o] Resolve security in pylons controllers 
    1717[.] Consider issues with visibility and open tags for elements -- how should they be set? 
    1818[x] Possibility of clicking on a globe and getting info for a certain feature (i.e. the value profile for that 
  • DPPP/kml/csml2kml/testdata/midas.csml2kml.conf.xml

    r3322 r3370  
    44    <UseRegions>yes</UseRegions> 
    55    <GeoServerRequest> 
    6       <URL>http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations</URL> 
     6      <URL>http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations_with_features</URL> 
    77      <BalloonTemplate>&lt;img src="http://bond.badc.rl.ac.uk:8089/csmlGrapher/plot?feature_id=$[feature_id]"&gt;</BalloonTemplate> 
    88      <StationData> 
Note: See TracChangeset for help on using the changeset viewer.