forked from organicmaps/organicmaps
[routing] Added route-ferry-motorcar type.
This commit is contained in:
parent
9978969d9d
commit
0dfe188b54
14 changed files with 243 additions and 27 deletions
|
@ -634,7 +634,9 @@ world +
|
|||
{}
|
||||
{}
|
||||
route +
|
||||
ferry -
|
||||
ferry +
|
||||
motorcar -
|
||||
{}
|
||||
{}
|
||||
shop +
|
||||
alcohol -
|
||||
|
|
|
@ -56947,6 +56947,149 @@ cont {
|
|||
}
|
||||
}
|
||||
}
|
||||
cont {
|
||||
name: "route-ferry-motorcar"
|
||||
element {
|
||||
scale: 10
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 3.0
|
||||
dd: 2.0
|
||||
}
|
||||
priority: 1174
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 11
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 3.0
|
||||
dd: 2.0
|
||||
}
|
||||
priority: 1174
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 12
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 3.0
|
||||
dd: 2.0
|
||||
}
|
||||
priority: 1375
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 13
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 3.0
|
||||
dd: 2.0
|
||||
}
|
||||
priority: 1411
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 14
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 3.0
|
||||
dd: 2.0
|
||||
}
|
||||
priority: 1474
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 15
|
||||
lines {
|
||||
width: 1.0
|
||||
color: 10075118
|
||||
dashdot {
|
||||
dd: 7.0
|
||||
dd: 5.0
|
||||
}
|
||||
priority: 1648
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 16
|
||||
lines {
|
||||
width: 2.0
|
||||
color: 11193565
|
||||
dashdot {
|
||||
dd: 12.0
|
||||
dd: 8.0
|
||||
}
|
||||
priority: 1834
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 17
|
||||
lines {
|
||||
width: 2.0
|
||||
color: 11193565
|
||||
dashdot {
|
||||
dd: 12.0
|
||||
dd: 8.0
|
||||
}
|
||||
priority: 1924
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 18
|
||||
lines {
|
||||
width: 2.0
|
||||
color: 11193565
|
||||
dashdot {
|
||||
dd: 12.0
|
||||
dd: 8.0
|
||||
}
|
||||
priority: 1924
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
element {
|
||||
scale: 19
|
||||
lines {
|
||||
width: 2.0
|
||||
color: 11193565
|
||||
dashdot {
|
||||
dd: 12.0
|
||||
dd: 8.0
|
||||
}
|
||||
priority: 1924
|
||||
join: ROUNDJOIN
|
||||
cap: BUTTCAP
|
||||
}
|
||||
}
|
||||
}
|
||||
cont {
|
||||
name: "shop"
|
||||
element {
|
||||
|
|
|
@ -986,3 +986,4 @@ internet_access|wlan;[internet_access=wlan];;name;int_name;985;
|
|||
amenity|waste_disposal;[amenity=waste_disposal];;name;int_name;986;
|
||||
amenity|bbq;[amenity=bbq];;name;int_name;987;
|
||||
hwtag|private;[hwtag=private];;name;int_name;988;
|
||||
route|ferry|motorcar;[route=ferry];;name;int_name;989;
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 371.
|
|
@ -986,3 +986,4 @@ internet_access|wlan
|
|||
amenity|waste_disposal
|
||||
amenity|bbq
|
||||
hwtag|private
|
||||
route|ferry|motorcar
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "feature_builder.hpp"
|
||||
|
||||
#include "../routing/vehicle_model.hpp"
|
||||
|
||||
#include "../indexer/feature_impl.hpp"
|
||||
#include "../indexer/feature_visibility.hpp"
|
||||
#include "../indexer/geometry_serialization.hpp"
|
||||
|
@ -175,13 +177,10 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
bool FeatureBuilder1::IsHighway() const
|
||||
bool FeatureBuilder1::IsRoad() const
|
||||
{
|
||||
/// @todo Add additional type for check "route-ferry-motorcar"
|
||||
/// when it will be added as separate type into classificator.
|
||||
|
||||
static feature::TypeSetChecker const checkHighway("highway");
|
||||
return checkHighway.IsEqualV(m_params.m_Types);
|
||||
static routing::CarModel const carModel;
|
||||
return carModel.IsRoad(m_params.m_Types);
|
||||
}
|
||||
|
||||
bool FeatureBuilder1::PreSerialize()
|
||||
|
@ -212,7 +211,7 @@ bool FeatureBuilder1::PreSerialize()
|
|||
case GEOM_LINE:
|
||||
{
|
||||
// We need refs for road's numbers.
|
||||
if (!IsHighway())
|
||||
if (!IsRoad())
|
||||
m_params.ref.clear();
|
||||
|
||||
m_params.rank = 0;
|
||||
|
@ -621,7 +620,7 @@ void FeatureBuilder2::Serialize(buffers_holder_t & data, serial::CodingParams co
|
|||
|
||||
uint64_t FeatureBuilder2::GetWayIDForRouting() const
|
||||
{
|
||||
if (m_osmIds.size() == 1 && m_osmIds[0].IsWay() && IsLine() && IsHighway())
|
||||
if (m_osmIds.size() == 1 && m_osmIds[0].IsWay() && IsLine() && IsRoad())
|
||||
return m_osmIds[0].OsmId();
|
||||
else
|
||||
return 0;
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
bool CheckValid() const;
|
||||
//@}
|
||||
|
||||
bool IsHighway() const;
|
||||
bool IsRoad() const;
|
||||
|
||||
protected:
|
||||
/// Used for features debugging
|
||||
|
|
|
@ -452,7 +452,7 @@ namespace feature
|
|||
points_t points;
|
||||
|
||||
// Do not change linear geometry for the upper scale.
|
||||
if (isLine && i == scalesStart && IsCountry() && fb.IsHighway())
|
||||
if (isLine && i == scalesStart && IsCountry() && fb.IsRoad())
|
||||
points = holder.GetSourcePoints();
|
||||
else
|
||||
SimplifyPoints(holder.GetSourcePoints(), points, level, isCoast, rect);
|
||||
|
|
|
@ -4,7 +4,7 @@ CONFIG -= app_bundle
|
|||
TEMPLATE = app
|
||||
|
||||
ROOT_DIR = ../..
|
||||
DEPENDENCIES = map generator indexer platform geometry coding base expat sgitess protobuf tomcrypt osrm
|
||||
DEPENDENCIES = generator map routing indexer platform geometry coding base expat sgitess protobuf tomcrypt osrm
|
||||
|
||||
include($$ROOT_DIR/common.pri)
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "../xml_element.hpp"
|
||||
#include "../osm2type.hpp"
|
||||
|
||||
#include "../../routing/vehicle_model.hpp"
|
||||
|
||||
#include "../../indexer/feature_data.hpp"
|
||||
#include "../../indexer/classificator.hpp"
|
||||
#include "../../indexer/classificator_loader.hpp"
|
||||
|
@ -537,3 +539,38 @@ UNIT_TEST(OsmType_Hwtag)
|
|||
TEST(params.IsTypeExist(GetType(tags[1])), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(OsmType_Ferry)
|
||||
{
|
||||
routing::CarModel carModel;
|
||||
|
||||
char const * arr[][2] = {
|
||||
{ "motorcar", "yes" },
|
||||
{ "highway", "primary" },
|
||||
{ "bridge", "yes" },
|
||||
{ "route", "ferry" },
|
||||
};
|
||||
|
||||
XMLElement e;
|
||||
FillXmlElement(arr, ARRAY_SIZE(arr), &e);
|
||||
|
||||
FeatureParams params;
|
||||
ftype::GetNameAndType(&e, params);
|
||||
|
||||
TEST_EQUAL(params.m_Types.size(), 2, (params));
|
||||
|
||||
char const * type1[] = { "highway", "primary", "bridge" };
|
||||
uint32_t type = GetType(type1);
|
||||
TEST(params.IsTypeExist(type), ());
|
||||
TEST(carModel.IsRoad(type), ());
|
||||
|
||||
char const * type2[] = { "route", "ferry", "motorcar" };
|
||||
type = GetType(type2);
|
||||
TEST(params.IsTypeExist(type), ());
|
||||
TEST(carModel.IsRoad(type), ());
|
||||
|
||||
char const * type3[] = { "route", "ferry" };
|
||||
type = GetType(type3);
|
||||
TEST(!params.IsTypeExist(type), ());
|
||||
TEST(!carModel.IsRoad(type), ());
|
||||
}
|
||||
|
|
|
@ -8,16 +8,15 @@
|
|||
namespace ftypes
|
||||
{
|
||||
|
||||
uint32_t BaseChecker::PrepareFeatureTypeToMatch(uint32_t featureType)
|
||||
uint32_t BaseChecker::PrepareToMatch(uint32_t type)
|
||||
{
|
||||
ftype::TruncValue(featureType, 2);
|
||||
return featureType;
|
||||
ftype::TruncValue(type, 2);
|
||||
return type;
|
||||
}
|
||||
|
||||
bool BaseChecker::IsMatched(uint32_t t) const
|
||||
bool BaseChecker::IsMatched(uint32_t type) const
|
||||
{
|
||||
ftype::TruncValue(t, 2);
|
||||
return (find(m_types.begin(), m_types.end(), t) != m_types.end());
|
||||
return (find(m_types.begin(), m_types.end(), PrepareToMatch(type)) != m_types.end());
|
||||
}
|
||||
|
||||
bool BaseChecker::operator() (feature::TypesHolder const & types) const
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace ftypes
|
|||
|
||||
class BaseChecker
|
||||
{
|
||||
bool IsMatched(uint32_t t) const;
|
||||
bool IsMatched(uint32_t type) const;
|
||||
|
||||
protected:
|
||||
vector<uint32_t> m_types;
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
bool operator() (FeatureType const & ft) const;
|
||||
bool operator() (vector<uint32_t> const & types) const;
|
||||
|
||||
static uint32_t PrepareFeatureTypeToMatch(uint32_t featureType);
|
||||
static uint32_t PrepareToMatch(uint32_t type);
|
||||
};
|
||||
|
||||
class IsStreetChecker : public BaseChecker
|
||||
|
|
|
@ -27,8 +27,6 @@ class Point2PhantomNode
|
|||
m2::PointD m_point;
|
||||
OsrmFtSegMapping const & m_mapping;
|
||||
|
||||
CarModel m_carModel;
|
||||
|
||||
struct Candidate
|
||||
{
|
||||
double m_dist;
|
||||
|
@ -49,7 +47,8 @@ public:
|
|||
|
||||
void operator() (FeatureType const & ft)
|
||||
{
|
||||
if (ft.GetFeatureType() != feature::GEOM_LINE || m_carModel.GetSpeed(ft) == 0)
|
||||
static CarModel const carModel;
|
||||
if (ft.GetFeatureType() != feature::GEOM_LINE || !carModel.IsRoad(ft))
|
||||
return;
|
||||
|
||||
Candidate res;
|
||||
|
|
|
@ -42,8 +42,13 @@ CarModel::CarModel()
|
|||
|
||||
VehicleModel::VehicleModel(Classificator const & c, vector<SpeedForType> const & speedLimits) : m_maxSpeed(0)
|
||||
{
|
||||
char const * arr[] = { "hwtag", "oneway" };
|
||||
m_onewayType = c.GetTypeByPath(vector<string>(arr, arr + 2));
|
||||
{
|
||||
char const * arr2[] = { "hwtag", "oneway" };
|
||||
m_onewayType = c.GetTypeByPath(vector<string>(arr2, arr2 + 2));
|
||||
|
||||
char const * arr3[] = { "route", "ferry", "motorcar" };
|
||||
m_ferryType = c.GetTypeByPath(vector<string>(arr3, arr3 + 3));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < speedLimits.size(); ++i)
|
||||
{
|
||||
|
@ -62,7 +67,7 @@ double VehicleModel::GetSpeed(feature::TypesHolder const & types) const
|
|||
double speed = m_maxSpeed * 2;
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
{
|
||||
uint32_t const type = ftypes::BaseChecker::PrepareFeatureTypeToMatch(types[i]);
|
||||
uint32_t const type = ftypes::BaseChecker::PrepareToMatch(types[i]);
|
||||
TypesT::const_iterator it = m_types.find(type);
|
||||
if (it != m_types.end())
|
||||
speed = min(speed, it->second.m_speed);
|
||||
|
@ -83,4 +88,27 @@ bool VehicleModel::IsOneWay(feature::TypesHolder const & types) const
|
|||
return types.Has(m_onewayType);
|
||||
}
|
||||
|
||||
bool VehicleModel::IsRoad(FeatureType const & f) const
|
||||
{
|
||||
feature::TypesHolder types(f);
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
if (IsRoad(types[i]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VehicleModel::IsRoad(vector<uint32_t> const & types) const
|
||||
{
|
||||
for (uint32_t t : types)
|
||||
if (IsRoad(t))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VehicleModel::IsRoad(uint32_t type) const
|
||||
{
|
||||
return (type == m_ferryType ||
|
||||
m_types.find(ftypes::BaseChecker::PrepareToMatch(type)) != m_types.end());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../std/vector.hpp"
|
||||
#include "../std/stdint.hpp"
|
||||
|
||||
|
||||
class Classificator;
|
||||
class FeatureType;
|
||||
|
||||
|
@ -40,11 +41,17 @@ public:
|
|||
double GetSpeed(feature::TypesHolder const & types) const;
|
||||
bool IsOneWay(feature::TypesHolder const & types) const;
|
||||
|
||||
bool IsRoad(FeatureType const & f) const;
|
||||
bool IsRoad(vector<uint32_t> const & types) const;
|
||||
bool IsRoad(uint32_t type) const;
|
||||
|
||||
private:
|
||||
double m_maxSpeed;
|
||||
|
||||
typedef unordered_map<uint32_t, SpeedForType> TypesT;
|
||||
TypesT m_types;
|
||||
uint32_t m_onewayType;
|
||||
|
||||
uint32_t m_onewayType, m_ferryType;
|
||||
};
|
||||
|
||||
class CarModel : public VehicleModel
|
||||
|
|
Loading…
Add table
Reference in a new issue