use of com.vividsolutions.jts.io.gml2.GMLWriter in project incubator-rya by apache.
the class GeoIndexerSfTest method geoToGmlUseJtsLib.
/**
* JTS library conversion from geometry to GML.
* @param geo base Geometry gets delegated
* @return String gml encoding of the geomoetry
*/
private static String geoToGmlUseJtsLib(final Geometry geo) {
final int srid = geo.getSRID();
final GMLWriter gmlWriter = new GMLWriter();
gmlWriter.setNamespace(false);
gmlWriter.setPrefix(null);
if (srid != -1 || srid != 0) {
gmlWriter.setSrsName("EPSG:" + geo.getSRID());
}
final String gml = gmlWriter.write(geo);
// It should tolerate this as it does other depreciated elements like <gml:coordinates>.
return gml.replace("outerBoundaryIs", "exterior");
}
use of com.vividsolutions.jts.io.gml2.GMLWriter in project teiid by teiid.
the class GeometryUtils method geometryToGml.
public static ClobType geometryToGml(CommandContext ctx, GeometryType geometry, boolean withGmlPrefix) throws FunctionExecutionException {
Geometry jtsGeometry = getGeometry(geometry);
GMLWriter writer = new GMLWriter();
if (!withGmlPrefix) {
if (geometry.getSrid() != SRID_4326) {
if (geometry.getSrid() == GeometryType.UNKNOWN_SRID) {
throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31161));
}
jtsGeometry = GeometryTransformUtils.transform(ctx, jtsGeometry, SRID_4326);
}
writer.setPrefix(null);
} else if (geometry.getSrid() != GeometryType.UNKNOWN_SRID) {
// TODO: should include the srsName
// writer.setSrsName(String.valueOf(geometry.getSrid()));
}
String gmlText = writer.write(jtsGeometry);
return new ClobType(new ClobImpl(gmlText));
}
use of com.vividsolutions.jts.io.gml2.GMLWriter in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertGeometryToGML.
public static String convertGeometryToGML(Geometry geometry) throws JAXBException {
GMLWriter gmlWriter = new GMLWriter(true);
String gml = gmlWriter.write(geometry);
return gml;
}
use of com.vividsolutions.jts.io.gml2.GMLWriter in project ddf by codice.
the class GmlGeometryConverter method marshal.
@Override
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
Geometry geometry = (Geometry) value;
GMLWriter gmlWriter = new GMLWriter();
String gmlXml = gmlWriter.write(geometry);
// Copy the GML XML into the writer
XmlPullParser parser = null;
try {
parser = XppFactory.createDefaultParser();
new HierarchicalStreamCopier().copy(new XppReader(new StringReader(gmlXml), parser), writer);
} catch (XmlPullParserException e) {
LOGGER.debug(ERROR_SERIALIZING_MSG, e);
}
}
use of com.vividsolutions.jts.io.gml2.GMLWriter in project incubator-rya by apache.
the class GeoWaveIndexerSfTest method geoToGmlUseJtsLib.
/**
* JTS library conversion from geometry to GML.
* @param geo base Geometry gets delegated
* @return String gml encoding of the geomoetry
*/
private static String geoToGmlUseJtsLib(final Geometry geo) {
final int srid = geo.getSRID();
final GMLWriter gmlWriter = new GMLWriter();
gmlWriter.setNamespace(false);
gmlWriter.setPrefix(null);
if (srid != -1 || srid != 0) {
gmlWriter.setSrsName("EPSG:" + geo.getSRID());
}
final String gml = gmlWriter.write(geo);
// It should tolerate this as it does other depreciated elements like <gml:coordinates>.
return gml.replace("outerBoundaryIs", "exterior");
}
Aggregations