| | |
| | | package com.yssh.utils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.awt.geom.Point2D; |
| | | import java.util.*; |
| | | |
| | | import com.yssh.entity.Coordinate; |
| | |
| | | import org.opengis.referencing.crs.CoordinateReferenceSystem; |
| | | |
| | | public class CalculateUtils { |
| | | private final static SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH"); |
| | | |
| | | /** |
| | | * 获取年月日时 |
| | | */ |
| | | public static String getYearMonthDayHour(Date date) { |
| | | return ymdh.format(date); |
| | | } |
| | | |
| | | /** |
| | | * 默认地球半径,赤道半径(单位m) |
| | | */ |
| | |
| | | return ids; |
| | | } |
| | | |
| | | /** |
| | | * 根据范围获取查询条件 |
| | | */ |
| | | public static String getFilterByExtend(MonitorPointPosition point, int range) { |
| | | Integer x = point.getX(); |
| | | Integer y = point.getY(); |
| | | |
| | | return String.format("x between %d and %d and y between %d and %d", x - range / 2, x + range / 2, y - range / 2, y + range / 2); |
| | | } |
| | | |
| | | public static List<String> temporary(MonitorPointPosition point, int range) { |
| | | List<String> ids3d = new ArrayList<>(); |
| | | Integer x = point.getX(); |
| | |
| | | */ |
| | | public static List<Coordinate> calcRect(double x, double y) { |
| | | double buffer = 10; |
| | | double dis = round6(Math.sqrt(Math.pow(buffer / 2, 2) * 2)); |
| | | |
| | | List<Coordinate> list = new ArrayList<>(); |
| | | // |
| | | list.add(getPointByDisAndAngle(x, y, 315, dis)); |
| | | list.add(getPointByDisAndAngle(x, y, 45, dis)); |
| | | list.add(getPointByDisAndAngle(x, y, 135, dis)); |
| | | list.add(getPointByDisAndAngle(x, y, 225, dis)); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 根据距离和角度获取目标点 |
| | | */ |
| | | private static Coordinate getPointByDisAndAngle(double x, double y, double angle, double dis) { |
| | | try { |
| | | DirectPosition2D p1 = new DirectPosition2D(x, y); |
| | | |
| | | GeodeticCalculator gc = new GeodeticCalculator(); |
| | | gc.setStartingGeographicPoint(p1); |
| | | gc.setDirection(angle, dis); |
| | | |
| | | Point2D dest = gc.getDestinationGeographicPoint(); |
| | | double newX = round6(dest.getX()); |
| | | double newY = round6(dest.getY()); |
| | | |
| | | return new Coordinate(newX, newY); |
| | | } catch (Exception ex) { |
| | | return new Coordinate(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param @return 参数 |
| | | * @return Double 返回类型 |
| | | * @throws |