Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libGPE-KML / src / org / gvsig / gpe / kml / writer / v21 / geometries / LatLonAltBoxWriter.java @ 18284

History | View | Annotate | Download (4.83 KB)

1
package org.gvsig.gpe.kml.writer.v21.geometries;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.kml.KmlTags;
6
import org.gvsig.gpe.kml.writer.GPEKmlWriterHandlerImplementor;
7
import org.gvsig.gpe.xml.writer.Writer;
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: LatLonAltBoxWriter.java 361 2008-01-10 08:41:21Z jpiera $
52
 * $Log$
53
 * Revision 1.3  2007/05/16 09:30:09  jorpiell
54
 * the writting methods has to have the errorHandler argument
55
 *
56
 * Revision 1.2  2007/05/09 08:36:23  jorpiell
57
 * Add the bbox to the layer
58
 *
59
 * Revision 1.1  2007/05/08 07:53:08  jorpiell
60
 * Add comments to the writers
61
 *
62
 *
63
 */
64
/**
65
 * This class writes a LatLonAltBox Kml tag. Example:
66
 * <p>
67
 * <pre>
68
 * <code> 
69
 * &lt;LatLonAltBox&gt;
70
 * &lt;north&gt;43.374&lt;/north&gt;
71
 * &lt;south&gt;42.983&lt;/south&gt;
72
 * &lt;east&gt;-0.335&lt;/east&gt;
73
 * &lt;west&gt;-1.423&lt;/west&gt;
74
 * &lt;minAltitude&gt;0&lt;/minAltitude&gt;
75
 * &lt;maxAltitude&gt;0&lt;/maxAltitude&gt;
76
 * &lt;/LatLonAltBox&gt;
77
 * </code>
78
 * </pre>
79
 * </p> 
80
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
81
 * @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#latlonaltbox
82
 */
83
public class LatLonAltBoxWriter {
84
        
85
        /**
86
         * It writes the LatLonAltBox init tag and its fields
87
         * @param writer
88
         * Writer to write the labels
89
         * @param handler
90
         * The writer handler implementor
91
         * @param north
92
         * Specifies the latitude of the north edge of the bounding box,
93
         * in decimal degrees from 0 to ?90.
94
         * @param south
95
         * Specifies the latitude of the south edge of the bounding box,
96
         * in decimal degrees from 0 to ?90.
97
         * @param east
98
         * Specifies the longitude of the east edge of the bounding box,
99
         * in decimal degrees from 0 to ?180.
100
         * @param west
101
         * Specifies the longitude of the west edge of the bounding box, 
102
         * in decimal degrees from 0 to ?180.
103
         * @param minAltitude
104
         * Specified in meters above sea level
105
         * @param maxAltitude
106
         * Specified in meters above sea levell 
107
         * @throws IOException
108
         */
109
        public void start(Writer writer, GPEKmlWriterHandlerImplementor handler,double north, double south,
110
                        double east, double west, double minAltitude,
111
                        double maxAltitude) throws IOException{
112
                writer.write("\n");
113
                writer.write("<" + KmlTags.LATLONALTBOX + ">");
114
                writer.write("\n");
115
                writer.write("<" + KmlTags.NORTH + ">");
116
                handler.getProfile().getDoubleWriter().write(writer, handler, north);
117
                writer.write("</" + KmlTags.NORTH + ">");
118
                writer.write("\n");
119
                writer.write("<" + KmlTags.SOUTH + ">");
120
                handler.getProfile().getDoubleWriter().write(writer, handler, south);
121
                writer.write("</" + KmlTags.SOUTH + ">");
122
                writer.write("\n");
123
                writer.write("<" + KmlTags.EAST + ">");
124
                handler.getProfile().getDoubleWriter().write(writer, handler, east);
125
                writer.write("</" + KmlTags.EAST + ">");
126
                writer.write("\n");
127
                writer.write("<" + KmlTags.WEST + ">");
128
                handler.getProfile().getDoubleWriter().write(writer, handler, west);
129
                writer.write("</" + KmlTags.WEST + ">");
130
                writer.write("\n");
131
                writer.write("<" + KmlTags.MINALTITUDE + ">");
132
                handler.getProfile().getDoubleWriter().write(writer, handler, minAltitude);
133
                writer.write("</" + KmlTags.MINALTITUDE + ">");
134
                writer.write("\n");
135
                writer.write("<" + KmlTags.MAXALTITUDE + ">");
136
                handler.getProfile().getDoubleWriter().write(writer, handler, maxAltitude);
137
                writer.write("</" + KmlTags.MAXALTITUDE + ">");
138
        }
139
        
140
        /**
141
        /**
142
         * It writes the LatLonAltBox end tag and its fields
143
         * @param writer
144
         * Writer to write the labels
145
         * @param handler
146
         * The writer handler implementor
147
         * @throws IOException
148
         */
149
        public void end(Writer writer, GPEKmlWriterHandlerImplementor hanlder) throws IOException{
150
                writer.write("\n");
151
                writer.write("</" + KmlTags.LATLONALTBOX + ">");
152
        }
153
}