PhantomNodes get transmitted as well. The client is supposed to send us
this information whenever it's possible.
This commit is contained in:
parent
0cd06be13a
commit
c273351d4a
58
Algorithms/ObjectToBase64.h
Normal file
58
Algorithms/ObjectToBase64.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
open source routing machine
|
||||
Copyright (C) Dennis Luxen, others 2010
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU AFFERO General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
or see http://www.gnu.org/licenses/agpl.txt.
|
||||
*/
|
||||
|
||||
#ifndef OBJECTTOBASE64_H_
|
||||
#define OBJECTTOBASE64_H_
|
||||
|
||||
#include <boost/archive/iterators/base64_from_binary.hpp>
|
||||
#include <boost/archive/iterators/binary_from_base64.hpp>
|
||||
#include <boost/archive/iterators/transform_width.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
typedef
|
||||
boost::archive::iterators::base64_from_binary<
|
||||
boost::archive::iterators::transform_width<string::const_iterator, 6, 8>
|
||||
> base64_t;
|
||||
|
||||
typedef
|
||||
boost::archive::iterators::transform_width<
|
||||
boost::archive::iterators::binary_from_base64<string::const_iterator>, 8, 6
|
||||
> binary_t;
|
||||
|
||||
template<class ToEncodeT>
|
||||
static void EncodeObjectToBase64(const ToEncodeT & object, std::string& encoded) {
|
||||
assert(0 == encoded.length());
|
||||
char * pointerToOriginalObject = (char *)&object;
|
||||
encoded = std::string(base64_t(pointerToOriginalObject), base64_t(pointerToOriginalObject+sizeof(ToEncodeT)));
|
||||
}
|
||||
|
||||
template<class ToEncodeT>
|
||||
static void DecodeObjectFraBase64(ToEncodeT & object, const std::string& encoded) {
|
||||
char * pointerToDecodedObject = (char *)&object;
|
||||
std::string dec(binary_t(encoded.begin()), binary_t(encoded.begin() + encoded.length() - 1));
|
||||
std::copy ( dec.begin(), dec.end(), pointerToDecodedObject );
|
||||
}
|
||||
|
||||
#endif /* OBJECTTOBASE64_H_ */
|
@ -21,10 +21,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#ifndef JSON_DESCRIPTOR_H_
|
||||
#define JSON_DESCRIPTOR_H_
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include "BaseDescriptor.h"
|
||||
#include "DescriptionFactory.h"
|
||||
#include "../Algorithms/ObjectToBase64.h"
|
||||
#include "../DataStructures/SegmentInformation.h"
|
||||
#include "../DataStructures/TurnInstructions.h"
|
||||
#include "../Util/Azimuth.h"
|
||||
@ -173,14 +174,17 @@ public:
|
||||
reply.content += ", \"hint_array\": [";
|
||||
|
||||
for(unsigned i = 0; i < rawRoute.segmentEndCoordinates.size(); ++i) {
|
||||
unsigned hint = ((rawRoute.segmentEndCoordinates[i].startPhantom.edgeBasedNode << 1) + rawRoute.segmentEndCoordinates[i].startPhantom.isBidirected());
|
||||
intToString(hint, tmp);
|
||||
reply.content += tmp;
|
||||
reply.content += ", ";
|
||||
std::string hint;
|
||||
reply.content += "\"";
|
||||
EncodeObjectToBase64(rawRoute.segmentEndCoordinates[i].startPhantom, hint);
|
||||
reply.content += hint;
|
||||
reply.content += "\", ";
|
||||
}
|
||||
intToString(((rawRoute.segmentEndCoordinates.back().targetPhantom.edgeBasedNode << 1)+ rawRoute.segmentEndCoordinates.back().targetPhantom.isBidirected()), tmp);
|
||||
reply.content += tmp;
|
||||
reply.content += "]";
|
||||
std::string hint;
|
||||
EncodeObjectToBase64(rawRoute.segmentEndCoordinates.back().targetPhantom, hint);
|
||||
reply.content += "\"";
|
||||
reply.content += hint;
|
||||
reply.content += "\"]";
|
||||
reply.content += "},";
|
||||
reply.content += "\"transactionId\": \"OSRM Routing Engine JSON Descriptor (v0.3)\"";
|
||||
reply.content += "}";
|
||||
|
Loading…
Reference in New Issue
Block a user