-
Notifications
You must be signed in to change notification settings - Fork 1
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
23 service improvements #50
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good so far with the individual services and common utils on the side for all of them. Looking through the code comments: have you decided yet if you want to use / which logging framework you want to use? Answering this could solve a lot of the TODOs left in the code.
Good use of TODOs to keep track of minor things in the code to be replaced as the project progresses.
Also make sure to add a copyright/license header to your files, see my comment on the other PRs.
Server/src/services/poi.service.ts
Outdated
@@ -97,11 +104,17 @@ export default class POIService{ | |||
*/ | |||
public static async getPOITrackDistanceKm(poi: POI): Promise<number | null>{ | |||
// get closest track if none is given | |||
const poiPos: GeoJSON.Feature<GeoJSON.Point> = JSON.parse(JSON.stringify(poi.position)) | |||
if (poiPos == null || poiPos.properties == null || poiPos.properties["trackKm"] == null) { | |||
const poiPos = GeoJSONUtils.parseGeoJSONFeaturePoint(JSON.parse(JSON.stringify(poi.position))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringifying and immediately parsing an object seems unnecessary/waseful. I guess you only want an object with the correct type for you to work on it or is there a reason why you would not want to work on the poi.position
directly?
362edcd
to
832958a
Compare
… into 23-service-improvements
} | ||
allVehiclesOnTrack.filter(async function (vehicle, index, vehicles){ | ||
const vehicleTrackKm = await VehicleService.getVehicleTrackDistanceKm(vehicle) | ||
if (vehicleTrackKm == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an error but more like an inconsistency:
Sometimes you use the ??
(Nullish Coalescing) operator to either return the "right" value or if it is "null" another value, and then sometimes you use a if statement.
This clearly needs a little bit more work. Please adjust call sites when changing the signature of functions:
|
Also there is infinite recursion when calculating a vehicle position. I am considering reverting this merge. |
This PR is mainly for complete review of the POI-, Track- and Vehicle-Service (because it was not done so far).
Furthermore there were changes to improve handling of GeoJSON data and also some minor code improvements.