Question: I am a asked to write a function that takes a LatLon as input (LatLon is a class with 2 doubles: latitude and longitude) and

I am a asked to write a function that takes a "LatLon" as input (LatLon is a class with 2 doubles: latitude and longitude) and returns the the ID (int) of the closest intersection to that position. I am given functions that return the location of any intersection, and also that return the distance between two positions. Because of "performance tests", my instructors have suggested me to store the locations of all Intersections in a R-Tree (from the boost library), where it would be faster to find the closest intersection, rather than iterating over all the intersections. However, I am just learning how R-Trees work, and I am having trouble in how to create one.

The problem is that I have seen several examples online where they create R-Trees, but what really confuses me is that they only use two arguments, rather than four, in one of the constructors. For example, they use:

bgi::rtree > rtree_;

where value_t is a pair of box and unsigned int, and the other argument is the size, however if I try to make:

bgi::rtree> intersectionRTree;

where point is a pair of unsigned int and LatLon, the compiler complains that i am not using the proper constructor, and that it should have four arguments instead of two.

I have read online, and find that I should be using this constructor:

rtree(parameters_type const &, indexable_getter const &, value_equal const &, allocator_type const &)

However, I don't understand the description of each argument, so I don't know how to use this constructor. So, can you please help me to understand what to do? And if possible, could you give me short example? Thank you very much.

This is the LatLon class. It is read only, so I cannot modify it:

I am a asked to write a function that takes a "LatLon"

This is what I m trying to do:

as input (LatLon is a class with 2 doubles: latitude and longitude)

The function getIntersectionPosition returns a LatLon, intersectionNumber is the maximum number of intersections, and intersection is the index of a intersection.

The compiler gives me along error detail that only sends me to another files, but actually never tolds me where I am wrong.

class LatLont public: LatLon()0 explicit LatLon(float lat_. float lon_) m_lat (lat_),m_1on (lon_)) double lat() const double lon() const return m_lat; return m_lon; private: float m_latstd::numeric_limits::quiet_NaN) float m_lonstd::numeric_limits::quiet_NaN) friend class boost::serialization: :access templatecclass Archive void serialize (Archive& ar, unsigned int) ar & m_lat & m_lon; std: :ostream& operators(std: :ostream& os, LatLon); std: :arraycLatLon,4> bounds_to_corners(std::pair LatLon, LatLon> bounds); class LatLont public: LatLon()0 explicit LatLon(float lat_. float lon_) m_lat (lat_),m_1on (lon_)) double lat() const double lon() const return m_lat; return m_lon; private: float m_latstd::numeric_limits::quiet_NaN) float m_lonstd::numeric_limits::quiet_NaN) friend class boost::serialization: :access templatecclass Archive void serialize (Archive& ar, unsigned int) ar & m_lat & m_lon; std: :ostream& operators(std: :ostream& os, LatLon); std: :arraycLatLon,4> bounds_to_corners(std::pair LatLon, LatLon> bounds)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!