osrm-backend/include/extractor/query_node.hpp

59 lines
1.3 KiB
C++
Raw Normal View History

#ifndef QUERY_NODE_HPP
#define QUERY_NODE_HPP
2010-07-09 05:05:40 -04:00
2016-01-02 11:13:44 -05:00
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
2016-01-02 11:13:44 -05:00
#include "osrm/coordinate.hpp"
2014-11-24 11:57:01 -05:00
#include <limits>
2010-07-14 10:22:29 -04:00
2014-08-29 06:37:07 -04:00
struct QueryNode
2014-05-07 12:39:16 -04:00
{
using key_type = OSMNodeID; // type of NodeID
2016-01-05 06:04:04 -05:00
using value_type = int; // type of lat,lons
2014-05-07 12:39:16 -04:00
2016-01-05 06:04:04 -05:00
explicit QueryNode(int lat, int lon, OSMNodeID node_id) : lat(lat), lon(lon), node_id(node_id)
{
}
2014-08-29 06:37:07 -04:00
QueryNode()
2014-05-07 12:39:16 -04:00
: lat(std::numeric_limits<int>::max()), lon(std::numeric_limits<int>::max()),
node_id(SPECIAL_OSM_NODEID)
2014-05-07 12:39:16 -04:00
{
}
int lat;
int lon;
OSMNodeID node_id;
2014-05-07 12:39:16 -04:00
2014-08-29 06:37:07 -04:00
static QueryNode min_value()
2014-05-07 12:39:16 -04:00
{
2014-08-29 06:37:07 -04:00
return QueryNode(static_cast<int>(-90 * COORDINATE_PRECISION),
2016-01-05 06:04:04 -05:00
static_cast<int>(-180 * COORDINATE_PRECISION), MIN_OSM_NODEID);
2014-05-07 12:39:16 -04:00
}
2014-08-29 06:37:07 -04:00
static QueryNode max_value()
2014-05-07 12:39:16 -04:00
{
2014-08-29 06:37:07 -04:00
return QueryNode(static_cast<int>(90 * COORDINATE_PRECISION),
2016-01-05 06:04:04 -05:00
static_cast<int>(180 * COORDINATE_PRECISION), MAX_OSM_NODEID);
2014-05-07 12:39:16 -04:00
}
value_type operator[](const std::size_t n) const
{
switch (n)
{
case 1:
return lat;
case 0:
return lon;
default:
break;
}
BOOST_ASSERT_MSG(false, "should not happen");
return std::numeric_limits<int>::lowest();
2014-05-07 12:39:16 -04:00
}
2010-07-09 05:05:40 -04:00
};
#endif // QUERY_NODE_HPP