Skip to content

Commit

Permalink
Fix undefined value
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed May 6, 2024
1 parent 5d70c0c commit a3372eb
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/lidar/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) 2018-2022 Camptocamp SA
// Copyright (c) 2018-2024 Camptocamp SA
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -82,15 +82,15 @@ export type LidarprofilePoints = {
* Profile point after measure or after parsing of the binary array returned by Pytree
*/
export type LidarPoint = {
cx?: number;
cy?: number;
distance?: number;
altitude?: number;
color_packed?: number[];
coords?: number[];
intensity?: number;
classification?: number;
set?: boolean;
cx?: number | undefined;
cy?: number | undefined;
distance?: number | undefined;
altitude?: number | undefined;
color_packed?: number[] | undefined;
coords?: number[] | undefined;
intensity?: number | undefined;
classification?: number | undefined;
set?: boolean | undefined;
};

type ClippedLine = {
Expand Down Expand Up @@ -374,9 +374,12 @@ export default class {
// @ts-ignore: unsupported by typescript
const value = point[key]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
if (key == 'altitude') {
row[key] = (value as LidarPoint['altitude']).toFixed(4);
} else if (key == 'color_packed' || key == 'coords') {
row[key] = (value as LidarPoint['color_packed'] | LidarPoint['coords']).join(' ');
const value = point?.altitude;
row[key] = value ? value.toFixed(4) : NaN;
} else if (key == 'color_packed') {
row[key] = (point.color_packed ?? []).join(' ');
} else if (key == 'coords') {
row[key] = (point.coords ?? []).join(' ');
} else {
row[key] = value; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
}
Expand Down

0 comments on commit a3372eb

Please sign in to comment.