Ignore:
Timestamp:
04/02/08 18:20:38 (12 years ago)
Author:
mkochan
Message:

Finished the testPointSeriesConvertor.py test script. Have running version of configurable PointSeriesConvertor? module.

File:
1 moved

Legend:

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

    r3304 r3306  
    1515        self.kmlFilename = kmlFilename 
    1616 
    17     def parseGMLStationsCollection(textGml): 
    18         ''' 
    19         Parse the GML returned from GeoServer and yield tuples containing information (gml_id, name, lon, lat) 
    20         about each station. 
    21         ''' 
    22         root = XML(textGml) 
    23         featureCollectionElement = root 
    24         for featureMember in featureCollectionElement.getchildren(): 
    25             stationElement = featureMember.getchildren()[0] 
    26             (stationNameElement, stationIDElement, locationElement) = stationElement.getchildren() 
    27             pointElement = locationElement.getchildren()[0] 
    28             posElement = pointElement.getchildren()[0] 
    29             (lon,lat) = map(float, posElement.text.split()) 
    30             yield (stationElement.get('{http://www.opengis.net/gml}id'), stationNameElement.text, lon, lat) 
    31  
    32     def convert(self, config, kmlFilename): 
     17    def convert(self): 
    3318        ''' 
    3419        Convert GML input from GeoServer (containing the <Station> tags with station information) 
     
    3924        ''' 
    4025 
     26        def _parseGMLStationsCollection(textGml): 
     27            ''' 
     28            Parse the GML returned from GeoServer and yield tuples containing information (gml_id, name, lon, lat) 
     29            about each station. 
     30            ''' 
     31            root = XML(textGml) 
     32            featureCollectionElement = root 
     33            for featureMember in featureCollectionElement.getchildren(): 
     34                stationElement = featureMember.getchildren()[0] 
     35                (stationNameElement, stationIDElement, locationElement) = stationElement.getchildren() 
     36                pointElement = locationElement.getchildren()[0] 
     37                posElement = pointElement.getchildren()[0] 
     38                (lon,lat) = map(float, posElement.text.split()) 
     39                yield (stationElement.get('{http://www.opengis.net/gml}id'), stationNameElement.text, lon, lat) 
     40 
    4141        # Read conversion configuration 
    4242        documentName = self.config.find('name').text 
     
    4444        balloonTemplate = self.config.find('GeoServerRequest/BalloonTemplate').text 
    4545        stationData = {} 
    46         data = self.config.findAll('GeoServerRequest/StationData/Datum') 
     46        data = self.config.findall('GeoServerRequest/StationData/Datum') 
    4747        for datum in data: 
    4848            datumName = datum.get('name') 
     
    5454        placemarkKmlStyle = createDefaultPlacemarKMLStyle(balloonTemplate = balloonTemplate) 
    5555        kmlDocument = KMLDocument(documentName, [placemarkKmlStyle]) 
    56         generator = parseGMLStationsCollection(textGml) 
     56        generator = _parseGMLStationsCollection(textGml) 
    5757        for (gml_id, name, lon, lat) in generator: 
    5858            kmlStation = KMLPlacemark(gml_id, name, lon, lat, styleID = placemarkKmlStyle.id, data = stationData) 
Note: See TracChangeset for help on using the changeset viewer.