Revision 11178

View differences:

trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELayerHeaderTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.gpe.GPEErrorHandler;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id$
50
 * $Log$
51
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
52
 * Add the writting tests for the simple geometries
53
 *
54
 *
55
 */
56
/**
57
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
58
 */
59
public abstract class GPELayerHeaderTest extends GPEWriterBaseTest{
60

  
61
	/*
62
	 * (non-Javadoc)
63
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
64
	 */
65
	public void readObjects() {
66
	
67
	}
68

  
69
	/*
70
	 * (non-Javadoc)
71
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
72
	 */
73
	public void writeObjects() {
74
		getHandler().initialize();
75
		getHandler().startLayer("1", "Layer Header", "Layer header test", "23030");
76
		getHandler().startBbox("bbox", generateRandomBBox(),
77
				generateRandomBBox(),
78
				generateRandomBBox(),
79
				"23030");
80
		getHandler().endBbox();
81
		getHandler().endLayer();
82
		getHandler().close();		
83
	}
84

  
85
}
0 86

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELinearRingLayerTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import org.gvsig.gpe.GPEErrorHandler;
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
53
 * Add the writting tests for the simple geometries
54
 *
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public abstract class GPELinearRingLayerTest extends GPEWriterBaseTest{
61

  
62

  
63
	public void readObjects() {
64
		// TODO Auto-generated method stub
65
		
66
	}
67

  
68
	public void writeObjects() {
69
		getHandler().initialize();
70
		getHandler().startLayer("1", "Municipality", "Linear Ring layer test", "23030");
71
		getHandler().startBbox("bbox", generateRandomBBox(),
72
				generateRandomBBox(),
73
				generateRandomBBox(),
74
				"23030");
75
		getHandler().endBbox();
76
		getHandler().startFeature("Valencia","f1");
77
		getHandler().startElement("AREA", new Integer("200"), Integer.class);
78
		getHandler().endElement();
79
		getHandler().startLinearRing("lr1", generateRandomLinearRing(),
80
				generateRandomLinearRing(),
81
				generateRandomLinearRing(), "EPSG:23030");
82
		getHandler().endLinearRing();		
83
		getHandler().endFeature();
84
		getHandler().startFeature("Sagunto","f2");
85
		getHandler().startElement("AREA", new Integer("300"), Integer.class);
86
		getHandler().endElement();
87
		getHandler().startLinearRing("lr2", generateRandomLinearRing(),
88
				generateRandomLinearRing(),
89
				generateRandomLinearRing(), "EPSG:23030");
90
		getHandler().endLinearRing();		
91
		getHandler().endFeature();
92
		getHandler().endLayer();
93
		getHandler().close();		
94
	}
95

  
96
}
0 97

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEPolygonsLayerTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import org.gvsig.gpe.GPEErrorHandler;
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
53
 * Add the writting tests for the simple geometries
54
 *
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public abstract class GPEPolygonsLayerTest extends GPEWriterBaseTest{
61

  
62
	/*
63
	 * (non-Javadoc)
64
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
65
	 */
66
	public void readObjects() {
67
		// TODO Auto-generated method stub
68
		
69
	}
70

  
71
	/*
72
	 * (non-Javadoc)
73
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
74
	 */
75
	public void writeObjects() {
76
		getHandler().initialize();
77
		getHandler().startLayer("1", "Municipality", "Polygon layer test", "23030");
78
		getHandler().startBbox("bbox", generateRandomBBox(),
79
				generateRandomBBox(),
80
				generateRandomBBox(),
81
				"23030");
82
		getHandler().endBbox();
83
		getHandler().startFeature("Valencia","f1");
84
		getHandler().startElement("AREA", new Integer("200"), Integer.class);
85
		getHandler().endElement();
86
		getHandler().startPolygon("p1", generateRandomLinearRing(),
87
				generateRandomLinearRing(),
88
				generateRandomLinearRing(), "EPSG:23030");
89
		getHandler().endPolygon();		
90
		getHandler().endFeature();
91
		getHandler().startFeature("Sagunto","f2");
92
		getHandler().startElement("AREA", new Integer("300"), Integer.class);
93
		getHandler().endElement();
94
		getHandler().startPolygon("p2", generateRandomLinearRing(),
95
				generateRandomLinearRing(),
96
				generateRandomLinearRing(), "EPSG:23030");
97
		getHandler().endPolygon();		
98
		getHandler().endFeature();
99
		getHandler().endLayer();
100
		getHandler().close();		
101
	}
102

  
103
}
0 104

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEWriterBaseTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.gpe.GPEErrorHandler;
9
import org.gvsig.gpe.GPEErrorHandlerTest;
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id$
54
 * $Log$
55
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
56
 * Add the writting tests for the simple geometries
57
 *
58
 *
59
 */
60
/**
61
 * This class must be implementend by all the classes that
62
 * implements a GPE writer Parser. It creates a writer, write some
63
 * features and then uses a reader to compare the writting 
64
 * process
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public abstract class GPEWriterBaseTest extends TestCase{
68
	private GPEWriterHandler handler = null;
69
	private File fileTemp = new File("testdata/tmp/filetemp");
70
	
71
	/**
72
	 * Creates the writer
73
	 */
74
	public void setUp(){
75
		try {
76
			handler = getWriter(fileTemp, new GPEErrorHandlerTest());
77
		} catch (IOException e) {
78
			// TODO Auto-generated catch block
79
			e.printStackTrace();
80
		}
81
	}
82
	
83
	/**
84
	 * Delete the file
85
	 */
86
	public void tearDown(){
87
		//fileTemp.delete();
88
	}
89
	
90
	/**
91
	 * This test writes some objects into the file and then
92
	 * try to read the created file. It compare that the written
93
	 * objects are the same that the read them
94
	 */
95
	public void testWriter(){
96
		writeObjects();
97
		readObjects();
98
	}
99
	
100
	/**
101
	 * This method write somo objects into the writer handler
102
	 */
103
	public abstract void writeObjects();
104
	
105
	/**
106
	 * It read the objects and make all the comparations
107
	 *
108
	 */
109
	public abstract void readObjects();
110
	
111
	/**
112
	 * It creates a writer handler. 
113
	 * @param file
114
	 * @param errorHandler
115
	 * @return
116
	 */
117
	public abstract GPEWriterHandler getWriter(File file,GPEErrorHandler errorHandler) throws IOException;
118
		
119
	/**
120
	 * It creates a Random bbox coordinates. It return 
121
	 * 10 coordinates 
122
	 * @return
123
	 */
124
	protected double[] generateRandomCoordinates(){
125
		return generateRandomCoordinates(10);
126
	}
127
	
128
	/**
129
	 * It creates a Random bbox coordinates
130
	 * @param length
131
	 * The number of coordinates
132
	 * @return
133
	 */
134
	protected double[] generateRandomCoordinates(int length){
135
		double[] coord = new double[length];
136
		for (int i=0 ; i<coord.length ; i++){
137
			coord[i] = Math.random();
138
		}
139
		return coord;
140
	}
141
	
142
	/**
143
	 * It creates a Random linear ring. It return 
144
	 * 10 coordinates 
145
	 * @return
146
	 */
147
	protected double[] generateRandomLinearRing(){
148
		return generateRandomLinearRing(10);
149
	}
150
	
151
	
152
	/**
153
	 * It creates a random linear ring
154
	 * @param length
155
	 * @return
156
	 */
157
	protected double[] generateRandomLinearRing(int length){
158
		double[] coord = new double[length];
159
		for (int i=0 ; i<coord.length-1 ; i++){
160
			coord[i] = Math.random();
161
		}
162
		coord[length-1] = coord[0];
163
		return coord;
164
	}
165
	
166
	/**
167
	 * It creates a Random bbox coordinates
168
	 * @return
169
	 */
170
	protected double[] generateRandomBBox(){
171
		double[] coord = new double[2];
172
		for (int i=0 ; i<coord.length ; i++){
173
			coord[i] = Math.random();
174
		}
175
		return coord;
176
	}
177

  
178
	/**
179
	 * @return the handler
180
	 */
181
	public GPEWriterHandler getHandler() {
182
		return handler;
183
	}
