forked from osmcode/libosmium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_osmium_project.sh
executable file
·96 lines (68 loc) · 1.85 KB
/
make_osmium_project.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#
# make_osmium_project.sh PROJECTNAME
#
# Creates a subdirectory named as the project in the current directory and
# adds a skeleton of files needed to begin a new project using the Osmium
# library.
#
if [ "x$1" = "x" ]; then
echo "Usage: $0 PROJECTNAME"
exit 1
fi
if [ -e "$1" ]; then
echo "Directory '$1' exists"
exit 1
fi
mkdir $1
cd $1
sed -e "s/__PROJECTNAME__/$1/g" >Makefile <<'__EOF__'
CXXFLAGS += -O3
#CXXFLAGS += -g
CXXFLAGS += -std=c++11 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CXXFLAGS += -I../include
OS:=$(shell uname -s)
ifeq ($(OS),Darwin)
CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif
CXXFLAGS_WARNINGS := -Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast
LIB_EXPAT := -lexpat
LIB_PBF := -pthread -lz -lprotobuf-lite -losmpbf
LIB_GZIP := -lz
LIB_BZIP2 := -lbz2
LIB_IO := $(LIB_EXPAT) $(LIB_PBF) $(LIB_GZIP) $(LIB_BZIP2)
PROGRAMS := __PROJECTNAME__
.PHONY: all clean
all: $(PROGRAMS)
__PROJECTNAME__: main.cpp
$(CXX) $(CXXFLAGS) $(CXXFLAGS_WARNINGS) -o $@ $< $(LDFLAGS) $(LIB_IO)
clean:
rm -f *.o core $(PROGRAMS)
__EOF__
cat >main.cpp <<'__EOF__'
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
#include <osmium/visitor.hpp>
class MyHandler : public osmium::handler::Handler {
public:
MyHandler() :
osmium::handler::Handler() {
}
void node(const osmium::Node& node) {
}
void way(const osmium::Way& way) {
}
void relation(const osmium::Relation& relation) {
}
}; // class MyHandler
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " OSMFILE\n";
exit(1);
}
MyHandler handler;
osmium::io::Reader reader(argv[1]);
osmium::apply(reader, handler);
}
__EOF__