12 files modified
21 files added
| New file |
| | |
| | | package com.dji.sample.media.model; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | @Data |
| | | public class MinioPojo { |
| | | @Value("${oss.endpoint}") |
| | | private String endpoint; |
| | | |
| | | @Value("${oss.access-key}") |
| | | private String accessKey; |
| | | |
| | | @Value("${oss.secret-key}") |
| | | private String secretKey; |
| | | |
| | | @Value("${oss.bucket}") |
| | | private String bucket; |
| | | } |
| | |
| | | * @param file |
| | | * @return |
| | | */ |
| | | Integer saveFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException; |
| | | Integer saveFile(String workspaceId, FileUploadDTO file); |
| | | |
| | | /** |
| | | * 存储水印图片 |
| | |
| | | private IWaylineJobService waylineJobService; |
| | | @Autowired |
| | | private IWaylineFileService waylineFileService; |
| | | @Autowired |
| | | private MinioPojo pojo; |
| | | |
| | | private ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException { |
| | | public Integer saveFile(String workspaceId, FileUploadDTO file) { |
| | | MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file); |
| | | fileEntity.setWorkspaceId(workspaceId); |
| | | fileEntity.setFileId(UUID.randomUUID().toString()); |
| | | Integer count= mapper.insert(fileEntity); |
| | | return mapper.insert(fileEntity); |
| | | } |
| | | |
| | | public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException { |
| | | |
| | | try { |
| | | boolean contains = file.getName().contains("~"); |
| | | if (contains) { |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException { |
| | | boolean endsWith = file.getObjectKey().endsWith(".mp4"); |
| | | if (endsWith) { |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | String url = "http://dev.jxpskj.com:9000/cloud-bucket" + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File file2 = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String endpoint = "http://dev.jxpskj.com:9000"; |
| | | String accessKey = "pskj"; |
| | | String secretKey = "pskj@2021"; |
| | | String bucketName = "cloud-bucket"; |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, file2); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } |
| | | |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | String url = pojo.getEndpoint()+"/"+pojo.getBucket() + file.getObjectKey(); |
| | | File file1 = TbFjServiceImpl.downloadFile(url); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File file2 = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String endpoint = pojo.getEndpoint(); |
| | | String accessKey = pojo.getAccessKey(); |
| | | String secretKey = pojo.getSecretKey(); |
| | | String bucketName = pojo.getBucket(); |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, file2,"image/jpeg"); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Object mediaInfo(String filename) { |
| | | String name = "mark"+filename; |
| | | MediaFileMarkEntity entity = markMapper.selectOne(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | String name = "mark" + filename; |
| | | List<MediaFileMarkEntity> entity = markMapper.selectList(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | .eq(MediaFileMarkEntity::getFileName, name)); |
| | | if (entity!=null){ |
| | | return entity.getDronedata();} |
| | | else { |
| | | if (entity != null) { |
| | | return entity.get(0).getDronedata(); |
| | | } else { |
| | | return "该图片信息正在加载"; |
| | | } |
| | | } |
| | |
| | | // 执行分页查询 |
| | | Page<MediaFileEntity> resultPage = mapper.selectPage(pageObj, queryWrapper); |
| | | |
| | | // 处理查询结果 |
| | | // 处理查询结果并去重 |
| | | Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileEntity> records = resultPage.getRecords() |
| | | .stream() |
| | | .peek(mediaFile -> { |
| | |
| | | String taskNameResult = waylineJobService.getName(mediaFile.getJobId()); |
| | | mediaFile.setJobName(taskNameResult); |
| | | }) |
| | | .collect(Collectors.toList() |
| | | ); |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 返回分页数据 |
| | | // 返回分页数据 |
| | | return new PaginationData<>(records, new Pagination(resultPage)); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | return builder.build(); |
| | | } |
| | | |
| | | public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file) { |
| | | public static void uploadFile(String endpoint, String accessKey, String secretKey, String bucketName, String objectName, File file,String type) { |
| | | try { |
| | | // 创建MinIO客户端实例 |
| | | MinioClient minioClient = MinioClient.builder() |
| | |
| | | .bucket(bucketName) |
| | | .object(objectName) |
| | | .stream(fileInputStream, file.length(), -1) |
| | | .contentType("image/jpeg") |
| | | .contentType(type) |
| | | .build() |
| | | ); |
| | | fileInputStream.close(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveMediaFile(String workspaceId, FileUploadDTO file) throws ImageProcessingException, IOException { |
| | | public Integer saveMediaFile(String workspaceId, FileUploadDTO file){ |
| | | return fileService.saveFile(workspaceId, file); |
| | | } |
| | | |
| | |
| | | BizCodeEnum.FILE_UPLOAD_CALLBACK.getCode(), mediaFileCount); |
| | | } |
| | | |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) throws IOException, FontFormatException, ImageProcessingException { |
| | | private Boolean parseMediaFile(FileUploadCallback callback, WaylineJobDTO job) { |
| | | // Set the drone sn that shoots the media |
| | | Optional<DeviceDTO> dockDTO = deviceService.getDeviceBySn(job.getDockSn()); |
| | | dockDTO.ifPresent(dock -> callback.getFile().getExt().setSn(dock.getChildDeviceSn())); |
| | |
| | | // set path |
| | | String objectKey = callback.getFile().getObjectKey(); |
| | | callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/"))); |
| | | try { |
| | | ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | executor.execute(() -> { |
| | | try { |
| | | fileService.saveMarkFile(job.getWorkspaceId(), callback.getFile()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | executor.shutdown(); |
| | | } catch (Exception e) { |
| | | log.error("方法执行有误==============: ", e); |
| | | throw e; |
| | | } |
| | | |
| | | |
| | | return fileService.saveFile(job.getWorkspaceId(), callback.getFile()) > 0; |
| | | } |
| | | |
| | |
| | | import com.dji.sample.patches.service.GetPatchesService; |
| | | import com.dji.sample.patches.service.ShpToDataSourceService; |
| | | import com.dji.sample.patches.utils.DistrictCodeUtils; |
| | | import com.dji.sample.patches.utils.GeoToolsUtil; |
| | | import com.dji.sample.patches.utils.PointPO; |
| | | import com.dji.sample.patches.utils.TimerUtil; |
| | | import com.dji.sample.territory.service.impl.TbDkjbxxServiceImpl; |
| | | import com.dji.sample.wayline.model.entity.WaylineFileEntity; |
| | |
| | | @GetMapping("/getWayline") |
| | | public ResponseResult getWayline(@RequestParam String waylineName, @RequestBody List<LotInfo> list) { |
| | | try { |
| | | MultipartFile file = timerUtil.getFile(waylineName, list, 25.8917266,116.020940643); |
| | | MultipartFile file = timerUtil.getFile(waylineName, list, 25.8917266, 116.020940643); |
| | | return ResponseResult.success(file); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getPoint") |
| | | public List<PointPO> getPoint(@RequestParam List<Integer> list, |
| | | @RequestParam Double airportLat, |
| | | @RequestParam Double airportLon) { |
| | | List<LotInfo> lotInfos = getPatchesService.getLotInfosByIds(list); |
| | | System.out.println(lotInfos); |
| | | System.out.println(lotInfos); |
| | | System.out.println(lotInfos); |
| | | System.out.println(lotInfos); |
| | | System.out.println(lotInfos); |
| | | System.out.println(lotInfos); |
| | | return GeoToolsUtil.getRoutePointOrder(lotInfos, airportLat, airportLon); |
| | | } |
| | | |
| | | @PostMapping("/patchesToWayline") |
| | | public ResponseResult patchesToWayline(@RequestBody List<LotInfo> lotInfos, |
| | | @RequestParam String waylineName, |
| | | @RequestParam String spotInFreckle, |
| | | @RequestParam String workspaceId, |
| | | @RequestParam String patchesId, |
| | | @RequestParam double lat, |
| | | @RequestParam double lon, |
| | | HttpServletRequest request) throws IOException { |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | MultipartFile file = timerUtil.getFile(waylineName, lotInfos, lat, lon); |
| | | waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, spotInFreckle); |
| | | WaylineFileEntity entity = waylineFileService.selectByName(waylineName); |
| | | Map<String, String> infoMap = new HashMap<>(); |
| | | URL url = null; |
| | | try { |
| | | url = waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId()); |
| | | infoMap.put("url", String.valueOf(MinioUrlUtils.getUrl(url))); |
| | | infoMap.put("waylineId", entity.getWaylineId()); |
| | | } catch (SQLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return ResponseResult.success(infoMap); |
| | | @PostMapping("/patchesToWayline") |
| | | public ResponseResult patchesToWayline(@RequestBody List<LotInfo> lotInfos, |
| | | @RequestParam String waylineName, |
| | | @RequestParam String spotInFreckle, |
| | | @RequestParam String workspaceId, |
| | | @RequestParam String patchesId, |
| | | @RequestParam double lat, |
| | | @RequestParam double lon, |
| | | HttpServletRequest request) throws IOException { |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | MultipartFile file = timerUtil.getFile(waylineName, lotInfos, lat, lon); |
| | | waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, spotInFreckle); |
| | | WaylineFileEntity entity = waylineFileService.selectByName(waylineName); |
| | | Map<String, String> infoMap = new HashMap<>(); |
| | | URL url = null; |
| | | try { |
| | | url = waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId()); |
| | | infoMap.put("url", String.valueOf(MinioUrlUtils.getUrl(url))); |
| | | infoMap.put("waylineId", entity.getWaylineId()); |
| | | } catch (SQLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return ResponseResult.success(infoMap); |
| | | } |
| | | |
| | | @GetMapping("/useMyTask") |
| | | public ResponseResult useMyTask() throws Exception { |
| | | try { |
| | | // timerUtil.myTask(); |
| | | timerUtil.myTask(); |
| | | // timerUtil.myTask2(); |
| | | // timerUtil.myTask3(); |
| | | timerUtil.mytask4(); |
| | | timerUtil.mytask5(); |
| | | timerUtil.mytask6(); |
| | | timerUtil.mytask7(); |
| | | // timerUtil.mytask4(); |
| | | // timerUtil.mytask5(); |
| | | // timerUtil.mytask6(); |
| | | // timerUtil.mytask7(); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("db存储发送出现异常" + e); |
| | |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @GetMapping ("/tests") |
| | | public ResponseResult use() { |
| | | ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | executor.execute(() -> { |
| | | try { |
| | | timerUtil.sendPostWithFileAndParameter("DB/result_db.db", |
| | | "635148ea-0ddb-4b23-945c-8a67abd813c9"); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | executor.shutdown(); |
| | | return ResponseResult.success(); |
| | | @GetMapping("/tests") |
| | | public ResponseResult use() { |
| | | ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | executor.execute(() -> { |
| | | try { |
| | | timerUtil.sendPostWithFileAndParameter("DB/result_db.db", |
| | | "635148ea-0ddb-4b23-945c-8a67abd813c9"); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | executor.shutdown(); |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @PostMapping("/way") |
| | | public void getway(@RequestParam("file") MultipartFile file, |
| | | @RequestParam String workspaceId, |
| New file |
| | |
| | | package com.dji.sample.patches.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class ShpDTO { |
| | | private String GEO; |
| | | private String DKFW; |
| | | private Double YZB; |
| | | private Double XZB; |
| | | private String DKBH; |
| | | private String BZ; |
| | | private Double JCMJ; |
| | | private String HSX; |
| | | private String XZQDM; |
| | | private String JCLX; |
| | | private String TBLX; |
| | | private String DDTC; |
| | | } |
| | |
| | | */ |
| | | PaginationData<LotInfo> limitGet(PatchesParam param); |
| | | int delPatches(String workspaceId); |
| | | |
| | | List<LotInfo> getLotInfosByIds(List<Integer> ids); |
| | | void patchesPushed(String taskId, String dkbh, String workspaceId); |
| | | int deleteOne(int id); |
| | | /** |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public PaginationData getPhoto(PatchesParam param, String dkbh) { |
| | | LotInfo lotInfo=getLotinfoToDb(dkbh); |
| | | int statue=lotInfo.getIsPush(); |
| | | if (statue==1){ |
| | | Page<MediaFileMarkEntity> page = markMapper.selectPage(new Page<MediaFileMarkEntity>(param.getPage(), param.getPageSize()), |
| | | LotInfo lotInfo = getLotinfoToDb(dkbh); |
| | | int statue = lotInfo.getIsPush(); |
| | | |
| | | if (statue == 1) { |
| | | Page<MediaFileMarkEntity> page = markMapper.selectPage( |
| | | new Page<MediaFileMarkEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileMarkEntity>().like(MediaFileMarkEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | |
| | | Map<String, MediaFileMarkEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileMarkEntity> records = page.getRecords() |
| | | .stream() |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<MediaFileMarkEntity>(records, new Pagination(page));} |
| | | else { |
| | | Page<MediaFileEntity> page = fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()), |
| | | |
| | | return new PaginationData<MediaFileMarkEntity>(records, new Pagination(page)); |
| | | } else { |
| | | Page<MediaFileEntity> page = fileMapper.selectPage( |
| | | new Page<MediaFileEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | |
| | | Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileEntity> records = page.getRecords() |
| | | .stream() |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<MediaFileEntity>(records, new Pagination(page));} |
| | | |
| | | return new PaginationData<MediaFileEntity>(records, new Pagination(page)); |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) { |
| | | return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%") |
| | |
| | | public LotInfo getLotinfoToDb(String dkbh) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)); |
| | | } |
| | | |
| | | public List<LotInfo> getLotInfosByIds(List<Integer> ids) { |
| | | LambdaQueryWrapper<LotInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(LotInfo::getId, ids); |
| | | return mapper.selectList(queryWrapper); |
| | | } |
| | | public List<LotInfo> listLotinfo() { |
| | | return mapper.selectList(null); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dji.sample.patches.config.pojo.PatchesConfigPojo; |
| | | import com.dji.sample.patches.dao.ShpToDataSourceMapper; |
| | | import com.dji.sample.patches.model.dto.ShpDTO; |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import com.dji.sample.patches.service.ShpToDataSourceService; |
| | | import com.dji.sample.patches.utils.*; |
| | |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | public MultipartFile insertGeo(MultipartFile file, String workspaceId, String waylineName, double airportLat, double airportLon) throws Exception { |
| | | List<LotInfo> list = new ArrayList<>(); |
| | | File file1 = MultipartFileTOFileUtil.multipartFile2File(file, patchesConfigPojo.getUnzip()); |
| | | List<String> s = ShapeFileUtil.shpToGeoJson(file1); |
| | | String[] arr1 = FormatConversionUtil.formatConversion(s); |
| | | for (int i = 0; i < arr1.length; i++) { |
| | | List<ShpDTO> shpData = ShapeFileUtil.shpToGeoJson(file1); |
| | | String s=null; |
| | | for (int i = 0; i < shpData.size(); i++) { |
| | | String[] arr1 = FormatConversionUtil.formatConversion(Collections.singletonList(s)); |
| | | LotInfo lotInfo = new LotInfo(); |
| | | String temp = arr1[i].trim(); |
| | | temp = FormatConversionUtil.modifySpacesAndCommas(temp); |
| | |
| | | return builder.build(); |
| | | } |
| | | |
| | | // private LotInfo shpDtoToLotInfo(ShpDTO shpDTO){ |
| | | // LotInfo.LotInfoBuilder builder=LotInfo.builder(); |
| | | // builder. |
| | | // |
| | | // } |
| | | |
| | | public List<LotInfo> getNoPlan(){ |
| | | return shpToDataSourceMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getIsPlan,0)); |
| | | } |
| | |
| | | private int index; |
| | | private Coordinate coordinate; |
| | | private Coordinate centro;//保存中心点 |
| | | private int patchesId; |
| | | |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.dji.sample.patches.model.dto.ShpDTO; |
| | | import org.geotools.data.DataStore; |
| | | import org.geotools.data.DataStoreFinder; |
| | | import org.geotools.data.FeatureSource; |
| | |
| | | * @description 通过shp压缩文件,将其转换为GeoJson格式 |
| | | */ |
| | | //将解压后的文件转换成GeoJson格式 |
| | | public static List<String> shpToGeoJson(File zipFile) throws IOException { |
| | | public static List<ShpDTO> shpToGeoJson(File zipFile) throws IOException { |
| | | ShpDTO shpDTO=new ShpDTO(); |
| | | List<ShpDTO> dtoList= new ArrayList<>(); |
| | | FeatureJSON fjson = new FeatureJSON(); |
| | | JSONObject geoJsonObject = new JSONObject(); |
| | | geoJsonObject.put("type", "FeatureCollection"); |
| | |
| | | byte[] b = temp.getBytes("iso8859-1"); |
| | | temp = new String(b, "gbk"); |
| | | JSONObject json = JSONObject.parseObject(temp); |
| | | shpDTO.setDKFW(json.getJSONObject("geometry").get("coordinates").toString()); |
| | | shpDTO.setGEO(json.getJSONObject("geometry").get("type").toString()); |
| | | shpDTO.setXZQDM(json.getJSONObject("properties").get("XZQDM").toString()); |
| | | shpDTO.setXZB( json.getJSONObject("properties").getDouble("XZB")); |
| | | shpDTO.setYZB( json.getJSONObject("properties").getDouble("YZB")); |
| | | shpDTO.setDKBH(json.getJSONObject("properties").get("JCBH").toString()); |
| | | shpDTO.setJCMJ(json.getJSONObject("properties").getDouble("JCMC")); |
| | | shpDTO.setTBLX(json.getJSONObject("properties").getString("TBLX")); |
| | | shpDTO.setDDTC(json.getJSONObject("properties").getString("DDTC")); |
| | | shpDTO.setHSX(json.getJSONObject("properties").getString("HSX")); |
| | | shpDTO.setJCLX(json.getJSONObject("properties").getString("JCLX")); |
| | | dtoList.add(shpDTO); |
| | | String str2 = json.getJSONObject("geometry").get("coordinates").toString(); |
| | | strings.add(str2); |
| | | array.add(json); |
| | |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | return strings; |
| | | return dtoList; |
| | | } |
| | | |
| | | } |
| | |
| | | // 如果是文件,就先创建一个文件,然后用io流把内容copy过去 |
| | | File targetFile = new File(destDirPath + File.separator + entry.getName()); |
| | | // 保证这个文件的父文件夹必须要存在 |
| | | File parentFile = targetFile.getParentFile(); |
| | | if (!parentFile.exists()) { |
| | | parentFile.mkdirs(); |
| | | } |
| | | |
| | | list.add(destDirPath + entry.getName()); |
| | | if (!targetFile.getParentFile().exists()) { |
| | | |
| | | } |
| | | targetFile.createNewFile(); |
| | | // 将压缩文件内容写入到这个文件中 |
| | | InputStream is = zipFile.getInputStream(entry); |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | // 定义一个公共的静态方法zipFolder,用于压缩文件夹 |
| | | // 参数sourceFolderPath是源文件夹的路径,zipFilePath是压缩后的zip文件路径 |
| | | public static boolean zipFolder(String sourceFolderPath, String zipFilePath) { |
| | | // 创建一个File对象,表示源文件夹 |
| | | File sourceFile = new File(sourceFolderPath); |
| | | try ( |
| | | // 创建一个FileOutputStream对象,用于向指定的zip文件路径写入数据 |
| | | FileOutputStream fos = new FileOutputStream(zipFilePath); |
| | | // 创建一个ZipOutputStream对象,用于将压缩数据写入到FileOutputStream中 |
| | | ZipOutputStream zos = new ZipOutputStream(fos) |
| | | ) { |
| | | // 调用zipFile方法,开始压缩文件 |
| | | zipFile(sourceFile, sourceFile.getName(), zos); |
| | | return true; |
| | | } catch (IOException e) { |
| | | // 如果在压缩过程中出现异常,打印异常堆栈信息 |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // 将文件夹整体压缩 |
| | | // 参数fileToZip是需要被压缩的文件或文件夹,fileName是其在zip中的名称,zos是ZipOutputStream对象 |
| | | private static void zipFile(File fileToZip, String fileName, ZipOutputStream zos) throws IOException { |
| | | // 如果fileToZip是一个隐藏文件,则不进行压缩,直接返回 |
| | | if (fileToZip.isHidden()) { |
| | | return; |
| | | } |
| | | // 如果fileToZip是一个目录(文件夹) |
| | | if (fileToZip.isDirectory()) { |
| | | // 如果fileName以"/"结尾,说明已经是一个目录路径,直接创建一个ZipEntry并关闭它 |
| | | if (fileName.endsWith("/")) { |
| | | zos.putNextEntry(new ZipEntry(fileName)); |
| | | zos.closeEntry(); |
| | | } else { |
| | | // 否则,需要在fileName后加上"/",表示这是一个目录路径,然后创建一个ZipEntry并关闭它 |
| | | zos.putNextEntry(new ZipEntry(fileName + "/")); |
| | | zos.closeEntry(); |
| | | } |
| | | // 获取fileToZip目录下的所有文件和子目录 |
| | | File[] children = fileToZip.listFiles(); |
| | | for (File childFile : children) { |
| | | // 递归调用zipFile方法,压缩子文件和子目录 |
| | | zipFile(childFile, fileName + "/" + childFile.getName(), zos); |
| | | } |
| | | return; |
| | | } |
| | | // 如果fileToZip不是一个目录,那么它就是一个文件,需要被压缩 |
| | | // 创建一个FileInputStream对象,用于读取fileToZip的内容 |
| | | FileInputStream fis = new FileInputStream(fileToZip); |
| | | // 创建一个ZipEntry对象,表示fileToZip在zip文件中的条目 |
| | | ZipEntry zipEntry = new ZipEntry(fileName); |
| | | // 在ZipOutputStream中开始一个新的zip条目(即将写入一个文件的内容) |
| | | zos.putNextEntry(zipEntry); |
| | | // 创建一个byte数组,作为缓冲区,用于从fileToZip读取数据并写入到zos中 |
| | | byte[] bytes = new byte[1024]; |
| | | int length; |
| | | // 使用循环从fis中读取数据,并写入到zos中,直到没有数据可读(返回-1)为止 |
| | | while ((length = fis.read(bytes)) >= 0) { |
| | | zos.write(bytes, 0, length); |
| | | } |
| | | // 关闭FileInputStream对象,释放资源 |
| | | fis.close(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // 调用方法进行测试 |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.controller; |
| | | |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.speak.model.dto.SpeakTtsContextDto; |
| | | import com.dji.sample.speak.model.dto.SpeakTtsStartDto; |
| | | import com.dji.sample.speak.service.SpeakTtsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @RestController |
| | | @RequestMapping("${url.speak.prefix}${url.speak.version}") |
| | | public class SpeakTtsController { |
| | | @Autowired |
| | | private SpeakTtsService ttsService; |
| | | |
| | | @PostMapping("/sendContext") |
| | | public ResponseResult sendContext(@RequestBody SpeakTtsContextDto dto) { |
| | | return ResponseResult.success(ttsService.sendTtsContext(dto)); |
| | | } |
| | | @PostMapping("/startTts") |
| | | public ResponseResult ttxStart(SpeakTtsStartDto dto){ |
| | | return ResponseResult.success(ttsService.speakTtxStart(dto)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.controller; |
| | | |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.mqtt.service.IMessageSenderService; |
| | | import com.dji.sample.speak.model.dto.PsdkModelDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceStartDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVolumeDto; |
| | | import com.dji.sample.speak.model.param.SpeakVoiceStartParam; |
| | | import com.dji.sample.speak.service.SpeakVoiceService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.File; |
| | | |
| | | @RestController |
| | | @RequestMapping("${url.speak.prefix}${url.speak.version}") |
| | | public class SpeakVoiceController { |
| | | @Autowired |
| | | private SpeakVoiceService voiceServicel; |
| | | |
| | | @PostMapping("/startVoice") |
| | | public ResponseResult takeVoice(String sn , SpeakVoiceStartParam param) { |
| | | return ResponseResult.success(voiceServicel.takeVoice(sn,param)); |
| | | } |
| | | |
| | | @PostMapping("/stopVoice") |
| | | public ResponseResult stopVoice() { |
| | | return ResponseResult.success(voiceServicel.stopVoice()); |
| | | } |
| | | |
| | | @PostMapping("/voiceVolumn") |
| | | public ResponseResult voiceVolumn(SpeakVolumeDto dto) { |
| | | return ResponseResult.success(voiceServicel.setVoiceVolume(dto)); |
| | | } |
| | | |
| | | @PostMapping("/voiceMode") |
| | | public ResponseResult restartVoice(PsdkModelDto dto) { |
| | | return ResponseResult.success(voiceServicel.setVoiceMode(dto)); |
| | | } |
| | | @PostMapping("/restartVoice") |
| | | public ResponseResult restartVoice() { |
| | | return ResponseResult.success(voiceServicel.restartVoice()); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class PsdkFloatDto { |
| | | private Integer psdkIndex; |
| | | private String value; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import com.dji.sample.speak.model.enums.PsdkModelEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class PsdkModelDto { |
| | | private Integer psdkIndex; |
| | | private PsdkModelEnum play_mode; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakTtsContextDto { |
| | | private Integer psdkIndex; |
| | | private String value; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakTtsFileDto { |
| | | private String name; |
| | | private String url; |
| | | private String md5; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakTtsStartDto { |
| | | private Integer psdkIndex; |
| | | private SpeakTtsFileDto tts; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import com.dji.sample.speak.model.enums.FormatEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakVoiceFileDto { |
| | | private String name; |
| | | private String url; |
| | | private String md5; |
| | | private FormatEnum format; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakVoiceStartDto { |
| | | private Integer psdkIndex; |
| | | private SpeakVoiceFileDto file; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.dto; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakVolumeDto { |
| | | private Integer psdkIndex; |
| | | private Integer play_volume; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum FormatEnum { |
| | | PCM("pcm"); |
| | | |
| | | private String pcm; |
| | | |
| | | FormatEnum(String pcm) { |
| | | this.pcm = pcm; |
| | | } |
| | | |
| | | public String getPcm() { |
| | | return pcm; |
| | | } |
| | | |
| | | public void setPcm(String pcm) { |
| | | this.pcm = pcm; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum PsdkModelEnum { |
| | | SINGLE(0), |
| | | CIRCLE(1); |
| | | int val; |
| | | |
| | | PsdkModelEnum(int val) { |
| | | this.val = val; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum VoiceEnums { |
| | | |
| | | PSDK_UI_RESOURCE_UPLOAD_RESULT("psdk_ui_resource_upload_result"), |
| | | PSDK_FLOATING_WINDOW_TEXT("psdk_floating_window_text"), |
| | | SPEAKER_AUDIO_PLAY_START_PROGRESS("speaker_audio_play_start_progress"), |
| | | SPEAKER_TTS_PLAY_START("speaker_tts_play_start"), |
| | | PSDK_WIDGET_VALUE_SET("psdk_widget_value_set"), |
| | | PSDK_INPUT_BOX_TEXT_SET("psdk_input_box_text_set"), |
| | | SPEAKER_AUDIO_PLAY_START("speaker_audio_play_start"), |
| | | SPEAKER_TTS_PLAY_START_PROGRESS("speaker_tts_play_start_progress"), |
| | | SPEAKER_REPLAY("speaker_replay"), |
| | | SPEAKER_PLAY_STOP("speaker_play_stop"), |
| | | SPEAKER_PLAY_MODE_SET("speaker_play_mode_set"), |
| | | SPEAKER_PLAY_VOLUME_SET("speaker_play_volume_set"), |
| | | STORAGE_CONFIG_GET("storage_config_get"); |
| | | |
| | | |
| | | private String method; |
| | | |
| | | VoiceEnums(String method) { |
| | | this.method = method; |
| | | } |
| | | |
| | | public String getMethod() { |
| | | return method; |
| | | } |
| | | |
| | | public void setMethod(String method) { |
| | | this.method = method; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.model.param; |
| | | |
| | | import com.dji.sample.speak.model.enums.FormatEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.File; |
| | | @Data |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SpeakVoiceStartParam { |
| | | private Integer psdkIndex; |
| | | private String name; |
| | | private File file; |
| | | private FormatEnum format; |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.service; |
| | | |
| | | import com.dji.sample.speak.model.dto.SpeakTtsContextDto; |
| | | import com.dji.sample.speak.model.dto.SpeakTtsStartDto; |
| | | |
| | | public interface SpeakTtsService { |
| | | int sendTtsContext(SpeakTtsContextDto dto); |
| | | |
| | | int speakTtxStart(SpeakTtsStartDto dto); |
| | | |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.service; |
| | | |
| | | import com.dji.sample.speak.model.dto.PsdkModelDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceStartDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVolumeDto; |
| | | import com.dji.sample.speak.model.param.SpeakVoiceStartParam; |
| | | |
| | | public interface SpeakVoiceService { |
| | | int takeVoice(String sn , SpeakVoiceStartParam param); |
| | | |
| | | int restartVoice(); |
| | | |
| | | int stopVoice(); |
| | | |
| | | int setVoiceMode(PsdkModelDto dto); |
| | | |
| | | int setVoiceVolume(SpeakVolumeDto dto); |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.service.serviceImpl; |
| | | |
| | | import com.dji.sample.speak.model.dto.SpeakTtsContextDto; |
| | | import com.dji.sample.speak.model.dto.SpeakTtsStartDto; |
| | | import com.dji.sample.speak.service.SpeakTtsService; |
| | | import lombok.extern.log4j.Log4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | |
| | | public class SpeakTtsServiceImpl implements SpeakTtsService { |
| | | @Override |
| | | public int sendTtsContext(SpeakTtsContextDto dto) { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int speakTtxStart(SpeakTtsStartDto dto) { |
| | | return 0; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.service.serviceImpl; |
| | | |
| | | import com.dji.sample.component.mqtt.service.IMessageSenderService; |
| | | import com.dji.sample.media.model.MinioPojo; |
| | | import com.dji.sample.media.service.impl.FileServiceImpl; |
| | | import com.dji.sample.speak.model.dto.PsdkModelDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceFileDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVoiceStartDto; |
| | | import com.dji.sample.speak.model.dto.SpeakVolumeDto; |
| | | import com.dji.sample.speak.model.enums.VoiceEnums; |
| | | import com.dji.sample.speak.model.param.SpeakVoiceStartParam; |
| | | import com.dji.sample.speak.service.SpeakVoiceService; |
| | | import com.dji.sample.speak.util.MD5Util; |
| | | import lombok.extern.log4j.Log4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | @Service |
| | | |
| | | public class SpeakVoiceServiceImpl implements SpeakVoiceService { |
| | | @Autowired |
| | | private IMessageSenderService messageSenderService; |
| | | @Autowired |
| | | private MinioPojo pojo; |
| | | @Override |
| | | public int takeVoice(String sn, SpeakVoiceStartParam param) { |
| | | SpeakVoiceStartDto dto=new SpeakVoiceStartDto(); |
| | | SpeakVoiceFileDto fileDto=new SpeakVoiceFileDto(); |
| | | String url=upMinio(param.getFile(),param.getName()); |
| | | fileDto.setUrl(url); |
| | | fileDto.setMd5(MD5Util.getMD5Checksum(param.getFile())); |
| | | fileDto.setFormat(param.getFormat()); |
| | | fileDto.setName(param.getName()); |
| | | dto.setPsdkIndex(param.getPsdkIndex()); |
| | | return messageSenderService.publishServicesTopic(sn, VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(),param).getResult(); |
| | | } |
| | | |
| | | @Override |
| | | public int restartVoice() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int stopVoice() { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int setVoiceMode(PsdkModelDto dto) { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int setVoiceVolume(SpeakVolumeDto dto) { |
| | | return 0; |
| | | } |
| | | |
| | | public String upMinio(File file,String fileName){ |
| | | String endpoint = pojo.getEndpoint(); |
| | | String accessKey = pojo.getAccessKey(); |
| | | String secretKey = pojo.getSecretKey(); |
| | | String bucketName = pojo.getBucket(); |
| | | String objectName="/"+fileName+getNowTimeName(); |
| | | FileServiceImpl.uploadFile(endpoint,accessKey,secretKey,bucketName,objectName,file,"audio/mpeg"); |
| | | return endpoint+"/"+bucketName+objectName; |
| | | } |
| | | public static String getNowTimeName() { |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | // 格式化时间,生成当前时间 |
| | | return currentTime.format(DateTimeFormatter.ofPattern("MMddHHmm")); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dji.sample.speak.util; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | public class MD5Util { |
| | | public static String getMD5Checksum(File file) { |
| | | try (InputStream fis = new FileInputStream(file)) { |
| | | MessageDigest md = MessageDigest.getInstance("MD5"); |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | |
| | | while ((bytesRead = fis.read(buffer)) != -1) { |
| | | md.update(buffer, 0, bytesRead); |
| | | } |
| | | |
| | | byte[] digest = md.digest(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (byte b : digest) { |
| | | sb.append(String.format("%02x", b)); |
| | | } |
| | | return sb.toString(); |
| | | } catch (IOException | NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | public class CoordinateSystemUtil { |
| | | public static void main(String[] args) { |
| | | String wtk= "MULTIPOLYGON(((3.94836025714E7 3176072.7897, 3.94835938931E7 3176063.7288, 3.94835894481E7 3176067.1154, 3.94835981264E7 3176075.7938, 3.94836026103E7 3176085.7288, 3.94836089215E7 3176099.7123, 3.94836159065E7 3176121.5139, 3.94836178114E7 3176140.9873, 3.94836181917E7 3176148.7199, 3.94836214775E7 3176146.8663, 3.94836254582E7 3176144.37, 3.94836237382E7 3176137.8123, 3.94836165415E7 3176107.3321, 3.9483608468E7 3176087.3696, 3.94836025714E7 3176072.7897)))"; |
| | | String se=wtk.replaceAll(",\\["," ").replaceAll("]","").replaceAll("\\[",""); |
| | | System.out.println(se); |
| | | System.out.println(poylonCGCStoWGS(se)); |
| | | } |
| | | public static Geometry pointCGCStoWGS(Double lot, Double lat) { |
| | | String wkt = "POINT (" + lot + " " + lat + ")"; |
| | | Geometry source = createGeometry(wkt, 4527); |
| | |
| | | summarize: |
| | | prefix: /summarize |
| | | version: /api/v1 |
| | | speak: |
| | | prefix: /speak |
| | | version: /api/v1 |
| | | |
| | | # Tutorial: https://www.alibabacloud.com/help/en/object-storage-service/latest/use-a-temporary-credential-provided-by-sts-to-access-oss |
| | | #oss: |