Statistics
| Revision:

gvsig-gazetteer / org.gvsig.gazetteer / trunk / org.gvsig.gazetteer / org.gvsig.gazetteer.lib / src / test / java / org / gvsig / gazetteer / drivers / ExampleNewDriver.java @ 103

History | View | Annotate | Download (3.84 KB)

1
package org.gvsig.gazetteer.drivers;
2

    
3
import java.awt.geom.Point2D;
4
import java.net.URI;
5

    
6
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
7
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
8
import org.gvsig.fmap.geom.GeometryLocator;
9
import org.gvsig.fmap.geom.GeometryManager;
10
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
11
import org.gvsig.fmap.geom.exception.CreateGeometryException;
12
import org.gvsig.fmap.geom.primitive.Point;
13
import org.gvsig.gazetteer.querys.Feature;
14
import org.gvsig.gazetteer.querys.GazetteerQuery;
15
import org.gvsig.gazetteer.wfsg.parsers.WfsgFeatureParser;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

    
19

    
20
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
21
 *
22
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
23
 *
24
 * This program is free software; you can redistribute it and/or
25
 * modify it under the terms of the GNU General Public License
26
 * as published by the Free Software Foundation; either version 2
27
 * of the License, or (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
37
 *
38
 * For more information, contact:
39
 *
40
 *  Generalitat Valenciana
41
 *   Conselleria d'Infraestructures i Transport
42
 *   Av. Blasco Ib??ez, 50
43
 *   46010 VALENCIA
44
 *   SPAIN
45
 *
46
 *      +34 963862235
47
 *   gvsig@gva.es
48
 *      www.gvsig.gva.es
49
 *
50
 *    or
51
 *
52
 *   IVER T.I. S.A
53
 *   Salamanca 50
54
 *   46005 Valencia
55
 *   Spain
56
 *
57
 *   +34 963163400
58
 *   dac@iver.es
59
 */
60
/* CVS MESSAGES:
61
 *
62
 * $Id: ExampleNewDriver.java 537 2007-07-26 11:21:10 +0000 (Thu, 26 Jul 2007) jpiera $
63
 * $Log$
64
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
65
 * Add the posibility to add a new panel
66
 *
67
 *
68
 */
69
/**
70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
71
 */
72
public class ExampleNewDriver extends AbstractGazetteerServiceDriver {
73
    private static final Logger logger =
74
        LoggerFactory.getLogger(ExampleNewDriver.class);
75

    
76
        /*
77
         * (non-Javadoc)
78
         * @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
79
         */
80
        public DiscoveryServiceCapabilities getCapabilities(URI uri) {
81
                return new GazetteerCapabilities();
82
        }
83

    
84
        /*
85
         * (non-Javadoc)
86
         * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query)
87
         */
88
        public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
89
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
90

    
91
                String prop = (String)query.getProperty("PROP1");
92
                Feature[] features = new Feature[1];
93
                Point point =null;
94
                double x=0.0;
95
                double y=0.0;
96
        try {
97
            point = geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
98
        } catch (CreateGeometryException | NumberFormatException e) {
99
            StringBuilder builder = new StringBuilder();
100
            builder.append("Can't create point: (");
101
            builder.append(x);
102
            builder.append(",");
103
            builder.append(y);
104
            builder.append(")");
105
            logger.warn(builder.toString());
106
        }
107
                features[0] = new Feature("1","Result 1","description 1",point);
108
                return features;
109
        }
110

    
111
        /*
112
         * (non-Javadoc)
113
         * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getServiceName()
114
         */
115
        public String getServiceName() {
116
                return "My service";
117
        }
118

    
119
        /*
120
         * (non-Javadoc)
121
         * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel()
122
         */
123
        public SearchAditionalPropertiesPanel getAditionalSearchPanel(){
124
                return new ExampleNewPanel();
125
        }
126

    
127
}