compute_regions.py

changeset 2
7378b802ddf8
parent 1
f9788970fa46
equal deleted inserted replaced
1:f9788970fa46 2:7378b802ddf8
47 blockmap = Blockmap() 47 blockmap = Blockmap()
48 for region in regions.values(): 48 for region in regions.values():
49 # Minor shapes contain major shapes, so just use those 49 # Minor shapes contain major shapes, so just use those
50 for shape in (region['minor_shapes'] or region['major_shapes']): 50 for shape in (region['minor_shapes'] or region['major_shapes']):
51 for block in blocks_in_shape(blockmap, shape): 51 for block in blocks_in_shape(blockmap, shape):
52 set.add(block, region['name']) 52 set.add(block, region['ref'])
53 return blockmap 53 return blockmap
54 54
55 def get_args(): 55 def get_args():
56 from argparse import ArgumentParser 56 from argparse import ArgumentParser
57 parser = ArgumentParser() 57 parser = ArgumentParser()
72 region_class = repr(self.region_class), 72 region_class = repr(self.region_class),
73 ) 73 )
74 74
75 def locate_regionally(position, region): 75 def locate_regionally(position, region):
76 if test_shapes(region['major_shapes'], position): 76 if test_shapes(region['major_shapes'], position):
77 return RegionalLocation(region = region['name'], region_class = 'major') 77 return RegionalLocation(region = region['ref'], region_class = 'major')
78 elif test_shapes(region['minor_shapes'], position): 78 elif test_shapes(region['minor_shapes'], position):
79 return RegionalLocation(region = region['name'], region_class = 'minor') 79 return RegionalLocation(region = region['ref'], region_class = 'minor')
80 else: 80 else:
81 return None 81 return None
82 82
83 def find_region_for_point(position, regions, blockmap): 83 def find_region_for_point(position, regions, blockmap):
84 for region_name in blockmap[blockmap.blockpoint(position)]: 84 for region_name in blockmap[blockmap.blockpoint(position)]:

mercurial