Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

flesh out some documentation

  • Loading branch information...
commit 969ca4f13629b77fcdaac68ad1f8a9893ce63325 1 parent 9407d8c
Rich Wareham authored
3  src/foldbeam/
@@ -72,6 +72,7 @@ def __init__(self, geometry):
self.geometry = geometry
+ @property
def envelope(self):
"""Calculate the bounding axis-aligned envelope which entirely contains this boundary.
@@ -203,7 +204,7 @@ def transform_to(self, other_spatial_reference, src_seg_len=None, dst_seg_len=No
return boundary_from_envelope(self). \
- transform_to(other_spatial_reference, src_seg_len, dst_seg_len).envelope()
+ transform_to(other_spatial_reference, src_seg_len, dst_seg_len).envelope
def __repr__(self):
return 'Envelope(%f,%f,%f,%f)' % (self.left, self.right,, self.bottom)
41 src/foldbeam/
@@ -99,6 +99,33 @@ class OutputPad(Pad):
A strong reference to this pad's container or :py:const:`None` if the container was not set or has been garbage
+ .. py:data:: damaged
+ A signal which can be connected to to be notified when the contents which can be pulled from this pad have
+ changed. Connect to it by passing a callable to the :py:meth:`damaged.connect` method::
+ def damage_cb(boundary):
+ recalculate_envelope(boundary.envelope)
+ # ... pad is the OutputPad of interest
+ pad.damaged.connect(damage_cb)
+ The callable should accept a single parameter which is a :py:class:`Boundary` specifying the geographic area in
+ which the output has changed. This can be :py:const:`None` in which case it is assumed that the output should
+ always be pulled from.
+ To notify listeners that an :py:class:`OutputPad` had new data, call the :py:attr:`damaged` signal directly::
+ # ... pad is the OutputPad of interest
+ # Notify any listeners that a specific region of the pad has changed:
+ boundary = Boundary(
+ # ...
+ )
+ pad.damaged(boundary)
+ # Notify any listeners that all regions of the pad have changed:
+ pad.damaged(None)
def __init__(self, type_, container, name, pull):
super(OutputPad, self).__init__(type_, container, name)
@@ -108,11 +135,6 @@ def __init__(self, type_, container, name, pull):
def __call__(self, **kwargs):
return self._pull(**kwargs)
- def notify_damage(self, envelope):
- """Push a region which has been invalidated."""
- self.damaged(envelope)
class PadCollection(collections.OrderedDict):
"""A collection of pads which can be iterated over and indexed like a dictionary with the wrinkle that pads are
returned in the order they are added.
@@ -201,8 +223,13 @@ def add_output(self, name, type_, pad_cb):
self.outputs[name] = OutputPad(type_, self, name, pad_cb)
def can_connect(src_pad, dst_pad):
- """Checks if the types of two pads are compatible for connection."""
+ """
+ Checks if the types of two pads are compatible for connection. Currently this simply checks that
+ :py:attr:`src_pad.type` is the same object as :py:attr:`dst_pad.type`. Should a more sophisticated type-munging
+ scheme be added, this function will be updated and so this function should be used in preference to checking the
+ types directly.
+ """
if src_pad is None or dst_pad is None:
return False
6 src/foldbeam/
@@ -251,18 +251,18 @@ def damage_cb(d):
env2 = core.Envelope(0,0,2,2,self.bng_srs)
- e.notify_damage(env1)
+ e.damaged(env1)
self.assertEqual(len(damages), 1)
self.assertEqual(damages[-1], env1)
self.assertNotEqual(damages[-1], env2)
- e.notify_damage(env2)
+ e.damaged(env2)
self.assertEqual(len(damages), 2)
self.assertEqual(damages[-1], env2)
self.assertNotEqual(damages[-1], env1)
- e.notify_damage(env1)
+ e.damaged(env1)
self.assertEqual(len(damages), 2)
self.assertEqual(damages[-1], env2)
self.assertNotEqual(damages[-1], env1)
Please sign in to comment.
Something went wrong with that request. Please try again.