/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.gml3.bindings; import javax.xml.namespace.QName; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; import org.geotools.xml.Node; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.MultiLineString; /** * Binding object for the type http://www.opengis.net/gml:CurveType. * * <p> * <pre> * <code> * <complexType name="CurveType"> * <annotation> * <documentation>Curve is a 1-dimensional primitive. Curves are continuous, connected, and have a measurable length in terms of the coordinate system. * 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. * The orientation of the curve is positive.</documentation> * </annotation> * <complexContent> * <extension base="gml:AbstractCurveType"> * <sequence> * <element ref="gml:segments"> * <annotation> * <documentation>This element encapsulates the segments of the curve.</documentation> * </annotation> * </element> * </sequence> * </extension> * </complexContent> * </complexType> * * </code> * </pre> * </p> * * @generated * * * @source $URL$ */ public class CurveTypeBinding extends AbstractComplexBinding { protected GeometryFactory gf; public CurveTypeBinding(GeometryFactory gf) { this.gf = gf; } /** * @generated */ public QName getTarget() { return GML.CurveType; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Class getType() { //return Curve.class; return MultiLineString.class; } public int getExecutionMode() { return BEFORE; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { LineString[] segments = (LineString[]) node.getChildValue("segments"); return gf.createMultiLineString(segments); //return new Curve(segments, gf); } public Object getProperty(Object object, QName name) throws Exception { if ("segments".equals(name.getLocalPart())) { //Curve curve = (Curve) object; MultiLineString curve = (MultiLineString) object; LineString[] segments = new LineString[curve.getNumGeometries()]; for (int i = 0; i < segments.length; i++) { segments[i] = (LineString) curve.getGeometryN(i); } return segments; } return null; } }