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

Add areas #77

Conversation

JuhoErvasti
Copy link
Collaborator

Fixes #74
#76 is included.

  • Add AreaLayer and Area
  • Create a new ProcessingUtils static class and move reusable code from the "Count trajectories" script there
  • New script: "Count trajectories (areas)"
  • I've renamed the old "Count trajectories" script to "Count trajectories (gates)"
  • Includes some improvement to gate counting as well
    • Basically we were unnecessarily evaluating expressions multiple times
    • Instead we can evaluate the filter expression once and for all and create an already filtered layer for TrajectoryLayer using the QgsVectorLayer.materialize method
    • Filtering should be faster now

msorvoja and others added 13 commits November 7, 2024 15:03
- We break up creating the filter expression for the processing script
  into functions
- This is done in order to be able to reuse the code in another
  processing script
- And if we need to change something later we don't have to edit both
  scripts
- Should be faster for filtering
- The filter expression argument passed to TrajectoryLayer() becomes a
  bit obsolete.
  - I considered deleting it since I'm not sure we need it at all now but
    I guess there's not that much harm in keeping it around, maybe we'll
    need it later.
  - Also by deleting it you'd need to change some existing stuff
…ent-calculation-of-average-speed-of-trajectories-crossing-two-gates
@JuhoErvasti JuhoErvasti requested a review from msorvoja November 8, 2024 13:24
@JuhoErvasti JuhoErvasti linked an issue Nov 8, 2024 that may be closed by this pull request
Copy link
Collaborator

@msorvoja msorvoja left a comment

Choose a reason for hiding this comment

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

Looks very good overall! However, there are some issues I noticed while testing the processing algorithms:

  • If class of traveler is not set, vehicle_class field in resulting line/area layer will be empty
  • Speed and acceleration are not rounded to digits precision in the exported gate/area layers
  • Resulting trajectory layers could be named e.g. Trajectories - Areas and Trajectories - Gates for the sake of clarity
  • count_trajectories_area connects trajectories with the same ID like this:
    Screenshot from 2024-11-11 07-48-52

- Round avg speed / acceleration to a precision of 2
- If points were not filtered by class of traveler, set 'vehicle_class'
  to 'all'
@JuhoErvasti
Copy link
Collaborator Author

JuhoErvasti commented Nov 11, 2024

@msorvoja I've addressed your comments, ready for another round.

Also something I noticed and a fix is included: when exporting trajectories/gates/areas, the 'fid' field started incrementing from 0, for features the indexing starts typically from 1 so I changed that as well.

Copy link
Collaborator

@msorvoja msorvoja left a comment

Choose a reason for hiding this comment

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

Everything seems to work now as intended, great job!

@msorvoja msorvoja merged commit cdd8d9e into main Nov 11, 2024
@msorvoja msorvoja deleted the 74-implement-calculation-of-average-speed-of-trajectories-crossing-two-gates branch November 11, 2024 10:49
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 calculation of average speed of trajectories inside an area
2 participants