Loading autocnet/spatial/overlap.py +21 −11 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ def place_points_in_overlap(overlap, semi_major = ncg.config['spatial']['semimajor_rad'] semi_minor = ncg.config['spatial']['semiminor_rad'] ta = time.time() # Determine the point distribution in the overlap geom geom = overlap.geom valid = compgeom.distribute_points_in_geom(geom, **distribute_points_kwargs, **kwargs) Loading @@ -167,8 +168,9 @@ def place_points_in_overlap(overlap, warnings.warn('Failed to distribute points in overlap') return [] print(f'Have {len(valid)} potential points to place.') print(f'Have {len(valid)} potential points to place in overlap {overlap.id}.') tb = time.time() print(f'Point distribution took {tb-ta} seconds.') # Setup the node objects that are covered by the geom nodes = [] with ncg.session_scope() as session: Loading @@ -177,8 +179,10 @@ def place_points_in_overlap(overlap, nn = NetworkNode(node_id=id, image_path=res.path) nn.parent = ncg nodes.append(nn) tc = time.time() print(f'Took {tc-tb} seconds to instantiate {len(nodes)} images.') print(f'Attempting to place measures in {len(nodes)} images.') for v in valid: lon = v[0] lat = v[1] Loading Loading @@ -237,11 +241,12 @@ def place_points_in_overlap(overlap, if cam_type == "isis": try: p = isis.point_info(node["image_path"], newsample, newline, point_type="image") except CalledProcessError as e: if 'Requested position does not project in camera model' in e.stderr: print(node["image_path"]) print(f'interesting point ({newsample}, {newline}) does not project back to ground') except: continue #except CalledProcessError as e: # if 'Requested position does not project in camera model' in e.stderr: # print(f'interesting point ({newsample}, {newline}) in image {node["image_path"]} does not project back to ground') # continue try: x, y, z = p["BodyFixedCoordinate"].value except: Loading Loading @@ -326,12 +331,17 @@ def place_points_in_overlap(overlap, points.append(point) print(f'Able to place {len(points)} points.') if not points: return # Insert the points into the database asynchronously (via redis) or synchronously via the ncg if use_cache: pipeline = ncg.redis_queue.pipeline() msgs = [json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points] pipeline.rpush(ncg.point_insert_queue, *msgs) pipeline.execute() # Push print('Using the cache') ncg.redis_queue.rpush(ncg.point_insert_queue, *[json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points]) ncg.redis_queue.incr(ncg.point_insert_counter, amount=len(points)) #ncg.redis_queue.rpush(ncg.point_insert_queue, *[json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points]) ncg.redis_queue.incr(ncg.point_insert_counter, amount=len(msgs)) else: with ncg.session_scope() as session: for point in points: Loading Loading
autocnet/spatial/overlap.py +21 −11 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ def place_points_in_overlap(overlap, semi_major = ncg.config['spatial']['semimajor_rad'] semi_minor = ncg.config['spatial']['semiminor_rad'] ta = time.time() # Determine the point distribution in the overlap geom geom = overlap.geom valid = compgeom.distribute_points_in_geom(geom, **distribute_points_kwargs, **kwargs) Loading @@ -167,8 +168,9 @@ def place_points_in_overlap(overlap, warnings.warn('Failed to distribute points in overlap') return [] print(f'Have {len(valid)} potential points to place.') print(f'Have {len(valid)} potential points to place in overlap {overlap.id}.') tb = time.time() print(f'Point distribution took {tb-ta} seconds.') # Setup the node objects that are covered by the geom nodes = [] with ncg.session_scope() as session: Loading @@ -177,8 +179,10 @@ def place_points_in_overlap(overlap, nn = NetworkNode(node_id=id, image_path=res.path) nn.parent = ncg nodes.append(nn) tc = time.time() print(f'Took {tc-tb} seconds to instantiate {len(nodes)} images.') print(f'Attempting to place measures in {len(nodes)} images.') for v in valid: lon = v[0] lat = v[1] Loading Loading @@ -237,11 +241,12 @@ def place_points_in_overlap(overlap, if cam_type == "isis": try: p = isis.point_info(node["image_path"], newsample, newline, point_type="image") except CalledProcessError as e: if 'Requested position does not project in camera model' in e.stderr: print(node["image_path"]) print(f'interesting point ({newsample}, {newline}) does not project back to ground') except: continue #except CalledProcessError as e: # if 'Requested position does not project in camera model' in e.stderr: # print(f'interesting point ({newsample}, {newline}) in image {node["image_path"]} does not project back to ground') # continue try: x, y, z = p["BodyFixedCoordinate"].value except: Loading Loading @@ -326,12 +331,17 @@ def place_points_in_overlap(overlap, points.append(point) print(f'Able to place {len(points)} points.') if not points: return # Insert the points into the database asynchronously (via redis) or synchronously via the ncg if use_cache: pipeline = ncg.redis_queue.pipeline() msgs = [json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points] pipeline.rpush(ncg.point_insert_queue, *msgs) pipeline.execute() # Push print('Using the cache') ncg.redis_queue.rpush(ncg.point_insert_queue, *[json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points]) ncg.redis_queue.incr(ncg.point_insert_counter, amount=len(points)) #ncg.redis_queue.rpush(ncg.point_insert_queue, *[json.dumps(point.to_dict(_hide=[]), cls=JsonEncoder) for point in points]) ncg.redis_queue.incr(ncg.point_insert_counter, amount=len(msgs)) else: with ncg.session_scope() as session: for point in points: Loading