2012-08-27 11:40:59 -04:00
|
|
|
/*
|
|
|
|
|
2013-10-14 07:42:28 -04:00
|
|
|
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
|
|
|
All rights reserved.
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-10-14 07:42:28 -04:00
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-10-14 07:42:28 -04:00
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
other materials provided with the distribution.
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-10-14 07:42:28 -04:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-10-14 07:42:28 -04:00
|
|
|
*/
|
2012-08-27 11:40:59 -04:00
|
|
|
|
|
|
|
#ifndef RESTRICTION_H_
|
|
|
|
#define RESTRICTION_H_
|
|
|
|
|
2013-08-14 05:59:46 -04:00
|
|
|
#include "../typedefs.h"
|
2014-01-29 05:31:39 -05:00
|
|
|
|
|
|
|
#include <limits>
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-08-14 05:59:46 -04:00
|
|
|
struct TurnRestriction {
|
2012-08-27 11:40:59 -04:00
|
|
|
NodeID viaNode;
|
|
|
|
NodeID fromNode;
|
|
|
|
NodeID toNode;
|
|
|
|
struct Bits { //mostly unused
|
2013-08-14 05:59:46 -04:00
|
|
|
Bits()
|
|
|
|
:
|
2013-07-08 08:51:55 -04:00
|
|
|
isOnly(false),
|
|
|
|
unused1(false),
|
|
|
|
unused2(false),
|
|
|
|
unused3(false),
|
|
|
|
unused4(false),
|
|
|
|
unused5(false),
|
|
|
|
unused6(false),
|
2013-08-14 05:59:46 -04:00
|
|
|
unused7(false)
|
|
|
|
{ }
|
2013-07-08 08:51:55 -04:00
|
|
|
|
2013-07-08 04:27:41 -04:00
|
|
|
bool isOnly:1;
|
|
|
|
bool unused1:1;
|
|
|
|
bool unused2:1;
|
|
|
|
bool unused3:1;
|
|
|
|
bool unused4:1;
|
|
|
|
bool unused5:1;
|
|
|
|
bool unused6:1;
|
|
|
|
bool unused7:1;
|
2012-08-27 11:40:59 -04:00
|
|
|
} flags;
|
|
|
|
|
2014-04-16 10:59:40 -04:00
|
|
|
explicit TurnRestriction(NodeID viaNode) :
|
2013-08-14 05:59:46 -04:00
|
|
|
viaNode(viaNode),
|
2014-01-29 05:31:39 -05:00
|
|
|
fromNode(std::numeric_limits<unsigned>::max()),
|
|
|
|
toNode(std::numeric_limits<unsigned>::max()) {
|
2013-07-08 08:51:55 -04:00
|
|
|
}
|
|
|
|
|
2014-04-16 10:59:40 -04:00
|
|
|
explicit TurnRestriction(const bool isOnly = false) :
|
2013-07-08 08:51:55 -04:00
|
|
|
viaNode(UINT_MAX),
|
|
|
|
fromNode(UINT_MAX),
|
|
|
|
toNode(UINT_MAX) {
|
2012-08-27 11:40:59 -04:00
|
|
|
flags.isOnly = isOnly;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-13 15:23:44 -05:00
|
|
|
struct InputRestrictionContainer {
|
2012-08-27 11:40:59 -04:00
|
|
|
EdgeID fromWay;
|
|
|
|
EdgeID toWay;
|
|
|
|
unsigned viaNode;
|
2013-11-13 15:23:44 -05:00
|
|
|
TurnRestriction restriction;
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-11-13 15:23:44 -05:00
|
|
|
InputRestrictionContainer(
|
2013-08-14 05:59:46 -04:00
|
|
|
EdgeID fromWay,
|
|
|
|
EdgeID toWay,
|
|
|
|
NodeID vn,
|
|
|
|
unsigned vw
|
|
|
|
) :
|
|
|
|
fromWay(fromWay),
|
|
|
|
toWay(toWay),
|
|
|
|
viaNode(vw)
|
|
|
|
{
|
|
|
|
restriction.viaNode = vn;
|
|
|
|
}
|
2014-04-16 10:59:40 -04:00
|
|
|
explicit InputRestrictionContainer(
|
2013-08-14 05:59:46 -04:00
|
|
|
bool isOnly = false
|
|
|
|
) :
|
2014-01-29 05:31:39 -05:00
|
|
|
fromWay(std::numeric_limits<unsigned>::max()),
|
|
|
|
toWay(std::numeric_limits<unsigned>::max()),
|
|
|
|
viaNode(std::numeric_limits<unsigned>::max())
|
2013-08-14 05:59:46 -04:00
|
|
|
{
|
|
|
|
restriction.flags.isOnly = isOnly;
|
|
|
|
}
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2013-11-13 15:23:44 -05:00
|
|
|
static InputRestrictionContainer min_value() {
|
|
|
|
return InputRestrictionContainer(0, 0, 0, 0);
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
2013-11-13 15:23:44 -05:00
|
|
|
static InputRestrictionContainer max_value() {
|
2014-01-09 10:13:35 -05:00
|
|
|
return InputRestrictionContainer(
|
2014-01-29 05:31:39 -05:00
|
|
|
std::numeric_limits<unsigned>::max(),
|
|
|
|
std::numeric_limits<unsigned>::max(),
|
|
|
|
std::numeric_limits<unsigned>::max(),
|
|
|
|
std::numeric_limits<unsigned>::max()
|
2014-01-09 10:13:35 -05:00
|
|
|
);
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-09 10:13:35 -05:00
|
|
|
struct CmpRestrictionContainerByFrom {
|
2013-11-13 15:23:44 -05:00
|
|
|
typedef InputRestrictionContainer value_type;
|
|
|
|
inline bool operator()(
|
|
|
|
const InputRestrictionContainer & a,
|
|
|
|
const InputRestrictionContainer & b
|
|
|
|
) const {
|
2012-08-27 11:40:59 -04:00
|
|
|
return a.fromWay < b.fromWay;
|
|
|
|
}
|
2013-11-13 15:23:44 -05:00
|
|
|
inline value_type max_value() const {
|
|
|
|
return InputRestrictionContainer::max_value();
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
2013-11-13 15:23:44 -05:00
|
|
|
inline value_type min_value() const {
|
|
|
|
return InputRestrictionContainer::min_value();
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-09 10:13:35 -05:00
|
|
|
struct CmpRestrictionContainerByTo {
|
2013-11-13 15:23:44 -05:00
|
|
|
typedef InputRestrictionContainer value_type;
|
2014-01-09 10:13:35 -05:00
|
|
|
inline bool operator()(
|
2013-11-13 15:23:44 -05:00
|
|
|
const InputRestrictionContainer & a,
|
|
|
|
const InputRestrictionContainer & b
|
|
|
|
) const {
|
2012-08-27 11:40:59 -04:00
|
|
|
return a.toWay < b.toWay;
|
|
|
|
}
|
2013-11-13 15:23:44 -05:00
|
|
|
value_type max_value() const {
|
|
|
|
return InputRestrictionContainer::max_value();
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
2013-11-13 15:23:44 -05:00
|
|
|
value_type min_value() const {
|
|
|
|
return InputRestrictionContainer::min_value();
|
2012-08-27 11:40:59 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* RESTRICTION_H_ */
|