final TileLayer layer = poll.getLayer();
final GeoRSSFeedDefinition pollDef = poll.getPollDef();
logger.info("Polling GeoRSS feed for layer " + layerName + ": " + pollDef.toString());
final StorageBroker storageBroker = seeder.getStorageBroker();
final String previousUpdatedEntry = storageBroker.getLayerMetadata(layerName, LAST_UPDATED);
final String gridSetId = pollDef.getGridSetId();
final URL feedUrl = new URL(templateFeedUrl(pollDef.getFeedUrl(), previousUpdatedEntry));
final String httpUsername = pollDef.getHttpUsername();
final String httpPassword = pollDef.getHttpUsername();
logger.debug("Getting GeoRSS reader for " + feedUrl.toExternalForm());
final GeoRSSReaderFactory geoRSSReaderFactory = new GeoRSSReaderFactory();
GeoRSSReader geoRSSReader = null;
try {
geoRSSReader = geoRSSReaderFactory.createReader(feedUrl, httpUsername, httpPassword);
} catch (IOException ioe) {
logger.error("Failed to fetch RSS feed from " + feedUrl + "\n" + ioe.getMessage());
return;
}
logger.debug("Got reader for " + pollDef.getFeedUrl()
+ ". Creating geometry filter matrix for gridset " + gridSetId + " on layer "
+ layerName);
final int maxMaskLevel = pollDef.getMaxMaskLevel();
final GeoRSSTileRangeBuilder matrixBuilder = new GeoRSSTileRangeBuilder(layer, gridSetId,
maxMaskLevel);
logger.debug("Creating tile range mask based on GeoRSS feed's geometries from "
+ feedUrl.toExternalForm() + " for " + layerName);
final GeometryRasterMaskBuilder tileRangeMask = matrixBuilder.buildTileRangeMask(
geoRSSReader, previousUpdatedEntry);
if (tileRangeMask == null) {
logger.info("Did not create a tileRangeMask, presumably no new entries in feed.");
return;
}
// store last updated entry to persist even after a restart
final String lastUpdatedEntry = matrixBuilder.getLastEntryUpdate();
storageBroker.putLayerMetadata(layerName, LAST_UPDATED, lastUpdatedEntry);
logger.debug("Created tile range mask based on GeoRSS geometry feed from " + pollDef
+ " for " + layerName + ". Calculating number of affected tiles...");
_logImagesToDisk(tileRangeMask);