Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.hull: Added the test cases for v.hull module #5135

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

codersmiti
Copy link

This PR introduces test suite for the v.hull GRASS GIS module, covering a range of scenarios, including validating the module's functionality, geometric correctness, and edge-case handling for convex hull generation. The test cases cover a variety of scenarios, including collinear points, non-collinear points, duplicate points, concave shapes, and 3D inputs.

Key updates in this PR include:

  • Functionality: Validate convex hull creation for 2D and 3D point sets, ensuring correct output existence and dimensions.

  • Edge Cases: Test collinear points, duplicate points, and concave shapes to ensure robust handling of degenerate and non-standard inputs.

  • Geometric Correctness: Verify the number of vertices, polygon closure, and correct exclusion of interior concave points.

  • 3D Inputs: Validate the formation of a tetrahedron from 3D input points.

Test Case Additions:

  • Basic Functionality:

    • Verify the creation and existence of the convex hull output.

    • Test input handling for 2D and 3D point sets.

  • Edge Cases:

    • Collinear Points: Ensure the convex hull forms a degenerate boundary with exactly 3 vertices.

    • Duplicate Points: Test that duplicate points do not affect the hull structure.

    • Concave Shapes: Validate that the convex hull ignores interior concave points.

  • Geometric Correctness:

    • Non-Collinear Points: Verify the convex hull correctly encloses a non-collinear set of points.

    • 3D Inputs: Test the formation of a tetrahedron from 3D input points.

@github-actions github-actions bot added vector Related to vector data processing raster Related to raster data processing Python Related code is in Python HTML Related code is in HTML module docs tests Related to Test Suite labels Feb 18, 2025
@codersmiti codersmiti changed the title v.hull : Added the test cases for v.hull module v.hull: Added the test cases for v.hull module Feb 18, 2025
Comment on lines +98 to +120
out_ascii = gs.read_command(
"v.out.ascii",
input=self.output_colinear_hull,
layer="-1",
format="standard",
)
lines = [
line
for line in out_ascii.splitlines()
if line.strip() and not line.startswith("ORGANIZATION:")
]

geometry_line = next((line for line in lines if line[0] in ("L", "B")), None)
self.assertIsNotNone(geometry_line, "No valid geometry found in output")
parts = geometry_line.split()

self.assertEqual(parts[0], "B", "Output should be a boundary")
self.assertEqual(int(parts[1]), 3, "Boundary should have 3 vertices")
self.assertEqual(
parts[2:4],
parts[6:8],
"Third vertex should be a copy of the first vertex in collinear case",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs HTML Related code is in HTML module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants