This commit is contained in:
Looly
2021-11-02 01:17:48 +08:00
parent cffb294bfe
commit 88edbafe4b
3 changed files with 49 additions and 41 deletions

View File

@@ -0,0 +1,47 @@
package cn.hutool.core.util;
import org.junit.Assert;
import org.junit.Test;
/**
* 坐标转换工具类单元测试<br>
* 测试参考https://github.com/wandergis/coordtransform
*
* @author hongzhe.qin, looly
*/
public class CoordinateUtilTest {
@Test
public void gcj02ToBd09Test() {
final CoordinateUtil.Coordinate gcj02 = CoordinateUtil.gcj02ToBd09(116.404, 39.915);
Assert.assertEquals(116.41036949371029D, gcj02.getLng(), 15);
Assert.assertEquals(39.92133699351021D, gcj02.getLat(), 15);
}
@Test
public void bd09toGcj02Test(){
final CoordinateUtil.Coordinate gcj02 = CoordinateUtil.bd09ToGcj02(116.404, 39.915);
Assert.assertEquals(116.39762729119315D, gcj02.getLng(), 15);
Assert.assertEquals(39.90865673957631D, gcj02.getLat(), 15);
}
@Test
public void gcj02ToWgs84(){
final CoordinateUtil.Coordinate gcj02 = CoordinateUtil.wgs84ToGcj02(116.404, 39.915);
Assert.assertEquals(116.39775550083061D, gcj02.getLng(), 15);
Assert.assertEquals(39.91359571849836D, gcj02.getLat(), 15);
}
@Test
public void wgs84ToGcj02Test(){
final CoordinateUtil.Coordinate gcj02 = CoordinateUtil.wgs84ToGcj02(116.404, 39.915);
Assert.assertEquals(116.41024449916938D, gcj02.getLng(), 15);
Assert.assertEquals(39.91640428150164D, gcj02.getLat(), 15);
}
@Test
public void wgs84toBd09(){
}
}

View File

@@ -1,39 +0,0 @@
package cn.hutool.core.util;
import org.junit.Test;
/**
* 坐标转换工具类单元测试
*
* ps: 坐标转换存在一定误差,故此工具类无单元测试,无法验证,请根据实际业务判断误差值
*
* @author hongzhe.qin
*/
public class W84UtilTest {
@Test
public void gcj02tobd09Test() {
}
@Test
public void bd09togcj02(){
}
@Test
public void gcj02towgs84(){
}
@Test
public void wgs84togcj02(){
}
@Test
public void wgs84tobd09(){
}
}