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());
|
}
|
|
|
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) throws ParseException {
|
String tag_id = request.getParameter("tag_value");
|
String begin_time = request.getParameter("begin_value");
|
String end_time = request.getParameter("end_value");
|
String floor = request.getParameter("floor_value");
|
List tagList = gpsTrackService.getTagtrack(tag_id,begin_time,end_time,floor);
|
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;
|
}
|
}
|