Skip to content

Commit

Permalink
Fixed collectionsCRS84 test - It's working!
Browse files Browse the repository at this point in the history
Using Apache SIS for reading WKT CRS strings
  • Loading branch information
ghobona committed Mar 18, 2021
1 parent 68ad289 commit 9db8e7c
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 80 deletions.
9 changes: 8 additions & 1 deletion docker/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Try out the EDR API ETS with these combinations of inputs.

Location of the landing page : https://ogcie.iblsoft.com/edr

Location of OpenAPI definition document : https://opengeospatial.github.io/ogcapi-environmental-data-retrieval/candidate-standard/openapi/EDR_OpenAPI.json
Location of OpenAPI definition document : https://ogcie.iblsoft.com/edr/api

Conformance class: Level 1 (Note this input is ignored)

Expand All @@ -25,4 +25,11 @@ Location of the landing page : https://data-api.mdl.nws.noaa.gov/EDR-API

Location of OpenAPI definition document : https://data-api.mdl.nws.noaa.gov/EDR-API/api?f=json


Alternatively, try it out with:

Location of the landing page : http://labs.metoffice.gov.uk/edr

Location of OpenAPI definition document : http://labs.metoffice.gov.uk/edr/openapi.json

Conformance class: Level 1 (Note this input is ignored)
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<label for="apiDefinition">
<h4 style="margin-bottom: 0.5em">Location of OpenAPI definition document</h4>
</label>
<input id="apiDefinition" name="apiDefinition" size="128" type="text" value="https://opengeospatial.github.io/ogcapi-environmental-data-retrieval/candidate-standard/openapi/EDR_OpenAPI.json" />
<input id="apiDefinition" name="apiDefinition" size="128" type="text" value="https://ogcie.iblsoft.com/edr/api" />
</p>
<p>
<label for="level">Conformance class: </label>
Expand Down
Binary file added docker/teamengine/WEB-INF/lib/apache-sis_old.zip
Binary file not shown.
Binary file modified docker/teamengine/WEB-INF/lib/ets-ogcapi-edr10-0.1-SNAPSHOT.jar
Binary file not shown.
Binary file added docker/teamengine/WEB-INF/lib/geoapi-3.0.1.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docker/teamengine/WEB-INF/lib/unit-api-1.0.jar
Binary file not shown.
19 changes: 18 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,25 @@
<artifactId>sis-referencing</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.sis.core/sis-utility -->
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.opengis/geoapi -->
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi</artifactId>
<version>3.0.1</version>
</dependency>



</dependencies>

