Revision 1527

View differences:

org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/parser/GPEReaderBaseTest.java
1
package org.gvsig.gpe.lib.impl.parser;
2

  
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
6
import java.io.InputStream;
7
import java.util.ArrayList;
8

  
9
import org.gvsig.gpe.lib.api.GPELocator;
10
import org.gvsig.gpe.lib.api.GPEManager;
11
import org.gvsig.gpe.lib.api.parser.IGPEContentHandler;
12
import org.gvsig.gpe.lib.api.parser.IGPEContentHandlerInmGeom;
13
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
14
import org.gvsig.gpe.lib.impl.containers.Layer;
15
import org.gvsig.gpe.lib.spi.GPEProviderLocator;
16
import org.gvsig.gpe.lib.spi.GPEProviderManager;
17
import org.gvsig.gpe.lib.spi.parser.IGPEParser;
18
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
19

  
20
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
21
 *
22
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
23
 *
24
 * This program is free software; you can redistribute it and/or
25
 * modify it under the terms of the GNU General Public License
26
 * as published by the Free Software Foundation; either version 2
27
 * of the License, or (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
37
 *
38
 * For more information, contact:
39
 *
40
 *  Generalitat Valenciana
41
 *   Conselleria d'Infraestructures i Transport
42
 *   Av. Blasco Ib??ez, 50
43
 *   46010 VALENCIA
44
 *   SPAIN
45
 *
46
 *      +34 963862235
47
 *   gvsig@gva.es
48
 *      www.gvsig.gva.es
49
 *
50
 *    or
51
 *
52
 *   IVER T.I. S.A
53
 *   Salamanca 50
54
 *   46005 Valencia
55
 *   Spain
56
 *
57
 *   +34 963163400
58
 *   dac@iver.es
59
 */
60
/* CVS MESSAGES:
61
 *
62
 * $Id: GPEReaderBaseTest.java 173 2007-11-06 12:10:57Z jpiera $
63
 * $Log$
64
 * Revision 1.7  2007/05/09 06:54:07  jorpiell
65
 * Change the File by URI
66
 *
67
 * Revision 1.6  2007/04/20 12:04:10  csanchez
68
 * Actualizacion protoripo libGPE, Añadidos test para el parser, parseo con XSOM
69
 *
70
 * Revision 1.5  2007/04/19 11:50:20  csanchez
71
 * Actualizacion protoripo libGPE
72
 *
73
 * Revision 1.4  2007/04/19 07:23:20  jorpiell
74
 * Add the add methods to teh contenhandler and change the register mode
75
 *
76
 * Revision 1.3  2007/04/14 16:06:35  jorpiell
77
 * Add the container classes
78
 *
79
 * Revision 1.2  2007/04/13 13:14:55  jorpiell
80
 * Created the base tests and add some methods to the content handler
81
 *
82
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
83
 * Add the writting tests for the simple geometries
84
 *
85
 *
86
 */
87
/**
88
 * This class must be implementend by all the classes that
89
 * implements a GPE reader Parser. 
90
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
91
 */
92
public abstract class GPEReaderBaseTest extends AbstractLibraryAutoInitTestCase {
93
	private File file = null;
94
	IGPEParser parser = null;
95
	IGPEContentHandlerInmGeom contenHandler = null;
96
	private IGPEErrorHandler errorHandler = null;
97
	private String parserName="FORMAT VERSION";
98
	private String parserDescription="default parser description";
99
	private GPEManager gpeManager = null;
100
	private GPEProviderManager gpeProviderManager = null;
101

  
102
	protected void doSetUp() throws Exception {
103
		gpeManager = GPELocator.getGPEManager();	
104
		gpeProviderManager = GPEProviderLocator.getGPEProviderManager();
105
	}	
106
	
107
	/**
108
	 * @return the gpeManager
109
	 */
110
	public GPEManager getGpeManager() {
111
		return gpeManager;
112
	}
113
	
114
	/**
115
	 * This test parses the file and make the 
116
	 * asserts.
117
	 * @throws Exception
118
	 */
119
	public void testParse() throws Exception{
120
		System.out.println("INFO: Parser registrado");
121
		file = new File(getClass().getClassLoader().getResource(getResourceName()).getFile());
122
		
123
		System.out.println("INFO: Abriendo Fichero: "+file.getName());
124
		//assertEquals(gpeManager.accept(file.toURI()),true);
125
		System.out.println("INFO: Existe parser registrado para el fomato ");
126
		parser = gpeProviderManager.createParserByClass(getGPEParserClass().getName());
127
		System.out.println("INFO: Creado el parser ");
128
		assertNotNull(parser);
129
		parseFile();
130
		parseInputStream();		
131
	}
132
	
133
	/**
134
	 * Parses the file
135
	 */
136
	private void parseFile(){
137
		System.out.println("INFO: PARSING THE FILE...");
138
		parser.parse(getContenHandler() , getErrorHandler(), file.toURI());
139
		System.out.println("INFO: ??? SUCCESS !!!");
140
		makeAsserts();
141
	}
142
	
143
	/**
144
	 * Parses the file like an inputstream
145
	 * @throws FileNotFoundException
146
	 */
147
	private void parseInputStream() throws Exception{
148
		InputStream is = getInputStream();
149
		errorHandler = null;
150
		contenHandler = null;
151
		System.out.println("INFO: PARSING THE INPUTSTREAM...");
152
		parser.parse(getContenHandler(), getErrorHandler(), is);
153
		System.out.println("INFO: ??? SUCCESS !!!");
154
		makeAsserts();
155
	}	
156
	
157
	/**
158
	 * This method has to be override by the tests that use
159
	 * other InputStream (KMZ...)
160
	 * @return
161
	 * @throws FileNotFoundException
162
	 */
163
	public InputStream getInputStream() throws Exception{
164
		return new FileInputStream(new File(getClass().getClassLoader().getResource(getResourceName()).getFile()));		
165
	}
166
	
167
	/**
168
	 * This method must be used by the subclasses
169
	 * to make the comparations. With getLayers
170
	 * it can retrieve the parsed layers
171
	 */
172
	public abstract void makeAsserts();
173
	
174
	/**
175
	 * Each test must to return its parser name
176
	 * to register it before to start the parsing
177
	 * process
178
	 */
179
	public String getGPEParserName(){
180
		return parserName;
181
	}
182
	
183
	/**
184
	 * Each test must to return its parser description
185
	 * to register it before to start the parsing
186
	 * process
187
	 */
188
	public String getGPEParserDescription(){
189
		return parserDescription ;
190
	}
191
	/**
192
	 * Each test must to return its parser name
193
	 * to register it before to start the parsing
194
	 * process
195
	 */
196
	public void setGPEParserName(String name){
197
		parserName=name;
198
	}
199
	
200
	/**
201
	 * Each test must to return its parser description
202
	 * to register it before to start the parsing
203
	 * process
204
	 */
205
	public void setGPEParserDescription(String description){
206
		parserDescription=description;
207
	}
208
	/**
209
	 * Each test must to return its parser class
210
	 * that will be used to create new parsers.
211
	 */
212
	public abstract Class getGPEParserClass();
213
	
214
	/**
215
	 * Gets the GML file to open
216
	 * @return
217
	 */
218
	public abstract String getResourceName();
219
	
220
	/**
221
	 * Gets a list of parsed layers
222
	 * @return
223
	 */
224
	public Layer[] getLayers(){
225
		ArrayList layers = ((GPEContentHandlerAdapterTest)parser.getContentHandler()).getLayers();
226
		Layer[] aLayers = new Layer[layers.size()];
227
		for (int i=0 ; i<layers.size() ; i++){
228
			aLayers[i] = (Layer)layers.get(i);
229
		}
230
		return aLayers;
231
	}
232
	
233
	/**
234
	 * @return the contenHandler
235
	 */
236
	public IGPEContentHandlerInmGeom getContenHandler() {
237
		if (contenHandler == null){
238
			contenHandler = new GPEContentHandlerAdapterTest(new GPEContentHandlerTest());
239
		}
240
		return contenHandler;
241
	}
242

  
243
	/**
244
	 * @return the errorHandler
245
	 */
246
	public IGPEErrorHandler getErrorHandler() {
247
		if (errorHandler == null){
248
			errorHandler = new GPEErrorHandlerTest();
249
		}
250
		return errorHandler;
251
	}
252
	
253
}
0 254

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/parser/GPEErrorHandlerTest.java
1
package org.gvsig.gpe.lib.impl.parser;
2

  
3

  
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: GPEErrorHandlerTest.java 144 2007-06-07 14:53:59Z jorpiell $
48
 * $Log$
49
 * Revision 1.6  2007/06/07 14:52:28  jorpiell
50
 * Add the schema support
51
 *
52
 * Revision 1.5  2007/05/16 09:27:55  jorpiell
53
 * Added two arrays to manage exceptions
54
 *
55
 * Revision 1.4  2007/04/19 07:23:20  jorpiell
56
 * Add the add methods to teh contenhandler and change the register mode
57
 *
58
 * Revision 1.3  2007/04/17 07:53:55  jorpiell
59
 * Before to start a new parsing process, the initialize method of the content handlers is throwed
60
 *
61
 * Revision 1.2  2007/04/13 13:14:55  jorpiell
62
 * Created the base tests and add some methods to the content handler
63
 *
64
 * Revision 1.1  2007/04/12 17:06:42  jorpiell
65
 * First GML writing tests
66
 *
67
 *
68
 */
69
/**
70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
71
 */
72
public class GPEErrorHandlerTest extends GPEErrorHandler{
73

  
74
}
0 75

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/parser/GPEContentHandlerTest.java
1
package org.gvsig.gpe.lib.impl.parser;
2

  
3
import java.io.IOException;
4
import java.util.ArrayList;
5

  
6
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
7
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
8
import org.gvsig.gpe.lib.impl.containers.Bbox;
9
import org.gvsig.gpe.lib.impl.containers.Curve;
10
import org.gvsig.gpe.lib.impl.containers.Element;
11
import org.gvsig.gpe.lib.impl.containers.Feature;
12
import org.gvsig.gpe.lib.impl.containers.Geometry;
13
import org.gvsig.gpe.lib.impl.containers.Layer;
14
import org.gvsig.gpe.lib.impl.containers.LineString;
15
import org.gvsig.gpe.lib.impl.containers.LinearRing;
16
import org.gvsig.gpe.lib.impl.containers.MetaData;
17
import org.gvsig.gpe.lib.impl.containers.MultiCurve;
18
import org.gvsig.gpe.lib.impl.containers.MultiGeometry;
19
import org.gvsig.gpe.lib.impl.containers.MultiLineString;
20
import org.gvsig.gpe.lib.impl.containers.MultiPoint;
21
import org.gvsig.gpe.lib.impl.containers.MultiPolygon;
22
import org.gvsig.gpe.lib.impl.containers.Point;
23
import org.gvsig.gpe.lib.impl.containers.Polygon;
24
import org.gvsig.gpe.lib.impl.containers.Time;
25
import org.gvsig.xmlpull.lib.api.stream.IQName;
26

  
27
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
28
 *
29
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
30
 *
31
 * This program is free software; you can redistribute it and/or
32
 * modify it under the terms of the GNU General Public License
33
 * as published by the Free Software Foundation; either version 2
34
 * of the License, or (at your option) any later version.
35
 *
36
 * This program is distributed in the hope that it will be useful,
37
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39
 * GNU General Public License for more details.
40
 *
41
 * You should have received a copy of the GNU General Public License
42
 * along with this program; if not, write to the Free Software
43
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
44
 *
45
 * For more information, contact:
46
 *
47
 *  Generalitat Valenciana
48
 *   Conselleria d'Infraestructures i Transport
49
 *   Av. Blasco Ib??ez, 50
50
 *   46010 VALENCIA
51
 *   SPAIN
52
 *
53
 *      +34 963862235
54
 *   gvsig@gva.es
55
 *      www.gvsig.gva.es
56
 *
57
 *    or
58
 *
59
 *   IVER T.I. S.A
60
 *   Salamanca 50
61
 *   46005 Valencia
62
 *   Spain
63
 *
64
 *   +34 963163400
65
 *   dac@iver.es
66
 */
67
/* CVS MESSAGES:
68
 *
69
 * $Id: GPEContentHandlerTest.java 202 2007-11-27 12:00:11Z jpiera $
70
 * $Log$
71
 * Revision 1.14  2007/06/07 14:52:28  jorpiell
72
 * Add the schema support
73
 *
74
 * Revision 1.13  2007/05/15 12:09:41  jorpiell
75
 * The bbox is linked to the feature
76
 *
77
 * Revision 1.12  2007/05/15 11:54:35  jorpiell
78
 * A wrong label fixed
79
 *
80
 * Revision 1.11  2007/05/15 07:28:34  jorpiell
81
 * Children Element printed
82
 *
83
 * Revision 1.10  2007/05/14 09:29:34  jorpiell
84
 * Add some comments when an element is added
85
 *
86
 * Revision 1.9  2007/05/09 10:25:45  jorpiell
87
 * Add the multiGeometries
88
 *
89
 * Revision 1.8  2007/05/09 08:35:58  jorpiell
90
 * fixed an exception
91
 *
92
 * Revision 1.7  2007/05/02 11:46:07  jorpiell
93
 * Writing tests updated
94
 *
95
 * Revision 1.6  2007/04/26 14:39:12  jorpiell
96
 * Add some tests
97
 *
98
 * Revision 1.5  2007/04/19 07:23:20  jorpiell
99
 * Add the add methods to teh contenhandler and change the register mode
100
 *
101
 * Revision 1.4  2007/04/17 07:53:55  jorpiell
102
 * Before to start a new parsing process, the initialize method of the content handlers is throwed
103
 *
104
 * Revision 1.3  2007/04/14 16:06:35  jorpiell
105
 * Add the container classes
106
 *
107
 * Revision 1.2  2007/04/13 13:14:55  jorpiell
108
 * Created the base tests and add some methods to the content handler
109
 *
110
 * Revision 1.1  2007/04/12 17:06:42  jorpiell
111
 * First GML writing tests
112
 *
113
 *
114
 */
115
/**
116
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
117
 */
118
public class GPEContentHandlerTest extends GPEContentHandler{
119
	private String tab = "";
120
	private ArrayList layers = new ArrayList();
121

  
122
	/**
123
	 * @return the layers without parent layer
124
	 */
125
	public ArrayList getLayers() {
126
		ArrayList newLayers = new ArrayList();
127
		for (int i=0 ; i<layers.size() ; i++){
128
			if (((Layer)layers.get(i)).getParentLayer() == null){
129
				newLayers.add(layers.get(i));
130
			}
131
		}
132
		return newLayers;
133
	}
134

  
135
	public void addNameToFeature(Object feature, String name){
136
		System.out.print(tab + "Feature name changed: " + name + "\n");
137
		((Feature)feature).setName(name);
138
	}
139

  
140
	public void endFeature(Object feature) {
141
		System.out.print(tab + "End Feature\n");
142
	}
143

  
144
	public void initialize(){
145
		layers = new ArrayList();
146
	}
147

  
148
	public void addBboxToFeature(Object bbox, Object feature) {
149
		((Feature)feature).setBbox(bbox);
150

  
151
	}
152

  
153
	public void addBboxToLayer(Object bbox, Object layer) {
154
		Bbox box = (Bbox)bbox;
155
		System.out.print(tab + "Layer bbox Added:\n");
156
		tab = tab + "\t";
157
		System.out.print(tab + "MINX: " + box.getMinX() + "\n");
158
		System.out.print(tab + "MINY: " + box.getMinY() + "\n");
159
		System.out.print(tab + "MINZ: " + box.getMinZ() + "\n");
160
		System.out.print(tab + "MAXX: " + box.getMaxX() + "\n");
161
		System.out.print(tab + "MAXY: " + box.getMaxY() + "\n");
162
		System.out.print(tab + "MAXZ: " + box.getMaxZ() + "\n");
163
		System.out.print(tab + "SRS: " + box.getSrs() + "\n");
164
		tab = tab.substring(0, tab.length()-1);
165
		((Layer)layer).setBbox(bbox);
166
	}
167

  
168
	public void addDescriptionToLayer(String description, Object layer) {
169
		System.out.print(tab + "Layer description changed: " + description + "\n");
170
		((Layer)layer).setDescription(description);
171
	}
172

  
173
	public void addElementToFeature(Object element, Object feature) {
174
		Element elem = (Element)element;
175
		tab = tab + "\t";
176
		System.out.print(tab + "Add Element " + elem.getName() + "=" +
177
				elem.getValue() + " to Feature\n");
178
		printChildElements(elem);
179
		tab = tab.substring(0, tab.length()-1);
180
		((Feature)feature).addElement(element);
181
	}
182

  
183
	/**
184
	 * Print the element children
185
	 * @param element to print
186
	 */
187
	private void printChildElements(Element element){
188
		tab = tab + "\t";
189
		for (int i=0 ; i< element.getElements().size() ; i++){
190
			Element child = element.getElementAt(i);
191
			System.out.print(tab + "- Element " + child.getName() + "=" +
192
					child.getValue() + "\n");
193
			printChildElements(child);
194
		}
195
		tab = tab.substring(0, tab.length()-1);
196
	}
197

  
198
	public void addFeatureToLayer(Object feature, Object layer) {
199
		((Layer)layer).addFeature(feature);
200

  
201
	}
202

  
203
	public void addGeometryToFeature(Object geometry, Object feature) {
204
		((Feature)feature).setGeometry(geometry);
205

  
206
	}
207

  
208
	public void addInnerPolygonToPolygon(Object innerPolygon, Object polygon) {
209
		((Polygon)polygon).addInnerBoundary(innerPolygon);
210

  
211
	}
212

  
213
	public void addNameToFeature(String name, Object feature) {
214
		((Feature)feature).setName(name);
215

  
216
	}
217

  
218
	public void addNameToLayer(String name, Object layer) {
219
		System.out.print(tab + "Layer name changed: " + name + "\n");
220
		((Layer)layer).setName(name);
221
	}
222

  
223
	public void addParentElementToElement(Object parent, Object element) {
224
		((Element)element).setParentElement(parent);
225

  
226
	}
227

  
228
	public void addParentLayerToLayer(Object parent, Object layer) {
229
		((Layer)layer).setParentLayer(parent);
230

  
231
	}
232

  
233
	public void addSrsToLayer(String srs, Object layer) {
234
		((Layer)layer).setSrs(srs);
235

  
236
	}
237

  
238

  
239
	public Object startBbox(String id, ICoordinateIterator coords, String srs) {
240
		Bbox bbox = new Bbox(coords.getDimension());
241
		double[] min = new double[coords.getDimension()];
242
		double[] max = new double[coords.getDimension()];
243
		try {
244
			if (coords.hasNext()){
245
				coords.next(min);
246
				bbox.addCoordinate(min);
247
				if (coords.hasNext()){
248
					coords.next(max);
249
					bbox.addCoordinate(max);
250
				}
251
			}
252
		} catch (IOException e) {
253
			e.printStackTrace();
254
		}
255
		bbox.setId(id);
256
		bbox.setSrs(srs);
257
		return bbox;
258
	}
259

  
260
	public void endBbox(Object bbox) {
261
		// TODO Ap?ndice de m?todo generado autom?ticamente
262
	}
263

  
264
	public Object startElement(String namespace, String name, Object value,  IAttributesIterator iterator, Object parentElement) {
265
		Element element = new Element();
266
		element.setParentElement(parentElement);
267
		element.setName(name);
268
		element.setValue(value);
269
		return element;
270
	}
271

  
272
	public void endElement(Object element) {
273
		// TODO Ap?ndice de m?todo generado autom?ticamente
274

  
275
	}
276

  
277
	public Object startFeature(String id, String namspace, String name, IAttributesIterator iterator, Object layer) {
278
		System.out.print(tab + "Start Feature, ID: " +  id + " NAME: " + name + "\n");
279
		Feature feature = new Feature();
280
		feature.setName(name);
281
		feature.setId(id);
282
		if (layer != null){
283
			addFeatureToLayer(feature, layer);
284
		}
285
		return feature;
286
	}
287

  
288
	public Object startInnerPolygon(String id, ICoordinateIterator coords, String srs) {
289
		tab = tab + "\t";
290
		System.out.print(tab + "Start InnerPolygon, SRS:" + srs + "\n");
291
		tab = tab + "\t";
292
		Polygon inner = new Polygon();
293
		try {
294
			while(coords.hasNext()){
295
				double[] buffer = new double[coords.getDimension()];
296
				coords.next(buffer);
297
				inner.addCoordinate(buffer);
298
				System.out.print(tab);
299
				for (int i=0 ; i<buffer.length ; i++){
300
					System.out.print(buffer[i]);
301
					if (i<buffer.length-1){
302
						System.out.print(",");
303
					}
304
				}
305
				System.out.print("\n");
306
			}
307
		} catch (IOException e) {
308
			e.printStackTrace();
309
		}
310
		inner.setId(id);
311
		inner.setSrs(srs);
312
		tab = tab.substring(0, tab.length()-2);
313
		return inner;
314
	}
315

  
316
	/*
317
	 * (non-Javadoc)
318
	 * @see org.gvsig.gpe.IGPEContentHandler#endInnerPolygon(java.lang.Object)
319
	 */
320
	public void endInnerPolygon(Object polygon){
321
		tab = tab + "\t";
322
		System.out.print(tab + "End InnerPolygon\n");
323
		tab = tab.substring(0, tab.length()-1);
324
	}
325

  
326

  
327
	public Object startLayer(String id, String namespace, String name, String description, String srs,  IAttributesIterator iterator, Object parentLayer, Object bBox) {
328
		System.out.print(tab + "Start Layer, ID: " +  id + " NAME: " + name + "\n");
329
		tab = tab + "\t";
330
		Layer layer = new Layer();
331
		layer.setId(id);
332
		layer.setName(name);
333
		layer.setDescription(description);
334
		layer.setSrs(srs);
335
		layer.setBbox(bBox);
336
		layer.setParentLayer(parentLayer);
337
		if (parentLayer != null){
338
			((Layer)parentLayer).addLayer(layer);
339
		}
340
		layers.add(layer);
341
		return layer;
342
	}
343

  
344
	public void endLayer(Object layer) {
345
		tab = tab.substring(0, tab.length()-1);
346
		System.out.print(tab + "End Layer\n");
347
	}
348

  
349
	public Object startLineString(String id, ICoordinateIterator coords, String srs) {
350
		tab = tab + "\t";
351
		System.out.print(tab + "Start LineString, SRS:" + srs + "\n");
352
		tab = tab + "\t";
353
		LineString lineString = new LineString();
354
		try {
355
			while(coords.hasNext()){
356
				double[] buffer = new double[coords.getDimension()];
357
				coords.next(buffer);
358
				lineString.addCoordinate(buffer);
359
				System.out.print(tab);
360
				for (int i=0 ; i<buffer.length ; i++){
361
					System.out.print(buffer[i]);
362
					if (i<buffer.length-1){
363
						System.out.print(",");
364
					}
365
				}
366
				System.out.print("\n");
367
			}
368
		} catch (IOException e) {
369
			e.printStackTrace();
370
		}
371
		lineString.setId(id);
372
		lineString.setSrs(srs);
373
		tab = tab.substring(0, tab.length()-2);
374
		return lineString;
375
	}
376

  
377
	public void endLineString(Object line) {
378
		System.out.print(tab + "\t"+ "End LineString:\n");
379
	}
380

  
381
	public Object startPoint(String id, ICoordinateIterator coords, String srs) {
382
		tab = tab + "\t";
383
		System.out.print(tab + "Start Point, SRS:" + srs + "\n");
384
		tab = tab + "\t";
385
		Point point = new Point();
386
		double[] buffer = new double[coords.getDimension()];
387
		try {
388
			if (coords.hasNext()){
389
				coords.next(buffer);
390
				point.setCoordinates(buffer);
391
				System.out.print(tab);
392
				for (int i=0 ; i<buffer.length ; i++){
393
					System.out.print(buffer[i]);
394
					if (i<buffer.length-1){
395
						System.out.print(",");
396
					}
397
				}
398
				System.out.print("\n");
399
			}
400
		} catch (IOException e) {
401
			e.printStackTrace();
402
		}
403

  
404
		point.setId(id);
405
		point.setSrs(srs);
406
		tab = tab.substring(0, tab.length()-2);
407
		return point;
408
	}
409

  
410
	public void endPoint(Object point) {
411
		System.out.print(tab + "\t" + "End Point\n");
412
	}
413

  
414
	public Object startPolygon(String id, ICoordinateIterator coords, String srs) {
415
		tab = tab + "\t";
416
		System.out.print(tab + "Start Polygon, SRS:" + srs + "\n");
417
		tab = tab + "\t";
418
		Polygon polygon = new Polygon();
419
		try {
420
			while(coords.hasNext()){
421
				double[] buffer = new double[coords.getDimension()];
422
				coords.next(buffer);
423
				polygon.addCoordinate(buffer);
424
				System.out.print(tab);
425
				for (int i=0 ; i<buffer.length ; i++){
426
					System.out.print(buffer[i]);
427
					if (i<buffer.length-1){
428
						System.out.print(",");
429
					}
430
				}
431
				System.out.print("\n");
432
			}
433
		} catch (IOException e) {
434
			e.printStackTrace();
435
		}
436
		polygon.setId(id);
437
		polygon.setSrs(srs);
438
		tab = tab.substring(0, tab.length()-2);
439
		return polygon;
440
	}
441

  
442

  
443
	public void endPolygon(Object polygon) {
444
		System.out.print(tab + "\t"+ "End Polygon\n");
445
	}
446

  
447

  
448
	public Object startLinearRing(String id, ICoordinateIterator coords, String srs) {
449
		System.out.print(tab + "Start LinearRing, SRS:" + srs + "\n");
450
		tab = tab + "\t";
451
		LinearRing linearRing = new LinearRing();
452
		try {
453
			while(coords.hasNext()){
454
				double[] buffer = new double[coords.getDimension()];
455
				coords.next(buffer);
456
				linearRing.addCoordinate(buffer);
457
				System.out.print(tab);
458
				for (int i=0 ; i<buffer.length ; i++){
459
					System.out.print(buffer[i]);
460
					if (i<buffer.length-1){
461
						System.out.print(",");
462
					}
463
				}
464
				System.out.print("\n");
465
			}
466
		} catch (IOException e) {
467
			e.printStackTrace();
468
		}
469
		linearRing.setId(id);
470
		linearRing.setSrs(srs);
471
		tab = tab.substring(0, tab.length()-1);
472
		return linearRing;
473
	}
474

  
475

  
476
	public void endLinearRing(Object linearRing) {
477
		System.out.print(tab + "End LinearRing\n");
478
	}
479

  
480

  
481
	public Object startMultiPoint(String id, String srs) {
482
		System.out.print(tab + "Start MultiPoint, ID: " + id + ", SRS:" + srs + "\n");
483
		tab = tab + "\t";
484
		MultiPoint multiPoint = new MultiPoint();
485
		multiPoint.setId(id);
486
		multiPoint.setSrs(srs);
487
		return multiPoint;
488
	}
489

  
490
	public void endMultiPoint(Object multiPoint) {
491
		tab = tab.substring(0, tab.length()-1);
492
		System.out.print(tab + "End MultiPoint\n");
493
	}
494

  
495
	public void addPointToMultiPoint(Object point, Object multiPoint) {
496
		System.out.print(tab + "Add Point to MultiPoint");
497
		((MultiPoint)multiPoint).addPoint((Point)point);
498
	}
499

  
500
	public Object startMultiLineString(String id, String srs) {
501
		System.out.print(tab + "Start MultiLineString, ID: " + id + ", SRS:" + srs + "\n");
502
		tab = tab + "\t";
503
		MultiLineString multiLineString = new MultiLineString();
504
		multiLineString.setId(id);
505
		multiLineString.setSrs(srs);
506
		return multiLineString;
507
	}
508

  
509
	public void endMultiLineString(Object multiLineString) {
510
		tab = tab.substring(0, tab.length()-1);
511
		System.out.print(tab + "End MultiLineString\n");
512
	}
513

  
514
	public void addLineStringToMultiLineString(Object lineString, Object multiLineString) {
515
		System.out.print(tab + "Add LineString to MultiLineString");
516
		((MultiLineString)multiLineString).addLineString((LineString)lineString);
517
	}
518

  
519
	public Object startMultiPolygon(String id, String srs) {
520
		System.out.print(tab + "Start MultiPolygon, ID: " + id + ", SRS:" + srs + "\n");
521
		tab = tab + "\t";
522
		MultiPolygon multiPolygon = new MultiPolygon();
523
		multiPolygon.setId(id);
524
		multiPolygon.setSrs(srs);
525
		return multiPolygon;
526
	}
527

  
528
	public void endMultiPolygon(Object multiPolygon) {
529
		tab = tab.substring(0, tab.length()-1);
530
		System.out.print(tab + "End MultiPolygon\n");
531
	}
532

  
533
	public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) {
534
		System.out.print(tab + "Add Polygon to MultiPolygon");
535
		((MultiPolygon)multiPolygon).addPolygon((Polygon)polygon);
536
	}
537

  
538
	public Object startMultiGeometry(String id, String srs) {
539
		System.out.print(tab + "Start MultiGeometry, ID: " + id + ", SRS:" + srs + "\n");
540
		tab = tab + "\t";
541
		MultiGeometry multiGeometry = new MultiGeometry();
542
		multiGeometry.setId(id);
543
		multiGeometry.setSrs(srs);
544
		return multiGeometry;
545
	}
546

  
547
	public void endMultiGeometry(Object multiGeometry) {
548
		tab = tab.substring(0, tab.length()-1);
549
		System.out.print(tab + "End MultiGeometry\n");
550
	}
551

  
552
	public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) {
553
		if (geometry instanceof Point){
554
			System.out.print(tab + "Add Point to MultiGeometry");
555
		}else if (geometry instanceof LineString){
556
			System.out.print(tab + "Add LineString to MultiGeometry");
557
		}else if (geometry instanceof Polygon){
558
			System.out.print(tab + "Add Polygon to MultiGeometry");
559
		}else if (geometry instanceof Curve){
560
			System.out.print(tab + "Add LineString to Curve");
561
		}else {
562
			System.out.print(tab + "Add Geometry to MultiGeometry");
563
		}
564
		((MultiGeometry)multiGeometry).addGeometry((Geometry)geometry);
565
	}
