fitst
This commit is contained in:
commit
20f481dac0
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
.idea/codeStyles/Project.xml
Normal file
7
.idea/codeStyles/Project.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
50
pom.xml
Normal file
50
pom.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>lll</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>lll</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<scala.version>2.12.8</scala.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.deng0515001</groupId>
|
||||
<artifactId>lnglat2Geo</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration><!--根据个人需要自己修改-->
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
35
src/main/java/org/example/App.java
Normal file
35
src/main/java/org/example/App.java
Normal file
@ -0,0 +1,35 @@
|
||||
package org.example;
|
||||
|
||||
import com.dengxq.lnglat2Geo.entity.Admin;
|
||||
import com.dengxq.lnglat2Geo.entity.CoordinateSystem$;
|
||||
import scala.Enumeration.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dengxq.lnglat2Geo.GeoTrans;
|
||||
import scala.collection.JavaConverters;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
String lon = "116.393353";
|
||||
String lat = "39.944625";
|
||||
getlocation(lon, lat);
|
||||
}
|
||||
|
||||
public static Admin getlocation(String lon, String lat) {
|
||||
// 将Scala枚举类型转换为Java枚举类型
|
||||
List<Value> colorValues = JavaConverters.seqAsJavaListConverter(
|
||||
CoordinateSystem$.MODULE$.values().toSeq()
|
||||
).asJava();
|
||||
|
||||
|
||||
Admin admin = GeoTrans.determineAdmin(Double.parseDouble(lon), Double.parseDouble(lat), colorValues.get(2), true);
|
||||
// System.out.println(admin.province());
|
||||
// System.out.println(admin.city());
|
||||
// System.out.println(admin.district());
|
||||
return admin;
|
||||
}
|
||||
}
|
76
src/main/java/org/example/CsvReaderx.java
Normal file
76
src/main/java/org/example/CsvReaderx.java
Normal file
@ -0,0 +1,76 @@
|
||||
package org.example;
|
||||
|
||||
import com.dengxq.lnglat2Geo.GeoTrans;
|
||||
import com.dengxq.lnglat2Geo.entity.Admin;
|
||||
import com.dengxq.lnglat2Geo.entity.CoordinateSystem$;
|
||||
import scala.Enumeration;
|
||||
import scala.collection.JavaConverters;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CsvReaderx {
|
||||
public static void main(String[] args) {
|
||||
// 将Scala枚举类型转换为Java枚举类型
|
||||
List<Enumeration.Value> colorValues = JavaConverters.seqAsJavaListConverter(
|
||||
CoordinateSystem$.MODULE$.values().toSeq()
|
||||
).asJava();
|
||||
|
||||
String csvFile = "E:\\javacode\\lll\\src\\main\\java\\org\\example\\Animaliax1.csv";
|
||||
String csvFileto = "E:\\javacode\\lll\\src\\main\\java\\org\\example\\Animalia1.csv";
|
||||
String line = "";
|
||||
String csvDelimiter = ","; //csv分隔符,根据实际情况修改
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
|
||||
List<String[]> csvData = new ArrayList<>();
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] csvLine = line.split(csvDelimiter);
|
||||
csvData.add(csvLine);
|
||||
}
|
||||
|
||||
try (FileWriter writer = new FileWriter(csvFileto)) {
|
||||
// 打印读取到的数据
|
||||
for (String[] row : csvData) {
|
||||
// System.out.println(row[0]);
|
||||
List<String> row1 = new ArrayList<String>();
|
||||
for (String col : row) {
|
||||
row1.add(col);
|
||||
}
|
||||
System.out.println("计算");
|
||||
try {
|
||||
System.out.println(Double.parseDouble(row[1]));
|
||||
System.out.println(Double.parseDouble(row[0]));
|
||||
System.out.println(colorValues.get(2));
|
||||
|
||||
Admin admin = App.getlocation(row[1], row[0]);
|
||||
row1.add(admin.province());
|
||||
row1.add(admin.city());
|
||||
row1.add(admin.district());
|
||||
writeRow(writer, row1, csvDelimiter);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
row1.add("");
|
||||
row1.add("");
|
||||
row1.add("");
|
||||
writeRow(writer, row1, csvDelimiter);
|
||||
System.out.println("经纬度为空");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeRow(FileWriter writer, List<String> row, String delimiter) throws IOException {
|
||||
String csvRow = String.join(delimiter, row);
|
||||
writer.write(csvRow + System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
38
src/test/java/org/example/AppTest.java
Normal file
38
src/test/java/org/example/AppTest.java
Normal file
@ -0,0 +1,38 @@
|
||||
package org.example;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user