Commit Graph

134 Commits

Author SHA1 Message Date
Daniel J. Hofmann
94af9b7f13 Caches iterators instead of invoking function calls on every iteration.
This caches iterators, i.e. especially the end iterator when possible.

The problem:

    for (auto it = begin(seq); it != end(seq); ++it)

this has to call `end(seq)` on every iteration, since the compiler is
not able to reason about the call's site effects (to bad, huh).

Instead do it like this:

    for (auto it = begin(seq), end = end(seq); it != end; ++it)

caching the end iterator.

Of course, still better would be:

    for (auto&& each : seq)

if all you want is value semantics.

Why `auto&&` you may ask? Because it binds to everything and never copies!

Skim the referenced proposal (that was rejected, but nevertheless) for a
detailed explanation on range-based for loops and why `auto&&` is great.

Reference:

- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3853.htm
2015-09-15 12:09:39 +02:00
Patrick Niklaus
8e02263084 Fix off-by one error in decoder and make padding deterministic. 2015-09-14 23:01:38 +02:00
Patrick Niklaus
a95bf64ccf Fix processing for data files with incorrect node references 2015-09-10 12:22:03 +02:00
Daniel J. Hofmann
db092c828e Don't pass by const-value for a read-only view.
I can't see a reason we pass by const-value here.

Note: changes API because of the `route_parameters` header.
2015-09-08 23:34:20 +02:00
Daniel J. Hofmann
bcc41bf3d1 Fixes undefined behavior from shifting into signed bit; use unsigned literal instead 2015-09-06 01:11:54 +02:00
Lauren Budorick
bac6703f8e Implement raster source feature to read data from third-party sources, to be used in lua profiles.
* Adds a data structure, RasterSource, to store parsed + queryable data
* Adds bindings for that and relevant data structures as well as source_function and segment_function
* Adds relevant unit tests and cucumber tests
* Bring-your-own-data feature
2015-09-03 22:28:18 -07:00
Patrick Niklaus
70bb082973 Fix endless loop 2015-09-03 17:02:34 +02:00
Patrick Niklaus
262b380280 Candidate query for match is now only depending on gps_precision 2015-09-03 17:02:33 +02:00
Patrick Niklaus
c30c144120 Move matching default in route_parameters.cpp 2015-09-03 17:02:33 +02:00
Huyen Chau Nguyen
74e00cf652 fix some small issues:
remove empty unit test

remove compiler directives

move trip related files from routing_algorithms to algorithms

run clang-format on files

fix all std::size_t related issues

improve code by adding std::move()s

clean up includes

fixing several code stye and improvement issues

add several small code improvements

return single scc in SplitUnaccessibleLocations() when theres only one

change ComputeRoute() to return an InternalRouteResult by value

improve some code style issues
2015-09-01 15:20:35 +02:00
Huyen Chau Nguyen
e773a80b06 remove possibility to choose algorithm but only use brute force and farthest insertion 2015-09-01 15:20:34 +02:00
Huyen Chau Nguyen
e6eea67eeb rename all names with round_trip, trip or tsp to trip to standardize the naming 2015-09-01 15:20:34 +02:00
Huyen Chau Nguyen
2de3fc9f6f fix GetAdjacendEdgeRange of matrix wrapper for tarjan scc and fix wrongly solved merge conflict 2015-09-01 15:20:34 +02:00
Huyen Chau Nguyen
78a8cf6982 add a wrapper for the distance table for better access 2015-09-01 15:20:34 +02:00
Huyen Chau Nguyen
3061c8b854 solve merge conflicts 2015-09-01 15:20:34 +02:00
Chau Nguyen
6191b6bee2 add parameter to choose algorithm for tsp calculation and remove redundant code 2015-09-01 15:20:33 +02:00
Chau Nguyen
b15f8f68e4 refactor and improve the round trip computation of multiple SCCs
Problem:
- old solution was slow
- depending on the result of TarjanSCC, new distance tables and new phantom node vectors were created to run tsp on it

Solution:
- dont create new distance tables and phantom node vectors
- pass an additional vector with the information which locations are in the same component and ignore all others

fix bug for scc split computation
2015-09-01 15:20:33 +02:00
Daniel J. Hofmann
62b20769ee Modernize the code base to C++11 standards and beyond.
Apply `clang-modernize` (based on Clang 3.6) transformations to the
codebase while making sure to support Clang>=3.4 and GCC>=4.8.

We apply the transformations in parallel to speed up the quite
time consuming process, and use our `clang-format` style file
to automatically format the code respecting our coding conventions.

We use the following self-explanatory transformations:

* AddOverride
* LoopConvert
* PassByValue
* ReplaceAutoPtr
* UseAuto
* UseNullptr

This required a `compile_commands.json` compilation database, e.g.

    ccmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1

