Browse Source

modify some codes

master
xiaowuler 3 years ago
parent
commit
8b00600b5f
  1. 59
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/ICustomInputStream.java
  2. 116
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/impl/CustomRadarInputStream.java
  3. 2
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/impl/CustomerDataOutputStream.java
  4. 89
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/customer/CustomerDataInputStream.java
  5. 24
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/exceptions/RadarReadException.java
  6. 16
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/CommonBlock.java
  7. 16
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/GenericHeader.java
  8. 8
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentBlock.java
  9. 11
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentData.java
  10. 18
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentHeader.java
  11. 8
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/Radial.java
  12. 8
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/RadialBlock.java
  13. 34
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/RadialHeader.java
  14. 93
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/ScanConfiguration.java
  15. 36
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/SiteConfiguration.java
  16. 38
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/TaskConfiguration.java
  17. 27
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/enums/RadarSuffixEnum.java
  18. 57
      04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/resolver/RadarReader.java
  19. 13
      04.系统编码/03.radar-resolver/src/test/java/com/xiaowuler/radarresolver/RadarResolverApplicationTests.java

59
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/ICustomInputStream.java

@ -0,0 +1,59 @@
package com.xiaowuler.radarresolver.custom;
import java.io.IOException;
/**
* @describe: 自定义读取字节流
* @author: xiaowuler
* @createTime: 2022-03-17 17:07
*/
public interface ICustomInputStream {
/**
* 转换 int
* @return
* @throws IOException
*/
int readInt() throws IOException;
/**
* 转换 short
* @return
* @throws IOException
*/
short readShort() throws IOException;
/**
* 转换 long
* @return
* @throws IOException
*/
long readLong() throws IOException;
/**
* 转换 float
* @return
* @throws IOException
*/
float readFloat() throws IOException;
/**
* 读取 指定个数 字节
* @param len
* @return
* @throws IOException
*/
byte[] readNBytes(int len) throws IOException;
/**
* 判断是否存在字节
* @return
* @throws IOException
*/
int available() throws IOException;
/**
* 释放资源
* @throws IOException
*/
void close() throws IOException;
}

116
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/impl/CustomRadarInputStream.java

