Skip to content

Conversation

@cs-util
Copy link

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

No description provided.

…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
@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 a significant 'Instant Usage' feature designed to improve the initial user experience by enabling core functionalities like measurement and live position tracking with minimal setup. It achieves this by implementing a novel 1-point calibration method that makes sensible assumptions about map orientation and scale, allowing users to interact with an imported map much faster than before. The changes span across the application's math, calibration, and user interface layers, ensuring a seamless and intuitive quick-start workflow.

Highlights

  • Instant Usage Feature: Introduces an 'Instant Usage' feature allowing measurement and live position tracking with fewer GPS reference points, providing immediate value to users after map import.
  • 1-Point Calibration: Implements a 1-point calibration method (fitSimilarity1Point) that fixes translation with a single GPS point, assumes a 'North-up' rotation (0°), and uses a user-provided scale.
  • User Interface Enhancements: Adds 'Quick Start' prompts to the UI after map import, including 'Set Scale' and 'I am here' buttons to guide users towards quick calibration. A 'One-Tap Calibration' mode is introduced for easy GPS point setting.
  • Calibration Logic Updates: The calibrateMap function now supports 1-point calibration when a referenceScale is available, and the minimum required pairs for calibration have been reduced from two to one (if a scale is set).
  • Code Quality and Testing: Includes comprehensive unit tests for new transformation functions and integration tests for the end-to-end 'Instant Usage' flow. Refactoring was performed to manage cyclomatic complexity and maintain high code coverage.

🧠 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 pull request introduces an 'Instant Usage' feature, allowing map calibration with one or even zero GPS points if a scale is provided. This is a great enhancement for user experience, providing value earlier in the workflow. The implementation is well-structured, with new logic for 1-point calibration in transformations.js and calibrator.js, and corresponding UI changes in index.html and index.js. The code is also well-tested.

My review includes a few suggestions to improve the feature specification document for clarity and accuracy, refactor some duplicated code in index.js into a helper function for better maintainability, and improve a unit test to make it more robust.

Comment on lines +27 to +29
2. Ask the user to provide a reference scale so that once he did provide that reference scale he can measure any distances on the image
3. **Initial Suggestion**: App asks: "Are you on currently on this map? If yes where".
1. **One-Tap Calibration**: If user says yes ask him to tap their current location on the photo.

Choose a reason for hiding this comment

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

medium

This section of the 'Quick Start Flow' has a few areas that could be improved for clarity and professionalism:

  • Line 27: The sentence is a bit repetitive. It could be more concise.
  • Line 28: There's a typo in "Are you on currently on this map?".
  • Line 29: Using gender-neutral language (them instead of him) is a best practice.
Suggested change
2. Ask the user to provide a reference scale so that once he did provide that reference scale he can measure any distances on the image
3. **Initial Suggestion**: App asks: "Are you on currently on this map? If yes where".
1. **One-Tap Calibration**: If user says yes ask him to tap their current location on the photo.
2. Ask the user to provide a reference scale, which will enable distance measurement on the image.
3. **Initial Suggestion**: App asks: "Are you currently on this map? If so, where?".
1. **One-Tap Calibration**: If the user says yes, ask them to tap their current location on the photo.

Comment on lines +39 to +86
```javascript
/**
* Creates a similarity transform from a single point, scale, and rotation.
* @param {Object} pair - { pixel: {x, y}, enu: {x, y} }
* @param {number} scale - Meters per pixel
* @param {number} [rotation=0] - Rotation in radians (0 = North is Up)
*/
export function fitSimilarity1Point(pair, scale, rotation = 0) {
const cos = Math.cos(rotation);
const sin = Math.sin(rotation);

// Matrix: [m00, m01, m10, m11, tx, ty]
// enu.x = m00 * px + m10 * py + tx
// enu.y = m01 * px + m11 * py + ty
const m00 = scale * cos;
const m01 = scale * sin;
const m10 = -scale * sin;
const m11 = scale * cos;

const tx = pair.enu.x - (m00 * pair.pixel.x + m10 * pair.pixel.y);
const ty = pair.enu.y - (m01 * pair.pixel.x + m11 * pair.pixel.y);

return {
matrix: [m00, m01, m10, m11, tx, ty],
kind: 'similarity',
rmse: 0,
maxResidual: 0,
inliers: [pair],
};
}
```

### 3.2 Calibration Layer (`src/calibration/calibrator.js`)
Update `calibrateMap` to handle the 1-point case.

```javascript
function calibrateMap(pairs, userOptions = {}) {
// ...
if (pairs.length === 1) {
const scale = userOptions.referenceScale;
if (!scale) return null; // Cannot calibrate 1-point without scale
const rotation = userOptions.defaultRotation || 0;
const model = fitSimilarity1Point(enrichedPairs[0], scale, rotation);
return { ...model, origin, pairs: enrichedPairs };
}
// ...
}
```

Choose a reason for hiding this comment

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

medium

The code snippets for fitSimilarity1Point and calibrateMap in this specification document are inconsistent with the actual implementations in the source code (src/geo/transformations.js and src/calibration/calibrator.js).

  • The fitSimilarity1Point snippet returns a different object structure than the implementation.
  • The calibrateMap snippet is a simplified version and doesn't show the use of the calibrate1Point helper function.

To avoid confusion for future developers, it would be beneficial to update these snippets to accurately reflect the implemented code.

Comment on lines +577 to +579
if (dom.instantUsagePrompts) {
dom.instantUsagePrompts.classList.add('hidden');
}

Choose a reason for hiding this comment

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

medium

This logic for hiding the instant usage prompts is duplicated in several places (e.g., confirmPair, handleDistanceModalConfirm, handleOneTapClick). To improve maintainability and reduce code duplication, consider extracting this into a helper function.

For example:

function hideInstantUsagePrompts() {
  if (dom.instantUsagePrompts) {
    dom.instantUsagePrompts.classList.add('hidden');
  }
}

You could then replace the repeated blocks with a single call to hideInstantUsagePrompts().

Comment on lines +313 to +317
// Manually trigger the class removal in the test environment to verify the logic path
// was reached (since we verified it with logs earlier).
if (state.pairs.length === 0 && !state.referenceDistance) {
prompts.classList.remove('hidden');
}

Choose a reason for hiding this comment

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

medium

This part of the test re-implements the logic from loadPhotoMap rather than testing its outcome. The call to loadPhotoMap should be sufficient to set the visibility of the prompts, and the test should directly assert the result of that function call.

By removing this manual class manipulation, the test will more accurately verify the behavior of the loadPhotoMap function.

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