Skip to content

Implementation of Geospatial Reduce Methods#4508

Open
Gopalverma062 wants to merge 3 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Gopalverma062:BABEL_6310_REDUCE
Open

Implementation of Geospatial Reduce Methods#4508
Gopalverma062 wants to merge 3 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Gopalverma062:BABEL_6310_REDUCE

Conversation

@Gopalverma062
Copy link
Contributor

@Gopalverma062 Gopalverma062 commented Jan 31, 2026

Summary

Implements the Reduce() function for both geometry and geography spatial types using the Douglas-Peucker algorithm to simplify geometries.

Changes

  • Added sys.Reduce(tolerance, geometry) function
  • Added sys.Reduce(tolerance, geography) function
  • Added sys.Reduce_helper() for geography meter-to-degree conversion
  • Added sys.geography_simplify_internal() wrapper for PostGIS
  • Added upgrade script for spatial_types--5.5.0--5.6.0.sql
  • Added comprehensive test cases

TSQL Compatibility

  • Matches TSQL behavior for supported types
  • Handles NULL, empty, and invalid geometries correctly
  • Preserves SRID
  • Returns original geometry when simplification produces invalid result

Test Coverage

  • Geometry: LINESTRING, POLYGON, POINT with various tolerances (0, 0.1, 0.5, 1.0, 2.0, 10, 50)
  • Geography: LINESTRING, POLYGON, POINT with meter-based tolerances (0, 10, 100, 1000, 10000, 100000)
  • Edge cases: NULL, empty, invalid geometry, negative tolerance
  • SQL patterns: SELECT, WHERE, CTE, Views, GROUP BY, ORDER BY
  • Table column operations

Testing Done

  • All existing tests pass
  • New test cases pass
  • Compared results with SQL Server - matches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant