Commit b1648444 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Merge pull request #292 from jlaura/testing

initial stab at postgresql in tests
parents a9ecb65f c9f2ebf8
Loading
Loading
Loading
Loading
+30 −13
Original line number Diff line number Diff line
language: generic  # Since we use conda, just go generic
sudo: false
language: generic
sudo: true

branches:
  only:
    - dev
    - testing

os:
  - linux
  - osx
matrix:
  include:
    - os: linux
      env: PYTHON_VERSION=3.6
    - os: linux
      env: PYTHON_VERSION=3.7
    
env:
  - PYTHON_VERSION=3.5
  - PYTHON_VERSION=3.6
  - PYTHON_VERSION=3.7

# Setup a postgresql instance w/postgis
services:
  - postgresql
addons:
  postgresql: 9.6
  apt:
    packages:
    - postgresql-9.6-postgis-2.4

before_install:
  # Create the template database that is used to instantiate the test DB 
  - psql -c 'create database template_postgis;' -U postgres
  - psql template_postgis -U postgres -c "create extension postgis"
  - psql template_postgis -c "create extension postgis_topology"
  - psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
  - psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
  - psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"

install:
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
@@ -26,6 +44,7 @@ before_install:
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda config --add channels conda-forge
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a
@@ -34,13 +53,11 @@ before_install:
  - source activate test

  # Install dependencies
  - conda config --add channels menpo
  - conda config --add channels usgs-astrogeology
  - conda config --add channels conda-forge
  - conda env update -n test -f environment.yml
  - export PROJ_LIB=$CONDA_PREFIX/share/proj  

script:
  - pytest autocnet tests
  - autocnet_config=config/test_config.yml pytest -v autocnet

after_success:
  - coveralls

README.md

0 → 100644
+29 −0
Original line number Diff line number Diff line
# AutoCNet

