Changeset 3256 for DPPP


Ignore:
Timestamp:
22/01/08 13:40:16 (12 years ago)
Author:
mkochan
Message:

Changed quadrize_stations.py to return LocLeaf? with locations rather than Tree (Tree should contain only children of type Tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/prototypes/quadrize_stations.py

    r3255 r3256  
    55 
    66class Leaf(Tree): 
     7    pass 
     8 
     9class NilLeaf(Leaf): 
    710    def __repr__(self): 
    811        return 'nil' 
    912 
     13class LocLeaf(Leaf): 
     14    def __init__(self, locations): 
     15        if not locations: 
     16            raise ValueError('Empty location list passed') 
     17        self.locations = locations 
     18    def __repr__(self): 
     19        s = '' 
     20        for loc in self.locations: s = s + repr(loc) + ',' 
     21        return '[' + s + ']' 
     22 
    1023class Node(Tree): 
    11     def __init__(self, children_tuple): 
    12         if not children_tuple: 
     24    def __init__(self, children): 
     25        if not children: 
    1326            raise ValueError('Empty child list passed') 
    14         self.children = children_tuple 
     27        self.children = children 
    1528    def __repr__(self): 
    1629        s = '' 
     
    4255    if len(l) == 0: 
    4356        #!print 'Nothing.' 
    44         return Leaf() 
     57        return NilLeaf() 
    4558    elif len(l) <= max_per_region: 
    4659        #!print 'Locations: ' + repr(l) 
    47         return Node(l) 
     60        return LocLeaf(l) 
    4861    else: 
    4962        (l1, l2, l3, l4) = ([], [], [], []) 
Note: See TracChangeset for help on using the changeset viewer.