Design and implementation of dynamic safety supervision system based on study tour for primary and secondary school students

At present, in the process of study tour, study tutors are responsible for supervising the safety of primary and secondary schools' students, and many hidden dangers are present in safety supervision. Therefore, how to provide study tutors with intelligent information tools and thus help safety tour have become the primary issue for the construction of research bases and the normal. For this reason, this study proposes an adaptive dynamic security area generation method and dynamic security area early warning technology. By comparing the location of the dynamic security area and the dangerous area, whether the users in the area are in a safe state can be determined. On the basis of mobile smart terminals, a dynamic safety supervision system that supports the study tour of primary and secondary school students has been developed. Practical application shows that the system has perfect functions and safe, stable, and reliable performance. The system has good application prospects and promotion value and can be used in other similar field safety management and control fields.

interacts with physical, mental, emotional and social aspects during learning. Therefore, it can be considered that outdoor education carried out in natural surroundings, and meeting individuals' physical, spiritual, and physiological needs are effective factors in the learning and teaching process. 1 Study tours are a form of outdoor education. Unfortunately, not all students enjoy study tours as a way to learn, perhaps because of the unfamiliarity of the environment or the unknown dangers. 2,3 In 2016, the Ministry of Education issued Opinions on Promoting Study Tours for Primary and Secondary School Students, which indicated that study tours for primary and secondary school students are organized and arranged by education departments and schools in a planned manner, combining research study and travel experience in group travels and centralized accommodation. Such tours are an innovative form of articulation of school education and out-of-school education, an important subject of education and teaching, and a comprehensive practical education for students. These activities are also an important element of education and teaching and an effective way to educate students through comprehensive practice. 4 Study tours activity is integrated with visual, hearing, feeling, perception, express the subject information from several aspects, stimulate students' sensory perception, improve the interactivity. 5 Moreover, many provinces (municipalities, districts) are actively creating local-level model bases for study tours, and study tours are developing rapidly in China. 6 The development of study tours in China is in full swing. However, the outdoor security system and early warning system are not perfect, and students' safety awareness is weak. Thus, how to effectively protect the personal safety of traveling students has become a topic of interest.
Commonly used security monitoring approaches include intelligent video monitoring, sensor monitoring, and location service monitoring. Intelligent video analysis technology, with the help of computer data processing functions, effective identification, and analysis and judgment of the target event, can make timely and appropriate responses to abnormal behavior and insecurity events and achieve preset early warning and analysis, feature storage, and other functions. 7 Zhao improved the quality of sports participation of left-behind children by transmitting high-definition video streams in real time through wireless network monitoring. 8 The method is based on the location service provider's access to the video of the examination room. Location service monitoring is based on the location service provider obtaining the geographic location of the monitoring target and providing personalized location services for the target through the analysis of the target location. Cui et al. realized real-time monitoring of field geological survey operators, vehicles, ships, and aircraft and real-time interaction with operators based on key technologies, such as Baidu map API, location-based services, and hybrid development model. 9 Neven et al. created an application called Viamigo for persons with intellectual disabilities; this application determines the location of the user and compares this in time and space within a predetermined range and automatically sends notifications to the coach in case the user deviates from the route, travels at an incorrect speed, or enters or leaves a safe or dangerous zone. 10 Geofencing technology has important applications in the fields of information push, smart home, attendance and check-in, child safety monitoring, and smart medical care. 11 It is used to build virtual geographic boundaries. When the target enters or leaves the constructed geofence, the mobile device can automatically get a notification or warning message. 12 Shen et al. designed a smartphone-based security monitoring system to realize the visualization of user monitoring, networking of information transfer, and intelligence of information prompting to solve problems of real-time monitoring of personnel location and security warning of abnormal situations. 13 Fu et al. designed a family member safety monitoring system to realize real-time positioning of the warded person, judge the safety status of the warded person, and automatically issue an early warning by judging whether the warded person is beyond the virtual fence. 14 Wu designed a collaborative positioning monitoring system that can monitor the location information of people prone to wandering and also allows users to monitor the location of targets by setting geofencing to meet users' monitoring needs. 15 Li completed the development of a mobile location system for Android and provided users with location services, such as route navigation, track tracking, and geofencing based on location capabilities. 16 Ilyas et al. created a geofence (geographical safe zone) for cattle based on IoT (Internet of Things) and GPRS (General Packet Radio Service), where the cattle are assigned dedicated IoT sensors. The cattle can be easily remotely monitored and controlled without any need for farmers to intervene in livestock management physically. This type of livestock management may help prevent the spread of COVID-19, lower farming costs, and enable remote monitoring. 17 This study mainly conducts research based on geofencing technology, and most of the above results are based on static geofencing research, with few applications based on dynamic geofencing technology. In this study, a system is designed and implemented based on dynamic geofencing for safety supervision, with the background of outdoor safety needs of primary and secondary school students' study tours, combined with dynamic safety area judgment and early warning analysis technologies.

Dynamic security region generation method
Geofencing is an application of LBS (Location Based Service), where a virtual fence is used to enclose a virtual geographic boundary, such that the phone can receive automatic notifications and warnings when it enters, leaves, or moves within a specific geographic area. 18 Geofencing requires neither a considerable amount of memory nor numerous computing resources, but direct access to the hardware device to retrieve location data. 19 Geofencing can be static or dynamic, and it can be divided into static and dynamic geofencing according to continuity. 20 The boundary of static geofencing does not change with time and location, whereas dynamic geofencing is moving with time and location. 21 Study tour often way to mountains, mountains with rich natural landscape and human landscape, changeable, associated with complex winding roads and undulating terrain. 22 Dangerous areas that threaten students' safety can be divided into several types, such as rivers and lakes, cliffs, dangerous obstacles (such as high-voltage electric piles and landslide areas), steep slopes, and beast-infested areas, depending on the outdoor natural environment (as shown in Figure 1). The method to determine the boundary of the hazardous area in this study is based on the shape of the area delineated. For example, if most of the water hazardous area is curved, then a curved buffer zone surrounding the river hazardous area is set up by extending 10 m outward from both sides of its boundary to form a river hazardous area buffer zone. Other types of hazardous areas are set up in a similar manner with different shapes of buffers.
In the process of moving the research tutor, the area within 10 m of its boundary (this boundary range can be customized) is circled to form a safety area buffer zone. The longitude and latitude coordinate strings of the study tutors and the boundaries of the safe and dangerous areas are obtained through GPS technology and stored in the server. During the movement of the research tutor, to determine whether the location coordinate information of the research tutor falls into the preset danger area, the distance between the research tutor and the center of the danger area can be calculated by the latitude and longitude coordinates. If this distance is greater than the set radius of the safe area, then the range of the safe F I G U R E 1 Schematic of hazardous and active areas with simulated activity trajectory. area remains unchanged. Conversely, the range of the safe area has partially overlapped with the range of the hazardous area. At this time, the range of the safe area needs to change, such that the latitude and longitude of the boundary of the safe area is equal to the latitude and longitude of the boundary of the buffer zone of the overlapping hazardous area, thereby forming the specific range of the new safe area, which is a dynamic safe area. On the basis of this technology, an intelligent monitoring system for mobile safety area has been designed and authorized by the State Intellectual Property Office for invention patent. 23 The simulated activity trajectory map and the location relationship schematic are shown in Figure 1. The research tutors and students have preset moving routes, such as safe areas A and A ′ , as shown in Figure 1, which are displayed in green, indicating safety, when the position relationship between the research tutor activity area and each danger area buffer is away from each other. When the position relationship between the research tutor activity area and the danger area buffer is intersecting, such as the danger area C shown in Figure 1, which is displayed in red, indicating danger, and the system will issue an early warning. When the location relationship between the study tutor activity area and the danger area buffer is tangent, such as the warning area B shown in Figure 1, which is displayed in orange, danger may occur. If the students are out of the range of activities of the study tutors, the display is orange, such as student β in the diagram, then the system will send early warning information to students and teachers, indicating that danger may exist. If students mistakenly enter the range of dangerous areas, the display is red, such as student α in the diagram, then students need to leave this area immediately, and teachers need to go to the rescue in the field if necessary.

Dynamic security area warning technology
After the buffer zone of the dynamic safety area is determined, the student location information is obtained through real-time positioning technology to determine the relationship between the student's location and the inside and outside of the dynamic safety area. Once the real-time location of the identified student is outside the range of the dynamic safety area, it is considered to be out of bounds and may be in a dangerous state. To simplify the calculation and speed up the server response speed without affecting judgment accuracy, the intelligent safety identification technology transforms the dynamic safety area, which is partly composed of irregular polygons with smooth curves, into linear irregular polygons. In this manner, the dynamic geofencing is constructed, and the essence of the boundary crossing detection is transformed into the judgment of the internal and external relationships between points and polygons in the dynamic geofencing.
To determine whether the circular safety buffer zone, centered on the research tutor, is adjacent to or even overlaps with the preset danger area, can be based on the tangent, intersection, and departure relationships between the circle and the straight line and the circle and the circle.
In Case 1, the position relationship between a circle and a line is determined. Assuming that the perpendicular distance between the center of the circle and the line is d O-L , three cases determine the position between the two: 1 the two are tangent, d O-L = R; 2 the two intersect, d O-L < R; and 3 the two are separated, d O-L > R, as shown in Figure 2.
In Case 2, to determine the position relationship between two circles, assuming the perpendicular distance between the two circle centers is d O1-O2 , the position determination between the two circles will have three cases: 1 two circles F I G U R E 2 Determination of the location of circular buffer zone and linear danger area. F I G U R E 3 Determination of the relationship between circular safety buffer zone and circular hazard buffer zone location. are externally tangent, d O1-O2 = R + R 1 ; 2 the two circles intersect, R-R 1 < d O1-O2 < R + R 1 ; and 3 the two circles are separated, d O1-O2 > R + R 1 , as shown in Figure 3.
However, dynamic safety regions cannot all be regular polygons, and when it comes to more complex and refined regions, the judgment of complex irregular polygonal regions will be introduced. For example, some research bases, undulating terrain, intersecting roads, and highly complex waters, cannot use simple graphics to directly circle the dangerous area. Such areas often need to introduce complex curves and irregular polygons based on the terrain to accurately divide the danger and safety areas. The traditional Method is based on the winding number. 24 Winding number (ω) is defined as how many times the polygon "S" winds around that point "P". If "P" is inside a polygon "S", then ω is nonzero. Similarly, if point "P" is outside, only when the polygon does not wind around the point at all that means ω = 0. The winding number is defined as a contour integral in the complex plane. Winding numbers play an important role in complex analysis. The winding number ω of a closed polygon "S" in complex plane is expressed in terms of the complex coordinate form as below (expression (1) and (2)).
The winding number of closed polygon "S" about the origin is given by the expression (3).
Obviously, traditional methods are too complex. Therefore, in this study, light projection algorit h m is used to solve the judgment of the position relationship between points and complex polygons. 25 The algorithm is illustrated in Figure 4, with point q located at the origin and polygon L = {l 1 ,l 2 , … , l 6 } containing six vertices. Notably, given that point q is located at the origin of the coordinates, the ray derived from it coincides with the x-axis.
According to the ray projection algorithm, given that point q lies neither on any vertex nor edge, the first point l 1 which is not on the x-axis is found sequentially and is denoted as l s . Iteration over the next point is l 2 . The process of F I G U R E 4 Example diagram to determine the point inside and outside the polygon. finding l 2 does not cross any vertex; thus, the number of intersections does not increase. Now, l 3 is traversed. Given that vertex l 3 is on the x-axis, i is incremented by 1. Similarly, traversing is performed all the way to l 5 , which is not on the x-axis. From vertex l 2 to l 5 crosses vertices l 3 and l 4 on the x-axis, but the line does not intersect the x-axis; thus, the number of intersection points does not increase by 1. At this point, start with l s = l 5 , continue to find the next vertex l 6 , which is on the x-axis, and i is incremented by 1, because l 6 is on the x-axis and it is the last vertex; the next vertex is l 1 . Given that point l 6 , which is positive on the x-axis, is crossed from l 5 to l 1 , and the line segment {l 5 ; l 1 } intersects the x-axis, the number of intersections is increased by 1. Up to this point, the algorithm has traversed all points on L, and the number of intersections is odd (the value is 1). Point q is determined to be in the interior of L.
If the system determines that the student's location data is not within the safety range of the dynamic geofencing (i.e., the student's location point is outside the polygon), then the system will automatically issue a warning to the student and the study tutor, and the study tutor can view information related to the student who has deviated from the safety route to facilitate the management of the study process; here, the monitoring method for determining whether a moving object has left the safety area has received the State Intellectual Property Office Invention patent granted. 26 The method of monitoring whether a moving object has left the safety zone has been granted a patent by the State Intellectual Property Office.

Functional module design
The system adopts the C/S mode and mainly consists of three terminals, namely, the teacher's cell phone terminal, the student's watch terminal, and the parent's web terminal. Some elementary school students are not allowed to travel with smartphones. In response to this situation, this study kindly and thoughtfully develops a smartwatch port that can be developed twice to meet the needs of students, in which a watch IP corresponds to a student. The smartwatch has some simple and practical functions, such as automatic one-touch calls, vibration, voice reminders, and real-time positioning. Middle school students can enter the student page on the cell phone side by scanning the corresponding QR code on the smartwatch, which has the same functions as the watch side, as shown in Figure 5.
The system is mainly divided into four functional modules, namely, real-time positioning module, dynamic fence supervision module, danger warning prompt module, and map display module. The system obtains real-time location information of study tutors and students through GPS technology and generates dynamic safety areas based on dynamic geofencing technology, thereby determining whether the state of students is safe. Then, the system sends feedback to teachers and students according to early warning technology. Each smartwatch corresponds to a student, and the teacher can send various instructions to the student through the watch. The daily trajectories of students and teachers are displayed on a map, which allows parents to view the specifics of the study tour. In addition, given that most of the study tour is outdoors, the study tutor will be alerted when the battery of the student's watch device is low, F I G U R E 5 Watch side page.

F I G U R E 6
Functional structural diagram of the safety dynamic supervision system. or when the student's smart device no longer seems to have connectivity. In case of special circumstances (inclement weather), the study tutor can make a one-touch call directly to the student's watch device via smartphone to ensure the student's safety.
The functional structure of the system is shown in Figure 6.
(1) Real-time positioning module. As the service scenes of study tours are complex and diverse, covering two places (indoor and outdoor) and the safety intelligent supervision technology in this study is more inclined to the safety supervision of field scenes. Thus, the real-time positioning of safety intelligent supervision adopts the combination of A-GPS and WiFi positioning, which can achieve better positioning effects in the face of different study scenes. A-GPS has a wide range of applications and can meet the positioning needs of students in the field. WiFi positioning has high accuracy and is suitable for the positioning service of indoor study tours. After obtaining the real-time positioning data of teachers and students, the data are uploaded to the server to provide data sources for the subsequent functional implementation.
(2) Dynamic geofencing supervision module. First, GIS technology is used to analyze the danger area, and the latitude and longitude coordinates of the danger area are entered into the database. The security area is a circular buffer zone centered on the study tutors. The radius size of this buffer zone can be defined on the cell phone terminal, with the movement of the teacher. This circular safety area will also change, and the coordinate string of the safety area is also recorded in the database. If the system determines that the safe area and the danger area overlap, then the safe area will change and the new safe area will not include the part that overlaps with the danger area. As a result, an adaptive safety zone is formed, and intelligence is achieved.
(3) Danger warning prompt module. In the study process, study tutors cannot take into account every student, the need to use information technology means real-time monitoring of students. In the process of student movement, its location information is also recorded in real time in the database. If the student leaves the teacher's range of activities, that is, the student's coordinate position is not in the adaptive security region dynamically generated by the system, then the system will send a danger warning to the student's watch device and the teacher's cell phone and record. The student's personal smartwatch will send a vibration to remind the student to return to the safety zone and to the teacher about the students who are far away from the safety zone.
(4) Map display module. Mobile track display, safety and danger area display, path navigation, and other functions need the support of the map. During the study tour, the system completes the map display and positioning according to the map control; places the layout of the map layer at the bottom for display; and then adds a point layer, a line layer, a marker layer, and an information display layer on top. When the map control is successfully displayed, based on the user's positioning, a new maker is added on top of the Baidu map layer to indicate the current location of the user. The map can also display the user's movement trajectory to visualize the geographic data and make it easy for all types of users to view.

Database design
When using the outdoor dynamic safety supervision system, the students' location information is generated almost in real time. With such a large amount of data, the basic Android built-in database cannot meet the storage needs. Thus, the outdoor dynamic safety supervision system in this study mainly relies on MySQL database to store the various data types generated in real time.
The main users of this system are study tutors and students. Study tutors can view the basic information of students, as well as location information. When traveling for outdoor activities, teachers can be interrelated with students, and students and teachers can be interrelated with activities. The design of database tables can observe the relationship between the users, such as a study tutor corresponding to multiple students in the group, due to the connection of database tables. The teacher can only see the specific information of the students in the group and can only evaluate and assess the study activities of the students in the group. For space reasons, listing all the database tables is impossible. Figure 7 shows the diagram of the key entity relationships of the system, and Tables 1-6 present the key database tables.

F I G U R E 7
System critical E-R diagram.

System development environment
The outdoor dynamic safety supervision system based on mobile intelligent terminal uses Java language to develop Android background application. The system development environment is Eclipse and Android Studio, and the development process uses many JSP technologies. Given that the outdoor dynamic safety supervision system generated by the data is mostly latitude and longitude data, the data is not particularly large. The system's background database uses MySQL database, and the system selects Tomcat server for background operation.

Implementation of dynamic fence supervision
After the user successfully logs into the system, the system automatically turns on the real-time positioning function by default. The mobile terminal uses the satellite chip carried by the Android phone to receive the latitude and longitude information and display the location on the map. First, it obtains the location management information through the API that comes with Android. Then, it registers a periodic location update through the locationManager.requestLocationUpdates() method. The Android mobile terminal uses the getLatitude() and getLongitude() methods in the onLocationChanged function to obtain the latitude and longitude data sent by the satellite to the mobile terminal. Each student participating in the study activity will wear a smartwatch with GPS function (or carry a smartphone with GPS function), and the students' location data will be automatically uploaded to the server. The study tutors can use the real-time positioning data obtained by the system to supervise the students and issue corresponding instructions to control the study process and manage academic safety, as shown in Figure 8 F I G U R E 8 Research activity instruction page.

F I G U R E 9
Teacher safety supervision page.

Implementation of hazard warning alerts
During the movement of the research tutor, the system will combine the location data obtained from real-time positioning and dynamic geofencing technology to generate an adaptive dynamic safety zone using the mathematical model of point and polygon position relationship judgment. If the coordinates of the student are judged not to be within this safety zone, then the student's watch will automatically alert the student to cross the boundary behavior in the form of a vibration or ringing bell, which may enter the danger zone. At the same time, the study tutor's cell phone will also receive a reminder that the student has crossed the border, and the study tutor can click on the view alert status page to view the student's danger status. After the research tutor clicks on the view, he or she can view the information related to the student in danger, including the student's name, equipment condition, and danger category. If the urgency of the situation is general, then the study tutor can choose to contact the student directly by phone to inform him or her of the danger information status or directly through the command operation to inform the student that he or she is out of the safe range; or the student can directly use the watch to make a one-touch call to his or her study tutor for help. If the situation is extremely urgent, then the study tutor can check the student's last location through the student's track information and go to the field for rescue. The test results are shown in Figure 9.

