Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPELinearRingLayerTest.java @ 12071

History | View | Annotate | Download (4.51 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
import org.gvsig.gpe.containers.LinearRing;
7

    
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: GPELinearRingLayerTest.java 12071 2007-06-07 14:53:59Z jorpiell $
52
 * $Log$
53
 * Revision 1.6  2007-06-07 14:52:28  jorpiell
54
 * Add the schema support
55
 *
56
 * Revision 1.5  2007/05/02 11:46:07  jorpiell
57
 * Writing tests updated
58
 *
59
 * Revision 1.4  2007/04/26 14:39:12  jorpiell
60
 * Add some tests
61
 *
62
 * Revision 1.3  2007/04/19 11:50:20  csanchez
63
 * Actualizacion protoripo libGPE
64
 *
65
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
66
 * Add the container classes
67
 *
68
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
69
 * Add the writting tests for the simple geometries
70
 *
71
 *
72
 */
73
/**
74
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
75
 */
76
public abstract class GPELinearRingLayerTest extends GPEWriterBaseTest{
77
        private String layerId = "l1";
78
        private String layerName = "Line String Layer";
79
        private String layerDescription = "This is a linear ring test";
80
        private String srs = "EPSG:23030";
81
        private String bboxId = "bboxID";
82
        private double[] bboxX = generateRandomBBox();
83
        private double[] bboxY = generateRandomBBox();
84
        private double[] bboxZ = generateRandomBBox();
85
        private String feature1Name = "Turia";
86
        private String feature1Id = "f1";
87
        private String linearRing1Id = "p1";
88
        private double[] linearRing1X = generateRandomLinearRing();
89
        private double[] linearRing1Y = generateRandomLinearRing();
90
        private double[] linearRing1Z = generateRandomLinearRing();        
91
        private String feature2Name = "Los Angeles";
92
        private String feature2Id = "f2";
93
        private String linearRing2Id = "p2";
94
        private double[] linearRing2X = generateRandomLinearRing();
95
        private double[] linearRing2Y = generateRandomLinearRing();
96
        private double[] linearRing2Z = generateRandomLinearRing();
97

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

    
113
                //FEATURE 2
114
                Feature feature2 = (Feature)layer.getFeatures().get(1);
115
                GeometryAsserts.linearRing((LinearRing)feature2.getGeometry(), linearRing2X, linearRing2Y, linearRing2Z);
116
        }
117

    
118
        /*
119
         * (non-Javadoc)
120
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
121
         */
122
        public void writeObjects() {
123
                getWriterHandler().initialize();
124
                getWriterHandler().startLayer(layerId, layerName, layerDescription, srs, null);
125
                getWriterHandler().startBbox(bboxId, bboxX,
126
                                bboxY,
127
                                bboxZ,
128
                                srs);
129
                getWriterHandler().endBbox();
130
                getWriterHandler().startFeature(feature1Id,feature1Name, null);
131
                getWriterHandler().startLinearRing(linearRing1Id,
132
                                linearRing1X,
133
                                linearRing1Y,
134
                                linearRing1Z, 
135
                                srs);
136
                getWriterHandler().endLinearRing();                
137
                getWriterHandler().endFeature();
138
                getWriterHandler().startFeature(feature2Id,feature2Name, null);
139
                getWriterHandler().startLinearRing(linearRing2Id, 
140
                                linearRing2X,
141
                                linearRing2Y,
142
                                linearRing2Z, 
143
                                srs);
144
                getWriterHandler().endLinearRing();                
145
                getWriterHandler().endFeature();
146
                getWriterHandler().endLayer();
147
                getWriterHandler().close();                
148
        }
149
}