Search in sources :

Example 11 with Capabilities

use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class CswXMLBindingTest method InspireUnmarshalingTest.

/**
 * Test capabilities with INSPIRE extendedCapabilities unmarshalling.
 */
@Test
public void InspireUnmarshalingTest() throws Exception {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Capabilities version=\"2.0.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <ows:OperationsMetadata>\n" + "   <ows:ExtendedCapabilities>\n" + "     <ins:MultiLingualCapabilities xmlns:ins=\"http://www.inspire.org\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + "       <ins:Languages>\n" + "         <ins:Language>GER</ins:Language>\n" + "         <ins:Language>DUT</ins:Language>\n" + "       </ins:Languages>\n" + "       <ins:TranslatedCapabilities>\n" + "         <ins:Document xlink:href=\"http://www.somehost.com/capabilities_german.xml\" language=\"GER\"/>\n" + "         <ins:Document xlink:href=\"http://www.somehost.com/capabilities_dutch.xml\"  language=\"DUT\"/>\n" + "       </ins:TranslatedCapabilities>\n" + "    </ins:MultiLingualCapabilities>\n" + "  </ows:ExtendedCapabilities>\n" + " </ows:OperationsMetadata>\n" + "</csw:Capabilities>\n";
    Capabilities result = (Capabilities) unmarshaller.unmarshal(new StringReader(xml));
    OperationsMetadata om = new OperationsMetadata();
    LanguagesType languages = new LanguagesType(Arrays.asList("GER", "DUT"));
    List<DocumentType> docs = Arrays.asList(new DocumentType("http://www.somehost.com/capabilities_german.xml", "GER"), new DocumentType("http://www.somehost.com/capabilities_dutch.xml", "DUT"));
    TranslatedCapabilitiesType trans = new TranslatedCapabilitiesType(docs);
    InspireCapabilitiesType inspireCapa = new InspireCapabilitiesType(languages, trans);
    MultiLingualCapabilities m = new MultiLingualCapabilities();
    m.setMultiLingualCapabilities(inspireCapa);
    om.setExtendedCapabilities(m);
    Capabilities expResult = new Capabilities(null, null, om, "2.0.2", null, null);
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : OperationsMetadata(org.geotoolkit.ows.xml.v100.OperationsMetadata) LanguagesType(org.geotoolkit.inspire.xml.LanguagesType) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) Capabilities(org.geotoolkit.csw.xml.v202.Capabilities) StringReader(java.io.StringReader) InspireCapabilitiesType(org.geotoolkit.inspire.xml.InspireCapabilitiesType) DocumentType(org.geotoolkit.inspire.xml.DocumentType) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) Unmarshaller(javax.xml.bind.Unmarshaller) TranslatedCapabilitiesType(org.geotoolkit.inspire.xml.TranslatedCapabilitiesType) Test(org.junit.Test)

Example 12 with Capabilities

use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class WMTSBindingUtilities method unmarshall.

public static Capabilities unmarshall(final Object source, final WMTSVersion version) throws JAXBException {
    Unmarshaller unMarshaller = null;
    switch(version) {
        case v100:
            unMarshaller = WMTSMarshallerPool.getInstance().acquireUnmarshaller();
            break;
        default:
            throw new IllegalArgumentException("unknonwed version");
    }
    Capabilities c = (Capabilities) unmarshall(source, unMarshaller);
    WMTSMarshallerPool.getInstance().recycle(unMarshaller);
    return c;
}
Also used : Capabilities(org.geotoolkit.wmts.xml.v100.Capabilities) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 13 with Capabilities

use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class SmlXMLFactory method convertTo101.

