src/main/java/de/blau/android/validation/BaseValidator.java
/**
     * Validate a Way with a highway tag
     * 
     * @param w the Way
     * @param highway the value of the highway tag
     * @return the status
     */
Validate a Way with a highway tag

@param w the Way
@param highway the value of the highway tag
@return the status
Validate a Way with a highway tag @param w the Way @param highway the value of the highway tag @return the status
int validateHighway(@NonNull Way w, @NonNull String highway) {
        int result = Validator.NOT_VALIDATED;
        Logic logic = App.getLogic();
        int layer = getLayer(w);
        de.blau.android.Map map = logic.getMap();
        if (unconnectedEndNodeValidation && map != null) {
            if (!map.getViewBox().equals(cachedViewBox)) {
                double centerLat = map.getViewBox().getCenterLat();
                double widthInMeters = GeoMath.haversineDistance(map.getViewBox().getLeft() / 1E7D, centerLat, map.getViewBox().getRight() / 1E7D, centerLat);
                tolerance = (float) (map.getPrefs().getConnectedNodeTolerance() / widthInMeters * map.getWidth());
                if (cachedViewBox == null) {
                    cachedViewBox = new ViewBox(map.getViewBox());
                } else {
                    cachedViewBox.set(map.getViewBox());
                }
            }
            try {
                checkNearbyWays(Tags.KEY_HIGHWAY, w, logic, layer, w.getFirstNode());
                checkNearbyWays(Tags.KEY_HIGHWAY, w, logic, layer, w.getLastNode());
            } catch (Exception ex) {
            }
        }
        if (highwayRoadValidation && Tags.VALUE_ROAD.equalsIgnoreCase(highway)) {
            result |= Validator.HIGHWAY_ROAD;
        }
        if (imperialUnitsValidation && geoContext != null) {
            boolean imperial = geoContext.imperial(w);
            if (imperial) {
                SortedMap<String, String> tags = w.getTags();
                Set<String> keys = w.getTags().keySet();
                for (String key : keys) {
                    if (Tags.isSpeedKey(key) && !tags.get(key).endsWith(Tags.MPH)) {
                        return result | Validator.IMPERIAL_UNITS;
                    }
                }
            }
        }
        return result;
    }
int validateHighway ( @ NonNull Way w , @ NonNull String highway ) { int result = Validator . NOT_VALIDATED ; Logic logic = App . getLogic ( ) ; int layer = getLayer ( w ) ; de . blau . android . Map map = logic . getMap ( ) ; if ( unconnectedEndNodeValidation && map != null ) { if ( ! map . getViewBox ( ) . equals ( cachedViewBox ) ) { double centerLat = map . getViewBox ( ) . getCenterLat ( ) ; double widthInMeters = GeoMath . haversineDistance ( map . getViewBox ( ) . getLeft ( ) / 1E7D , centerLat , map . getViewBox ( ) . getRight ( ) / 1E7D , centerLat ) ; tolerance = ( float ) ( map . getPrefs ( ) . getConnectedNodeTolerance ( ) / widthInMeters * map . getWidth ( ) ) ; if ( cachedViewBox == null ) { cachedViewBox = new ViewBox ( map . getViewBox ( ) ) ; } else { cachedViewBox . set ( map . getViewBox ( ) ) ; } } try { checkNearbyWays ( Tags . KEY_HIGHWAY , w , logic , layer , w . getFirstNode ( ) ) ; checkNearbyWays ( Tags . KEY_HIGHWAY , w , logic , layer , w . getLastNode ( ) ) ; } catch ( Exception ex ) { } } if ( highwayRoadValidation && Tags . VALUE_ROAD . equalsIgnoreCase ( highway ) ) { result |= Validator . HIGHWAY_ROAD ; } if ( imperialUnitsValidation && geoContext != null ) { boolean imperial = geoContext . imperial ( w ) ; if ( imperial ) { SortedMap < String , String > tags = w . getTags ( ) ; Set < String > keys = w . getTags ( ) . keySet ( ) ; for ( String key : keys ) { if ( Tags . isSpeedKey ( key ) && ! tags . get ( key ) . endsWith ( Tags . MPH ) ) { return result | Validator . IMPERIAL_UNITS ; } } } } return result ; }
Validate a Way with a highway tag
Validate a Way with a highway tag
// we try to cache these (tolerance) fairly expensive to calculate values at least as long as the ViewBox // hasn't changed // ignored // unsurveyed road