-
Notifications
You must be signed in to change notification settings - Fork 27
1849 show more trajectory information #1481
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
Merged
Merged
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
80a2229
1849-show-more-trajectory-information: make string as resource
sandradeng20 bf90357
1849-show-more-trajectory-information: update mapbox secret token set…
sandradeng20 6001ead
1849-show-more-trajectory-information: fix empty trajectory processing
sandradeng20 c56a4bc
1849-show-more-trajectory-information: refactor code
sandradeng20 62ff6d4
1849-show-more-trajectory-information: reformat code
sandradeng20 a6d0653
Merge branch 'main' into 1849-show-more-trajectory-information
abbybernstein 0c76715
add postgres logic to create layer by activity
abbybernstein f6591ba
connect trajectory by activity layer to timeline app
abbybernstein 30b4b96
change colors by activity type
abbybernstein 1cadf91
add activity summary functionality
abbybernstein 3d98c44
fix postgres activity type assignment
abbybernstein 4b21e40
add trajectory summary colorcoded
abbybernstein a5f395c
fix summary updating error
abbybernstein b4f3f42
fix colors
abbybernstein d795199
Print trajectory info by session
abbybernstein 5fabc91
add summary to bottom sheet
abbybernstein c46519b
fix page switch loaidng behavior
abbybernstein 880728f
fix centering trajectory
abbybernstein 3a37197
refactor files
abbybernstein e8d375a
resolve comments
abbybernstein 1cc4285
resolve comments
abbybernstein bbe55ea
simplifying sql
abbybernstein 7f06941
interactable trajectoryline
abbybernstein 407e686
fix sql script for layer creation
abbybernstein 935da95
fix sql script
abbybernstein 205fd14
fix trajectory interactability
abbybernstein f8b3eed
resolve comments
abbybernstein 773669c
update user agent
abbybernstein dda320e
upate trajectoryqueryagent image
abbybernstein 59a1fa1
Merge branch 'main' into 1849-show-more-trajectory-information
abbybernstein 62242c6
fix errors
abbybernstein f1b2bff
1849-show-more-trajectory-information: resolve comments
sandradeng20 b64c5cd
redesign trajectory classes
abbybernstein f064269
fix xml
abbybernstein 59a9842
clickability fixed
abbybernstein 6a73793
fix trajectory line clicking
abbybernstein c65834b
resolve comments
abbybernstein e9ef455
resolve comments
abbybernstein a6a2ffd
resolve comments
abbybernstein f1a34ce
fix error
abbybernstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| services: | ||
| trajectoryqueryagent: | ||
| image: ghcr.io/cambridge-cares/trajectoryqueryagent:4.1.1 | ||
| image: ghcr.io/cambridge-cares/trajectoryqueryagent:4.2.0 | ||
| build: . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
...toryQueryAgent/trajectoryqueryagent/src/main/resources/line_layer_user_id_by_activity.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| WITH distinct_devices AS ( | ||
| SELECT | ||
| array_agg(device_id::text) AS device_list | ||
| FROM | ||
| (SELECT DISTINCT device_id | ||
| FROM devices | ||
| WHERE sensor_class = 'Activity') AS distinct_devices | ||
| ), | ||
|
|
||
| timeseries AS ( | ||
| SELECT | ||
| * | ||
| FROM | ||
| public.get_location_table((SELECT device_list FROM distinct_devices)) AS timeseries | ||
| ORDER BY time | ||
| ), | ||
|
|
||
| activity_data AS ( | ||
| SELECT | ||
| * | ||
| FROM | ||
| public.get_activity_table((SELECT device_list FROM distinct_devices)) AS activity_data | ||
| ORDER BY time | ||
| ), | ||
|
|
||
| joined_data AS ( | ||
| SELECT | ||
| t.*, | ||
| a.activity_type, | ||
| a.confidence_level, | ||
| LAG(t.time) OVER (PARTITION BY t.user_id ORDER BY t.time) AS prev_time | ||
| FROM | ||
| timeseries t | ||
| LEFT JOIN | ||
| activity_data a | ||
| ON | ||
| ABS(t.time - a.time) <= 5000 | ||
| ORDER BY t.time | ||
| ), | ||
|
|
||
| fixed_activity_data AS ( | ||
| SELECT | ||
| time, | ||
| speed, | ||
| altitude, | ||
| geom, | ||
| bearing, | ||
| session_id, | ||
| user_id, | ||
| confidence_level, | ||
| COALESCE(activity_type, 'others') AS activity_type | ||
| FROM joined_data | ||
| WHERE time <> prev_time | ||
| ), | ||
|
|
||
| temp_activity_table AS ( | ||
| SELECT * FROM fill_activity_types( | ||
| (SELECT array_agg(activity_type ORDER BY time) FROM fixed_activity_data), | ||
| (SELECT array_agg(time ORDER BY time) FROM fixed_activity_data) | ||
| ) | ||
| ), | ||
|
|
||
| filled_activity_data AS ( | ||
| SELECT | ||
| fixed.time AS time, | ||
| fixed.speed AS speed, | ||
| fixed.altitude AS altitude, | ||
| fixed.geom AS geom, | ||
| fixed.bearing AS bearing, | ||
| fixed.session_id AS session_id, | ||
| fixed.user_id AS user_id, | ||
| temp.activity_type AS activity_type, | ||
| fixed.confidence_level AS confidence_level | ||
| FROM fixed_activity_data AS fixed | ||
| JOIN temp_activity_table AS temp | ||
| ON fixed.time = temp.time | ||
| ORDER BY time | ||
| ), | ||
|
|
||
| change_marked AS ( | ||
| SELECT | ||
| *, | ||
| CASE | ||
| WHEN | ||
| LAG(activity_type) OVER (PARTITION BY user_id ORDER BY time) IS DISTINCT FROM activity_type | ||
| THEN 1 | ||
| ELSE 0 | ||
| END AS change_flag | ||
| FROM filled_activity_data | ||
| ), | ||
|
|
||
| change_marked_union AS ( | ||
| SELECT * FROM change_marked | ||
| UNION ALL | ||
| SELECT time, speed, altitude, geom, bearing, session_id, user_id, | ||
| LAG(activity_type) OVER (PARTITION BY user_id ORDER BY time), confidence_level, 0 | ||
| FROM change_marked WHERE change_flag = 1 | ||
| ORDER BY time, change_flag | ||
| ), | ||
|
|
||
| numbered_activity_data AS ( | ||
| SELECT | ||
| *, | ||
| SUM(change_flag) OVER (PARTITION BY user_id ORDER BY time ROWS UNBOUNDED PRECEDING) AS id | ||
| FROM change_marked_union cm | ||
| WHERE activity_type IS NOT NULL | ||
| ORDER BY cm.time, cm.change_flag | ||
| ) | ||
|
|
||
| SELECT | ||
| id, | ||
| MIN(na.time) AS start_time, | ||
| MAX(na.time) AS end_time, | ||
| user_id, | ||
| activity_type, | ||
| session_id, | ||
| ST_MakeLine(geom) as geom, | ||
| ST_Length(ST_Transform(ST_MakeLine(geom), 3857))::INTEGER AS distance_traveled, | ||
| CONCAT('https://w3id.org/MON/person.owl#person_', user_id) AS iri | ||
| FROM | ||
| numbered_activity_data na | ||
| WHERE | ||
| ('%user_id%' = '' OR user_id = '%user_id%') | ||
| AND ('%lowerbound%' = '0' OR na.time > '%lowerbound%'::BIGINT) | ||
| AND ('%upperbound%' = '0' OR na.time < '%upperbound%'::BIGINT) | ||
| GROUP BY | ||
| na.id, na.activity_type, na.user_id, na.session_id | ||
| ORDER BY start_time | ||
sandradeng20 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.