public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
    List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
    for (Member oldMember : sensor.getMember()) {
        final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
        if (oldMember.getRealProcess() instanceof System) {
            newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
        } else if (oldMember.getRealProcess() instanceof Component) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
        } else {
            throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
        // id
        newProcess.setId(oldProcess.getId());
        // name
        newProcess.setName(oldProcess.getName());
        // srsName
        newProcess.setSrsName(oldProcess.getSrsName());
        // description
        newProcess.setDescription(oldProcess.getDescription());
        // boundedBy
        newProcess.setBoundedBy(oldProcess.getBoundedBy());
        // capabilities
        List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
        for (Capabilities oldCapa : oldProcess.getCapabilities()) {
            newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
        }
        newProcess.setCapabilities(newCapabilities);
        // characteristics
        List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
        for (Characteristics oldChar : oldProcess.getCharacteristics()) {
            newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
        }
        newProcess.setCharacteristics(newCharacteristics);
        // Classification
        List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
        for (Classification oldClass : oldProcess.getClassification()) {
            newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
        }
        newProcess.setClassification(newClassification);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
        for (Contact oldContact : oldProcess.getContact()) {
            newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
        }
        newProcess.setContact(newContact);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
        for (Documentation oldDoc : oldProcess.getDocumentation()) {
            newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
        }
        newProcess.setDocumentation(newDocumentation);
        // History
        List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
        for (History oldhist : oldProcess.getHistory()) {
            newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
        }
        newProcess.setHistory(newHistory);
        // Identification
        List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
        for (Identification oldIdent : oldProcess.getIdentification()) {
            newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
        }
        newProcess.setIdentification(newIdentification);
        // keywords
        List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
        for (Keywords oldKeyw : oldProcess.getKeywords()) {
            newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
        }
        newProcess.setKeywords(newKeywords);
        // legal constraint
        List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
        for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
            newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
        }
        newProcess.setLegalConstraint(newLegalConstraints);
        // security constraint
        if (oldProcess.getSecurityConstraint() != null) {
            newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
        }
        // validTime
        if (oldProcess.getValidTime() != null) {
            newProcess.setValidTime(oldProcess.getValidTime());
        }
        if (oldProcess instanceof AbstractComponent) {
            AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
            AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
            // Inputs
            if (oldAbsComponent.getInputs() != null) {
                newAbsComponent.setInputs(oldAbsComponent.getInputs());
            }
            // outputs
            if (oldAbsComponent.getOutputs() != null) {
                newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
            }
            // parameters
            if (oldAbsComponent.getParameters() != null) {
                newAbsComponent.setParameters(oldAbsComponent.getParameters());
            }
        }
        if (oldProcess instanceof AbstractDerivableComponent) {
            org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
            AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
            // Position
            if (oldDerComponent.getPosition() != null) {
                newDerComponent.setPosition(oldDerComponent.getPosition());
            }
            if (oldDerComponent.getSMLLocation() != null) {
                newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
            }
            if (oldDerComponent.getInterfaces() != null) {
                newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
            }
            if (oldDerComponent.getSpatialReferenceFrame() != null) {
                newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
            }
            if (oldDerComponent.getTemporalReferenceFrame() != null) {
                newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
            }
            if (oldDerComponent.getTimePosition() != null) {
                newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
            }
        }
        if (oldProcess instanceof AbstractPureProcess) {
            org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
            AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
            // Inputs
            if (oldAbsPuProc.getInputs() != null) {
                newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
            }
            // outputs
            if (oldAbsPuProc.getOutputs() != null) {
                newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
            }
            // parameters
            if (oldAbsPuProc.getParameters() != null) {
                newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
            }
        }
        if (oldMember.getRealProcess() instanceof System) {
            SystemType oldSystem = (SystemType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
            // components
            if (oldSystem.getComponents() != null) {
                newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
            }
            // positions
            if (oldSystem.getPositions() != null) {
                newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
            }
            // connections
            if (oldSystem.getConnections() != null) {
                newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof Component) {
            ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
            // method
            if (oldComponent.getMethod() != null) {
                newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
            if (oldDataSource.getDataDefinition() != null) {
                newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
            }
            if (oldDataSource.getValues() != null) {
                newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
            }
            if (oldDataSource.getObservationReference() != null) {
                newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
            if (oldProcessModel.getMethod() != null) {
                newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
            ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
            // components
            if (oldProcessChain.getComponents() != null) {
                newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
            }
            // connections
            if (oldProcessChain.getConnections() != null) {
                newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
        // nothing to do
        } else {
            throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
    }
    org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
    return result;
}
Also used : ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) History(org.geotoolkit.sml.xml.v100.History) Classification(org.geotoolkit.sml.xml.v100.Classification) DataSourceType(org.geotoolkit.sml.xml.v100.DataSourceType) Member(org.geotoolkit.sml.xml.v100.Member) Documentation(org.geotoolkit.sml.xml.v100.Documentation) AbstractProcessType(org.geotoolkit.sml.xml.v100.AbstractProcessType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Contact(org.geotoolkit.sml.xml.v100.Contact) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) ProcessModelType(org.geotoolkit.sml.xml.v100.ProcessModelType) ProcessChainType(org.geotoolkit.sml.xml.v100.ProcessChainType)

Example 14 with Capabilities

use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class CSWClientDemo method main.

public static void main(String[] args) throws MalformedURLException, URISyntaxException, IOException, JAXBException {
    Demos.init();
    final MarshallerPool pool = CSWMarshallerPool.getInstance();
    final Unmarshaller um = pool.acquireUnmarshaller();
    final MarshallWarnings warnings = new MarshallWarnings();
    um.setProperty(XML.CONVERTER, warnings);
    // build a new CSW client
    final CatalogServicesClient cswServer = new CatalogServicesClient(new URL("http://catalog.data.gov/csw?"), "2.0.2");
    /**
     * make a getCapabilities request
     */
    final GetCapabilitiesRequest getCapa = cswServer.createGetCapabilities();
    InputStream is = getCapa.getResponseStream();
    // unmarshall the response
    Capabilities capabilities = (Capabilities) um.unmarshal(is);
    // print the title of the server
    System.out.println(capabilities.getServiceIdentification().getTitle());
    /**
     * make a getRecords request
     */
    final GetRecordsRequest getRecords = cswServer.createGetRecords();
    getRecords.setTypeNames("gmd:MD_Metadata");
    getRecords.setConstraintLanguage("CQL");
    getRecords.setConstraintLanguageVersion("1.1.0");
    getRecords.setConstraint("apiso:Title like '%'");
    getRecords.setElementSetName(ElementSetType.FULL);
    is = getRecords.getResponseStream();
    // unmarshall the response
    Object obj = um.unmarshal(is);
    GetRecordsResponseType response;
    if (obj instanceof ExceptionReport) {
        System.out.println("Error received:" + obj);
        return;
    } else {
        response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
    }
    // print the number of result matching the request
    System.out.println(response.getSearchResults().getNumberOfRecordsMatched());
    /**
     * retrieve results in dublin core
     */
    getRecords.setResultType(ResultType.RESULTS);
    is = getRecords.getResponseStream();
    obj = um.unmarshal(is);
    // unmarshall the response
    if (obj instanceof ExceptionReport) {
        System.out.println("Error received:" + obj);
        return;
    } else {
        response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
    }
    // print the first result (Dublin core)
    AbstractRecord record = (AbstractRecord) response.getSearchResults().getAny().get(0);
    System.out.println(record);
    /**
     * retrieve results in ISO 19139
     */
    getRecords.setOutputSchema("http://www.isotc211.org/2005/gmd");
    is = getRecords.getResponseStream();
    // unmarshall the response
    obj = um.unmarshal(is);
    // unmarshall the response
    if (obj instanceof ExceptionReport) {
        System.out.println("Error received:" + obj);
        return;
    } else {
        response = ((JAXBElement<GetRecordsResponseType>) obj).getValue();
    }
    // print the first result (ISO 19139)
    Metadata meta = (Metadata) response.getSearchResults().getAny().get(0);
    System.out.println(meta);
    final String identifier = meta.getFileIdentifier();
    /**
     * make a getRecordById request
     */
    final GetRecordByIdRequest getRecordById = cswServer.createGetRecordById();
    getRecordById.setOutputSchema("http://www.isotc211.org/2005/gmd");
    getRecordById.setIds(identifier);
    is = getRecordById.getResponseStream();
    // unmarshall the response
    obj = um.unmarshal(is);
    // unmarshall the response
    GetRecordByIdResponse responseBi;
    if (obj instanceof ExceptionReport) {
        System.out.println("Error received:" + obj);
        return;
    } else {
        responseBi = ((JAXBElement<GetRecordByIdResponse>) obj).getValue();
    }
    // print the result (same as getRecords first result)
    meta = (Metadata) responseBi.getAny().get(0);
    System.out.println(meta);
    pool.recycle(um);
}
Also used : GetRecordByIdResponse(org.geotoolkit.csw.xml.GetRecordByIdResponse) GetCapabilitiesRequest(org.geotoolkit.csw.GetCapabilitiesRequest) InputStream(java.io.InputStream) ExceptionReport(org.geotoolkit.ows.xml.v100.ExceptionReport) AbstractRecord(org.geotoolkit.csw.xml.AbstractRecord) Metadata(org.opengis.metadata.Metadata) CSWMarshallerPool(org.geotoolkit.csw.xml.CSWMarshallerPool) MarshallerPool(org.apache.sis.xml.MarshallerPool) GetRecordByIdRequest(org.geotoolkit.csw.GetRecordByIdRequest) URL(java.net.URL) GetRecordsRequest(org.geotoolkit.csw.GetRecordsRequest) CatalogServicesClient(org.geotoolkit.csw.CatalogServicesClient) Capabilities(org.geotoolkit.csw.xml.v202.Capabilities) GetRecordsResponseType(org.geotoolkit.csw.xml.v202.GetRecordsResponseType) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 15 with Capabilities

use of org.geotoolkit.sml.xml.v100.Capabilities in project geotoolkit by Geomatys.

the class SOSClientDemo method main.

public static void main(String[] args) throws MalformedURLException, URISyntaxException, IOException, JAXBException {
    Demos.init();
    final MarshallerPool pool = SOSMarshallerPool.getInstance();
    final Unmarshaller um = pool.acquireUnmarshaller();
    // build a new SOS client
    final SensorObservationServiceClient sosServer = new SensorObservationServiceClient(new URL("http://test.geomatys.com/swe_TS/WS/sos?"), "1.0.0");
    /**
     * make a getCapabilities request
     */
    final GetCapabilitiesRequest getCapa = sosServer.createGetCapabilities();
    InputStream is = getCapa.getResponseStream();
    // unmarshall the response
    Capabilities capabilities = (Capabilities) um.unmarshal(is);
    // print the title of the server
    System.out.println(capabilities.getServiceIdentification().getTitle());
    // extract a sensorML identifier and outputFormat to make a describeSensor request
    Operation describeSensorOperation = capabilities.getOperationsMetadata().getOperation("DescribeSensor");
    String sensorID = ((ValueType) describeSensorOperation.getParameter("procedure").getAllowedValues().getValueOrRange().get(0)).getValue();
    String outputFormat = ((ValueType) describeSensorOperation.getParameter("outputFormat").getAllowedValues().getValueOrRange().get(0)).getValue();
    // extract a all the parameters necessary to make a getObservation request
    Operation getObservationOperation = capabilities.getOperationsMetadata().getOperation("GetObservation");
    String offering = ((ValueType) getObservationOperation.getParameter("offering").getAllowedValues().getValueOrRange().get(0)).getValue();
    String responseFormat = ((ValueType) getObservationOperation.getParameter("responseFormat").getAllowedValues().getValueOrRange().get(0)).getValue();
    String phenomenon = ((ValueType) getObservationOperation.getParameter("observedProperty").getAllowedValues().getValueOrRange().get(0)).getValue();
    String procedure = ((ValueType) getObservationOperation.getParameter("procedure").getAllowedValues().getValueOrRange().get(0)).getValue();
    String featureOfInterest = ((ValueType) getObservationOperation.getParameter("featureOfInterest").getAllowedValues().getValueOrRange().get(0)).getValue();
    /**
     * make a DescribeSensor request
     */
    final DescribeSensorRequest descSensor = sosServer.createDescribeSensor();
    descSensor.setSensorId(sensorID);
    descSensor.setOutputFormat(outputFormat);
    is = descSensor.getResponseStream();
    // unmarshall the response
    AbstractSensorML sensorMLResponse = (AbstractSensorML) um.unmarshal(is);
    System.out.println(sensorMLResponse);
    /**
     * make a GetObservation request
     */
    final GetObservationRequest getObs = sosServer.createGetObservation();
    getObs.setOffering(offering);
    getObs.setObservedProperties(phenomenon);
    getObs.setProcedures(procedure);
    getObs.setResponseFormat(responseFormat);
    getObs.setFeatureOfInterest(new FeatureOfInterest(Arrays.asList(featureOfInterest)));
    is = getObs.getResponseStream();
    // unmarshall the response
    ObservationCollectionType getObsResponse = (ObservationCollectionType) um.unmarshal(is);
    System.out.println(getObsResponse);
    pool.recycle(um);
}
Also used : GetCapabilitiesRequest(org.geotoolkit.sos.GetCapabilitiesRequest) ValueType(org.geotoolkit.ows.xml.v110.ValueType) InputStream(java.io.InputStream) ObservationCollectionType(org.geotoolkit.observation.xml.v100.ObservationCollectionType) MarshallerPool(org.apache.sis.xml.MarshallerPool) SOSMarshallerPool(org.geotoolkit.sos.xml.SOSMarshallerPool) Operation(org.geotoolkit.ows.xml.v110.Operation) URL(java.net.URL) AbstractSensorML(org.geotoolkit.sml.xml.AbstractSensorML) GetObservationRequest(org.geotoolkit.sos.GetObservationRequest) FeatureOfInterest(org.geotoolkit.sos.xml.v100.GetObservation.FeatureOfInterest) Capabilities(org.geotoolkit.sos.xml.v100.Capabilities) Unmarshaller(javax.xml.bind.Unmarshaller) DescribeSensorRequest(org.geotoolkit.sos.DescribeSensorRequest) SensorObservationServiceClient(org.geotoolkit.sos.SensorObservationServiceClient)

Aggregations

Test (org.junit.Test)8 Unmarshaller (javax.xml.bind.Unmarshaller)7 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)7 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 ByteBuf (io.netty.buffer.ByteBuf)3 URL (java.net.URL)3 JAXBElement (javax.xml.bind.JAXBElement)3 Capabilities (org.geotoolkit.csw.xml.v202.Capabilities)3 Capabilities (org.geotoolkit.wmts.xml.v100.Capabilities)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 MarshallerPool (org.apache.sis.xml.MarshallerPool)2 CapabilitiesException (org.geotoolkit.client.CapabilitiesException)2 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)2 DocumentType (org.geotoolkit.inspire.xml.DocumentType)2 InspireCapabilitiesType (org.geotoolkit.inspire.xml.InspireCapabilitiesType)2 LanguagesType (org.geotoolkit.inspire.xml.LanguagesType)2 MultiLingualCapabilities (org.geotoolkit.inspire.xml.MultiLingualCapabilities)2 TranslatedCapabilitiesType (org.geotoolkit.inspire.xml.TranslatedCapabilitiesType)2 OperationsMetadata (org.geotoolkit.ows.xml.v100.OperationsMetadata)2