GMLWriter { public static String write(GeometryWrapper geometryWrapper) { Geometry geometry = geometryWrapper.getParsingGeometry(); CoordinateSequenceDimensions dimensions = geometryWrapper.getCoordinateSequenceDimensions(); String srsName = geometryWrapper.getSrsURI(); Element gmlElement = expand(geometry, dimensions, srsName); String output = XML_OUTPUT.outputString(gmlElement); return output; }  static String write(GeometryWrapper geometryWrapper); static String convertToGMLText(CustomCoordinateSequence coordSequence); static final Namespace GML_NAMESPACE; }
@Test public void testWritePoint() { Geometry geometry = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.1")); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:Point xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteLineString() { Geometry geometry = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.1, 15.0 8.0")); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:LineString xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWritePolygon() { Geometry geometry = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "30 10, 40 40, 20 40, 10 20, 30 10")); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:Polygon xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWritePolygon2() { LinearRing shell = GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "30 10, 40 40, 20 40, 10 20, 30 10")); LinearRing[] holes = new LinearRing[]{GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "20 30, 35 35, 30 20, 20 30"))}; Geometry geometry = GEOMETRY_FACTORY.createPolygon(shell, holes); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:Polygon xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteMultiPoint() { Geometry geometry = GEOMETRY_FACTORY.createMultiPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "10 40, 40 30, 20 20, 30 10")); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiPoint xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteMultiCurve() { LineString[] lineStrings = new LineString[2]; lineStrings[0] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "10 10, 20 20, 10 40")); lineStrings[1] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "40 40, 30 30, 40 20, 30 10")); Geometry geometry = GEOMETRY_FACTORY.createMultiLineString(lineStrings); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiCurve xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteMultiSurface() { Polygon[] polygons = new Polygon[2]; polygons[0] = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "40 40, 20 45, 45 30, 40 40")); polygons[1] = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "20 35, 10 30, 10 10, 30 5, 45 20, 20 35")); Geometry geometry = GEOMETRY_FACTORY.createMultiPolygon(polygons); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiSurface xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteMultiSurface2() { Polygon[] polygons = new Polygon[2]; polygons[0] = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "40 40, 20 45, 45 30, 40 40")); LinearRing shell = GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "20 35, 10 30, 10 10, 30 5, 45 20, 20 35")); LinearRing[] holes = new LinearRing[]{GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "30 20, 20 15, 20 25, 30 20"))}; polygons[1] = GEOMETRY_FACTORY.createPolygon(shell, holes); Geometry geometry = GEOMETRY_FACTORY.createMultiPolygon(polygons); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiSurface xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWriteMultiGeometry() { Geometry[] geometries = new Geometry[2]; geometries[0] = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "4 6")); geometries[1] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "4 6,7 10")); Geometry geometry = GEOMETRY_FACTORY.createGeometryCollection(geometries); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, GML_SRS_NAMESPACE, GMLDatatype.URI, new DimensionInfo(2, 2, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiGeometry xmlns:gml=\"http: assertEquals(expResult.trim(), result.trim()); }
@Test public void testWritePointEmpty() { Geometry geometry = GEOMETRY_FACTORY.createPoint(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:Point xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWriteLineStringEmpty() { Geometry geometry = GEOMETRY_FACTORY.createLineString(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:LineString xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWritePolygonEmpty() { Geometry geometry = GEOMETRY_FACTORY.createPolygon(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:Polygon xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWriteMultiPointEmpty() { Geometry geometry = GEOMETRY_FACTORY.createMultiPoint(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiPoint xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWriteMultiCurveEmpty() { Geometry geometry = GEOMETRY_FACTORY.createMultiLineString(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiCurve xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWriteMultiSurfaceEmpty() { Geometry geometry = GEOMETRY_FACTORY.createMultiPolygon(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiSurface xmlns:gml=\"http: assertEquals(expResult, result); }
@Test public void testWriteMultiGeometryEmpty() { Geometry geometry = GEOMETRY_FACTORY.createGeometryCollection(); GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, GMLDatatype.URI, new DimensionInfo(4, 3, 0)); String result = GMLWriter.write(geometryWrapper); String expResult = "<gml:MultiGeometry xmlns:gml=\"http: assertEquals(expResult, result); }