use of org.apache.olingo.commons.api.edm.geo.Polygon in project teiid by teiid.
the class AtomGeoValueSerializer method polygons.
private void polygons(final XMLStreamWriter writer, final Iterator<Polygon> itor, final boolean wrap) throws XMLStreamException {
while (itor.hasNext()) {
final Polygon polygon = itor.next();
if (wrap) {
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON, Constants.NS_GML);
}
if (!polygon.getExterior().isEmpty()) {
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_EXTERIOR, Constants.NS_GML);
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
points(writer, polygon.getExterior().iterator(), false);
writer.writeEndElement();
writer.writeEndElement();
}
if (!polygon.getInterior().isEmpty()) {
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_INTERIOR, Constants.NS_GML);
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POLYGON_LINEARRING, Constants.NS_GML);
points(writer, polygon.getInterior().iterator(), false);
writer.writeEndElement();
writer.writeEndElement();
}
if (wrap) {
writer.writeEndElement();
}
}
}
use of org.apache.olingo.commons.api.edm.geo.Polygon 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:
}
}
Aggregations