Class BaseCheck<T>
- java.lang.Object
-
- org.openstreetmap.atlas.checks.base.BaseCheck<T>
-
- Type Parameters:
T- the type for the flagged identifiers
- All Implemented Interfaces:
java.io.Serializable,Check
- Direct Known Subclasses:
AbbreviatedNameCheck,AddressPointMatchCheck,AddressStreetNameCheck,ApproximateWayCheck,AreasWithHighwayTagCheck,AtGradeSignPostCheck,BigNodeBadDataCheck,BoundaryIntersectionCheck,BridgeDetailedInfoCheck,BuildingRoadIntersectionCheck,ConcerningAngleBuildingCheck,ConditionalRestrictionCheck,ConflictingAreaTagCombination,ConflictingTagCombinationCheck,ConnectivityCheck,ConstructionCheck,DuplicateLocationInPolyLineCheck,DuplicateMapFeatureCheck,DuplicateNodeCheck,DuplicatePointCheck,DuplicateRelationCheck,DuplicateWaysCheck,EdgeCrossingEdgeCheck,FixMeReviewCheck,FloatingEdgeCheck,GeneralizedCoastlineCheck,GenericTagCheck,HighwayAccessCheck,HighwayIntersectionCheck,HighwayMissingNameAndRefTagCheck,HighwayToFerryTagCheck,ImproperAndUnknownRoadNameCheck,InconsistentRoadClassificationCheck,IntersectingBuildingsCheck,IntersectionAtDifferentLayersCheck,InvalidAccessTagCheck,InvalidCharacterNameTagCheck,InvalidGeometryCheck,InvalidLanesTagCheck,InvalidMiniRoundaboutCheck,InvalidMultiPolygonRelationCheck,InvalidPiersCheck,InvalidSignBoardRelationCheck,InvalidTagsCheck,InvalidTurnLanesValueCheck,InvalidTurnRestrictionCheck,LevelCrossingOnRailwayCheck,LineCrossingBuildingCheck,LineCrossingWaterBodyCheck,LoneNodeCheck,LongNameCheck,LongSegmentCheck,MalformedPolyLineCheck,MalformedRoundaboutCheck,MissingRelationTypeCheck,MixedCaseNameCheck,NodeValenceCheck,OceanBleedingCheck,OneMemberRelationCheck,OpenBoundaryCheck,OrphanNodeCheck,OverlappingAOIPolygonCheck,OverlappingEdgeCheck,PedestrianAreaOverlappingEdgeCheck,PoolSizeCheck,RoadLinkCheck,RoadNameGapCheck,RoadNameSpellingConsistencyCheck,RoundaboutClosedLoopCheck,RoundaboutConnectorCheck,RoundaboutHighwayTagCheck,RoundaboutMissingTagCheck,RoundaboutValenceCheck,RouteRelationCheck,SelfIntersectingPolylineCheck,SeparateSidewalkTagCheck,ShadowDetectionCheck,SharpAngleCheck,ShortNameCheck,ShortSegmentCheck,SignPostCheck,SimilarTagValueCheck,SingleSegmentMotorwayCheck,SinkIslandCheck,SnakeRoadCheck,SourceMaxspeedCheck,SpikyBuildingCheck,StreetNameCheck,StreetNameIntegersOnlyCheck,SuddenHighwayTypeChangeCheck,TallBuildingCheck,TollValidationCheck,TunnelBridgeHeightLimitCheck,UnknownHighwayTagCheck,UnusualLayerTagsCheck,UnwalkableWaysCheck,ValenceOneImportantRoadCheck,WaterAreaCheck,WaterbodyAndIslandSizeCheck,WaterWayCheck
public abstract class BaseCheck<T> extends java.lang.Object implements Check, java.io.Serializable
Abstract BaseCheck for an Integrity Check- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPARAMETER_ACCEPT_PIERSstatic java.lang.StringPARAMETER_CHALLENGEstatic java.lang.StringPARAMETER_DENYLIST_COUNTRIESstatic java.lang.StringPARAMETER_FLAGstatic java.lang.StringPARAMETER_PERMITLIST_COUNTRIESstatic java.lang.StringPARAMETER_PERMITLIST_TAGSstatic java.lang.StringPARAMETER_USE_EXTERNAL_DATA
-
Constructor Summary
Constructors Constructor Description BaseCheck(org.openstreetmap.atlas.utilities.configuration.Configuration configuration)Default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanacceptPier()If the check wants to accept piers as part of it's evaluation then it will need to override this function and returntrue.java.util.Optional<CheckFlag>check(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)The check for the atlas objectjava.util.function.Predicate<org.openstreetmap.atlas.geography.atlas.items.AtlasObject>checkObjectFilter()voidclear()Clears all flagged feature identifiers for this check.protected voidclearFlaggedIdentifiers()protected java.lang.StringconfigurationKey(java.lang.Class<?> type, java.lang.String key)protected java.lang.StringconfigurationKey(java.lang.String key)Configuration Keys in the Integrity Framework are based on the check simple classname.protected <U> UconfigurationValue(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue)protected <U,V>
VconfigurationValue(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue, java.util.function.Function<U,V> transform)protected CheckFlagcreateFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction)protected CheckFlagcreateFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)protected CheckFlagcreateFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions)protected CheckFlagcreateFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)protected CheckFlagcreateFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction)protected CheckFlagcreateFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)protected CheckFlagcreateFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions)protected CheckFlagcreateFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)protected abstract java.util.Optional<CheckFlag>flag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)java.lang.Iterable<CheckFlag>flags(org.openstreetmap.atlas.geography.atlas.Atlas atlas)ChallengegetChallenge()Gets a challenge object for the specific checkjava.lang.StringgetCheckName()Gets the name of this checkorg.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFiltergetCheckPolygonFilter()java.util.List<java.lang.String>getCountries()Gets the permitlisted countries for this check.java.util.List<java.lang.String>getDenylistCountries()protected java.util.List<java.lang.String>getFallbackInstructions()Method to implement for inheriting checks to return the default set of instruction formats that will be the last resort ingetLocalizedInstruction(int, Object[])protected java.util.Set<T>getFlaggedIdentifiers()org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFiltergetGlobalPolygonFilter()java.util.LocalegetLocale()java.lang.StringgetLocalizedInstruction(int index, java.lang.Object... objects)Uses the default of configured locale to grab the localized instruction format from the configuration.protected java.lang.StringgetTaskIdentifier(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects)The task identifier is ordered to maintain identifier uniqueness.protected java.lang.StringgetTaskIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)protected java.lang.StringgetUniqueObjectIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)Similar togetUniqueOSMIdentifier(AtlasObject)except instead of using the OSM identifier we use the Atlas identifierprotected java.lang.StringgetUniqueOSMIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)Generates a unique identifier given anAtlasObject.protected booleanisFlagged(T identifier)voidlogStatus()Helper for debugging.protected voidmarkAsFlagged(T identifier)protected booleanuseExternalData()booleanvalidCheckForCountry(java.lang.String country)The country check will first check the country permitlist and if the country is contained in the permitlist it is allowed, after that the country is checked it against denylist and if contained in the denylist will not be allowed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.atlas.checks.base.Check
finder, validCheckForObject
-
-
-
-
Field Detail
-
PARAMETER_ACCEPT_PIERS
public static final java.lang.String PARAMETER_ACCEPT_PIERS
- See Also:
- Constant Field Values
-
PARAMETER_DENYLIST_COUNTRIES
public static final java.lang.String PARAMETER_DENYLIST_COUNTRIES
- See Also:
- Constant Field Values
-
PARAMETER_CHALLENGE
public static final java.lang.String PARAMETER_CHALLENGE
- See Also:
- Constant Field Values
-
PARAMETER_FLAG
public static final java.lang.String PARAMETER_FLAG
- See Also:
- Constant Field Values
-
PARAMETER_PERMITLIST_COUNTRIES
public static final java.lang.String PARAMETER_PERMITLIST_COUNTRIES
- See Also:
- Constant Field Values
-
PARAMETER_PERMITLIST_TAGS
public static final java.lang.String PARAMETER_PERMITLIST_TAGS
- See Also:
- Constant Field Values
-
PARAMETER_USE_EXTERNAL_DATA
public static final java.lang.String PARAMETER_USE_EXTERNAL_DATA
- See Also:
- Constant Field Values
-
-
Method Detail
-
check
public java.util.Optional<CheckFlag> check(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
Description copied from interface:CheckThe check for the atlas object
-
checkObjectFilter
public final java.util.function.Predicate<org.openstreetmap.atlas.geography.atlas.items.AtlasObject> checkObjectFilter()
-
clear
public void clear()
Clears all flagged feature identifiers for this check. Primary purpose is to reset flagged features during testing. Be careful in using this for actual production checks.
-
flags
public java.lang.Iterable<CheckFlag> flags(org.openstreetmap.atlas.geography.atlas.Atlas atlas)
Description copied from interface:CheckCompute and return all theCheckFlags from this check, givenAtlasEntitys andRelations.ComplexEntitys can be added as well, using the appropriateFinder.
-
getChallenge
public Challenge getChallenge()
Description copied from interface:CheckGets a challenge object for the specific check- Specified by:
getChallengein interfaceCheck- Returns:
- a
Challenge
-
getCheckName
public final java.lang.String getCheckName()
Description copied from interface:CheckGets the name of this check- Specified by:
getCheckNamein interfaceCheck- Returns:
- a
Stringname
-
getCheckPolygonFilter
public org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getCheckPolygonFilter()
-
getCountries
public java.util.List<java.lang.String> getCountries()
Gets the permitlisted countries for this check. If an empty list is returned it safe to assume this check applies to all countries.- Returns:
- a list of country ISO3 codes
-
getDenylistCountries
public java.util.List<java.lang.String> getDenylistCountries()
-
getGlobalPolygonFilter
public org.openstreetmap.atlas.utilities.filters.AtlasEntityPolygonsFilter getGlobalPolygonFilter()
-
getLocale
public java.util.Locale getLocale()
-
getLocalizedInstruction
public final java.lang.String getLocalizedInstruction(int index, java.lang.Object... objects)Uses the default of configured locale to grab the localized instruction format from the configuration. If the localized version does not contain the given index instruction then it will be grabbed from the FallBack Instructions. AIndexOutOfBoundsExceptionwill be thrown if the instruction index is out of the Fallback Instructions. The instruction format will then be formatted using the provided objects and returned.- Parameters:
index- The index of the desired instruction format.objects- The objects to be used in constructing the instruction- Returns:
- String of the localized instruction, or the
DEFAULT_LOCALElanguage instruction, or the fallback instruction. In that order if the previous isn't present in the configuration.
-
logStatus
public void logStatus()
Description copied from interface:CheckHelper for debugging. Implement in check to log info after check is run.
-
validCheckForCountry
public boolean validCheckForCountry(java.lang.String country)
The country check will first check the country permitlist and if the country is contained in the permitlist it is allowed, after that the country is checked it against denylist and if contained in the denylist will not be allowed.- Specified by:
validCheckForCountryin interfaceCheck- Parameters:
country- country ISO3 code to check- Returns:
trueif valid check for country, otherwisefalse
-
acceptPier
protected boolean acceptPier()
If the check wants to accept piers as part of it's evaluation then it will need to override this function and returntrue. By default piers are skipped.- Returns:
trueif we want to check pier edges,falseif we want to skip them
-
clearFlaggedIdentifiers
protected void clearFlaggedIdentifiers()
-
configurationKey
protected final java.lang.String configurationKey(java.lang.Class<?> type, java.lang.String key)
-
configurationKey
protected final java.lang.String configurationKey(java.lang.String key)
Configuration Keys in the Integrity Framework are based on the check simple classname.- Parameters:
key- key part for a specific configuration item defined for this class- Returns:
- complete key for lookup
-
configurationValue
protected <U> U configurationValue(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue)
-
configurationValue
protected <U,V> V configurationValue(org.openstreetmap.atlas.utilities.configuration.Configuration configuration, java.lang.String key, U defaultValue, java.util.function.Function<U,V> transform)
-
createFlag
protected CheckFlag createFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction)
-
createFlag
protected CheckFlag createFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)
-
createFlag
protected CheckFlag createFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction)
-
createFlag
protected CheckFlag createFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.lang.String instruction, java.util.List<org.openstreetmap.atlas.geography.Location> points)
-
createFlag
protected CheckFlag createFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)
-
createFlag
protected CheckFlag createFlag(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects, java.util.List<java.lang.String> instructions)
-
createFlag
protected CheckFlag createFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions)
-
createFlag
protected CheckFlag createFlag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object, java.util.List<java.lang.String> instructions, java.util.List<org.openstreetmap.atlas.geography.Location> points)
-
flag
protected abstract java.util.Optional<CheckFlag> flag(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
-
getFallbackInstructions
protected java.util.List<java.lang.String> getFallbackInstructions()
Method to implement for inheriting checks to return the default set of instruction formats that will be the last resort ingetLocalizedInstruction(int, Object[])- Returns:
- The set of instructions to fall back to if configuration results in none.
-
getFlaggedIdentifiers
protected java.util.Set<T> getFlaggedIdentifiers()
-
getTaskIdentifier
protected java.lang.String getTaskIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
-
getTaskIdentifier
protected java.lang.String getTaskIdentifier(java.util.Set<? extends org.openstreetmap.atlas.geography.atlas.items.AtlasObject> objects)
The task identifier is ordered to maintain identifier uniqueness.- Parameters:
objects- set ofAtlasObjects comprising this task- Returns:
- a unique string identifier for this task, made from the sorted object identifiers
-
getUniqueOSMIdentifier
protected java.lang.String getUniqueOSMIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
Generates a unique identifier given anAtlasObject. OSM/Atlas objects with different types can share the identifier (way 12345 - node 12345). This method makes sure we generate a truly unique identifier, based on the OSM identifier, among different types for anAtlasObject. If the AtlasObject is an instanceof AtlasEntity then it will simply use the type for the first part of the identifier, otherwise it will use the simple class name.- Parameters:
object-AtlasObjectto generate unique identifier for- Returns:
- unique object identifier among different types
-
getUniqueObjectIdentifier
protected java.lang.String getUniqueObjectIdentifier(org.openstreetmap.atlas.geography.atlas.items.AtlasObject object)
Similar togetUniqueOSMIdentifier(AtlasObject)except instead of using the OSM identifier we use the Atlas identifier- Parameters:
object-AtlasObjectto generate unique identifier for- Returns:
- unique object identifier among different types
-
isFlagged
protected final boolean isFlagged(T identifier)
-
markAsFlagged
protected final void markAsFlagged(T identifier)
-
useExternalData
protected final boolean useExternalData()
-
-