Commit b6e74352 authored by Adam Paquette's avatar Adam Paquette
Browse files

implimented new method overlap in edge to calculate the area overlaped and the...

implimented new method overlap in edge to calculate the area overlaped and the percentage of the area being overlaped
parent e9dff884
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ class Edge(dict, MutableMapping):
                 With key equal to an autoincrementing integer and value
                 equal to a dict of parameters used to generate this
                 realization.

    weight : dict
             Dictionary with two keys overlap_area, and overlap_percn
             overlap_area returns the area overlaped by both images
             overlap_percn retuns the total percentage of overlap
    """

    def __init__(self, source=None, destination=None):
@@ -41,6 +46,8 @@ class Edge(dict, MutableMapping):
        self.fundamental_matrix = None
        self._subpixel_offsets = None

        self.weight = {}

        self._observers = set()

        # Subscribe the heatlh observer
@@ -80,6 +87,21 @@ class Edge(dict, MutableMapping):
    def health(self):
        return self._health.health

    def overlap(self):
        if hasattr(self, 'weight'):
            poly1 = self.source.geodata.footprint
            poly2 = self.destination.geodata.footprint

            intersection = poly1.Intersection(poly2)
            self._overlap_area = intersection.GetArea()

            total_area = poly1.GetArea()
            intersection_area = intersection.GetArea()
            self._overlap_percn = (intersection_area/total_area)*100

            self.weight['overlap_area'] = self._overlap_area
            self.weight['overlap_percn'] = self._overlap_percn

    def symmetry_check(self):
        if hasattr(self, 'matches'):
            mask = od.mirroring_test(self.matches)