osrm-backend/DataStructures/NodeInformationHelpDesk.h

69 lines
2.2 KiB
C
Raw Normal View History

2010-07-09 05:05:40 -04:00
/*
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.
2010-07-26 04:17:52 -04:00
*/
2010-07-09 05:05:40 -04:00
#ifndef NODEINFORMATIONHELPDESK_H_
2010-07-09 05:05:40 -04:00
#define NODEINFORMATIONHELPDESK_H_
#include <fstream>
#include <iostream>
#include <vector>
#include "../typedefs.h"
#include "NNGrid.h"
#include "PhantomNodes.h"
2010-07-09 05:05:40 -04:00
typedef NNGrid::NNGrid Grid;
2010-07-09 05:05:40 -04:00
class NodeInformationHelpDesk{
public:
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput) { numberOfNodes = 0; int2ExtNodeMap = new vector<_Coordinate>(); g = new Grid(ramIndexInput,fileIndexInput); }
~NodeInformationHelpDesk() { delete int2ExtNodeMap; delete g; }
void initNNGrid(ifstream& in)
2010-07-26 04:17:52 -04:00
{
while(!in.eof())
{
NodeInfo b;
in.read((char *)&b, sizeof(b));
int2ExtNodeMap->push_back(_Coordinate(b.lat, b.lon));
numberOfNodes++;
}
in.close();
g->OpenIndexFiles();
2010-07-26 04:17:52 -04:00
}
2010-07-09 05:05:40 -04:00
int getLatitudeOfNode(const NodeID node) const { return int2ExtNodeMap->at(node).lat; }
2010-07-09 05:05:40 -04:00
int getLongitudeOfNode(const NodeID node) const { return int2ExtNodeMap->at(node).lon; }
2010-07-09 05:05:40 -04:00
NodeID getNumberOfNodes() const { return numberOfNodes; }
2010-07-09 05:05:40 -04:00
inline void findNearestNodeIDForLatLon(const _Coordinate coord, _Coordinate& result) { result = g->FindNearestPointOnEdge(coord); }
2010-07-09 05:05:40 -04:00
inline bool FindRoutingStarts(const _Coordinate start, const _Coordinate target, PhantomNodes * phantomNodes) {
g->FindRoutingStarts(start, target, phantomNodes);
}
private:
vector<_Coordinate> * int2ExtNodeMap;
Grid * g;
unsigned numberOfNodes;
};
2010-07-09 05:05:40 -04:00
#endif /*NODEINFORMATIONHELPDESK_H_*/