Search in sources :

Example 1 with MultiPolygon

use of org.apache.olingo.commons.api.edm.geo.MultiPolygon in project teiid by teiid.

the class AtomGeoValueSerializer method serialize.

public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
    switch(value.getEdmPrimitiveTypeKind()) {
        case GeographyPoint:
        case GeometryPoint:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
            writeSrsName(writer, value);
            points(writer, Collections.singleton((Point) value).iterator(), false);
            writer.writeEndElement();
            break;
        case GeometryMultiPoint:
        case GeographyMultiPoint:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOINT, Constants.NS_GML);
            writeSrsName(writer, value);
            if (!((MultiPoint) value).isEmpty()) {
                writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINTMEMBERS, Constants.NS_GML);
                points(writer, ((MultiPoint) value).iterator(), true);
                writer.writeEndElement();
            }
            writer.writeEndElement();
            break;
        case GeometryLineString:
        case GeographyLineString:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRING, Constants.NS_GML);
            writeSrsName(writer, value);
            lineStrings(writer, Collections.singleton((LineString) value).iterator(), false);
            writer.writeEndElement();
            break;
        case GeometryMultiLineString:
        case GeographyMultiLineString:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTILINESTRING, Constants.NS_GML);
            writeSrsName(writer, value);
            if (!((MultiLineString) value).isEmpty()) {
                writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_LINESTRINGMEMBERS, Constants.NS_GML);
                lineStrings(writer, ((MultiLineString) value).iterator(), true);
                writer.writeEndElement();
            }
            writer.writeEndElement();
            break;
        case GeographyPolygon:
        case GeometryPolygon:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
            writeSrsName(writer, value);
            polygons(writer, Collections.singleton(((Polygon) value)).iterator(), false);
            writer.writeEndElement();
            break;
        case GeographyMultiPolygon:
        case GeometryMultiPolygon:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_MULTIPOLYGON, Constants.NS_GML);
            writeSrsName(writer, value);
            if (!((MultiPolygon) value).isEmpty()) {
                writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_SURFACEMEMBERS, Constants.NS_GML);
                polygons(writer, ((MultiPolygon) value).iterator(), true);
                writer.writeEndElement();
            }
            writer.writeEndElement();
            break;
        case GeographyCollection:
        case GeometryCollection:
            writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOCOLLECTION, Constants.NS_GML);
            writeSrsName(writer, value);
            if (!((GeospatialCollection) value).isEmpty()) {
                writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_GEOMEMBERS, Constants.NS_GML);
                for (Geospatial geospatial : ((GeospatialCollection) value)) {
                    serialize(writer, geospatial);
                }
                writer.writeEndElement();
            }
            writer.writeEndElement();
            break;
        default:
    }
}
Also used : Geospatial(org.apache.olingo.commons.api.edm.geo.Geospatial) Polygon(org.apache.olingo.commons.api.edm.geo.Polygon) MultiPolygon(org.apache.olingo.commons.api.edm.geo.MultiPolygon)

Aggregations

Geospatial (org.apache.olingo.commons.api.edm.geo.Geospatial)1 MultiPolygon (org.apache.olingo.commons.api.edm.geo.MultiPolygon)1 Polygon (org.apache.olingo.commons.api.edm.geo.Polygon)1