Changeset 3306


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.

Location:
DPPP/kml/csml2kml
Files:
2 edited
2 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) 
  • DPPP/kml/csml2kml/python/csml2kml/tests/testPointSeriesConvertor.py

    r3303 r3306  
    1 import PointSeriesConvertor 
     1from PointSeriesConvertor import PointSeriesConvertor 
    22from cElementTree import ElementTree 
    33 
    44# Load the configuration XML element 
    55configTree = ElementTree() 
    6 configTree.parse('../../testdata/midas.csml2kml.conf.xml') 
     6configTree.parse('../../../testdata/midas.csml2kml.conf.xml') 
    77configRoot = configTree.getroot() 
    8 config = configRoot.find('CSML2KMLConfig/CSMLStationPointSeries') 
     8config = configRoot.find('CSMLStationPointSeries') 
    99 
    1010# Do the conversion 
    11 convertor = PointSeriesConvertor(config, '../../output/exampleps.3.xml') 
     11convertor = PointSeriesConvertor(config, '../../../output/exampleps_stations.2.xml') 
     12convertor.convert() 
  • DPPP/kml/csml2kml/testdata/midas.csml2kml.conf.xml

    r3305 r3306  
    11<CSML2KMLConfig> 
    22  <CSMLStationPointSeries> 
    3     <name>MIDAS stations example</name> 
     3    <name>MIDAS stations (example)</name> 
    44    <GeoServerRequest> 
    55      <URL>http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations</URL> 
    6       <BalloonTemplate> 
    7         &lt;img src="http://bond.badc.rl.ac.uk:8089/csmlGrapher/plot?feature_id=$[feature_id]"&gt; 
    8       </BalloonTemplate> 
     6      <BalloonTemplate>&lt;img src="http://bond.badc.rl.ac.uk:8089/csmlGrapher/plot?feature_id=$[feature_id]"&gt;</BalloonTemplate> 
    97      <StationData> 
    108        <Datum name="feature_id">#ID#</Datum> 
Note: See TracChangeset for help on using the changeset viewer.