Revision 102 org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.java
GeonamesServiceDriver.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
/* |
... | ... | |
46 | 46 |
|
47 | 47 |
|
48 | 48 |
public class GeonamesServiceDriver extends AbstractGazetteerServiceDriver { |
49 |
|
|
50 |
|
|
49 |
|
|
50 |
|
|
51 | 51 |
public GeonamesServiceDriver() { |
52 | 52 |
super(); |
53 |
setProjection("EPSG:4326");
|
|
53 |
setProjection("EPSG:4326"); |
|
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
/* |
... | ... | |
58 | 58 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.GazetteerQuery) |
59 | 59 |
*/ |
60 | 60 |
public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception { |
61 |
WebService.setUserName(getUsername()); |
|
61 | 62 |
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria(); |
62 | 63 |
searchCriteria.setQ(query.getName()); |
63 | 64 |
ToponymSearchResult searchResult = WebService.search(searchCriteria); |
... | ... | |
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
private Feature converToponym(Toponym toponym) { |
73 |
Feature feature = new Feature(toponym.getFeatureCode(),
|
|
74 |
Feature feature = new Feature(toponym.getFeatureCode(), |
|
74 | 75 |
toponym.getName(), |
75 | 76 |
toponym.getName(), |
76 | 77 |
new Point2D.Double(toponym.getLongitude(), toponym.getLatitude())); |
77 |
|
|
78 |
|
|
78 | 79 |
return feature; |
79 | 80 |
} |
80 | 81 |
|
... | ... | |
103 | 104 |
public ServerData getOneServer() { |
104 | 105 |
return new ServerData("www.geonames.org", "GEONAMES"); |
105 | 106 |
} |
106 |
|
|
107 |
|
|
107 |
|
|
108 |
@Override |
|
109 |
public boolean needsUsername(String protocol) { |
|
110 |
return true; |
|
111 |
} |
|
108 | 112 |
} |
Also available in: Unified diff