Ignore:
Timestamp:
2021-05-06T17:39:27+02:00 (3 years ago)
Author:
simon04
Message:

fix #17177 - Add support for Mapbox Vector Tile (patch by taylor.smock)

Signed-off-by: Taylor Smock <tsmock@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java

    r12656 r17862  
    1010
    1111/**
    12  * Class for applying {@link Filter}s to {@link OsmPrimitive}s.
     12 * Class for applying {@link Filter}s to {@link IPrimitive}s.
    1313 *
    1414 * Provides a bridge between Filter GUI and the data.
     
    2525     * Apply the filters to the primitives of the data set.
    2626     *
     27     * @param <T> The primitive type
    2728     * @param all the collection of primitives for that the filter state should be updated
    2829     * @param filters the filters
    2930     * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
    3031     * @throws SearchParseError if the search expression in a filter cannot be parsed
    31      * @since 12383
     32     * @since 12383, xxx (generics)
    3233     */
    33     public static boolean executeFilters(Collection<OsmPrimitive> all, Filter... filters) throws SearchParseError {
     34    public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(Collection<T> all, Filter... filters)
     35            throws SearchParseError {
    3436        return executeFilters(all, FilterMatcher.of(filters));
    3537    }
     
    3840     * Apply the filters to the primitives of the data set.
    3941     *
     42     * @param <T> The primitive type
    4043     * @param all the collection of primitives for that the filter state should be updated
    4144     * @param filterMatcher the FilterMatcher
    4245     * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
     46     * @since xxx (generics)
    4347     */
    44     public static boolean executeFilters(Collection<OsmPrimitive> all, FilterMatcher filterMatcher) {
     48    public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(Collection<T> all, FilterMatcher filterMatcher) {
    4549        boolean changed;
    4650        // first relations, then ways and nodes last; this is required to resolve dependencies
    47         changed = doExecuteFilters(SubclassFilteredCollection.filter(all, Relation.class::isInstance), filterMatcher);
    48         changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, Way.class::isInstance), filterMatcher);
    49         changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, Node.class::isInstance), filterMatcher);
     51        changed = doExecuteFilters(SubclassFilteredCollection.filter(all, IRelation.class::isInstance), filterMatcher);
     52        changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, IWay.class::isInstance), filterMatcher);
     53        changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, INode.class::isInstance), filterMatcher);
    5054        return changed;
    5155    }
    5256
    53     private static boolean doExecuteFilters(Collection<OsmPrimitive> all, FilterMatcher filterMatcher) {
     57    private static <T extends IPrimitive & IFilterablePrimitive> boolean doExecuteFilters(Collection<T> all, FilterMatcher filterMatcher) {
    5458
    5559        boolean changed = false;
    5660
    57         for (OsmPrimitive primitive: all) {
     61        for (T primitive : all) {
    5862            FilterType hiddenType = filterMatcher.isHidden(primitive);
    5963            if (hiddenType != FilterType.NOT_FILTERED) {
     
    7680     * Apply the filters to a single primitive.
    7781     *
     82     * @param <T> the primitive type
    7883     * @param primitive the primitive
    7984     * @param filterMatcher the FilterMatcher
    8085     * @return true, if the filter state (normal / disabled / hidden)
    8186     * of the primitive has changed in the process
     87     * @since xxx (generics)
    8288     */
    83     public static boolean executeFilters(OsmPrimitive primitive, FilterMatcher filterMatcher) {
     89    public static <T extends IPrimitive & IFilterablePrimitive> boolean executeFilters(T primitive, FilterMatcher filterMatcher) {
    8490        return doExecuteFilters(Collections.singleton(primitive), filterMatcher);
    8591    }
     
    8793    /**
    8894     * Clear all filter flags, i.e.&nbsp;turn off filters.
     95     * @param <T> the primitive type
    8996     * @param prims the primitives
    9097     * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
    9198     * @since 12388 (signature)
    9299     */
    93     public static boolean clearFilterFlags(Collection<OsmPrimitive> prims) {
     100    public static <T extends IPrimitive & IFilterablePrimitive> boolean clearFilterFlags(Collection<T> prims) {
    94101        boolean changed = false;
    95         for (OsmPrimitive osm : prims) {
     102        for (T osm : prims) {
    96103            changed |= osm.unsetDisabledState();
    97104        }
Note: See TracChangeset for help on using the changeset viewer.