本文整理汇总了Java中org.geonames.ToponymSearchCriteria类的典型用法代码示例。如果您正苦于以下问题:Java ToponymSearchCriteria类的具体用法?Java ToponymSearchCriteria怎么用?Java ToponymSearchCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToponymSearchCriteria类属于org.geonames包,在下文中一共展示了ToponymSearchCriteria类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: searchByString
import org.geonames.ToponymSearchCriteria; //导入依赖的package包/类
private String searchByString(String location) throws EnforcedWaitException {
geonamesLastCall.enforce();
ToponymSearchResult x;
try {
ToponymSearchCriteria search = new ToponymSearchCriteria();
search.setQ(location);
x = WebService.search(search);
if(x.getTotalResultsCount() == 0)
{
return "";
}
return x.getToponyms()
.get(0)
.getCountryCode();
} catch (Exception e) {
return "";
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:CountryCodeMode.java
示例2: buscarInformacoesExtrasGeonames
import org.geonames.ToponymSearchCriteria; //导入依赖的package包/类
public List<ResultadoGeonames> buscarInformacoesExtrasGeonames(String nome) {
WebService.setUserName("infotur");
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
searchCriteria.setName(nome);
searchCriteria.setNameEquals(nome);
searchCriteria.setStyle(Style.FULL);
ToponymSearchResult searchResult;
List<ResultadoGeonames> resultado = new ArrayList<ResultadoGeonames>();
try {
searchResult = WebService.search(searchCriteria);
for (Toponym toponym : searchResult.getToponyms()) {
ResultadoGeonames rg = new ResultadoGeonames();
rg.setNome(toponym.getName());
rg.setNomesAlternativos(toponym.getAlternateNames());
rg.setLatitude(toponym.getLatitude());
rg.setLongitude(toponym.getLongitude());
rg.setPopulacao(toponym.getPopulation());
resultado.add(rg);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultado;
}
开发者ID:dwws-ufes,项目名称:2014-infotur,代码行数:35,代码来源:RDFService.java
示例3: getBoundariesWKT
import org.geonames.ToponymSearchCriteria; //导入依赖的package包/类
/**
* Returns the location of the first toponym resulting from a GeoNames
* Web Service search based on the given address parameter.
*
* <p>
* Due to the GeoNames capabilities, this function only returns a single
* POINT geometry as WKT boundaries.
* </p>
*
* @param the human-readable address to geocode.
*
* @return the WTK POINT or null if no toponym matches the address of if
* an communication error occurred.
*/
@Override
public String getBoundariesWKT(final String address)
{
// Prepare search criteria
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
searchCriteria.setQ(address);
// Search address
ToponymSearchResult searchResult;
try
{
searchResult = WebService.search(searchCriteria);
}
catch (Exception exception)
{
LOGGER.warn("Error while performing GeoNames query: " +
exception.getMessage ());
return null;
}
// Process search result (if any)
String wkt_point = null;
if (searchResult.getTotalResultsCount() > 0)
{
Toponym toponym = searchResult.getToponyms().get(0);
wkt_point = "POINT (" +
toponym.getLongitude() + " " + toponym.getLatitude() + ")";
}
// Return WKT geometry
return wkt_point;
}
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:49,代码来源:GeoNamesGeocoder.java
示例4: getGeoNames
import org.geonames.ToponymSearchCriteria; //导入依赖的package包/类
private void getGeoNames(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getGeoNames
choice1.removeAll();
WebService.setUserName("manfredegger"); // add your username here
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
searchCriteria.setQ(jTextField1.getText());
ToponymSearchResult searchResult = null;
try {
//Request to geonames...
searchResult = WebService.search(searchCriteria);
} catch (Exception ex) {
Logger.getLogger(SHPProjFinder.class.getName()).log(Level.SEVERE, null, ex);
}
//get List of geoNames with LON/LAT values
int u = 0;
for (Toponym toponym : searchResult.getToponyms()) {
if (u == 0 && (toponym.getName().toLowerCase().contains(jTextField1.getText().toLowerCase()) && toponym.getFeatureClass().name().toLowerCase().equals("P".toLowerCase()))) {
textField6.setText("" + toponym.getLongitude());
textField5.setText("" + toponym.getLatitude());
u++;
}
if (toponym.getName().toLowerCase().contains(jTextField1.getText().toLowerCase()) && toponym.getFeatureClass().name().toLowerCase().equals("P".toLowerCase())) {
choice1.add(toponym.getName() + " LAT: " + toponym.getLatitude() + " LON: " + toponym.getLongitude());
}
}
}
开发者ID:maegger,项目名称:SHPProjFinder,代码行数:32,代码来源:SHPProjFinder.java
示例5: generateGeoLocations
import org.geonames.ToponymSearchCriteria; //导入依赖的package包/类
public GeoLocationWithOptions[] generateGeoLocations(String[] locations_name) {
WebService.setUserName("julia94"); // add your username here
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
List<GeoLocationWithOptions> geo_locations = new LinkedList<GeoLocationWithOptions>();
for(String location_name: locations_name){
searchCriteria.setQ(location_name);
GeoLocationWithOptions geo_location = new GeoLocationWithOptions(location_name);
Set<String> countries = new HashSet<String>();
ToponymSearchResult searchResult;
try {
searchResult = WebService.search(searchCriteria);
for (Toponym toponym : searchResult.getToponyms()) {
if(!countries.contains(toponym.getCountryName().toLowerCase())){
countries.add(toponym.getCountryName().toLowerCase());
geo_location.add(location_name, toponym.getLatitude(), toponym.getLongitude(), toponym.getCountryName());
}
}
geo_locations.add(geo_location);
} catch (Exception e) {
// TODO Auto-generated catch block
geo_locations.add(null);
}
}
return (GeoLocationWithOptions[]) geo_locations.toArray();
}
开发者ID:rkhatib,项目名称:topotext,代码行数:30,代码来源:GenerateGeoCoordinatesGeoNames.java
注:本文中的org.geonames.ToponymSearchCriteria类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论