Skip to content

reduce invalidation frequency#220

Closed
maerki wants to merge 1 commit into
mainfrom
bugfix/reduce-invaildation-frequency
Closed

reduce invalidation frequency#220
maerki wants to merge 1 commit into
mainfrom
bugfix/reduce-invaildation-frequency

Conversation

@maerki

@maerki maerki commented Jun 15, 2025

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a mechanism to skip minor GPS position updates to reduce invalidation frequency.

  • Extracted mapCoordinateSystem into a local variable for reuse
  • Added a threshold check to early-return on negligible position changes
  • Refactored repeated getMapConfig().mapCoordinateSystem accesses
Comments suppressed due to low confidence (2)

shared/src/gps/GpsLayer.cpp:136

  • [nitpick] The variable name threshold is generic. Consider renaming to something more descriptive, like positionChangeThreshold.
    auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;

shared/src/gps/GpsLayer.cpp:120

  • The indentation on this continued line is inconsistent with the project style. Align it with the opening parenthesis for clarity.
                mapCoordinateSystem.identifier, position);

}

// skip update for small position changes
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;

Copilot AI Jun 15, 2025

Copy link

Choose a reason for hiding this comment

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

The hard-coded multiplier 10 is a magic number. Consider defining a named constant (e.g., kMinUpdateDistanceScreenMeters) or documenting why 10 is chosen.

Suggested change
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * kMinUpdateDistanceScreenMeters;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On Android, this is usually a configuration value in the LocationProvider itself (so the client decides whats best). Shouldn't we make it configurable at least?


// skip update for small position changes
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;
if (this->position &&

Copilot AI Jun 15, 2025

Copy link

Choose a reason for hiding this comment

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

Using abs() on floating-point differences may invoke the integer overload. Use std::abs (from ) or std::fabs to ensure correct floating-point behavior.

Copilot uses AI. Check for mistakes.
}

// skip update for small position changes
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On Android, this is usually a configuration value in the LocationProvider itself (so the client decides whats best). Shouldn't we make it configurable at least?

@maerki maerki closed this Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants