Commit 205ef66e authored by jlaura's avatar jlaura Committed by Kelvin Rodriguez
Browse files

updates to fundamental matrix (#354)

* updates to fundamental

* Removes unused session
parent d441655a
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -750,11 +750,12 @@ class NetworkEdge(Edge):

    @property
    def masks(self):
        res = Session().query(Edges.masks).\
        session = Session()
        res = session.query(Edges.masks).\
                                        filter(Edges.source == self.source['node_id']).\
                                        filter(Edges.destination == self.destination['node_id']).\
                                        first()

        session.close()
        try:
            df = pd.DataFrame.from_records(res[0])
            df.index = df.index.map(int)
@@ -789,14 +790,16 @@ class NetworkEdge(Edge):
            res.masks = as_dict
            session.add(res)
            session.commit()
        session.close()

    @property
    def costs(self):
        # these are np.float coming out, sqlalchemy needs ints
        ids = list(map(int, self.matches.index.values))
        res = Session().query(Costs).filter(Costs.match_id.in_(ids)).all()
        session = Session()
        res = session.query(Costs).filter(Costs.match_id.in_(ids)).all()
        #qf = q.filter(Costs.match_id.in_(ids))

        session.close()
        if res:
        # Parse the JSON dicts in the cost field into a full dimension dataframe
            costs = {r.match_id:r._cost for r in res}
@@ -843,6 +846,7 @@ class NetworkEdge(Edge):
        if to_db_add:
            session.bulk_save_objects(to_db_add)
        session.commit()
        session.close()

    @property
    def matches(self):
@@ -907,6 +911,7 @@ class NetworkEdge(Edge):
        if to_db_update:
            session.bulk_update_mappings(Matches, to_db_update)
        session.commit()
        session.close()

    @matches.deleter
    def matches(self):
@@ -939,6 +944,7 @@ class NetworkEdge(Edge):
                         ring=ring)
            session.add(edge)
            session.commit()
        session.close()
        return

    @property
@@ -969,6 +975,7 @@ class NetworkEdge(Edge):
                         fundamental = v)
            session.add(edge)
        session.commit()
        session.close()

    def get_overlapping_indices(self, kps):
        ecef = pyproj.Proj(proj='geocent',
@@ -984,7 +991,10 @@ class NetworkEdge(Edge):

    @property
    def measures(self):
        return Session().query(Measures).filter(sqlalchemy.or_(Measures.imageid == self.source['node_id'], Measures.imageid == self.destination['node_id'])).all()
        session = Session()
        res = session.query(Measures).filter(sqlalchemy.or_(Measures.imageid == self.source['node_id'], Measures.imageid == self.destination['node_id'])).all()
        session.close()
        return res

    def network_to_matches(self, active_point=True, active_measure=True, rejected_jigsaw=False):
        """
@@ -1012,7 +1022,8 @@ class NetworkEdge(Edge):
        if source > destin:
            source, destin = destin, source

        q = Session().query(Points.id,
        session = Session()
        q = session.query(Points.id,
                  Points.pointtype,
                  Measures.id.label('mid'),
                  Measures.sample,
@@ -1031,6 +1042,7 @@ class NetworkEdge(Edge):
               'lat', 'lon', 'geom', 'source_x', 'source_y', 'destination_x',
               'destination_y', 'shift_x', 'shift_y', 'original_destination_x',
               'original_destination_y']
        session.close()

        def net2matches(grp, matches, source, destin):
            # Grab the image ids and then get the cartesian product of the ids to know which
@@ -1081,5 +1093,5 @@ class NetworkEdge(Edge):
            # necessarily bad in all of the other images. Doing it this way assumes that it is...
            bad[o.source_measure_id] = 1
            bad[o.destin_measure_id] = 1

        session.close()
        return Counter(bad)
+13 −4
Original line number Diff line number Diff line
@@ -508,6 +508,7 @@ class NetworkNode(Node):

        # For now, just use the PATH to determine if the node/image is in the DB
        res = session.query(Images).filter(Images.path == kwargs['image_path']).first()
        session.close()
        if res is None:
            kpspath = io_keypoints.create_output_path(self.geodata.file_name)

@@ -580,6 +581,7 @@ class NetworkNode(Node):
            res = self._from_db(Keypoints)
        res.nkeypoints = len(kps)
        session.commit()
        session.close()

    @property
    def descriptors(self):
@@ -647,7 +649,9 @@ class NetworkNode(Node):

    @property
    def footprint(self):
        res = Session().query(Images).filter(Images.id == self['node_id']).first()
        session = Session()
        res = session.query(Images).filter(Images.id == self['node_id']).first()
        session.close()
        # not in database, create footprint
        if res is None:
            # get ISIS footprint if possible
@@ -673,13 +677,18 @@ class NetworkNode(Node):

    @property
    def points(self):
        pids = Session().query(Measures.pointid).filter(Measures.imageid == self['node_id']).all()
        res = Session().query(Points).filter(Points.id.in_(pids)).all()
        session = Session()
        pids = session.query(Measures.pointid).filter(Measures.imageid == self['node_id']).all()
        res = session.query(Points).filter(Points.id.in_(pids)).all()
        session.close()
        return res

    @property
    def measures(self):
        return Session().query(Measures).filter(Measures.imageid == self['node_id']).all()
        session = Session()
        res = session.query(Measures).filter(Measures.imageid == self['node_id']).all()
        session.close()
        return res

    def generate_vrt(self, **kwargs):
        """
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ import sys
from redis import StrictRedis
import yaml

from autocnet.io.db import connection
from autocnet.io.db.redis_queue import pop_computetime_push, finalize
from autocnet.graph.node import NetworkNode
from autocnet.graph.edge import NetworkEdge