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.gml3.bindings;
17:
18: import javax.xml.namespace.QName;
19: import com.vividsolutions.jts.geom.Envelope;
20: import com.vividsolutions.jts.geom.Polygon;
21: import org.geotools.xml.*;
22:
23: /**
24: * Binding object for the type http://www.opengis.net/gml:BoundingShapeType.
25: *
26: * <p>
27: * <pre>
28: * <code>
29: * <complexType name="BoundingShapeType">
30: * <annotation>
31: * <documentation>Bounding shape.</documentation>
32: * </annotation>
33: * <sequence>
34: * <choice>
35: * <element ref="gml:Envelope"/>
36: * <element ref="gml:Null"/>
37: * </choice>
38: * </sequence>
39: * </complexType>
40: *
41: * </code>
42: * </pre>
43: * </p>
44: *
45: * @generated
46: */
47: public class BoundingShapeTypeBinding extends AbstractComplexBinding {
48: /**
49: * @generated
50: */
51: public QName getTarget() {
52: return GML.BoundingShapeType;
53: }
54:
55: /**
56: * <!-- begin-user-doc -->
57: * <!-- end-user-doc -->
58: *
59: * @generated modifiable
60: */
61: public Class getType() {
62: return Envelope.class;
63: }
64:
65: /**
66: * <!-- begin-user-doc -->
67: * <!-- end-user-doc -->
68: *
69: * @generated modifiable
70: */
71: public Object parse(ElementInstance instance, Node node,
72: Object value) throws Exception {
73: Envelope envelope = (Envelope) node
74: .getChildValue(Envelope.class);
75:
76: if (envelope == null) {
77: envelope = new Envelope();
78: envelope.setToNull();
79: }
80:
81: return envelope;
82: }
83:
84: public Object getProperty(Object object, QName name) {
85: if (name.equals(GML.Envelope)) {
86: if (object instanceof Envelope) {
87: return object;
88: }
89:
90: //check for a polygon
91: if (object instanceof Polygon) {
92: return ((Polygon) object).getEnvelopeInternal();
93: }
94: }
95:
96: return null;
97: }
98: }
|