GMLReader implements ParserReader { public static GMLReader extract(String gmlText) throws JDOMException, IOException { if (gmlText.isEmpty()) { gmlText = EMPTY_GML_TEXT; } SAXBuilder jdomBuilder = new SAXBuilder(); InputStream stream = new ByteArrayInputStream(gmlText.getBytes("UTF-8")); Document xmlDoc = jdomBuilder.build(stream); Element gmlElement = xmlDoc.getRootElement(); return new GMLReader(gmlElement); } protected  GMLReader(Element gmlElement); protected  GMLReader(Geometry geometry, int srsDimension, String srsURI); protected  GMLReader(Geometry geometry, int srsDimension); @Override Geometry getGeometry(); @Override String getSrsURI(); @Override CoordinateSequenceDimensions getDimensions(); @Override DimensionInfo getDimensionInfo(); static GMLReader extract(String gmlText); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testExtractPoint2() throws JDOMException, IOException { String gmlText = "<gml:Point xmlns:gml=\"http: GMLReader expResult = new GMLReader(GEOMETRY_FACTORY.createPoint(new CoordinateXY(11.0, 12.0)), 2, SRS_URI.OSGB36_CRS); GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractPoint3() throws JDOMException, IOException { String gmlText = "<gml:Point xmlns:gml=\"http: GMLReader expResult = new GMLReader(GEOMETRY_FACTORY.createPoint(new Coordinate(11.0, 12.0, 8.0)), 2, SRS_URI.OSGB36_CRS); GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractPoint4() throws JDOMException, IOException { String gmlText = "<gml:Point xmlns:gml=\"http: GMLReader expResult = new GMLReader(GEOMETRY_FACTORY.createPoint(new CoordinateXYZM(11.0, 12.0, 8.0, 5.0)), 2, SRS_URI.OSGB36_CRS); GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractPolygon() throws JDOMException, IOException { String gmlText = "<gml:Polygon xmlns:gml=\"http: Geometry geometry = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "30 10, 40 40, 20 40, 10 20, 30 10")); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractPolygonHole() throws JDOMException, IOException { 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); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:Polygon xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractLineString() throws JDOMException, IOException { Geometry geometry = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.1, 15.0 8.0")); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:LineString xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractLineStringSegment() throws JDOMException, IOException { Geometry geometry = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.1, 15.0 8.0, 20.0 14.0, 25.0 14.0")); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:Curve xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractArc() throws JDOMException, IOException { GeometricShapeFactory shapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY); shapeFactory.setCentre(new CoordinateXY(0, 0)); shapeFactory.setWidth(10); Geometry arc = shapeFactory.createArc(0, Math.PI); GMLReader expResult = new GMLReader(arc, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:Curve xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractCircle() throws JDOMException, IOException { GeometricShapeFactory shapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY); shapeFactory.setCentre(new CoordinateXY(0, 0)); shapeFactory.setWidth(10); Geometry circle = shapeFactory.createCircle().getExteriorRing(); GMLReader expResult = new GMLReader(circle, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:Curve xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractCircleByCentrePoint() throws JDOMException, IOException { GeometricShapeFactory shapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY); shapeFactory.setCentre(new Coordinate(0, 0)); shapeFactory.setSize(10); Geometry circle = shapeFactory.createCircle().getExteriorRing(); GMLReader expResult = new GMLReader(circle, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:Curve xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractMultiPoint() throws JDOMException, IOException { Geometry geometry = GEOMETRY_FACTORY.createMultiPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "10 40, 40 30, 20 20, 30 10")); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:MultiPoint xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractMutliCurve() throws JDOMException, IOException { 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); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:MultiCurve xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractMultiSurface() throws JDOMException, IOException { 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); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:MultiSurface xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractMultiSurface2() throws JDOMException, IOException { 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); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:MultiSurface xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }
@Test public void testExtractMultiGeometry() throws JDOMException, IOException { 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); GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS); String gmlText = "<gml:MultiGeometry xmlns:gml=\"http: GMLReader result = GMLReader.extract(gmlText); assertEquals(expResult, result); }