de-templetize polyline generalizer

This commit is contained in:
Dennis Luxen 2013-11-13 17:33:19 -05:00
parent 1863e85bf5
commit 8f4b0c8078
3 changed files with 10 additions and 11 deletions

View File

@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DOUGLASPEUCKER_H_
#include "../DataStructures/Coordinate.h"
#include "../DataStructures/SegmentInformation.h"
#include <boost/assert.hpp>
@ -49,7 +50,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
static double DouglasPeuckerThresholds[19] = { 32000000., 16240000., 80240000., 40240000., 20000000., 10000000., 500000., 240000., 120000., 60000., 30000., 19000., 5000., 2000., 200, 16, 6, 3. , 3. };
template<class PointT>
class DouglasPeucker {
private:
typedef std::pair<std::size_t, std::size_t> PairOfPoints;
@ -60,8 +60,7 @@ private:
* This distance computation does integer arithmetic only and is about twice as fast as
* the other distance function. It is an approximation only, but works more or less ok.
*/
template<class CoordT>
inline int fastDistance(const CoordT& point, const CoordT& segA, const CoordT& segB) const {
inline int fastDistance(const FixedPointCoordinate& point, const FixedPointCoordinate& segA, const FixedPointCoordinate& segB) const {
const int p2x = (segB.lon - segA.lat);
const int p2y = (segB.lon - segA.lat);
const int something = p2x*p2x + p2y*p2y;
@ -86,7 +85,7 @@ private:
public:
void Run(std::vector<PointT> & input_geometry, const unsigned zoom_level) {
void Run(std::vector<SegmentInformation> & input_geometry, const unsigned zoom_level) {
{
BOOST_ASSERT_MSG(zoom_level < 19, "unsupported zoom level");
BOOST_ASSERT_MSG(1 < input_geometry.size(), "geometry invalid");

View File

@ -98,18 +98,18 @@ void DescriptionFactory::AppendEncodedPolylineString(
std::string & output
) {
if(return_encoded) {
pc.printEncodedString(pathDescription, output);
polyline_compressor.printEncodedString(pathDescription, output);
} else {
pc.printUnencodedString(pathDescription, output);
polyline_compressor.printUnencodedString(pathDescription, output);
}
}
void DescriptionFactory::AppendEncodedPolylineString(std::string &output) const {
pc.printEncodedString(pathDescription, output);
polyline_compressor.printEncodedString(pathDescription, output);
}
void DescriptionFactory::AppendUnencodedPolylineString(std::string &output) const {
pc.printUnencodedString(pathDescription, output);
polyline_compressor.printUnencodedString(pathDescription, output);
}
// void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLevel) {

View File

@ -45,8 +45,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* and produces the description plus the encoded polyline */
class DescriptionFactory {
DouglasPeucker<SegmentInformation> dp;
PolylineCompressor pc;
DouglasPeucker polyline_generalizer;
PolylineCompressor polyline_compressor;
PhantomNode start_phantom, target_phantom;
double DegreeToRadian(const double degree) const;
@ -202,7 +202,7 @@ public:
}
//Generalize poly line
dp.Run(pathDescription, zoomLevel);
polyline_generalizer.Run(pathDescription, zoomLevel);
//fix what needs to be fixed else
for(unsigned i = 0; i < pathDescription.size()-1 && pathDescription.size() >= 2; ++i){