01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfs.xml;
06:
07: import org.geotools.feature.Feature;
08: import org.geotools.gml.producer.FeatureTransformer;
09: import org.geotools.gml.producer.GeometryTransformer.GeometryTranslator;
10: import org.geotools.gml3.bindings.GML;
11: import org.xml.sax.Attributes;
12: import org.xml.sax.ContentHandler;
13: import org.xml.sax.helpers.AttributesImpl;
14: import java.util.Set;
15:
16: public class GML3FeatureTransformer extends FeatureTransformer {
17: protected FeatureTranslator createTranslator(
18: ContentHandler handler, String prefix, String ns,
19: FeatureTypeNamespaces featureTypeNamespaces,
20: SchemaLocationSupport schemaLocationSupport) {
21: return new GML3FeatureTranslator(handler, prefix, ns,
22: featureTypeNamespaces, schemaLocationSupport);
23: }
24:
25: protected void loadGmlAttributes(Set set) {
26: set.add("name");
27: set.add("description");
28: }
29:
30: public static class GML3FeatureTranslator extends FeatureTranslator {
31: public GML3FeatureTranslator(ContentHandler handler,
32: String prefix, String ns,
33: FeatureTypeNamespaces featureTypeNamespaces,
34: SchemaLocationSupport schemaLocationSupport) {
35: super (handler, prefix, ns, featureTypeNamespaces,
36: schemaLocationSupport);
37: }
38:
39: protected GeometryTranslator createGeometryTranslator(
40: ContentHandler handler) {
41: return new GML3GeometryTranslator(handler);
42: }
43:
44: protected GeometryTranslator createGeometryTranslator(
45: ContentHandler handler, int numDecimals) {
46: return new GML3GeometryTranslator(handler, numDecimals);
47: }
48:
49: protected GeometryTranslator createGeometryTranslator(
50: ContentHandler handler, int numDecimals,
51: boolean useDummyZ) {
52: return new GML3GeometryTranslator(handler, numDecimals,
53: useDummyZ);
54: }
55:
56: protected Attributes encodeFeatureId(Feature f) {
57: AttributesImpl atts = new AttributesImpl();
58:
59: if (f.getID() != null) {
60: atts.addAttribute(GML.NAMESPACE, "id", "gml:id", null,
61: f.getID());
62: }
63:
64: return atts;
65: }
66:
67: protected String boxElement() {
68: return "Envelope";
69: }
70: }
71: }
|