566

  
567

  
568
	public Object startCurve(String id, ICoordinateIterator coords, String srs){
569
		tab = tab + "\t";
570
		System.out.print(tab + "Start Curve, ID: " + id + ", SRS:" + srs + "\n");
571
		tab = tab + "\t";
572
		Curve curve = new Curve();
573
		try {
574
			while(coords.hasNext()){
575
				double[] buffer = new double[coords.getDimension()];
576
				coords.next(buffer);
577
				curve.addCoordinate(buffer);
578
				System.out.print(tab);
579
				for (int i=0 ; i<buffer.length ; i++){
580
					System.out.print(buffer[i]);
581
					if (i<buffer.length-1){
582
						System.out.print(",");
583
					}
584
				}
585
				System.out.print("\n");
586
			}
587
		} catch (IOException e) {
588
			e.printStackTrace();
589
		}
590
		curve.setId(id);
591
		curve.setSrs(srs);
592
		tab = tab.substring(0, tab.length()-2);
593
		return curve;
594
	}
595

  
596
	public void endCurve(Object curve) {
597
		System.out.print(tab + "\t"+ "End Curve:\n");
598
	}
599

  
600
	public Object startMultiCurve(String id, String srs) {
601
		System.out.print(tab + "Start MultiCurve, ID: " + id + ", SRS:" + srs + "\n");
602
		tab = tab + "\t";
603
		MultiCurve multiCurve = new MultiCurve();
604
		multiCurve.setId(id);
605
		multiCurve.setSrs(srs);
606
		return multiCurve;
607
	}
