Skip to content

Polygon search#4

Merged
rm-hull merged 10 commits into
mainfrom
feat/polygon-search
Jun 25, 2025
Merged

Polygon search#4
rm-hull merged 10 commits into
mainfrom
feat/polygon-search

Conversation

@rm-hull

@rm-hull rm-hull commented Jun 23, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

gemini-code-assist[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jun 23, 2025

Copy link
Copy Markdown
TestsPassed ❌️SkippedFailed
JUnit Test Report0 ran0 passed0 skipped0 failed
TestResult
No test annotations available

@coveralls

coveralls commented Jun 23, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 15871888841

Details

  • 0 of 86 (0.0%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
main.go 0 2 0.0%
spatial-index/codepoint.go 0 13 0.0%
routes/search.go 0 71 0.0%
Files with Coverage Reduction New Missed Lines %
spatial-index/codepoint.go 1 0.0%
Totals Coverage Status
Change from base Build 15853203916: 0.0%
Covered Lines: 0
Relevant Lines: 413

💛 - Coveralls

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new polygon search feature, including a new API endpoint and refactoring of the spatial index search logic. Review comments address potential issues in the new PolygonSearch handler, opportunities to improve the handler's resilience and readability, and a breaking change due to endpoint renaming.

Comment thread routes/search.go Outdated
Comment thread routes/search.go
Comment thread routes/search.go Outdated
Comment thread main.go
@rm-hull

rm-hull commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator Author

/gemini summary

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request implements a new API endpoint for searching postcode polygons based on a bounding box. It introduces the ability to load polygon data from compressed GeoJSON files, leveraging a spatial index to efficiently retrieve relevant data. The changes also include refactoring the spatial index search to use an iterator, and adding necessary dependencies for GeoJSON handling and bzip2 decompression.

Highlights

  • New API Endpoint: Introduces a new /v1/postcode/polygons endpoint that searches for postcode polygons within a given bounding box.
  • Polygon Data Loading: Adds functionality to load postcode polygon data from compressed GeoJSON files (bzip2) stored locally.
  • Spatial Indexing: Modifies the spatial index search to use an iterator pattern for more efficient data retrieval.
  • Dependency Updates: Adds jsoniter, dsnet/compress/bzip2, and paulmach/orb/geojson as new dependencies.
Changelog
  • Dockerfile
    • Added the jsoniter tag to the go build command.
  • main.go
    • Renamed the /v1/postcode/codepoint endpoint to /v1/postcode/codepoints.
    • Added a new route /v1/postcode/polygons that calls the PolygonSearch function.
  • routes/search.go
    • Added imports for os, github.com/dsnet/compress/bzip2, jsoniter, and github.com/paulmach/orb/geojson.
    • Implemented the PolygonSearch function to handle polygon searches based on a bounding box.
    • Implemented the loadFromFile function to load GeoJSON feature collections from bzip2 compressed files.
    • The PolygonSearch function extracts the bounding box from the query parameters, searches the spatial index for relevant postcodes, loads the corresponding GeoJSON polygons, and returns a FeatureCollection containing the matching polygons.
  • spatial-index/codepoint.go
    • Refactored the Search function to use SearchIter internally.
    • Introduced the SearchIter function to allow iterating over search results without collecting all results into a slice at once.
    • The original Search function now returns an error if an error occurs during the spatial search.
Activity
  • The pull request was created to add polygon search functionality.
  • JUnit tests reported no tests ran.
  • Coveralls reported 0.0% coverage for the changed lines.
  • gemini-code-assist[bot] left review comments pointing out potential issues such as sending the HTTP response within a loop, error handling in loadFromFile, nested if statements, and the breaking change of renaming the /v1/postcode/codepoint endpoint.

@rm-hull
rm-hull merged commit 37ae9a5 into main Jun 25, 2025
3 checks passed
@rm-hull
rm-hull deleted the feat/polygon-search branch June 25, 2025 18:58
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.

2 participants