01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.gml2.bindings;
17:
18: import com.vividsolutions.jts.geom.Coordinate;
19: import com.vividsolutions.jts.geom.Geometry;
20: import com.vividsolutions.jts.geom.GeometryFactory;
21: import com.vividsolutions.jts.geom.Polygon;
22: import org.geotools.xml.ElementInstance;
23: import org.geotools.xml.Node;
24:
25: public class GMLPolygonMemberTypeBindingTest extends
26: AbstractGMLBindingTest {
27: ElementInstance association;
28: ElementInstance geometry;
29:
30: protected void setUp() throws Exception {
31: super .setUp();
32:
33: association = createElement(GML.NAMESPACE, "myAssociation",
34: GML.POLYGONMEMBERTYPE, null);
35: geometry = createElement(GML.NAMESPACE, "myGeometry",
36: GML.POLYGONTYPE, null);
37: }
38:
39: public void testWithGeometry() throws Exception {
40: Node node = createNode(
41: association,
42: new ElementInstance[] { geometry },
43: new Object[] { new GeometryFactory().createPolygon(
44: new GeometryFactory()
45: .createLinearRing(new Coordinate[] {
46: new Coordinate(0, 0),
47: new Coordinate(1, 1),
48: new Coordinate(2, 2),
49: new Coordinate(0, 0) }), null) },
50: null, null);
51: GMLGeometryAssociationTypeBinding s1 = (GMLGeometryAssociationTypeBinding) getBinding(GML.GEOMETRYASSOCIATIONTYPE);
52: Geometry g = (Geometry) s1.parse(association, node, null);
53:
54: GMLPolygonMemberTypeBinding s2 = (GMLPolygonMemberTypeBinding) getBinding(GML.POLYGONMEMBERTYPE);
55: g = (Geometry) s2.parse(association, node, g);
56:
57: assertNotNull(g);
58: assertTrue(g instanceof Polygon);
59: }
60: }
|