Changeset 3434


Ignore:
Timestamp:
15/02/08 13:46:52 (12 years ago)
Author:
mkochan
Message:

Added display of multiple CSML features (plots) per station.

Location:
DPPP/kml/csml2kml
Files:
2 added
4 edited

Legend:

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

    r3363 r3434  
    132132    ''' 
    133133     
    134     def __init__(self, id, name, lon, lat, styleID = None, data=None): 
     134    def __init__(self, id, name, lon, lat, featuresHtml, styleID = None, data=None): 
    135135        self.id = id 
    136136        self.name = name 
    137137        self.lon = lon 
    138138        self.lat = lat 
     139        self.featuresHtml = featuresHtml 
    139140        self.styleID = styleID 
    140141        self.data = data 
     
    167168                value = value.replace('#LON#', str(self.lon)) 
    168169                value = value.replace('#LAT#', str(self.lat)) 
     170                value = value.replace('#FEATS#', self.featuresHtml) 
    169171                SubElement(dataElement, 'value').text = value 
    170  
     172                 
    171173        return placemarkElement 
    172174 
  • DPPP/kml/csml2kml/python/csml2kml/StationConvertor.py

    r3363 r3434  
    2626 
    2727        # URL of GeoServer to get a <wfs:StationCollection> from 
    28         self.url = self.config.find('GeoServerRequest/URL').text 
     28        self.geoServerUrl = self.config.find('GeoServerRequest/URL').text 
    2929 
    3030        # Get template for placemark balloons; create a KML style for placemarks 
     
    4646        self.lockedFolderStyle = KMLStyle('locked_folder_style', listItemType = 'checkHideChildren') 
    4747 
     48        self.grapherUrl = self.config.find('GrapherRequest/URL').text 
     49 
    4850    def _npStationToKmlPlacemark(self, npStation): 
    4951        '''Converts a Station.NPStation object into it's KML.KMLPlacemark representation''' 
    50         return KMLPlacemark(npStation.id, npStation.desc, npStation.lon, npStation.lat, 
     52        featuresHtml = '' 
     53        for featureId in npStation.csmlFeatureIds: 
     54            featuresHtml = featuresHtml + '<img src="' + self.grapherUrl + '?feature_id=' + featureId + '"><br>' 
     55        return KMLPlacemark(npStation.id, npStation.desc, npStation.lon, npStation.lat, featuresHtml, 
    5156                            styleID = self.placemarkKmlStyle.id, data = self.stationData 
    5257                            ) 
     
    121126 
    122127        # Get a collection of stations from a GeoServer, and put the stations into a list 
    123         geoServerResponse = wget(self.url) 
     128        geoServerResponse = wget(self.geoServerUrl) 
    124129        wfsStationsCollection = WFSStationCollection() 
    125130        wfsStationsCollection.parseString(geoServerResponse) 
  • DPPP/kml/csml2kml/python/csml2kml/tests/testStationConvertor.py

    r3362 r3434  
    66configTree.parse('../../../testdata/midas.csml2kml.conf.xml') 
    77configRoot = configTree.getroot() 
    8 config = configRoot.find('CSMLStationPointSeries') 
     8config = configRoot.find('NPStations2KML') 
    99 
    1010# Do the conversion 
    11 convertor = StationConvertor(config, '../../../output/exampleps_stations.3.xml') 
     11convertor = StationConvertor(config, '../../../output/exampleps_stations.3.kml') 
    1212convertor.convert() 
  • DPPP/kml/csml2kml/testdata/midas.csml2kml.conf.xml

    r3370 r3434  
    11<CSML2KMLConfig> 
    2   <CSMLStationPointSeries> 
     2  <NPStations2KML> 
     3    <!-- Notes: The GrapherURL tag should refer to a service that can graph csml:PointSeriesFeature elements, 
     4         so that a request to address "GrapherURL?feature_id=some-feature-id" results in that feature being 
     5         drawn ( hence, the graphing service must be accessing the same GeoServer ). --> 
    36    <name>MIDAS stations (example)</name> 
    47    <UseRegions>yes</UseRegions> 
    58    <GeoServerRequest> 
    69      <URL>http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=MIDAS_Stations_with_features</URL> 
    7       <BalloonTemplate>&lt;img src="http://bond.badc.rl.ac.uk:8089/csmlGrapher/plot?feature_id=$[feature_id]"&gt;</BalloonTemplate> 
     10      <BalloonTemplate>Station $[station_name] (located at $[station_lon] longitude, $[station_lat] latitude). Contains features: $[station_features]</BalloonTemplate> 
    811      <StationData> 
    9         <Datum name="feature_id">#ID#</Datum> 
     12        <Datum name="station_id">#ID#</Datum> 
     13        <Datum name="station_name">#NAME#</Datum> 
     14        <Datum name="station_lon">#LON#</Datum> 
     15        <Datum name="station_lat">#LAT#</Datum> 
     16        <Datum name="station_features">#FEATS#</Datum> 
    1017      </StationData> 
    1118    </GeoServerRequest> 
    12   </CSMLStationPointSeries> 
     19    <GrapherRequest> 
     20      <URL>http://bond.badc.rl.ac.uk:8089/csmlGrapher/plot</URL> 
     21    </GrapherRequest>  
     22  </NPStations2KML> 
    1323</CSML2KMLConfig> 
Note: See TracChangeset for help on using the changeset viewer.