608

  
609
	public void endMultiCurve(Object multiCurve) {
610
		tab = tab.substring(0, tab.length()-1);
611
		System.out.print(tab + "End MultiCurve\n");
612
	}
613

  
614
	public void addCurveToMultiCurve(Object curve, Object multiCurve) {
615
		System.out.print(tab + "Add Curve to MultiCurve");
616
		((MultiCurve)multiCurve).addCurve((Curve)curve);
617
	}
618

  
619
	public Object startMetadata(String type, String data, IAttributesIterator attributes){
620
		tab = tab + "\t";
621
		MetaData meta=null;
622
		System.out.print(tab + "Start Metadata, META: " + type + ", DATA:" + data + "\n");
623
		try {
624

  
625
			for(int i = 0; i<attributes.getNumAttributes();i++)
626
			{
627
				//String[] buffer = new String[2];
628
				IQName name = attributes.nextAttributeName();
629
				Object value = attributes.nextAttribute();
630
				System.out.print(tab + name + " : " + value + "\n");
631
			}
632
		} catch (IOException e) {
633
			// TODO Auto-generated catch block
634
			e.printStackTrace();
635
		}
636
		meta = new MetaData();
637
		meta.setTagType(type);
638
		meta.setTagData(data);
639
		return meta;
640
	}
