| | |
| | | import com.ard.route.domain.WaypointTurnReq; |
| | | import com.ard.route.domain.kml.*; |
| | | import com.ard.route.domain.route.ArdRouteInformation; |
| | | import com.ard.route.domain.vo.KmzInfoVO; |
| | | import com.ard.route.enums.kml.ExitOnRCLostEnums; |
| | | import com.ard.route.service.IArdRouteInformationService; |
| | | import com.ard.route.util.FileUtils; |
| | | import com.ard.route.util.RouteFileUtils; |
| | | import com.ard.route.service.UavRouteService; |
| | | import com.thoughtworks.xstream.XStream; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | import static com.ard.route.util.RouteFileUtils.*; |
| | | import static com.ard.route.util.ToolUtils.extractFilePath; |
| | | import static com.ard.route.util.ToolUtils.getFileNameWithoutExtension; |
| | | |
| | | /** |
| | |
| | | ArdRouteInformation ardRouteInformation = new ArdRouteInformation(); |
| | | ardRouteInformation.setFileName(fileName); |
| | | ardRouteInformation.setFileNameNew(getFileNameWithoutExtension(kmzFilePath)); |
| | | ardRouteInformation.setMinioUpPath(extractFilePath(kmzFilePath)); |
| | | ardRouteInformation.setUpPath(kmzFilePath); |
| | | ardRouteInformation.setUpFileSize(fileSize); |
| | | ardRouteInformation.setCreateBy(SecurityUtils.getUsername()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public KmzInfoVO parseKmz(String fileUrl) throws IOException { |
| | | KmzInfoVO kmzInfoVO = new KmzInfoVO(); |
| | | File file = FileUtils.downloadUrlToTempFile(fileUrl); |
| | | try (ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(FileUtil.getInputStream(file))) { |
| | | ArchiveEntry entry; |
| | | while (!Objects.isNull(entry = archiveInputStream.getNextEntry())) { |
| | | String name = entry.getName(); |
| | | if (name.toLowerCase().endsWith(".kml")) { |
| | | kmzInfoVO.setKmlInfo(RouteFileUtils.parseKml(archiveInputStream)); |
| | | } else if (name.toLowerCase().endsWith(".wpml")) { |
| | | kmzInfoVO.setWpmlInfo(RouteFileUtils.parseKml(archiveInputStream)); |
| | | } |
| | | } |
| | | return kmzInfoVO; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |