Loading autocnet/cg/cg.py +1 −2 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,5 @@ def get_area(poly1, poly2): of two polygons of two polygons """ """ intersection = poly1.Intersection(poly2) intersection_area = poly1.Intersection(poly2).GetArea() intersection_area = intersection.GetArea() return intersection_area return intersection_area autocnet/graph/edge.py +4 −5 Original line number Original line Diff line number Diff line Loading @@ -382,7 +382,7 @@ class Edge(dict, MutableMapping): def plot(self, ax=None, clean_keys=[], **kwargs): def plot(self, ax=None, clean_keys=[], **kwargs): return plot_edge(self, ax=ax, clean_keys=clean_keys, **kwargs) return plot_edge(self, ax=ax, clean_keys=clean_keys, **kwargs) def _clean(self, clean_keys=[], pid=None): def _clean(self, clean_keys, pid=None): """ """ Given a list of clean keys and a provenance id compute the Given a list of clean keys and a provenance id compute the mask of valid matches mask of valid matches Loading Loading @@ -424,7 +424,7 @@ class Edge(dict, MutableMapping): self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_percn'] = overlapinfo[0] self.weight['overlap_percn'] = overlapinfo[0] def coverage(self): def coverage(self, clean_keys = []): """ """ Acts on the edge given either the source node Acts on the edge given either the source node or the destination node and returns the percentage or the destination node and returns the percentage Loading @@ -442,8 +442,7 @@ class Edge(dict, MutableMapping): if self.matches is None: if self.matches is None: raise AttributeError('Edge needs to have features extracted and matched') raise AttributeError('Edge needs to have features extracted and matched') return return mask = self.masks.all(axis=1) matches, mask = self._clean(clean_keys) matches = self.matches[mask] source_array = self.source.get_keypoint_coordinates(index=matches['source_idx']).values source_array = self.source.get_keypoint_coordinates(index=matches['source_idx']).values source_coords = self.source.geodata.latlon_corners source_coords = self.source.geodata.latlon_corners Loading @@ -452,7 +451,7 @@ class Edge(dict, MutableMapping): convex_hull = cg.convex_hull(source_array) convex_hull = cg.convex_hull(source_array) convex_points = [self.source.geodata.pixel_to_latlon(row[0], row[1]) for row in convex_hull.points[convex_hull.vertices]] convex_points = [self.source.geodata.pixel_to_latlon(row[0], row[1]) for row in convex_hull.points[convex_hull.vertices]] convex_coords = [(i, j) for i, j in convex_points] convex_coords = [(x, y) for x, y in convex_points] source_poly = utils.array_to_poly(source_coords) source_poly = utils.array_to_poly(source_coords) destination_poly = utils.array_to_poly(destination_coords) destination_poly = utils.array_to_poly(destination_coords) Loading autocnet/utils/tests/test_utils.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -129,7 +129,7 @@ class TestUtils(unittest.TestCase): slope = utils.calculate_slope(x1, x2) slope = utils.calculate_slope(x1, x2) self.assertEqual(slope[0], 2) self.assertEqual(slope[0], 2) def test_array_to_geom(self): def test_array_to_poly(self): array1 = np.array([[1, 2], array1 = np.array([[1, 2], [3, 4], [3, 4], [5, 6]]) [5, 6]]) Loading autocnet/utils/utils.py +2 −3 Original line number Original line Diff line number Diff line Loading @@ -329,9 +329,8 @@ def array_to_poly(array): if size[1] != 2: if size[1] != 2: raise ValueError('Array is not the proper size.') raise ValueError('Array is not the proper size.') return return geom_array = np.append(array, [array[0]], axis = 0) geom_array = np.append(array, [array[0]], axis = 0).tolist() geom_list = np.array(geom_array).tolist() geom = {"type": "Polygon", "coordinates": [geom_array]} geom = {"type": "Polygon", "coordinates": [geom_list]} poly = ogr.CreateGeometryFromJson(json.dumps(geom)) poly = ogr.CreateGeometryFromJson(json.dumps(geom)) return poly return poly Loading
autocnet/cg/cg.py +1 −2 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,5 @@ def get_area(poly1, poly2): of two polygons of two polygons """ """ intersection = poly1.Intersection(poly2) intersection_area = poly1.Intersection(poly2).GetArea() intersection_area = intersection.GetArea() return intersection_area return intersection_area
autocnet/graph/edge.py +4 −5 Original line number Original line Diff line number Diff line Loading @@ -382,7 +382,7 @@ class Edge(dict, MutableMapping): def plot(self, ax=None, clean_keys=[], **kwargs): def plot(self, ax=None, clean_keys=[], **kwargs): return plot_edge(self, ax=ax, clean_keys=clean_keys, **kwargs) return plot_edge(self, ax=ax, clean_keys=clean_keys, **kwargs) def _clean(self, clean_keys=[], pid=None): def _clean(self, clean_keys, pid=None): """ """ Given a list of clean keys and a provenance id compute the Given a list of clean keys and a provenance id compute the mask of valid matches mask of valid matches Loading Loading @@ -424,7 +424,7 @@ class Edge(dict, MutableMapping): self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_percn'] = overlapinfo[0] self.weight['overlap_percn'] = overlapinfo[0] def coverage(self): def coverage(self, clean_keys = []): """ """ Acts on the edge given either the source node Acts on the edge given either the source node or the destination node and returns the percentage or the destination node and returns the percentage Loading @@ -442,8 +442,7 @@ class Edge(dict, MutableMapping): if self.matches is None: if self.matches is None: raise AttributeError('Edge needs to have features extracted and matched') raise AttributeError('Edge needs to have features extracted and matched') return return mask = self.masks.all(axis=1) matches, mask = self._clean(clean_keys) matches = self.matches[mask] source_array = self.source.get_keypoint_coordinates(index=matches['source_idx']).values source_array = self.source.get_keypoint_coordinates(index=matches['source_idx']).values source_coords = self.source.geodata.latlon_corners source_coords = self.source.geodata.latlon_corners Loading @@ -452,7 +451,7 @@ class Edge(dict, MutableMapping): convex_hull = cg.convex_hull(source_array) convex_hull = cg.convex_hull(source_array) convex_points = [self.source.geodata.pixel_to_latlon(row[0], row[1]) for row in convex_hull.points[convex_hull.vertices]] convex_points = [self.source.geodata.pixel_to_latlon(row[0], row[1]) for row in convex_hull.points[convex_hull.vertices]] convex_coords = [(i, j) for i, j in convex_points] convex_coords = [(x, y) for x, y in convex_points] source_poly = utils.array_to_poly(source_coords) source_poly = utils.array_to_poly(source_coords) destination_poly = utils.array_to_poly(destination_coords) destination_poly = utils.array_to_poly(destination_coords) Loading
autocnet/utils/tests/test_utils.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -129,7 +129,7 @@ class TestUtils(unittest.TestCase): slope = utils.calculate_slope(x1, x2) slope = utils.calculate_slope(x1, x2) self.assertEqual(slope[0], 2) self.assertEqual(slope[0], 2) def test_array_to_geom(self): def test_array_to_poly(self): array1 = np.array([[1, 2], array1 = np.array([[1, 2], [3, 4], [3, 4], [5, 6]]) [5, 6]]) Loading
autocnet/utils/utils.py +2 −3 Original line number Original line Diff line number Diff line Loading @@ -329,9 +329,8 @@ def array_to_poly(array): if size[1] != 2: if size[1] != 2: raise ValueError('Array is not the proper size.') raise ValueError('Array is not the proper size.') return return geom_array = np.append(array, [array[0]], axis = 0) geom_array = np.append(array, [array[0]], axis = 0).tolist() geom_list = np.array(geom_array).tolist() geom = {"type": "Polygon", "coordinates": [geom_array]} geom = {"type": "Polygon", "coordinates": [geom_list]} poly = ogr.CreateGeometryFromJson(json.dumps(geom)) poly = ogr.CreateGeometryFromJson(json.dumps(geom)) return poly return poly