Revision 21847

View differences:

branches/Mobile_Compatible_Hito_1/libFMap/src-test/org/gvsig/data/datastores/vectorial/file/shp/SHPTest.java
1 1
package org.gvsig.data.datastores.vectorial.file.shp;
2 2

  
3 3
import java.awt.Shape;
4
import java.awt.geom.PathIterator;
4 5
import java.io.File;
5
import java.text.DateFormat;
6
import java.text.ParseException;
7 6
import java.util.Date;
8 7
import java.util.Iterator;
9 8

  
10 9
import junit.framework.TestCase;
11 10

  
11
import org.apache.log4j.FileAppender;
12
import org.apache.log4j.Level;
12 13
import org.apache.log4j.Logger;
14
import org.apache.log4j.PatternLayout;
15
import org.cresques.cts.IProjection;
16
import org.gvsig.compatible.StringUtil;
17
import org.gvsig.data.CloseException;
18
import org.gvsig.data.DataCollection;
13 19
import org.gvsig.data.DataManager;
14
import org.gvsig.data.IDataCollection;
15
import org.gvsig.data.IDataStoreParameters;
20
import org.gvsig.data.DataStoreParameters;
21
import org.gvsig.data.InitializeException;
22
import org.gvsig.data.OpenException;
23
import org.gvsig.data.ReadException;
24
import org.gvsig.data.datastores.vectorial.file.ResourceReader;
25
import org.gvsig.data.datastores.vectorial.file.Utils;
16 26
import org.gvsig.data.datastores.vectorial.file.shp.utils.SHP;
17 27
import org.gvsig.data.datastores.vectorial.file.shp_jni.JNISHPStore;
18 28
import org.gvsig.data.datastores.vectorial.file.shp_mem.MemSHPStore;
19 29
import org.gvsig.data.datastores.vectorial.file.shp_util.IGeometricDataStore;
20
import org.gvsig.data.exception.CloseException;
21
import org.gvsig.data.exception.InitializeException;
22
import org.gvsig.data.exception.OpenException;
23
import org.gvsig.data.exception.ReadException;
24
import org.gvsig.data.vectorial.IFeature;
25
import org.gvsig.data.vectorial.IFeatureType;
30
import org.gvsig.data.vectorial.Feature;
31
import org.gvsig.data.vectorial.FeatureType;
32
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.gvsig.fmap.geom.aggregate.MultiCurve2D;
35
import org.gvsig.fmap.geom.aggregate.MultiPoint2D;
36
import org.gvsig.fmap.geom.aggregate.MultiSurface2D;
37
import org.gvsig.fmap.geom.primitive.Curve2D;
38
import org.gvsig.fmap.geom.primitive.NullGeometry;
39
import org.gvsig.fmap.geom.primitive.Point2D;
40
import org.gvsig.fmap.geom.primitive.Surface2D;
26 41

  
27
import es.prodevelop.geodetic.utils.conversion.GeoUtils;
28
import es.prodevelop.gvsig.mobile.fmap.core.FGeometry;
29
import es.prodevelop.gvsig.mobile.fmap.core.FMultiPoint2D;
30
import es.prodevelop.gvsig.mobile.fmap.core.FPoint2D;
31
import es.prodevelop.gvsig.mobile.fmap.core.FPolygon2D;
32
import es.prodevelop.gvsig.mobile.fmap.core.FPolyline2D;
33
import es.prodevelop.gvsig.mobile.fmap.util.ResourceReader;
34
import es.prodevelop.gvsig.mobile.fmap.util.Utils;
35
import es.prodevelop.gvsig.mobile.fmap.util.graph2d.Graph2DUtilities;
42
import com.vividsolutions.jts.algorithm.CGAlgorithms;
43
import com.vividsolutions.jts.geom.Coordinate;
44
import com.vividsolutions.jts.geom.CoordinateList;
36 45

  
46
import es.prodevelop.gvsig.mobile.fmap.driver.vect.shp.ShpReader;
47

  
37 48
/**
38 49
 * This class tests the three SHP drivers implemented for gvSIG Mobile.
39 50
 * These drivers are compatible with the new data access model (june 2008)
......
65 76
		junit.textui.TestRunner.run(SHPTest.class);
66 77
	}
67 78

  
79
	public void publicSetup() {
80
		
81
		try {
82
			setUp();
83
		} catch (Exception e) {
84
			logger.error("While doing setup: " + e.getMessage());
85
		}
86
	}
87
	
68 88
	protected void setUp() throws Exception {
69 89
		super.setUp();
90
		
91
		// call static section to self-registration
92
		new Point2D();
93
		new MultiPoint2D((IProjection) null);
94
		new MultiCurve2D(null, null);
95
		new MultiSurface2D(null, null);
96
		new NullGeometry();
97
		
98
		ShpReader.touch();
99
		initLogger();
70 100
	}
71 101

  
72 102
	public void testInitialize() {
......
125 155
		
126 156
		logger.debug("DATASOURCE: " + ds_name + ", FILE = " + fileAtt.getName() + "...");
127 157
		shp(fileAtt, TEST_ATT, ds_name);
158
		
128 159
		// shp(fileGeometryNull);
129 160
	}
130 161
	
......
136 167
		shpParameters.setFile(file);
137 168
		shpParameters.setDBFFile(SHP.getDbfFile(file));
138 169
		shpParameters.setSHXFile(SHP.getShxFile(file));
170
		shpParameters.setDataStoreName(datastore_name);
171
		
139 172

  
140 173
		try {
141 174
			store = (IGeometricDataStore)
142
			manager.createDataStore((IDataStoreParameters)shpParameters);
175
			manager.createDataStore((DataStoreParameters)shpParameters);
143 176
		} catch (InitializeException e) {
144 177
			// TODO Auto-generated catch block
145 178
			e.printStackTrace();
146 179
		}
147 180
		try {
148
			store.open();
181
			store.doOpen();
149 182
		} catch (OpenException e2) {
150 183
			// TODO Auto-generated catch block
151 184
			e2.printStackTrace();
152 185
		}
153 186

  
154
		IFeatureType ft = store.getDefaultFeatureType();
155
		IDataCollection dataCollection = null;
187
		FeatureType ft = store.getDefaultFeatureType();
188
		DataCollection dataCollection = null;
156 189
		try {
157 190
			dataCollection = store.getDataCollection(ft,null,null);
158 191
		} catch (ReadException e1) {
......
162 195
		int feature_count = 0;
163 196
		
164 197
		while (iter.hasNext()) {
165
			IFeature feature = (IFeature)iter.next();
166
			
167
			
198
			Feature feature = (Feature)iter.next();
199

  
168 200
			boolean simple = (datastore_name.compareTo(JNISHPStore.DATASTORE_NAME) == 0);
169 201
			check(feature, ft, fileid, simple);
170 202
			feature_count++;
......
173 205
		dataCollection.dispose();
174 206

  
175 207
		try {
176
			store.close();
177
			store.dispose();
208
			store.doClose();
209
			store.doDispose();
178 210
		} catch (CloseException e) {
179 211
			// TODO Auto-generated catch block
180 212
			e.printStackTrace();
......
182 214

  
183 215
	}
184 216
	
185
	private void check(IFeature feature, IFeatureType att_desc, int fileid, boolean simpletypes) {
217
	private void check(Feature feature, FeatureType att_desc, int fileid, boolean simpletypes) {
186 218

  
187 219
		double expected = 0;
188 220
		
......
190 222
		
191 223
		case TEST_PUNTO:
192 224
			expected = feature.getDouble("X");
193
			FPoint2D p =  (FPoint2D) ((FGeometry) feature.getDefaultGeometry()).getInternalShape();
225
			Point2D p =  (Point2D) ((Geometry) feature.getDefaultGeometry()).getInternalShape();
194 226
			checkPoint(feature, p, expected, simpletypes);
195 227
			break;
196 228
		case TEST_MPUNTO:
......
198 230
			break;
199 231
		case TEST_LINEA:
200 232
			expected = feature.getDouble("LEN");
201
			FPolyline2D pl =  (FPolyline2D) ((FGeometry) feature.getDefaultGeometry()).getInternalShape();
233
			Curve2D pl =  (Curve2D) ((Geometry) feature.getDefaultGeometry()).getInternalShape();
202 234
			checkLineLength(feature, pl, expected, simpletypes);
203 235
			break;
204 236
		case TEST_POLIGONO:
205 237
			expected = feature.getDouble("AREA");
206
			FPolygon2D pg =  (FPolygon2D) ((FGeometry) feature.getDefaultGeometry()).getInternalShape();
238
			Surface2D pg =  (Surface2D) ((Geometry) feature.getDefaultGeometry()).getInternalShape();
207 239
			checkPolygonArea(feature, pg, expected, simpletypes);
208 240
			break;
209 241
		case TEST_NULL:
......
215 247
		}
216 248
	}
217 249

  
218
	private void checkAttributes(IFeature feat, boolean simpl) {
250
	private void checkAttributes(Feature feat, boolean simpl) {
219 251
		
220 252
		if (! simpl) {
221 253
			Date d = feat.getDate("ATT_DATE");
254
			
255
			if (d == null) {
256
				Thread.activeCount();
257
			}
222 258
			String str = d.toString().toLowerCase();
223 259
			boolean boo =
224
				((str.indexOf("9999") != -1)
260
				((str.indexOf("99") != -1)
225 261
					&& (
226 262
							(str.indexOf("12") != -1)
227 263
							|| (str.indexOf("dec") != -1)
228 264
							|| (str.indexOf("dic") != -1))
229 265
					&& (str.indexOf("31") != -1));
230
			assertTrue("Found a date different to 9999 12 31", boo);
266
			assertTrue("Found a date different to 1999 12 31", boo);
231 267

  
232 268
		}
233 269

  
234
		String str = feat.getString("ATT_STRING");
270
		String str = feat.getString("ATT_STRING").trim();
235 271
		assertEquals(str, "DFGDFGDFG");
236 272
		
237 273
		double real = feat.getDouble("ATT_REAL");
......
241 277
		boolean bool = feat.getBoolean("ATT_BOOLEA");
242 278
		assertTrue("EXP = FALSE, RET = " + (!bool), !bool);
243 279

  
280

  
281
		int integ = 0;
244 282
		if (simpl) {
245
			double d = feat.getDouble("ATT_INTEGE");
246
			assertTrue("REAL = " + d + ", EXP = 44444", d == 44444.0);
283
			integ = (int) Math.round(feat.getDouble("ATT_INTEGE"));
247 284
		} else {
248
			int integ = feat.getInt("ATT_INTEGE");
249
			assertTrue("REAL = " + integ + ", EXP = 44444", integ == 44444);
285
			integ = feat.getInt("ATT_INTEGE");
250 286
		}
287
		
288
		assertTrue("REAL = " + integ + ", EXP = 44444", integ == 44444);
251 289
	}
290
	
291
	/**
292
	 * Gets the area of the path iterator
293
	 * @param piter the path iterator
294
	 * @return the area of the path iterator
295
	 */
