use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class GetCoverageType method getCRS.
/**
* {@inheritDoc}
*/
@Override
public CoordinateReferenceSystem getCRS() throws FactoryException {
if (domainSubset == null || domainSubset.getBoundingBox() == null) {
return null;
}
final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue();
final CoordinateReferenceSystem objCrs = AbstractCRS.castOrCopy(CRS.forCode(boundingBox.getCrs())).forConvention(AxesConvention.RIGHT_HANDED);
/*
* If the bounding box contains at least 3 dimensions and the CRS specified is just
* a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step.
* Otherwise the CRS decoded is already fine, and we just return it.
*/
if (boundingBox.getUpperCorner().size() > 2 && objCrs.getCoordinateSystem().getDimension() < 3) {
final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
return new GeodeticObjectBuilder().addName(objCrs.getName().getCode() + " (3D)").createCompoundCRS(objCrs, verticalCRS);
} else {
return objCrs;
}
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class GetCoverageType method getEnvelope.
/**
* {@inheritDoc}
*/
@Override
public Envelope getEnvelope() throws FactoryException {
if (domainSubset == null || domainSubset.getBoundingBox() == null) {
return null;
}
final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue();
final List<Double> lowerCorner = boundingBox.getLowerCorner();
final List<Double> upperCorner = boundingBox.getUpperCorner();
final CoordinateReferenceSystem crs = getCRS();
final GeneralEnvelope objEnv = new GeneralEnvelope(crs);
objEnv.setRange(0, lowerCorner.get(0), upperCorner.get(0));
objEnv.setRange(1, lowerCorner.get(1), upperCorner.get(1));
// If the CRS has a vertical part, then the envelope to return should be a 3D one.
if (CRS.getVerticalComponent(crs, true) != null) {
objEnv.setRange(2, lowerCorner.get(2), upperCorner.get(2));
}
return objEnv;
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method briefRecordMarshalingTest.
/**
* Test brief Record Marshalling.
*/
@Test
public void briefRecordMarshalingTest() throws JAXBException {
Marshaller marshaller = pool.acquireMarshaller();
/*
* Test marshalling BRIEF csw Record v2.0.2
*/
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
BriefRecordType record = new BriefRecordType(id, title, type, bbox);
StringWriter sw = new StringWriter();
marshaller.marshal(record, sw);
String result = sw.toString();
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
assertXmlEquals(expResult, result, "xmlns:*");
/*
* Test marshalling csw Record v2.0.2
*/
List<SimpleLiteral> identifiers = new ArrayList<>();
identifiers.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
identifiers.add(new SimpleLiteral("urn:ogc:x-def:F7807C8AB645"));
List<SimpleLiteral> titles = new ArrayList<>();
titles.add(new SimpleLiteral("(JASON-1)"));
titles.add(new SimpleLiteral("(JASON-2)"));
type = new SimpleLiteral("clearinghouse");
bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
bbox.add(new WGS84BoundingBoxType(176, -16.4, -178, 6.1));
record = new BriefRecordType(identifiers, titles, type, bbox);
sw = new StringWriter();
marshaller.marshal(record, sw);
result = sw.toString();
expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:identifier>urn:ogc:x-def:F7807C8AB645</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:title>(JASON-2)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>176.0 -16.4</ows:LowerCorner>\n" + " <ows:UpperCorner>-178.0 6.1</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method transactionResponseMarshalingTest.
@Test
public void transactionResponseMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
Marshaller marshaller = pool.acquireMarshaller();
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
Object record = new BriefRecordType(id, title, type, bbox);
final List<InsertResultType> inserteds = new ArrayList<>();
inserteds.add(new InsertResultType(Arrays.asList(record), null));
TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
TransactionResponseType request = new TransactionResponseType(summ, inserteds, "2.0.2");
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + " <csw:TransactionSummary requestId=\"rid\">\n" + " <csw:totalInserted>2</csw:totalInserted>\n" + " <csw:totalUpdated>0</csw:totalUpdated>\n" + " <csw:totalDeleted>1</csw:totalDeleted>\n" + " </csw:TransactionSummary>\n" + " <csw:InsertResult>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
StringWriter sw = new StringWriter();
marshaller.marshal(request, sw);
String result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method getRecordsResponseUnMarshalingTest.
/**
* Test getRecordById request Marshalling.
*/
@Test
public void getRecordsResponseUnMarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test marshalling csw getRecordByIdResponse v2.0.2
*/
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<SimpleLiteral> subject = new ArrayList<>();
subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
subject.add(new SimpleLiteral("oceans elevation 2"));
SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
List<Object> records = new ArrayList<>();
records.add(record);
records.add(briefRecord);
records.add(sumRecord);
final SearchResultsType sr = new SearchResultsType("set", ElementSetType.BRIEF, 1, records, 1, 0);
GetRecordsResponse expResult = new GetRecordsResponseType("rid", 100000, "v1.2", sr);
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordsResponse version=\"v1.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + " <csw:RequestId>rid</csw:RequestId>\n" + " <csw:SearchStatus timestamp=\"1970-01-01T01:01:40.000+01:00\"/>\n" + " <csw:SearchResults resultSetId=\"set\" elementSet=\"brief\" numberOfRecordsMatched=\"1\" numberOfRecordsReturned=\"1\" nextRecord=\"0\">\n" + " <csw:Record>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + " <dc:subject>oceans elevation 2</dc:subject>\n" + " <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + " <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + " <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + " <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:Record>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " <csw:SummaryRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + " <dc:subject>oceans elevation 2</dc:subject>\n" + " <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + " <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:SummaryRecord>\n" + " </csw:SearchResults>\n" + "</csw:GetRecordsResponse>\n";
GetRecordsResponse result = ((JAXBElement<GetRecordsResponse>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
assertTrue(result.getSearchResults().getAny() instanceof List);
List<Object> resultList = result.getSearchResults().getAny();
List<Object> expResultList = expResult.getSearchResults().getAny();
assertEquals(expResultList.get(0), resultList.get(0));
assertEquals(expResultList.get(1), resultList.get(1));
assertEquals(expResultList.get(2), resultList.get(2));
assertEquals(expResultList, resultList);
assertEquals(expResult.getSearchResults().getAny(), result.getSearchResults().getAny());
assertEquals(expResult.getSearchStatus(), result.getSearchStatus());
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
Aggregations