Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.29k stars 3.32k forks source link

Don't save extra invalid values for segment indexed data #3178

Open TheMarex opened 7 years ago

TheMarex commented 7 years ago

Currently we need to save at least one invalid value in the forward and reverse weight vectors here and here.

We do this so that the index saved here works for all three vectors (even though the number of coordinates is always the number of segments plus one).

However we can save some space if we do some index arithmetic. By just omitting the invalid values we can compute the correct indices to the weight vectors as:

begin = id + m_compressed_geometry_index[id] and begin = id + 1 + m_compressed_geometry_index[id+1]. This would need an adaption in GetUncompressedForwardWeights and GetUncompressedBackwardWeights (and also the shared memory version of those functions).

/cc @jakepruitt @danpat

danpat commented 7 years ago

When https://github.com/Project-OSRM/osrm-backend/pull/3165 lands, there will only be the shared memory versions of those functions, no duplicates.