641

  
642
	public void endMetadata(Object metadata) {
643
		tab = tab.substring(0, tab.length()-1);
644
		System.out.print(tab + "\t"+ "End Metadata:\n");
645
	}
646

  
647
	public void addMetadataToFeature(Object metadata, Object feature){
648
		System.out.print(tab+tab + "Add Metadata to Feature \n");
649
		((Feature)feature).addMetadata((MetaData)metadata);
650
	}
651

  
652
	public void addMetadataToMetadata(Object metadata, Object parent){
653
		System.out.print(tab + "Add Metadata to Complex Metadata\n");
654
		((MetaData)parent).addChildData((MetaData)metadata);
655
	}
656

  
657
	public void addTimeToFeature(Object time, Object feature) {
658
		System.out.print(tab + "Add Time to feature\n");
659
		((Feature)feature).addTime(time);
660
	}
661

  
662
	public void endTime(Object time) {
663
		tab = tab.substring(0, tab.length()-1);
664
		System.out.print(tab + "\t"+ "End Time:\n");
665
	}
666

  
667
	public Object startTime(String type, String time) {
668
		tab = tab + "\t";
669
		System.out.print(tab + "Start Time, TYPE: " + type + ", DATA:" + time + "\n");
670
		Time t = new Time();
671
		t.setType(type);
672
		t.setValue(time);
673
		return t;
674
	}
