Commit 89354eb1 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by GitHub
Browse files

Merge pull request #385 from ladoramkershner/population

leaky session fix, populating new columns in DB
parents 82a9f743 0efe7851
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1570,9 +1570,11 @@ WHERE points.active = True AND measures.active=TRUE AND measures.jigreject=FALSE
        if clear_db:
            cls.clear_db()

        for f in filelist:
        total=len(filelist)
        for cnt, f in enumerate(filelist):
            # Create the nodes in the graph. Really, this is creating the
            # images in the DB
            print('loading {} of {}'.format(cnt+1, total))
            image_name = os.path.basename(f)
            NetworkNode(image_path=f, image_name=image_name)

+8 −4
Original line number Diff line number Diff line
@@ -516,7 +516,8 @@ class NetworkNode(Node):
            kps = Keypoints(path=kpspath, nkeypoints=0)
            cam = self.create_camera()
            try:
                fp = self.footprint
                fp, cam_type = self.footprint

            except Exception as e:
                warnings.warn('Unable to generate image footprint.\n{}'.format(e))
                fp = None
@@ -526,7 +527,8 @@ class NetworkNode(Node):
                       footprint_latlon=fp,
                       keypoints=kps,
                       cameras=cam,
                       serial=self.isis_serial)
                       serial=self.isis_serial,
                       cam_type=cam_type)
            session = Session()
            session.add(i)
            session.commit()
@@ -657,7 +659,8 @@ class NetworkNode(Node):
            # get ISIS footprint if possible
            if utils.find_in_dict(self.geodata.metadata, "Polygon"):
                footprint_latlon =  shapely.wkt.loads(self.geodata.footprint.ExportToWkt())
                return footprint_latlon
                cam_type = 'isis'
                return footprint_latlon, cam_type
            # Get CSM footprint
            else:
                boundary = generate_boundary(self.geodata.raster_size[::-1])  # yx to xy
@@ -669,7 +672,8 @@ class NetworkNode(Node):

                footprint_latlon = generate_latlon_footprint(self.camera, boundary, dem=geodata)
                footprint_latlon.FlattenTo2D()
                return footprint_latlon
                cam_type = 'csm'
                return footprint_latlon, cam_type
        else:
            # in database, return footprint
            footprint_latlon = res.footprint_latlon
+3 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ class Cameras(BaseMixin, Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    image_id = Column(Integer, ForeignKey("images.id", ondelete="CASCADE"), unique=True)
    camera = Column(Json())
    camtype = Column(String)

class Images(BaseMixin, Base):
    __tablename__ = 'images'
@@ -189,6 +190,7 @@ class Images(BaseMixin, Base):
    active = Column(Boolean, default=True)
    _footprint_latlon = Column("footprint_latlon", Geometry('MultiPolygon', srid=latitudinal_srid, dimension=2, spatial_index=True))
    footprint_bodyfixed = Column(Geometry('MULTIPOLYGON', dimension=2))
    cam_type = Column(String)
    #footprint_bodyfixed = Column(Geometry('POLYGON',dimension=3))

    # Relationships
@@ -273,6 +275,7 @@ class Points(BaseMixin, Base):
    _pointtype = Column("pointtype", IntEnum(PointType), nullable=False)  # 2, 3, 4 - Could be an enum in the future, map str to int in a decorator
    identifier = Column(String, unique=True)
    _geom = Column("geom", Geometry('POINT', srid=latitudinal_srid, dimension=2, spatial_index=True))
    cam_type = Column(String)
    active = Column(Boolean, default=True)
    _apriori = Column("apriori", Geometry('POINTZ', srid=rectangular_srid, dimension=3, spatial_index=False))
    _adjusted = Column("adjusted", Geometry('POINTZ', srid=rectangular_srid, dimension=3, spatial_index=False))
+1 −3
Original line number Diff line number Diff line
@@ -410,7 +410,6 @@ def subpixel_register_point(pointid, iterative_phase_kwargs={}, subpixel_templat
    source_node = NetworkNode(node_id=sourceid, image_path=res.path)

    for measure in measures[1:]:
        active = True
        cost = None
        destinationid = measure.imageid

@@ -447,7 +446,6 @@ def subpixel_register_point(pointid, iterative_phase_kwargs={}, subpixel_templat
            continue

        # Update the measure
        measure.active = active
        if new_template_x:
            measure.sample = new_template_x
            measure.line = new_template_y
@@ -485,7 +483,7 @@ def subpixel_register_points(iterative_phase_kwargs={'size': 251},
    """
    session = Session()
    pointids = [point.id for point in session.query(Points)]
    sessoin.close()
    session.close()
    for pointid in pointids:
        subpixel_register_point(pointid,
                                iterative_phase_kwargs=iterative_phase_kwargs,
+4 −1
Original line number Diff line number Diff line
@@ -172,7 +172,8 @@ def place_points_in_overlap(nodes, geom, cam_type="csm",
        geom = shapely.geometry.Point(x, y, z)
        point = Points(apriori=geom,
                       adjusted=geom,
                       pointtype=2) # Would be 3 or 4 for ground
                       pointtype=2, # Would be 3 or 4 for ground
                       cam_type=cam_type)

        gnd = csmapi.EcefCoord(x, y, z)
        for node in nodes:
@@ -184,6 +185,8 @@ def place_points_in_overlap(nodes, geom, cam_type="csm",

            point.measures.append(Measures(sample=sample,
                                           line=line,
                                           apriorisample=sample,
                                           aprioriline=line,
                                           imageid=node['node_id'],
                                           serial=node.isis_serial,
                                           measuretype=3))