Changeset 3290 for DPPP/kml


Ignore:
Timestamp:
30/01/08 16:41:28 (12 years ago)
Author:
mkochan
Message:

Added KMLRegion and KMLFolder in the KMLDocument module

Location:
DPPP/kml/csml2kml/python
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/notes.txt

    r3234 r3290  
    1 --------------------------------------- 
    2 || Notes: 
     1[.] minor issue 
     2[o] important but can wait 
     3[O] current/urgent 
    34 
    4 * We can infer WMS address from CSML document id & prefix which is static 
    5   (the address of the concrete WMS service; not part of the CSML document). 
    6 * Layer names also are dataset specific; not part of the CSML document. 
    7 * For GridSeriesFeature, in the timeframe of the project, there will be no TimeBounds, 
    8   only TimeSteps encoding timebounds. That is because: 
    9   * the data will be only climate data 
    10   * Andrew Wolfe is still adding TimeBounds into CSML (and will keep doing so 
    11     during the duration of the project) 
     5---------------------------------------------------------------------------------------------------------------------------- 
    126 
    13 # http://ndgbeta.badc.rl.ac.uk/wms/badc.nerc.ac.uk__NDG-A0__AWQX8gTc?    
    14  
    15 --------------------------------------- 
    16 || Ideas: 
    17  
    18 * [ASK] Would in not be possible to express linkage of a CSML document to a WMS service, 
    19         using the FeatureDescriptor construct? That would make existence of a config file 
    20         unneccessary. 
    21         - No, because CSML file should not be linked to any WMS service (they change a lot, 
    22           even within BADC). It would make CSML "not what it's supposed to be". 
    23 * CSML does not require a specific CRS, but for portals it's gonna be "WGS" (world geodetic system). 
    24  
    25 --------------------------------------- 
    26 || To do: 
    27  
    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: 
    47  
    48 * The way coordinate bounds are specified. Both systems (-180, 180) or (0, 360) have 
    49   a problem with singularity, which WMS cannot account for. We cannot a map returned which 
    50   has the west coordinate higher than the east coordinate -- the server will not return a 
    51   map spanning the singularity. Hence we probably need to do 2 calls to WMS by using two 
    52   regions in KML on the map. 
     7[o] Resolve outstanding issues in pylons controllers 
     8[O] Make quadrize_stations.py work with the KMLDocument module -- by wrapping the functionality for creating 
     9    quad-tree representation of a list of placemarks/stations into the KMLDocument 
     10    * test the new KMLDocument classes 
     11    * make quadrize_stations.py use KMLDocument for all KML generation 
     12     
  • DPPP/kml/csml2kml/python/prototypes/KMLDocument.py

    r3289 r3290  
    5151        f.close() 
    5252 
    53 class KMLStyle: 
     53# Abstract class 
     54class KMLElement: 
     55    def build(self): 
     56        raise NotImplementedError("Abstract method, to be overriden by child classes") 
     57 
     58class KMLStyle(KMLElement): 
    5459 
    5560    def __init__(self, id, iconURL, balloonTemplate): 
     
    7984    return KMLStyle('basic_style', basicIcon, basicBalloonTemplate) 
    8085 
    81 class KMLPlacemark: 
     86class KMLPlacemark(KMLElement): 
    8287     
    8388    def __init__(self, id, name, lon, lat, style='basic_style', data=None): 
     
    119124 
    120125        return placemarkElement 
     126 
     127class KMLFolder(KMLElement): 
     128 
     129    def __init__(self, name, children): 
     130        self.name = name 
     131        self.children = children 
     132         
     133    def build(self): 
     134        folderElement = Element('Folder') 
     135        SubElement(folderElement, 'name').text = name 
     136        for child in children: 
     137            if not isinstance(child, KMLElement): 
     138                raise TypeError('KMLFolder child does not have a KMLElement base class') 
     139            folderElement.append( child.build() ) 
     140        return folderElement 
     141 
     142class KMLRegion(KMLElement): 
     143     
     144    def __init__(self, west, south, east, north, minLodPixels = 64, maxLodPixels = -1): 
     145        self.west = west 
     146        self.south = south 
     147        self.east = east 
     148        self.north = north 
     149        self.minLodPixels = minLodPixel 
     150        self.maxLodPixels = maxLodPixel 
     151 
     152    def build(self): 
     153 
     154        llabElement = Element('LatLonAltBox') 
     155        SubElement(llabElement, 'west').text = self.west 
     156        SubElement(llabElement, 'south').text = self.south 
     157        SubElement(llabElement, 'east').text = self.east 
     158        SubElement(llabElement, 'north').text = self.north 
     159 
     160        lodElement = Element('Lod') 
     161        SubElement(lodElement, 'minLodPixels').text = self.minLodPixels 
     162        SubElement(lodElement, 'maxLodPixels').text = self.maxLodPixels 
     163 
     164        regionElement = Element('Region') 
     165        regionElement.append(llabElement) 
     166        regionElement.append(lodElement) 
     167        return regionElement 
  • DPPP/kml/csml2kml/python/prototypes/quadrize_stations_use_KMLDocument.py

    r3260 r3290  
    11''' 
    2 Prototype for producing KML documents containing a quad-tree like <Folder> structure containing locations 
     2[CHANGE]("Prototype") for producing KML documents containing a quad-tree like <Folder> structure containing locations 
    33in an effective way. See description of the build_quadtree() function to see what a "quad-tree" is. 
    44''' 
     
    66from random import random 
    77from cElementTree import ElementTree, Element, SubElement 
     8from KMLDocument import * 
    89 
    910class Location: 
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py

    r3281 r3290  
    9696            response.content = buf.getvalue() 
    9797             
    98         def wget(url): 
     98        def _wget(url): 
    9999            content = None 
    100100            try: 
     
    124124        # Get response from GeoServer and parse it into an ElementTree 
    125125        geoServerURL = 'http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=' + gml_id 
    126         geoSrResponse = wget(geoServerURL) 
     126        geoSrResponse = _wget(geoServerURL) 
    127127        tree = ElementTree(XML(geoSrResponse)) 
    128128 
Note: See TracChangeset for help on using the changeset viewer.