Skip to content

Commit

Permalink
Fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
yageek committed Oct 14, 2013
1 parent 30a7751 commit b84b552
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.gradle
*.iml
build
gradle.properties
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = 'net.yageek.lambert'
version = '0.1'
version = '1.1'

buildscript {
repositories {
Expand Down Expand Up @@ -66,7 +66,7 @@ publishing {

bintray {
user = user_name
key = apikey
key = api_key
publications = ['mavenJava'] // When uploading Maven-based publication files
pkg {
repo = 'maven'
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/net/yageek/lambert/Lambert.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,20 @@ private static LambertPoint cartesianToGeographic(LambertPoint org, double merid

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

LambertPoint pt1 = lambertToGeographic(org, zone, LON_MERID_PARIS, E_CLARK_IGN, DEFAULT_EPS);

LambertPoint pt2 = geographicToCartesian(pt1.getX(), pt1.getY(), pt1.getZ(), A_CLARK_IGN, E_CLARK_IGN);

pt2.translate(-168,-60,320);
if(zone == Lambert93)
{
return lambertToGeographic(org,Lambert93,LON_MERID_IERS,E_WGS84,DEFAULT_EPS);
}
else {
LambertPoint pt1 = lambertToGeographic(org, zone, LON_MERID_PARIS, E_CLARK_IGN, DEFAULT_EPS);

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

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

//WGS84 refers to greenwich
return cartesianToGeographic(pt2, LON_MERID_GREENWICH, A_WGS84, E_WGS84, DEFAULT_EPS);
}
}

public static LambertPoint convertToWGS84(double x, double y, LambertZone zone){
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/yageek/lambert/LambertZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum LambertZone{
private final static double[] LAMBERT_XS = {600000.0, 600000.0, 600000.0, 234.358, 600000.0, 700000.0};
private final static double[] LAMBERT_YS = {5657616.674, 6199695.768, 6791905.085, 7239161.542, 8199695.768, 12655612.050};

public final static double M_PI_2 = 1.57079632679489661923;
public final static double M_PI_2 = Math.PI/2.0;
public final static double DEFAULT_EPS = 1e-10 ;
public final static double E_CLARK_IGN = 0.08248325676 ;
public final static double E_WGS84 = 0.08181919106 ;
Expand All @@ -20,6 +20,7 @@ public enum LambertZone{
public final static double A_WGS84 = 6378137.0 ;
public final static double LON_MERID_PARIS = 0 ;
public final static double LON_MERID_GREENWICH =0.04079234433 ;
public final static double LON_MERID_IERS = 3.0*Math.PI/180.0;



Expand Down
27 changes: 27 additions & 0 deletions src/test/java/net/yageek/lambert/LambertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

@RunWith(JUnit4.class)
public class LambertTest {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

@Before
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
}

@After

public void cleanUpStreams() {
System.setOut(null);
System.setErr(null);
}
@Test
public void ResultTest(){
LambertPoint pt = Lambert.convertToWGS84Deg(994272.661, 113467.422, LambertZone.LambertI);
Expand All @@ -17,5 +37,12 @@ public void ResultTest(){

}

@Test
public void Lamber93BugTest(){
LambertPoint pt = Lambert.convertToWGS84Deg(668832.5384, 6950138.7285,LambertZone.Lambert93);
assertEquals(2.56865,pt.getX(),0.0001);
assertEquals(49.64961,pt.getY(),0.0001);
}


}

0 comments on commit b84b552

Please sign in to comment.