| | |
| | | return (Polygon) area; |
| | | } |
| | | |
| | | /** |
| | | /** |
| | | * 获取某点周围指定距离(米)的缓冲区,返回WKT字符串格式 |
| | | * |
| | | * @param lon 中心点经度 |
| | | * @param lat 中心点纬度 |
| | | * @param distance 距离(米) |
| | | * @return WKT格式的多边形字符串,格式:POLYGON((lon1 lat1, lon2 lat2, ...)) |
| | | * @return EWKT格式的多边形字符串,格式:SRID=4326;POLYGON((lon1 lat1, lon2 lat2, ...)) |
| | | */ |
| | | public static String getBufferAroundPointAsString(double lon, double lat, double distance) throws Exception { |
| | | Polygon polygon = getBufferAroundPoint(lon, lat, distance); |
| | | return polygon.toText(); |
| | | return "SRID=4326;" + polygon.toText(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将Polygon对象转换为WKT字符串格式 |
| | | * |
| | |
| | | // 获取设备位置 生成缓冲区 |
| | | if (gdManageDeviceEntity.getLongitude() != null && gdManageDeviceEntity.getLatitude() != null) { |
| | | String bufferAroundPointAsString = GeomUtils.getBufferAroundPointAsString(gdManageDeviceEntity.getLongitude(), gdManageDeviceEntity.getLatitude(), 5 * 1000); |
| | | log.info("saveOrUpdateDevice {}", bufferAroundPointAsString); |
| | | gdManageDeviceEntity.setGeom(bufferAroundPointAsString); |
| | | String location = GdGeoAddressUtil.getFormattedAddress(gdManageDeviceEntity.getLongitude(), gdManageDeviceEntity.getLatitude()); |
| | | gdManageDeviceEntity.setLocation(location); |