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

Fully exposes distribution of points in geom (#345)

* Exposes point funcs

* Linspace supports 2D

* Adds docs

* Fixes typos in feature loading

* Fully exposes geom distribution

* updates cluster overlaps and submission

* Updates to use bulk adding

* Closing the session

* Linspace supports 2D

* Adds docs

* Fully exposes geom distribution

* updates cluster overlaps and submission

* Updates to use bulk adding

* Closing the session

* Linspace supports 2D

* Adds docs

* updates cluster overlaps and submission

* Linspace supports 2D

* Adds docs

* Closing the session

* Updates for comments

* removes RMS
parent 447658e7
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ from sqlalchemy.event import listen

from pkg_resources import get_distribution, DistributionNotFound

from plio.io.io_gdal import GeoDataset

try:
    _dist = get_distribution('autocnet')
    # Normalize case for Windows systems
@@ -29,6 +31,16 @@ except:
    warnings.warn('No autocnet_config environment variable set. Defaulting to an en empty configuration.')
    config = {}

if 'dem' in config['spatial']:
    dem = config['spatial']['dem']
    try:
        dem = GeoDataset(dem)
    except:
        warnings.warn(f'Unable to load the dem: {dem}')
        dem = None
else:
    dem = None

try:
    db_uri = '{}://{}:{}@{}:{}/{}'.format(config['database']['type'],
                                            config['database']['username'],
@@ -42,8 +54,13 @@ try:
                    isolation_level="AUTOCOMMIT")                   
    Session = orm.session.sessionmaker(bind=engine)
except: 
    Session = None
    engine = None
    def sessionwarn():
        raise RuntimeError('This call requires a database connection.')
    
    Session = sessionwarn
    engine = sessionwarn



import autocnet.examples
import autocnet.camera
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ def convex_hull(points):
    """

    if isinstance(points, pd.DataFrame) :
        points = pd.DataFrame.as_matrix(points)
        points = pd.DataFrame(points).values

    hull = ConvexHull(points)
    return hull
+1 −0
Original line number Diff line number Diff line
@@ -80,3 +80,4 @@ def test_voronoi_keypoint_intersection(keypoints):
def test_points_in_geom(polygon, nexpected):
    pts = cg.distribute_points_in_geom(polygon)
    assert len(pts) == nexpected
    
+2 −2
Original line number Diff line number Diff line
@@ -450,9 +450,9 @@ class CandidateGraph(nx.Graph):
                of nodes to load features for.  If empty, load features
                for all nodes
        """
        self.apply(Nodes.load_features, args=(in_path, nfeatures), on='node', **kwargs)
        self.apply(Node.load_features, args=(in_path, nfeatures), on='node', **kwargs)
        for n in self.nodes:
            if node['node_id'] not in nodes:
            if n['node_id'] not in nodes:
                continue
            else:
                n.load_features(in_path, **kwargs)
+26 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import json

import numpy as np

import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (Column, String, Integer, Float, \
                        ForeignKey, Boolean, LargeBinary, \
@@ -36,6 +37,13 @@ class BaseMixin(object):
        session.commit()
        return obj

    @staticmethod
    def bulkadd(iterable):
        session = Session()
        session.add_all(iterable)
        session.commit()
        session.close()

class JsonEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.ndarray):
@@ -249,6 +257,24 @@ class Overlay(BaseMixin, Base):
    def geom(self, geom):
        self._geom = from_shape(geom, srid=latitudinal_srid)

    @classmethod
    def overlapping_larger_than(cls, size_threshold):
        """
        Query the Overlay table for an iterable of responses where the objects
        in the iterable have an area greater than a given size.

        Parameters
        ----------
        size_threshold : Number
                        area >= this arg are returned
        """
        session = Session()
        res = session.query(cls).\
                filter(sqlalchemy.func.ST_Area(cls.geom) >= size_threshold).\
                filter(sqlalchemy.func.array_length(cls.intersections, 1) > 1)
        session.close()
        return res

class PointType(enum.IntEnum):
    """
    Enum to enforce point type for ISIS control networks
@@ -267,7 +293,6 @@ class Points(BaseMixin, Base):
    _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))
    measures = relationship('Measures')
    rms = Column(Float)

    @hybrid_property
    def geom(self):
Loading