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

Enhance Region Functionality with Geometry and Optimized Subregion Queries #39

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

OhmSpectator
Copy link
Member

Description

This PR introduces several key features and optimizations related to the Region entity in the backend. Specifically, it adds the ability to fetch and calculate geometries for regions and efficiently retrieves all subregions with a new method. This PR aims to improve the performance and feature set for managing regions in the application.

Key Features

  • Geometry Field for Region Model: Adds a geom field in the Region model to store geometry data.
  • Get Geometry API: Implements an API endpoint to fetch and calculate the geometry for a given region.
  • Optimized Subregion Fetching: Adds a new method that uses recursive SQL queries to fetch all subregions for a given region efficiently.
  • Route Validations: Implements new validation logic for the API parameters.

Extend the database initialization script to create a GiST (Generalized Search
Tree) index on the `geom` column of the `regions` table. This will optimize
spatial queries on this column.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Add a new field `geom` of type GEOMETRY('MULTIPOLYGON', 4326) to the Region
model to store the geometry data.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Add a new controller method to retrieve and calculate the geometry of a region.
Uses a recursive SQL query to combine the geometries of all sub-regions.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Introduce a new function `getAllSubregions` that retrieves all subregions of a
given region. Utilize a recursive SQL query for efficient data retrieval.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
…tion.

- Update the `getSubregions` method to use the optimized `getAllSubregions`
  function.
- Add route validation for the `getAll` query parameter.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Implement a new API route to fetch the geometry of a region.

Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
@OhmSpectator OhmSpectator linked an issue Oct 25, 2023 that may be closed by this pull request
@OhmSpectator OhmSpectator merged commit a6a4110 into main Oct 25, 2023
3 checks passed
@OhmSpectator OhmSpectator deleted the 37-implement-api-for-getting-region-geometry branch October 31, 2023 14:40
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.

Implement API for getting region geometry
1 participant