Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

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

Product Description

Convert the input type from Lng Lat to Lat Lng format
Added test cases to verify same

Technical Summary

Safety Assurance

Safety story

Automated test coverage

Added test cases to verify the changes

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, with revised examples and descriptions.
  • Tests

    • Adjusted test cases for polygon functions to use latitude-longitude coordinate order.
    • Added new test cases to improve coverage for various polygon scenarios.
    • Removed outdated tests for invalid polygons.

@pm-dimagi pm-dimagi requested a review from shubham1g5 June 12, 2025 15:04
@coderabbitai
Copy link

coderabbitai bot commented Jun 12, 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 coordinate order for polygon-related XPath functions and their documentation was changed from "longitude latitude" to "latitude longitude". Documentation comments and example usages were updated to reflect this, and test cases were revised and expanded to use the new coordinate order. No changes were made to implementation logic.

Changes

File(s) Change Summary
src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java,
src/main/java/org/javarosa/xpath/expr/XPathIsPointInsidePolygonFunc.java
Updated documentation comments and examples to use "latitude longitude" coordinate order.
src/test/java/org/javarosa/xpath/test/XPathEvalTest.java Updated and expanded tests to use "latitude longitude" order; added new cases; removed invalid polygon tests.

Suggested labels

cross requested, Release Note

Suggested reviewers

  • shubham1g5

Poem

A rabbit hops with latitude first,
Longitude second, to quench its thirst.
Polygons checked, points find their place,
In tests and docs, all coordinates embrace.
With every hop, the order’s right,
Geometry’s joy, code shining bright! 🐇✨

✨ 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: 0

🧹 Nitpick comments (4)
src/main/java/org/javarosa/xpath/expr/XPathIsPointInsidePolygonFunc.java (1)

26-28: Parameter order in Javadoc contradicts both syntax line and implementation

is-point-inside-polygon(point_coord, polygon_coords) (line 21) – and the method body – expect the point first, polygon second.
The list below reverses them (polygon_coords, then point_coord). This will mislead API users.

- *   <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs …</li>
- *   <li><code>point_coord</code>: A single point as "lat lon"</li>
+ *   <li><code>point_coord</code>:  A single point as "lat lon"</li>
+ *   <li><code>polygon_coords</code>: A space-separated string of lat/lon pairs …</li>
src/main/java/org/javarosa/xpath/expr/XPathClosestPointOnPolygonFunc.java (1)

24-29: Same Javadoc parameter-order mismatch as above

The implementation (closestPointToPolygon) unpacks the first arg as the point and the second as the polygon, but the list documents them in the opposite order. Please swap to avoid confusion.

Also, the sample string on line 26/27 is split by an unintended newline (27 .174884). Consider joining the literal so Javadoc renders correctly.

src/test/java/org/javarosa/xpath/test/XPathEvalTest.java (2)

613-619: Redundant duplicate test block

The two closest-point-on-polygon('27.176 78.041', …) assertions are identical (lines 613-615 and 617-619). Keeping both adds runtime with no coverage gain.

-        testEval(
-                "closest-point-on-polygon('27.176 78.041','27.174957 78.041309 27.174884 78.042574 27.175493 78.042661 27.175569 78.041383')",
-                null, null, "27.175569 78.041383");

666-687: Potentially unintended longitude/latitude reversal & further duplicates

  1. The input '27.175 91.040' etc. follow the new lat lon convention, but one case ('91.043 27.176', line 688-690) reverts to lon lat. Please confirm this is deliberate.

  2. Several calls are repeated twice with identical expectations (lines 666-675 vs 685-687). Removing the duplicates keeps the suite concise.

📜 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 f2d9bb1.

📒 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 (1)
  • GitHub Check: build

testEval("is-point-inside-polygon('78.0187201 27.203509','78.0186987 27.2043773 78.0187201 27.203509')", null, null,
new XPathException(
"Invalid polygon: Self-intersection")); // Only 2 points, not a polygon
"closest-point-on-polygon('91.043 27.176','27.174957 91.041309 27.174884 91.042574 27.175493 91.042661 27.175569 91.041383')",
Copy link
Contributor

Choose a reason for hiding this comment

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

how is it working given we are doing lat long now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expected 27.175569 91.041383, got 27.175493 91.042661 when put the right lat lng
Its the case when point is near the edge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

according to the chat gpt the correct answer is "27.17505732 91.04259876" but on deep dive into it i got the reply
(27.175493, 91.042661) → (27.175569, 91.041383) any value range from here is correct depends on the deviations and maths calculation

@pm-dimagi pm-dimagi requested a review from shubham1g5 June 12, 2025 18:36
@pm-dimagi pm-dimagi merged commit b1c4f3e into master Jun 13, 2025
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 13, 2025
3 tasks
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