From e7e07f42b336bb7b5c488eb3bcc6397c0a2a03f4 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期一, 24 八月 2020 16:36:09 +0800
Subject: [PATCH] fix conflict

---
 test/test_right_walk3.c |  163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 163 insertions(+), 0 deletions(-)

diff --git a/test/test_right_walk3.c b/test/test_right_walk3.c
new file mode 100644
index 0000000..9b97b1c
--- /dev/null
+++ b/test/test_right_walk3.c
@@ -0,0 +1,163 @@
+#include <usg_common.h>        /* cos */
+#include <graph.h>
+#include <IndirectAlg.h>
+#include <fstream>
+using namespace std;
+char *ltrim(char *str, const char *seps)
+{
+    size_t totrim;
+    if (seps == NULL) {
+        seps = "\t\n\v\f\r ";
+    }
+    totrim = strspn(str, seps);
+    if (totrim > 0) {
+        size_t len = strlen(str);
+        if (totrim == len) {
+            str[0] = '\0';
+        }
+        else {
+            memmove(str, str + totrim, len + 1 - totrim);
+        }
+    }
+    return str;
+}
+
+char *rtrim(char *str, const char *seps)
+{
+    int i;
+    if (seps == NULL) {
+        seps = "\t\n\v\f\r ";
+    }
+    i = strlen(str) - 1;
+    while (i >= 0 && strchr(seps, str[i]) != NULL) {
+        str[i] = '\0';
+        i--;
+    }
+    return str;
+}
+
+char *trim(char *str, const char *seps)
+{
+    return ltrim(rtrim(str, seps), seps);
+}
+
+
+int test2() {
+    // IndirectAlg indirectAlg({  {{0.0, 0.0}, {1000.0, 0.0}}, {{1000.0, 0.0}, {1000.0, 1000.0}}, {{1000.0, 1000.0}, {0.0, 1000.0}}, {{0.0, 1000.0}, {0.0, 0.0}} }, 5, {1, 1});
+    /**
+     * 绗竴涓弬鏁癅points  缁勬垚瑙傛祴鍖哄煙鐨勫郊姝ょ浉閭荤殑鐐�
+     * 绗簩涓弬鏁癅_keepTime 淇濇寔鏃堕棿
+     * 绗笁涓弬鏁癅_direction 姝g‘琛岃繘鐨勬柟鍚戞柟鍚�
+     */
+    IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0},  {1000.0, 1000.0}, {0.0, 1000.0} }, 5, {1, 1});
+    
+    int i = 0;
+    // time_t start_time;
+    srand((unsigned) time(0));
+
+    double rx, ry;
+    bool isRetrograde;
+    //璧风偣
+    Point start = {0, 0};
+    //浼犲叆鐨勬祦鏁版嵁璁板綍淇℃伅Record 
+    Record record;
+    record.id = 1; //鐩爣ID 
+    record.timestamp = time(0); //鏃堕棿鎴�
+    record.coordinate = start; // 鍧愭爣
+    // time(&start_time);
+    //鍒ゆ柇鏄惁閫嗚
+    while(!(isRetrograde = indirectAlg.isRetrograde(record)) ) {
+        rx = ((double)(rand()%10))/100000;
+        ry = ((double)(rand()%10))/100000;
+
+        //std::cout << timestamp << ":" <<  << "isRetrograde" << isRetrograde;
+       // err_msg(0, "%ld : {%f, %f}  %d\n", record.timestamp, record.coordinate.x, record.coordinate.y, isRetrograde);
+        record.timestamp = time(0);
+        
+        //if (difftime(time(0), start_time) > 1)
+        if (i > 10)
+        {
+            record.coordinate = {record.coordinate.x - rx , record.coordinate.y - ry};
+        } else {
+            record.coordinate = {record.coordinate.x + rx , record.coordinate.y + ry};
+        }
+
+        if (i > 100)
+            break;
+
+        sleep(1);
+        i++;
+    }
+    printf("return %ld : {%f, %f}  %d\n", record.timestamp, record.coordinate.x, record.coordinate.y, isRetrograde);
+    return 0;
+}
+
+void test3() {
+
+    std::ifstream fin("test3.txt");
+    char line[1024];
+    //std::string line;
+    char *targetIdStr;
+    char *timestampStr;
+    char *targetStr;
+    char *targetStrBegin;
+    char *targetStrEnd;
+    char *targetPointXstr;
+    char *targetPointYstr;
+//{"x":148,"y":45},{"x":148,"y":539},{"x":769,"y":539},{"x":769,"y":45}
+    //{148, 45}, {148, 539},  {769, 539}, {769, 45}
+    Record record;
+    IndirectAlg indirectAlg((std::initializer_list<Point>){}, 3, {621, 0});
+    
+    // const char *delim = " ";
+    while(fin.getline(line, 1024)) {
+        // printf("line=%s\n", line);
+        if(strlen(trim(line, NULL))== 0)
+            continue;
+        if(*line == '#') {
+            continue;
+        }
+
+        
+
+        targetStrBegin = strchr(line, '{'); 
+        targetStrEnd = strchr(line, '}'); 
+
+
+       
+        *targetStrBegin = 0;
+        *targetStrEnd = 0;
+
+        targetIdStr  = strtok(line, " ");
+        timestampStr = strtok(NULL, " ");
+
+        targetStr = targetStrBegin + 1;
+
+        targetPointXstr =  strtok(targetStr, " ");
+        targetPointYstr = strtok(NULL, " ");
+        //std::cout << targetIdStr << "," << timestampStr << ","  << targetPointXstr << ","  << targetPointYstr << std::endl;
+        record.id = targetIdStr;
+        record.timestamp = atol(timestampStr);
+        record.coordinate.x =  strtod(targetPointXstr, 0);
+        record.coordinate.y =  strtod(targetPointYstr, 0);
+       
+        if ( indirectAlg.isRetrograde(record)) {
+             std::cout << record.id  << "," <<  record.timestamp << ","  << record.coordinate.x << ","  << record.coordinate.y << std::endl;
+        }
+        // while(token) {
+        //     puts(token);
+        //     token = strtok(NULL, " ");
+        // }
+        
+        // printf("key = %s, value=%s\n", key, value);
+    }
+    fin.close();
+    sleep(30);
+}
+
+
+int main() {
+    test3();
+
+
+}

--
Gitblit v1.8.0