Commit 5a09f394 authored by Jesse Mapel's avatar Jesse Mapel Committed by jlaura
Browse files

Empty footprint (#330)

* Added warning and handling for None footprint

* Removed print

* Added test for null footprint
parent 925ecd57
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -517,7 +517,8 @@ class NetworkNode(Node):
            cam = self.create_camera()
            try:
                fp = self.footprint
            except:
            except Exception as e:
                warnings.warn('Unable to generate image footprint.\n{}'.format(e))
                fp = None
            # Create the image
            i = Images(name=kwargs['image_name'],
+3 −0
Original line number Diff line number Diff line
@@ -226,6 +226,9 @@ class Images(BaseMixin, Base):
        if isinstance(geom, osgeo.ogr.Geometry):
            # If an OGR geom, convert to shapely
            geom = shapely.wkt.loads(geom.ExportToWkt())
        if geom is None:
            self._footprint_latlon = None
        else:
            self._footprint_latlon = from_shape(geom, srid=srid)

class Overlay(BaseMixin, Base):
+5 −0
Original line number Diff line number Diff line
@@ -169,6 +169,11 @@ def test_jigsaw_append(mockFunc, session, measure_data, point_data, image_data):
    assert resp.liner == 0.1
    assert resp.sampler == 0.1

def test_null_footprint(session):
    i = model.Images.create(session, footprint_latlon=None,
                                      serial = 'serial')
    assert i.footprint_latlon is None

def test_broken_bad_geom(session):
    # An irreperablly damaged poly
    geom = MultiPolygon([Polygon([(0,0), (1,1), (1,2), (1,1), (0,0)])])