Skip to content

Commit

Permalink
Merge pull request #1 from ZZHow1024/develop
Browse files Browse the repository at this point in the history
ZSEGY1.0.0
  • Loading branch information
ZZHow1024 authored Nov 26, 2024
2 parents 9146a3f + 6622b7e commit 2fa1d84
Show file tree
Hide file tree
Showing 9 changed files with 1,937 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
/out
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 ZZHow(ZZHow1024)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,65 @@
# MagicSEGY
MagicSEGY.Developing with Java.
# [Java 项目]ZSEGY(中文说明)

---

Website:

[[Java 项目]ZSEGY | ZZHow](https://www.zzhow.com/ZSEGY)

Source Code:

https://github.com/ZZHow1024/ZSEGY

Releases:

https://github.com/ZZHow1024/ZSEGY/releases

---

## 它是什么?

ZSEGY 是一款跨平台的 SEG-Y 文件解析工具,支持命令模式和交互模式,可以解析并显示 SEG-Y 文件的文件头和数据体。

---

## 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 [LICENSE](https://github.com/ZZHow1024/ZSEGY/blob/main/LICENSE) 文件。

---

## 使用说明

下载地址:https://github.com/ZZHow1024/ZSEGY/releases

- 下载 .jar 文件
- 命令模式:
- 通过 `java -jar zsegy.jar [-command] <num> [filePath]` 命令使用软件。
- -head [filePath]:解析并输出文件头
- -body <num> [filePath]:解析并输出数据体中的第 num 个数据道
- -all <num> [filePath]:解析并输出文件头和数据体中的第 num 个数据道
-i [filePath]:解析并进入交互模式
- help:呼出本提示
- 交互模式:
- 通过 `java -jar zsegy.jar` 命令使用软件。
1. 指定文件全路径
2. 展示文件头
3. 展示数据体
4. 退出程序

---

## 各版本功能介绍

- ZSEGY1.0.0
- 解析 SEG-Y文件
- 输出解析后的内容
- 支持命令模式与交互模式

---

## 各版本主界面

![ZSEGY1.0.0](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2F77686c07-8ce0-4713-9982-c0fbb624147e%2FZSEGY1.0.0.png?table=block&id=14ae64bd-e40f-8010-b353-e36c9a36e3d9&t=14ae64bd-e40f-8010-b353-e36c9a36e3d9&width=434&cache=v2)

ZSEGY1.0.0
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: Main

131 changes: 131 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import pojo.entity.SEGY;
import util.SEGYUtils;

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

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

System.out.println("ZSEGY 1.0.0");
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]));
System.exit(0);
}
case "-body", "body" -> {
long num = 1;
try {
num = Long.parseLong(args[1]);
} catch (NumberFormatException e) {
System.out.println("格式错误,输入 -help 查看提示");
System.exit(0);;
}
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;
try {
num = Long.parseLong(args[1]);
} 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));
System.exit(0);
}
case "-i", "i" -> {
filePath = args[1];
}
case "-help", "help" -> {
System.out.println("--- ZSEGY 1.0.0 使用说明 ---");
System.out.println("java -jar zsegy.jar [-command] <num> [filePath]");
System.out.println("[-command]: ");
System.out.println("-head [filePath]:解析并输出文件头");
System.out.println("-body <num> [filePath]:解析并输出数据体中的第 num 个数据道");
System.out.println("-all <num> [filePath]:解析并输出文件头和数据体中的第 num 个数据道");
System.out.println("-i [filePath]:解析并进入交互模式");
System.out.println();
System.out.println("-help:呼出本提示");
System.exit(0);
}
}
}

// 交互模式
// 程序主界面
System.out.println("0. 指定文件全路径\t\t");
System.out.println("1. 展示文件头");
System.out.println("2. 展示数据体");
System.out.println("3. 退出程序");

String op = "-1";
if (filePath == null || filePath.isEmpty()) {
System.out.println("尚未指定文件");
op = "0";
} else {
try {
segy = SEGYUtils.parseSEGY(filePath);
} catch (UnsupportedOperationException e) {
System.out.println("数据采样格式编码错误,请检查");
}
}

while (true) {
switch (op) {
case "0" -> {
System.out.println("请输入文件全路径:");
filePath = scanner.next();
if (!new File(filePath).exists()) {
filePath = null;
System.out.println("文件不存在!");
} else {
try {
segy = SEGYUtils.parseSEGY(filePath);
} catch (UnsupportedOperationException e) {
System.out.println("数据采样格式编码错误,请检查");
}
}
}
case "1" -> {
System.out.println(segy.getFileHeader());
}
case "2" -> {
System.out.print("数据道数:");
long num = scanner.nextLong();
System.out.println(segy.getDataBodies().get(num));
}
case "3" -> {
System.out.println("程序退出...");
System.exit(0);
}
case "-1" -> {
}
default -> {
System.out.println("无效输入");
}
}
System.out.print("->");
op = scanner.next();
scanner.nextLine();
}
}
}
Loading

0 comments on commit 2fa1d84

Please sign in to comment.