Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 1070:7096a2e13676
Added functionality to publish the the mbr of the generated layer to
the client.
gnv-artifacts/trunk@1166 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 07 Jun 2010 14:42:42 +0000 |
parents | 04967dc9c83f |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
1069:0d15e515f88d | 1070:7096a2e13676 |
---|---|
3 import java.io.File; | 3 import java.io.File; |
4 import java.io.FileNotFoundException; | 4 import java.io.FileNotFoundException; |
5 import java.io.FileOutputStream; | 5 import java.io.FileOutputStream; |
6 import java.io.IOException; | 6 import java.io.IOException; |
7 import java.io.OutputStream; | 7 import java.io.OutputStream; |
8 import java.text.DecimalFormat; | |
8 import java.util.Date; | 9 import java.util.Date; |
9 | 10 |
10 import javax.xml.xpath.XPathConstants; | 11 import javax.xml.xpath.XPathConstants; |
11 | 12 |
12 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
13 | |
14 import org.w3c.dom.Document; | 14 import org.w3c.dom.Document; |
15 import org.w3c.dom.Element; | 15 import org.w3c.dom.Element; |
16 import org.w3c.dom.Node; | 16 import org.w3c.dom.Node; |
17 | |
18 import com.vividsolutions.jts.geom.Envelope; | |
17 | 19 |
18 import de.intevation.artifactdatabase.XMLUtils; | 20 import de.intevation.artifactdatabase.XMLUtils; |
19 import de.intevation.artifacts.ArtifactNamespaceContext; | 21 import de.intevation.artifacts.ArtifactNamespaceContext; |
20 import de.intevation.artifacts.CallContext; | 22 import de.intevation.artifacts.CallContext; |
21 import de.intevation.gnv.artifacts.context.GNVArtifactContext; | 23 import de.intevation.gnv.artifacts.context.GNVArtifactContext; |
37 public static final String NODE_TTL = "ttl"; | 39 public static final String NODE_TTL = "ttl"; |
38 | 40 |
39 public static final String META_FILE_NAME = "meta.xml"; | 41 public static final String META_FILE_NAME = "meta.xml"; |
40 | 42 |
41 public static final String XPATH_META = "/art:meta"; | 43 public static final String XPATH_META = "/art:meta"; |
44 public static final String XPATH_MAPSERVER = "art:meta/art:"+NODE_MAPSERVER; | |
42 | 45 |
43 /** | 46 /** |
44 * Constructor. | 47 * Constructor. |
45 */ | 48 */ |
46 private MetaWriter() { | 49 private MetaWriter() { |
131 meta.appendChild(layerEl); | 134 meta.appendChild(layerEl); |
132 | 135 |
133 return true; | 136 return true; |
134 } | 137 } |
135 | 138 |
136 | 139 /** |
140 * Method to write the <i>meta</i> document down to a file. | |
141 * | |
142 * @param path The destination of the file. | |
143 * @param meta The xml document storing the meta information. | |
144 */ | |
145 public static boolean insertMbr(Envelope mbr, String srs, Document meta) { | |
146 Node mapserverNode = (Node) XMLUtils.xpath( | |
147 meta, | |
148 XPATH_MAPSERVER, | |
149 XPathConstants.NODE, | |
150 ArtifactNamespaceContext.INSTANCE); | |
151 if (mapserverNode != null){ | |
152 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( | |
153 meta, | |
154 ArtifactNamespaceContext.NAMESPACE_URI, | |
155 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
156 Element bboxNode = creator.create("Box"); | |
157 bboxNode.setAttribute("srsName", srs); | |
158 Element coordinateNode = creator.create("coordinates"); | |
159 | |
160 DecimalFormat formatter = new DecimalFormat("###.############"); | |
161 coordinateNode.setTextContent(formatter.format(mbr.getMinX()).replace(',', '.') +","+ | |
162 formatter.format(mbr.getMinY()).replace(',', '.')+" "+ | |
163 formatter.format(mbr.getMaxX()).replace(',', '.') +","+ | |
164 formatter.format(mbr.getMaxY()).replace(',', '.')); | |
165 mapserverNode.appendChild(bboxNode); | |
166 bboxNode.appendChild(coordinateNode); | |
167 } | |
168 return true; | |
169 } | |
137 /** | 170 /** |
138 * Method to write the <i>meta</i> document down to a file. | 171 * Method to write the <i>meta</i> document down to a file. |
139 * | 172 * |
140 * @param path The destination of the file. | 173 * @param path The destination of the file. |
141 * @param meta The xml document storing the meta information. | 174 * @param meta The xml document storing the meta information. |