Revision 42392 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/primitive/curve/line/AbstractLine.java

View differences:

AbstractLine.java
49 49
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
50 50
import org.gvsig.fmap.geom.primitive.GeneralPathX;
51 51
import org.gvsig.fmap.geom.primitive.IGeneralPathX;
52
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
52 53
import org.gvsig.fmap.geom.primitive.Point;
53 54

  
54 55
/**
......
64 65
    private static final Logger logger = LoggerFactory.getLogger(AbstractLine.class);
65 66

  
66 67
    protected ArrayListCoordinateSequence coordinates;
67
    protected PointJTS anyVertex;
68 68

  
69
    public class VertexIterator implements Iterator<Point> {
70

  
71
        private PointJTS vertex;
72
        private int current;
73

  
74
        public VertexIterator() {
75
            this.current = 0;
76
            if( getNumVertices()>0 ) {
77
                this.vertex = (PointJTS) getVertex(0).cloneGeometry();
78
            } else {
79
                this.vertex = null;
80
            }
81
        }
82

  
83
        @Override
84
        public boolean hasNext() {
85
            return this.current < getNumVertices() ;
86
        }
87

  
88
        @Override
89
        public Point next() {
90
            this.vertex.setJTSCoordinate(coordinates.get(current) );
91
            this.current++;
92
            return this.vertex;
93
        }
94

  
95
        @Override
96
        public void remove() {
97
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
98
        }
99

  
100
    }    
69 101
    /**
70 102
    *
71 103
    */
......
81 113
        super(type, subtype);
82 114
    }
83 115

  
116
    abstract public Point getVertex(int index);
117
    
118
    public Iterator<Point> iterator() {
119
        return new VertexIterator();
120
    }
121

  
84 122
    /*
85 123
     * (non-Javadoc)
86 124
     *
......
100 138
    public void addVertex(Point point) {
101 139
        point = fixPoint(point);
102 140
        coordinates.add(((PointJTS) point).getJTSCoordinate());
103
        anyVertex = (PointJTS) point;
104 141
    }
105 142

  
106 143
    /*
......
338 375
     * @see org.gvsig.fmap.geom.Geometry#getDimension()
339 376
     */
340 377
    public int getDimension() {
341
        return anyVertex.getDimension();
378
        return this.getGeometryType().getDimension();
342 379
    }
343 380

  
344 381
    /*
......
487 524
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#is3D()
488 525
     */
489 526
    public boolean is3D() {
490
        return anyVertex.is3D();
527
        int subtype = this.getGeometryType().getType();
528
        return subtype == Geometry.SUBTYPES.GEOM3D || subtype == Geometry.SUBTYPES.GEOM3DM;
491 529
    }
492 530

  
493 531
    protected boolean isClosed(){

Also available in: Unified diff