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

#90: Added logging to services #119

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

Kebslock
Copy link
Contributor

@Kebslock Kebslock commented Sep 3, 2023

No description provided.

@Kebslock Kebslock requested a review from liamboddin September 3, 2023 13:38
@Kebslock Kebslock self-assigned this Sep 3, 2023
@@ -124,7 +127,11 @@ export default class TrackService {

// for easier access we set the property of track kilometer to the already calculated value
if (projectedPoint.properties["location"] == null) {
// TODO: log this
logger.error(
`Turf did something wrong while computing nearest point on line for track with id ${
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rather something like: Turf error: Could not compute nearest point on line for track with id ... and position ...

@@ -209,7 +222,11 @@ export default class TrackService {
// this gives us the nearest point on the linestring including the distance to that point
const closestPoint: GeoJSON.Feature<GeoJSON.Point> = nearestPointOnLine(lineStringData, position)
if (closestPoint.properties == null || closestPoint.properties["dist"] == null) {
// TODO: this should not happen, so maybe log this
logger.warn(
`Turf did not calculate nearest point on line correctly for position ${JSON.stringify(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above:
Turf error: Could not calculate nearest point on line correctly for position ${JSON.stringify(position)} for track with id {tracks[i].uid}.

I think it is just easier to read that this error lies in turf, not our implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not thinking too much about this as this check should prevent typescript from complaining (the properties-field is optional in GeoJSON) rather than really handling any errors there. I guess turf would throw an error instead of setting properties to null anyways. But you are right, that the log messages are a little bit vague. So I will change this (thanks for the suggestions for those).

@Kebslock
Copy link
Contributor Author

Kebslock commented Sep 4, 2023

I just pushed the requested changes, but you may noticed I also added the correct type to the variables, which store the result of turf's nearestPointOnLine. That way we can be sure, that the properties are set and only the fields of properties are optional and need this check.

@Kebslock Kebslock requested a review from liamboddin September 4, 2023 10:08
@Kebslock Kebslock merged commit 9c47d5e into development Sep 4, 2023
@Kebslock Kebslock deleted the 90-implement-logging-in-services branch September 4, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants