zhitong.yu
2024-12-27 21e0b93688de2a98abe3b7b9c0cfed6efdc21183
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
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.*;
import com.hxzk.service.GpsGuiJiService;
import com.hxzk.service.GpsTrackService;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.awt.geom.Point2D;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping("/")
public class GpsTrackController {
 
    @Autowired
    GpsTrackService gpsTrackService;
 
    @GetMapping("findGpsTrack")
    result<List<TbGpsTrack>> findshishigaojing(Integer page, Integer limit){
        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        String formattedDate = currentDate.format(formatter);
        PageInfo<TbGpsTrack> cz= gpsTrackService.findAll(page,limit,formattedDate);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping("findJingWeiSearch")
    result<List<TbGpsTrack>>  findJingWeiSearch(Integer page,Integer limit,String tagid,String datte) throws ParseException {
        PageInfo<TbGpsTrack> cz= gpsTrackService.findJingWeiSearch(page, limit, tagid, datte);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping("findHourceCount")
    public List findHourceCount(String dates,String tagid){
        return gpsTrackService.findHourceCount(dates, tagid);
    }
    @GetMapping("findHourceCountHaiBa")
    public List findHourceCountHaiBa(String dates,String tagid) throws ParseException {
        return gpsTrackService.findHourceCountHaiBa(dates, tagid);
    }
 
 
    public static boolean isInPolygon(Point2D.Double point, List<Point2D.Double> pts) {
        int N = pts.size();
        boolean boundOrVertex = true;
        int intersectCount = 0;
        double precision = 2.0E-10;
        Point2D.Double p = point;
        Point2D.Double p1 = (Point2D.Double)pts.get(0);
 
        for(int i = 1; i <= N; ++i) {
            if (p.equals(p1)) {
                return boundOrVertex;
            }
 
            Point2D.Double p2 = (Point2D.Double)pts.get(i % N);
            if (!(p.x < Math.min(p1.x, p2.x)) && !(p.x > Math.max(p1.x, p2.x))) {
                if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) {
                    if (p.y <= Math.max(p1.y, p2.y)) {
                        if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) {
                            return boundOrVertex;
                        }
 
                        if (p1.y == p2.y) {
                            if (p1.y == p.y) {
                                return boundOrVertex;
                            }
 
                            ++intersectCount;
                        } else {
                            double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;
                            if (Math.abs(p.y - xinters) < precision) {
                                return boundOrVertex;
                            }
 
                            if (p.y < xinters) {
                                ++intersectCount;
                            }
                        }
                    }
                } else if (p.x == p2.x && p.y <= p2.y) {
                    Point2D.Double p3 = (Point2D.Double)pts.get((i + 1) % N);
                    if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) {
                        ++intersectCount;
                    } else {
                        intersectCount += 2;
                    }
                }
 
                p1 = p2;
            } else {
                p1 = p2;
            }
        }
 
        if (intersectCount % 2 == 0) {
            return false;
        } else {
            return true;
        }
    }
 
    //二维地图查询轨迹
    @PostMapping("trackTagid.do")
    public List<TbTrackGps> queryTagid(HttpServletRequest request,String tagid,String start,String end) throws ParseException {
        List tagList = gpsTrackService.getTagtrack(tagid,start,end,"0");
        return tagList;
    }
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
}