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

Fix line overload color computation #109

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

jamal-khey
Copy link
Contributor

@jamal-khey jamal-khey commented Oct 30, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
This PR fixes the function that computes the color of lines based on their overload status.

What kind of change does this PR introduce?
Bug fix: Corrects line coloring calculation by considering absolute values of line intensities

What is the current behavior?
The current implementation uses raw intensity values to determine line loading zones, which causes incorrect coloring when the intensity is negative. Negative values are being treated as overload when they should be treated based on their magnitude regardless of direction.

What is the new behavior (if this is a feature change)?
The fix uses the absolute value of the intensity (Math.abs(intensity)) when comparing against thresholds. This ensures that line loading zones are correctly calculated regardless of the current flow direction. For example, an intensity of -900A on a line with a 1000A limit will now properly show as being close to overload, whereas before it might have been incorrectly shown as safe.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Other information:

This fix ensures consistent line coloring behavior regardless of power flow direction
The change affects the visual representation only and does not impact any underlying calculations or data

Signed-off-by: jamal-khey <myjamal89@gmail.com>
@jamal-khey jamal-khey force-pushed the jamal-khey/fix-map-lines-color-overload branch from 06401cb to 0d575af Compare October 30, 2024 16:41
@jamal-khey jamal-khey self-assigned this Oct 30, 2024
@@ -61,9 +61,10 @@ export function getLineLoadingZoneOfSide(limit, intensity, lineFlowAlertThreshol
return LineLoadingZone.UNKNOWN;
} else {
let threshold = (lineFlowAlertThreshold * limit) / 100;
if (intensity > 0 && intensity < threshold) {
const absoluteIntensity = Math.abs(intensity);
if (absoluteIntensity > 0 && absoluteIntensity < threshold) {
Copy link
Contributor

Choose a reason for hiding this comment

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

absolute intensity is always > 0 as we checked if intensity === 0 before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@souissimai souissimai self-requested a review November 7, 2024 10:45
Signed-off-by: jamal-khey <myjamal89@gmail.com>
Copy link

sonarqubecloud bot commented Nov 7, 2024

@jamal-khey jamal-khey merged commit 5573b0d into main Nov 7, 2024
5 checks passed
@jamal-khey jamal-khey deleted the jamal-khey/fix-map-lines-color-overload branch November 7, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants