001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.gml3.bindings;
017:
018: import javax.xml.namespace.QName;
019: import com.vividsolutions.jts.geom.GeometryFactory;
020: import com.vividsolutions.jts.geom.LineString;
021: import com.vividsolutions.jts.geom.MultiLineString;
022: import org.geotools.xml.AbstractComplexBinding;
023: import org.geotools.xml.ElementInstance;
024: import org.geotools.xml.Node;
025:
026: /**
027: * Binding object for the type http://www.opengis.net/gml:CurveType.
028: *
029: * <p>
030: * <pre>
031: * <code>
032: * <complexType name="CurveType">
033: * <annotation>
034: * <documentation>Curve is a 1-dimensional primitive. Curves are continuous, connected, and have a measurable length in terms of the coordinate system.
035: * A curve is composed of one or more curve segments. Each curve segment within a curve may be defined using a different interpolation method. The curve segments are connected to one another, with the end point of each segment except the last being the start point of the next segment in the segment list.
036: * The orientation of the curve is positive.</documentation>
037: * </annotation>
038: * <complexContent>
039: * <extension base="gml:AbstractCurveType">
040: * <sequence>
041: * <element ref="gml:segments">
042: * <annotation>
043: * <documentation>This element encapsulates the segments of the curve.</documentation>
044: * </annotation>
045: * </element>
046: * </sequence>
047: * </extension>
048: * </complexContent>
049: * </complexType>
050: *
051: * </code>
052: * </pre>
053: * </p>
054: *
055: * @generated
056: */
057: public class CurveTypeBinding extends AbstractComplexBinding {
058: GeometryFactory gf;
059:
060: public CurveTypeBinding(GeometryFactory gf) {
061: this .gf = gf;
062: }
063:
064: /**
065: * @generated
066: */
067: public QName getTarget() {
068: return GML.CurveType;
069: }
070:
071: /**
072: * <!-- begin-user-doc -->
073: * <!-- end-user-doc -->
074: *
075: * @generated modifiable
076: */
077: public Class getType() {
078: //return Curve.class;
079: return MultiLineString.class;
080: }
081:
082: public int getExecutionMode() {
083: return BEFORE;
084: }
085:
086: /**
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: *
090: * @generated modifiable
091: */
092: public Object parse(ElementInstance instance, Node node,
093: Object value) throws Exception {
094: LineString[] segments = (LineString[]) node
095: .getChildValue("segments");
096:
097: return gf.createMultiLineString(segments);
098:
099: //return new Curve(segments, gf);
100: }
101:
102: public Object getProperty(Object object, QName name)
103: throws Exception {
104: if (GML.segments.equals(name)) {
105: //Curve curve = (Curve) object;
106: MultiLineString curve = (MultiLineString) object;
107: LineString[] segments = new LineString[curve
108: .getNumGeometries()];
109:
110: for (int i = 0; i < segments.length; i++) {
111: segments[i] = (LineString) curve.getGeometryN(i);
112: }
113:
114: return segments;
115: }
116:
117: return null;
118: }
119: }
|