algorithm/IndirectAlg.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
algorithm/graph.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test2.txt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_right_walk | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_right_walk3 | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_right_walk3.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
algorithm/IndirectAlg.c
@@ -19,6 +19,10 @@ time_t firstInvalTime; //上次逆行的时间 time_t lastInvalTime; //第一次正确行的时间 time_t firstValTime; //上次逆=正确行的时间 time_t lastValTime; //上一次出现的坐标 Point lastCoordinate; // Status(std::string _id, time_t ftime, time_t ltime, Point coordinate): @@ -89,8 +93,12 @@ } /** * for debug */ void IndirectAlg::printRecord(int tag, Record &record) { printf("%d %ld : {%f, %f}\n", tag, record.timestamp, record.coordinate.x, record.coordinate.y); // printf("%d %ld : {%f, %f}\n", tag, record.timestamp, record.coordinate.x, record.coordinate.y); } /** @@ -117,6 +125,8 @@ .lastTime = record.timestamp, .firstInvalTime = 0, .lastInvalTime = 0, .firstValTime = 0, .lastValTime = 0, .lastCoordinate = record.coordinate}); statusMap.insert({record.id, status}); @@ -141,13 +151,16 @@ if(status->firstInvalTime ==0) { //第一次发生逆行 status->firstInvalTime = status->lastInvalTime = record.timestamp; //printf("%第一次发生逆行的时间=%ld\n", status->firstInvalTime); printRecord(4, record); return false; } else { status->lastInvalTime = record.timestamp; //printf("%后续发生逆行的时间=%ld\n", status->lastInvalTime); //逆行时间超过keeptime if (status->lastInvalTime - status-> firstInvalTime > keepTime) { if (status->lastInvalTime - status-> firstInvalTime >= keepTime) { status->firstValTime = status->lastValTime = 0; printRecord(5, record); return true; } @@ -155,8 +168,19 @@ return false; } } else { printRecord(7, record); status->firstInvalTime = status->lastInvalTime = 0; if(status->firstValTime ==0) { status->firstValTime = status->lastValTime = record.timestamp; printRecord(7, record); } else { status->lastValTime = record.timestamp; //逆行时间超过keeptime if (status->lastValTime - status-> firstValTime >= keepTime) { status->firstInvalTime = status->lastInvalTime = 0; printRecord(8, record); } } return false; } algorithm/graph.c
@@ -23,11 +23,16 @@ return *this; } // bool Figure::contains(const Point& p) const // { // auto c = 0; // for (auto e : edges) if (e.isCorss(p)) c++; // return c % 2 != 0; // } bool Figure::contains(const Point& p) const { auto c = 0; for (auto e : edges) if (e.isCorss(p)) c++; return c % 2 != 0; return true; } /** test/test2.txt
New file @@ -0,0 +1,86 @@ 535 1592307583 {2061 120 445 760} 535 1592307583 {2080 102 394 858} 535 1592307583 {2067 105 361 840} 535 1592307583 {2016 98 387 851} 535 1592307583 {1977 105 400 844} 535 1592307583 {1944 95 381 862} 535 1592307583 {1873 105 413 1030} 535 1592307583 {1718 116 542 1048} 535 1592307583 {1712 124 523 1052} 535 1592307583 {1692 127 523 1066} 535 1592307584 {1680 120 465 1077} 535 1592307584 {1686 124 439 1066} 535 1592307584 {1712 109 348 1092} 535 1592307584 {1686 109 361 1088} 535 1592307584 {1550 124 400 1107} 535 1592307584 {1421 113 484 1129} 535 1592307584 {1369 124 516 1118} 535 1592307584 {1318 149 549 1121} 535 1592307584 {1318 138 536 1143} 535 1592307584 {1318 138 529 1140} 535 1592307584 {1324 135 439 1150} 535 1592307584 {1331 127 387 1165} 535 1592307584 {1324 146 290 1150} 535 1592307584 {1260 146 323 1132} 535 1592307584 {1234 135 323 1158} 535 1592307584 {1117 138 420 1150} 535 1592307584 {1027 153 516 1129} 535 1592307585 {1008 171 516 1107} 535 1592307585 {995 168 523 1114} 535 1592307585 {995 149 516 1136} 535 1592307585 {930 160 510 1110} 535 1592307585 {917 153 426 1110} 535 1592307585 {930 175 336 1085} 535 1592307585 {840 157 329 1110} 535 1592307585 {814 127 336 1176} 535 1592307585 {749 160 413 1121} 535 1592307585 {639 175 523 1107} 535 1592307585 {626 186 536 1099} 535 1592307585 {613 182 516 1110} 535 1592307585 {600 179 510 1110} 535 1592307585 {555 171 439 1121} 535 1592307585 {523 171 420 1125} 535 1592307585 {491 160 329 1165} 535 1592307586 {465 157 342 1180} 535 1592307586 {458 164 342 1180} 535 1592307586 {394 197 407 1136} 535 1592307586 {400 200 407 1132} 535 1592307586 {381 193 426 1140} 535 1592307586 {381 204 400 1114} 535 1592307586 {394 361 368 960} 538 1592307603 {432 182 471 1074} 538 1592307603 {465 182 432 1074} 538 1592307603 {510 171 387 1092} 538 1592307603 {529 179 381 1081} 538 1592307603 {568 171 355 1088} 538 1592307603 {633 164 316 1103} 538 1592307603 {678 160 432 1096} 538 1592307603 {684 171 516 1085} 538 1592307603 {704 186 549 1059} 538 1592307603 {736 179 562 1070} 538 1592307603 {756 179 562 1074} 538 1592307603 {865 142 458 1085} 538 1592307603 {930 138 368 1074} 538 1592307603 {1079 105 297 1096} 538 1592307604 {1130 105 471 1085} 538 1592307604 {1137 124 497 1066} 538 1592307604 {1156 124 516 1066} 538 1592307604 {1137 138 555 1055} 538 1592307604 {1195 131 516 1066} 538 1592307604 {1247 124 465 1077} 538 1592307604 {1389 113 342 1107} 538 1592307604 {1428 105 355 1118} 538 1592307604 {1486 105 303 1114} 538 1592307604 {1505 98 368 1121} 538 1592307604 {1531 102 368 1107} 538 1592307604 {1531 113 452 1096} 538 1592307604 {1531 116 465 1096} 538 1592307604 {1531 113 504 1103} 538 1592307604 {1544 105 504 1118} 538 1592307604 {1718 109 387 1059} 538 1592307605 {1738 105 432 1008} 538 1592307605 {1789 76 394 1048} 538 1592307605 {1867 69 342 1081} 538 1592307605 {1841 76 400 1066} 538 1592307605 {1925 91 413 920} 538 1592307605 {1970 102 432 876} test/test_right_walkBinary files differ
test/test_right_walk3Binary files differ
test/test_right_walk3.c
@@ -94,7 +94,7 @@ void test3() { std::ifstream fin("test.txt"); std::ifstream fin("test2.txt"); char line[1024]; //std::string line; char *targetIdStr; @@ -106,7 +106,7 @@ char *targetPointYstr; //{"x":148,"y":45},{"x":148,"y":539},{"x":769,"y":539},{"x":769,"y":45} Record record; IndirectAlg indirectAlg((std::initializer_list<Point>){{148, 45}, {148, 539}, {769, 539}, {769, 45} }, 5, {621, 0}); IndirectAlg indirectAlg((std::initializer_list<Point>){{148, 45}, {148, 539}, {769, 539}, {769, 45} }, 2, {621, 0}); // const char *delim = " "; while(fin.getline(line, 1024)) {