Skip to content

Commit

Permalink
Merge pull request #2 from ZZHow1024/develop
Browse files Browse the repository at this point in the history
ZSEGY1.0.1
  • Loading branch information
ZZHow1024 committed Nov 27, 2024
2 parents 8a93fee + 41d19c0 commit 38a6e76
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 146 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ ZSEGY 是一款跨平台的 SEG-Y 文件解析工具,支持命令模式和交
3. 展示数据体
4. 退出程序

------

## 参考文献

- SEG Y rev 1Release 1.02: [library.seg.org](https://library.seg.org/pb-assets/technical-standards/seg_y_rev1-1686080991247.pdf)

---

## 各版本功能介绍
Expand Down
2 changes: 1 addition & 1 deletion src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: Main
Main-Class: MainClass

11 changes: 11 additions & 0 deletions src/MainClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ui.Application;

/**
* @author ZZHow
* @date 2024/11/25
*/
public class MainClass {
public static void main(String[] args) {
Application.show(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author ZZHow
* @date 2024/11/25
*/
public class DataBody {
/* 数据体第一部分——道头 */
public class DataTrace {
/* 数据道第一部分——道头 */
// 1-4:测线中道顺序号
private Integer traceSequenceNumberWithinLine;
// 5-8:SEG Y文件中道顺序号
Expand Down Expand Up @@ -183,9 +183,10 @@ public class DataBody {
// 233-240:未赋值――为任选信息预留
/**/

/* 数据道第二部分——采样数据 */
private float[] samplingData;

public DataBody() {
public DataTrace() {
}

public Integer getTraceSequenceNumberWithinLine() {
Expand Down
14 changes: 7 additions & 7 deletions src/pojo/entity/SEGY.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ public class SEGY {
// 文件头
private FileHeader fileHeader;
// 数据体
private Map<Long, DataBody> dataBodies;
private Map<Long, DataTrace> dataBody;

public SEGY() {
}

public SEGY(FileHeader fileHeader, Map<Long, DataBody> dataBodies) {
public SEGY(FileHeader fileHeader, Map<Long, DataTrace> dataBody) {
this.fileHeader = fileHeader;
this.dataBodies = dataBodies;
this.dataBody = dataBody;
}

public FileHeader getFileHeader() {
return fileHeader;
}

public Map<Long, DataBody> getDataBodies() {
return dataBodies;
public Map<Long, DataTrace> getDataBody() {
return dataBody;
}

public void setFileHeader(FileHeader fileHeader) {
this.fileHeader = fileHeader;
}

public void setDataBodies(Map<Long, DataBody> dataBodies) {
this.dataBodies = dataBodies;
public void setDataBody(Map<Long, DataTrace> dataBody) {
this.dataBody = dataBody;
}
}
84 changes: 60 additions & 24 deletions src/Main.java → src/ui/Application.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,86 @@
package ui;

import pojo.entity.DataTrace;
import pojo.entity.FileHeader;
import pojo.entity.SEGY;
import util.SEGYUtils;

import java.io.File;
import java.util.Map;
import java.util.Scanner;

/**
* @author ZZHow
* @date 2024/11/25
* @date 2024/11/27
*/
public class Main {
public static void main(String[] args) {
public class Application {
public static void show(String[] args) {
Scanner scanner = new Scanner(System.in);
SEGY segy = new SEGY();
String filePath = "";

System.out.println("ZSEGY 1.0.0");
System.out.println("ZSEGY 1.0.1");
System.out.println("Author: ZZHow");

// 命令模式
if (args.length != 0) {

switch (args[0]) {
case "-head", "head" -> {
System.out.println("正在解析中...");
System.out.println(SEGYUtils.parseFileHeader(args[1]));
FileHeader fileHeader = null;
try {
fileHeader = SEGYUtils.parseFileHeader(args[1]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("格式错误,输入 -help 查看提示");
}
if (fileHeader != null)
System.out.println(fileHeader);
System.exit(0);
}
case "-body", "body" -> {
long num = 1;
try {
num = Long.parseLong(args[1]);
} catch (NumberFormatException e) {
segy = SEGYUtils.parseSEGY(args[2]);
} catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
System.out.println("格式错误,输入 -help 查看提示");
System.exit(0);;
System.exit(0);
} catch (UnsupportedOperationException e) {
System.out.println("数据采样格式编码错误,请检查");
}
if (segy != null) {
System.out.println("\n@@@第 " + num + " 个数据道@@@");
System.out.println(segy.getDataBody().get(num));
}
segy = SEGYUtils.parseSEGY(args[2]);
System.out.println("\n@@@第 " + num + " 个数据道@@@");
System.out.println(segy.getDataBodies().get(num));
System.exit(0);
}
case "-all", "all" -> {
long num;
long num = 1;
try {
num = Long.parseLong(args[1]);
segy = SEGYUtils.parseSEGY(args[2]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("格式错误,输入 -help 查看提示");
} catch (NumberFormatException e) {
System.out.println("输入格式错误,输入 -help 查看提示");
break;
}
segy = SEGYUtils.parseSEGY(args[2]);
System.out.println(segy.getFileHeader());
System.out.println("\n@@@第 " + num + " 个数据道@@@");
System.out.println(segy.getDataBodies().get(num));
if (segy != null) {
System.out.println(segy.getFileHeader());
System.out.println("\n@@@第 " + num + " 个数据道@@@");
System.out.println(segy.getDataBody().get(num));
}
System.exit(0);
}
case "-i", "i" -> {
filePath = args[1];
try {
filePath = args[1];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("输入格式错误,输入 -help 查看提示");
System.exit(0);
}
}
case "-help", "help" -> {
System.out.println("--- ZSEGY 1.0.0 使用说明 ---");
System.out.println("--- ZSEGY 1.0.1 使用说明 ---");
System.out.println("java -jar zsegy.jar [-command] <num> [filePath]");
System.out.println("[-command]: ");
System.out.println("-head [filePath]:解析并输出文件头");
Expand Down Expand Up @@ -106,12 +130,24 @@ public static void main(String[] args) {
}
}
case "1" -> {
System.out.println(segy.getFileHeader());
if (segy != null)
System.out.println(segy.getFileHeader());
else
System.out.println("文件头为空");
}
case "2" -> {
System.out.print("数据道数:");
long num = scanner.nextLong();
System.out.println(segy.getDataBodies().get(num));
if (segy != null) {
Map<Long, DataTrace> dataBody = segy.getDataBody();
if (dataBody == null) {
System.out.println("数据体为空");
} else {
System.out.print("数据道数:");
long num = scanner.nextLong();
System.out.println(dataBody.get(num));
}
} else {
System.out.println("数据体为空");
}
}
case "3" -> {
System.out.println("程序退出...");
Expand All @@ -128,4 +164,4 @@ public static void main(String[] args) {
scanner.nextLine();
}
}
}
}
Loading

0 comments on commit 38a6e76

Please sign in to comment.