Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

@pm-dimagi pm-dimagi commented Jun 13, 2025

Product Description

Mp fix from long Lat input to Lat Lng duplicate of the master PR
checked for valid coordinates of lat lng

Technical Summary

Safety Assurance

Safety story

Automated test coverage

QA Plan

Special deploy instructions

  • This PR can be deployed after merge with no further considerations.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations.

Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change.

Duplicate PR

Automatically duplicate this PR as defined in contributing.md.

Summary by CodeRabbit

  • Documentation

    • Updated documentation for polygon-related functions to clarify that coordinates should be provided in latitude-longitude order, including revised parameter descriptions and example usage.
  • Tests

    • Adjusted all polygon-related test cases to use latitude-longitude coordinate order.
    • Added new test cases for additional point-in-polygon scenarios and improved coverage.
    • Removed tests for invalid polygon inputs.

@pm-dimagi pm-dimagi requested a review from shubham1g5 June 13, 2025 06:29
@coderabbitai
Copy link

coderabbitai bot commented Jun 13, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The documentation and test cases for polygon-related XPath functions were updated to use latitude-longitude coordinate order instead of longitude-latitude. Changes were made to parameter descriptions, example usages, and test data to reflect this new convention. No implementation or public API changes were made.

Changes

Files Change Summary
src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java,
src/main/java/org/javarosa/xpath/expr/XPathIsPointInsidePolygonFunc.java
Updated documentation comments to specify coordinates as latitude-longitude instead of longitude-latitude.
src/test/java/org/javarosa/xpath/test/XPathEvalTest.java Updated and expanded test cases to use latitude-longitude order; added new edge cases; removed some invalid polygon tests.

Sequence Diagram(s)

sequenceDiagram
    participant TestSuite as XPathEvalTest
    participant XPathFunc as XPath Function (closest-point-on-polygon / is-point-inside-polygon)
    participant Polygon as Polygon Data

    TestSuite->>XPathFunc: Call function with "lat lon" ordered coordinates
    XPathFunc->>Polygon: Parse coordinates (lat, lon)
    Polygon-->>XPathFunc: Polygon structure
    XPathFunc-->>TestSuite: Result (using lat-lon order)
Loading

Possibly related PRs

Suggested labels

cross requested

Suggested reviewers

  • shubham1g5

Poem

A hop and a skip, the order is new,
Latitude first, longitude in view!
Polygons and points, now clear as the sun,
Tests and docs aligned—our work is done.
🐇✨
From east to west, the code’s now right,
Mapping the world in a rabbit’s delight!

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch pm_map_fix
  • Post Copyable Unit Tests in Comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java (1)

21-23: ⚠️ Potential issue

Fix typo in signature – polygon_cordpolygon_coords

- *     closest-point-on-polygon(point_coord,polygon_cord)
+ *     closest-point-on-polygon(point_coord, polygon_coords)
🧹 Nitpick comments (6)
src/main/java/org/javarosa/xpath/expr/XPathIsPointInsidePolygonFunc.java (2)

26-28: Clarify parameter wording for consistency

The second bullet still says “lat/lon pairs”, re-introducing the slash you just removed elsewhere.
To avoid another round of confusion, stick to the exact wording “lat lon pairs”.

-   <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs …
+   <li><code>polygon_coords</code>: A space-separated string of lat lon pairs …

36-39: Trim the trailing space in the example input

The example string has a stray space after the first coordinate which may be copied into forms verbatim and break parsing.

-     is-point-inside-polygon('27.174957 78.041309 ','27.174957 …
+     is-point-inside-polygon('27.174957 78.041309','27.174957 …
src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java (2)

37-40: Minor: add space after comma in example call

For readability and to match the actual syntax used in tests.

-closest-point-on-polygon('27.176 78.041','27.174957 …
+closest-point-on-polygon('27.176 78.041', '27.174957 …

55-57: Use consistent wording – “lat lon” instead of “Lat Lng”

The rest of the doc now standardises on “lat lon”.

- * Returns the point on polygon closest to the geopoint, in "Lat Lng", …
+ * Returns the point on polygon closest to the geopoint, in "lat lon" format, …
src/test/java/org/javarosa/xpath/test/XPathEvalTest.java (2)

660-670: Duplicate test – remove one copy

The block appears twice with identical inputs and expected output, providing no extra coverage and lengthening the suite.

-        testEval(
-                "closest-point-on-polygon('27.175 91.043','27.174957 91.041309 27.174884 91.042574 27.175493 91.042661 27.175569 91.041383')",
-                null, null, "27.175057319999997 91.04259876");

681-683: Second duplicate of the same assertion

Same call/expectation already present above; safe to delete.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca7c66 and 68637ca.

📒 Files selected for processing (3)
  • src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java (2 hunks)
  • src/main/java/org/javarosa/xpath/expr/XPathIsPointInsidePolygonFunc.java (2 hunks)
  • src/test/java/org/javarosa/xpath/test/XPathEvalTest.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed

Comment on lines +26 to 29
* <li><code>point_coord</code>: A single point as "lat lon eg('27.175 78.043')"</li>
* <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs (e.g. "'27.174957 78.041309 27
* .174884 78.042574 27.175493 78.042661 27.175569 78.041383'")</li>
* </ul>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Re-format Javadoc bullets – example breaks the list and HTML

  1. The example is inserted right inside the quoted string, making the sentence hard to read.
  2. A newline splits the literal string and leaves the <li> open, which causes malformed Javadoc.

Suggested minimal patch:

-   <li><code>point_coord</code>: A single point as "lat lon eg('27.175 78.043')"</li>
-   <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs (e.g. "'27.174957 78.041309
-   .174884 78.042574 27.175493 78.042661 27.175569 78.041383'")</li>
+   <li><code>point_coord</code>: A single point in <code>"lat lon"</code> format
+       (e.g. <code>"27.175 78.043"</code>)</li>
+   <li><code>polygon_coords</code>: Space-separated <code>lat lon</code> pairs,
+       e.g. <code>"27.174957 78.041309 27.174884 78.042574 27.175493 78.042661 27.175569 78.041383"</code></li>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* <li><code>point_coord</code>: A single point as "lat lon eg('27.175 78.043')"</li>
* <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs (e.g. "'27.174957 78.041309 27
* .174884 78.042574 27.175493 78.042661 27.175569 78.041383'")</li>
* </ul>
* <li><code>point_coord</code>: A single point in <code>"lat lon"</code> format
* (e.g. <code>"27.175 78.043"</code>)</li>
* <li><code>polygon_coords</code>: Space-separated <code>lat lon</code> pairs,
* e.g. <code>"27.174957 78.041309 27.174884 78.042574 27.175493 78.042661 27.175569 78.041383"</code></li>
🤖 Prompt for AI Agents
In src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java
around lines 26 to 29, the Javadoc list items are malformed because the example
string is broken by a newline and the example is embedded inside the quoted
string, breaking the list structure. Fix this by moving the example outside the
quoted string and ensuring the entire <li> element is on one continuous line
without line breaks, so the list renders correctly and the example is clearly
separated from the string literal.

@pm-dimagi pm-dimagi merged commit 7ebdd13 into commcare_2.57 Jun 13, 2025
1 of 2 checks passed
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.

3 participants