Implementation of map track display
After the mobile terminal receives the trajectory information, it draws the trajectory according to the chronological order; draws the starting point, ending point, and the record points of the travel route according to the user's travel route at that time; adds a point layer on top of the map layer; and uses the line layer to connect the record points between the record points to realize the visualization of the user's movement trajectory. When the study activities are over, the study tutors can use the student trackback function to view the students' study history dynamics, including the students' location tracks, uploaded voice and video materials, and text information in the study activities. The parent side can also view the daily activity routes of students during the study tour at any time to remotely supervise the safety of students. The test results are shown in Figure 10.

Test environment
For the test, the intelligent terminal of the study tutor chose Huawei Mate 40 cell phone, and the student terminal uses Huawei Android smartwatch. The experimental test sites are selected at dangerous obstacles (with high-voltage lines), water areas, and mountains. The purpose of the test is to determine the safety detection effect of the system terminal equipped with dynamic safety supervision technology under different terrain conditions.

Test methods and results
The test method sets up separate hazard area buffers of different shapes and sizes at different experimental sites. Test person 1 (playing the role of research tutor) carries a smartphone to keep moving normally. Different radii of safe activity areas are set with Tester 1 as the center. Test person 2 (playing the role of students) carried a smartwatch near the activity area and conducted n times of marching experiments. The marching methods include Test person 2 entering the danger area, leaving the range of the safe activity area, and keeping normal movement. The test results are shown in Table 7. The average error distance indicates the average of the distance error between the actual crossing place and the test display crossing place. When the distance between the test display crossing place and the actual crossing place exceeds the radius of the experimental activity, the crossing detection is regarded as a failure. The success rate indicates the proportion of the number of successes in successfully identifying Test person 2's transgression within the acceptable error range.

Analysis of results and discussion
The test results basically meet the expected requirements when the test site is located in a flat terrain and a good mobile phone signal area. The test site is a mountainous area with undulating terrain, high terrain, and many tall obstacles. The accuracy and precision of the location of the border crossing detection are not sufficiently high. The analysis of the experimental error shows that the error source is mainly the accuracy of intelligent terminal positioning errors. Dynamic safety supervision technology still has a reference value. Dynamic security region can be successfully generated, and in most experiments, Tester 2 crossing the border can be successfully detected, and the system will automatically send a warning notice. Conversely, given that most of the outdoor study areas of study tours are also open terrain and rarely involve mountainous areas, the dynamic safety supervision technology in this study can meet the safety supervision needs of most outdoor scenes of study tours and facilitate study tutors to supervise students' outdoor safety activities in study tours, which has high practical value and can be applied to the construction of outdoor safety supervision systems of study tours.

SUMMARY
In this study, we investigate the safety supervision of students during study tours and related technologies and realize the generation of dynamic safety zones and intelligent safety warnings. On the basis of the aforementioned research on outdoor safety supervision methods, a complete dynamic safety supervision tool has been designed and implemented, which facilitates the centralized management of scattered students by study tutors and controls the study process, thereby greatly reducing the collective management cost of students and effectively ensuring their safety. Given that the study tour was conducted in 2017, the system has served tens of thousands of people, and through practical application, it has shown that the system is stable, normal, and reliable. This safety supervision system can also meet the security needs of outdoor safety for study tours, thereby creating good economic and social benefits. In addition, in the future, the system can be used to collect data on the trajectory of students in the study tour for behavioral analysis, will be a deep analysis of student character and action trajectory; and increase the education system, study bases and other multiple end users to provide better outdoor education services.
This system can be extended and formulated to create a safety regulatory framework that can be applied to other related industries, such as security for engineering field personnel, safe travel for the general public, guardianship for vulnerable groups, and precise services for emergency rescue.

DATA AVAILABILITY STATEMENT
Data sharing is not applicable to this article as no new data were created or analyzed in this study.