Statistics
| Revision:

svn-gvsig-desktop / tags / v1_9_Build_1250 / extensions / extGPE-gvSIG / src / org / gvsig / fmap / drivers / gpe / writer / CoordinatesSequenceGeneralPath.java @ 31459

History | View | Annotate | Download (2.11 KB)

1 27093 jpiera
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program 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
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 Iver T.I.  {{Task}}
26
*/
27
28
package org.gvsig.fmap.drivers.gpe.writer;
29
30
import java.awt.geom.PathIterator;
31
import java.io.IOException;
32
33
import org.gvsig.gpe.parser.ICoordinateIterator;
34
import org.gvsig.gpe.writer.ICoordinateSequence;
35
36
public class CoordinatesSequenceGeneralPath implements ICoordinateSequence, ICoordinateIterator{
37
        private PathIterator it = null;
38
        int size = 0;
39 27133 jpiera
        boolean hasMoreGeoemtries = true;
40 27093 jpiera
41
        public CoordinatesSequenceGeneralPath(PathIterator it) {
42
                super();
43
                this.it = it;
44
        }
45
46
        public int getSize() {
47
                return size;
48
        }
49
50 27133 jpiera
        public void initialize(){
51
                size = 0;
52
        }
53
54
        public boolean hasMoreGeometries(){
55
                return hasMoreGeoemtries;
56
        }
57
58 27093 jpiera
        public ICoordinateIterator iterator() {
59
                return this;
60
        }
61
62
        public int getDimension() {
63
                return 2;
64
        }
65
66
        public boolean hasNext() throws IOException {
67 27133 jpiera
                if (it.isDone()){
68
                        hasMoreGeoemtries = false;
69
                        return false;
70
                }
71
                double[] coords = new double[2];
72
                int type = it.currentSegment(coords);
73
                if (type == PathIterator.SEG_CLOSE){
74
                        hasMoreGeoemtries = false;
75
                }
76
                return ((type != PathIterator.SEG_MOVETO) || (size == 0));
77 27093 jpiera
        }
78
79
        public void next(double[] buffer) throws IOException {
80
                it.currentSegment(buffer);
81
                it.next();
82
                size++;
83
        }
84
85
}