Search in sources :

Example 6 with Descent

use of eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent in project hale by halestudio.

the class MultiLineStringWriter method write.

/**
 * @see GeometryWriter#write(XMLStreamWriter, Geometry, TypeDefinition,
 *      QName, String, DecimalFormat)
 */
@Override
public void write(XMLStreamWriter writer, MultiLineString geometry, TypeDefinition elementType, QName elementName, String gmlNs, DecimalFormat decimalFormatter) throws XMLStreamException {
    for (int i = 0; i < geometry.getNumGeometries(); i++) {
        if (i > 0) {
            writer.writeStartElement(elementName.getNamespaceURI(), elementName.getLocalPart());
        }
        Descent descent = descend(// $NON-NLS-1$
        writer, // $NON-NLS-1$
        Pattern.parse("*/LineString"), elementType, elementName, gmlNs, false);
        LineString line = (LineString) geometry.getGeometryN(i);
        writeCoordinates(writer, line.getCoordinates(), descent.getPath().getLastType(), gmlNs, decimalFormatter);
        descent.close();
        if (i < geometry.getNumGeometries() - 1) {
            writer.writeEndElement();
        }
    }
}
Also used : LineString(org.locationtech.jts.geom.LineString) MultiLineString(org.locationtech.jts.geom.MultiLineString) Descent(eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent)

Example 7 with Descent

use of eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent in project hale by halestudio.

the class AbstractGeometryWriter method descendAndWriteCoordinates.

/**
 * Write coordinates into a posList or coordinates property
 *
 * @param writer the XML stream writer
 * @param descendPattern the pattern to descend
 * @param coordinates the coordinates to write
 * @param elementType the type of the encompassing element
 * @param elementName the encompassing element name
 * @param gmlNs the GML namespace
 * @param unique if the path's start element cannot be repeated
 * @param decimalFormatter a decimal formatter to format geometry
 *            coordinates
 * @throws XMLStreamException if an error occurs writing the coordinates
 */
protected static void descendAndWriteCoordinates(XMLStreamWriter writer, Pattern descendPattern, Coordinate[] coordinates, TypeDefinition elementType, QName elementName, String gmlNs, boolean unique, DecimalFormat decimalFormatter) throws XMLStreamException {
    Descent descent = descend(writer, descendPattern, elementType, elementName, gmlNs, unique);
    // write geometry
    writeCoordinates(writer, coordinates, descent.getPath().getLastType(), gmlNs, decimalFormatter);
    descent.close();
}
Also used : Descent(eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent)

Example 8 with Descent

use of eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent in project hale by halestudio.

the class MultiCurveWriter method write.

/**
 * @see GeometryWriter#write(XMLStreamWriter, Geometry, TypeDefinition,
 *      QName, String, DecimalFormat)
 */
@Override
public void write(XMLStreamWriter writer, MultiLineString geometry, TypeDefinition elementType, QName elementName, String gmlNs, DecimalFormat decimalFormatter) throws XMLStreamException {
    for (int i = 0; i < geometry.getNumGeometries(); i++) {
        if (i > 0) {
            writer.writeStartElement(elementName.getNamespaceURI(), elementName.getLocalPart());
        }
        Descent descent = descend(// $NON-NLS-1$
        writer, // $NON-NLS-1$
        Pattern.parse("*/LineString"), elementType, elementName, gmlNs, false);
        LineString line = (LineString) geometry.getGeometryN(i);
        writeCoordinates(writer, line.getCoordinates(), descent.getPath().getLastType(), gmlNs, decimalFormatter);
        descent.close();
        if (i < geometry.getNumGeometries() - 1) {
            writer.writeEndElement();
        }
    }
}
Also used : LineString(org.locationtech.jts.geom.LineString) MultiLineString(org.locationtech.jts.geom.MultiLineString) Descent(eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent)

Aggregations

Descent (eu.esdihumboldt.hale.io.gml.writer.internal.geometry.Descent)8 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 DefinitionPath (eu.esdihumboldt.hale.io.gml.writer.internal.geometry.DefinitionPath)2 HashMap (java.util.HashMap)2 QName (javax.xml.namespace.QName)2 LineString (org.locationtech.jts.geom.LineString)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)2 Point (org.locationtech.jts.geom.Point)2 Polygon (org.locationtech.jts.geom.Polygon)2 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)1 SubtaskProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.SubtaskProgressIndicator)1 Locatable (eu.esdihumboldt.hale.common.core.io.supplier.Locatable)1 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)1 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 URI (java.net.URI)1