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
@cs-util cs-util closed this Dec 27, 2025
@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 significant new functionality to enhance the application's map calibration and measurement capabilities. It enables users to quickly get started with maps by defining a manual scale or using a single GPS point with default assumptions, allowing for immediate distance measurements and live position tracking. A robust mechanism for defining precise reference distances is now available, which can be used independently of GPS or to improve the accuracy and stability of GPS-based calibrations. These extensive changes are supported by a refactored codebase with improved modularity and comprehensive testing.

Highlights

  • Instant Usage Feature: Introduced the 'Instant Usage' feature, allowing users to get immediate value from an imported map with zero or one GPS reference points. This enables measurement and live position tracking by making sensible assumptions (North is up, perfect top-down view) and requiring a manual scale.
  • Manual Reference Distance & Measurement Tool: Implemented a robust 'Manual Reference Distance' feature, enabling users to define a map's scale by drawing a line and inputting a real-world distance. This allows for precise measurements independently of GPS data and integrates with existing calibration.
  • Hybrid Calibration Logic: Enhanced the calibration pipeline to support a hybrid approach, where a manual reference scale can constrain or validate GPS-derived scales, improving the stability and accuracy of transformations, especially with limited GPS points.
  • Modular State Management & UI Refactor: Refactored UI interaction logic into dedicated state machine modules (src/scale/scale-mode.js) and utility functions (src/scale/scale.js), promoting cleaner code, better testability, and separation of concerns for scale and measurement modes.
  • Comprehensive Testing: Added extensive unit, integration, and property-based tests for the new mathematical transformations, scale calculation utilities, and UI interaction flows, ensuring the reliability and correctness of the new features.
  • User Interface & Persistence: Updated the UI with new controls for setting scale, measuring distances, selecting preferred display units (meters, feet, feet & inches), and quick-start prompts. User preferences and manual reference distances are now persisted using localStorage.

🧠 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 introduces significant new functionality for "Instant Usage" and manual scale references. The implementation is of very high quality, demonstrating excellent software engineering practices. The features are well-documented in the new specification files, the code is cleanly refactored with a great separation of concerns (e.g., extracting pure state machine logic), and the test coverage is exceptionally thorough, including unit, integration, and property-based tests.

My review includes a couple of medium-severity suggestions for improving maintainability and user experience:

  • Moving inline CSS from index.html to a separate file.
  • Replacing the native confirm() dialog with a custom modal for a more consistent UI.

Overall, this is a fantastic contribution that greatly enhances the application's capabilities. The changes are well-thought-out and robustly implemented.

Comment on lines +11 to +35
<style>
/* Custom marker and label styles for scale/measure features */
.scale-marker-dot {
width: 14px;
height: 14px;
border: 2px solid white;
border-radius: 50%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.distance-label {
color: white;
padding: 2px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
white-space: nowrap;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
transform: translate(-50%, -100%);
margin-top: -4px;
}
.distance-label--measure {
padding: 3px 10px;
font-size: 13px;
}
</style>

Choose a reason for hiding this comment

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

medium

The new CSS rules for markers and labels are currently defined in an inline <style> block. While this works, it's generally better for maintainability to keep styles in separate .css files. This separates concerns (structure vs. presentation) and allows for better caching and organization, especially as the project grows.

Consider moving these styles to a new CSS file (e.g., css/custom.css) and linking it in the <head>.

if (btn) {
L.DomEvent.on(btn, 'click', (e) => {
L.DomEvent.stopPropagation(e);
if (confirm('Delete reference scale?')) {

Choose a reason for hiding this comment

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

medium

The code uses a native confirm() dialog to ask the user for confirmation before deleting a reference scale. While functional, confirm() is a blocking call that freezes the UI, and its appearance is inconsistent across different browsers and operating systems.

For a more polished and consistent user experience, it would be better to use a custom modal dialog that matches the application's visual style, similar to the one implemented for entering a distance.

For example:

// Replace confirm() with a custom modal for a better UX
showConfirmationModal('Delete reference scale?', () => {
  state.referenceDistance = null;
  clearReferenceVisualization();
  recalculateCalibration();
  saveSettings();
});

This would require implementing a generic showConfirmationModal function but would improve the overall UX.

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