675

  
676
	public Object startTime(String name, String description, String type,
677
			String time, Time previous, Time next)
678
	{
679
		tab = tab + "\t";
680
		System.out.print(tab + "Start Time, NAME: " + name + ", DATA:" + time + "\n");
681
		Time t = new Time();
682
		t.setType(type);
683
		t.setValue(time);
684
		t.setDescription(description);
685
		t.setName(name);
686
		t.setPrevious(previous);
687
		t.setNext(next);
688
		return t;
689
	}
690

  
691
    public Object startMultiPoint(String id, String srs, int dimension) {
692
        //Do nothing
693
        return null;
694
    }
695

  
696
    public Object startMultiLineString(String id, String srs, int dimension) {
697
        //Do nothing
698
        return null;
699
    }
700

  
701
    public Object startMultiPolygon(String id, String srs, int dimension) {
702
        //Do nothing
703
        return null;
704
    }
705

  
706
    public Object startMultiCurve(String id, String srs, int dimension) {
707
        //Do nothing
708
        return null;
709
    }
710
}
711

  
0 712

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/parser/GPEContentHandlerAdapterTest.java
1
package org.gvsig.gpe.lib.impl.parser;
2

  
3
import java.util.ArrayList;
4

  
5
import org.gvsig.gpe.lib.api.parser.IGPEContentHandler;
6
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
7

  
8
public class GPEContentHandlerAdapterTest extends GPEContentHandlerAdapter {
9

  
10
	private GPEContentHandlerTest contentHandlerTest;
11

  
12
	public GPEContentHandlerAdapterTest(IGPEContentHandler contentHandler) {
13
		super(contentHandler);
14
		this.contentHandlerTest = (GPEContentHandlerTest) contentHandler;
15
		// TODO Auto-generated constructor stub
16
	}
17

  
18
	public IGPEErrorHandler getErrorHandler() {
19
		return contentHandlerTest.getErrorHandler();
20
	}
21

  
22
	public ArrayList getLayers() {
23
		return contentHandlerTest.getLayers();
24
	}
25

  
26
	public int hashCode() {
27
		return contentHandlerTest.hashCode();
28
	}
29

  
30
	public void setErrorHandler(IGPEErrorHandler errorHandler) {
31
		contentHandlerTest.setErrorHandler(errorHandler);
32
	}
33

  
34
	public void initialize() {
35
		contentHandlerTest.initialize();
36
	}
37
	
38
	
39
}
0 40

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/writer/GPEPointsLayerTest.java
1
package org.gvsig.gpe.lib.impl.writer;
2

  
3
import org.gvsig.gpe.lib.impl.containers.CoordinatesSequence;
4
import org.gvsig.gpe.lib.impl.containers.Feature;
5
import org.gvsig.gpe.lib.impl.containers.GeometryAsserts;
6
import org.gvsig.gpe.lib.impl.containers.Layer;
7
import org.gvsig.gpe.lib.impl.containers.Point;
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: GPEPointsLayerTest.java 144 2007-06-07 14:53:59Z jorpiell $
52
 * $Log$
