Commit ae030273 authored by xiaosl's avatar xiaosl

xml解析

parent 9c947f36
...@@ -6,10 +6,6 @@ SUCCESS_CODE=200 ...@@ -6,10 +6,6 @@ SUCCESS_CODE=200
#操作失败 #操作失败
FAILED_CODE=1001 FAILED_CODE=1001
1001=操作失败 1001=操作失败
IM_DELETE_FAIL_CODE = 10011
10011 = 删除消息失败
IM_MSG_NOT_EXIST_CODE = 10012
10012 = 消息不存在
#数据已存在 #数据已存在
EXIST_CODE=1002 EXIST_CODE=1002
1002=数据已存在 1002=数据已存在
...@@ -22,12 +18,11 @@ NULL_CODE=1003 ...@@ -22,12 +18,11 @@ NULL_CODE=1003
#操作出现异常 #操作出现异常
EXCEPTION_CODE=1004 EXCEPTION_CODE=1004
1004=操作出现异常 1004=操作出现异常
#操作频繁,稍后再试
API_MAX_CODE=1005
1005=操作频繁,稍后再试
#rstoken已失效 #rstoken已失效
RSTOKEN_EXPIRED_CODE=1006 RSTOKEN_EXPIRED_CODE=1006
1006=rstoken已失效 1006=rstoken已失效
#rstoken为空 #rstoken为空
RSTOKEN_NULL_CODE=1007 RSTOKEN_NULL_CODE=1007
1007=rstoken为空 1007=rstoken为空
...@@ -37,63 +32,14 @@ RSTOKEN_NULL_CODE=1007 ...@@ -37,63 +32,14 @@ RSTOKEN_NULL_CODE=1007
DB_OPERATION_FAIL_CODE=1008 DB_OPERATION_FAIL_CODE=1008
1008=数据库操作失败 1008=数据库操作失败
VEHICLE_IS_BOOKED=10080
10080=车辆已经被预定
#参数非法 #参数非法
PARAM_ILLEGAL_CODE=1011 PARAM_ILLEGAL_CODE=1011
1011=参数非法,请修改 1011=参数非法,请修改
#参数时效已过时
PARAM_EXPIRE_CODE=1010
1010=参数时效已过时,不能使用
#请求微信接口失败 #请求微信接口失败
WXAPI_CODE=2001 WXAPI_CODE=2001
#微信用不不存在 #微信用不不存在
WXNOTEXIST_CODE=2003 WXNOTEXIST_CODE=2003
#公众号不存在
PUBLIC_NOTEXIST_CODE=2004
2004=公众号不存在
#ajax请求,用户未登录
AJAX_WECHAT_NOTEXIST_CODE=2005
2005=ajax请求,用户未登录
#手机号已绑定人脸
FACE_BIND_CODE=3000
3000=手机号已绑定人脸
#手机号未绑定人脸
FACE_NOTBIND_CODE=3001
3001=手机号未绑定人脸
#人脸识别失败
FACE_NOTEXIST_CODE=3002
3002=人脸识别失败
#人脸比对失败
FACE_COMPARE_FAILED_CODE=3003
3003=人脸比对失败
#人脸已绑定手机号码
FACE_BIND_PHONE_CODE=3004
3004=人脸已绑定手机号
#人脸已绑定手机号码
EYE_NOTEXIST_CODE=3005
3005=识别失败
#登陆token过期
REDIS_TOKEN_NULL_CODE=4001
4001=登陆token过期
#手机号已绑定微信
WX_BIND_CODE=4002
4002=手机号已绑定微信
#获取用户失败
GET_APPUSER_FAILED_CODE=4003
4003=获取用户失败
#手机号码已被使用 #手机号码已被使用
PHONE_EXIST_CODE=5001 PHONE_EXIST_CODE=5001
...@@ -107,101 +53,15 @@ USER_NOTEXIST_CODE=5002 ...@@ -107,101 +53,15 @@ USER_NOTEXIST_CODE=5002
USER_EXIST_CODE=5003 USER_EXIST_CODE=5003
5003=用户不存在 5003=用户不存在
ORG_INSERT_FAILED_CODE=6001
6001=新增组织失败
ORG_UPDATE_FAILED_CODE=6002
6002=更新组织信息失败
ROLE_INSERT_FAILED_CODE=7001
7001=新增角色信息失败
ROLE_UPDATE_FAILED_CODE=7002
7002=更新角色信息失败
ROLE_SUPER_ISEXIST_CODE=7003
7003=该组织已存在一级管理员角色
ROLE_NOTEXIST_CODE=7004
7004=角色不存在
NOT_HAVE_LEVEL1=7005
7005=该组织无一级角色,请先创建
NOT_MENU_AUTH_CODE=8001
8001=没有操作该菜单的权限
INSERT_AUTH_FAILED_CODE=8003
8003=新增权限失败
UPDATE_AUTH_FAILED_CODE=8002
8002=更新权限失败
ROLE_NOTEXIST_AUTH_CODE=8004
8004=角色权限不存在
ACCOUNT_ISEXIST_CODE=9001 ACCOUNT_ISEXIST_CODE=9001
9001=账户已存在 9001=账户已存在
ACCOUNT_FIRST_ISEXIST_CODE=9002 ACCOUNT_FIRST_ISEXIST_CODE=9002
9002=该组织已存在超级管理员账户 9002=该组织已存在超级管理员账户
ACCOUNT_NOT_EXIST_CODE=9003
9003=账户不存在
NOT_FIND_SERVICE_CODE=9004
9004=未找到客服信息
ORG_DONTHAVE_PUBLIC_CODE=9005 ORG_DONTHAVE_PUBLIC_CODE=9005
9005=该组织暂未配置公众号信息,请先配置! 9005=该组织暂未配置公众号信息,请先配置!
NICKNAME_NULL_CODE=9006
9006=昵称格式有误,请填写正确昵称
ACCOUNTINFO_ISDEL=9007
9007=账户已禁用
#DEVICE_NOTEXIST_CODE=1005
#1005=监控设备不存在
#DEVICE_TOKEN_NOTEXIST_CODE=1006
#1005=设备access_token获取失败
REPEAT_SUB_CODE=1008
#身份证信息已采集
IDNUM_ISEXIST_CODE=10001
#身份证已过去
IDCARD_INVALID_CODE=10002
#企业个人简历不存在
CORP_VITA_NOTEXIST=20001
20001=个人简历不存在,请先创建简历
#企业个人简历不完善
CORP_VITA_INCOMPLETET=20002
20002=个人简历不完善,请先完善简历
#简历在有效时间内已投递
VITA_DELIVERED=20003
#岗位已下架
POST_END_CODE=20004
20004=该岗位已下架
#客服存在粉丝
SERVICE_HAS_FANS=40001
40001=请先转移该客服的粉丝!
#客服
NOT_SERVICE=40002
40002=当前用户不是客服身份!
#圈子模块resultInfo类型返回正确码
SCRM_RESULTINFO_SUCCESS_CODE=10344
#市接口无数据返回
NO_SELECT_BY_RS=1010
#还未绑定社保卡
NOT_BIND_SOCIAL_CARD=3010
#库存不足
STOCK_CODE=201
#获取用户认证信息失败
GET_AUTH_INFO_FAILED_CODE=4004 GET_AUTH_INFO_FAILED_CODE=4004
4004=获取用户认证信息失败! 4004=获取用户认证信息失败!
#证件件格式 #证件件格式
...@@ -211,44 +71,6 @@ WRONG_FORMAT_OF_ID_CARD=4005 ...@@ -211,44 +71,6 @@ WRONG_FORMAT_OF_ID_CARD=4005
INCOMPLETE_DATA=4006 INCOMPLETE_DATA=4006
4006=资料不齐全! 4006=资料不齐全!
BOOKED_FAILED_CODE = 4007 ####################################订单相关################################
4007=车辆预定失败,请重试! ORDER_NOT_EXIST = 20001
20001 = 该订单不存在!
ONLY_BOOK_FROM_TODAY = 4008 \ No newline at end of file
4008=预定时间不能小于当前时间
ADD_VEHICLE_FAIL = 4009
4009 = 添加车辆失败,请重试
UPDATE_VEHICLE_FAIL = 4010
4010 = 修改车辆失败,请重试
DATE_TIME_IS_NULL = 4011
4011 = 预定时间不能为空
ONLY_BOOK_TWO_MONTH = 4012
4012 = 最多提前三个月预约
ONLY_UNBOOK_TWO_MONTH = 4013
4013 = 只能取消预定两月内的车辆
VEHICLE_CAN_NOT_UNBOOK = 4014
4014 = 选择日期不可取消预定
BOOKED_DATE_IS_EMPTY = 4015
4015 = 预定日期为空
TODAY_CAN_NOT_BOOK = 4016
4016 = 当天不可预定
ADD_VEHICLE_MORE = 4017
4017 = 添加车辆过多,请分批添加
RET_COMPANY_CAN_NOT_BE_NULL = 4018
4018 = 停靠公司不能为空
NUMBER_PLAT_CAN_NOT_BE_NULL = 4019
4019 = 车牌不能为空
END_TIME_FROM_TODAY = 4020
4020 = 结束时间不能小于开始时间
\ No newline at end of file
...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Value;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -25,10 +24,16 @@ public class ImageStorageParseUtil { ...@@ -25,10 +24,16 @@ public class ImageStorageParseUtil {
@Value("${localDirTemp.tarFileTemp}") @Value("${localDirTemp.tarFileTemp}")
private static String tarFileTempDir; private static String tarFileTempDir;
@Value("${gtDataDir.dataRootDir}")
private static String gtDataDataRootDir;
@Value("${gtDataDir.thumbRootDir}")
private static String gtDataThumbRootDir;
@Autowired @Autowired
private static GtDataRestClient gtDataRestClient; private static GtDataRestClient gtDataRestClient;
public static ImageStorageVo tarFileParseGtData(String inputGtPath, String ouputGtDir)throws BaseException { public static ImageStorageVo tarFileParseGtData(String inputGtPath)throws BaseException {
//将GT上压缩包下载到本地 //将GT上压缩包下载到本地
Integer indexOf = inputGtPath.lastIndexOf("/"); Integer indexOf = inputGtPath.lastIndexOf("/");
String fileName = inputGtPath.substring(indexOf); String fileName = inputGtPath.substring(indexOf);
...@@ -53,14 +58,14 @@ public class ImageStorageParseUtil { ...@@ -53,14 +58,14 @@ public class ImageStorageParseUtil {
}catch (Exception e) { }catch (Exception e) {
throw new BaseException("文件保存失败", ResultCode.FAILED_CODE); throw new BaseException("文件保存失败", ResultCode.FAILED_CODE);
} }
return tarFileParse(localInputPath, localDir.getPath(), ouputGtDir); return tarFileParse(localInputPath, localDir.getPath());
} }
public static ImageStorageVo tarFileParse(String inputLocalPath, String localOutputDir, String outputGtPath) throws BaseException { public static ImageStorageVo tarFileParse(String inputLocalPath, String localOutputDir) throws BaseException {
if (inputLocalPath.endsWith("zip")) { if (inputLocalPath.endsWith("zip")) {
//Satellogic 压缩包解析 //Satellogic 压缩包解析
return satellogicParse(inputLocalPath, localOutputDir, outputGtPath); return satellogicParse(inputLocalPath, localOutputDir);
}else if (inputLocalPath.endsWith("tar.gz")) { }else if (inputLocalPath.endsWith("tar.gz")) {
throw new BaseException("tar.gz 压缩包未实现", ResultCode.FAILED_CODE); throw new BaseException("tar.gz 压缩包未实现", ResultCode.FAILED_CODE);
}else { }else {
...@@ -70,7 +75,7 @@ public class ImageStorageParseUtil { ...@@ -70,7 +75,7 @@ public class ImageStorageParseUtil {
//Satellogic 压缩包解析 //Satellogic 压缩包解析
public static ImageStorageVo satellogicParse(String inputLocalPath, String localOutputDir, String outputGtPath) throws BaseException { public static ImageStorageVo satellogicParse(String inputLocalPath, String localOutputDir) throws BaseException {
//1、提取解析xml文件 //1、提取解析xml文件
List<String> xmlPathList = TarFileOperateUtil.zipFileRead(inputLocalPath, localOutputDir,".xml"); List<String> xmlPathList = TarFileOperateUtil.zipFileRead(inputLocalPath, localOutputDir,".xml");
if (xmlPathList == null || xmlPathList.size() == 0) { if (xmlPathList == null || xmlPathList.size() == 0) {
...@@ -143,7 +148,7 @@ public class ImageStorageParseUtil { ...@@ -143,7 +148,7 @@ public class ImageStorageParseUtil {
if (tifPathList == null || tifPathList.size() == 0) { if (tifPathList == null || tifPathList.size() == 0) {
throw new BaseException("tif 文件提取失败", ResultCode.FAILED_CODE); throw new BaseException("tif 文件提取失败", ResultCode.FAILED_CODE);
} }
//生成缩略图 //生成缩略图,读取WGS84坐标点
List<String> picPathList = new ArrayList<>(); List<String> picPathList = new ArrayList<>();
for (String tifPath : tifPathList) { for (String tifPath : tifPathList) {
if (tifPath.toLowerCase().contains("_quicklook")) { if (tifPath.toLowerCase().contains("_quicklook")) {
...@@ -153,11 +158,26 @@ public class ImageStorageParseUtil { ...@@ -153,11 +158,26 @@ public class ImageStorageParseUtil {
ImageOperateTools.tif2Pic(tifPath, localPngPic); ImageOperateTools.tif2Pic(tifPath, localPngPic);
picPathList.add(localPngPic); picPathList.add(localPngPic);
String localTargetPngPic = localPicPrefix + "_800_800.png"; String localTargetPngPic = localPicPrefix + "_800_800.png";
ImageOperateTools.zipImageFile(localPngPic, localTargetPngPic, 800, 1.0f); if (!ImageOperateTools.zipImageFile(localPngPic, localTargetPngPic, 800, 1.0f)) {
throw new BaseException("png_800 转失败", ResultCode.FAILED_CODE);
}
String localJpegPic_800 = localPicPrefix + "_800_800.jpeg";
if (!ImageOperateTools.zipImageFile(localPngPic, localJpegPic_800, 800, 1.0f)) {
throw new BaseException("jpeg_800 转失败", ResultCode.FAILED_CODE);
}
String localJpegPic_205 = localPicPrefix + "_205_205.jpeg";
if (!ImageOperateTools.zipImageFile(localPngPic, localJpegPic_205, 205, 1.0f)) {
throw new BaseException("jpeg_205 转失败", ResultCode.FAILED_CODE);
}
String localJpegPic_98 = localPicPrefix + "_98_98.jpeg";
if (!ImageOperateTools.zipImageFile(localPngPic, localJpegPic_98, 98, 1.0f)) {
throw new BaseException("jpeg_98 转失败", ResultCode.FAILED_CODE);
}
imageStorageVo = ImageOperateTools.getWGS84BoundingBox(tifPath, imageStorageVo);
break; break;
} }
} }
//3、转坐标系 //3、上传图片、xml
return imageStorageVo; return imageStorageVo;
} }
} }
package com.upyuns.platform.rs.datacenter.utils.gdal; package com.upyuns.platform.rs.datacenter.utils.gdal;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam; import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder; import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.upyuns.platform.rs.datacenter.vo.ImageStorageVo;
import org.gdal.gdal.Dataset; import org.gdal.gdal.Dataset;
import org.gdal.gdal.Driver; import org.gdal.gdal.Driver;
import org.gdal.gdal.gdal; import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants; import org.gdal.gdalconst.gdalconstConstants;
import org.gdal.osr.CoordinateTransformation;
import org.gdal.osr.SpatialReference;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
...@@ -16,6 +21,7 @@ import java.io.File; ...@@ -16,6 +21,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
public class ImageOperateTools { public class ImageOperateTools {
...@@ -45,26 +51,92 @@ public class ImageOperateTools { ...@@ -45,26 +51,92 @@ public class ImageOperateTools {
return true; return true;
} }
/**
* 获取影像四点坐标
* @param inputPath
* @return
*/
public static ImageStorageVo getWGS84BoundingBox(String inputPath, ImageStorageVo imageStorageVo)throws BaseException {
//注册GDAL
gdal.AllRegister();
//设置中文
gdal.SetConfigOption("gdal_FILENAME_IS_UTF8", "YES");
//只读方式读取数据
Dataset sourceData = gdal.Open(inputPath, gdalconstConstants.GA_ReadOnly);
if (sourceData == null) {
throw new BaseException("文件错误", ResultCode.FAILED_CODE);
}
//获取源图像crs 获取源影像的坐标参考
String srcWkt = sourceData.GetProjectionRef();
//构造投影坐标系统的空间参考(srcWkt)
SpatialReference srcCrs = new SpatialReference(srcWkt);
sourceData.delete();
//设置输出图像的坐标
SpatialReference oLatLong;
//获取该投影坐标系统中的地理坐标系
oLatLong = srcCrs.CloneGeogCS();
//构造一个从投影坐标系到地理坐标系的转换关系
CoordinateTransformation ct = new CoordinateTransformation(srcCrs, oLatLong);
int xSize = sourceData.GetRasterXSize(); // 栅格尺寸
int ySize = sourceData.GetRasterYSize(); //
double[] geoTransform = sourceData.GetGeoTransform();
// 图像范围
// 东西方向空间分辨率 --->像素宽度
double wSrc = geoTransform[1];
// 南北方向空间分辨率 ---> 像素高度
double hSrc = geoTransform[5];
// x方向旋转角
double xRotate = geoTransform[2];
// y方向旋转角
double yRotate = geoTransform[4];
// 左上角x坐标,y坐标 ---> 影像 左上角 投影坐标
double xMin = geoTransform[0];
double yMax = geoTransform[3];
// 右下角 x坐标,y坐标
double xMax = geoTransform[0] + xSize * wSrc + ySize * xRotate;
double yMin = geoTransform[3] + xSize * yRotate + ySize * hSrc;
double a[] = ct.TransformPoint(xMin, yMax);
double b[] = ct.TransformPoint(xMax, yMin);
if (imageStorageVo == null) {
imageStorageVo = new ImageStorageVo();
}
//左上角坐标
imageStorageVo.setLeftTopLon(new BigDecimal(xMin + ""));
imageStorageVo.setLeftTopLat(new BigDecimal(yMax + ""));
//左下角坐标
imageStorageVo.setLeftBottomLon(new BigDecimal(xMin + ""));
imageStorageVo.setLeftBottomLat(new BigDecimal(yMin + ""));
//右下角坐标
imageStorageVo.setRightBottomLon(new BigDecimal(xMax + ""));
imageStorageVo.setRightBottomLat(new BigDecimal(yMin + ""));
//右上角坐标
imageStorageVo.setRightBottomLon(new BigDecimal(xMax + ""));
imageStorageVo.setRightBottomLat(new BigDecimal(yMax + ""));
BigDecimal two = new BigDecimal("2");
BigDecimal centerPointLon = imageStorageVo.getLeftTopLon().add(imageStorageVo.getRightBottomLon().divide(two));
BigDecimal centerPointLat = imageStorageVo.getLeftTopLat().add(imageStorageVo.getRightBottomLat().divide(two));
imageStorageVo.setImageCenterPointLon(centerPointLon);
imageStorageVo.setImageCenterPointLat(centerPointLat);
return imageStorageVo;
}
//jpeg图片压缩处理 //jpeg图片压缩处理
public static Boolean zipImageFile(String oldFile, String newFile, int width, float quality) { public static Boolean zipImageFile(String oldFile, String newFile, int width, float quality) {
if (oldFile == null) { if (oldFile == null) {
return false; return false;
} }
try { /**对服务器上的临时文件进行处理 */
/**对服务器上的临时文件进行处理 */ ImageIcon imageIcon = new ImageIcon(oldFile);
Image srcFile = ImageIO.read(new File(oldFile)); int iconWidth = imageIcon.getIconWidth();
ImageIcon imageIcon = new ImageIcon(oldFile); int iconHeight = imageIcon.getIconHeight();
int iconWidth = imageIcon.getIconWidth(); int height = iconHeight * width / iconWidth;
int iconHeight = imageIcon.getIconHeight(); return zipImageFile(oldFile, newFile, width, height, quality);
int height = iconHeight * width / iconWidth;
return zipImageFile(oldFile, newFile, width, height, quality);
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
} }
//jpeg图片压缩处理 //jpeg图片压缩处理
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment