svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEGeometryWithBboxTest.java @ 11435
History | View | Annotate | Download (4.15 KB)
1 |
package org.gvsig.gpe.writers; |
---|---|
2 |
|
3 |
import org.gvsig.gpe.containers.Feature; |
4 |
import org.gvsig.gpe.containers.GeometryAsserts; |
5 |
import org.gvsig.gpe.containers.Layer; |
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: GPEGeometryWithBboxTest.java 11435 2007-05-02 11:46:50Z jorpiell $
|
50 |
* $Log$
|
51 |
* Revision 1.1 2007-05-02 11:46:07 jorpiell
|
52 |
* Writing tests updated
|
53 |
*
|
54 |
*
|
55 |
*/
|
56 |
/**
|
57 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
58 |
*/
|
59 |
public abstract class GPEGeometryWithBboxTest extends GPEWriterBaseTest { |
60 |
private String layerId = "l1"; |
61 |
private String layerName = "Points Layer"; |
62 |
private String layerDescription = "This is a test of a points layer"; |
63 |
private String srs = "EPSG:23030"; |
64 |
private String feature1Name = "New York"; |
65 |
private String feature1Id = "f1"; |
66 |
private String point1Id = "p1"; |
67 |
private double point1X = generateRandomPoint(); |
68 |
private double point1Y = generateRandomPoint(); |
69 |
private double point1Z = generateRandomPoint(); |
70 |
private String bboxG1Id = "bboxG1"; |
71 |
private double[] bboxG1X = generateRandomBBox(); |
72 |
private double[] bboxG1Y = generateRandomBBox(); |
73 |
private double[] bboxG1Z = generateRandomBBox(); |
74 |
private String feature2Name = "Los Angeles"; |
75 |
private String feature2Id = "f2"; |
76 |
private String point2Id = "p2"; |
77 |
private double point2X = generateRandomPoint(); |
78 |
private double point2Y = generateRandomPoint(); |
79 |
private double point2Z = generateRandomPoint(); |
80 |
private String bboxG2Id = "bboxG2"; |
81 |
private double[] bboxG2X = generateRandomBBox(); |
82 |
private double[] bboxG2Y = generateRandomBBox(); |
83 |
private double[] bboxG2Z = generateRandomBBox(); |
84 |
|
85 |
|
86 |
/*
|
87 |
* (non-Javadoc)
|
88 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
|
89 |
*/
|
90 |
public void readObjects() { |
91 |
Layer[] layers = getLayers();
|
92 |
assertEquals(layers.length, 1);
|
93 |
Layer layer = layers[0];
|
94 |
|
95 |
assertEquals(layer.getFeatures().size(), 2);
|
96 |
//FEATURE 1
|
97 |
Feature feature1 = (Feature)layer.getFeatures().get(0);
|
98 |
GeometryAsserts.bbox(feature1.getGeometry().getBbox(),bboxG1X,bboxG1Y,bboxG1Z); |
99 |
|
100 |
//FEATURE 2
|
101 |
Feature feature2 = (Feature)layer.getFeatures().get(1);
|
102 |
GeometryAsserts.bbox(feature2.getGeometry().getBbox(),bboxG2X,bboxG2Y,bboxG2Z); |
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
|
108 |
*/
|
109 |
public void writeObjects() { |
110 |
getWriterHandler().initialize(); |
111 |
getWriterHandler().startLayer(layerId, layerName, layerDescription, srs); |
112 |
getWriterHandler().startFeature(feature1Id,feature1Name); |
113 |
getWriterHandler().startPoint(point1Id, point1X, point1Y, point1Z, srs); |
114 |
getWriterHandler().startBbox(bboxG1Id, bboxG1X, |
115 |
bboxG1Y, |
116 |
bboxG1Z, |
117 |
srs); |
118 |
getWriterHandler().endBbox(); |
119 |
getWriterHandler().endPoint(); |
120 |
getWriterHandler().endFeature(); |
121 |
getWriterHandler().startFeature(feature2Id,feature2Name); |
122 |
getWriterHandler().startPoint(point2Id, point2X, point2Y, point2Z, srs); |
123 |
getWriterHandler().startBbox(bboxG2Id, bboxG2X, |
124 |
bboxG2Y, |
125 |
bboxG2Z, |
126 |
srs); |
127 |
getWriterHandler().endBbox(); |
128 |
getWriterHandler().endPoint(); |
129 |
getWriterHandler().endFeature(); |
130 |
getWriterHandler().endLayer(); |
131 |
getWriterHandler().close(); |
132 |
} |
133 |
|
134 |
} |