Skip to content

Conversation

kilianvolmer
Copy link
Contributor

@kilianvolmer kilianvolmer commented Aug 11, 2025

Changes and Information

Please briefly list the changes (main added features, changed items, or corrected bugs) made:

  • Moved GeographicLocation to memilio/geography/locations.h
  • Added a distance calculation for two GeographicLocations on the sphere
  • Added a wrapper for boosts r-Tree to work with GeographicLocation

If need be, add additional information and what the reviewer should look out for in particular:

Merge Request - Guideline Checklist

Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.

Checks by code author

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation within the code (Doxygen) for new functionality has been added in the code
  • Appropriate external documentation (ReadTheDocs) for new functionality has been added to the online documentation
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

Closes #1342

@kilianvolmer kilianvolmer changed the title 1342 make geographic location available to all of m emilio 1342 make geographic location available to all of MEmilio Aug 11, 2025
@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.27%. Comparing base (08a6cf0) to head (267ca7e).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1346    +/-   ##
========================================
  Coverage   97.26%   97.27%            
========================================
  Files         176      179     +3     
  Lines       15439    15545   +106     
========================================
+ Hits        15017    15121   +104     
- Misses        422      424     +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

kilianvolmer and others added 2 commits September 3, 2025 10:59
Co-authored-by: Carlotta Gerstein <100771374+charlie0614@users.noreply.github.com>
Co-authored-by: Martin J. Kühn <62713180+mknaranja@users.noreply.github.com>
/**
* @brief Test the r-Tree Constructor given a vector
*/
TEST_F(TestGeography, rtreeConstructionVector)
Copy link
Member

Choose a reason for hiding this comment

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

I think you should rather test that the constructor does what it is supposed to do rather than just test that it runs without an error.

Copy link
Contributor

@HenrZu HenrZu left a comment

Choose a reason for hiding this comment

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

looks great :) I think its a nice additions. I left a few comments. When done, we can merge it.

kilianvolmer and others added 3 commits October 6, 2025 11:29
@kilianvolmer kilianvolmer requested a review from HenrZu October 9, 2025 07:38
Co-authored-by: HenrZu <69154294+HenrZu@users.noreply.github.com>
Comment on lines 107 to 111
void check_input() const
{
assert(m_latitude <= 90. && m_latitude >= -90. && "Latitude must be in [-90, 90]");
assert(m_longitude <= 180. && m_longitude >= -180. && "Longitude must be in [-180, 180]");
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be private. Also please add a short @brief that this (only) calls asserts.

Copy link
Member

Choose a reason for hiding this comment

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

A possible alternative to using asserts, would be to add a "parse" member function

static IOResult<GeographicalLocation> parse(ScalarType, ScalarType);

that constructs a location for valid coordinates and returns an error otherwise. This would make sense if we use this for user input a lot.

* @param radius The radius of the query in kilometers.
* @return Vector with indices of the points found.
*/
std::vector<size_t> inrange_indices_approximate(const IsSphericalLocation auto& location, double radius) const
Copy link
Member

Choose a reason for hiding this comment

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

I am slightly confused by this "inrange", is this an established phrase? Is the name indices_in_radius_approximate better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that inrange is an established phrase. At least I can show you other packages using it.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, but it seems like it is still meant as "in range", and not a single word, right? So it should be "in_range" in our naming convention.

I still slightly prefer my suggenstion "indices_in_radius_approximate": I feel like "indices_in_range_approximate" is a more intuitive order. And we ask for a radius, rather than a range (in the sense of std::ranges).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me my naming feels more natural. Especially I would start with the inrange as this is the first thing you think of when searching for this function.

Copy link
Member

Choose a reason for hiding this comment

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

as this is the first thing you think of when searching for this function

No, I would not think of that. And typing "inrange" in most IDEs should bring up "indices_in_range" as well.

Anyways, we should not break our naming conventions for this, so please use "in_range".

Comment on lines 92 to 103
template <IsSphericalLocationIterator Iter>
RTree(Iter first, Iter last)
: rtree{}
{
size_t index = 0;
while (first != last) {
Point point(first->get_longitude(), first->get_latitude());
rtree.insert(Node(point, index));
++first;
++index;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this constructor, when the vector version already exists?
A while loop over user provided iterators is a common source of segfaults or infinite loops, so I would prefer to remove this. In most cases, the vector constructor can be used equivalently via RTree({begin(), end()}).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't this give more flexibility for data not stored in vectors?

Copy link
Member

Choose a reason for hiding this comment

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

Not really, RTree({begin(), end()}) can be used with any iterable. It creates a vector from two iterators, then uses the construction from vector. At worst, you have an additional copy of the elements.

You could change the vector constructor, so that it takes a std::ranges::range instead, and make use of a range based for loop. But I honestly think the vector is enough.

kilianvolmer and others added 4 commits October 16, 2025 09:43
Co-authored-by: reneSchm <49305466+reneSchm@users.noreply.github.com>
…o' of github.com:SciCompMod/memilio into 1342-Make-GeographicLocation-available-to-all-of-MEmilio
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.

Make GeographicLocation available for all of MEmilio

5 participants