Statistics
| Revision:

root / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEPointsLayerTest.java @ 12439

History | View | Annotate | Download (4.4 KB)

1 11178 jorpiell
package org.gvsig.gpe.writers;
2
3 11247 jorpiell
import org.gvsig.gpe.containers.Feature;
4 11379 jorpiell
import org.gvsig.gpe.containers.GeometryAsserts;
5 11209 jorpiell
import org.gvsig.gpe.containers.Layer;
6 11379 jorpiell
import org.gvsig.gpe.containers.Point;
7 11178 jorpiell
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$
51
 * $Log$
52 12071 jorpiell
 * Revision 1.7  2007-06-07 14:52:28  jorpiell
53
 * Add the schema support
54
 *
55
 * Revision 1.6  2007/05/02 11:46:07  jorpiell
56 11435 jorpiell
 * Writing tests updated
57
 *
58
 * Revision 1.5  2007/04/26 14:39:12  jorpiell
59 11379 jorpiell
 * Add some tests
60
 *
61
 * Revision 1.4  2007/04/19 11:50:20  csanchez
62 11265 csanchez
 * Actualizacion protoripo libGPE
63
 *
64
 * Revision 1.3  2007/04/19 07:23:20  jorpiell
65 11247 jorpiell
 * Add the add methods to teh contenhandler and change the register mode
66
 *
67
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
68 11209 jorpiell
 * Add the container classes
69
 *
70
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
71 11178 jorpiell
 * Add the writting tests for the simple geometries
72
 *
73
 *
74
 */
75
/**
76
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
77
 */
78
public abstract class GPEPointsLayerTest extends GPEWriterBaseTest {
79 11247 jorpiell
        private String layerId = "l1";
80 11209 jorpiell
        private String layerName = "Points Layer";
81
        private String layerDescription = "This is a test of a points layer";
82 11379 jorpiell
        private String srs = "EPSG:23030";
83
        private String bboxId = "bboxID";
84 11247 jorpiell
        private double[] bboxX = generateRandomBBox();
85
        private double[] bboxY = generateRandomBBox();
86
        private double[] bboxZ = generateRandomBBox();
87
        private String feature1Name = "New York";
88
        private String feature1Id = "f1";
89 11379 jorpiell
        private String point1Id = "p1";
90
        private double point1X = generateRandomPoint();
91
        private double point1Y = generateRandomPoint();
92
        private double point1Z = generateRandomPoint();
93
        private String feature2Name = "Los Angeles";
94
        private String feature2Id = "f2";
95
        private String point2Id = "p2";
96
        private double point2X = generateRandomPoint();
97
        private double point2Y = generateRandomPoint();
98
        private double point2Z = generateRandomPoint();
99 11178 jorpiell
100 11435 jorpiell
101 11178 jorpiell
        /*
102
         * (non-Javadoc)
103
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
104
         */
105
        public void readObjects() {
106 11209 jorpiell
                Layer[] layers = getLayers();
107 11379 jorpiell
                assertEquals(layers.length, 1);
108 11209 jorpiell
                Layer layer = layers[0];
109 11435 jorpiell
110 11247 jorpiell
                assertEquals(layer.getFeatures().size(), 2);
111 11379 jorpiell
                //FEATURE 1
112 11247 jorpiell
                Feature feature1 = (Feature)layer.getFeatures().get(0);
113 11379 jorpiell
                GeometryAsserts.point((Point)feature1.getGeometry(), point1X, point1Y, point1Z);
114 11435 jorpiell
115
                //FEATURE 2
116 11379 jorpiell
                Feature feature2 = (Feature)layer.getFeatures().get(1);
117 11435 jorpiell
                GeometryAsserts.point((Point)feature2.getGeometry(), point2X, point2Y, point2Z);
118 11178 jorpiell
        }
119
120
        /*
121
         * (non-Javadoc)
122
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
123
         */
124
        public void writeObjects() {
125 11209 jorpiell
                getWriterHandler().initialize();
126 12071 jorpiell
                getWriterHandler().startLayer(layerId, layerName, layerDescription, srs, null);
127 11379 jorpiell
                getWriterHandler().startBbox(bboxId, bboxX,
128 11247 jorpiell
                                bboxY,
129
                                bboxZ,
130 11379 jorpiell
                                srs);
131 11209 jorpiell
                getWriterHandler().endBbox();
132 12071 jorpiell
                getWriterHandler().startFeature(feature1Id,feature1Name, null);
133 11379 jorpiell
                getWriterHandler().startPoint(point1Id, point1X, point1Y, point1Z, srs);
134 11209 jorpiell
                getWriterHandler().endPoint();
135
                getWriterHandler().endFeature();
136 12071 jorpiell
                getWriterHandler().startFeature(feature2Id,feature2Name, null);
137 11379 jorpiell
                getWriterHandler().startPoint(point2Id, point2X, point2Y, point2Z, srs);
138 11209 jorpiell
                getWriterHandler().endPoint();
139
                getWriterHandler().endFeature();
140
                getWriterHandler().endLayer();
141
                getWriterHandler().close();
142 11178 jorpiell
        }
143
144
}