Skip to content

Commit 104f198

Browse files
committed
readme proj example and test
1 parent ed96b44 commit 104f198

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ case OPERATION:
115115

116116
```
117117

118+
#### PROJ ####
119+
120+
```java
121+
122+
// String wkt = ...
123+
124+
CRS crs = CRSReader.read(wkt);
125+
126+
ProjParams projParamsFromCRS = ProjParser.params(crs);
127+
String projTextFromCRS = ProjParser.paramsText(crs);
128+
ProjParams projParamsFromWKT = ProjParser.params(wkt);
129+
String projTextFromWKT = ProjParser.paramsText(wkt);
130+
131+
```
132+
118133
### Installation ###
119134

120135
Pull from the [Maven Central Repository](http://search.maven.org/#artifactdetails|mil.nga|crs|1.0.0|jar) (JAR, POM, Source, Javadoc)

src/test/java/mil/nga/crs/ReadmeTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import mil.nga.crs.parametric.ParametricCoordinateReferenceSystem;
1919
import mil.nga.crs.projected.ProjectedCoordinateReferenceSystem;
2020
import mil.nga.crs.temporal.TemporalCoordinateReferenceSystem;
21+
import mil.nga.crs.util.proj.ProjParams;
22+
import mil.nga.crs.util.proj.ProjParser;
2123
import mil.nga.crs.vertical.VerticalCoordinateReferenceSystem;
2224
import mil.nga.crs.wkt.CRSReader;
2325
import mil.nga.crs.wkt.CRSWriter;
@@ -51,8 +53,11 @@ public void testCRS() throws IOException {
5153
+ "AXIS[\"Geodetic latitude (Lat)\",north],AXIS[\"Geodetic longitude (Lon)\",east],"
5254
+ "ANGLEUNIT[\"degree\",0.0174532925199433,ID[\"EPSG\",9102]],"
5355
+ "ID[\"EPSG\",4326]]";
56+
5457
assertEquals(wkt, testCRS(wkt));
5558

59+
assertEquals("+proj=longlat +datum=WGS84 +no_defs", testProj(wkt));
60+
5661
}
5762

5863
/**
@@ -161,4 +166,27 @@ private String testCRS(String wkt) throws IOException {
161166
return text;
162167
}
163168

169+
/**
170+
* Test proj
171+
*
172+
* @param wkt
173+
* crs well-known text
174+
* @return PROJ text
175+
* @throws IOException
176+
* upon failure
177+
*/
178+
private String testProj(String wkt) throws IOException {
179+
180+
// String wkt = ...
181+
182+
CRS crs = CRSReader.read(wkt);
183+
184+
ProjParams projParamsFromCRS = ProjParser.params(crs);
185+
String projTextFromCRS = ProjParser.paramsText(crs);
186+
ProjParams projParamsFromWKT = ProjParser.params(wkt);
187+
String projTextFromWKT = ProjParser.paramsText(wkt);
188+
189+
return projTextFromWKT;
190+
}
191+
164192
}

0 commit comments

Comments
 (0)