Skip to content

Commit

Permalink
Implement setRadius (#55)
Browse files Browse the repository at this point in the history
A projection may have a radius. This commit implements setRadius used in for example Equidistant Cylindrical where:
+R=<value> Radius of the sphere given in meters. As per documentation this function is applied on the end, so it takes precedence over +ellps.

Signed-off-by: Stefan de Konink <stefan@konink.de>
  • Loading branch information
skinkie authored and pomadchin committed Dec 14, 2019
1 parent 5ba8168 commit 96a1fab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static synchronized Set supportedParameters() {
supportedParams.add(ellps);
supportedParams.add(h);

supportedParams.add(R);
supportedParams.add(R_A);

supportedParams.add(k);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/locationtech/proj4j/parser/Proj4Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ private Projection parseProjection(Map params, Ellipsoid ellipsoid) {
if (s != null)
projection.setAxisOrder(s);

/* Radius of the sphere given in meters. If used in conjuction with +ellps +R takes precedence. */
s = (String) params.get(Proj4Keyword.R);
if (s != null)
projection.setRadius(Double.parseDouble(s));

//TODO: implement some of these parameters ?

// this must be done last, since behaviour depends on other params being set (eg +south)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/locationtech/proj4j/proj/Projection.java
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ public Ellipsoid getEllipsoid() {
return ellipsoid;
}

public void setRadius(double radius) {
a = radius;
}

/**
* Returns the ESPG code for this projection, or 0 if unknown.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ public void testPROJ4_LargeDiscrepancy() {
checkTransformFromGeo("EPSG:29100", -53.0, 5.0, 5110899.06, 10552971.67, 4000);
}

@Test
public void testRadius() {
checkTransformToWGS84("+title=long/lat:WGS84 +proj=eqc +R=57295779.5130823209", 1000000.0, 1000000.0, 1.0, 1.0, 0.01);
}

@Ignore("TODO: Should these expect UnknownAuthoriyCode exceptions?") @Test
public void XtestUndefined() {
//runInverseTransform("EPSG:27492", 25260.493584, -9579.245052, -7.84, 39.58);
Expand Down

0 comments on commit 96a1fab

Please sign in to comment.