for CMake or check Bear for a Makefile based solution (or even Ninja).

    git ls-files -x '*.cpp|*.h' | \
      xargs -I{} -P $(nproc) clang-modernize -p build -final-syntax-check -format -style=file -summary -for-compilers=clang-3.4,gcc-4.8 -include . -exclude third_party {}

Boom!

References:

* http://clang.llvm.org/extra/clang-modernize.html
* http://clang.llvm.org/extra/ModernizerUsage.html
2015-08-18 12:56:34 +02:00
Patrick Niklaus
49adf2192a Move calculate_coordinate to algorithms/
Fixes #1367
2015-08-12 13:02:18 +02:00
Patrick Niklaus
c2f0e4f683 Implement correct const iterator for DeallocatingVector 2015-08-06 11:13:25 +02:00
Patrick Niklaus
2621f4a2fa Allow any input format for StaticGraph and check if edge list is sorted 2015-08-06 11:13:25 +02:00
MoKob
b526cadebd Initial version of core ch
This improves preprocessing times in favour of worse query performance.
Core size can be set over the --core parameater, default is the old
behaviour to fully contract the graph.
2015-08-01 18:00:48 +02:00
Patrick Niklaus
021a1c7a39 Restructure the construction of the undirected graph 2015-07-01 18:07:29 +02:00
Patrick Niklaus
faa880d60a Remove unused memebers and rename to currrent style convention 2015-07-01 18:07:29 +02:00
Patrick Niklaus
fd30e82836 Add graph compressor unit tests 2015-07-01 18:07:29 +02:00
Patrick Niklaus
3ef34fbb56 Rename GeometryCompressor and add unit tests 2015-07-01 18:07:29 +02:00
Patrick Niklaus
7345dc6861 Move graph compression code outside of EBGF 2015-07-01 18:07:29 +02:00
Patrick Niklaus
9958937fd1 At least check 4*LEAF_SIZE edges before returning none. 2015-07-01 17:57:03 +02:00
Andreas Gruß
9b0d3dfaeb polyline string as parameter added 2015-06-02 12:09:46 +02:00
Patrick Niklaus
2777d53a12 Direct edges in contractor correctly and add better graph validation. 2015-06-01 17:22:12 +02:00
Patrick Niklaus
3065de63dd Move renumbering and edge deduplication in extractor 2015-06-01 17:22:12 +02:00
Patrick Niklaus
a57fb4f1ab First step into overhauling the edge storage 2015-06-01 17:22:12 +02:00
Patrick Niklaus
4cab617c25 Fix Coverity issue by initializing member 2015-05-29 09:13:28 +02:00
Patrick Niklaus
17a4463f59 More assertions 2015-05-28 15:18:48 +02:00
Patrick Niklaus
1164a65df8 Refactor processing_chain by splitting into sub functions 2015-05-28 15:18:48 +02:00
Patrick Niklaus
5c0a964321 Remove unused code SimpleNodeBasedDynamicGraph 2015-05-28 12:43:55 +02:00
Patrick Niklaus
4c03ace9eb Remove pruning in IncrementalFindPhantomNode 2015-05-25 02:07:01 +02:00
Patrick Niklaus
fd9bb3ac43 Only activate pruning for big cc after one was found 2015-05-18 09:41:41 +02:00
Patrick Niklaus
1b0d8739c1 Increase max distance to 1100 to fix unrelated test cases 2015-05-15 00:34:34 +02:00
Patrick Niklaus
c4c6ab2494 Use distance based search radius
This limits the nearest neighbour search to a maximum distance
of 1000 meters, but will also work in dense areas.
2015-05-14 22:24:07 +02:00
Patrick Niklaus
345dd2481b Add documentation to InputRestrictionContainer 2015-04-21 20:00:58 +02:00
Patrick Niklaus
006bcc0fc8 Add some documentation to the restriction parser 2015-04-21 20:00:58 +02:00
Patrick Niklaus
52592b84fd Add functions to find reverse edge to DynamicGraph 2015-04-17 00:22:51 +02:00
Patrick Niklaus
f2cd68e3ec Return SPECIAL_EDGEID if no edge was found 2015-04-17 00:21:57 +02:00
Dennis Luxen
aff590a44d make implementation of FindEdge consistent among graph implementations, introduce FindSmallestEdge() function to return the edge with smallest weight if there are multiple, fixes #1427 2015-04-16 16:12:08 +02:00
Dennis Luxen
0eb2106067 reorder includes, add tuple include 2015-04-16 14:30:52 +02:00
Dennis Luxen
c03aec364c add comparison tool for graph classes 2015-04-16 11:25:43 +02:00
Patrick Niklaus
a372ade7ce Mark suspicious transitions 2015-04-13 22:39:55 +02:00
Dennis Luxen
8ee82d1e03 replace old-style typefs with using 2015-03-23 17:06:10 +01:00
Patrick Niklaus
028fad94af Fix overflows when handling size_t 2015-03-08 00:53:15 +01:00