Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周健威
rs-cloud-platform
Commits
f9882d8e
Commit
f9882d8e
authored
Dec 17, 2020
by
xiaosl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ruku
parent
3d6bb76d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
10 deletions
+93
-10
FileOperateUtil.java
.../upyuns/platform/rs/datacenter/utils/FileOperateUtil.java
+17
-0
ImageStorageParseUtil.java
...s/platform/rs/datacenter/utils/ImageStorageParseUtil.java
+53
-10
ImageOperateTools.java
.../platform/rs/datacenter/utils/gdal/ImageOperateTools.java
+23
-0
No files found.
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/FileOperateUtil.java
View file @
f9882d8e
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
package
com
.
upyuns
.
platform
.
rs
.
datacenter
.
utils
;
import
java.io.File
;
public
class
FileOperateUtil
{
public
class
FileOperateUtil
{
public
static
String
getFileNameNotFormat
(
String
filePath
)
{
public
static
String
getFileNameNotFormat
(
String
filePath
)
{
...
@@ -20,4 +22,19 @@ public class FileOperateUtil {
...
@@ -20,4 +22,19 @@ public class FileOperateUtil {
String
fileName
=
filePath
.
substring
(
indexOf
);
String
fileName
=
filePath
.
substring
(
indexOf
);
return
fileName
;
return
fileName
;
}
}
public
static
String
getlocalFileParentPath
(
String
filePath
)
{
File
file
=
new
File
(
filePath
);
return
file
.
getParent
();
}
public
static
String
getPathParentPath
(
String
filePath
)
{
filePath
=
filePath
.
replaceAll
(
"\\\\"
,
"/"
);
Integer
indexOf
=
filePath
.
lastIndexOf
(
"/"
);
String
parentPath
=
filePath
;
if
(
indexOf
>
0
)
{
parentPath
=
parentPath
.
substring
(
0
,
indexOf
);
}
return
parentPath
;
}
}
}
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/ImageStorageParseUtil.java
View file @
f9882d8e
...
@@ -3,9 +3,12 @@ package com.upyuns.platform.rs.datacenter.utils;
...
@@ -3,9 +3,12 @@ package com.upyuns.platform.rs.datacenter.utils;
import
com.github.wxiaoqi.security.common.constant.RestCode
;
import
com.github.wxiaoqi.security.common.constant.RestCode
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.upyuns.platform.rs.datacenter.utils.gdal.ImageOperateTools
;
import
com.upyuns.platform.rs.datacenter.vo.ImageStorageVo
;
import
com.upyuns.platform.rs.datacenter.vo.ImageStorageVo
;
import
com.upyuns.platform.rs.gtdata.GtDataRestClient
;
import
com.upyuns.platform.rs.gtdata.GtDataRestClient
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -14,8 +17,8 @@ import java.io.FileOutputStream;
...
@@ -14,8 +17,8 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.
util.Lis
t
;
import
java.
text.SimpleDateForma
t
;
import
java.util.
Map
;
import
java.util.
*
;
public
class
ImageStorageParseUtil
{
public
class
ImageStorageParseUtil
{
...
@@ -73,6 +76,7 @@ public class ImageStorageParseUtil {
...
@@ -73,6 +76,7 @@ public class ImageStorageParseUtil {
if
(
xmlPathList
==
null
||
xmlPathList
.
size
()
==
0
)
{
if
(
xmlPathList
==
null
||
xmlPathList
.
size
()
==
0
)
{
throw
new
BaseException
(
"xml文件提取失败"
,
ResultCode
.
FAILED_CODE
);
throw
new
BaseException
(
"xml文件提取失败"
,
ResultCode
.
FAILED_CODE
);
}
}
List
<
String
>
fileNameList
=
new
ArrayList
<>();
ImageStorageVo
imageStorageVo
=
new
ImageStorageVo
();
ImageStorageVo
imageStorageVo
=
new
ImageStorageVo
();
//初始基础或固定信息
//初始基础或固定信息
imageStorageVo
.
setName
(
FileOperateUtil
.
getFileNameNotFormat
(
inputLocalPath
));
imageStorageVo
.
setName
(
FileOperateUtil
.
getFileNameNotFormat
(
inputLocalPath
));
...
@@ -88,22 +92,41 @@ public class ImageStorageParseUtil {
...
@@ -88,22 +92,41 @@ public class ImageStorageParseUtil {
XmlFileOperateUtil
.
xmlParse
(
xmlPath
,
paramsMap
);
XmlFileOperateUtil
.
xmlParse
(
xmlPath
,
paramsMap
);
if
(
paramsMap
.
get
(
"camera"
)
!=
null
&&
paramsMap
.
get
(
"bounds"
)
!=
null
)
{
if
(
paramsMap
.
get
(
"camera"
)
!=
null
&&
paramsMap
.
get
(
"bounds"
)
!=
null
)
{
//拍摄时间
//拍摄时间
imageStorageVo
.
setImageTakeTime
(
paramsMap
.
get
(
"created_at"
));
String
takeTime
=
paramsMap
.
get
(
"created_at"
);
imageStorageVo
.
setImageProductTime
(
paramsMap
.
get
(
"created_at"
));
if
(
StringUtils
.
isNotBlank
(
takeTime
))
{
imageStorageVo
.
setImageEndTime
(
paramsMap
.
get
(
"created_at"
));
String
takeTimeFormat
=
takeTime
.
replace
(
"T"
,
" "
);
imageStorageVo
.
setImageStartTime
(
paramsMap
.
get
(
"created_at"
));
Integer
indexOf
=
takeTimeFormat
.
lastIndexOf
(
"."
);
imageStorageVo
.
setImageCenterTime
(
paramsMap
.
get
(
"created_at"
));
if
(
indexOf
>
0
)
{
takeTimeFormat
=
takeTimeFormat
.
substring
(
0
,
indexOf
);
}
if
(
takeTime
.
toLowerCase
().
endsWith
(
"z"
))
{
//UTC格林标准时区
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
try
{
Date
date
=
sdf
.
parse
(
takeTimeFormat
);
DateUtils
.
addHours
(
date
,
8
);
//增加8小时,转为北京时区
takeTimeFormat
=
sdf
.
format
(
date
);
}
catch
(
Exception
e
)
{
throw
new
BaseException
(
"时间解析失败"
,
ResultCode
.
FAILED_CODE
);
}
}
imageStorageVo
.
setImageTakeTime
(
takeTimeFormat
);
imageStorageVo
.
setImageProductTime
(
takeTimeFormat
);
imageStorageVo
.
setImageEndTime
(
takeTimeFormat
);
imageStorageVo
.
setImageStartTime
(
takeTimeFormat
);
imageStorageVo
.
setImageCenterTime
(
takeTimeFormat
);
}
//供应商
//供应商
imageStorageVo
.
setSupplier
(
paramsMap
.
get
(
"supplier"
));
imageStorageVo
.
setSupplier
(
paramsMap
.
get
(
"supplier"
));
//卫星名称、类型
//卫星名称、类型
imageStorageVo
.
setImageSatelliteType
(
paramsMap
.
get
(
"satellite_name"
));
imageStorageVo
.
setImageSatelliteType
(
paramsMap
.
get
(
"satellite_name"
));
imageStorageVo
.
setImageSatelliteTypeDisplay
(
paramsMap
.
get
(
"satellite_name"
));
imageStorageVo
.
setImageSatelliteTypeDisplay
(
paramsMap
.
get
(
"satellite_name"
));
//云量
//云量
imageStorageVo
.
setImageCloudage
(
new
BigDecimal
(
paramsMap
.
get
(
"cloud_pctg"
))
.
intValue
()
);
imageStorageVo
.
setImageCloudage
(
new
BigDecimal
(
paramsMap
.
get
(
"cloud_pctg"
)));
//传感器类型
//传感器类型
imageStorageVo
.
setImageSensorType
(
paramsMap
.
get
(
"camera"
));
imageStorageVo
.
setImageSensorType
(
paramsMap
.
get
(
"camera"
));
imageStorageVo
.
setImageSensorId
(
paramsMap
.
get
(
"camera"
));
imageStorageVo
.
setImageSensorId
(
paramsMap
.
get
(
"camera"
));
//景id
imageStorageVo
.
setImageSceneId
(
paramsMap
.
get
(
"scene_id"
));
xmlFlag
=
true
;
xmlFlag
=
true
;
break
;
break
;
...
@@ -113,7 +136,27 @@ public class ImageStorageParseUtil {
...
@@ -113,7 +136,27 @@ public class ImageStorageParseUtil {
throw
new
BaseException
(
"xml 解析失败"
,
ResultCode
.
FAILED_CODE
);
throw
new
BaseException
(
"xml 解析失败"
,
ResultCode
.
FAILED_CODE
);
}
}
//2、提取tiff,生成缩略图
//2、提取tiff,生成缩略图
List
<
String
>
tifPathList
=
TarFileOperateUtil
.
zipFileRead
(
inputLocalPath
,
localOutputDir
,
".tif"
);
if
(
tifPathList
==
null
||
tifPathList
.
size
()
==
0
)
{
tifPathList
=
TarFileOperateUtil
.
zipFileRead
(
inputLocalPath
,
localOutputDir
,
".tiff"
);
}
if
(
tifPathList
==
null
||
tifPathList
.
size
()
==
0
)
{
throw
new
BaseException
(
"tif 文件提取失败"
,
ResultCode
.
FAILED_CODE
);
}
//生成缩略图
List
<
String
>
picPathList
=
new
ArrayList
<>();
for
(
String
tifPath
:
tifPathList
)
{
if
(
tifPath
.
toLowerCase
().
contains
(
"_quicklook"
))
{
String
localPicPrefix
=
FileOperateUtil
.
getlocalFileParentPath
(
tifPath
)
+
"/"
+
FileOperateUtil
.
getFileNameNotFormat
(
tifPath
);
String
localPngPic
=
localPicPrefix
+
".png"
;
ImageOperateTools
.
tif2Pic
(
tifPath
,
localPngPic
);
picPathList
.
add
(
localPngPic
);
String
localTargetPngPic
=
localPicPrefix
+
"_800_800.png"
;
ImageOperateTools
.
zipImageFile
(
localPngPic
,
localTargetPngPic
,
800
,
1.0f
);
break
;
}
}
//3、转坐标系
//3、转坐标系
return
imageStorageVo
;
return
imageStorageVo
;
}
}
...
...
rs-datacenter/rs-datacenter-server/src/main/java/com/upyuns/platform/rs/datacenter/utils/gdal/ImageOperateTools.java
View file @
f9882d8e
...
@@ -9,6 +9,7 @@ import org.gdal.gdal.gdal;
...
@@ -9,6 +9,7 @@ import org.gdal.gdal.gdal;
import
org.gdal.gdalconst.gdalconstConstants
;
import
org.gdal.gdalconst.gdalconstConstants
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.File
;
...
@@ -44,6 +45,28 @@ public class ImageOperateTools {
...
@@ -44,6 +45,28 @@ public class ImageOperateTools {
return
true
;
return
true
;
}
}
//jpeg图片压缩处理
public
static
Boolean
zipImageFile
(
String
oldFile
,
String
newFile
,
int
width
,
float
quality
)
{
if
(
oldFile
==
null
)
{
return
false
;
}
try
{
/**对服务器上的临时文件进行处理 */
Image
srcFile
=
ImageIO
.
read
(
new
File
(
oldFile
));
ImageIcon
imageIcon
=
new
ImageIcon
(
oldFile
);
int
iconWidth
=
imageIcon
.
getIconWidth
();
int
iconHeight
=
imageIcon
.
getIconHeight
();
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图片压缩处理
public
static
Boolean
zipImageFile
(
String
oldFile
,
String
newFile
,
int
width
,
int
height
,
float
quality
)
{
public
static
Boolean
zipImageFile
(
String
oldFile
,
String
newFile
,
int
width
,
int
height
,
float
quality
)
{
if
(
oldFile
==
null
)
{
if
(
oldFile
==
null
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment