Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Initial version
- Loading branch information
0 parents
commit cb0da48
Showing
18 changed files
with
1,976 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
CXX=g++ | ||
CXXFLAGS=-W -Wall -ansi -pedantic -g -Wno-deprecated | ||
LDFLAGS=-lexpat -lbz2 -lpq -lboost_program_options -lboost_filesystem | ||
EXEC=osm4routing | ||
|
||
all: $(EXEC) | ||
|
||
osm4routing: parameters.o main.o osmreader.o bz2reader.o stdinreader.o csvwriter.o pqwriter.o | ||
$(CXX) -o $@ $^ $(LDFLAGS) | ||
|
||
main.o: main.cc main.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
parameters.o: parameters.cc main.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
osmreader.o: osmreader.cc osmreader.h reader.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
bz2reader.o: bz2reader.cc bz2reader.h reader.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
stdinreader.o: stdinreader.cc stdinreader.h reader.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
csvwriter.o: csvwriter.cc csvwriter.h writer.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
pqwriter.o: pqwriter.cc pqwriter.h writer.h | ||
$(CXX) -o $@ -c $< $(CXXFLAGS) | ||
|
||
clean: | ||
rm -rf *.o | ||
|
||
mrproper: clean | ||
rm -rf $(EXEC) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* 0.0 | ||
First public release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
This file is part of osm4routing. | ||
osm4routing is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Mumoro 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 General Public License | ||
along with osm4routing. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "bz2reader.h" | ||
#include <iostream> | ||
#include <cerrno> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
|
||
using namespace std; | ||
BZReader::BZReader(const std::string & filename) | ||
{ | ||
FILE* fp = fopen64(filename.c_str(), "rb"); | ||
if(!fp) | ||
{ | ||
std::cout << std::endl; | ||
std::cerr << "Error opening file " << filename << " errorno " << errno << " " << strerror(errno) << std::endl; | ||
exit(1); | ||
} | ||
|
||
b = BZ2_bzReadOpen ( &bzerror, fp, 0, 0, NULL, 0 ); | ||
if ( bzerror != BZ_OK ) | ||
{ | ||
std::cerr << "Error opening file " << filename << " as bzip2 file, errno " << bzerror << " " << | ||
BZ2_bzerror(b, &bzerror) << std::endl; | ||
BZ2_bzReadClose ( &bzerror, b ); | ||
} | ||
} | ||
|
||
int BZReader::read(char * buff, int buffsize) | ||
{ | ||
return BZ2_bzRead ( &bzerror, b, buff, buffsize ); | ||
} | ||
|
||
bool BZReader::eof() const | ||
{ | ||
return bzerror == BZ_STREAM_END; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
This file is part of osm4routing. | ||
osm4routing is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Mumoro 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 General Public License | ||
along with osm4routing. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "reader.h" | ||
#include <bzlib.h> | ||
#include <string> | ||
|
||
#ifndef _BZ2READER_H | ||
#define _BZ2READER_H | ||
class BZReader : public Reader | ||
{ | ||
BZFILE* b; | ||
int bzerror; | ||
public: | ||
BZReader(const std::string & filename); | ||
int read(char * buff, int buffsize); | ||
bool eof() const; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
This file is part of osm4routing. | ||
osm4routing is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Mumoro 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 General Public License | ||
along with osm4routing. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "csvwriter.h" | ||
|
||
using namespace std; | ||
|
||
CSVWriter::CSVWriter(const std::string & nodes_file, const std::string & edges_filename): | ||
nodes_filename(nodes_file) | ||
{ | ||
edges_file.open(edges_filename.c_str()); | ||
edges_file << setprecision(9); | ||
edges_file << "\"edge_id\",\"source\",\"target\",\"length\",\"car\",\"car reverse\",\"bike\",\"bike reverse\",\"foot\",\"WKT\"" << endl; | ||
} | ||
|
||
int CSVWriter::save_nodes(const NodeMapType & nodes) | ||
{ | ||
ofstream nodes_file; | ||
nodes_file.open (nodes_filename.c_str()); | ||
// By default outstream only give 4 digits after the dot (~10m precision) | ||
nodes_file << setprecision(9); | ||
nodes_file << "\"node_id\",\"longitude\",\"latitude\"" << endl; | ||
int nodes_inserted = 0; | ||
|
||
for(NodeMapType::const_iterator i = nodes.begin(); i != nodes.end(); i++) | ||
{ | ||
if( (*i).second.uses > 1 ) | ||
{ | ||
nodes_file << (*i).first << "," << | ||
(*i).second.lon << "," << | ||
(*i).second.lat << endl; | ||
nodes_inserted++; | ||
} | ||
} | ||
nodes_file.close(); | ||
return nodes_inserted; | ||
} | ||
|
||
void CSVWriter::save_edge(int edge_id, | ||
node_t source, node_t target, float length, | ||
char car_direct, char car_rev, | ||
char bike_direct, char bike_rev, | ||
char foot, | ||
std::string geom) | ||
{ | ||
edges_file << edge_id << "," << source << "," << target << "," | ||
<< length << "," | ||
<< car_direct << "," << car_rev << "," | ||
<< bike_direct << "," << bike_rev << "," | ||
<< foot << "," | ||
<< "LINESTRING(\"" << geom << "\")" << endl; | ||
} | ||
|
||
|
||
CSVWriter::~CSVWriter() | ||
{ | ||
edges_file.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
This file is part of osm4routing. | ||
osm4routing is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Mumoro 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 General Public License | ||
along with osm4routing. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "writer.h" | ||
#include <iostream> | ||
|
||
#ifndef _CSVWRITER_H | ||
#define _CSVWRITER_H | ||
|
||
class CSVWriter : public Writer | ||
{ | ||
std::ofstream edges_file; | ||
std::string nodes_filename; | ||
public: | ||
CSVWriter(const std::string & nodes_fn, const std::string & edges_fn); | ||
|
||
int save_nodes(const NodeMapType & nodes); | ||
|
||
void save_edge(int edge_id, | ||
node_t source, node_t target, float length, | ||
char car, char car_d, | ||
char bike, char bike_d, | ||
char foot, | ||
std::string geom); | ||
|
||
~CSVWriter(); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.