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.LineString;
22: import org.geotools.xml.ElementInstance;
23: import org.geotools.xml.Node;
24:
25: public class GMLLineStringMemberTypeBindingTest 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.LINESTRINGMEMBERTYPE, null);
35: geometry = createElement(GML.NAMESPACE, "myGeometry",
36: GML.LINESTRINGTYPE, null);
37: }
38:
39: public void testWithGeometry() throws Exception {
40: Node node = createNode(association,
41: new ElementInstance[] { geometry },
42: new Object[] { new GeometryFactory()
43: .createLineString(new Coordinate[] {
44: new Coordinate(0, 0),
45: new Coordinate(1, 1) }) }, null, null);
46: GMLGeometryAssociationTypeBinding s1 = (GMLGeometryAssociationTypeBinding) getBinding(GML.GEOMETRYASSOCIATIONTYPE);
47: Geometry g = (Geometry) s1.parse(association, node, null);
48:
49: GMLLineStringMemberTypeBinding s2 = (GMLLineStringMemberTypeBinding) getBinding(GML.LINESTRINGMEMBERTYPE);
50: g = (Geometry) s2.parse(association, node, g);
51:
52: assertNotNull(g);
53: assertTrue(g instanceof LineString);
54: }
55: }
|