184
}
0 185

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEPointsLayerTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.gpe.GPEErrorHandler;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id$
50
 * $Log$
51
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
52
 * Add the writting tests for the simple geometries
53
 *
54
 *
55
 */
56
/**
57
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
58
 */
59
public abstract class GPEPointsLayerTest extends GPEWriterBaseTest {
60
	
61
	/*
62
	 * (non-Javadoc)
63
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
64
	 */
65
	public void readObjects() {
66
		// TODO Auto-generated method stub
67
		
68
	}
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
73
	 */
74
	public void writeObjects() {
75
		getHandler().initialize();
76
		getHandler().startLayer("1", "Points Header", "Points layer test", "23030");
77
		getHandler().startBbox("bbox", generateRandomBBox(),
78
				generateRandomBBox(),
79
				generateRandomBBox(),
80
				"23030");
81
		getHandler().endBbox();
82
		getHandler().startFeature("New York","1");
83
		getHandler().startElement("POPULATION", new Integer("300000"), Integer.class);
84
		getHandler().endElement();
85
		getHandler().startPoint("p1", 2, 2, 2, "EPSG:23030");
86
		getHandler().endPoint();		
87
		getHandler().endFeature();
88
		getHandler().startFeature("Los Angeles","2");
89
		getHandler().startElement("POPULATION", new Integer("400000"), Integer.class);
90
		getHandler().endElement();
91
		getHandler().startPoint("p1", 1, 1, 1, "EPSG:23030");
92
		getHandler().endPoint();		
93
		getHandler().endFeature();
94
		getHandler().endLayer();
95
		getHandler().close();		
96
	}
97

  
98
}
0 99

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELineStringLayerTest.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.gpe.GPEErrorHandler;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id$
50
 * $Log$
51
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
52
 * Add the writting tests for the simple geometries
53
 *
54
 *
55
 */
56
/**
57
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
58
 */
59
public abstract class GPELineStringLayerTest extends GPEWriterBaseTest{
60

  
61
	/*
62
	 * (non-Javadoc)
63
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
64
	 */
65
	public void readObjects() {
66
		// TODO Auto-generated method stub
67
		
68
	}
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
73
	 */
74
	public void writeObjects() {
75
		getHandler().initialize();
76
		getHandler().startLayer("1", "Rivers", "Line string layer test", "23030");
77
		getHandler().startBbox("bbox", generateRandomBBox(),
78
				generateRandomBBox(),
79
				generateRandomBBox(),
80
				"23030");
81
		getHandler().endBbox();
82
		getHandler().startFeature("Turia","1");
83
		getHandler().startElement("LENGHT", new Integer("150"), Integer.class);
84
		getHandler().endElement();
85
		getHandler().startLineString("p1", generateRandomCoordinates(),
86
				generateRandomCoordinates(),
87
				generateRandomCoordinates(), "EPSG:23030");
88
		getHandler().endLineString();		
89
		getHandler().endFeature();
90
		getHandler().startFeature("Ebro","2");
91
		getHandler().startElement("LENGHT", new Integer("300"), Integer.class);
92
		getHandler().endElement();
93
		getHandler().startLineString("p1", generateRandomCoordinates(),
94
				generateRandomCoordinates(),
95
				generateRandomCoordinates(), "EPSG:23030");
96
		getHandler().endLineString();		
97
		getHandler().endFeature();
98
		getHandler().endLayer();
99
		getHandler().close();		
100
	}
101

  
102
}
0 103

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/readers/GPEReaderBaseTest.java
1
package org.gvsig.gpe.readers;
2

  
3
import java.io.File;
4

  
5
import junit.framework.TestCase;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id$
50
 * $Log$
51
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
52
 * Add the writting tests for the simple geometries
53
 *
54
 *
55
 */
56
/**
57
 * This class must be implementend by all the classes that
58
 * implements a GPE reader Parser. 
59
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
60
 */
61
public abstract class GPEReaderBaseTest extends TestCase {
62
	private File file = null;
63
	
64
	public void setUp(){
65
		file = new File(getFile());
66
	}
67
	
68
	/**
69
	 * Gets the GML file to open
70
	 * @return
71
	 */
72
	public abstract String getFile();
73
	
74
	/**
75
	 * Return the numbre of features
76
	 * @return
77
	 */
78
	public abstract int getNumFeatures();
79
			
80
	/**
81
	 * Compare the feature number i
82
	 * @param i
83
	 */
84
	public abstract void compareFeature(int i);
85
}
0 86

  
trunk/libraries/libGPE/src/org/gvsig/gpe/GPEParser.java
3 3
import java.io.FileNotFoundException;
4 4
import java.io.IOException;
5 5

  
6
import org.gvsig.gpe.writer.GPEWriterHandler;
6
import org.gvsig.gpe.writers.GPEWriterHandler;
7 7

  
8 8

  
9 9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
......
50 50
 *
51 51
 * $Id$
52 52
 * $Log$
53
 * Revision 1.5  2007-04-12 17:06:42  jorpiell
53
 * Revision 1.6  2007-04-13 07:17:54  jorpiell
54
 * Add the writting tests for the simple geometries
55
 *
56
 * Revision 1.5  2007/04/12 17:06:42  jorpiell
54 57
 * First GML writing tests
55 58
 *
56 59
 * Revision 1.4  2007/04/12 10:21:29  jorpiell
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/GPEWriterHandler.java
1
package org.gvsig.gpe.writers;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.gpe.GPEErrorHandler;
6
import org.gvsig.gpe.IGPEContentHandler;
7
import org.xml.sax.ErrorHandler;
8

  
9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10
 *
11
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
12
 *
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
26
 *
27
 * For more information, contact:
28
 *
29
 *  Generalitat Valenciana
30
 *   Conselleria d'Infraestructures i Transport
31
 *   Av. Blasco Ib??ez, 50
32
 *   46010 VALENCIA
33
 *   SPAIN
34
 *
35
 *      +34 963862235
36
 *   gvsig@gva.es
37
 *      www.gvsig.gva.es
38
 *
39
 *    or
40
 *
41
 *   IVER T.I. S.A
42
 *   Salamanca 50
43
 *   46005 Valencia
44
 *   Spain
45
 *
46
 *   +34 963163400
47
 *   dac@iver.es
48
 */
49
/* CVS MESSAGES:
50
 *
51
 * $Id$
52
 * $Log$
53
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
54
 * Add the writting tests for the simple geometries
55
 *
56
 * Revision 1.2  2007/04/12 17:06:42  jorpiell
57
 * First GML writing tests
58
 *
59
 * Revision 1.1  2007/04/12 10:20:40  jorpiell
60
 * Add the writer
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public abstract class GPEWriterHandler implements IGPEWriterHandler{
68
	private String format = null;
69
	private File file = null;
70
	private GPEErrorHandler errorHandler = null;
71
	
72
	public GPEWriterHandler(String format,File file,GPEErrorHandler errorHandler){
73
		this.format = format;
74
		this.file = file;
75
		this.errorHandler = errorHandler;
76
	}	
77

  
78
	/**
79
	 * @return the errorHandler
80
	 */
81
	public GPEErrorHandler getErrorHandler() {
82
		return errorHandler;
83
	}
84

  
85
	public void close() {
86
		// TODO Auto-generated method stub
87
		
88
	}
89

  
90
	public void endBbox() {
91
		// TODO Auto-generated method stub
92
		
93
	}
94

  
95
	public void endElement() {
96
		// TODO Auto-generated method stub
97
		
98
	}
99

  
100
	public void endInnerBoundary() {
101
		// TODO Auto-generated method stub
102
		
103
	}
104

  
105
	public void endLayer() {
106
		// TODO Auto-generated method stub
107
		
108
	}
109

  
110
	public void endLineString() {
111
		// TODO Auto-generated method stub
112
		
113
	}
114

  
115
	public void endLinearRing() {
116
		// TODO Auto-generated method stub
117
		
118
	}
119

  
120
	public void endOuterBoundary() {
121
		// TODO Auto-generated method stub
122
		
123
	}
124

  
125
	public void endPoint() {
126
		// TODO Auto-generated method stub
127
		
128
	}
129

  
130
	public void endPolygon() {
131
		// TODO Auto-generated method stub
132
		
133
	}
134

  
135
	public void initialize() {
136
		// TODO Auto-generated method stub
137
		
138
	}
139

  
140
	public void startBbox(String id, double[] x, double[] y, double[] z, String srs) {
141
		// TODO Auto-generated method stub
142
		
143
	}
144

  
145
	public void startElement(String name, Object value, Object type) {
146
		// TODO Auto-generated method stub
147
		
148
	}
149

  
150
	public void startInnerBoundary(String id, double[] x, double[] y, double[] z, String srs) {
151
		// TODO Auto-generated method stub
152
		
153
	}
154

  
155
	public void startLayer(String id, String name, String description, String srs) {
156
		// TODO Auto-generated method stub
157
		
158
	}
159

  
160
	public void startLineString(String id, double[] x, double[] y, double[] z, String srs) {
161
		// TODO Auto-generated method stub
162
		
163
	}
164

  
165
	public void startLinearRing(String id, double[] x, double[] y, double[] z, String srs) {
166
		// TODO Auto-generated method stub
167
		
168
	}
169

  
170
	public void startOuterBoundary(String id, double[] x, double[] y, double[] z, String srs) {
171
		// TODO Auto-generated method stub
172
		
173
	}
174

  
175
	public void startPoint(String id, double x, double y, double z, String srs) {
176
		// TODO Auto-generated method stub
177
		
178
	}
179

  
180
	public void startPolygon(String id, double[] x, double[] y, double[] z, String srs) {
181
		// TODO Auto-generated method stub
182
		
183
	}
184

  
185
	public void endFeature() {
186
		// TODO Auto-generated method stub
187
		
188
	}
189

  
190
	public void startFeature(String name, String id) {
191
		// TODO Auto-generated method stub
192
		
193
	}
194

  
195
	/**
196
	 * @return the file
197
	 */
198
	public File getFile() {
199
		return file;
200
	}
201

  
202
	/**
203
	 * @return the format
204
	 */
205
	public String getFormat() {
206
		return format;
207
	}	
208

  
209
}
0 210

  
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/IGPEWriterHandler.java
1
package org.gvsig.gpe.writers;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
/* CVS MESSAGES:
43
 *
44
 * $Id$
45
 * $Log$
46
 * Revision 1.1  2007-04-13 07:17:54  jorpiell
47
 * Add the writting tests for the simple geometries
48
 *
49
 * Revision 1.2  2007/04/12 17:06:42  jorpiell
50
 * First GML writing tests
51
 *
52
 * Revision 1.1  2007/04/12 10:20:40  jorpiell
53
 * Add the writer
54
 *
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public interface IGPEWriterHandler {
61
	
62
	public void initialize();
63
	
64
	public void close();
65
	
66
	public void startLayer(String id,String name,String description,String srs);
67
	
68
	public void endLayer();
69
	
70
	public void startBbox(String id,double[] x, double[] y, double[] z,String srs);
71
	
72
	public void endBbox();
73
	
74
	public void startElement(String name, Object value, Object type);
75
	
76
	public void endElement();
77
	
78
	public void startFeature(String name, String id);
79
	
80
	public void endFeature();
81
	
82
	public void startPoint(String id,double x, double y, double z, String srs);
83
	
84
	public void endPoint();
85
	
86
	public void startLineString(String id,double[] x, double[] y, double[] z, String srs);
87
	
88
	public void endLineString();
89
	
90
	public void startLinearRing(String id,double[] x, double[] y, double[] z, String srs);
91
	
92
	public void endLinearRing();
93
	
94
	public void startPolygon(String id,double[] x, double[] y, double[] z, String srs);
95
	
96
	public void endPolygon();
97
	
98
	public void startInnerBoundary(String id,double[] x, double[] y, double[] z, String srs);
99
	
100
	public void endInnerBoundary();
101
	
102
	public void startOuterBoundary(String id,double[] x, double[] y, double[] z, String srs);
103
	
104
	public void endOuterBoundary();
105
	
106
	
107
}
0 108

  
trunk/libraries/libGPE/.classpath
3 3
	<classpathentry kind="src" path="src"/>
4 4
	<classpathentry kind="src" path="src-test"/>
5 5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
6 7
	<classpathentry kind="output" path="bin"/>
7 8
</classpath>
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLWriteBaseTest.java
1
package org.gvsig.gpe.gml.writers;
2

  
3
import junit.framework.TestCase;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 * Revision 1.1  2007-04-12 17:06:44  jorpiell
50
 * First GML writing tests
51
 *
52
 *
53
 */
54
/**
55
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
56
 */
57
public abstract class GMLWriteBaseTest extends TestCase{
58
	
59
	protected double[] generateRandomCoordinates(){
60
		double[] coord = new double[10];
61
		for (int i=0 ; i<coord.length ; i++){
62
			coord[i] = Math.random();
63
		}
64
		return coord;
65
	}
66
	
67
	protected double[] generateRandomBBox(){
68
		double[] coord = new double[2];
69
		for (int i=0 ; i<coord.length ; i++){
70
			coord[i] = Math.random();
71
		}
72
		return coord;
73
	}
74
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLWriteLineStringLayerTest.java
1
package org.gvsig.gpe.gml.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.gpe.GPEErrorHandlerTest;
9
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandler;
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id$
54
 * $Log$
55
 * Revision 1.1  2007-04-12 17:06:44  jorpiell
56
 * First GML writing tests
57
 *
58
 *
59
 */
60
/**
61
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
62
 */
63
public class GMLWriteLineStringLayerTest extends GMLWriteBaseTest {
64
	public void test1() throws IOException{
65
		GPEGmlWriterHandler writer = new GPEGmlWriterHandler("GML",
66
				new File("testdata/tmp/lineStrings.gml"),
67
				new GPEErrorHandlerTest());
68
		writer.initialize();
69
		writer.startLayer("1", "Rivers", "Line string layer test", "23030");
70
		writer.startBbox("bbox", generateRandomBBox(),
71
				generateRandomBBox(),
72
				generateRandomBBox(),
73
				"23030");
74
		writer.endBbox();
75
		writer.startFeature("Turia","1");
76
		writer.startElement("LENGHT", new Integer("150"), Integer.class);
77
		writer.endElement();
78
		writer.startLineString("p1", generateRandomCoordinates(),
79
				generateRandomCoordinates(),
80
				generateRandomCoordinates(), "EPSG:23030");
81
		writer.endLineString();		
82
		writer.endFeature();
83
		writer.startFeature("Ebro","2");
84
		writer.startElement("LENGHT", new Integer("300"), Integer.class);
85
		writer.endElement();
86
		writer.startLineString("p1", generateRandomCoordinates(),
87
				generateRandomCoordinates(),
88
				generateRandomCoordinates(), "EPSG:23030");
89
		writer.endLineString();		
90
		writer.endFeature();
91
		writer.endLayer();
92
		writer.close();
93
	}
94

  
95
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLWriteLayerHeaderTest.java
1
package org.gvsig.gpe.gml.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import org.gvsig.gpe.GPEErrorHandlerTest;
7
import org.gvsig.gpe.GPERegister;
8
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandler;
9

  
10
import junit.framework.TestCase;
11

  
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id$
55
 * $Log$
56
 * Revision 1.1  2007-04-12 17:06:44  jorpiell
57
 * First GML writing tests
58
 *
59
 *
60
 */
61
/**
62
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63
 */
64
public class GMLWriteLayerHeaderTest extends GMLWriteBaseTest {
65
	
66
	public void test1() throws IOException{
67
		GPEGmlWriterHandler writer = new GPEGmlWriterHandler("GML",
68
				new File("testdata/tmp/header.gml"),
69
				new GPEErrorHandlerTest());
70
		writer.initialize();
71
		writer.startLayer("1", "Layer Header", "Layer header test", "23030");
72
		writer.startBbox("bbox", generateRandomBBox(),
73
				generateRandomBBox(),
74
				generateRandomBBox(),
75
				"23030");
76
		writer.endBbox();
77
		writer.endLayer();
78
		writer.close();
79
	}
80
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLWritePointsLayerTest.java
1
package org.gvsig.gpe.gml.writers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.gpe.GPEErrorHandlerTest;
9
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandler;
10

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff