|
@@ -0,0 +1,651 @@
|
|
|
+#include "stdafx.h"
|
|
|
+#include "classdef.h"
|
|
|
+#include "constdef.h"
|
|
|
+#include "structdef.h"
|
|
|
+#include "locate_algorithm.h"
|
|
|
+
|
|
|
+#include <math.h>
|
|
|
+
|
|
|
+Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12.0*/, double offset_y /*=12.0*/ )
|
|
|
+{
|
|
|
+ card_type = cardtype;
|
|
|
+ card_id = cardid;
|
|
|
+ coor_offset_x = offset_x;
|
|
|
+ coor_offset_y = offset_y;
|
|
|
+ this->z_offset = z_offset;
|
|
|
+
|
|
|
+ down_time = up_time = enter_area_time = enter_reader_time = deal_time = rec_time = time(NULL);
|
|
|
+ time_over_time = time_area_over_time = time_area_forbidden = time_over_speed = time_low_power = time(NULL);
|
|
|
+
|
|
|
+ x = y = z = last_x = last_y = last_z =0;
|
|
|
+ xx = yy = zz = 0;
|
|
|
+ x1 = y1 = z1 = x2 = y2 = z2 = x3 = y3 = z3 = x4 = y4 = z4 = 0;
|
|
|
+ a = 0;
|
|
|
+ t = 0;
|
|
|
+ init_postion = false;
|
|
|
+ is_first_location = true;
|
|
|
+
|
|
|
+ map_id = map_id_old = area_id = reader_id = 0;
|
|
|
+ state = 0;
|
|
|
+ pos_state = pos_state_count = pos_state_old = 0;
|
|
|
+ dept_id = group_id = 0;
|
|
|
+ power_state = power_state_last = 0;
|
|
|
+
|
|
|
+ isdealed = isreceive = is_pos_changed = is_hist = is_need_cal = false;
|
|
|
+ is_area_over_time = is_mine_over_time = false;
|
|
|
+
|
|
|
+ id = name = number = department = group = worktype = "";
|
|
|
+
|
|
|
+ reader_tickcount = time_stamp = time_stamp_last = 0;
|
|
|
+
|
|
|
+ p_dists = new _coordinate*[DIST_COUNT];
|
|
|
+ p_dists_locate = new _coordinate*[DIST_COUNT];
|
|
|
+ time_stamp_max = 0;
|
|
|
+ for(int i = 0; i < DIST_COUNT; i++){
|
|
|
+ p_dists[i] = NULL;
|
|
|
+ p_dists_locate[i] = NULL;
|
|
|
+ }
|
|
|
+ //cal_location = new CalLocation(KALMAN_OFFSET_COOR, KALMAN_OFFSET_MOVE, KALMAN_OFFSET_RANGING, KALMAN_INTERVAL);
|
|
|
+ //p2_anchors = new Point2[ANCHOR_COUNT];
|
|
|
+ //cal_location3 = new CalLocation3(KALMAN_OFFSET_COOR_TRI, KALMAN_OFFSET_COOR_TRI, KALMAN_OFFSET_COOR_TRI,
|
|
|
+ // KALMAN_OFFSET_MOVE_TRI, KALMAN_OFFSET_MOVE_TRI, 0, KALMAN_OFFSET_RANGING_TRI, KALMAN_INTERVAL_TRI);
|
|
|
+ cal_location3 = new CalLocation3(KALMAN_OFFSET_COOR_TRI, KALMAN_OFFSET_MOVE_TRI, KALMAN_OFFSET_RANGING_TRI, KALMAN_INTERVAL_TRI);
|
|
|
+ p3_anchors = new Point3[ANCHOR_COUNT];
|
|
|
+ is_init_kalman = false;
|
|
|
+}
|
|
|
+
|
|
|
+Card::Card( void )
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//void Card::set_pos_state( int val )
|
|
|
+//{
|
|
|
+// if(val == pos_state) {
|
|
|
+// pos_state_count++;
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// pos_state = val;
|
|
|
+// pos_state_count = 1;
|
|
|
+//}
|
|
|
+
|
|
|
+void Card::set_reader( Reader* preader ) // 设置卡时间
|
|
|
+{
|
|
|
+ this->rec_time = time(NULL);
|
|
|
+ if(preader->reader_id == this->reader_id){ // 所在分站没有发生变化
|
|
|
+ this->pos_state_count++;
|
|
|
+ }else{ // 分站变化
|
|
|
+ this->p_reader = preader;
|
|
|
+ this->reader_id = preader->reader_id;
|
|
|
+ this->enter_reader_time = this->rec_time;
|
|
|
+
|
|
|
+ //if(preader->area_id != this->area_id){ // 区域变化 // note 根据区域坐标计算
|
|
|
+ // this->area_id = preader->area_id;
|
|
|
+ // this->enter_area_time = this->rev_time;
|
|
|
+ //}
|
|
|
+ this->map_id_old = this->map_id;
|
|
|
+ this->map_id = preader->map_id;
|
|
|
+
|
|
|
+ //if(this->pos_state == preader->pos_state){
|
|
|
+ // this->pos_state_count++;
|
|
|
+ //}else{ // 井上,井下位置变化
|
|
|
+ // this->pos_state_last = this->pos_state;
|
|
|
+ // this->pos_state = preader->pos_state;
|
|
|
+ // this->pos_state_count = 0;
|
|
|
+ //}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool Card::is_pos_state_changed( int nval ) // 考勤
|
|
|
+{
|
|
|
+ if(this->pos_state == this->pos_state_old){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //if(this->pos_state_count < nval ){ // 未达到确认次数
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ this->pos_state_old = this->pos_state;
|
|
|
+ return true;
|
|
|
+ //if(last_area_type_id != cur_area_type_id){
|
|
|
+ // if(0 ==last_area_type_id || 0==cur_area_type_id){
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //return false;
|
|
|
+ //return (this->last_area_type_id != this->cur_area_type_id && 0 == (this->cur_area_type_id & this->last_area_type_id));
|
|
|
+}
|
|
|
+
|
|
|
+void Card::add_dist( _coordinate* dist )
|
|
|
+{
|
|
|
+ string s = concat(dist->reader_id, dist->antenna_id);
|
|
|
+ if(0 == _dists.size()){
|
|
|
+ DistQueItem* p = new DistQueItem;
|
|
|
+ p->t = dist->t;
|
|
|
+ p->mp_dist.insert(make_pair(s, dist));
|
|
|
+ _dists.push_back(p);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(_dists.front()->t == dist->t){
|
|
|
+ DistMap::iterator it = _dists.front()->mp_dist.find(s);
|
|
|
+ if(it != _dists.front()->mp_dist.end()){
|
|
|
+ it->second->x = dist->x;
|
|
|
+ it->second->y = dist->y;
|
|
|
+ it->second->z = dist->z;
|
|
|
+ it->second->a = dist->a;
|
|
|
+ }else{
|
|
|
+ _dists.front()->mp_dist.insert(make_pair(s, dist));
|
|
|
+ }
|
|
|
+ }else if(_dists.back()->t == dist->t){
|
|
|
+ DistMap::iterator it = _dists.back()->mp_dist.find(s);
|
|
|
+ if(it != _dists.back()->mp_dist.end()){
|
|
|
+ it->second->x = dist->x;
|
|
|
+ it->second->y = dist->y;
|
|
|
+ it->second->z = dist->z;
|
|
|
+ it->second->a = dist->a;
|
|
|
+ }else{
|
|
|
+ _dists.back()->mp_dist.insert(make_pair(s, dist));
|
|
|
+ }
|
|
|
+ }else{ // 新数据
|
|
|
+ DistQueItem* p = new DistQueItem;
|
|
|
+ p->t = dist->t;
|
|
|
+ p->mp_dist.insert(make_pair(s, dist));
|
|
|
+ if(_dists.size() > 1){ // 大于一个
|
|
|
+ _dists.pop_front();
|
|
|
+ }
|
|
|
+ _dists.push_back(p);
|
|
|
+ get_coordinate();
|
|
|
+ }
|
|
|
+
|
|
|
+ //// new reader, replace the earliest or the null
|
|
|
+ //bool b_exist = false;
|
|
|
+ //int min_stamp = dist->t, min_stamp_index = -1;
|
|
|
+ //// when dist->t is the latest data, calc the last timestamp data (the second latest data)
|
|
|
+ //// (dist->t > 0 && time_stamp_max < dist->t) || (dist->t == 0 && time_stamp_max == 0xFFFF)
|
|
|
+ //is_need_cal = (dist->t > 0 && time_stamp_max < dist->t) || (dist->t < 10 && abs(dist->t - time_stamp_max) > 100);
|
|
|
+
|
|
|
+ //time_stamp_max = dist->t;
|
|
|
+ //for(int i = 0; i < DIST_COUNT; i++ ){
|
|
|
+ // if(p_dists[i] == NULL){
|
|
|
+ // p_dists[i] = dist;
|
|
|
+ // is_anchor_changed = true;
|
|
|
+ // b_exist = true;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // //if(p_dists[i]->reader_id == dist->reader_id){
|
|
|
+ // if(p_dists[i]->x == dist->x && p_dists[i]->y == dist->y
|
|
|
+ // && p_dists[i]->z == dist->z && p_dists[i]->a == dist->a){ // 同一分站,新数据有效
|
|
|
+ // dist->d_offset = p_dists[i]->d_offset; // 同一分站的偏移
|
|
|
+ // if(dist->t >= p_dists[i]->t){
|
|
|
+ // p_dists[i] = dist;
|
|
|
+ // }else if(abs(dist->t - p_dists[i]->t) > 100){
|
|
|
+ // p_dists[i] = dist;
|
|
|
+ // }
|
|
|
+ // b_exist = true;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // if(min_stamp >= p_dists[i]->t && abs(min_stamp-p_dists[i]->t) <100){
|
|
|
+ // min_stamp = p_dists[i]->t;
|
|
|
+ // min_stamp_index = i;
|
|
|
+ // }else if(min_stamp < p_dists[i]->t && abs(min_stamp - p_dists[i]->t) >= 100){
|
|
|
+ // min_stamp = p_dists[i]->t;
|
|
|
+ // min_stamp_index = i;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //if(!b_exist){
|
|
|
+ // p_dists[min_stamp_index] = dist;
|
|
|
+ // is_anchor_changed = true;
|
|
|
+ //}
|
|
|
+}
|
|
|
+
|
|
|
+time_t Card::get_working_time()
|
|
|
+{
|
|
|
+ //return (card_type == CT_VEHICLE) ? leave_park_time : down_time;
|
|
|
+ return down_time;
|
|
|
+}
|
|
|
+
|
|
|
+int Card::get_effictive_dist_count( int offset /*= 0*/ )
|
|
|
+{
|
|
|
+ if(0 == _dists.size()) return 0;
|
|
|
+ return _dists.front()->mp_dist.size();
|
|
|
+
|
|
|
+ //int nTimeStamp;
|
|
|
+ //if(time_stamp_max == 0 && offset != 0){
|
|
|
+ // nTimeStamp = 0xFFFF;
|
|
|
+ //}else{
|
|
|
+ // nTimeStamp = time_stamp_max - offset;
|
|
|
+ //}
|
|
|
+ //int ret = 0, tmp = -1;
|
|
|
+ //for(int i = 0; i < DIST_COUNT; i++){
|
|
|
+ // if(NULL == p_dists[i]) break;
|
|
|
+ // if(p_dists[i]->t == nTimeStamp){
|
|
|
+ // ret++;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //return ret;
|
|
|
+}
|
|
|
+
|
|
|
+Card::~Card(void)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+void Card::get_coordinate_2d( int cnt )
|
|
|
+{
|
|
|
+ //double d_dist[3];
|
|
|
+ //Point2 pt2, pt2_1;
|
|
|
+ //for(int i = 0; i < cnt; i++){
|
|
|
+ // d_dist[i] = p_dists_locate[i]->d;
|
|
|
+
|
|
|
+ //}
|
|
|
+ //for(int i=0; i< cnt; i++){
|
|
|
+ // if(p_dists[i]->reader_id == 1){
|
|
|
+ // p2_anchors[0].x = p_dists[i]->x;
|
|
|
+ // p2_anchors[0].y = p_dists[i]->y;
|
|
|
+ // d_dist[0] = p_dists[i]->d;
|
|
|
+ // }else if(p_dists[i]->reader_id == 2){
|
|
|
+ // p2_anchors[1].x = p_dists[i]->x;
|
|
|
+ // p2_anchors[1].y = p_dists[i]->y;
|
|
|
+ // d_dist[1] = p_dists[i]->d;
|
|
|
+ // }if(p_dists[i]->reader_id == 3){
|
|
|
+ // p2_anchors[2].x = p_dists[i]->x;
|
|
|
+ // p2_anchors[2].y = p_dists[i]->y;
|
|
|
+ // d_dist[2] = p_dists[i]->d;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //Mat mat(3, 1, d_dist);
|
|
|
+
|
|
|
+ //if(is_anchor_changed){
|
|
|
+ // cal_location->setAnchors(p2_anchors);
|
|
|
+ // pt2 = cal_location->initPos(mat);
|
|
|
+ //} else{
|
|
|
+ // pt2 = cal_location->estiPos(mat);
|
|
|
+ //}
|
|
|
+ //pt2_1 = cal_location->getError();
|
|
|
+ //x = pt2.x;
|
|
|
+ //y = pt2.y;
|
|
|
+ //z = 0;
|
|
|
+ //x1 = pt2_1.x;
|
|
|
+ //y1 = pt2_1.y;
|
|
|
+ //z1 = 0;
|
|
|
+}
|
|
|
+
|
|
|
+void Card::get_coordinate_3d( int cnt )
|
|
|
+{
|
|
|
+ double d_dist[ANCHOR_COUNT];
|
|
|
+ Point3 pt3, pt3_1;
|
|
|
+ for(int i = 0; i < cnt; i++){
|
|
|
+ d_dist[i] = p_dists_locate[i]->d;
|
|
|
+ }
|
|
|
+
|
|
|
+ Mat mat(ANCHOR_COUNT, 1, d_dist);
|
|
|
+ if(is_anchor_changed){
|
|
|
+ set_anchors(cnt);
|
|
|
+ pt3 = cal_location3->initPos(mat);
|
|
|
+ } else{
|
|
|
+ pt3 = cal_location3->estiPos(mat);
|
|
|
+ }
|
|
|
+ pt3_1 = cal_location3->getError();
|
|
|
+
|
|
|
+ x = pt3.x;
|
|
|
+ y = pt3.y;
|
|
|
+ z = pt3.z;
|
|
|
+ x1 = pt3_1.x;
|
|
|
+ y1 = pt3_1.y;
|
|
|
+ z1 = pt3_1.z;
|
|
|
+}
|
|
|
+
|
|
|
+double Card::get_speed()
|
|
|
+{
|
|
|
+ double speed = 0;
|
|
|
+ // 计算速度
|
|
|
+ return speed;
|
|
|
+}
|
|
|
+
|
|
|
+void Card::set_anchors( int cnt )
|
|
|
+{
|
|
|
+ for(int i = 0; i < cnt; i++){
|
|
|
+ p3_anchors[i].x = p_dists[i]->x;
|
|
|
+ p3_anchors[i].y = p_dists[i]->y;
|
|
|
+ p3_anchors[i].z = p_dists[i]->z;
|
|
|
+ }
|
|
|
+ cal_location3->setAnchors(p3_anchors, ANCHOR_COUNT);
|
|
|
+ is_anchor_changed = false;
|
|
|
+}
|
|
|
+
|
|
|
+void Card::get_coordinate( int cnt )
|
|
|
+{
|
|
|
+// if(cnt < 2) return; // 只有一个测量值,忽略不计算
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ DistMap::iterator it = _dists.front()->mp_dist.begin();
|
|
|
+ for(; it != _dists.front()->mp_dist.end(); ++it, i++){
|
|
|
+ p_dists_locate[i] = it->second;
|
|
|
+ }
|
|
|
+
|
|
|
+ //int i = 0;
|
|
|
+ //int j = 0;
|
|
|
+ //for(int k = j; k < DIST_COUNT; k++,j++){
|
|
|
+ // if(p_dists[k] == NULL) return;
|
|
|
+ // //if(p_dists[k]->t == time_stamp_max){ // with the latest data
|
|
|
+ // if(p_dists[k]->t == time_stamp_max - 1){ // with the last data
|
|
|
+ // p_dists_locate[i] = p_dists[k];
|
|
|
+ // i++;
|
|
|
+ // if(i >= cnt) break;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //if(cnt > 3){
|
|
|
+ ////get_coordinate_3d(cnt);
|
|
|
+ ////}else if(cnt > 2){
|
|
|
+ //// get_coordinate_2d(cnt);
|
|
|
+ //}else /*if(cnt > 1)*/{
|
|
|
+ _coordinate* coor_hist = new _coordinate;
|
|
|
+ _coordinate* coor_dest = new _coordinate;
|
|
|
+ if(!init_postion){
|
|
|
+ this->x = p_dists_locate[0]->x;
|
|
|
+ this->y = p_dists_locate[0]->y;
|
|
|
+ this->z = p_dists_locate[0]->z;
|
|
|
+ this->a = p_dists_locate[0]->a;
|
|
|
+ this->distance = p_dists_locate[0]->d;
|
|
|
+ this->t = p_dists_locate[0]->t;
|
|
|
+
|
|
|
+ this->last_x = p_dists_locate[0]->x;
|
|
|
+ this->last_y = p_dists_locate[0]->y;
|
|
|
+ this->last_z = p_dists_locate[0]->z;
|
|
|
+
|
|
|
+ init_postion = true;
|
|
|
+ }
|
|
|
+ coor_hist->x = this->x;
|
|
|
+ coor_hist->y = this->y;
|
|
|
+ coor_hist->z = this->z;
|
|
|
+ coor_hist->a = this->a;
|
|
|
+ coor_hist->t = this->t;
|
|
|
+ coor_hist->d = this->distance;
|
|
|
+ coor_hist->v = this->get_speed();
|
|
|
+
|
|
|
+ coor_dest->x = this->x;
|
|
|
+ coor_dest->y = this->y;
|
|
|
+ coor_dest->z = this->z;
|
|
|
+ coor_dest->a = this->a;
|
|
|
+ coor_dest->v = coor_hist->v;
|
|
|
+ //coor_dest->d = this->distance;
|
|
|
+ //coor_dest->d_offset = 0;
|
|
|
+ //coor_dest->reader_id = this->reader_id;
|
|
|
+ if(is_first_location){
|
|
|
+ algorithm_locate_ex(p_dists_locate, cnt, NULL, coor_dest, 500);
|
|
|
+ }else{
|
|
|
+ algorithm_locate_ex(p_dists_locate, cnt, coor_hist, coor_dest, 500);
|
|
|
+ }
|
|
|
+ //algorithm_locate(p_dists_locate, cnt, coor_hist, coor_dest, 500, z_offset);
|
|
|
+ this->x = coor_dest->x;
|
|
|
+ this->y = coor_dest->y;
|
|
|
+ this->a = coor_dest->a;
|
|
|
+ this->t = coor_dest->t;
|
|
|
+ //}
|
|
|
+ //this->x -= coor_offset_x;
|
|
|
+ //this->y -= coor_offset_y;
|
|
|
+}
|
|
|
+
|
|
|
+void Card::get_coordinate()
|
|
|
+{
|
|
|
+ get_coordinate(get_effictive_dist_count());
|
|
|
+}
|
|
|
+
|
|
|
+std::string Card::get_state_text()
|
|
|
+{
|
|
|
+ //if(this->state == 0){
|
|
|
+ // return "正常";
|
|
|
+ //}
|
|
|
+ string ret = "";
|
|
|
+ if(status_help == STATUS_ERROR){
|
|
|
+ ret += "呼救,";
|
|
|
+ }
|
|
|
+ if(status_area_over_time == STATUS_ERROR){
|
|
|
+ ret += "区域超时,";
|
|
|
+ }else if(status_area_over_time == STATUS_ERROR){
|
|
|
+ ret += "超时,";
|
|
|
+ }
|
|
|
+ if(status_area_over_speed == STATUS_ERROR){
|
|
|
+ ret += "区域超速,";
|
|
|
+ }else if(status_over_speed == STATUS_ERROR){
|
|
|
+ ret += "超速,";
|
|
|
+ }
|
|
|
+ if(status_area_forbidden == STATUS_ERROR){
|
|
|
+ ret += "进入限制区域,";
|
|
|
+ }
|
|
|
+ if(status_call == STATUS_ERROR){
|
|
|
+ ret += "呼叫,";
|
|
|
+ }
|
|
|
+ if(status_power == STATUS_ERROR){
|
|
|
+ ret += "电量低,";
|
|
|
+ }else if(status_power == STATUS_ERROR_SERIOUS){
|
|
|
+ ret += "电量极低,";
|
|
|
+ }
|
|
|
+ if(status_lost == STATUS_ERROR){
|
|
|
+ ret += "进入盲区,";
|
|
|
+ }
|
|
|
+ if(ret.length() > 0){
|
|
|
+ ret = ret.substr(0, ret.length() - 1);
|
|
|
+ state = 1;
|
|
|
+ }else{
|
|
|
+ ret = "正常";
|
|
|
+ state = 0;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+std::string Card::get_acc_text()
|
|
|
+{
|
|
|
+ string ret = "";
|
|
|
+ status_moving = (accelerate_state && 0x01)? STATUS_ERROR : STATUS_NORMAL;
|
|
|
+
|
|
|
+ if(status_moving == STATUS_NORMAL){
|
|
|
+ ret += "静止";
|
|
|
+ }else if(status_moving == STATUS_ERROR){
|
|
|
+ ret += "运动";
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+std::string Card::concat( int reader_id, int ant_id )
|
|
|
+{
|
|
|
+ char s[10];
|
|
|
+ sprintf(s, "%d-%d", reader_id, ant_id);
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
+Reader::Reader(void)
|
|
|
+{
|
|
|
+ rec_time = reader_time = lost_time = time(NULL);
|
|
|
+ state = STATUS_DEVICE_NORMAL;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Reader::~Reader(void)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+std::string Reader::get_state_text()
|
|
|
+{
|
|
|
+ string ret = "";
|
|
|
+ if(state == STATUS_DEVICE_ERROR){
|
|
|
+ ret = "故障";
|
|
|
+ }else if(state == STATUS_DEVICE_NORMAL){
|
|
|
+ ret = "正常";
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+Antenna::Antenna(void)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Antenna::~Antenna(void)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Area::Area(void)
|
|
|
+{
|
|
|
+ polygon_count = 0;
|
|
|
+ polygon = NULL;
|
|
|
+ map_id = area_id = area_type_id = 0 ;
|
|
|
+ area_name = area_type_name = path = "";
|
|
|
+ over_count_person = over_time_person = under_count_person = under_time_person = 0;
|
|
|
+ over_count_vehicle = over_time_vehicle = under_count_vehicle = under_time_vehicle = 0;
|
|
|
+
|
|
|
+ count_person = count_vehicle = count_card = 0;
|
|
|
+ is_area_over_time_person = is_area_over_time_vehicle = false;
|
|
|
+ count_area_over_time_person = count_area_over_time_vehicle = 0;
|
|
|
+ time_over_time_person = time_over_time_vehicle = time(NULL);
|
|
|
+
|
|
|
+ is_area_over_count_person = is_area_over_count_vehicle = false;
|
|
|
+ count_area_over_count_person = count_area_over_count_vehicle = 0;
|
|
|
+ time_over_count_person = time_over_count_vehicle = time(NULL);
|
|
|
+
|
|
|
+ is_area_forbidden_person = is_area_forbidden_vehicle = 0;
|
|
|
+ count_area_forbidden_person = count_area_forbidden_vehicle = 0;
|
|
|
+ time_forbidden_person = time_forbidden_vehicle = time(NULL);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+Area::~Area(void)
|
|
|
+{
|
|
|
+ if(polygon){
|
|
|
+ delete[] polygon;
|
|
|
+ polygon = NULL;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void Area::init_border( string sz_path )
|
|
|
+{
|
|
|
+ //std::vector<std::string> vec = split(sz_path, ",");
|
|
|
+ //if(vec.size() >= 4){
|
|
|
+ // rect_left = atoi(vec[0].c_str());
|
|
|
+ // rect_top = atoi(vec[1].c_str());
|
|
|
+ // rect_right = atoi(vec[2].c_str());
|
|
|
+ // rect_bottom = atoi(vec[3].c_str());
|
|
|
+ //}else{
|
|
|
+ // rect_left = rect_right = rect_top = rect_bottom = 0;
|
|
|
+ //}
|
|
|
+ std::vector<std::string> vec = split(sz_path, " ");
|
|
|
+ std::vector<std::string>::iterator it = vec.begin();
|
|
|
+ if(polygon){
|
|
|
+ delete[] polygon;
|
|
|
+ polygon = NULL;
|
|
|
+ }
|
|
|
+ polygon = new _point[vec.size()];
|
|
|
+ polygon_count = 0;
|
|
|
+ for(; it != vec.end(); ++it){
|
|
|
+ std::vector<std::string> subvec = split(it->c_str(), ",");
|
|
|
+ _point p;
|
|
|
+ p.x = get_vertex(subvec[0]);
|
|
|
+ p.y = get_vertex(subvec[1]);
|
|
|
+ p.z = 0;
|
|
|
+ polygon[polygon_count] = p;
|
|
|
+ polygon_count++;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<std::string> Area::split( std::string str,std::string pattern )
|
|
|
+{
|
|
|
+ std::string::size_type pos;
|
|
|
+ std::vector<std::string> result;
|
|
|
+ str+=pattern;//扩展字符串以方便操作
|
|
|
+ unsigned int size=str.size();
|
|
|
+
|
|
|
+ for(unsigned int i=0; i<size; i++){
|
|
|
+ pos=str.find(pattern,i);
|
|
|
+ if(pos<size){
|
|
|
+ std::string s=str.substr(i,pos-i);
|
|
|
+ result.push_back(s);
|
|
|
+ i=pos+pattern.size()-1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+double Area::get_vertex( std::string src)
|
|
|
+{
|
|
|
+ std::string dest = "";
|
|
|
+ for(unsigned int i = 0; i < src.length(); i++){
|
|
|
+ if((src[i] >= '0' && src[i]<='9') || src[i]=='-' || src[i] == '.'){
|
|
|
+ dest += src[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return atof(dest.c_str());
|
|
|
+}
|
|
|
+
|
|
|
+bool Area::is_in_polygon( _point p )
|
|
|
+{
|
|
|
+ //int i,j=polySides-1 ;
|
|
|
+ //bool oddNodes=NO ;
|
|
|
+
|
|
|
+ //for (i=0;i<polySides; i++) {
|
|
|
+ // if((polyY[i]< y && polyY[j]>=y
|
|
|
+ // || polyY[j]<y && polyY[i]>=y)
|
|
|
+ // && (polyX[i]<=x || polyX[j]<=x)) {
|
|
|
+ // oddNodes^=(polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x);}
|
|
|
+ // j=i;}
|
|
|
+
|
|
|
+ //returnoddNodes;
|
|
|
+
|
|
|
+ int counter = 0;
|
|
|
+ int i;
|
|
|
+ double xinters;
|
|
|
+ _point p1,p2;
|
|
|
+
|
|
|
+ p1 = polygon[0];
|
|
|
+ for (int i=1;i<= polygon_count;i++) {
|
|
|
+ p2 = polygon[i % polygon_count];
|
|
|
+ if (p.y > MIN(p1.y,p2.y)) {
|
|
|
+ if (p.y <= MAX(p1.y,p2.y)) {
|
|
|
+ if (p.x <= MAX(p1.x,p2.x)) {
|
|
|
+ if (p1.y != p2.y) {
|
|
|
+ xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x;
|
|
|
+ if (p1.x == p2.x || p.x <= xinters)
|
|
|
+ counter++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p1 = p2;
|
|
|
+ }
|
|
|
+ return (counter % 2 == 0) ? false : true;
|
|
|
+}
|
|
|
+
|
|
|
+MapInfo::MapInfo( void )
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+MapInfo::~MapInfo( void )
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+Dept::Dept( int id, string name )
|
|
|
+{
|
|
|
+ dept_id = id;
|
|
|
+ dept_name = name;
|
|
|
+}
|
|
|
+
|
|
|
+Dept::Dept()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+Dept::~Dept()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+Adhoc::Adhoc()
|
|
|
+{
|
|
|
+ adhoc_id = 0;
|
|
|
+ x = 0;
|
|
|
+ y = 0;
|
|
|
+ z = 0;
|
|
|
+ idx = 0;
|
|
|
+}
|
|
|
+
|
|
|
+Adhoc::~Adhoc()
|
|
|
+{
|
|
|
+}
|