Changeset 3234 for DPPP/kml


Ignore:
Timestamp:
16/01/08 15:11:55 (12 years ago)
Author:
mkochan
Message:

Finished CSML-to-KML conversion for the climatology dataset. Changed naming of dataset to use CSML name and naming of meteorological features to use feature description preferentially over feature (short)name.

Location:
DPPP/kml/csml2kml
Files:
4 edited

Legend:

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

    r3228 r3234  
    3737        
    3838        # Start with an empty KML document 
    39         kmlDocName='TEST GridSeries KML' 
    4039        kmlDocumentElement=Element('Document') 
    41         SubElement(kmlDocumentElement, 'name').text=kmlDocName 
     40        SubElement(kmlDocumentElement, 'name').text=self.ds.name.CONTENT 
    4241        SubElement(kmlDocumentElement, 'open').text='1' 
    4342 
    44         datasetName = os.path.split(self.csmlFilename)[1].split('.')[0] 
     43        #!!datasetName = os.path.split(self.csmlFilename)[1].split('.')[0] 
    4544 
    4645        # Create and populate a separate folder for each view 
     
    7069                # Generate a populated KML folder containing the feature, append it to the view 
    7170                kmlFeatureElement = gsKML.exportFeature(viewConfig) 
    72                 #!SubElement(kmlViewElement, kmlFeatureElement) 
    7371                kmlViewElement.append(kmlFeatureElement) 
    7472             
    75             #!SubElement(kmlDocumentElement, kmlViewElement) 
    7673            kmlDocumentElement.append(kmlViewElement) 
    7774             
    7875        # Attach the Document element as a subelement of the root 'kml' element 
    7976        kmlRootElement=Element('kml', xmlns='http://earth.google.com/kml/2.2') 
    80         #!SubElement(kmlRootElement, kmlDocumentElement) 
    8177        kmlRootElement.append(kmlDocumentElement) 
    8278        self._indentXML(kmlRootElement, 0) 
  • DPPP/kml/csml2kml/python/kmlfeatures.py

    r3228 r3234  
    3737        else: 
    3838            raise ValueError('Config error: Unsupported date/time delta') 
     39 
     40        try: 
     41            self.categoryNamingPattern = viewConfig.find('CategoryNamingPattern').text 
     42        except AttributeError: 
     43            self.categoryNamingPattern = None             
    3944 
    4045        # Name of the CSML file in which feature is contained 
     
    112117 
    113118        featureElement=Element('Folder') 
    114         SubElement(featureElement, 'name').text=self.name  # feature name 
     119        if self.description: 
     120            SubElement(featureElement, 'name').text=self.description  # come up with a feature folder name 
     121        else: 
     122            SubElement(featureElement, 'name').text=self.name 
    115123        SubElement(featureElement, 'open').text='0' 
    116124        SubElement(featureElement, 'visibility').text='0' 
     
    145153            for category in dictKeys:             
    146154                categoryElement=Element('Folder') 
    147                 SubElement(categoryElement, 'name').text='Category_' + str(category) 
     155 
     156                if self.categoryNamingPattern == None: 
     157                    categoryName = 'Category ' + str(category) 
     158                else: 
     159                    categoryName = self.categoryNamingPattern.replace('#VERBATIM#', str(category)) 
     160                    if (category >= 1 and category <= 12): 
     161                        categoryName = categoryName.replace('#MONTH#', getMonthCommonName(category)) 
     162                 
     163                SubElement(categoryElement, 'name').text=categoryName 
    148164                SubElement(categoryElement, 'open').text='0' 
    149165                SubElement(categoryElement, 'visibility').text='0'         
     
    208224 
    209225# -------------------------------------------------------------------------------------------------------------- 
     226 
     227def getMonthCommonName(monthInt): 
     228    if monthInt < 1 or monthInt > 12: 
     229        raise ArgumentError('Wrong month name (' + str(monthInt) + ')') 
     230    names = ['January', 'February', 'March', 'April', 'May', 'June',  
     231             'July', 'August', 'September', 'October', 'November', 'December'] 
     232    return names[monthInt-1] 
     233 
     234# -------------------------------------------------------------------------------------------------------------- 
     235# (end of kmlfeatures.py) 
  • DPPP/kml/csml2kml/python/notes.txt

    r3209 r3234  
    1 Notes: 
     1--------------------------------------- 
     2|| Notes: 
    23 
    34* We can infer WMS address from CSML document id & prefix which is static 
     
    1314 
    1415--------------------------------------- 
    15  
    16 Ideas: 
     16|| Ideas: 
    1717 
    1818* [ASK] Would in not be possible to express linkage of a CSML document to a WMS service, 
     
    2424 
    2525--------------------------------------- 
     26|| To do: 
    2627 
    27 Long term issues: 
     28[.] = minor 
     29[o] = should be done but can wait 
     30[O] = to be done straight away 
     31 
     32[As of Rev. 3233] 
     33 
     34* GridFeature-only document: 
     35  * [o] Code: re-write in kmlfeatures (also change in config file). All the occurences of 
     36        "DateTime" should be "TimeStep". 
     37  * [.] Possibly also change config file to even such degree 
     38        that would be a section: 
     39 
     40              <ExtendTimeStepToTimeSpan> 
     41                <StartTransform>...</StartTransform> 
     42                <DurationTransform>...</DurationTransform> 
     43              </ExtendTimeStepToTimeSpan> 
     44 
     45--------------------------------------- 
     46|| Long term issues: 
    2847 
    2948* The way coordinate bounds are specified. Both systems (-180, 180) or (0, 360) have 
  • DPPP/kml/csml2kml/testdata/clim_10.csml2kml.conf.xml

    r3228 r3234  
    1818  <View name="Compare decades"> 
    1919    <SplitTimeStepsBy>year</SplitTimeStepsBy> 
     20    <CategoryNamingPattern>Decade of #VERBATIM#</CategoryNamingPattern> 
    2021    <LogicalDateTimeTransform>FIRST_DAY_OF_MONTH</LogicalDateTimeTransform> 
    2122    <LogicalDateTimeDelta>MONTH_HENCE</LogicalDateTimeDelta> 
     
    2324  <View name="Compare months"> 
    2425    <SplitTimeStepsBy>month</SplitTimeStepsBy> 
     26    <CategoryNamingPattern>#MONTH#</CategoryNamingPattern> 
    2527    <LogicalDateTimeTransform>FIRST_DAY_OF_MONTH</LogicalDateTimeTransform> 
    2628    <LogicalDateTimeDelta>DECADE_HENCE</LogicalDateTimeDelta> 
Note: See TracChangeset for help on using the changeset viewer.