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