Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / writer / geometries / GeometriesWriter.java @ 11621

History | View | Annotate | Download (3.29 KB)

1
package org.gvsig.gpe.gml.writer.geometries;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.GPEErrorHandler;
6
import org.gvsig.gpe.xml.writer.Writer;
7

    
8
import org.gvsig.gpe.gml.GMLProjectionFactory;
9
import org.gvsig.gpe.gml.GMLTags;
10

    
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: GeometriesWriter.java 11621 2007-05-14 11:18:12Z jorpiell $
54
 * $Log$
55
 * Revision 1.6  2007-05-14 11:18:12  jorpiell
56
 * Add the ErrorHandler to all the methods
57
 *
58
 * Revision 1.5  2007/05/14 09:32:12  jorpiell
59
 * Add the a new class to compare tags
60
 *
61
 * Revision 1.4  2007/05/08 10:24:16  jorpiell
62
 * Add comments to create javadocs
63
 *
64
 * Revision 1.3  2007/04/14 16:07:30  jorpiell
65
 * The writer has been created
66
 *
67
 * Revision 1.2  2007/04/12 17:06:44  jorpiell
68
 * First GML writing tests
69
 *
70
 * Revision 1.1  2007/04/12 10:23:41  jorpiell
71
 * Add some writers and the GPEXml parser
72
 *
73
 *
74
 */
75
/**
76
 * This class is used to write the attributes for
77
 * a GML geometry. 
78
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
79
 */
80
public class GeometriesWriter {
81
        
82
        /**
83
         * Writes a Geoemtry init tag in GML
84
         * @param writer
85
         * Writer to write the labels
86
         * @param errorHandler
87
         * To add the errors
88
         * @param tagName
89
         * Geometry type
90
         * @param id
91
         * Geometry id
92
         * @param srs
93
         * Spatial reference system
94
         * @throws IOException
95
         */
96
        public static void startGeometry(Writer writer,GPEErrorHandler errorHandler, String tagName,String id,String srs) throws IOException{
97
                writer.write("\n");
98
                writer.write("<" + GMLTags.GML_NAMESPACE + ":" + tagName);
99
                if (id != null){
100
                        writer.write(" " + GMLTags.GML_GID + "='" + id + "'");
101
                }
102
                if (srs != null){
103
                        writer.write(" " + GMLTags.GML_SRS_NAME + "='");
104
                        writer.write(GMLProjectionFactory.fromGPEToGML(srs,errorHandler));
105
                        writer.write("'");
106
                }
107
                writer.write(">");                
108
        }
109
        
110
        /**
111
         * Writes a Geoemtry end tag in GML
112
         * @param writer
113
         * Writer to write the labels
114
         * @param errorHandler
115
         * To add the errors
116
         * @param tagName
117
         * Geometry type
118
         * @throws IOException
119
         */
120
        public static void endGeometry(Writer writer, GPEErrorHandler errorHandler,String tagName) throws IOException{
121
                writer.write("\n");
122
                writer.write("</" + GMLTags.GML_NAMESPACE + ":" + tagName + ">");
123
        }
124
        
125
}
126