use of org.openstreetmap.atlas.geography.atlas.items.AtlasEntity in project atlas-checks by osmlab.
the class IntegrityCheckSparkJob method executeChecks.
/**
* Executes all {@link BaseCheck}s on the given {@link Atlas}. Each check runs in a separate
* thread. The checks go over all {@link AtlasEntity}s and {@link Relation}s.
* {@link ComplexEntity}s can be processed by using the appropriate {@link Finder} and adding
* them to the {@link Iterable} of objects.
*
* @param atlas
* the {@link Atlas} on which the checks will be run
* @param checksToRun
* the set of {@link BaseCheck}s to execute
* @param configuration
* {@link MapRouletteConfiguration} to create a new {@link MapRouletteClient}s
*/
@SuppressWarnings("rawtypes")
private static void executeChecks(final String country, final Atlas atlas, final Set<BaseCheck> checksToRun, final MapRouletteConfiguration configuration) {
final Pool checkExecutionPool = new Pool(checksToRun.size(), "Check execution pool", POOL_DURATION_BEFORE_KILL);
checksToRun.stream().filter(check -> check.validCheckForCountry(country)).forEach(check -> checkExecutionPool.queue(new RunnableCheck(country, check, new MultiIterable<>(atlas.items(), atlas.relations(), findComplexEntities(check, atlas)), MapRouletteClient.instance(configuration))));
checkExecutionPool.close();
}
use of org.openstreetmap.atlas.geography.atlas.items.AtlasEntity in project atlas-checks by osmlab.
the class AbbreviatedNameCheck method flag.
/**
* Flags {@link AtlasObject}s that has names with abbreviations.
*/
@Override
protected Optional<CheckFlag> flag(final AtlasObject object) {
// Mark OSM identifier as we are processing it
this.markAsFlagged(this.getUniqueOSMIdentifier((AtlasEntity) object));
// Fetch the name
final Optional<String> optionalName = NameTag.getNameOf(object);
if (!optionalName.isPresent()) {
return Optional.empty();
}
// Lowercase name and parse it into tokens
final String name = optionalName.get();
final String lowercaseName = name.toLowerCase(this.getLocale());
final Set<String> tokens = Sets.newHashSet(NAME_SPLITTER.split(lowercaseName));
// Flag if it has any abbreviations
if (tokens.stream().anyMatch(this.abbreviations::contains)) {
final CheckFlag flag = this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier(), name));
return Optional.of(flag);
}
return Optional.empty();
}
Aggregations