svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / adl / drivers / ADLSearchByName.java @ 9250
History | View | Annotate | Download (2.98 KB)
1 | 3566 | jorpiell | |
---|---|---|---|
2 | 3214 | jorpiell | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 | *
|
||
4 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * Generalitat Valenciana
|
||
23 | * Conselleria d'Infraestructures i Transport
|
||
24 | * Av. Blasco Ib??ez, 50
|
||
25 | * 46010 VALENCIA
|
||
26 | * SPAIN
|
||
27 | *
|
||
28 | * +34 963862235
|
||
29 | * gvsig@gva.es
|
||
30 | * www.gvsig.gva.es
|
||
31 | *
|
||
32 | * or
|
||
33 | *
|
||
34 | * IVER T.I. S.A
|
||
35 | * Salamanca 50
|
||
36 | * 46005 Valencia
|
||
37 | * Spain
|
||
38 | *
|
||
39 | * +34 963163400
|
||
40 | * dac@iver.es
|
||
41 | */
|
||
42 | package es.gva.cit.gazetteer.adl.drivers; |
||
43 | import es.gva.cit.catalogClient.metadataXML.XMLNode; |
||
44 | import es.gva.cit.gazetteer.adl.parsers.AdlFeatureParser; |
||
45 | import es.gva.cit.gazetteer.querys.Feature; |
||
46 | import es.gva.cit.gazetteer.querys.Query; |
||
47 | 3613 | jorpiell | import java.net.MalformedURLException; |
48 | import java.net.URL; |
||
49 | import java.util.Collection; |
||
50 | 3214 | jorpiell | |
51 | /**
|
||
52 | 3566 | jorpiell | * This class is used to find and return the coordinates for a place.
|
53 | *
|
||
54 | *
|
||
55 | 3214 | jorpiell | * @author Jorge Piera Llodra (piera_jor@gva.es)
|
56 | */
|
||
57 | 3566 | jorpiell | public class ADLSearchByName extends ADLGazetteerServiceDriver { |
58 | |||
59 | /**
|
||
60 | *
|
||
61 | *
|
||
62 | */
|
||
63 | 9250 | jorpiell | public String serverURL = "http://middleware.alexandria.ucsb.edu:8080/gaz/adlgaz/dispatch"; |
64 | 3566 | jorpiell | |
65 | /**
|
||
66 | * This class needs the server URL to work
|
||
67 | *
|
||
68 | *
|
||
69 | * @param url Server URL
|
||
70 | */
|
||
71 | public ADLSearchByName(String url) { |
||
72 | 3214 | jorpiell | super();
|
73 | setServerURL(url); |
||
74 | 3566 | jorpiell | } |
75 | |||
76 | /**
|
||
77 | * Constructor witout fileds
|
||
78 | *
|
||
79 | */
|
||
80 | public ADLSearchByName() {
|
||
81 | 3214 | jorpiell | super();
|
82 | 3566 | jorpiell | } |
83 | |||
84 | /**
|
||
85 | * It searches and returns an array of features.
|
||
86 | *
|
||
87 | *
|
||
88 | * @return
|
||
89 | * @param placeName String with the place name to find.
|
||
90 | */
|
||
91 | public Feature[] search(String placeName) { |
||
92 | 3214 | jorpiell | Query query = new Query(placeName,"populated places"); |
93 | try {
|
||
94 | 3566 | jorpiell | Collection nodes = getFeature(new URL(getServerURL()),query); |
95 | Feature[] features = new AdlFeatureParser().parse((XMLNode)nodes.toArray()[0]); |
||
96 | 3214 | jorpiell | return features;
|
97 | } catch (MalformedURLException e) { |
||
98 | // TODO Auto-generated catch block
|
||
99 | e.printStackTrace(); |
||
100 | return null; |
||
101 | } |
||
102 | |||
103 | 3566 | jorpiell | } |
104 | |||
105 | /**
|
||
106 | *
|
||
107 | *
|
||
108 | *
|
||
109 | * @return Returns the serverURL.
|
||
110 | */
|
||
111 | public String getServerURL() { |
||
112 | 3214 | jorpiell | return serverURL;
|
113 | 3566 | jorpiell | } |
114 | |||
115 | /**
|
||
116 | *
|
||
117 | *
|
||
118 | *
|
||
119 | * @param serverURL The serverURL to set.
|
||
120 | */
|
||
121 | public void setServerURL(String serverURL) { |
||
122 | 3214 | jorpiell | this.serverURL = serverURL;
|
123 | 3566 | jorpiell | } |
124 | } |