Search in sources :

Example 1 with DataBlockDefinitionType

use of org.geotoolkit.swe.xml.v101.DataBlockDefinitionType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method DataSourceMarshalingTest.

@Test
public void DataSourceMarshalingTest() throws Exception {
    final SystemType system = new SystemType();
    final List<DataComponentPropertyType> fields = new ArrayList<>();
    fields.add(DataComponentPropertyType.LATITUDE_FIELD);
    fields.add(DataComponentPropertyType.LONGITUDE_FIELD);
    fields.add(DataComponentPropertyType.TIME_FIELD);
    final DataRecordType posRecord = new DataRecordType(null, fields);
    final DataBlockDefinitionType definition = new DataBlockDefinitionType(null, Arrays.asList(posRecord), TextBlockType.DEFAULT_ENCODING);
    final DataDefinition dataDefinition = new DataDefinition(definition);
    final org.geotoolkit.sml.xml.v101.Values trajValues = new org.geotoolkit.sml.xml.v101.Values();
    trajValues.setAny("test");
    final DataSourceType datasource = new DataSourceType(dataDefinition, trajValues, null);
    final Position pos = new Position(null, datasource);
    system.setPosition(pos);
    DataSourceType expds = (DataSourceType) pos.getAbstractProcess();
    DataSourceType resds = (DataSourceType) system.getPosition().getAbstractProcess();
    assertEquals(expds.getDataDefinition(), resds.getDataDefinition());
    assertEquals(expds, resds);
    assertEquals(pos.getAbstractProcess(), system.getPosition().getAbstractProcess());
    assertEquals(pos.getPosition(), system.getPosition().getPosition());
    assertEquals(pos, system.getPosition());
    final SensorML sml = new SensorML("1.0.1", Arrays.asList(new SensorML.Member(system)));
    Marshaller m = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    ObjectFactory factory = new ObjectFactory();
    // m.marshal(factory.createPosition(pos), System.out);
    // m.marshal(factory.createSystem(system), System.out);
    // m.marshal(sml, System.out);
    SensorMLMarshallerPool.getInstance().recycle(m);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) Marshaller(javax.xml.bind.Marshaller) Position(org.geotoolkit.sml.xml.v101.Position) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v101.SystemType) DataDefinition(org.geotoolkit.sml.xml.v101.DataDefinition) SensorML(org.geotoolkit.sml.xml.v101.SensorML) DataBlockDefinitionType(org.geotoolkit.swe.xml.v101.DataBlockDefinitionType) ObjectFactory(org.geotoolkit.sml.xml.v101.ObjectFactory) DataSourceType(org.geotoolkit.sml.xml.v101.DataSourceType) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType)

Example 2 with DataBlockDefinitionType

use of org.geotoolkit.swe.xml.v101.DataBlockDefinitionType in project geotoolkit by Geomatys.

the class SweXMLBindingTest method marshallingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void marshallingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    Text text = new Text("definition", "some value");
    StringWriter sw = new StringWriter();
    marshaller.marshal(text, sw);
    String result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    // we remove the xmlmns
    result = StringUtilities.removeXmlns(result);
    String expResult = "<swe:Text definition=\"definition\" >" + '\n' + "  <swe:value>some value</swe:value>" + '\n' + "</swe:Text>";
    assertEquals(expResult, result.trim());
    SimpleDataRecordType elementType = new SimpleDataRecordType();
    AnyScalarPropertyType any = new AnyScalarPropertyType("id-1", "any name", text);
    TextBlockType encoding = new TextBlockType("encoding-1", ",", "@@", ".");
    elementType.setField(Arrays.asList(any));
    DataArrayType array = new DataArrayType("array-id-1", 0, "array-id-1", elementType, encoding, null, null);
    sw = new StringWriter();
    marshaller.marshal(array, sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<swe:DataArray gml:id=\"array-id-1\"" + " xmlns:gml=\"http://www.opengis.net/gml\"" + " xmlns:swe=\"http://www.opengis.net/swe/1.0.1\">" + '\n' + "    <swe:elementCount>" + '\n' + "        <swe:Count>" + '\n' + "            <swe:value>0</swe:value>" + '\n' + "        </swe:Count>" + '\n' + "    </swe:elementCount>" + '\n' + "    <swe:elementType name=\"array-id-1\">" + '\n' + "        <swe:SimpleDataRecord>" + '\n' + "            <swe:field name=\"any name\">" + '\n' + "                <swe:Text definition=\"definition\">" + '\n' + "                    <swe:value>some value</swe:value>" + '\n' + "                </swe:Text>" + '\n' + "            </swe:field>" + '\n' + "        </swe:SimpleDataRecord>" + '\n' + "    </swe:elementType>" + '\n' + "    <swe:encoding>" + '\n' + "        <swe:TextBlock blockSeparator=\"@@\" decimalSeparator=\".\" tokenSeparator=\",\" id=\"encoding-1\"/>" + '\n' + "    </swe:encoding>" + '\n' + "</swe:DataArray>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    ObjectFactory factory = new ObjectFactory();
    final List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    fields.add(DataComponentPropertyType.LATITUDE_FIELD);
    fields.add(DataComponentPropertyType.LONGITUDE_FIELD);
    fields.add(DataComponentPropertyType.TIME_FIELD);
    final DataRecordType posRecord = new DataRecordType(null, fields);
    final DataBlockDefinitionType definition = new DataBlockDefinitionType(null, Arrays.asList((AbstractDataComponentType) posRecord), TextBlockType.DEFAULT_ENCODING);
    marshaller.marshal(factory.createDataBlockDefinition(definition), System.out);
    org.geotoolkit.swe.xml.v200.ObjectFactory factoryV200 = new org.geotoolkit.swe.xml.v200.ObjectFactory();
    org.geotoolkit.swe.xml.v200.DataArrayType arrayV200 = new org.geotoolkit.swe.xml.v200.DataArrayType("test-id", 2, null, "balbbla", "test-id", null, null);
    marshaller.marshal(factoryV200.createDataArray(arrayV200), System.out);
}
Also used : SimpleDataRecordType(org.geotoolkit.swe.xml.v101.SimpleDataRecordType) DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) AnyScalarPropertyType(org.geotoolkit.swe.xml.v101.AnyScalarPropertyType) ArrayList(java.util.ArrayList) Text(org.geotoolkit.swe.xml.v101.Text) DataBlockDefinitionType(org.geotoolkit.swe.xml.v101.DataBlockDefinitionType) AbstractDataComponentType(org.geotoolkit.swe.xml.v101.AbstractDataComponentType) StringWriter(java.io.StringWriter) ObjectFactory(org.geotoolkit.swe.xml.v101.ObjectFactory) TextBlockType(org.geotoolkit.swe.xml.v101.TextBlockType) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) SimpleDataRecordType(org.geotoolkit.swe.xml.v101.SimpleDataRecordType) DataArrayType(org.geotoolkit.swe.xml.v101.DataArrayType)

