Skip to content

Conversation

@cs-util
Copy link

@cs-util cs-util commented Dec 27, 2025

No description provided.

…tionality for setting reference distances and measuring
…istance input modal for reference distance entry with validation and unit selection
…es for scale and measure markers and labels in the UI
…d rely on conversion function for improved clarity
…ility and integrate into distance validation
Achieved 100% Statement, Branch, Function, and Line coverage across all files in the src directory.
Added comprehensive test cases to transformations.test.js to cover:
Degenerate cases in fitHomography.
Singular matrices in invertHomography.
Jacobian calculations for affine and homography transforms.
Unsupported transform types in applyTransform and applyInverseTransform.
Added test cases to calibrator.test.js to cover:
Automatic origin computation in calibrateMap.
Edge cases in evaluateModel (e.g., infinite RMSE).
Defensive branches in accuracyRingRadiusPixels.
Code Refinement:

Simplified a redundant null check in accuracyRingRadiusPixels within calibrator.js to improve branch coverage and code clarity.
…ap calibration, improve fallback indicators, and enable live mode based on GPS points.
… position and enhance user feedback for missing scale.
…nd implement one-tap calibration functionality
…dPhotoMap function; update related test case
… ensure logic path is verified by state conditions
…add default rotation setting and refine prompt visibility logic
….md:100-112 to match the correct implementation in the source code.

Tests: I improved the test case in scale.test.js:379-385 to specifically assert that 0.6090m (which rounds to 12 inches) correctly results in 2' 0".
…to reflect the correct implementation of getMetersPerPixelFromCalibration. The documentation now correctly states that the calibration maps pixels directly to ENU coordinates (meters), eliminating the need for degree-to-meter conversions.

Removed Outdated Constant: I removed the unused METERS_PER_DEGREE_EQUATOR constant from scale.js:8, as it was part of the outdated logic and no longer needed.
Verified Implementation: I confirmed that the actual implementation in scale.js already correctly handled the scale extraction without the unnecessary conversion.
Fixed Lint Errors: I resolved a lint error in index.scale.test.js that was uncovered during the quality check process.
…fy reference scale and initial suggestion prompts
…ementation in transformations.js, which returns a structured object with scale, rotation, and translation instead of a raw matrix.

Calibration Layer: Updated the calibrateMap snippet to include the calibrate1Point helper function as it exists in calibrator.js, ensuring the return structure (including status, metrics, and quality) is consistent with the actual API
Extracting the hiding and showing logic into two new helper functions: hideInstantUsagePrompts() and showInstantUsagePrompts().
Replacing all manual manipulations of dom.instantUsagePrompts.classList with calls to these helpers.
Simplifying setPhotoImportState and beginPairMode by using the new hideInstantUsagePrompts() helper.
…convert rotation degrees (0, 90, 180, 270) into their corresponding labels ("North-up", "East-up", etc.).

Updated handleDistanceModalConfirm: Modified the toast message in index.js:1042 to dynamically include the selected rotation label when a 1-point calibration becomes active after setting the scale.
Updated handleOneTapClick: Modified the toast message in index.js:1137 to dynamically include the selected rotation label when a 1-point calibration is active after pinning a location
@gemini-code-assist
Copy link

Summary of Changes

Hello @cs-util, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the 'Instant Usage' feature, significantly enhancing the initial user experience by enabling measurement and live GPS tracking on imported maps with fewer calibration points. It achieves this through a new 1-point calibration method, a manual 'Set Scale' tool, and a streamlined quick-start flow. The changes involve updates to the core calibration logic, new UI components, and a refactored architecture for better testability and maintainability.

Highlights

  • Instant Usage Feature: Introduced a new 'Instant Usage' feature that allows immediate measurement and live GPS position tracking on imported maps with fewer calibration points.
  • 1-Point Calibration: Implemented a 1-point calibration method that assumes a North-up orientation and utilizes a manually provided scale, enabling early live position tracking.
  • Manual Scale Definition: Added a 'Set Scale' tool, allowing users to define a reference distance on the map image, which then enables accurate measurements even without GPS data.
  • UI/UX Enhancements: Integrated quick-start prompts, a one-tap calibration mode, global unit selection, default rotation settings, and persistence for user preferences and reference distances.
  • Code Refactoring & Testing: Refactored core application logic into a testable state machine for scale and measure modes, accompanied by comprehensive unit and integration tests to ensure robustness and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an impressive pull request that adds significant new functionality ("Instant Usage" via 1-point calibration and manual scale setting). The changes are extensive, touching math layers, calibration logic, UI, state management, and adding comprehensive documentation and tests. The code is well-structured, with good separation of concerns (e.g., extracting pure state machine logic from UI code). The addition of property-based tests is a great sign of quality.

I found a couple of issues: one high-severity bug in unit conversion logic that could lead to incorrect scale calculations, and one medium-severity logic issue in handling geolocation permissions. My review includes suggestions to fix these. Overall, this is a high-quality contribution.

Comment on lines +184 to +194
export function convertToMeters(value, unit) {
if (!Number.isFinite(value) || value <= 0) {
return null;
}
switch (unit) {
case 'ft':
return value / METERS_TO_FEET;
default:
return value;
}
}

Choose a reason for hiding this comment

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

high

The convertToMeters function doesn't handle the 'ft-in' unit, which is an option in the UI's distance input modal. When a user selects 'Feet & Inches', the default case in the switch statement is triggered, incorrectly treating the input value as meters instead of feet. This will lead to incorrect scale calculations.

Given the current UI has a single number input, a simple fix is to treat 'ft-in' the same as 'ft', assuming the user enters a decimal value for feet (e.g., 5.5 for 5' 6").

Additionally, it would be beneficial to add a unit test case for the 'ft-in' unit to prevent this from happening in the future.

Suggested change
export function convertToMeters(value, unit) {
if (!Number.isFinite(value) || value <= 0) {
return null;
}
switch (unit) {
case 'ft':
return value / METERS_TO_FEET;
default:
return value;
}
}
export function convertToMeters(value, unit) {
if (!Number.isFinite(value) || value <= 0) {
return null;
}
switch (unit) {
case 'ft':
case 'ft-in': // Assume decimal feet are entered for 'ft-in'
return value / METERS_TO_FEET;
default:
return value;
}
}

Comment on lines +1749 to +1753
if (status.state === 'granted') {
requestAndCenterOsmOnUser();
} else if (status.state === 'prompt' && shouldPrompt) {
doRequest();
}

Choose a reason for hiding this comment

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

medium

There's a small logic inconsistency here. When the geolocation permission is already 'granted', you call requestAndCenterOsmOnUser() directly. However, when the state is 'prompt', you call doRequest(), which not only calls requestAndCenterOsmOnUser() but also sets state.osmGeoPrompted = true.

This can lead to inconsistent state. If permission is already granted, state.osmGeoPrompted is never set.

To make the behavior consistent and more robust, I suggest calling doRequest() in the 'granted' case as well. This ensures state.osmGeoPrompted is always correctly updated.

Suggested change
if (status.state === 'granted') {
requestAndCenterOsmOnUser();
} else if (status.state === 'prompt' && shouldPrompt) {
doRequest();
}
if (status.state === 'granted') {
doRequest();
} else if (status.state === 'prompt' && shouldPrompt) {
doRequest();
}

@cs-util cs-util closed this Dec 27, 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.

2 participants