Commit ccdfe0f7 authored by Adam Paquette's avatar Adam Paquette
Browse files

Fixed merge conflict

parents 52828686 8c73cfc6
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -33,9 +33,8 @@ install:


  # Install the non-conda packages if required, requirements.txt duplicates are ignored
  # Install the non-conda packages if required, requirements.txt duplicates are ignored
  - conda install -c https://conda.anaconda.org/jlaura opencv3=3.0.0
  - conda install -c https://conda.anaconda.org/jlaura opencv3=3.0.0
  - conda install -c https://conda.anaconda.org/jlaura h5py gdal
  - conda config --add channels conda-forge
  - conda install -c osgeo proj4
  - conda install -c https://conda.anaconda.org/conda-forge gdal h5py
  - conda upgrade numpy
  - pip install -r requirements.txt
  - pip install -r requirements.txt
  - pip install coverage
  - pip install coverage
  - pip install coveralls
  - pip install coveralls
+9 −0
Original line number Original line Diff line number Diff line
@@ -22,3 +22,12 @@ def delete_dir(dir):
          Remove a directory
          Remove a directory
    """
    """
    shutil.rmtree(dir)
    shutil.rmtree(dir)


def file_to_list(file):
    with open(file, 'r') as f:
        file_list = f.readlines()
        file_list = map(str.rstrip, file_list)
        file_list = filter(None, file_list)

    return file_list
+22 −13
Original line number Original line Diff line number Diff line
@@ -5,8 +5,10 @@ import dill as pickle
import networkx as nx
import networkx as nx
import numpy as np
import numpy as np
import pandas as pd
import pandas as pd
import warnings


from autocnet.fileio.io_gdal import GeoDataset
from autocnet.fileio.io_gdal import GeoDataset
from autocnet.fileio import io_utils
from autocnet.fileio import io_hdf
from autocnet.fileio import io_hdf
from autocnet.control.control import C
from autocnet.control.control import C
from autocnet.fileio import io_json
from autocnet.fileio import io_json
@@ -107,11 +109,8 @@ class CandidateGraph(nx.Graph):
        : object
        : object
          A Network graph object
          A Network graph object
        """
        """
        if not isinstance(filelist, list):
        if isinstance(filelist, str):
            with open(filelist, 'r') as f:
            filelist = io_utils.file_to_list(filelist)
                filelist = f.readlines()
                filelist = map(str.rstrip, filelist)
                filelist = filter(None, filelist)


        # TODO: Reject unsupported file formats + work with more file formats
        # TODO: Reject unsupported file formats + work with more file formats
        if basepath:
        if basepath:
@@ -121,23 +120,28 @@ class CandidateGraph(nx.Graph):


        # This is brute force for now, could swap to an RTree at some point.
        # This is brute force for now, could swap to an RTree at some point.
        adjacency_dict = {}
        adjacency_dict = {}
        valid_datasets = []


        for i, j in itertools.permutations(datasets,2):
        for i in datasets:
            if not i.file_name in adjacency_dict.keys():
            adjacency_dict[i.file_name] = []
            adjacency_dict[i.file_name] = []
            if not j.file_name in adjacency_dict.keys():

                adjacency_dict[j.file_name] = []
            fp = i.footprint
            if fp and fp.IsValid():
                valid_datasets.append(i)
            else:
                warnings.warn('Missing or invalid geospatial data for {}'.format(i.base_name))


        # Grab the footprints and test for intersection
        # Grab the footprints and test for intersection
        for i, j in itertools.permutations(valid_datasets, 2):
            i_fp = i.footprint
            i_fp = i.footprint
            j_fp = j.footprint
            j_fp = j.footprint


            try:
            try:
                if j_fp and i_fp and i_fp.Intersects(j_fp):
                if i_fp.Intersects(j_fp):
                    adjacency_dict[i.file_name].append(j.file_name)
                    adjacency_dict[i.file_name].append(j.file_name)
                    adjacency_dict[j.file_name].append(i.file_name)
                    adjacency_dict[j.file_name].append(i.file_name)
            except:
            except:
                warnings.warn('No or incorrect geospatial information for {} and/or {}'.format(i, j))
                warnings.warn('Failed to calculated intersection between {} and {}'.format(i, j))


        return cls(adjacency_dict)
        return cls(adjacency_dict)


@@ -300,6 +304,11 @@ class CandidateGraph(nx.Graph):
            descriptors = node.descriptors
            descriptors = node.descriptors
            # Load the neighbors of the current node into the FLANN matcher
            # Load the neighbors of the current node into the FLANN matcher
            neighbors = self.neighbors(i)
            neighbors = self.neighbors(i)

            # if node has no neighbors, skip
            if not neighbors:
                continue

            for n in neighbors:
            for n in neighbors:
                neighbor_descriptors = self.node[n].descriptors
                neighbor_descriptors = self.node[n].descriptors
                self._fl.add(neighbor_descriptors, n)
                self._fl.add(neighbor_descriptors, n)
+22 −0
Original line number Original line Diff line number Diff line
@@ -4,9 +4,16 @@ sys.path.insert(0, os.path.abspath('..'))


import unittest
import unittest


from unittest.mock import patch
from unittest.mock import PropertyMock
from unittest.mock import MagicMock
from osgeo import ogr
import gdal

import numpy as np
import numpy as np


from autocnet.examples import get_path
from autocnet.examples import get_path
from autocnet.fileio import io_gdal


from .. import network
from .. import network


@@ -100,6 +107,21 @@ class TestCandidateGraph(unittest.TestCase):
    def test_fromlist(self):
    def test_fromlist(self):
        mock_list = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png', 'AS15-M-0297_SML.png',
        mock_list = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png', 'AS15-M-0297_SML.png',
                     'AS15-M-0298_SML.png', 'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png']
                     'AS15-M-0298_SML.png', 'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png']

        good_poly = ogr.CreateGeometryFromWkt('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')
        bad_poly = ogr.CreateGeometryFromWkt('POLYGON ((9999 10, 40 40, 20 40, 10 20, 30 10))')

        with patch('autocnet.fileio.io_gdal.GeoDataset.footprint', new_callable=PropertyMock) as patch_fp:
            patch_fp.return_value = good_poly
            n = network.CandidateGraph.from_filelist(mock_list, get_path('Apollo15'))
            self.assertEqual(n.number_of_nodes(), 6)
            self.assertEqual(n.number_of_edges(), 15)

            patch_fp.return_value = bad_poly
            n = network.CandidateGraph.from_filelist(mock_list, get_path('Apollo15'))
            self.assertEqual(n.number_of_nodes(), 6)
            self.assertEqual(n.number_of_edges(), 0)

        n = network.CandidateGraph.from_filelist(mock_list, get_path('Apollo15'))
        n = network.CandidateGraph.from_filelist(mock_list, get_path('Apollo15'))
        self.assertEqual(len(n.nodes()), 6)
        self.assertEqual(len(n.nodes()), 6)


+1 −1
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@ def plot_node(node, ax=None, clean_keys=[], **kwargs):
    keypoints = node.get_keypoints()
    keypoints = node.get_keypoints()
    if clean_keys:
    if clean_keys:
        matches, mask = node._clean(clean_keys)
        matches, mask = node._clean(clean_keys)
        keypoints = node.keypoints[mask]
        keypoints = node.get_keypoints()[mask]


    marker = '.'
    marker = '.'
    if 'marker' in kwargs.keys():
    if 'marker' in kwargs.keys():