Example 3 with DataBlockDefinitionType

use of org.geotoolkit.swe.xml.v101.DataBlockDefinitionType in project geotoolkit by Geomatys.

the class SweXMLBindingTest method cloneDataBlockDefinitionTest.

@Test
public void cloneDataBlockDefinitionTest() throws Exception {
    final List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    fields.add(DataComponentPropertyType.LATITUDE_FIELD);
    fields.add(DataComponentPropertyType.LONGITUDE_FIELD);
    fields.add(DataComponentPropertyType.TIME_FIELD);
    final DataRecordType posRecord = new DataRecordType(null, fields);
    final DataBlockDefinitionType expResult = new DataBlockDefinitionType(null, Arrays.asList((AbstractDataComponentType) posRecord), TextBlockType.DEFAULT_ENCODING);
    final DataBlockDefinitionType result = new DataBlockDefinitionType(expResult);
    assertEquals(expResult.getEncoding(), result.getEncoding());
    assertEquals(expResult, result);
}
Also used : SimpleDataRecordType(org.geotoolkit.swe.xml.v101.SimpleDataRecordType) DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) AbstractDataComponentType(org.geotoolkit.swe.xml.v101.AbstractDataComponentType) ArrayList(java.util.ArrayList) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType) DataBlockDefinitionType(org.geotoolkit.swe.xml.v101.DataBlockDefinitionType)

Aggregations

ArrayList (java.util.ArrayList)3 DataBlockDefinitionType (org.geotoolkit.swe.xml.v101.DataBlockDefinitionType)3 DataComponentPropertyType (org.geotoolkit.swe.xml.v101.DataComponentPropertyType)3 DataRecordType (org.geotoolkit.swe.xml.v101.DataRecordType)3 AbstractDataComponentType (org.geotoolkit.swe.xml.v101.AbstractDataComponentType)2 SimpleDataRecordType (org.geotoolkit.swe.xml.v101.SimpleDataRecordType)2 StringWriter (java.io.StringWriter)1 Marshaller (javax.xml.bind.Marshaller)1 DataDefinition (org.geotoolkit.sml.xml.v101.DataDefinition)1 DataSourceType (org.geotoolkit.sml.xml.v101.DataSourceType)1 ObjectFactory (org.geotoolkit.sml.xml.v101.ObjectFactory)1 Position (org.geotoolkit.sml.xml.v101.Position)1 SensorML (org.geotoolkit.sml.xml.v101.SensorML)1 SystemType (org.geotoolkit.sml.xml.v101.SystemType)1 AnyScalarPropertyType (org.geotoolkit.swe.xml.v101.AnyScalarPropertyType)1 DataArrayType (org.geotoolkit.swe.xml.v101.DataArrayType)1 ObjectFactory (org.geotoolkit.swe.xml.v101.ObjectFactory)1 Text (org.geotoolkit.swe.xml.v101.Text)1 TextBlockType (org.geotoolkit.swe.xml.v101.TextBlockType)1