|
28 | 28 | import java.io.RandomAccessFile; |
29 | 29 | import java.net.URI; |
30 | 30 | import java.nio.CharBuffer; |
| 31 | +import java.util.List; |
31 | 32 | import java.util.Map; |
32 | 33 |
|
33 | 34 | import org.cts.CRSFactory; |
@@ -319,4 +320,35 @@ void testCompareCRS_PRJ() throws Exception { |
319 | 320 | assertNotNull(crs); |
320 | 321 | assertFalse(crs.equals(crs2)); |
321 | 322 | } |
| 323 | + |
| 324 | + @Test |
| 325 | + void testWKT2() { |
| 326 | + String prj = "PROJCRS[\"WGS 84 / UTM zone 31N\",\n" + |
| 327 | + "BASEGEOGCRS[\"WGS 84\",ENSEMBLE[\"World Geodetic System 1984 ensemble\",MEMBER[\"World Geodetic System 1984 (Transit)\"],MEMBER[\"World Geodetic System 1984 (G730)\"],MEMBER[\"World Geodetic System 1984 (G873)\"],MEMBER[\"World Geodetic System 1984 (G1150)\"],MEMBER[\"World Geodetic System 1984 (G1674)\"],MEMBER[\"World Geodetic System 1984 (G1762)\"],MEMBER[\"World Geodetic System 1984 (G2139)\"],MEMBER[\"World Geodetic System 1984 (G2296)\"],ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]],ENSEMBLEACCURACY[2.0]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],ID[\"EPSG\",4326]],\n" + |
| 328 | + "CONVERSION[\"UTM zone 31N\",METHOD[\"Transverse Mercator\",ID[\"EPSG\",9807]],PARAMETER[\"Latitude of natural origin\",0,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8801]],PARAMETER[\"Longitude of natural origin\",3,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"Scale factor at natural origin\",0.9996,SCALEUNIT[\"unity\",1],ID[\"EPSG\",8805]],PARAMETER[\"False easting\",500000,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],\n" + |
| 329 | + "CS[Cartesian,2],\n" + |
| 330 | + "AXIS[\"(E)\",east,ORDER[1],LENGTHUNIT[\"metre\",1]],\n" + |
| 331 | + "AXIS[\"(N)\",north,ORDER[2],LENGTHUNIT[\"metre\",1]],\n" + |
| 332 | + "USAGE[SCOPE[\"Navigation and medium accuracy spatial referencing.\"],AREA[\"Between 0°E and 6°E, northern hemisphere between equator and 84°N, onshore and offshore. Algeria. Andorra. Belgium. Benin. Burkina Faso. Denmark - North Sea. France. Germany - North Sea. Ghana. Luxembourg. Mali. Netherlands. Niger. Nigeria. Norway. Spain. Togo. United Kingdom (UK) - North Sea.\"],BBOX[0,0,84,6]],\n" + |
| 333 | + "ID[\"EPSG\",32631]]"; |
| 334 | + PrjElement prjElement = parser.getAsPrjElement(prj); |
| 335 | + assertInstanceOf(PrjNodeElement.class, prjElement); |
| 336 | + PrjNodeElement firstNode = (PrjNodeElement) prjElement; |
| 337 | + assertEquals("PROJCRS", firstNode.getName()); |
| 338 | + List<PrjElement> nodes = firstNode.getChildren(); |
| 339 | + PrjNodeElement id_epsg=null; |
| 340 | + for (PrjElement node : nodes) { |
| 341 | + if(node instanceof PrjNodeElement) { |
| 342 | + id_epsg = (PrjNodeElement) node; |
| 343 | + if (id_epsg.getName().equals("ID")) { |
| 344 | + break; |
| 345 | + } |
| 346 | + } |
| 347 | + } |
| 348 | + assertEquals("ID", id_epsg.getName()); |
| 349 | + List<PrjElement> epsgElement = id_epsg.getChildren(); |
| 350 | + assertEquals(2, epsgElement.size()); |
| 351 | + assertEquals("EPSG", ((PrjStringElement)epsgElement.get(0)).getValue()); |
| 352 | + assertEquals(32631, ((PrjNumberElement)epsgElement.get(1)).getValue()); |
| 353 | + } |
322 | 354 | } |
0 commit comments