[![Gitter Chat](https://badges.gitter.im/USGS-Astrogeology/autocnet.svg)](https://gitter.im/USGS-Astrogeology/autocnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Travis-CI](https://travis-ci.org/USGS-Astrogeology/autocnet.svg?branch=dev)](https://travis-ci.org/USGS-Astrogeology/autocnet)

[![Coveralls](https://coveralls.io/repos/USGS-Astrogeology/autocnet/badge.svg?branch=dev&service=github)](https://coveralls.io/github/USGS-Astrogeology/autocnet?branch=dev)

[![Docs](https://img.shields.io/badge/Docs-latest-green.svg)](https://usgs-astrogeology.github.io/autocnet/)

Automated sparse control network generation to support photogrammetric control of planetary image data.

## Documentation
Is available at: https://usgs-astrogeology.github.io/autocnet/

## Installation Instructions
We suggest using Anaconda Python to install Autocnet within a virtual environment.  These steps will walk you through the process.

1. [Download](https://www.continuum.io/downloads) and install the Python 3.x Miniconda installer.  Respond ``Yes`` when prompted to add conda to your BASH profile.  
2. Install the autocnet environment using the supplied environment.yml file: `conda env create -n autocnet -f environment.yml` 
3. Activate your environment: `conda activate autocnet`
4. If you are doing to develop autocnet or would like to use the bleeding edge version: `python setup.py develop`. Otherwise, `conda install -c usgs-astrogeology` autocnet.

## How to run the test suite locally

1. Install Docker
2. Get the Postgresql with Postgis container and run it `docker run --name testdb -e POSTGRES_PASSOWRD='' -e POSTGRES_USER='postgres' -p 5432:5432 -d mdillon/postgis`
3. create database template_postgis: `docker exec testdb psql -c 'create database template_postgis;' -U postgres`
4. Run the test suite: `autocnet_config=config/test_config.yml pytest autocnet`

README.rst

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
===============================
AutoCNet
===============================

.. image:: https://badges.gitter.im/USGS-Astrogeology/autocnet.svg
   :alt: Join the chat at https://gitter.im/USGS-Astrogeology/autocnet
   :target: https://gitter.im/USGS-Astrogeology/autocnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://img.shields.io/pypi/v/autocnet.svg
        :target: https://pypi.python.org/pypi/autocnet

.. image:: https://travis-ci.org/USGS-Astrogeology/autocnet.svg?branch=master
    :target: https://travis-ci.org/USGS-Astrogeology/autocnet

.. image:: https://coveralls.io/repos/USGS-Astrogeology/autocnet/badge.svg?branch=master&service=github
    :target: https://coveralls.io/github/USGS-Astrogeology/autocnet?branch=master

.. image:: https://img.shields.io/badge/Docs-latest-green.svg
    :target: hhttps://usgs-astrogeology.github.io/autocnet/
    :alt: Documentation Status

.. image:: https://badge.waffle.io/USGS-Astrogeology/autocnet.png?label=ready&title=Ready
 :target: https://waffle.io/USGS-Astrogeology/autocnet
 :alt: 'Stories in Ready'

Automated sparse control network generation to support photogrammetric control of planetary image data.

* Documentation: https://usgs-astrogeology.github.io/autocnet/

Installation Instructions
-------------------------
We suggest using Anaconda Python to install Autocnet within a virtual environment.  These steps will walk you through the process.

#. [Download](https://www.continuum.io/downloads) and install the Python 3.x Miniconda installer.  Respond ``Yes`` when
   prompted to add conda to your BASH profile.  
#. (Optional) We like to sequester applications in their own environments to avoid any dependency conflicts.  To do this:
   
   * ``conda create -n <your_environment_name> python=3 && source activate <your_environment_name>``
   
   Note, that you might want to specify either ``python=3.5`` or ``python=3.6``, depending on your requirements. Both are currently supported by autocnet.
#. Make the newly created environment the active one:

   * ``conda activate <your_environment_name>`` (or ``source activate`` on an older conda system)
   
#. Bring up a command line and add three channels to your conda environment-specific config file:
   
   * ``conda config --env --add channels conda-forge``
   * ``conda config --env --add channels menpo``
   * ``conda config --env --add channels usgs-astrogeology``
#. Finally, install autocnet: ``conda install autocnet``

+2 −2
Original line number Diff line number Diff line
import numpy as np
from autocnet.camera.utils import crossform
import cv2
from cv2 import triangulatePoints



@@ -102,7 +102,7 @@ def triangulate(pt, pt1, p, p1):
    if pt1.shape[0] != 3:
        pt1 = pt1.T

    X = cv2.triangulatePoints(p, p1, pt[:2], pt1[:2])
    X = triangulatePoints(p, p1, pt[:2], pt1[:2])
    X /= X[3] # Homogenize
    return X

+8 −18
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@ from sqlalchemy.types import TypeDecorator
from geoalchemy2 import Geometry
from geoalchemy2.shape import to_shape

from autocnet import engine, Session
from autocnet import engine, Session, config

Base = declarative_base()

srid = config['spatial']['srid']

class JsonEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.ndarray):
@@ -116,7 +118,7 @@ class Keypoints(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    image_id = Column(Integer, ForeignKey("images.id", ondelete="CASCADE"))
    convex_hull_image = Column(Geometry('POLYGON'))
    convex_hull_latlon = Column(Geometry('POLYGON', srid=949900))
    convex_hull_latlon = Column(Geometry('POLYGON', srid=srid))
    path = Column(String)
    nkeypoints = Column(Integer)

@@ -159,7 +161,7 @@ class Matches(Base):
    destination_idx = Column(Integer, nullable=False)
    lat = Column(Float)
    lon = Column(Float)
    geom = Column(Geometry('POINT', dimension=2, srid=949900, spatial_index=True))
    geom = Column(Geometry('POINT', dimension=2, srid=srid, spatial_index=True))
    source_x = Column(Float)
    source_y = Column(Float)
    destination_x = Column(Float)
@@ -184,7 +186,7 @@ class Images(Base):
    path = Column(String)
    serial = Column(String, unique=True)
    active = Column(Boolean)
    footprint_latlon = Column(Geometry('MultiPolygon', srid=949900, dimension=2, spatial_index=True))
    footprint_latlon = Column(Geometry('MultiPolygon', srid=srid, dimension=2, spatial_index=True))
    footprint_bodyfixed = Column(Geometry('MULTIPOLYGON', dimension=2))
    #footprint_bodyfixed = Column(Geometry('POLYGON',dimension=3))

@@ -204,24 +206,12 @@ class Images(Base):
                'footprint_latlon':footprint,
                'footprint_bodyfixed':self.footprint_bodyfixed})

"""class Network(Base):
    __tablename__ = 'network'
    id = Column(Integer, primary_key=True, autoincrement=True)
    #TODO: Document that images on delete will CASCADE into all other tables
    image_id = Column(Integer, ForeignKey("images.id", ondelete="CASCADE"))  # Links back to the source image
    match_id = Column(Integer)
    point_id = Column(String) # User defined point identifier
    keypoint_id = Column(Integer)  # id to link to a keypoint in the correct file
    x = Column(Float)
    y = Column(Float)
    geom = Column(Geometry('POINTZ', dimension=3, srid=949900, spatial_index=True))"""
    
class Overlay(Base):
    __tablename__ = 'overlay'
    id = Column(Integer, primary_key=True, autoincrement=True)
    intersections = Column(ARRAY(Integer))
    #geom = Column(Geometry(geometry_type='POLYGON', management=True))  # sqlite
    geom = Column(Geometry('POLYGON', srid=949900, dimension=2, spatial_index=True))  # postgresql
    geom = Column(Geometry('POLYGON', srid=srid, dimension=2, spatial_index=True))  # postgresql


class PointType(enum.IntEnum):
@@ -237,7 +227,7 @@ class Points(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    pointtype = Column(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(Geometry('POINT', srid=949900, dimension=2, spatial_index=True))
    geom = Column(Geometry('POINT', srid=srid, dimension=2, spatial_index=True))
    active = Column(Boolean, default=True)
    apriorix = Column(Float)
    aprioriy = Column(Float)
Loading