Ignore:
Timestamp:
17/03/08 15:34:40 (12 years ago)
Author:
mkochan
Message:

Finished listing of features according to collection times (only those features are listed which are available during the whole interval. Also, add more detailed error messages.

File:
1 edited

Legend:

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

    r3614 r3633  
    2424    ''' 
    2525 
    26     def __init__(self, id = None, desc = None, lon = None, lat = None, features = None): 
     26    def __init__(self, id = None, desc = None, lon = None, lat = None, stationFeatures = None): 
    2727        ''' 
    2828        The initialiser (use empty call C{NPStation()} and later call the C{parseString} or C{parseXML} method). 
     
    3131        self.desc = desc 
    3232        self.lon = lon; self.lat = lat 
    33         self.csmlFeatureIds = csmlFeatureIds 
     33        self.stationFeatures = stationFeatures 
    3434 
    3535    def parseString(self, str): 
     
    4848 
    4949        # Extract the identifier, short description, and longitude and latitute 
    50         (stationNameElement, stationIDElement, locationElement, featuresElement) = stationElement.getchildren() 
     50        (stationNameElement, stationIDElement, locationElement, stationFeaturesElement) = stationElement.getchildren() 
    5151        pointElement = locationElement.getchildren()[0] 
    5252        posElement = pointElement.getchildren()[0] 
     
    5555        self.desc = stationNameElement.text 
    5656 
    57         # Extract the IDs of the associated CSML features 
    58         self.csmlFeatureIds = [] 
    59         for stationsFeatureElement in featuresElement.getchildren(): 
    60             (featureTypeElement, featureParameterElement) = stationsFeatureElement.getchildren() 
    61             if featureTypeElement.text != 'csml:PointSeriesFeature': 
    62                 raise TypeError('Feature type not "csml:PointSeriesFeature"') 
    63             self.csmlFeatureIds.append(featureParameterElement.text) 
     57        self.stationFeatures = [] 
     58        for stationFeatureElement in stationFeaturesElement.getchildren(): 
     59            npStationFeature = NPStationFeature() 
     60            npStationFeature.parseXML(stationFeatureElement) 
     61            self.stationFeatures.append(npStationFeature) 
    6462 
    6563    def __repr__(self): 
    6664        return '<np:Station> %s ("%s") located at (%f, %f) with %d features (%s).' % ( 
    67             self.id, self.desc, self.lon, self.lat, len(self.csmlFeatureIds), str(self.csmlFeatureIds) 
     65            self.id, self.desc, self.lon, self.lat, len(self.stationFeatures), str(self.stationFeatures) 
    6866            ) 
    6967 
     
    9694        (featureTypeElement, featureIdElement,  
    9795         collectBeginDateElement, collectEndDateElement) = stationFeatureElement.getchildren() 
    98         if featureTypeElement != 'csml:PointSeriesFeature': 
     96        if featureTypeElement.text != 'csml:PointSeriesFeature': 
    9997            raise NotImplementedError('No other than "csml:PointSeriesFeature" feature type is supported') 
    100         self.featureID = featureIdElement.text 
     98        self.featureType = featureTypeElement.text 
     99        self.featureId = featureIdElement.text 
    101100        self.collectBeginDate = dates.dateutil.parser.parse(collectBeginDateElement.text) 
    102101        self.collectEndDate = dates.dateutil.parser.parse(collectEndDateElement.text) 
     102 
     103    def __repr__(self): 
     104        return str(vars(self)) 
    103105 
    104106class WFSStationCollection: 
Note: See TracChangeset for help on using the changeset viewer.