use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method summmaryRecordUnmarshalingTest.
/**
* Test summary Record Marshalling.
*/
@Test
public void summmaryRecordUnmarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test marshalling csw summmary Record v2.0.2
*/
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord 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" + " <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" + " <dc:format>format 11-11</dc:format>\n" + " <dc:format>format 22-22</dc:format>\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";
StringReader sr = new StringReader(xml);
SummaryRecordType result = (SummaryRecordType) unmarshaller.unmarshal(sr);
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"));
List<SimpleLiteral> formats = new ArrayList<>();
formats.add(new SimpleLiteral("format 11-11"));
formats.add(new SimpleLiteral("format 22-22"));
SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
List<SimpleLiteral> Abstract = new ArrayList<>();
Abstract.add(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."));
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
SummaryRecordType expResult = new SummaryRecordType(id, title, type, bbox, subject, formats, modified, Abstract);
assertEquals(expResult, result);
/*
* Test marshalling csw summmary Record v2.0.2
*/
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord 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" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:identifier>urn:ogc-x:df:F7807C8AB645</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:title>(JASON-2)</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" + " <dc:format>format 11-11</dc:format>\n" + " <dc:format>format 22-22</dc:format>\n" + " <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + " <dct:modified>2007-11-15 21:26:48</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:abstract>Jason-2 blablablablabla.</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" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>100.0 -6.04</ows:LowerCorner>\n" + " <ows:UpperCorner>-144.0 5.9</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + "</csw:SummaryRecord>\n";
sr = new StringReader(xml);
result = (SummaryRecordType) unmarshaller.unmarshal(sr);
List<SimpleLiteral> ids = new ArrayList<>();
ids.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
ids.add(new SimpleLiteral("urn:ogc-x:df:F7807C8AB645"));
List<SimpleLiteral> titles = new ArrayList<>();
titles.add(new SimpleLiteral("(JASON-1)"));
titles.add(new SimpleLiteral("(JASON-2)"));
type = new SimpleLiteral("clearinghouse");
subject = new ArrayList<>();
subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
subject.add(new SimpleLiteral("oceans elevation 2"));
formats = new ArrayList<>();
formats.add(new SimpleLiteral("format 11-11"));
formats.add(new SimpleLiteral("format 22-22"));
List<SimpleLiteral> modifieds = new ArrayList<>();
modifieds.add(new SimpleLiteral("2007-11-15 21:26:49"));
modifieds.add(new SimpleLiteral("2007-11-15 21:26:48"));
Abstract = new ArrayList<>();
Abstract.add(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."));
Abstract.add(new SimpleLiteral("Jason-2 blablablablabla."));
bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
bbox.add(new WGS84BoundingBoxType(100, -6.04, -144, 5.9));
expResult = new SummaryRecordType(ids, titles, type, bbox, subject, formats, modifieds, Abstract);
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class GetCoverageType method getResponseCRS.
/**
* {@inheritDoc}
*/
@Override
public CoordinateReferenceSystem getResponseCRS() throws FactoryException {
if (output == null || output.getGridCRS() == null || output.getGridCRS().getSrsName() == null || output.getGridCRS().getSrsName().getValue() == null) {
return null;
}
final CoordinateReferenceSystem objCrs = CRS.forCode(output.getGridCRS().getSrsName().getValue());
final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue();
/*
* 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.getDimensions().intValue() > 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 BboxAdaptorTest method supportedCrsWPS2.
@Test
public void supportedCrsWPS2() throws FactoryException {
final BoundingBoxData bboxDataType = new BoundingBoxData();
final SupportedCRS scrs = new SupportedCRS("ESPG:4326");
bboxDataType.getSupportedCRS().add(scrs);
final BboxAdaptor adaptor = BboxAdaptor.create(bboxDataType);
assertEquals(Envelope.class, adaptor.getValueClass());
final BoundingBoxType litValue = new BoundingBoxType("EPSG:4326", -180, -90, +180, +90);
final DataOutput output = new DataOutput();
final Data data = new Data(litValue);
output.setData(data);
final Envelope result = adaptor.fromWPS2Input(output);
final GeneralEnvelope env = new GeneralEnvelope(CRS.forCode("EPSG:4326"));
env.setRange(0, -180, +180);
env.setRange(1, -90, +90);
assertEquals(env, new GeneralEnvelope(result));
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project geotoolkit by Geomatys.
the class BboxAdaptor method toWPS2Input.
@Override
public DataInput toWPS2Input(Envelope candidate) {
// change envelope crs if not supported
if (!crss.contains(candidate.getCoordinateReferenceSystem())) {
try {
candidate = Envelopes.transform(candidate, crss.get(0));
} catch (TransformException ex) {
throw new UnconvertibleObjectException(ex.getMessage(), ex);
}
}
final BoundingBoxType litValue = new BoundingBoxType(candidate);
final Data data = new Data();
data.getContent().add(litValue);
final DataInput dit = new DataInput();
dit.setData(data);
return dit;
}
use of org.geotoolkit.ows.xml.v200.BoundingBoxType in project ddf by codice.
the class CswEndpoint method getInsertResultFromResponse.
private InsertResultType getInsertResultFromResponse(CreateResponse createResponse) throws CswException {
InsertResultType result = new InsertResultType();
WKTReader reader = new WKTReader();
for (Metacard metacard : createResponse.getCreatedMetacards()) {
BoundingBoxType boundingBox = new BoundingBoxType();
Geometry geometry = null;
String bbox = null;
try {
if (metacard.getAttribute(CswConstants.BBOX_PROP) != null) {
bbox = metacard.getAttribute(CswConstants.BBOX_PROP).getValue().toString();
geometry = reader.read(bbox);
} else if (StringUtils.isNotBlank(metacard.getLocation())) {
bbox = metacard.getLocation();
geometry = reader.read(bbox);
}
} catch (ParseException e) {
LOGGER.debug("Unable to parse BoundingBox : {}", bbox, e);
}
BriefRecordType briefRecordType = new BriefRecordType();
if (geometry != null) {
Envelope bounds = geometry.getEnvelopeInternal();
if (bounds != null) {
boundingBox.setCrs(CswConstants.SRS_NAME);
boundingBox.setLowerCorner(Arrays.asList(bounds.getMinX(), bounds.getMinY()));
boundingBox.setUpperCorner(Arrays.asList(bounds.getMaxX(), bounds.getMaxY()));
briefRecordType.getBoundingBox().add(new net.opengis.ows.v_1_0_0.ObjectFactory().createBoundingBox(boundingBox));
}
}
SimpleLiteral identifier = new SimpleLiteral();
identifier.getContent().add(metacard.getId());
briefRecordType.getIdentifier().add(new JAXBElement<>(CswConstants.DC_IDENTIFIER_QNAME, SimpleLiteral.class, identifier));
SimpleLiteral title = new SimpleLiteral();
title.getContent().add(metacard.getTitle());
briefRecordType.getTitle().add(new JAXBElement<>(CswConstants.DC_TITLE_QNAME, SimpleLiteral.class, title));
SimpleLiteral type = new SimpleLiteral();
type.getContent().add(metacard.getContentTypeName());
briefRecordType.setType(type);
result.getBriefRecord().add(briefRecordType);
}
return result;
}
Aggregations