Skip to content

Optimize GBFS geolocation extraction: Use OSM polygons as query cache #1301

Description

@davidgamez

Describe the problem

Geolocation extraction is a great feature, but it consumes a high amount of resources. In this issue, we will optimize the extraction of locations on the GBFS feeds. As it has not been proven that the proposed solution will increase performance until it is implemented and tested, as part of this issue, we are adding the ability to "configure" the extraction strategy. This will keep the code intact, and we will be able to conduct live tests to gather more accurate data for comparison.

Proposed solution

Currently, we query the database once per geographic point. For GBFS, many geographic points are "clustered". This is primarily true in the case of vehicle positions as they tend to be clustered across regions in the same city. In many cities, the scooters/bikes/etc are only allowed to be parked in certain areas, which increases the points per cluster. This is empirical information.

Tasks:

  • Adjust the code to allow multiple location extraction strategies by using a cloud function parameter or a pub/sub event parameter. Consider adding a default in case no strategy is passed.
  • Having the list of points to extract the geolocation, implement the following strategy:
    1. Query the DB for one point
    2. Get the list of OSM IDs
    3. From the OSM IDs, select the one with the highest level and retrieve the polygon associated
    4. Iterate over the list and remove from the list all the points that are in the retrieved polygon
    5. Go to step 1 until the list is completed
  • Test the strategy with a few feeds and adjust it if needed. Consider twinking the comparison of the polygon by comparing all OSM polygons
  • Consider adjusting the CPU and memory function if needed, as the local processing will demand more resources.

Alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions