Skip to content

Commit b84b552

Browse files
committed
Fix #2
1 parent 30a7751 commit b84b552

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.gradle
33
*.iml
44
build
5+
gradle.properties

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = 'net.yageek.lambert'
2-
version = '0.1'
2+
version = '1.1'
33

44
buildscript {
55
repositories {
@@ -66,7 +66,7 @@ publishing {
6666

6767
bintray {
6868
user = user_name
69-
key = apikey
69+
key = api_key
7070
publications = ['mavenJava'] // When uploading Maven-based publication files
7171
pkg {
7272
repo = 'maven'

src/main/java/net/yageek/lambert/Lambert.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,20 @@ private static LambertPoint cartesianToGeographic(LambertPoint org, double merid
125125

126126
public static LambertPoint convertToWGS84(LambertPoint org, LambertZone zone){
127127

128-
LambertPoint pt1 = lambertToGeographic(org, zone, LON_MERID_PARIS, E_CLARK_IGN, DEFAULT_EPS);
129-
130-
LambertPoint pt2 = geographicToCartesian(pt1.getX(), pt1.getY(), pt1.getZ(), A_CLARK_IGN, E_CLARK_IGN);
131-
132-
pt2.translate(-168,-60,320);
128+
if(zone == Lambert93)
129+
{
130+
return lambertToGeographic(org,Lambert93,LON_MERID_IERS,E_WGS84,DEFAULT_EPS);
131+
}
132+
else {
133+
LambertPoint pt1 = lambertToGeographic(org, zone, LON_MERID_PARIS, E_CLARK_IGN, DEFAULT_EPS);
133134

134-
//WGS84 refers to greenwich
135-
pt2 = cartesianToGeographic(pt2, LON_MERID_GREENWICH, A_WGS84, E_WGS84, DEFAULT_EPS);
135+
LambertPoint pt2 = geographicToCartesian(pt1.getX(), pt1.getY(), pt1.getZ(), A_CLARK_IGN, E_CLARK_IGN);
136136

137-
return pt2;
137+
pt2.translate(-168,-60,320);
138138

139+
//WGS84 refers to greenwich
140+
return cartesianToGeographic(pt2, LON_MERID_GREENWICH, A_WGS84, E_WGS84, DEFAULT_EPS);
141+
}
139142
}
140143

141144
public static LambertPoint convertToWGS84(double x, double y, LambertZone zone){

src/main/java/net/yageek/lambert/LambertZone.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum LambertZone{
1111
private final static double[] LAMBERT_XS = {600000.0, 600000.0, 600000.0, 234.358, 600000.0, 700000.0};
1212
private final static double[] LAMBERT_YS = {5657616.674, 6199695.768, 6791905.085, 7239161.542, 8199695.768, 12655612.050};
1313

14-
public final static double M_PI_2 = 1.57079632679489661923;
14+
public final static double M_PI_2 = Math.PI/2.0;
1515
public final static double DEFAULT_EPS = 1e-10 ;
1616
public final static double E_CLARK_IGN = 0.08248325676 ;
1717
public final static double E_WGS84 = 0.08181919106 ;
@@ -20,6 +20,7 @@ public enum LambertZone{
2020
public final static double A_WGS84 = 6378137.0 ;
2121
public final static double LON_MERID_PARIS = 0 ;
2222
public final static double LON_MERID_GREENWICH =0.04079234433 ;
23+
public final static double LON_MERID_IERS = 3.0*Math.PI/180.0;
2324

2425

2526

src/test/java/net/yageek/lambert/LambertTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,33 @@
22

33
import static org.junit.Assert.assertEquals;
44

5+
import org.junit.After;
6+
import org.junit.Assert;
7+
import org.junit.Before;
58
import org.junit.Test;
69
import org.junit.runner.RunWith;
710
import org.junit.runners.JUnit4;
811

12+
import java.io.ByteArrayOutputStream;
13+
import java.io.PrintStream;
14+
915
@RunWith(JUnit4.class)
1016
public class LambertTest {
17+
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
18+
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
19+
20+
@Before
21+
public void setUpStreams() {
22+
System.setOut(new PrintStream(outContent));
23+
System.setErr(new PrintStream(errContent));
24+
}
25+
26+
@After
1127

28+
public void cleanUpStreams() {
29+
System.setOut(null);
30+
System.setErr(null);
31+
}
1232
@Test
1333
public void ResultTest(){
1434
LambertPoint pt = Lambert.convertToWGS84Deg(994272.661, 113467.422, LambertZone.LambertI);
@@ -17,5 +37,12 @@ public void ResultTest(){
1737

1838
}
1939

40+
@Test
41+
public void Lamber93BugTest(){
42+
LambertPoint pt = Lambert.convertToWGS84Deg(668832.5384, 6950138.7285,LambertZone.Lambert93);
43+
assertEquals(2.56865,pt.getX(),0.0001);
44+
assertEquals(49.64961,pt.getY(),0.0001);
45+
}
46+
2047

2148
}

0 commit comments

Comments
 (0)