296
	public static double getPathIteratorArea(PathIterator piter) {
297
		
298
		if (piter == null) {
299
			return 0;
300
		}
252 301

  
253
	private void checkPolygonArea(IFeature feature, FPolygon2D poly, double expected, boolean simpl) {
302
		double resp = 0;
254 303

  
304
		double[] theData = new double[6];
305
		Coordinate c1 = null;
306
		Coordinate firstc = null;
307
		CoordinateList coordList = null;
308

  
309
		while (!piter.isDone()) {
310

  
311
			int type = piter.currentSegment(theData);
312
			
313
			if (type == PathIterator.SEG_MOVETO) {
314
				if (coordList != null) {
315
					coordList.add(firstc, true);
316
					// printCoordList(coordList);
317
					resp = resp + CGAlgorithms.signedArea(coordList.toCoordinateArray());
318
				}
319
				firstc = new Coordinate(theData[0], theData[1]);
320
				coordList = new CoordinateList();
321
			}
322
			c1 = new Coordinate(theData[0], theData[1]);
323
			coordList.add(c1, true);
324
			piter.next();
325
		}
326
		
327
		if (coordList != null) {
328
			coordList.add(firstc, true);
329
			// printCoordList(coordList);
330
			// resp = resp + Math.abs(CGAlgorithms.signedArea(coordList.toCoordinateArray()));
331
			resp = resp + CGAlgorithms.signedArea(coordList.toCoordinateArray());
332
		}
333
		return Math.abs(resp);
334
	}
335

  
336
	private void checkPolygonArea(Feature feature, Surface2D poly, double expected, boolean simpl) {
337

  
255 338
		int id = 0;
339
		
256 340
		if (simpl) {
257 341
			id = (int) Math.round(feature.getDouble("GUIA_ID"));
258 342
		} else {
259 343
			id = feature.getInt("GUIA_ID");
260 344
		}
261 345

  
262
		double ar = Graph2DUtilities.getPathIteratorArea(poly.getPathIterator(null));
346
		double ar = getPathIteratorArea(poly.getPathIterator(null));
263 347
		assertTrue("AREA = " + ar + ", EXP = " + expected, acceptablySimilar(expected, ar, 0.1));
264 348

  
265 349
		switch (id) {
......
278 362
		}
279 363
	}
280 364

  
281
	private void checkLineLength(IFeature feature, FPolyline2D pl, double expected, boolean simpl) {
365
    /**
366
     * Gets the Euclidean distance between points A and B.
367
     * 
368
     * @param x1 x coordinate of point A
369
     * @param y1 y coordinate of point A
370
     * @param x2 x coordinate of point B
371
     * @param y2 y coordinate of point B
372
     * @return the Euclidean distance between points A and B.
373
     */
374
	public static double distance(double x1, double y1, double x2, double y2) {
375
		double dx = x2 - x1;
376
		double dy = y2 - y1;
377
		return Math.sqrt(dx * dx + dy * dy);
378
	}
379
	
380
	/**
381
	 * Gets the length of the path iterator and of the last of its arcs.
382
	 * No SRS or unit conversion is used, just the plain length between coordinates.
383
	 * 
384
	 * @param piter the path iterator of interest
385
	 * @return the length of the path iterator and of the last of its arcs.
386
	 */
387
	public static double[] getIteratorLengthAndLast(PathIterator piter) {
388

  
389
		double[] resp = new double[2];
390
		resp[0] = 0;
391
		resp[1] = 0;
392

  
393
		if (piter == null)
394
			return resp;
395

  
396
		double lastx = 0;
397
		double lasty = 0;
398
		boolean conn = true;
399
		float[] current = new float[6];
400

  
401
		// logger.debug("UTILS getIteratorLength. PITER = " + piter);
402

  
403
		while (!piter.isDone()) {
404
			if (piter.currentSegment(current) != PathIterator.SEG_MOVETO) {
405
				conn = true;
406
			} else {
407
				conn = false;
408
			}
409
			resp[1] = distance(lastx, lasty, current[0], current[1]);
410
			if (conn)
411
				resp[0] = resp[0] + resp[1];
412
			lastx = current[0];
413
			lasty = current[1];
414
			piter.next();
415
		}
416
		return resp;
417
	}
418

  
419
	private void checkLineLength(Feature feature, Curve2D pl, double expected, boolean simpl) {
282 420
		int color = 0;
283 421
		int eleva = 0;
422
		
284 423
		if (simpl) {
285 424
			color = (int) Math.round(feature.getDouble("COLOR"));
286 425
			eleva = (int) Math.round(feature.getDouble("ELEVACION"));
......
288 427
			color = feature.getInt("COLOR");
289 428
			eleva = feature.getInt("ELEVACION");
290 429
		}
291
		
292
		
293
		double len = GeoUtils.getIteratorLengthAndLast(pl.getPathIterator(null))[0];
430
				
431
		double len = getIteratorLengthAndLast(pl.getPathIterator(null))[0];
294 432
		assertTrue("Not good: " + len  + " and " + expected, acceptablySimilar(expected, len, 0.05));
295 433

  
296 434
		switch (color) {
......
312 450
		}
313 451
	}
314 452

  
315
	private void checkMPoint(IFeature feature, boolean simpl) {
453
	private void checkMPoint(Feature feature, boolean simpl) {
316 454
		
317 455
		int tipocont = 0;
456
		
318 457
		if (simpl) {
319 458
			tipocont = (int) Math.round(feature.getDouble("TIPOCONT"));
320 459
		} else {
321
			tipocont = feature.getInt("GUIA_ID");
322
		}
460
			tipocont = feature.getInt("TIPOCONT");		}		
461

  
462
		tipocont = feature.getInt("TIPOCONT");
323 463
		
324
		String nomb = feature.getString("FIRST_NOMB");
325
		FMultiPoint2D mp = (FMultiPoint2D) feature.getDefaultGeometry(); 
464
		String nomb = feature.getString("FIRST_NOMB").trim();
465
		MultiPoint2D mp = (MultiPoint2D) feature.getDefaultGeometry(); 
326 466

  
327 467
		switch (tipocont) {
328 468
		case 116:
......
350 490

  
351 491
	private boolean oneOfXInMPoint(Shape pointorpoints, double d) {
352 492
		
353
		if (pointorpoints instanceof FMultiPoint2D) {
354
			FMultiPoint2D mp = (FMultiPoint2D) pointorpoints;
493
		if (pointorpoints instanceof MultiPoint2D) {
494
			MultiPoint2D mp = (MultiPoint2D) pointorpoints;
355 495
			int np = mp.getNumPoints();
356 496
			for (int i=0; i<np; i++) {
357 497
				double itemx = mp.getPoint(i).getX();
......
359 499
			}
360 500
			return false;
361 501
		} else {
362
			FPoint2D p = (FPoint2D) pointorpoints;
502
			Point2D p = (Point2D) pointorpoints;
363 503
			return acceptablySimilar(d, p.getX(), 0.01); 
364 504
		}
365 505
	}
366 506
	
367
	private void checkNullGeometry(IFeature feature) {
507
	private void checkNullGeometry(Feature feature) {
368 508
		Object obj = feature.getDefaultGeometry();
369 509
		assertNotNull("Checking not NULL geometry: ", obj);
370 510
	}
371 511
	
372 512

  
373
	private void checkPoint(IFeature feature, FPoint2D point, double expected, boolean simpl) {
513
	private void checkPoint(Feature feature, Point2D point, double expected, boolean simpl) {
374 514
		int id = 0;
375
		
515

  
376 516
		if (simpl) {
377 517
			id = (int) Math.round(feature.getDouble("NUMEROENT"));
378 518
		} else {
379 519
			id = feature.getInt("NUMEROENT");
380 520
		}
381
		
382
		String nomb = feature.getString("NOMBRE");
521

  
522
		String nomb = feature.getString("NOMBRE").trim();
383 523
		assertTrue(acceptablySimilar(expected, point.getX(), 0.01));
384 524

  
385 525
		switch (id) {
......
422 562
//
423 563
//		DataStoreTest.doFileResourceTest(shpParameters);
424 564
//	}
565
	
425 566

  
567
	private void initLogger() {
568

  
569
		Date now = new Date(System.currentTimeMillis());
570
		String nowstr = now.toString();
571
		
572
		nowstr = StringUtil.replaceAllString(nowstr, " ", "_");
573
		nowstr = StringUtil.replaceAllString(nowstr, ":", "_") + ".txt";
574
		
575
		
576
		String outlogpath = "";
577
		
578
		if (Utils.USING_PDA) {
579
			outlogpath = ResourceReader.getPdaTestFile(PerformanceTest.SD_FOLDER, "testdata", "performance_" + nowstr).getAbsolutePath();
580
		} else {
581
			outlogpath = ResourceReader.getResourceFile("testdata", "performance_" + nowstr).getAbsolutePath();
582
		}
583

  
584
		System.out.println("Log file: " + outlogpath);
585

  
586
		try {
587
    		PatternLayout l = new PatternLayout("%5p [%t] - %m%n");
588
    		FileAppender fa = new FileAppender(l, outlogpath, false);
589
    		// ConsoleAppender ca = new ConsoleAppender(l);
590
    		Logger.getRootLogger().setLevel(Level.DEBUG);
591
    		Logger.getRootLogger().addAppender(fa);
592
    		// Logger.getRootLogger().addAppender(ca);
593
		} catch (Exception ex) {
594
			System.err.println("Error while initializing log4j: " + ex.getMessage());
595
		}
596
		
597
	}
598

  
426 599
}
branches/Mobile_Compatible_Hito_1/libFMap/src-test/org/gvsig/data/datastores/vectorial/file/shp/PerformanceTest.java
9 9
import org.apache.log4j.Level;
10 10
import org.apache.log4j.Logger;
11 11
import org.apache.log4j.PatternLayout;
12
import org.gvsig.compatible.StringUtil;
13
import org.gvsig.data.datastores.vectorial.file.Utils;
12 14
import org.gvsig.data.datastores.vectorial.file.shp_jni.JNISHPStore;
13 15
import org.gvsig.data.datastores.vectorial.file.shp_mem.MemSHPStore;
14 16

  
15
import es.prodevelop.gvsig.mobile.fmap.layer.newmodel.FPerformanceTestVectorLayer;
16
import es.prodevelop.gvsig.mobile.fmap.util.ResourceReader;
17
import es.prodevelop.gvsig.mobile.fmap.util.Utils;
18
import es.prodevelop.gvsig.mobile.fmap.util.string.StringUtilities;
17
//import es.prodevelop.gvsig.mobile.fmap.layer.newmodel.FPerformanceTestVectorLayer;
18
//import es.prodevelop.gvsig.mobile.fmap.util.ResourceReader;
19
//import es.prodevelop.gvsig.mobile.fmap.util.Utils;
20
//import es.prodevelop.gvsig.mobile.fmap.util.string.StringUtilities;
19 21

  
20 22
/**
21 23
 * This class tests the performance of three SHP drivers implemented for gvSIG Mobile.
......
32 34
	
33 35
	private static Logger logger = Logger.getLogger(PerformanceTest.class);
34 36
	public static String SD_FOLDER = "Tarjeta SD";
37
	
38
	private static String resourceDir = "";
39
	
40
	static {
41
		String base = System.getProperty("java.class.path");
42
		int ind = base.indexOf(File.pathSeparator);
43
		if (ind != -1) base = base.substring(0, ind);
44
		ind = base.lastIndexOf(File.separator);
45
		base = base.substring(0, ind);
46
		//logger.debug("Base directory: " + base);
47
		ind = base.lastIndexOf(File.separator);
48
		resourceDir = base.substring(0, ind) + File.separator + "resources";
49
	}
35 50

  
36 51
	/**
37 52
	 * Number of sample executions
......
106 121
				String filename = base_name + size + ".shp";
107 122
				
108 123
				if (Utils.USING_PDA) {
109
					shpFile = ResourceReader.getPdaTestFile(SD_FOLDER, "testdata", filename);
124
					shpFile = getPdaTestFile(SD_FOLDER, "testdata", filename);
110 125
				} else {
111
					shpFile = ResourceReader.getResourceFile("testdata", filename);
126
					shpFile = getResourceFile("testdata", filename);
112 127
				}
113 128

  
114 129
				performance(shpFile, storename);
......
120 135
			String feat_type = FEATURE_SIZE_TEST_FEATURE_TYPES[i];
121 136
			String filename = feat_type + FEATURE_SIZE_TEST_BASE_FILE_NAME;
122 137
			if (Utils.USING_PDA) {
123
				shpFile = ResourceReader.getPdaTestFile(SD_FOLDER, "testdata", filename);
138
				shpFile = getPdaTestFile(SD_FOLDER, "testdata", filename);
124 139
			} else {
125
				shpFile = ResourceReader.getResourceFile("testdata", filename);
140
				shpFile = getResourceFile("testdata", filename);
126 141
			}
127 142
			performance(shpFile, storename);
128 143
		}
......
133 148
		Date now = new Date(System.currentTimeMillis());
134 149
		String nowstr = now.toString();
135 150
		
136
		nowstr = StringUtilities.replace(nowstr, " ", "_");
137
		nowstr = StringUtilities.replace(nowstr, ":", "_") + ".txt";
151
		nowstr = StringUtil.replaceAllString(nowstr, " ", "_");
152
		nowstr = StringUtil.replaceAllString(nowstr, ":", "_") + ".txt";
138 153
		
139 154
		
140 155
		String outlogpath = "";
141 156
		
142 157
		if (Utils.USING_PDA) {
143
			outlogpath = ResourceReader.getPdaTestFile(SD_FOLDER, "testdata", "performance_" + nowstr).getAbsolutePath();
158
			outlogpath = getPdaTestFile(SD_FOLDER, "testdata", "performance_" + nowstr).getAbsolutePath();
144 159
		} else {
145
			outlogpath = ResourceReader.getResourceFile("testdata", "performance_" + nowstr).getAbsolutePath();
160
			outlogpath = getResourceFile("testdata", "performance_" + nowstr).getAbsolutePath();
146 161
		}
147 162

  
148 163
		System.out.println("Log file: " + outlogpath);
......
163 178
	private void performance(File file, String st_name) {
164 179

  
165 180
		if (!file.exists()) return;
166
		FPerformanceTestVectorLayer lyr = null;
181
		PerformanceTester lyr = null;
167 182
		try {
168
			lyr = new FPerformanceTestVectorLayer(file, logger, st_name);
183
			lyr = new PerformanceTester(file, logger, st_name);
169 184
			for (int i=0; i<REPEAT_TIMES; i++) {
170
				lyr.draw(null, null);
185
				lyr.drawStore();
171 186
			}
172 187
		} catch (Exception e) {
173 188
			logger.debug("PERFORMANCE_TEST LAYER " + file.getName() + " STORE " + st_name + " ERROR " + e.getMessage());
......
185 200
		return ((diff / Math.abs((expec + area) / 2)) < tol);
186 201
	}
187 202
	
203
	/**
204
	 * Gets a file from the resource folder 
205
	 * @param dir
206
	 * @param file_name
207
	 * @return the file object
208
	 */
209
	public static File getResourceFile(String dir, String file_name) {
210
		String filePath = resourceDir + File.separator + dir + File.separator + file_name;
211
		File resp = new File(filePath);
212
		return resp;
213
	}
214
	
215
	/**
216
	 * Gets a file from the pda sd card folder 
217
	 * @param dir
218
	 * @param file_name
219
	 * @return the file object
220
	 */
221
	public static File getPdaTestFile(String sdfolder, String dir, String file_name) {
222
		String filePath = File.separator + sdfolder + File.separator + dir + File.separator + file_name;
223
		File resp = new File(filePath);
224
		return resp;
225
	}	
226
	
188 227
}

Also available in: Unified diff