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

refactor: Cleanup routing profile management #1790

Merged
merged 10 commits into from
May 15, 2024
Merged

Conversation

sfendrich
Copy link
Contributor

@sfendrich sfendrich commented May 13, 2024

Pull Request Checklist

  • 1. I have rebased the latest version of the main branch into my feature branch and all conflicts
    have been resolved.
  • 2. I have added information about the change/addition to functionality to the CHANGELOG.md file under the
    [Unreleased] heading.
  • 3. I have documented my code using JDocs tags.
  • 4. I have removed unnecessary commented out code, imports and System.out.println statements.
  • 5. I have written JUnit tests for any new methods/classes and ensured that they pass.
  • 6. I have created API tests for any new functionality exposed to the API.
  • 7. If changes/additions are made to the ors-config.json file, I have added these to the ors config documentation
    along with a short description of what it is for, and documented this in the Pull Request (below).
  • 8. I have built graphs with my code of the Heidelberg.osm.gz file and run the api-tests with all test passing
  • 9. I have referenced the Issue Number in the Pull Request (if the changes were from an issue).
  • 10. For new features or changes involving building of graphs, I have tested on a larger dataset
    (at least Germany), and the graphs build without problems (i.e. no out-of-memory errors).
  • 11. For new features or changes involving the graphbuilding process (i.e. changing encoders, updating the
    importer etc.), I have generated longer distance routes for the affected profiles with different options
    (avoid features, max weight etc.) and compared these with the routes of the same parameters and start/end
    points generated from the current live ORS.
    If there are differences then the reasoning for these MUST be documented in the pull request.
  • 12. I have written in the Pull Request information about the changes made including their intended usage
    and why the change was needed.
  • 13. For changes touching the API documentation, I have tested that the API playground renders correctly.

Fixes # .

Information about the changes

Key functionality added:

  • Move method computeResult from SnappingService to SnappingRequest
  • Move methods computeMatrix, computeDijkstraMatrix, computeCoreMatrix and computeRPHASTMatrix from RoutingProfile to MatrixRequest
  • Move method computeExport from RoutingProfile to ExportRequest
  • Harmonize interfaces of these request classes
  • Move methods computeRoute and createPTRequest from RoutingProfile to RoutingRequest

Reason for change:

  • The goal of this PR is to refactor class RoutingProfile in order to permit future developments and to improve maintainability of the code base.

Examples and reasons for differences between live ORS routes, and those generated from this pull request

Required changes to ors config (if applicable)

@takb takb added this to To do in ors general May 13, 2024
@sfendrich sfendrich changed the title refactor: Move compute method into SnappingRequest refactor: Cleanup class RoutingProfile May 14, 2024
@sfendrich sfendrich changed the title refactor: Cleanup class RoutingProfile refactor: Cleanup crouting profile management May 14, 2024
@aoles aoles changed the title refactor: Cleanup crouting profile management refactor: Cleanup routing profile management May 14, 2024
@sfendrich sfendrich marked this pull request as ready for review May 15, 2024 07:17
Copy link
Member

@aoles aoles left a comment

Choose a reason for hiding this comment

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

LGTM, Cheers! ❤️

Sascha Fendrich added 3 commits May 15, 2024 22:29
The compute method was erroneuosly placed in class SnappingService.
SnappingService is an API-level class and should not need to know
anything about Graphhopper internals. A better place for computing
results are the core-level request classes.

Fixes #64.
The methods computeMatrix and its private submethods computeDijkstraMatrix,
computeRPHASTMatrix and computeCoreMatrix have benn moved from class
RoutingProfile into MatrixRequest. This is part of a larger refactoring
aiming to move the compute methods out of RoutingProfile in order to
enable better polymorphism for future developments.
Sascha Fendrich added 7 commits May 15, 2024 22:29
As a part of cleaning up RoutingProfile the method computeExport
is moved to a more appropriate place. This will enable better
encapsulation and more Polymorphism later.
The request interfaces for Matrix, Snapping and Export differed in
little details. This commit harmonizes the interfaces towards a
common interface. The goal is to support polymorphism in the future.
RoutingProfile's unused field mUseCounter is removed together with
the methods beginUseGH, endUseGH and isGHUsed and their unnecessary
calls throughout the class.
RoutingProfile contains several static helper methods which do not
really belong there. These methods are moved into a temporary
util class until a better place is found.
In order to move the methods computeRoute and createPTRequest, we
need some preparations:

- replace direct access to fields mGraphHopper and config by
  calling the getters
- make some of the called methods public
- introduce new method parameter RoutingRequest rq and pass the
  routing request at the call site
- introduce a public logger in RoutingRequest and use it instead of
  RoutingProfile's logger in computedRoute; the public logger
  will be made private after the move
- temporarily provide getters for fields astar* to be used in
  `computeRoute`; appropriate places for these fields need to be found
As part of refactoring ROutingProfile the compute methods
need to be moved into the appropriate request classes.
@aoles aoles force-pushed the refactor/routing-profile branch from 5c19b87 to 56e4f73 Compare May 15, 2024 20:30
@aoles aoles enabled auto-merge May 15, 2024 20:30
Copy link

sonarcloud bot commented May 15, 2024

@aoles aoles merged commit 2740e85 into main May 15, 2024
38 checks passed
ors general automation moved this from To do to Awaiting release May 15, 2024
@aoles aoles deleted the refactor/routing-profile branch May 15, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
ors general
  
Awaiting release
Development

Successfully merging this pull request may close these issues.

None yet

2 participants