-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.cpp
105 lines (92 loc) · 4.01 KB
/
sample.cpp
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
96
97
98
99
100
101
102
103
104
105
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include "ExpPublic.h"
#include "ExpDispLine.h"
namespace fs = boost::filesystem;
ExpDiaDBHandler diadb_load(void) {
ExpBool memMapSw = EXP_FALSE;
// ダイヤDB生成
const fs::path dia_d_path("data/dia");
ExpDiaDataFileList dia_entry_list;
dia_entry_list = ExpDiaDB_NewFileList();
BOOST_FOREACH(const fs::path& p, std::make_pair(fs::directory_iterator(dia_d_path),
fs::directory_iterator())) {
if (!fs::is_directory(p)) {
ExpDiaDB_AddFileList3(p.c_str(), EXP_IO_LEVEL_HIGH, memMapSw, dia_entry_list);
}
}
ExpErr err;
ExpDiaDBHandler db =ExpDiaDB_Initiate( dia_entry_list, 0, &err);
ExpDiaDB_DeleteFileList(dia_entry_list);
return db;
}
ExpDataHandler data_load(ExpDiaDBHandler diadb_h) {
ExpBool memMapSw = EXP_FALSE;
// DB生成
ExpBool load_english_data = EXP_FALSE;
ExpFileID dummy_file_id;
const fs::path knb_d_path("data/knb");
ExpDataFileList knb_entry_list = ExpDB_NewFileList();
BOOST_FOREACH(const fs::path& p, std::make_pair(fs::directory_iterator(knb_d_path),
fs::directory_iterator())) {
if (!fs::is_directory(p)) {
ExpDB_AddFileList3( p.c_str(), EXP_IO_LEVEL_HIGH, memMapSw, knb_entry_list, dummy_file_id);
}
}
ExpErr err;
ExpDataHandler db = ExpDB_Initiate( knb_entry_list, diadb_h, load_english_data, &err);
ExpDB_DeleteFileList(knb_entry_list);
return db;
}
void output_result(ExpRouteResHandler searchResult) {
int routeCount = ExpRoute_GetRouteCount(searchResult);
ExpChar name[512];
for(int routeNo = 1; routeNo<=routeCount; routeNo++) {
int railCount = ExpCRoute_GetRailCount(searchResult, routeNo);
std::cout << "route" << routeNo << "================================" << std::endl;
for(int railNo = 1; railNo<=railCount; railNo++) {
ExpCRouteRPart_GetStationName( searchResult, routeNo, railNo, EXP_LANG_JAPANESE, name, 512, EXP_FALSE);
std::cout << name << std::endl;
ExpCRouteRPart_GetRailName( searchResult, routeNo, railNo, EXP_LANG_JAPANESE, name, 512, EXP_FALSE);
std::cout << name << std::endl;
}
ExpCRouteRPart_GetStationName( searchResult, routeNo, railCount+1, EXP_LANG_JAPANESE, name, 512, EXP_FALSE);
std::cout << name << std::endl;
}
}
int main() {
ExpDiaDBHandler diadb_h = diadb_load();
ExpDataHandler db_handler = data_load(diadb_h);
// 表示線区情報
ExpErr err;
ExpDLineData_Initiate(db_handler, diadb_h, "data/displine/dlinemst.dat", "data/displine/ptn_match.dat", &err);
// 探索
ExpNaviHandler navi_handler = ExpNavi_NewHandler(db_handler, &err);
ExpStationCode code1;
ExpStationCode code2;
ExpStation_SetEmptyCode(&code1);
ExpStation_SetEmptyCode(&code2);
ExpStation_SharedCodeToCode( db_handler, 22828, &code1);
ExpStation_SharedCodeToCode( db_handler, 25853, &code2);
ExpNavi_SetStationEntry( navi_handler, 1, &code1 );
ExpNavi_SetStationEntry( navi_handler, 2, &code2 );
//出発
ExpInt16 searchMode = 0;
ExpDate searchDate = 20150625;
ExpInt16 searchTime = 600;
ExpDiaVehicles vehicles;
ExpDiaVehicles_Clear(&vehicles, EXP_TRUE);
ExpRouteResHandler searchResult = ExpRoute_DiaSearch( navi_handler,
searchMode,
searchDate,
searchTime,
nullptr,
0,
&vehicles );
output_result(searchResult);
ExpNavi_DeleteHandler(navi_handler);
ExpRoute_Delete(searchResult);
ExpDB_Terminate(db_handler);
ExpDiaDB_Terminate(diadb_h);
}