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 java.util.List;
019: import javax.xml.namespace.QName;
020: import com.vividsolutions.jts.geom.Coordinate;
021: import com.vividsolutions.jts.geom.CoordinateSequence;
022: import com.vividsolutions.jts.geom.CoordinateSequenceFactory;
023: import com.vividsolutions.jts.geom.GeometryFactory;
024: import com.vividsolutions.jts.geom.LineString;
025: import com.vividsolutions.jts.geom.Point;
026: import org.opengis.geometry.DirectPosition;
027: import org.geotools.geometry.DirectPosition2D;
028: import org.geotools.xml.*;
029:
030: /**
031: * Binding object for the type http://www.opengis.net/gml:LineStringType.
032: *
033: * <p>
034: * <pre>
035: * <code>
036: * <complexType name="LineStringType">
037: * <annotation>
038: * <documentation>A LineString is a special curve that consists of a single segment with linear interpolation. It is defined by two or more coordinate
039: * tuples, with linear interpolation between them. It is backwards compatible with the LineString of GML 2, GM_LineString of ISO 19107 is
040: * implemented by LineStringSegment.</documentation>
041: * </annotation>
042: * <complexContent>
043: * <extension base="gml:AbstractCurveType">
044: * <sequence>
045: * <choice>
046: * <annotation>
047: * <documentation>GML supports two different ways to specify the control points of a line string. 1. A sequence of "pos"
048: * (DirectPositionType) or "pointProperty" (PointPropertyType) elements. "pos" elements are control points that are only part
049: * of this curve, "pointProperty" elements contain a point that may be referenced from other geometry elements or reference
050: * another point defined outside of this curve (reuse of existing points). 2. The "posList" element allows for a compact way to
051: * specifiy the coordinates of the control points, if all control points are in the same coordinate reference systems and belong
052: * to this curve only. The number of direct positions in the list must be at least two.</documentation>
053: * </annotation>
054: * <choice maxOccurs="unbounded" minOccurs="2">
055: * <element ref="gml:pos"/>
056: * <element ref="gml:pointProperty"/>
057: * <element ref="gml:pointRep">
058: * <annotation>
059: * <documentation>Deprecated with GML version 3.1.0. Use "pointProperty" instead. Included for backwards compatibility
060: * with GML 3.0.0.</documentation>
061: * </annotation>
062: * </element>
063: * <element ref="gml:coord">
064: * <annotation>
065: * <documentation>Deprecated with GML version 3.0. Use "pos" instead. The "coord" element is included for backwards
066: * compatibility with GML 2.</documentation>
067: * </annotation>
068: * </element>
069: * </choice>
070: * <element ref="gml:posList"/>
071: * <element ref="gml:coordinates">
072: * <annotation>
073: * <documentation>Deprecated with GML version 3.1.0. Use "posList" instead.</documentation>
074: * </annotation>
075: * </element>
076: * </choice>
077: * </sequence>
078: * </extension>
079: * </complexContent>
080: * </complexType>
081: *
082: * </code>
083: * </pre>
084: * </p>
085: *
086: * @generated
087: */
088: public class LineStringTypeBinding extends AbstractComplexBinding {
089: GeometryFactory gFactory;
090: CoordinateSequenceFactory csFactory;
091:
092: public LineStringTypeBinding(GeometryFactory gFactory,
093: CoordinateSequenceFactory csFactory) {
094: this .gFactory = gFactory;
095: this .csFactory = csFactory;
096: }
097:
098: /**
099: * @generated
100: */
101: public QName getTarget() {
102: return GML.LineStringType;
103: }
104:
105: /**
106: * <!-- begin-user-doc -->
107: * <!-- end-user-doc -->
108: *
109: * @generated modifiable
110: */
111: public Class getType() {
112: return LineString.class;
113: }
114:
115: public int getExecutionMode() {
116: return BEFORE;
117: }
118:
119: /**
120: * <!-- begin-user-doc -->
121: * <!-- end-user-doc -->
122: *
123: * @generated modifiable
124: */
125: public Object parse(ElementInstance instance, Node node,
126: Object value) throws Exception {
127: return GML3ParsingUtils.lineString(node, gFactory, csFactory);
128: }
129:
130: public Object getProperty(Object object, QName name)
131: throws Exception {
132: if (GML.posList.equals(name)) {
133: return GML3EncodingUtils.positions((LineString) object);
134: }
135:
136: return null;
137: }
138: }
|