make entire_length variable a private member that cannot be set from the outside and only accessed thru a const getter.
This commit is contained in:
parent
b12decc865
commit
94288843f1
@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "../DataStructures/SegmentInformation.h"
|
#include "../DataStructures/SegmentInformation.h"
|
||||||
#include "../DataStructures/TurnInstructions.h"
|
#include "../DataStructures/TurnInstructions.h"
|
||||||
|
|
||||||
DescriptionFactory::DescriptionFactory() : entireLength(0) { via_indices.push_back(0); }
|
DescriptionFactory::DescriptionFactory() : entire_length(0) { via_indices.push_back(0); }
|
||||||
|
|
||||||
std::vector<unsigned> const &DescriptionFactory::GetViaIndices() const { return via_indices; }
|
std::vector<unsigned> const &DescriptionFactory::GetViaIndices() const { return via_indices; }
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ class DescriptionFactory
|
|||||||
|
|
||||||
std::vector<unsigned> via_indices;
|
std::vector<unsigned> via_indices;
|
||||||
|
|
||||||
|
double entire_length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct RouteSummary
|
struct RouteSummary
|
||||||
{
|
{
|
||||||
@ -72,8 +74,6 @@ class DescriptionFactory
|
|||||||
}
|
}
|
||||||
} summary;
|
} summary;
|
||||||
|
|
||||||
double entireLength;
|
|
||||||
|
|
||||||
// I know, declaring this public is considered bad. I'm lazy
|
// I know, declaring this public is considered bad. I'm lazy
|
||||||
std::vector<SegmentInformation> path_description;
|
std::vector<SegmentInformation> path_description;
|
||||||
DescriptionFactory();
|
DescriptionFactory();
|
||||||
@ -86,6 +86,11 @@ class DescriptionFactory
|
|||||||
JSON::Value AppendGeometryString(const bool return_encoded);
|
JSON::Value AppendGeometryString(const bool return_encoded);
|
||||||
std::vector<unsigned> const &GetViaIndices() const;
|
std::vector<unsigned> const &GetViaIndices() const;
|
||||||
|
|
||||||
|
double get_entire_length() const
|
||||||
|
{
|
||||||
|
return entire_length;
|
||||||
|
}
|
||||||
|
|
||||||
template <class DataFacadeT> void Run(const DataFacadeT *facade, const unsigned zoomLevel)
|
template <class DataFacadeT> void Run(const DataFacadeT *facade, const unsigned zoomLevel)
|
||||||
{
|
{
|
||||||
if (path_description.empty())
|
if (path_description.empty())
|
||||||
@ -152,7 +157,7 @@ class DescriptionFactory
|
|||||||
|
|
||||||
for (unsigned i = 1; i < path_description.size(); ++i)
|
for (unsigned i = 1; i < path_description.size(); ++i)
|
||||||
{
|
{
|
||||||
entireLength += path_description[i].length;
|
entire_length += path_description[i].length;
|
||||||
segment_length += path_description[i].length;
|
segment_length += path_description[i].length;
|
||||||
segment_duration += path_description[i].duration;
|
segment_duration += path_description[i].duration;
|
||||||
path_description[segment_start_index].length = segment_length;
|
path_description[segment_start_index].length = segment_length;
|
||||||
|
@ -149,7 +149,7 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
|||||||
shortest_path_segments);
|
shortest_path_segments);
|
||||||
json_result.values["route_instructions"] = json_route_instructions;
|
json_result.values["route_instructions"] = json_route_instructions;
|
||||||
}
|
}
|
||||||
description_factory.BuildRouteSummary(description_factory.entireLength,
|
description_factory.BuildRouteSummary(description_factory.get_entire_length(),
|
||||||
raw_route.shortest_path_length);
|
raw_route.shortest_path_length);
|
||||||
JSON::Object json_route_summary;
|
JSON::Object json_route_summary;
|
||||||
json_route_summary.values["total_distance"] = description_factory.summary.distance;
|
json_route_summary.values["total_distance"] = description_factory.summary.distance;
|
||||||
@ -231,7 +231,7 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
|||||||
json_result.values["alternative_instructions"] = json_alt_instructions;
|
json_result.values["alternative_instructions"] = json_alt_instructions;
|
||||||
}
|
}
|
||||||
alternate_description_factory.BuildRouteSummary(
|
alternate_description_factory.BuildRouteSummary(
|
||||||
alternate_description_factory.entireLength, raw_route.alternative_path_length);
|
alternate_description_factory.get_entire_length(), raw_route.alternative_path_length);
|
||||||
|
|
||||||
JSON::Object json_alternate_route_summary;
|
JSON::Object json_alternate_route_summary;
|
||||||
JSON::Array json_alternate_route_summary_array;
|
JSON::Array json_alternate_route_summary_array;
|
||||||
|
Loading…
Reference in New Issue
Block a user