53
 * Revision 1.7  2007/06/07 14:52:28  jorpiell
54
 * Add the schema support
55
 *
56
 * Revision 1.6  2007/05/02 11:46:07  jorpiell
57
 * Writing tests updated
58
 *
59
 * Revision 1.5  2007/04/26 14:39:12  jorpiell
60
 * Add some tests
61
 *
62
 * Revision 1.4  2007/04/19 11:50:20  csanchez
63
 * Actualizacion protoripo libGPE
64
 *
65
 * Revision 1.3  2007/04/19 07:23:20  jorpiell
66
 * Add the add methods to teh contenhandler and change the register mode
67
 *
68
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
69
 * Add the container classes
70
 *
71
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
72
 * Add the writting tests for the simple geometries
73
 *
74
 *
75
 */
76
/**
77
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
78
 */
79
public abstract class GPEPointsLayerTest extends GPEWriterBaseTest {
80
	private String layerId = "l1";
81
	private String layerName = "Points Layer";
82
	private String layerDescription = "This is a test of a points layer";
83
	private String srs = "EPSG:23030";
84
	private String bboxId = "bboxID";
85
	private double[] bboxX = generateRandomBBox();
86
	private double[] bboxY = generateRandomBBox();
87
	private double[] bboxZ = generateRandomBBox();
88
	private String feature1Name = "New York";
89
	private String feature1Id = "f1";
90
	private String point1Id = "p1";
91
	private double point1X = generateRandomPoint();
92
	private double point1Y = generateRandomPoint();
93
	private double point1Z = generateRandomPoint();
94
	private String feature2Name = "Los Angeles";
95
	private String feature2Id = "f2";
96
	private String point2Id = "p2";
97
	private double point2X = generateRandomPoint();
98
	private double point2Y = generateRandomPoint();
99
	private double point2Z = generateRandomPoint();
100
	
101
	
102
	/*
103
	 * (non-Javadoc)
104
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
105
	 */
106
	public void readObjects() {
107
		Layer[] layers = getLayers();
108
		assertEquals(layers.length, 1);		
109
		Layer layer = layers[0];
110
	
111
		assertEquals(layer.getFeatures().size(), 2);
112
		//FEATURE 1
113
		Feature feature1 = (Feature)layer.getFeatures().get(0);
114
		GeometryAsserts.point((Point)feature1.getGeometry(), point1X, point1Y, point1Z);
115
		
116
		//FEATURE 2
117
		Feature feature2 = (Feature)layer.getFeatures().get(1);
118
		GeometryAsserts.point((Point)feature2.getGeometry(), point2X, point2Y, point2Z);		
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
124
	 */
125
	public void writeObjects() throws Exception {
126
		getWriterHandler().initialize();
127
		getWriterHandler().startLayer(layerId, null, layerName, layerDescription, srs);
128
		getWriterHandler().startBbox(bboxId, new CoordinatesSequence(bboxX,	bboxY, bboxZ), srs);
129
		getWriterHandler().endBbox();
130
		getWriterHandler().startFeature(feature1Id, null, feature1Name);
131
		getWriterHandler().startPoint(point1Id, new CoordinatesSequence(point1X, point1Y, point1Z), srs);
132
		getWriterHandler().endPoint();		
133
		getWriterHandler().endFeature();
134
		getWriterHandler().startFeature(feature2Id, null, feature2Name);
135
		getWriterHandler().startPoint(point2Id, new CoordinatesSequence(point2X, point2Y, point2Z), srs);
136
		getWriterHandler().endPoint();		
137
		getWriterHandler().endFeature();
138
		getWriterHandler().endLayer();
139
		getWriterHandler().close();		
140
	}
141

  
142
}
0 143

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/writer/GPELayerWithNameTest.java
1
package org.gvsig.gpe.lib.impl.writer;
2

  
3
import org.gvsig.gpe.lib.impl.containers.Layer;
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: GPELayerWithNameTest.java 144 2007-06-07 14:53:59Z jorpiell $
48
 * $Log$
49
 * Revision 1.2  2007/06/07 14:52:28  jorpiell
50
 * Add the schema support
51
 *
52
 * Revision 1.1  2007/05/02 11:46:07  jorpiell
53
 * Writing tests updated
54
 *
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public abstract class GPELayerWithNameTest extends GPEWriterBaseTest{
61
	private String layerId = "l1";
62
	private String layerName = "Layer";
63
	private String layerDescription = "Layer with bbox Test";
64
	private String srs = "EPSG:23030";
65

  
66
	/*
67
	 * (non-Javadoc)
68
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
69
	 */
70
	public void readObjects() {
71
		Layer[] layers = getLayers();
72
		assertEquals(layers.length, 1);		
73
		Layer layer = layers[0];
74
		assertEquals(layer.getName(), layerName);
75
	}
76

  
77
	/*
78
	 * (non-Javadoc)
79
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
80
	 */
81
	public void writeObjects() throws Exception {
82
		getWriterHandler().initialize();
83
		getWriterHandler().startLayer(layerId, null, layerName, layerDescription, srs);
84
		getWriterHandler().endLayer();
85
		getWriterHandler().close();		
86
	}
87
}
0 88

  
org.gvsig.gpe/library/tags/org.gvsig.gpe-2.1.163/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/writer/GPELineStringLayerTest.java
1
package org.gvsig.gpe.lib.impl.writer;
2

  
3
import org.gvsig.gpe.lib.impl.containers.CoordinatesSequence;
4
import org.gvsig.gpe.lib.impl.containers.Feature;
5
import org.gvsig.gpe.lib.impl.containers.GeometryAsserts;
6
import org.gvsig.gpe.lib.impl.containers.Layer;
7
import org.gvsig.gpe.lib.impl.containers.LineString;
8

  
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id: GPELineStringLayerTest.java 144 2007-06-07 14:53:59Z jorpiell $
53
 * $Log$
54
 * Revision 1.6  2007/06/07 14:52:28  jorpiell
55
 * Add the schema support
56
 *
57
 * Revision 1.5  2007/05/02 11:46:07  jorpiell
58
 * Writing tests updated
59
 *
60
 * Revision 1.4  2007/04/26 14:39:12  jorpiell
61
 * Add some tests
62
 *
63
 * Revision 1.3  2007/04/19 11:50:20  csanchez
64
 * Actualizacion protoripo libGPE
65
 *
66
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
67
 * Add the container classes
68
 *
69
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
70
 * Add the writting tests for the simple geometries
71
 *
72
 *
73
 */
74
/**
75
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
76
 */
77
public abstract class GPELineStringLayerTest extends GPEWriterBaseTest{
78
	private String layerId = "l1";
79
	private String layerName = "Line String Layer";
80
	private String layerDescription = "This is a line string test";
81
	private String srs = "EPSG:23030";
82
	private String bboxId = "bboxID";
83
	private double[] bboxX = generateRandomBBox();
84
	private double[] bboxY = generateRandomBBox();
85
	private double[] bboxZ = generateRandomBBox();
86
	private String feature1Name = "Turia";
87
	private String feature1Id = "f1";
88
	private String lineString1Id = "p1";
89
	private double[] lineString1X = generateRandomCoordinates();
90
	private double[] lineString1Y = generateRandomCoordinates();
91
	private double[] lineString1Z = generateRandomCoordinates();	
92
	private String feature2Name = "Los Angeles";
93
	private String feature2Id = "f2";
94
	private String lineString2Id = "p2";
95
	private double[] lineString2X = generateRandomCoordinates();
96
	private double[] lineString2Y = generateRandomCoordinates();
97
	private double[] lineString2Z = generateRandomCoordinates();
98

  
99
	
100
	/*
101
	 * (non-Javadoc)
102
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
103
	 */
104
	public void readObjects() {
105
		Layer[] layers = getLayers();
106
		assertEquals(layers.length, 1);		
107
		Layer layer = layers[0];
108
		
109
		assertEquals(layer.getFeatures().size(), 2);
110
		//FEATURE 1
111
		Feature feature1 = (Feature)layer.getFeatures().get(0);
112
		GeometryAsserts.lineString((LineString)feature1.getGeometry(), lineString1X, lineString1Y, lineString1Z);
113

  
114
		//FEATURE 2
115
		Feature feature2 = (Feature)layer.getFeatures().get(1);
116
		GeometryAsserts.lineString((LineString)feature2.getGeometry(), lineString2X, lineString2Y, lineString2Z);
117
	}
118

  
119
	/*
120
	 * (non-Javadoc)
121
	 * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
122
	 */
123
	public void writeObjects() throws Exception {
124
		getWriterHandler().initialize();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff