本文整理汇总了Java中com.rometools.modules.georss.GeoRSSUtils类的典型用法代码示例。如果您正苦于以下问题:Java GeoRSSUtils类的具体用法?Java GeoRSSUtils怎么用?Java GeoRSSUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoRSSUtils类属于com.rometools.modules.georss包,在下文中一共展示了GeoRSSUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertTestInputStream
import com.rometools.modules.georss.GeoRSSUtils; //导入依赖的package包/类
/**
* test expected latitude and longitude values in items of test file.
*
* @param in testfeed
* @param expectedLat expected latitude values
* @param expectedLng expected longitude values
* @throws Exception if file not found or not accessible
*/
private void assertTestInputStream(final InputStream in, final Double[] expectedLat, final Double[] expectedLng) throws Exception {
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new XmlReader(in));
final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = entries.get(i);
final GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
final Position position = geoRSSModule.getPosition();
if (expectedLat[i] == null || expectedLng[i] == null) {
assertNull("position " + i, position);
} else {
assertEquals("lat " + i, expectedLat[i], position.getLatitude(), DELTA);
assertEquals("lng " + i, expectedLng[i], position.getLongitude(), DELTA);
}
}
}
示例2: load
import com.rometools.modules.georss.GeoRSSUtils; //导入依赖的package包/类
/**
* Check a RSS flow from an URL
*
* @param dataProducer {@link IDataProducer} contains the data queue
* @see WeatherProducerConnector#source
* @see WeatherProducerConnector#METRICS_LOGGER
*/
@Override
public void load(IDataProducer dataProducer) {
Objects.requireNonNull(dataProducer);
while (!Thread.currentThread().isInterrupted()) {
try {
SyndFeedInput input = new SyndFeedInput(false, Locale.FRANCE);
XmlReader reader = new XmlReader(url);
SyndFeed feed = input.build(reader);
long start = System.currentTimeMillis();
feed.getEntries().forEach(entry -> {
Date date = entry.getPublishedDate();
String description = entry.getDescription().getValue();
GeoRSSModule module = GeoRSSUtils.getGeoRSS(entry);
if (date == null) {
date = Date.from(Instant.now());
}
if (description == null) {
description = "no description";
}
if (module != null && module.getPosition() != null) {
LatLong latLong = new LatLong(module.getPosition().getLatitude(), module.getPosition().getLongitude());
Event event = new Event(latLong, date, date, description, source);
dataProducer.push(event);
long end = System.currentTimeMillis();
long result = end - start;
METRICS_LOGGER.log("time_process_" + this.source, result);
LOGGER.info("Event " + event + " has been pushed");
}
});
} catch (IOException | FeedException e) {
LOGGER.error(e.getMessage());
return;
}
}
}