package BaoWen;
|
import java.awt.geom.Point2D;
|
import java.util.logging.Logger;
|
|
import Method.GetNowTime;
|
import Method.PutPosInHistoryDataBase;
|
import PbuliClass.Shi_jian_cha_sss;
|
import PbuliClass.Systems;
|
import fence.Fences;
|
import fence.PointIsInWall;
|
import fence.PointIsInshinei;
|
import fence.PointIsInwuxiao;
|
import jiekou.display;
|
import person.Person;
|
import tag.Tag;
|
import tag.Tag_Dell;
|
import tbDataModel.Tb_gps;
|
import tbDataModel_Dell.Dell_ReallPoint;
|
import tbDataModel_Dell.Dell_tb_suanfa2;
|
import tbDataModel_Dell.Map_Dell;
|
import urt.xytoutm;
|
import zijisuan.Zjsdo;
|
|
/**ÅжϱêÇ©ÔÚÊÒÍ⻹ÊÇÔÚÊÒÍâ*/
|
public class Juge_indoor {
|
static Logger logger= Logger.getLogger(String.valueOf(Juge_indoor.class));
|
static int jiange=Integer.parseInt(Systems.sys().getBaoliu22());
|
static String jwd="0";//¾Î³¶ÈתΪ¶È¸ñʽ±£´æ
|
|
/**µ±Êý¾ÝÀ´Ô´ÊÇUWBµÄʱºò*/
|
public static void data_from_uwb(Person person,String baoxu,String intime) {
|
String gnggatime=person.getReceive_gngga_time();
|
if(gnggatime.equals("-1")) {//ûÓÐÊÕµ½ÓÐЧµÄGNGGAÊý¾Ý
|
pos_form_uwb_or_gps(1,person,baoxu,intime);
|
person.setIndoor_or_outdoor(1);
|
person.setReason_indoor_from("δÊÕµ½GNGGA");
|
}else {
|
boolean aa=Shi_jian_cha_sss.shijiancha(gnggatime,3);
|
if(aa) {//Èç¹û3ÃëÖÓÄÚûÓÐÊÕµ½ÓÐЧµÄÎÀÐǶ¨Î»Êý¾Ý
|
pos_form_uwb_or_gps(1,person,baoxu,intime);
|
person.setIndoor_or_outdoor(1);
|
person.setReason_indoor_from("3sδÊÕµ½GNGGA");
|
}else {//Èç¹û3ÃëÖÓÄÚÓÐÊÕµ½ÓÐЧµÄÎÀÐǶ¨Î»Êý¾Ý
|
if(Dell_tb_suanfa2.isJuli_juge_in()) {//Èç¹û¿ªÆôͨ¹ý¾àÀëÅжÏÊÒÄÚÍâ
|
if(person.getdistance_juge_indoor()==1) {//ÔÚÊÒÄÚ
|
person.setIndoor_or_outdoor(1);
|
person.setReason_indoor_from("²â¾à¾àÀëÅжÏ");
|
if(person.getGngga_state() !=4) {//GNGGA²»ÊǸ߾«¶È״̬
|
pos_form_uwb_or_gps(1,person,baoxu,intime);
|
}
|
}else {//ͨ¹ý¾àÀëÅжϲ»ÔÚÊÒÄÚ
|
juge_indoor_fence(person,baoxu,intime);
|
}
|
}else {//Èç¹ûû¿ªÆôͨ¹ý¾àÀëÅжÏÊÒÄÚÍâ
|
juge_indoor_fence(person,baoxu,intime);
|
}
|
}
|
}
|
|
}
|
|
/**µ±Êý¾ÝÀ´Ô´ÊÇGPSµÄʱºò*/
|
public static void data_from_gps(Person person,Tb_gps gps,String gpsxinhao,String tagid) {
|
String intime=GetNowTime.timestamp2();
|
String uwbtime=person.getReceive_uwbpos_time();
|
if(uwbtime.equals("-1")) {//ûÓÐÊÕµ½ÓÐЧµÄUWBÊý¾Ý
|
pos_form_uwb_or_gps(0,person,"65535",intime);
|
person.setIndoor_or_outdoor(0);
|
person.setReason_indoor_from("δÊÕµ½UWB");
|
}else {
|
boolean aa=Shi_jian_cha_sss.shijiancha(uwbtime,5);
|
if(aa) {//Èç¹û5ÃëÖÓÄÚûÓÐÊÕµ½ÓÐЧµÄUWB¶¨Î»Êý¾Ý
|
pos_form_uwb_or_gps(0,person,"65535",intime);
|
person.setIndoor_or_outdoor(0);
|
person.setReason_indoor_from("5sδÊÕµ½UWB");
|
}else {//Èç¹û5ÃëÖÓÄÚÓÐÊÕµ½ÓÐЧµÄuwb¶¨Î»Êý¾Ý
|
if(person.getGngga_state() ==4) {//GNGGAÊǸ߾«¶È״̬
|
pos_form_uwb_or_gps(0,person,"65535",intime);
|
person.setIndoor_or_outdoor(0);
|
person.setReason_indoor_from("¸ß¾«¶È״̬");
|
}else {
|
if(person.getdistance_juge_indoor() !=1 && person.getIndoor_fence() !=1) {//Èç¹ûUWBûÓÐÅжϳöÊÇ·ñÔÚÊÒÄÚ
|
if(Dell_tb_suanfa2.isGps_xinhao_in()) {//¿ªÆôÎÀÐÇÐźÅÅжÏÊÒÄÚÍâ
|
juge_urt_indorr_to_xinhao(gps,gpsxinhao,tagid,person,intime);
|
}else {//û¿ªÆôÎÀÐÇÐźÅÅжÏÊÒÄÚÍâ
|
pos_form_uwb_or_gps(0,person,"65535",intime);
|
person.setIndoor_or_outdoor(0);
|
person.setReason_indoor_from("UWBÅжϲ»ÔÚÊÒÄÚ");
|
}
|
}
|
}
|
}
|
}
|
}
|
|
/**È·¶¨Î»ÖÃÀ´Ô´ÊÇGPS»òÕßUWB
|
* int datafrom=0±íʾÊý¾ÝÀ´Ô´GPS£¬1±íʾÀ´Ô´ÓÚUWB*/
|
public static void pos_form_uwb_or_gps(int datafrom,Person person,String baoxu,String intime) {
|
String tagid=person.getP_tagid();
|
Tag tag = Tag_Dell.get_tag(tagid);
|
int x=person.getUwb_x();
|
int y=person.getUwb_y();
|
double z=person.getUwb_z();
|
String floor=person.getP_floor();
|
if(datafrom==0) {//Èç¹ûÊý¾ÝÀ´Ô´ÊÇGNGGA
|
x=person.getGps_x();
|
y=person.getGps_y();
|
z=person.getGps_z();
|
floor=String.valueOf(person.getGps_floor());
|
}
|
if (Fences.get_fence_vector("Î§Ç½ÇøÓò").size()>0){//Èç¹ûÎ§Ç½ÇøÓò´æÔÚ
|
if(tag.getTag_in_wall()==0) {
|
int[] ints = PointIsInWall.inwall(x, y,floor);
|
if (ints!=null) {
|
x = ints[0];
|
y = ints[1];
|
}
|
}
|
}
|
String xx=String.valueOf(x);
|
String yy=String.valueOf(y);
|
int intz=(int)z;
|
String zz=String.valueOf(intz);
|
String batarry=person.getP_power();
|
String state=person.getJingzhi();
|
String sos=person.getP_sos();
|
person.setPosfrom(datafrom);
|
person.setP_online("1");
|
int intfloor=Integer.parseInt(floor);
|
PointIsInwuxiao.juge(person, x, y,intfloor,intz);//ÅжϱêÇ©ÊÇ·ñÔÚÎÞÐ§ÇøÓò
|
int inwuxiao=person.getInwuxiaoqu();//ֵΪ1±íʾÔÚÎÞÐ§ÇøÓò0²»ÊÇ
|
if(inwuxiao ==1) {//ÔÚÎÞÐ§ÇøÓòÔò·µ»Ø
|
person.setReason_indoor_from("ÔÚÎÞÐ§ÇøÓò");
|
return;
|
}
|
person.setP_x(x);
|
person.setP_y(y);
|
person.setP_z(intz);
|
person.setP_floor(floor);
|
person.setLasttime(GetNowTime.now());
|
Dell_ReallPoint.insertpoid(tagid, x, y,floor);//½«Î»ÖÃÐÅÏ¢·ÅÈë¹ì¼£¼¯ºÏ,Èç¹û²»ÊDz»ÏÔʾʵʱ¹ì¼£
|
if(Systems.isGps2000()) {//Èç¹û¿ªÆôxyתgnss
|
double[] xycs=Map_Dell.get_xycs(floor);
|
if (xycs!=null) {
|
String a[] = xytoutm.xy2jwd(xx, yy, xycs);
|
String jingdu = String.valueOf(a[1]);//¶È¸ñʽ
|
String weidu = String.valueOf(a[0]);//¶È¸ñʽ
|
jwd=jingdu+","+weidu;
|
display.out2(tagid, jingdu, weidu, zz, batarry);
|
person.setBaoliu2(jingdu);
|
person.setBaoliu3(weidu);
|
person.setBaoliu4(zz);
|
|
}
|
}else {//Èç¹ûûÓпªÆôxyתgnss
|
display(x,y,tagid, baoxu, intime,floor, xx, yy,zz, batarry,state,sos,person);
|
}
|
//Èç¹ûÊÇÓÐЧµÄλÖÃÐÅÏ¢ÐèÒª×öЩÊÂÇé
|
HaveOkPosDo.do_something(tagid,baoxu,x,y,intz,floor,zz,batarry);
|
PutPosInHistoryDataBase.putInHistory(person,tagid,xx,yy,zz,floor,"-1",jwd);//Êý¾Ý´æÈë¹ì¼£Êý¾Ý¿â
|
|
}
|
|
|
/**ת·¢Î»ÖÃÊý¾Ý*/
|
public static void display(
|
int x,
|
int y,
|
String tagid,
|
String baoxu,
|
String intime,
|
String ceng,
|
String xx,
|
String yy,
|
String zz,
|
String batarry,
|
String state,
|
String sos,
|
Person per) {
|
if(Systems.isRealzhuanfa()) {//Èç¹û¿ªÆôʵʱλÖÃת·¢¼ä¸ô
|
if(per.getZhuanfatime()==null) {
|
display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
|
per.setZhuanfatime(GetNowTime.now());
|
}else {
|
display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
|
per.setZhuanfatime(GetNowTime.now());
|
|
}
|
}else {//Èç¹ûûÓпªÆôʵʱλÖÃת·¢¼ä¸ô
|
display.out(tagid, baoxu, intime, ceng, xx, yy,zz, batarry,state, sos);
|
}
|
/**Êý¾Ý¸ñʽ£º
|
* °üÐò+±êÇ©ID£¨Î¨Ò»£©+X×ø±ê+Y×ø±ê+Z×ø±ê£¨×ø±êµ¥Î»ÀåÃ×£©+¾¶È+ά¶È+¸ß³Ì+Êý¾ÝÀ´Ô´(1±íʾUWB£¬0±íʾÎÀÐÇ)*/
|
if(Systems.getZijiesuan() !=0) {//×Ô½âËãģʽÈç¹û¿ªÆô
|
double[] xycs=Map_Dell.get_xycs(ceng);
|
String a[]=xytoutm.xy2jwd(xx, yy,xycs);
|
String jingdu2=String.valueOf(a[3]);//¶È·Ö¸ñʽ
|
String weidu2=String.valueOf(a[2]);//¶È·Ö¸ñʽ
|
double dz=Double.parseDouble(zz);
|
Zjsdo.sendxy(per,tagid, baoxu, x, y,dz,jingdu2,weidu2,ceng);
|
}
|
}
|
|
|
/**ÅжÏÊÇ·ñÔÚÊÒÄÚÇøÓòͨ¹ýÊÒÄÚÇøÓòÅжÏ*/
|
public static void juge_indoor_fence(Person person,String baoxu,String intime) {
|
if(Dell_tb_suanfa2.isInuwbarea()) { //Èç¹û¿ªÆôÊÒÄÚÇøÓòÅжϹ¦ÄÜ
|
int size=Fences.getShinei_fences().size();
|
if(size !=0 ) {
|
int x=person.getUwb_x();
|
int y=person.getUwb_y();
|
String floor=person.getP_floor();
|
String tagid=person.getP_tagid();
|
Point2D.Double point=new Point2D.Double(x,y);
|
PointIsInshinei.is_in_shinei(size,Fences.getShinei_fences(),
|
tagid,x,y, floor,point);
|
int inddorfc=person.getIndoor_fence();
|
if(inddorfc==1) {//ÔÚÊÒÄÚÇøÓò
|
person.setIndoor_or_outdoor(1);
|
person.setReason_indoor_from("ÔÚÊÒÄÚÇø");
|
if(person.getGngga_state() !=4) {//GNGGA²»ÊǸ߾«¶È״̬
|
pos_form_uwb_or_gps(1,person,baoxu,intime);
|
}
|
}else {
|
person.setReason_indoor_from("²»ÔÚÊÒÄÚÇø");
|
}
|
}
|
}
|
}
|
|
/**¸ù¾ÝÐźÅÇ¿¶ÈÅжÏURTÊÇ·ñÔÚÊÒÄÚ
|
* @param lenthGNGGA±¨Îij¤¶È
|
* @param gpsxinhao URTÐźÅÇ¿¶È*/
|
public static void juge_urt_indorr_to_xinhao(Tb_gps gps,String gpsxinhao,
|
String tagid,Person person,String intime) {
|
|
//ÎÀÐÇÐźÅÇ¿¶È
|
int gpsqiangdu=Integer.parseInt(gpsxinhao);
|
int jishu=gps.getGpsxinhaonum();
|
int xinhao=gps.getGpsxinhao();
|
if(jishu<Dell_tb_suanfa2.getGpsjishu()) {
|
gps.setGpsxinhao(xinhao+gpsqiangdu);
|
int num=jishu+1;
|
gps.setGpsxinhaonum(num);
|
}else {
|
double pingjun=xinhao/jishu;
|
person.setGpsxinhao10(String.valueOf(pingjun));
|
//Èç¹ûÐźÅÇ¿¶È´óÓÚµÈÓÚmax
|
if(pingjun>=Dell_tb_suanfa2.getMax()) {
|
person.setIndoor_or_outdoor(0);
|
person.setReason_indoor_from("GPSÐźÅÇ¿¶ÈÇ¿");
|
pos_form_uwb_or_gps(0,person,"65535",intime);
|
}else if(pingjun<=Dell_tb_suanfa2.getSmall()) {
|
person.setIndoor_or_outdoor(1);
|
person.setReason_indoor_from("GPSÐźÅÇ¿¶ÈÈô");
|
pos_form_uwb_or_gps(1,person,"65535",intime);
|
}
|
gps.setGpsxinhao(0);
|
gps.setGpsxinhaonum(0);
|
}
|
}
|
|
/**½«XY×ø±êתΪ¶È¸ñÊ½×ø±ê
|
* @param xxΪX×ø±ê
|
* @param yyΪY×ø±ê
|
* @param floorËùÔÚ²ã*/
|
public static String[] xy2d(String xx,String yy,String floor) {
|
String[] jw= {"0","0"};
|
if(Systems.isGps2000()) {//Èç¹û¿ªÆôxyתgnss
|
double[] xycs=Map_Dell.get_xycs(floor);
|
if (xycs!=null) {
|
String a[] = xytoutm.xy2jwd(xx, yy, xycs);
|
jw[0] = String.valueOf(a[1]);//¶È¸ñʽ
|
jw[1] = String.valueOf(a[0]);//¶È¸ñʽ
|
}
|
}
|
return jw;
|
}
|
|
|
/**½«xyת»»ºóµÄÊý¾Ý·¢Ë͸øÖ÷»ùÕ¾
|
* @param tagid
|
* @param lat
|
* @param lon
|
*//*
|
public static void data2ac(String tagid, String lat, String lon, String anchorid){
|
String out2ac="uwb,"+tagid+","+lat+","+lon+","+GetNowTime.sss();
|
byte[] byt= out2ac.getBytes(StandardCharsets.UTF_8);
|
|
if (!anchorid.equals("gps")) {
|
Anchor anchor = Anchor_Dell.get_anchor(anchorid);
|
if (anchor!=null) {
|
Udp_Receive.out(byt, byt.length, anchor, "Ï·¢uwb");
|
}
|
}
|
}*/
|
|
}
|