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