Loading autocnet/spatial/overlap.py +11 −12 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ def place_points_in_overlaps(cg, size_threshold=0.0007, overlaps = o.intersections if overlaps == None: continue nodes = [cg.node[id] for id in overlaps] nodes = [cg.node[id]['data'] for id in overlaps] points.extend(place_points_in_overlap(nodes, o.geom, dem=gd, iterative_phase_kwargs=iterative_phase_kwargs)) Loading Loading @@ -151,7 +151,7 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", Parameters ---------- nodes : list of Nodes The CandidateGraph nodes of all the images that intersect the overlap The Nodes or Networknodes of all the images that intersect the overlap geom : geometry The geometry of the overlap region Loading Loading @@ -191,7 +191,6 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", # Grab the source image. This is just the node with the lowest ID, nothing smart. source = nodes[0] nodes.remove(source) source_camera = source["data"].camera for v in valid: lon = v[0] lat = v[1] Loading @@ -211,33 +210,33 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", if cam_type == "csm": gnd = csmapi.EcefCoord(x, y, z) sic = source_camera.groundToImage(gnd) sic = source.camera.groundToImage(gnd) ssample, sline = sic.samp, sic.line if cam_type == "isis": sline, ssample = isis.ground_to_image(source["data"]["image_path"], lat ,lon) sline, ssample = isis.ground_to_image(source["image_path"], lat ,lon) point.measures.append(Measures(sample=ssample, line=sline, imageid=source['data']['node_id'], serial=source['data'].isis_serial, imageid=source['node_id'], serial=source.isis_serial, measuretype=3)) for i, dest in enumerate(nodes): if cam_type == "csm": dic = dest['data'].camera.groundToImage(gnd) dic = dest.camera.groundToImage(gnd) dline, dsample = dic.line, dic.samp if cam_type == "isis": dline, dsample = isis.groud_to_image(dest["data"]["image_path"], lat, lon) dline, dsample = isis.groud_to_image(dest["image_path"], lat, lon) dx, dy, _ = iterative_phase(ssample, sline, dsample, dline, source['data'].geodata, dest['data'].geodata, source.geodata, dest.geodata, **iterative_phase_kwargs) if dx is not None or dy is not None: point.measures.append(Measures(sample=dx, line=dy, imageid=dest['data']['node_id'], serial=dest['data'].isis_serial, imageid=dest['node_id'], serial=dest.isis_serial, measuretype=3)) if len(point.measures) >= 2: points.append(point) Loading autocnet/spatial/tests/test_overlap_points.py +27 −27 Original line number Diff line number Diff line Loading @@ -8,26 +8,26 @@ import csmapi @patch('autocnet.cg.cg.distribute_points_in_geom', return_value=[(0, 0), (5, 5), (10, 10)]) def test_place_points_in_overlap(point_distributer, phase_matcher): # Mock setup first_node = {'data':MagicMock()} first_node['data'].camera = MagicMock() first_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 0.0) first_node['data'].isis_serial = '1' first_node['data'].__getitem__.return_value = 1 second_node = {'data':MagicMock()} second_node['data'].camera = MagicMock() second_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 1.0) second_node['data'].isis_serial = '2' second_node['data'].__getitem__.return_value = 2 third_node = {'data':MagicMock()} third_node['data'].camera = MagicMock() third_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 1.0) third_node['data'].isis_serial = '3' third_node['data'].__getitem__.return_value = 3 fourth_node = {'data':MagicMock()} fourth_node['data'].camera = MagicMock() fourth_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 0.0) fourth_node['data'].isis_serial = '4' fourth_node['data'].__getitem__.return_value = 4 first_node = MagicMock() first_node.camera = MagicMock() first_node.camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 0.0) first_node.isis_serial = '1' first_node.__getitem__.return_value = 1 second_node = MagicMock() second_node.camera = MagicMock() second_node.camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 1.0) second_node.isis_serial = '2' second_node.__getitem__.return_value = 2 third_node = MagicMock() third_node.camera = MagicMock() third_node.camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 1.0) third_node.isis_serial = '3' third_node.__getitem__.return_value = 3 fourth_node = MagicMock() fourth_node.camera = MagicMock() fourth_node.camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 0.0) fourth_node.isis_serial = '4' fourth_node.__getitem__.return_value = 4 dem = MagicMock() dem.latlon_to_pixel.return_value = (1.0, 1.0) dem.read_array.return_value = [[0.0]] Loading @@ -48,13 +48,13 @@ def test_place_points_in_overlap(point_distributer, phase_matcher): point_distributer.assert_called_with(Polygon([(0, 0), (0, 10), (10, 10), (10, 0)])) dem.latlon_to_pixel.assert_called() dem.read_array.assert_called() first_node['data'].camera.groundToImage.assert_called() second_node['data'].camera.groundToImage.assert_called() third_node['data'].camera.groundToImage.assert_called() fourth_node['data'].camera.groundToImage.assert_called() first_node.camera.groundToImage.assert_called() second_node.camera.groundToImage.assert_called() third_node.camera.groundToImage.assert_called() fourth_node.camera.groundToImage.assert_called() phase_matcher.assert_any_call(0.0, 1.0, 1.0, 1.0, first_node['data'].geodata, second_node['data'].geodata, size=71) first_node.geodata, second_node.geodata, size=71) phase_matcher.assert_any_call(0.0, 1.0, 1.0, 0.0, first_node['data'].geodata, third_node['data'].geodata, size=71) first_node.geodata, third_node.geodata, size=71) phase_matcher.assert_any_call(0.0, 1.0, 0.0, 0.0, first_node['data'].geodata, fourth_node['data'].geodata, size=71) first_node.geodata, fourth_node.geodata, size=71) Loading
autocnet/spatial/overlap.py +11 −12 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ def place_points_in_overlaps(cg, size_threshold=0.0007, overlaps = o.intersections if overlaps == None: continue nodes = [cg.node[id] for id in overlaps] nodes = [cg.node[id]['data'] for id in overlaps] points.extend(place_points_in_overlap(nodes, o.geom, dem=gd, iterative_phase_kwargs=iterative_phase_kwargs)) Loading Loading @@ -151,7 +151,7 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", Parameters ---------- nodes : list of Nodes The CandidateGraph nodes of all the images that intersect the overlap The Nodes or Networknodes of all the images that intersect the overlap geom : geometry The geometry of the overlap region Loading Loading @@ -191,7 +191,6 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", # Grab the source image. This is just the node with the lowest ID, nothing smart. source = nodes[0] nodes.remove(source) source_camera = source["data"].camera for v in valid: lon = v[0] lat = v[1] Loading @@ -211,33 +210,33 @@ def place_points_in_overlap(nodes, geom, dem=None, cam_type="csm", if cam_type == "csm": gnd = csmapi.EcefCoord(x, y, z) sic = source_camera.groundToImage(gnd) sic = source.camera.groundToImage(gnd) ssample, sline = sic.samp, sic.line if cam_type == "isis": sline, ssample = isis.ground_to_image(source["data"]["image_path"], lat ,lon) sline, ssample = isis.ground_to_image(source["image_path"], lat ,lon) point.measures.append(Measures(sample=ssample, line=sline, imageid=source['data']['node_id'], serial=source['data'].isis_serial, imageid=source['node_id'], serial=source.isis_serial, measuretype=3)) for i, dest in enumerate(nodes): if cam_type == "csm": dic = dest['data'].camera.groundToImage(gnd) dic = dest.camera.groundToImage(gnd) dline, dsample = dic.line, dic.samp if cam_type == "isis": dline, dsample = isis.groud_to_image(dest["data"]["image_path"], lat, lon) dline, dsample = isis.groud_to_image(dest["image_path"], lat, lon) dx, dy, _ = iterative_phase(ssample, sline, dsample, dline, source['data'].geodata, dest['data'].geodata, source.geodata, dest.geodata, **iterative_phase_kwargs) if dx is not None or dy is not None: point.measures.append(Measures(sample=dx, line=dy, imageid=dest['data']['node_id'], serial=dest['data'].isis_serial, imageid=dest['node_id'], serial=dest.isis_serial, measuretype=3)) if len(point.measures) >= 2: points.append(point) Loading
autocnet/spatial/tests/test_overlap_points.py +27 −27 Original line number Diff line number Diff line Loading @@ -8,26 +8,26 @@ import csmapi @patch('autocnet.cg.cg.distribute_points_in_geom', return_value=[(0, 0), (5, 5), (10, 10)]) def test_place_points_in_overlap(point_distributer, phase_matcher): # Mock setup first_node = {'data':MagicMock()} first_node['data'].camera = MagicMock() first_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 0.0) first_node['data'].isis_serial = '1' first_node['data'].__getitem__.return_value = 1 second_node = {'data':MagicMock()} second_node['data'].camera = MagicMock() second_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 1.0) second_node['data'].isis_serial = '2' second_node['data'].__getitem__.return_value = 2 third_node = {'data':MagicMock()} third_node['data'].camera = MagicMock() third_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 1.0) third_node['data'].isis_serial = '3' third_node['data'].__getitem__.return_value = 3 fourth_node = {'data':MagicMock()} fourth_node['data'].camera = MagicMock() fourth_node['data'].camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 0.0) fourth_node['data'].isis_serial = '4' fourth_node['data'].__getitem__.return_value = 4 first_node = MagicMock() first_node.camera = MagicMock() first_node.camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 0.0) first_node.isis_serial = '1' first_node.__getitem__.return_value = 1 second_node = MagicMock() second_node.camera = MagicMock() second_node.camera.groundToImage.return_value = csmapi.ImageCoord(1.0, 1.0) second_node.isis_serial = '2' second_node.__getitem__.return_value = 2 third_node = MagicMock() third_node.camera = MagicMock() third_node.camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 1.0) third_node.isis_serial = '3' third_node.__getitem__.return_value = 3 fourth_node = MagicMock() fourth_node.camera = MagicMock() fourth_node.camera.groundToImage.return_value = csmapi.ImageCoord(0.0, 0.0) fourth_node.isis_serial = '4' fourth_node.__getitem__.return_value = 4 dem = MagicMock() dem.latlon_to_pixel.return_value = (1.0, 1.0) dem.read_array.return_value = [[0.0]] Loading @@ -48,13 +48,13 @@ def test_place_points_in_overlap(point_distributer, phase_matcher): point_distributer.assert_called_with(Polygon([(0, 0), (0, 10), (10, 10), (10, 0)])) dem.latlon_to_pixel.assert_called() dem.read_array.assert_called() first_node['data'].camera.groundToImage.assert_called() second_node['data'].camera.groundToImage.assert_called() third_node['data'].camera.groundToImage.assert_called() fourth_node['data'].camera.groundToImage.assert_called() first_node.camera.groundToImage.assert_called() second_node.camera.groundToImage.assert_called() third_node.camera.groundToImage.assert_called() fourth_node.camera.groundToImage.assert_called() phase_matcher.assert_any_call(0.0, 1.0, 1.0, 1.0, first_node['data'].geodata, second_node['data'].geodata, size=71) first_node.geodata, second_node.geodata, size=71) phase_matcher.assert_any_call(0.0, 1.0, 1.0, 0.0, first_node['data'].geodata, third_node['data'].geodata, size=71) first_node.geodata, third_node.geodata, size=71) phase_matcher.assert_any_call(0.0, 1.0, 0.0, 0.0, first_node['data'].geodata, fourth_node['data'].geodata, size=71) first_node.geodata, fourth_node.geodata, size=71)