<build>
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/org/opengis/cite/ogcapiedr10/CommonFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import org.apache.sis.referencing.CRS;
import org.opengis.cite.ogcapiedr10.util.ClientUtils;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.opengis.util.FactoryException;
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
Expand Down Expand Up @@ -48,19 +47,7 @@ public void initCommonFixture( ITestContext testContext ) {
initLogging();
rootUri = (URI) testContext.getSuite().getAttribute( SuiteAttribute.IUT.getName() );

CoordinateReferenceSystem source = null;

try {


source = CRS.fromWKT("GEOGCS[\"Unknown\", DATUM[\"Unknown\", SPHEROID[\"WGS_1984\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\",0], UNIT[\"degree\", 0.017453], AXIS[\"Lon\", EAST], AXIS[\"Lat\", NORTH]]");
} catch (NoSuchAuthorityCodeException e) {
System.out.println("CHK ERROR 1");
e.printStackTrace();
} catch (FactoryException e) {
System.out.println("CHK ERROR 2");
e.printStackTrace();
}



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@

import io.restassured.response.Response;
import io.restassured.path.json.JsonPath;

/**
* /collections/{collectionId}/
*
*/
public class CollectionsCRS extends CommonFixture {
public class CollectionsCRS extends CommonFixture {

/**
* <pre>
Expand All @@ -63,69 +64,57 @@ public class CollectionsCRS extends CommonFixture {
@Test(description = "Implements Abstract Test 8 Requirement 33 /req/core/crs84")
public void collectionsCRS84() {

boolean compliesWithCRS84Requirement = false;
StringBuffer resultMessage = new StringBuffer();

TestPoint testPoint = new TestPoint(rootUri.toString(),"/collections",null);
String testPointUri = new UriBuilder( testPoint ).buildUrl();
Response response = init().baseUri( testPointUri ).accept( JSON ).when().request( GET );
JsonPath jsonPath = response.jsonPath();

List<Object> collectionsList = jsonPath.getList( "collections" );

for(int t = 0 ; t < collectionsList.size(); t++)
{
boolean supportsCRS84 = false;
HashMap collectionMap = (HashMap) collectionsList.get(t);

String crsText = collectionMap.get("crs").toString();
ArrayList crsList = (ArrayList) collectionMap.get("crs");
HashMap crsMap = (HashMap) crsList.get(0);

CoordinateReferenceSystem source = null;

try {


source = CRS.fromWKT(crsMap.get("wkt").toString());
} catch (NoSuchAuthorityCodeException e) {

e.printStackTrace();
} catch (FactoryException e) {

e.printStackTrace();
boolean compliesWithCRS84Requirement = true;
StringBuffer resultMessage = new StringBuffer();

TestPoint testPoint = new TestPoint(rootUri.toString(), "/collections", null);
String testPointUri = new UriBuilder(testPoint).buildUrl();
Response response = init().baseUri(testPointUri).accept(JSON).when().request(GET);
JsonPath jsonPath = response.jsonPath();

List<Object> collectionsList = jsonPath.getList("collections");

for (int t = 0; t < collectionsList.size(); t++) {
boolean supportsCRS84 = false;
HashMap collectionMap = (HashMap) collectionsList.get(t);

String crsText = collectionMap.get("crs").toString();
ArrayList crsList = (ArrayList) collectionMap.get("crs");
HashMap crsMap = (HashMap) crsList.get(0);

CoordinateReferenceSystem source = null;

try {

source = CRS.fromWKT(crsMap.get("wkt").toString());
} catch (Exception e) {

e.printStackTrace();
}

DefaultGeographicCRS crs = (DefaultGeographicCRS) source;

if (crs.getDatum().getEllipsoid().getName().toString().equals("WGS 84")
|| crs.getDatum().getEllipsoid().getName().toString().equals("WGS_1984")
|| crs.getDatum().getEllipsoid().getName().toString().equals("WGS84")) {

if (source.getCoordinateSystem().getAxis(0).toString().toLowerCase().contains("longitude")
&& source.getCoordinateSystem().getAxis(1).toString().toLowerCase().contains("latitude")) {

supportsCRS84 = true;

}


DefaultGeographicCRS crs = (DefaultGeographicCRS) source;

if(crs.getDatum().getEllipsoid().getName().toString().equals("WGS 84") || crs.getDatum().getEllipsoid().getName().toString().equals("WGS_1984") || crs.getDatum().getEllipsoid().getName().toString().equals("WGS84")) {

if(source.getCoordinateSystem().getAxis(0).toString().toLowerCase().contains("longitude") && source.getCoordinateSystem().getAxis(1).toString().toLowerCase().contains("latitude")) {

supportsCRS84 = true;

}
}
if(supportsCRS84==false) {
compliesWithCRS84Requirement = false;
resultMessage.append("Collection "+collectionMap.get("id").toString()+" fails. ");
}





}


org.testng.Assert.assertTrue( compliesWithCRS84Requirement, "Fails Abstract Test 8 because "+resultMessage.toString() );
}
if (supportsCRS84 == false) {
compliesWithCRS84Requirement = false;
resultMessage.append("Collection " + collectionMap.get("id").toString() + " fails. ");
}

}

}
org.testng.Assert.assertTrue(compliesWithCRS84Requirement,
"Fails Abstract Test 8 because " + resultMessage.toString());

}




}
2 changes: 1 addition & 1 deletion src/main/scripts/ctl/ogcapi-edr10-suite.ctl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<label for="apiDefinition">
<h4 style="margin-bottom: 0.5em">Location of OpenAPI definition document</h4>
</label>
<input id="apiDefinition" name="apiDefinition" size="128" type="text" value="https://opengeospatial.github.io/ogcapi-environmental-data-retrieval/candidate-standard/openapi/EDR_OpenAPI.json" />
<input id="apiDefinition" name="apiDefinition" size="128" type="text" value="https://ogcie.iblsoft.com/edr/api" />
</p>
<p>
<label for="level">Conformance class: </label>
Expand Down

0 comments on commit 9db8e7c

Please sign in to comment.