@ -0,0 +1,116 @@
package com.xiaowuler.radarresolver.custom.impl;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Locale;
import java.util.Objects;
import org.python.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
import com.xiaowuler.radarresolver.util.ByteUtils;
/**
* @describe: 自定义 雷达 输入流
* Big-Endian Little-Endian 字节排序
* * Big-Endian 一个Word中的高位的Byte放在内存中这个Word区域的低地址处
* * Little-Endian 一个Word中的低位的Byte放在内存中这个Word区域的低地址处
* * python写入的二进制文件和java二进制文件编码读取顺序不同java 是从左到右编码python是从右到左
* @author: xiaowuler
* @createTime: 2022-03-18 09:09
*/
public class CustomRadarInputStream implements ICustomInputStream, Closeable{
private static final String BZIP_SUFFIX = "bz2";
private static final String BIN_SUFFIX = "bin";
private InputStream inputStream;
private FileInputStream fileInputStream;
public CustomRadarInputStream(String filepath) throws FileNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
String fileSuffix = filepath.substring(filepath.lastIndexOf(".") + 1).trim().toLowerCase(Locale.ROOT);
switch (fileSuffix){
case BIN_SUFFIX:
customRadarInputStream(filepath, DataInputStream.class);
break;
case BZIP_SUFFIX:
customRadarInputStream(filepath, BZip2CompressorInputStream.class);
default:
throw new IllegalAccessException("无效的文件格式类型");
}
}
private <T extends InputStream> void customRadarInputStream(String filepath, Class<T> clazz) throws NoSuchMethodException, FileNotFoundException, InvocationTargetException, InstantiationException, IllegalAccessException {
fileInputStream = new FileInputStream(filepath);
inputStream = clazz.getConstructor(InputStream.class).newInstance(fileInputStream);
}
@Override
public int readInt() throws IOException {
int ch1 = inputStream.read();
int ch2 = inputStream.read();
int ch3 = inputStream.read();
int ch4 = inputStream.read();
if ((ch1 | ch2 | ch3 | ch4) < 0) {
throw new EOFException();
}
return ((ch1 << 0) + (ch2 << 8) + (ch3 << 16) + (ch4 << 24));
}
/**
* Big-Endian Little-Endian 字节排序
*
* Big-Endian 一个Word中的高位的Byte放在内存中这个Word区域的低地址处
* Little-Endian 一个Word中的低位的Byte放在内存中这个Word区域的低地址处
* @return
* @throws IOException
*/
@Override
public short readShort() throws IOException{
byte[] bytes = inputStream.readNBytes(2);
return ByteUtils.bytes2Short(bytes);
}
@Override
public long readLong() throws IOException{
byte[] bytes = inputStream.readNBytes(8);
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
return byteBuffer.getLong();
}
@Override
public float readFloat() throws IOException {
return Float.intBitsToFloat(readInt());
}
@Override
public byte[] readNBytes(int len) throws IOException{
return inputStream.readNBytes(len);
}
@Override
public int available() throws IOException {
return inputStream.available();
}
@Override
public void close() {
if (Objects.nonNull(fileInputStream)){
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (Objects.nonNull(inputStream)){
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

2
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/customer/CustomerDataOutputStream.java → 04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/custom/impl/CustomerDataOutputStream.java

@ -1,4 +1,4 @@
package com.xiaowuler.radarresolver.customer;
package com.xiaowuler.radarresolver.custom.impl;
import java.io.DataOutputStream;
import java.io.FilterOutputStream;

89
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/customer/CustomerDataInputStream.java

@ -1,89 +0,0 @@
package com.xiaowuler.radarresolver.customer;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import lombok.Data;
import com.xiaowuler.radarresolver.util.ByteUtils;
/**
* @describe: Big-Endian Little-Endian 字节排序
* Big-Endian 一个Word中的高位的Byte放在内存中这个Word区域的低地址处
* Little-Endian 一个Word中的低位的Byte放在内存中这个Word区域的低地址处
* python写入的二进制文件和java二进制文件编码读取顺序不同java 是从左到右编码python是从右到左
* @author: xiaowuler
* @createTime: 2021-05-19 09:01
*/
public class CustomerDataInputStream extends DataInputStream {
// private int pos = 0;
/**
* Creates a DataInputStream that uses the specified
* underlying InputStream.
*
* @param in the specified input stream
*/
public CustomerDataInputStream(InputStream in) {
super(in);
}
public final int readCInt() throws IOException {
// addPos(4);
int ch1 = in.read();
int ch2 = in.read();
int ch3 = in.read();
int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0) {
throw new EOFException();
}
return ((ch1 << 0) + (ch2 << 8) + (ch3 << 16) + (ch4 << 24));
}
/**
* Big-Endian Little-Endian 字节排序
*
* Big-Endian 一个Word中的高位的Byte放在内存中这个Word区域的低地址处
* Little-Endian 一个Word中的低位的Byte放在内存中这个Word区域的低地址处
* @return
* @throws IOException
*/
public final short readCShort() throws IOException{
// addPos(2);
byte[] bytes = in.readNBytes(2);
return ByteUtils.bytes2Short(bytes);
}
public final long readCLong() throws IOException{
// addPos(8);
byte[] bytes = in.readNBytes(8);
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
return byteBuffer.getLong();
}
public final float readCFloat() throws IOException {
// addPos(4);
return Float.intBitsToFloat(readCInt());
}
@Override
public byte[] readNBytes(int len) throws IOException{
// addPos(len);
return super.readNBytes(len);
}
public byte readCByte() throws IOException{
// addPos(1);
return super.readByte();
}
// public int getPos() {
// return pos;
// }
//
// private synchronized void addPos(int value) {
// this.pos += value;
// }
}

24
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/exceptions/RadarReadException.java

@ -0,0 +1,24 @@
package com.xiaowuler.radarresolver.exceptions;
/**
* @describe: 雷达读取异常
* @author: xiaowuler
* @createTime: 2022-03-18 09:47
*/
public class RadarReadException extends Exception {
public RadarReadException(){
super();
}
public RadarReadException(String message){
super(message);
}
public RadarReadException(String message, Throwable cause){
super(message, cause);
}
public RadarReadException(Throwable cause){
super(cause);
}
}

16
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/CommonBlock.java

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 公共数据块
@ -18,18 +18,18 @@ public class CommonBlock {
private SiteConfiguration siteConfiguration;
private TaskConfiguration taskConfiguration;
private List<ScanConfiguration> scanConfigurations;
public CommonBlock(CustomerDataInputStream customerDataInputStream) throws IOException {
this.genericHeader = new GenericHeader(customerDataInputStream);
this.siteConfiguration = new SiteConfiguration(customerDataInputStream);
this.taskConfiguration = new TaskConfiguration(customerDataInputStream);
public CommonBlock(ICustomInputStream ICustomInputStream) throws IOException {
this.genericHeader = new GenericHeader(ICustomInputStream);
this.siteConfiguration = new SiteConfiguration(ICustomInputStream);
this.taskConfiguration = new TaskConfiguration(ICustomInputStream);
addScanConfigurations(customerDataInputStream);
addScanConfigurations(ICustomInputStream);
}
private void addScanConfigurations(CustomerDataInputStream customerDataInputStream) throws IOException {
private void addScanConfigurations(ICustomInputStream ICustomInputStream) throws IOException {
this.scanConfigurations = new ArrayList<>(taskConfiguration.getCutNumber());
for(int index = 0; index < taskConfiguration.getCutNumber(); index++){
scanConfigurations.add(new ScanConfiguration(customerDataInputStream));
scanConfigurations.add(new ScanConfiguration(ICustomInputStream));
}
}
}

16
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/GenericHeader.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 通用头块
@ -43,12 +43,12 @@ public class GenericHeader {
*/
private byte[] reserved;
public GenericHeader(CustomerDataInputStream dataInputStream) throws IOException {
this.magicNumber = dataInputStream.readCInt();
this.majorVersion = dataInputStream.readCShort();
this.minorVersion = dataInputStream.readCShort();
this.genericType = dataInputStream.readCInt();
this.productType = dataInputStream.readCInt();
this.reserved = dataInputStream.readNBytes(16);
public GenericHeader(ICustomInputStream ICustomInputStream) throws IOException {
this.magicNumber = ICustomInputStream.readInt();
this.majorVersion = ICustomInputStream.readShort();
this.minorVersion = ICustomInputStream.readShort();
this.genericType = ICustomInputStream.readInt();
this.productType = ICustomInputStream.readInt();
this.reserved = ICustomInputStream.readNBytes(16);
}
}

8
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentBlock.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 径向数据块
@ -15,8 +15,8 @@ public class MomentBlock {
private MomentHeader momentHeader;
private MomentData momentData;
public MomentBlock(CustomerDataInputStream customerDataInputStream) throws IOException {
this.momentHeader = new MomentHeader(customerDataInputStream);
this.momentData = new MomentData(customerDataInputStream, momentHeader);
public MomentBlock(ICustomInputStream ICustomInputStream) throws IOException {
this.momentHeader = new MomentHeader(ICustomInputStream);
this.momentData = new MomentData(ICustomInputStream, momentHeader);
}
}

11
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentData.java

@ -1,12 +1,9 @@
package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
import com.xiaowuler.radarresolver.util.ByteUtils;
/**
@ -18,12 +15,12 @@ import com.xiaowuler.radarresolver.util.ByteUtils;
public class MomentData {
private double[] data;
public MomentData(CustomerDataInputStream customerDataInputStream, MomentHeader momentHeader) throws IOException {
public MomentData(ICustomInputStream ICustomInputStream, MomentHeader momentHeader) throws IOException {
if (momentHeader.getBinLength() == 1){
oneByteConvert(customerDataInputStream.readNBytes(momentHeader.getLength()), momentHeader.getLength(), momentHeader.getScale(), momentHeader.getOffset());
oneByteConvert(ICustomInputStream.readNBytes(momentHeader.getLength()), momentHeader.getLength(), momentHeader.getScale(), momentHeader.getOffset());
return;
}
twoByteConvert(customerDataInputStream.readNBytes(momentHeader.getLength()), momentHeader.getLength() / momentHeader.getBinLength(), momentHeader.getScale(), momentHeader.getOffset());
twoByteConvert(ICustomInputStream.readNBytes(momentHeader.getLength()), momentHeader.getLength() / momentHeader.getBinLength(), momentHeader.getScale(), momentHeader.getOffset());
}
private void oneByteConvert(byte[] bytes, int length, int scale, int offset){

18
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/MomentHeader.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 径向数据头
@ -20,13 +20,13 @@ public class MomentHeader {
private int length;
private byte[] reserved;
public MomentHeader(CustomerDataInputStream customerDataInputStream) throws IOException {
this.dataType = customerDataInputStream.readCInt();
this.scale = customerDataInputStream.readCInt();
this.offset = customerDataInputStream.readCInt();
this.binLength = customerDataInputStream.readCShort();
this.flags = customerDataInputStream.readCShort();
this.length = customerDataInputStream.readCInt();
this.reserved = customerDataInputStream.readNBytes(12);
public MomentHeader(ICustomInputStream ICustomInputStream) throws IOException {
this.dataType = ICustomInputStream.readInt();
this.scale = ICustomInputStream.readInt();
this.offset = ICustomInputStream.readInt();
this.binLength = ICustomInputStream.readShort();
this.flags = ICustomInputStream.readShort();
this.length = ICustomInputStream.readInt();
this.reserved = ICustomInputStream.readNBytes(12);
}
}

8
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/Radial.java

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe:
@ -18,12 +18,12 @@ public class Radial {
private RadialHeader radialHeader;
private List<MomentBlock> momentBlocks;
public Radial(CustomerDataInputStream customerDataInputStream) throws IOException {
this.radialHeader = new RadialHeader(customerDataInputStream);
public Radial(ICustomInputStream ICustomInputStream) throws IOException {
this.radialHeader = new RadialHeader(ICustomInputStream);
this.momentBlocks = new ArrayList<>(radialHeader.getMomentNumber());
for(int index = 0; index < radialHeader.getMomentNumber(); index ++){
momentBlocks.add(new MomentBlock(customerDataInputStream));
momentBlocks.add(new MomentBlock(ICustomInputStream));
}
}
}

8
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/RadialBlock.java

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 径向数据块
@ -17,10 +17,10 @@ public class RadialBlock {
private List<Radial> radials;
public RadialBlock(CustomerDataInputStream customerDataInputStream) throws IOException {
public RadialBlock(ICustomInputStream ICustomInputStream) throws IOException {
this.radials = new ArrayList<>();
while (customerDataInputStream.available() > 0){
this.radials.add(new Radial(customerDataInputStream));
while (ICustomInputStream.available() > 0){
this.radials.add(new Radial(ICustomInputStream));
}
}
}

34
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/RadialHeader.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 径向头
@ -28,21 +28,21 @@ public class RadialHeader {
private short verticalEstimatedNoise;
private byte[] reserved;
public RadialHeader(CustomerDataInputStream customerDataInputStream) throws IOException {
this.radialState = customerDataInputStream.readCInt();
this.spotBlank = customerDataInputStream.readCInt();
this.sequenceNumber = customerDataInputStream.readCInt();
this.radialNumber = customerDataInputStream.readCInt();
this.elevationNumber = customerDataInputStream.readCInt();
this.azimuth = customerDataInputStream.readCFloat();
this.elevation = customerDataInputStream.readCFloat();
this.seconds = customerDataInputStream.readCInt();
this.microseconds = customerDataInputStream.readCInt();
this.lengthData = customerDataInputStream.readCInt();
this.momentNumber = customerDataInputStream.readCInt();
this.otherReserved = customerDataInputStream.readNBytes(2);
this.horizontalEstimatedNoise = customerDataInputStream.readCShort();
this.verticalEstimatedNoise = customerDataInputStream.readCShort();
this.reserved = customerDataInputStream.readNBytes(14);
public RadialHeader(ICustomInputStream ICustomInputStream) throws IOException {
this.radialState = ICustomInputStream.readInt();
this.spotBlank = ICustomInputStream.readInt();
this.sequenceNumber = ICustomInputStream.readInt();
this.radialNumber = ICustomInputStream.readInt();
this.elevationNumber = ICustomInputStream.readInt();
this.azimuth = ICustomInputStream.readFloat();
this.elevation = ICustomInputStream.readFloat();
this.seconds = ICustomInputStream.readInt();
this.microseconds = ICustomInputStream.readInt();
this.lengthData = ICustomInputStream.readInt();
this.momentNumber = ICustomInputStream.readInt();
this.otherReserved = ICustomInputStream.readNBytes(2);
this.horizontalEstimatedNoise = ICustomInputStream.readShort();
this.verticalEstimatedNoise = ICustomInputStream.readShort();
this.reserved = ICustomInputStream.readNBytes(14);
}
}

93
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/ScanConfiguration.java

@ -1,10 +1,9 @@
package com.xiaowuler.radarresolver.weather.domain;
import java.io.BufferedInputStream;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
/**
* @describe: 扫描配置
@ -58,50 +57,50 @@ public class ScanConfiguration {
private short groundClutterFilterWindow;
private byte[] reserved;
public ScanConfiguration(CustomerDataInputStream customerDataInputStream) throws IOException {
this.processMode = customerDataInputStream.readCInt();
this.waveForm = customerDataInputStream.readCInt();
this.PRF1 = customerDataInputStream.readCFloat();
this.PRF2 = customerDataInputStream.readCFloat();
this.dealMode = customerDataInputStream.readCInt();
this.azimuth = customerDataInputStream.readCFloat();
this.elevation = customerDataInputStream.readCFloat();
this.startAngle = customerDataInputStream.readCFloat();
this.endAngle = customerDataInputStream.readCFloat();
this.angularResolution = customerDataInputStream.readCFloat();
this.scanSpeed = customerDataInputStream.readCFloat();
this.logResolution = customerDataInputStream.readCInt() * 0.001f;
this.dopplerResolution = customerDataInputStream.readCInt();
this.maximumRange1 = customerDataInputStream.readCInt();
this.maximumRange2 = customerDataInputStream.readCInt();
this.startRange = customerDataInputStream.readCInt();
this.sample1 = customerDataInputStream.readCInt();
this.sample2 = customerDataInputStream.readCInt();
this.phaseMode = customerDataInputStream.readCInt();
this.atmosphericLoss = customerDataInputStream.readCFloat();
this.nyquistSpeed = customerDataInputStream.readCFloat();
this.momentsMask = customerDataInputStream.readCLong();
this.momentsSizeMask = customerDataInputStream.readCLong();
this.miscFilterMask = customerDataInputStream.readCInt();
this.SQIThreshold = customerDataInputStream.readCFloat();
this.SIGThreshold = customerDataInputStream.readCFloat();
this.CSRThreshold = customerDataInputStream.readCFloat();
this.LOGThreshold = customerDataInputStream.readCFloat();
this.CPAThreshold = customerDataInputStream.readCFloat();
this.PMIThreshold = customerDataInputStream.readCFloat();
this.DPLOGThreshold = customerDataInputStream.readCFloat();
this.thresholdsReserved = customerDataInputStream.readNBytes(4);
this.dBTMask = customerDataInputStream.readCInt();
this.dBZMask = customerDataInputStream.readCInt();
this.velocityMask = customerDataInputStream.readCInt();
this.spectrumWidthMask = customerDataInputStream.readCInt();
this.DPMask = customerDataInputStream.readCInt();
this.maskReserved = customerDataInputStream.readNBytes(16);
this.direction = customerDataInputStream.readCInt();
this.groundClutterClassifierType = customerDataInputStream.readCShort();
this.groundClutterFilterType = customerDataInputStream.readCShort();
this.groundClutterFilterNotchWidth = customerDataInputStream.readCShort();
this.groundClutterFilterWindow = customerDataInputStream.readCShort();
this.reserved = customerDataInputStream.readNBytes(72);
public ScanConfiguration(ICustomInputStream ICustomInputStream) throws IOException {
this.processMode = ICustomInputStream.readInt();
this.waveForm = ICustomInputStream.readInt();
this.PRF1 = ICustomInputStream.readFloat();
this.PRF2 = ICustomInputStream.readFloat();
this.dealMode = ICustomInputStream.readInt();
this.azimuth = ICustomInputStream.readFloat();
this.elevation = ICustomInputStream.readFloat();
this.startAngle = ICustomInputStream.readFloat();
this.endAngle = ICustomInputStream.readFloat();
this.angularResolution = ICustomInputStream.readFloat();
this.scanSpeed = ICustomInputStream.readFloat();
this.logResolution = ICustomInputStream.readInt() * 0.001f;
this.dopplerResolution = ICustomInputStream.readInt();
this.maximumRange1 = ICustomInputStream.readInt();
this.maximumRange2 = ICustomInputStream.readInt();
this.startRange = ICustomInputStream.readInt();
this.sample1 = ICustomInputStream.readInt();
this.sample2 = ICustomInputStream.readInt();
this.phaseMode = ICustomInputStream.readInt();
this.atmosphericLoss = ICustomInputStream.readFloat();
this.nyquistSpeed = ICustomInputStream.readFloat();
this.momentsMask = ICustomInputStream.readLong();
this.momentsSizeMask = ICustomInputStream.readLong();
this.miscFilterMask = ICustomInputStream.readInt();
this.SQIThreshold = ICustomInputStream.readFloat();
this.SIGThreshold = ICustomInputStream.readFloat();
this.CSRThreshold = ICustomInputStream.readFloat();
this.LOGThreshold = ICustomInputStream.readFloat();
this.CPAThreshold = ICustomInputStream.readFloat();
this.PMIThreshold = ICustomInputStream.readFloat();
this.DPLOGThreshold = ICustomInputStream.readFloat();
this.thresholdsReserved = ICustomInputStream.readNBytes(4);
this.dBTMask = ICustomInputStream.readInt();
this.dBZMask = ICustomInputStream.readInt();
this.velocityMask = ICustomInputStream.readInt();
this.spectrumWidthMask = ICustomInputStream.readInt();
this.DPMask = ICustomInputStream.readInt();
this.maskReserved = ICustomInputStream.readNBytes(16);
this.direction = ICustomInputStream.readInt();
this.groundClutterClassifierType = ICustomInputStream.readShort();
this.groundClutterFilterType = ICustomInputStream.readShort();
this.groundClutterFilterNotchWidth = ICustomInputStream.readShort();
this.groundClutterFilterWindow = ICustomInputStream.readShort();
this.reserved = ICustomInputStream.readNBytes(72);
}
}

36
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/SiteConfiguration.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
import com.xiaowuler.radarresolver.util.ByteUtils;
/**
@ -111,22 +111,22 @@ public class SiteConfiguration {
*/
private byte[] reserved = new byte[46];
public SiteConfiguration(CustomerDataInputStream customerDataInputStream) throws IOException {
this.siteCode = ByteUtils.bytes2String(customerDataInputStream.readNBytes(8));
this.siteName = ByteUtils.bytes2String(customerDataInputStream.readNBytes(32));
this.latitude = customerDataInputStream.readCFloat();
this.longitude = customerDataInputStream.readCFloat();
this.antennaHeight = customerDataInputStream.readCInt();
this.groundHeight = customerDataInputStream.readCInt();
this.frequency = customerDataInputStream.readCFloat();
this.beamWidthHorizontal = customerDataInputStream.readCFloat();
this.beamWidthVertical = customerDataInputStream.readCFloat();
this.RDAVersion = customerDataInputStream.readCInt();
this.radarType = customerDataInputStream.readCShort();
this.antennaGain = customerDataInputStream.readCShort();
this.transmittingFeederLoss = customerDataInputStream.readCShort();
this.receivingFeederLoss = customerDataInputStream.readCShort();
this.otherLoss = customerDataInputStream.readCShort();
this.reserved = customerDataInputStream.readNBytes(46);
public SiteConfiguration(ICustomInputStream ICustomInputStream) throws IOException {
this.siteCode = ByteUtils.bytes2String(ICustomInputStream.readNBytes(8));
this.siteName = ByteUtils.bytes2String(ICustomInputStream.readNBytes(32));
this.latitude = ICustomInputStream.readFloat();
this.longitude = ICustomInputStream.readFloat();
this.antennaHeight = ICustomInputStream.readInt();
this.groundHeight = ICustomInputStream.readInt();
this.frequency = ICustomInputStream.readFloat();
this.beamWidthHorizontal = ICustomInputStream.readFloat();
this.beamWidthVertical = ICustomInputStream.readFloat();
this.RDAVersion = ICustomInputStream.readInt();
this.radarType = ICustomInputStream.readShort();
this.antennaGain = ICustomInputStream.readShort();
this.transmittingFeederLoss = ICustomInputStream.readShort();
this.receivingFeederLoss = ICustomInputStream.readShort();
this.otherLoss = ICustomInputStream.readShort();
this.reserved = ICustomInputStream.readNBytes(46);
}
}

38
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/domain/TaskConfiguration.java

@ -3,7 +3,7 @@ package com.xiaowuler.radarresolver.weather.domain;
import java.io.IOException;
import lombok.Data;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.ICustomInputStream;
import com.xiaowuler.radarresolver.util.ByteUtils;
/**
@ -120,23 +120,23 @@ public class TaskConfiguration {
*/
private byte[] reserved;
public TaskConfiguration(CustomerDataInputStream customerDataInputStream) throws IOException {
this.taskName = ByteUtils.bytes2String(customerDataInputStream.readNBytes(32));
this.taskDescription = ByteUtils.bytes2String(customerDataInputStream.readNBytes(128));
this.polarizationType = customerDataInputStream.readCInt();
this.scanType = customerDataInputStream.readCInt();
this.pulseWidth = customerDataInputStream.readCInt();
this.scanStartTime = customerDataInputStream.readCInt();
this.cutNumber = customerDataInputStream.readCInt();
this.horizontalNoise = customerDataInputStream.readCFloat();
this.verticalNoise = customerDataInputStream.readCFloat();
this.horizontalCalibration = customerDataInputStream.readCFloat();
this.verticalCalibration = customerDataInputStream.readCFloat();
this.horizontalNoiseTemperature = customerDataInputStream.readCFloat();
this.verticalNoiseTemperature = customerDataInputStream.readCFloat();
this.ZDRCalibration = customerDataInputStream.readCFloat();
this.PHIDPCalibration = customerDataInputStream.readCFloat();
this.LDRCalibration = customerDataInputStream.readCFloat();
this.reserved = customerDataInputStream.readNBytes(40);
public TaskConfiguration(ICustomInputStream ICustomInputStream) throws IOException {
this.taskName = ByteUtils.bytes2String(ICustomInputStream.readNBytes(32));
this.taskDescription = ByteUtils.bytes2String(ICustomInputStream.readNBytes(128));
this.polarizationType = ICustomInputStream.readInt();
this.scanType = ICustomInputStream.readInt();
this.pulseWidth = ICustomInputStream.readInt();
this.scanStartTime = ICustomInputStream.readInt();
this.cutNumber = ICustomInputStream.readInt();
this.horizontalNoise = ICustomInputStream.readFloat();
this.verticalNoise = ICustomInputStream.readFloat();
this.horizontalCalibration = ICustomInputStream.readFloat();
this.verticalCalibration = ICustomInputStream.readFloat();
this.horizontalNoiseTemperature = ICustomInputStream.readFloat();
this.verticalNoiseTemperature = ICustomInputStream.readFloat();
this.ZDRCalibration = ICustomInputStream.readFloat();
this.PHIDPCalibration = ICustomInputStream.readFloat();
this.LDRCalibration = ICustomInputStream.readFloat();
this.reserved = ICustomInputStream.readNBytes(40);
}
}

27
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/enums/RadarSuffixEnum.java

@ -0,0 +1,27 @@
package com.xiaowuler.radarresolver.weather.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
/**
* @describe: 雷达文件枚举
* @author: xiaowuler
* @createTime: 2022-03-18 09:19
*/
@AllArgsConstructor
public enum RadarSuffixEnum {
/**
* 二进制 文件 后缀名
*/
BIN(".bin"),
/**
* 压缩文件 后缀名
*/
BZIP2(".bz2");
@Getter
private final String type;
}

57
04.系统编码/03.radar-resolver/src/main/java/com/xiaowuler/radarresolver/weather/resolver/RadarReader.java

@ -1,17 +1,14 @@
package com.xiaowuler.radarresolver.weather.resolver;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import com.xiaowuler.radarresolver.customer.CustomerDataInputStream;
import com.xiaowuler.radarresolver.custom.impl.CustomRadarInputStream;
import com.xiaowuler.radarresolver.exceptions.RadarReadException;
import com.xiaowuler.radarresolver.weather.domain.*;
import org.python.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
/**
* @describe: radar reader
@ -24,46 +21,22 @@ public class RadarReader {
private static final double DEG2RAD = Math.PI / 180;
private RadarBlock radarBlock;
public void read(String filepath) {
FileInputStream fileInputStream = null;
CustomerDataInputStream customerDataInputStream = null;
try{
fileInputStream = new FileInputStream(filepath);
customerDataInputStream = new CustomerDataInputStream(fileInputStream);
CustomerDataInputStream finalCustomerDataInputStream = customerDataInputStream;
public void read(String filepath) throws RadarReadException {
CustomRadarInputStream customRadarInputStream = null;
try {
customRadarInputStream = new CustomRadarInputStream(filepath);
CustomRadarInputStream finalCustomRadarInputStream = customRadarInputStream;
this.radarBlock = new RadarBlock(){{
setCommonBlock(new CommonBlock(finalCustomerDataInputStream));
setRadialBlock(new RadialBlock(finalCustomerDataInputStream));
setCommonBlock(new CommonBlock(finalCustomRadarInputStream));
setRadialBlock(new RadialBlock(finalCustomRadarInputStream));
}};
}catch (Exception e){
log.error("文件:【{}】解析失败,原因:{}", filepath, e.getMessage());
}finally {
if (Objects.nonNull(fileInputStream)){
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
log.error("雷达文件:[" + filepath + "]读取失败", e);
throw new RadarReadException(e);
} finally {
if (Objects.nonNull(customRadarInputStream)){
customRadarInputStream.close();
}
if (Objects.nonNull(customerDataInputStream)){
try {
customerDataInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public void readBiz2(String filepath){
try{
BZip2CompressorInputStream bis = new BZip2CompressorInputStream(new FileInputStream(filepath));
System.out.println(bis.readAllBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

13
04.系统编码/03.radar-resolver/src/test/java/com/xiaowuler/radarresolver/RadarResolverApplicationTests.java

@ -6,18 +6,23 @@ import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import com.xiaowuler.radarresolver.exceptions.RadarReadException;
import com.xiaowuler.radarresolver.weather.resolver.RadarReader;
@SpringBootTest
class RadarResolverApplicationTests {
@Test
void contextLoads() throws IOException {
void contextLoads() throws RadarReadException {
RadarReader radarReader = new RadarReader();
radarReader.read("C:\\Users\\xiaowuler\\Desktop\\Z_RADR_I_Z9551_20210712000134_O_DOR_SA_CAP_FMT.bin");
// double[] latLngs = radarReader.calcLonLat(1839 * 0.25f, 164.5f, 0.68f, 117.23944f, 31.866112f);
List<List<double[]>> coordinate = radarReader.getCoordinate();
radarReader.read("C:\\Users\\xiaowuler\\Desktop\\test\\Z_RADR_I_Z9551_20210712000134_O_DOR_SA_CAP_FMT.bin\\Z_RADR_I_Z9551_20210712000134_O_DOR_SA_CAP_FMT.bin");
// byte[] ss = radarReader.readBiz2("C:\\Users\\xiaowuler\\Desktop\\test\\Z_RADR_I_Z9551_20210712000134_O_DOR_SA_CAP_FMT.bin.bz2");
System.out.println();
// radarReader.read("C:\\Users\\xiaowuler\\Desktop\\Z_RADR_I_Z9551_20210712000134_O_DOR_SA_CAP_FMT.bin");
// double[] latLngs = radarReader.calcLonLat(1839 * 0.25f, 164.5f, 0.68f, 117.23944f, 31.866112f);
// List<List<double[]>> coordinate = radarReader.getCoordinate();
// System.out.println();
//
// List<Map<String, Object>> values = new ArrayList<>(){{
// add(new HashMap<>(){{

Loading…
Cancel
Save