Commit d80dea5b authored by Laura, Jason R's avatar Laura, Jason R
Browse files

Merge branch 'Sliver_Update' into 'main'

Add option for ratio size for slivers

See merge request astrogeology/autocnet!674
parents 79c42a94 24c86315
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -459,6 +459,7 @@ def distribute_points_in_geom(geom, method="classic",
                              nspts_func=lambda x: ceil(round(x,1)*10),
                              ewpts_func=lambda x: ceil(round(x,1)*5),
                              Session=None,
                              ratio_size=0.1,
                              **kwargs):
    """
    Given a geometry, attempt a basic classification of the shape.
@@ -486,6 +487,9 @@ def distribute_points_in_geom(geom, method="classic",

    ewpts_func : obj
                 Function taking a Number and returning an int
    ratio_size : float
                 A number that represent the minimum size the
                 ratio is set at to be considered a sliver.

    Returns
    -------
@@ -532,7 +536,7 @@ def distribute_points_in_geom(geom, method="classic",
        ew = True

    # Decision Tree
    if ratio < 0.1 and geom.area < 0.01:
    if ratio < ratio_size and geom.area < 0.01:
        # Class: Slivers - ignore.
        return np.array([])
    elif geom.area <= 0.004 and ratio >= 0.25:
+8 −6
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import shapely
import sqlalchemy
from plio.io.io_gdal import GeoDataset

from math import floor

from autocnet.cg import cg as compgeom
from autocnet.graph.node import NetworkNode
@@ -76,6 +75,7 @@ def place_points_in_overlap(overlap,
                            point_type=2,
                            ncg=None,
                            use_cache=False,
                            ratio_size=0.1,
                            **kwargs):
    """
    Place points into an overlap geometry by back-projecting using sensor models.
@@ -114,6 +114,10 @@ def place_points_in_overlap(overlap,
                messages to the point_insert (defined in ncg.config) redis queue for
                asynchronous (higher performance) inserts.
    
    ratio_size : float
                Used in calling the function distribute_points_in_geom to determine the
                minimum size the ratio can be to be considered a sliver and ignored.

    Returns
    -------
    points : list of Points
@@ -146,7 +150,7 @@ def place_points_in_overlap(overlap,
    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)
    valid = compgeom.distribute_points_in_geom(geom, ratio_size=ratio_size, **distribute_points_kwargs, **kwargs)
    if not valid.any():
        warnings.warn(f'Failed to distribute points in overlap {overlap.id}')
        return []
@@ -218,8 +222,7 @@ def place_points_in_overlap(overlap,
            # kps are in the image space with upper left origin and the roi
            # could be the requested size or smaller if near an image boundary.
            # So use the roi upper left_x and top_y for the actual origin.
            left_x = floor(image_roi.x) - image_roi.size_x
            top_y = floor(image_roi.y) - image_roi.size_y
            left_x, _, top_y, _ = image_roi.image_extent
            newsample = left_x + interesting.x
            newline = top_y + interesting.y

@@ -449,8 +452,7 @@ def place_points_in_image(image,
        # kps are in the image space with upper left origin and the roi
        # could be the requested size or smaller if near an image boundary.
        # So use the roi upper left_x and top_y for the actual origin.
        left_x = floor(image_roi.x) - image_roi.size_x
        top_y = floor(image_roi.y) - image_roi.size_y
        left_x, _, top_y, _ = image_roi.image_extent
        newsample = left_x + interesting.x
        newline = top_y + interesting.y