zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package tbDataModel_Dell;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import ColorAndFont.ChooseColor;
import DataBase.DatabaseManagement;
import home.Open_soft_dialog;
import tbDataModel.PolygonNew;
@SuppressWarnings("rawtypes")
public class Dell_Polygon {
 
    /**ËùÓжà±ßÐÎÇøÓò¼¯ºÏ*/
    static Vector<PolygonNew> polyVec=new Vector<PolygonNew>();
    static String id="";
    /**»ñÈ¡ËùÓеÄΧÀ¸¶ÔÏó*/
    static{
        Open_soft_dialog.addara("¼ÓÔØtb_fence");
        Iterator iterator = DatabaseManagement.get_alldate_indatabase("tb_fence").iterator();//´´½¨µü´úÆ÷
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
            List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
            id= (String) info.get(0);
            String floor=(String)info.get(1);
            String type=(String)info.get(2);
            String bumen=(String)info.get(3);
            String name=(String)info.get(4);
            String zuobiao=(String)info.get(5);
            String shape=(String)info.get(6);
            String start=(String)info.get(7);
            String stop=(String)info.get(8);
            String yanse=(String)info.get(10);
            String allFloor=(String)info.get(20);//2023.08.21 zsh ¶ÔËùÓÐͼ²ãÉúЧ
            add_a_fence_tomap(floor,type,bumen,name,zuobiao,shape,start,stop,yanse,allFloor);
        }
    }
 
    /**ɾ³ý¼¯ºÏÖеÄij¸öΧÀ¸¶ÔÏó*/
    public static void  delete_a_PolygonNew(String name) {
        if( found(name) !=null) {
            polyVec.remove(found(name));
        }
 
    }
 
    /**ÔÚµØÍ¼Ò³ÃæÔö¼ÓÒ»¸öΧÀ¸*/
    public static void add_a_fence_tomap(String floor,String type,String bumen,String name,
            String zuobiao,String shape,String start,String stop,String yanse,String allFloor) {
        if(found(name) !=null) {
            return;
        }
        PolygonNew poly=new PolygonNew();
        poly.setId(id);
        poly.setFloor(floor);
        poly.settype(type);
        poly.setBumen(bumen);
        poly.setName(name);
        poly.setShape(shape);
        poly.setStart(start);
        poly.setStop(stop);
        poly.setAllFloor(allFloor);//¶ÔËùÓÐͼ²ãÉúЧ
        if(shape.equals("¾ØÐÎ")) {
            double[] x=new double[2];
            double[] y=new double[2];
            String[] zb=zuobiao.split("\\,");//ÒÔ¡°£¬¡±·Ö¸î×Ö·û´®    
            x[0]=Double.parseDouble(zb[0]);
            y[0]=Double.parseDouble(zb[1]);
            x[1]=Double.parseDouble(zb[2])-Double.parseDouble(zb[0]);
            y[1]=Double.parseDouble(zb[3])-Double.parseDouble(zb[1]);    
            poly.setX(x);
            poly.setY(y);
        }else if(shape.equals("¶à±ßÐÎ")) {    
            //987,447;1548,576;1458,1203;1065,1197;939,735;987,447
            String[] xy_s=zuobiao.split("\\;");//ÒÔ¡°;¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµã×ø±ê
            double[] x=new double[xy_s.length];
            double[] y=new double[xy_s.length];
            for(int i=0;i<xy_s.length;i++) {
                String zbxy=xy_s[i];
                String[] xy=zbxy.split("\\,");//ÒÔ¡°,¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµãµÄxºÍy
                x[i]=Double.parseDouble(xy[0]);
                y[i]=Double.parseDouble(xy[1]);
            }
            poly.setX(x);
            poly.setY(y);
        }else if(shape.equals("Ô²ÐÎ")) {
            String[] zb=zuobiao.split("\\,");//ÒÔ¡°£¬¡±·Ö¸î×Ö·û´®
            double[] x=new double[1];
            double[] y=new double[1];
            double[] bj=new double[1];
            x[0]=Double.parseDouble(zb[0]);
            y[0]=Double.parseDouble(zb[1]);
            bj[0]=Double.parseDouble(zb[2]);
            poly.setX(x);
            poly.setY(y);
            poly.setBj(bj);//Ô²Ðεİ뾶
        }else if(shape.equals("һάÏß")){
            String[] xy_s=zuobiao.split("\\;");//ÒÔ¡°;¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµã×ø±ê
            double[] x=new double[xy_s.length];
            double[] y=new double[xy_s.length];
            for(int i=0;i<xy_s.length;i++) {
                String zbxy=xy_s[i];
                String[] xy=zbxy.split("\\,");//ÒÔ¡°,¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµãµÄxºÍy
                x[i]=Double.parseDouble(xy[0]);
                y[i]=Double.parseDouble(xy[1]);
            }
            poly.setX(x);
            poly.setY(y);
        }
 
        if(yanse==null) {
            yanse="ºìÉ«";
        }
        poly.setColor(ChooseColor.getColo(yanse,90));
        polyVec.add(poly);
    }
 
    /**ÕÒµ½Ä³¸ö¶à±ßÐζÔÏóͨ¹ýÃû³Æ*/
    public static PolygonNew found(String name) {
        PolygonNew poly=null;
        if(polyVec.size() !=0) {
            for(int i=0;i<polyVec.size();i++) {
                PolygonNew poly1=polyVec.get(i);
                String name1=poly1.getName();
                if(name1.equals(name)) {
                    poly=poly1;
                    break;
                }
            }
        }
        return poly;
    }
 
 
    /**ɾ³ýÈ«²¿µÄΧÀ¸¶ÔÏó*/
    public static void delete_all() {
        if(polyVec.size() !=0) {
            polyVec.removeAllElements();
        }
    }
 
 
    public static Vector<PolygonNew> getPolyVec() {
        return polyVec;
    }
 
 
    /**»ñÈ¡ËùÓеĿ¼ÇÚÇøÓòµç×ÓΧÀ¸*/
    public  static Vector<PolygonNew> get_kaoqing_fences(){
        Vector<PolygonNew> kaoqing_fences=new Vector<PolygonNew>();
        Iterator<PolygonNew> it= polyVec.iterator();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
        while (it.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            PolygonNew tbfence=it.next();
            String type=tbfence.gettype();
            if(type.equals("¿¼ÇÚÇøÓò")) {
                kaoqing_fences.add(tbfence);                
            }
        }
        return kaoqing_fences;
    }
 
    /**»ñÈ¡ËùÓÐµÄ¸æ¾¯ÇøÓòµÄµç×ÓΧÀ¸*/
    public static  Vector<PolygonNew> get_inwarning_fences(){
        Vector<PolygonNew> inwarning_fences=new Vector<PolygonNew>();
        Iterator<PolygonNew> it= polyVec.iterator();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
        while (it.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            PolygonNew tbfence=it.next();  
            String type=tbfence.gettype();
            if(type.equals("½øÈë¸æ¾¯")) {
                inwarning_fences.add(tbfence);                
            }
        }
        return inwarning_fences;
    }
 
    /**»ñÈ¡¿¼ÇÚÇøÓòµç×ÓΧÀ¸µÄµÄ×ÜÊý*/
    public  static int getkaoqing_fence_num () {
        int num =get_kaoqing_fences().size();
        return num;
    }
 
 
 
    public static void alert(String name,String bumen,String shape,
            String start,String stop,String zuobiao ) {
        PolygonNew poly=found(name);
        if( poly==null) {
            return;
        }
        poly.setBumen(bumen);
        poly.setStart(start);
        poly.setStop(stop);
        if(shape.equals("¾ØÐÎ")) {
            double[] x=new double[2];
            double[] y=new double[2];
            String[] zb=zuobiao.split("\\,");//ÒÔ¡°£¬¡±·Ö¸î×Ö·û´®    
            x[0]=Double.parseDouble(zb[0]);
            y[0]=Double.parseDouble(zb[1]);
            x[1]=Double.parseDouble(zb[2])-Double.parseDouble(zb[0]);
            y[1]=Double.parseDouble(zb[3])-Double.parseDouble(zb[1]);
            poly.setX(x);
            poly.setY(y);
        }else if(shape.equals("¶à±ßÐÎ")){
            //987,447;1548,576;1458,1203;1065,1197;939,735;987,447
            String[] xy_s=zuobiao.split("\\;");//ÒÔ¡°;¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµã×ø±ê
            double[] x=new double[xy_s.length-1];
            double[] y=new double[xy_s.length-1];
            for(int i=0;i<xy_s.length-1;i++) {
                String zbxy=xy_s[i];
                String[] xy=zbxy.split("\\,");//ÒÔ¡°,¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµãµÄxºÍy
                x[i]=Double.parseDouble(xy[0]);
                y[i]=Double.parseDouble(xy[1]);
            }
            poly.setX(x);
            poly.setY(y);
        }else if (shape.equals("һάÏß")){
            String[] xy=zuobiao.split("\\;");
            double[] x=new double[xy.length-1];
            double[] y=new double[xy.length-1];
            for(int i=0;i<xy.length-1;i++) {
                String zbxy=xy[i];
                String[] xy_y=zbxy.split("\\,");//ÒÔ¡°,¡±·Ö¸î×Ö·û´®´Ó¶ø»ñµÃÿ¸öµãµÄxºÍy
                x[i]=Double.parseDouble(xy_y[0]);
                y[i]=Double.parseDouble(xy_y[1]);
            }
        }
    }
}