use of org.geotoolkit.gml.xml.v311.TimePositionType in project ddf by codice.
the class WfsFilterDelegateTest method testAbsoluteTemporalOnlyQueryDuringSupported.
/**
* If the WFS server does not support an 'After' and 'Before' temporal query, and supports a
* 'During' temporal query, the query should be translated into 'During <after> to <before>'
*/
@Test
public void testAbsoluteTemporalOnlyQueryDuringSupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterType beforeFilter = setupBeforeFilterType();
FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
// Get After Filter Date
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getTimePosition();
Date afterDate = timePositionTypeToDate(beginPositionType);
// Get Before Filter Date
binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
TimePositionType endPositionType = timePeriod.getTimePosition();
Date beforeDate = timePositionTypeToDate(endPositionType);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
testFilters.add(beforeFilter);
List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
FilterType duringFilter = convertedFilters.get(0);
assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriodType = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
beginPositionType = timePeriodType.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
endPositionType = timePeriodType.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
assertThat(endDate.equals(beforeDate), is(true));
assertThat(beginDate.equals(afterDate), is(true));
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project arctic-sea by 52North.
the class GmlDecoderv321 method parseTimePeriod.
/**
* creates SOS representation of time period from XMLBeans representation of time period
*
* @param xbTimePeriod XMLBeans representation of time period
*
* @return Returns SOS representation of time period
*
* @throws DecodingException if the time string is invalid
*/
private Object parseTimePeriod(TimePeriodType xbTimePeriod) throws DecodingException {
// begin position
TimePositionType xbBeginTPT = xbTimePeriod.getBeginPosition();
TimeInstant begin = null;
if (xbBeginTPT != null) {
begin = parseTimePosition(xbBeginTPT);
} else {
throw new DecodingException("gml:TimePeriod must contain gml:beginPosition Element with valid ISO:8601 String!");
}
// end position
TimePositionType xbEndTPT = xbTimePeriod.getEndPosition();
TimeInstant end = null;
if (xbEndTPT != null) {
end = parseTimePosition(xbEndTPT);
} else {
throw new DecodingException("gml:TimePeriod must contain gml:endPosition Element with valid ISO:8601 String!");
}
TimePeriod timePeriod = new TimePeriod(begin, end);
timePeriod.setGmlId(xbTimePeriod.getId());
return timePeriod;
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class MeasurementType method getTemporaryTemplate.
/**
* Construit un nouveau template temporaire d'observation a partir d'un template fournit en argument.
* On y rajoute un samplingTime et un id temporaire.
*/
@Override
public MeasurementType getTemporaryTemplate(final String temporaryName, TemporalGeometricPrimitive time) {
if (time == null) {
TimePositionType begin = new TimePositionType("1900-01-01T00:00:00");
time = new TimePeriodType(begin);
}
PhenomenonType pheno = null;
if (getObservedProperty() != null) {
pheno = (PhenomenonType) getObservedProperty();
}
SamplingFeatureType foi = null;
if (getFeatureOfInterest() != null) {
foi = (SamplingFeatureType) getFeatureOfInterest();
}
final MeasureType res = (MeasureType) getResult();
res.setValue(0);
return new MeasurementType(temporaryName, getDefinition(), foi, pheno, getProcedure().getHref(), res, (AbstractTimeGeometricPrimitiveType) time);
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class SmlXMLBindingTest method ComponentMarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void ComponentMarshalingTest() throws Exception {
ComponentType compo = new ComponentType();
compo.setValidTime(new TimePeriodType(new TimePositionType("2004-06-01")));
Marshaller marshaller = SensorMLMarshallerPool.getInstance().acquireMarshaller();
StringWriter sw = new StringWriter();
final ObjectFactory factory = new ObjectFactory();
marshaller.marshal(factory.createComponent(compo), sw);
String result = sw.toString();
System.out.println("result:" + result);
}
use of org.geotoolkit.gml.xml.v311.TimePositionType in project geotoolkit by Geomatys.
the class SmlXMLBindingTest method ComponentUnmarshallMarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void ComponentUnmarshallMarshalingTest() throws Exception {
Unmarshaller unmarshaller = SensorMLMarshallerPool.getInstance().acquireUnmarshaller();
InputStream is = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/component.xml");
Object unmarshalled = unmarshaller.unmarshal(is);
if (unmarshalled instanceof JAXBElement) {
unmarshalled = ((JAXBElement) unmarshalled).getValue();
}
assertTrue(unmarshalled instanceof SensorML);
SensorML result = (SensorML) unmarshalled;
Member member = new Member();
member.setRole("urn:x-ogx:def:sensor:OGC:detector");
ComponentType component = new ComponentType();
List<JAXBElement<String>> kw = new ArrayList<JAXBElement<String>>();
kw.add(sml100Factory.createKeywordsKeywordListKeyword("piezometer"));
kw.add(sml100Factory.createKeywordsKeywordListKeyword("geosciences"));
kw.add(sml100Factory.createKeywordsKeywordListKeyword("point d'eau"));
Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-brgm:def:gcmd:keywords"), kw));
component.setKeywords(keywords);
Classifier cl1 = new Classifier("intendedApplication", new Term("eaux souterraines", URI.create("urn:x-ogc:def:classifier:OGC:application")));
CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-brgm:def:GeoPoint:bss");
Classifier cl2 = new Classifier("sensorType", new Term(cs, "Profondeur", URI.create("urn:sensor:classifier:sensorType")));
List<Classifier> cls = new ArrayList<Classifier>();
cls.add(cl1);
cls.add(cl2);
ClassifierList claList = new ClassifierList(null, cls);
Classification classification = new Classification(claList);
component.setClassification(classification);
List<Identifier> identifiers = new ArrayList<Identifier>();
cs = new CodeSpacePropertyType("urn:x-brgm:def:sensorSystem:hydras");
Identifier id1 = new Identifier("supervisorCode", new Term(cs, "00ARGLELES_2000", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
Identifier id2 = new Identifier("longName", new Term("Madofil II", URI.create("urn:x-ogc:def:identifier:OGC:longname")));
identifiers.add(id1);
identifiers.add(id2);
IdentifierList identifierList = new IdentifierList(null, identifiers);
Identification identification = new Identification(identifierList);
component.setIdentification(identification);
TimePeriodType period = new TimePeriodType(new TimePositionType("2004-06-01"));
ValidTime vTime = new ValidTime(period);
component.setValidTime(vTime);
Capabilities capabilities = new Capabilities();
TimeRange timeRange = new TimeRange(Arrays.asList("1987-04-23", "now"));
DataComponentPropertyType field = new DataComponentPropertyType("periodOfData", "urn:x-brgm:def:property:periodOfData", timeRange);
DataRecordType record = new DataRecordType("urn:x-brgm:def:property:periodOfData", Arrays.asList(field));
JAXBElement<? extends AbstractDataRecordType> jbRecord = swe100Factory.createDataRecord(record);
capabilities.setAbstractDataRecord(jbRecord);
component.setCapabilities(capabilities);
Contact contact = new Contact("urn:x-ogc:def:role:manufacturer", new ResponsibleParty("IRIS"));
component.setContact(contact);
Position position = new Position("conductivitePosition", "piezometer#piezoPosition");
component.setPosition(position);
IoComponentPropertyType io = new IoComponentPropertyType("level", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:level"));
InputList inputList = new InputList(Arrays.asList(io));
Inputs inputs = new Inputs(inputList);
component.setInputs(inputs);
IoComponentPropertyType io2 = new IoComponentPropertyType("depth", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:depth"));
OutputList outputList = new OutputList(Arrays.asList(io2));
Outputs outputs = new Outputs(outputList);
component.setOutputs(outputs);
List<DataComponentPropertyType> params = new ArrayList<DataComponentPropertyType>();
UomPropertyType uom = new UomPropertyType(null, "urn:ogc:unit:minuts");
QuantityType quantity1 = new QuantityType("urn:x-ogc:def:property:frequency", uom, 60.0);
DataComponentPropertyType p1 = new DataComponentPropertyType("frequency", "urn:x-ogc:def:property:frequency", quantity1);
params.add(p1);
UomPropertyType uom2 = new UomPropertyType("m", null);
QuantityType quantity2 = new QuantityType("urn:x-ogc:def:property:precision", uom2, 0.05);
DataComponentPropertyType p2 = new DataComponentPropertyType("precision", "urn:x-ogc:def:property:precision", quantity2);
params.add(p2);
QuantityRange quantityRange = new QuantityRange(uom2, Arrays.asList(0.0, 10.0));
DataComponentPropertyType p3 = new DataComponentPropertyType("validity", "urn:x-ogc:def:property:validity", quantityRange);
params.add(p3);
ParameterList paramList = new ParameterList(params);
Parameters parameters = new Parameters(paramList);
component.setParameters(parameters);
component.setPosition(new Position("conductivitePosition", "piezometer#piezoPosition"));
component.setName(new DefaultIdentifier("Capteur Profondeur de ARGELES"));
member.setProcess(sml100Factory.createComponent(component));
SensorML expectedResult = new SensorML("1.0", Arrays.asList(member));
assertEquals(result.getMember().size(), 1);
assertTrue(result.getMember().get(0).getProcess() != null);
assertTrue(result.getMember().get(0).getProcess().getValue() instanceof ComponentType);
ComponentType resultProcess = (ComponentType) result.getMember().get(0).getProcess().getValue();
assertEquals(resultProcess.getCapabilities(), component.getCapabilities());
assertTrue(resultProcess.getContact().size() == 1);
assertEquals(resultProcess.getContact().get(0).getContactList(), component.getContact().get(0).getContactList());
assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getContactInfo(), component.getContact().get(0).getResponsibleParty().getContactInfo());
assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getOrganizationName(), component.getContact().get(0).getResponsibleParty().getOrganizationName());
assertEquals(resultProcess.getContact().get(0).getResponsibleParty(), component.getContact().get(0).getResponsibleParty());
assertEquals(resultProcess.getContact().get(0), component.getContact().get(0));
assertEquals(resultProcess.getContact(), component.getContact());
assertTrue(resultProcess.getClassification().size() == 1);
assertTrue(resultProcess.getClassification().get(0).getClassifierList().getClassifier().size() == 2);
assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm(), component.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm());
assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0), component.getClassification().get(0).getClassifierList().getClassifier().get(0));
assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier(), component.getClassification().get(0).getClassifierList().getClassifier());
assertEquals(resultProcess.getClassification().get(0).getClassifierList(), component.getClassification().get(0).getClassifierList());
assertEquals(resultProcess.getClassification().get(0), component.getClassification().get(0));
assertEquals(resultProcess.getClassification(), component.getClassification());
assertEquals(resultProcess.getIdentification(), component.getIdentification());
assertEquals(resultProcess.getValidTime(), component.getValidTime());
assertEquals(resultProcess.getParameters(), component.getParameters());
assertEquals(resultProcess.getInputs().getInputList().getInput(), component.getInputs().getInputList().getInput());
assertEquals(resultProcess.getInputs().getInputList(), component.getInputs().getInputList());
assertEquals(resultProcess.getInputs(), component.getInputs());
assertEquals(resultProcess.getOutputs(), component.getOutputs());
assertEquals(resultProcess.getSMLLocation(), component.getSMLLocation());
assertEquals(resultProcess.getPosition(), component.getPosition());
assertEquals(resultProcess.getSpatialReferenceFrame(), component.getSpatialReferenceFrame());
assertEquals(resultProcess.getDocumentation(), component.getDocumentation());
assertEquals(resultProcess.getCharacteristics(), component.getCharacteristics());
assertEquals(resultProcess.getKeywords(), component.getKeywords());
assertEquals(resultProcess.getParameters(), component.getParameters());
assertEquals(resultProcess.getName(), component.getName());
assertEquals(resultProcess, component);
assertEquals(expectedResult.getMember().get(0), result.getMember().get(0));
assertEquals(expectedResult.getMember(), result.getMember());
assertEquals(expectedResult, result);
SensorMLMarshallerPool.getInstance().recycle(unmarshaller);
}
Aggregations