Skip to content

featureFilter: $type filter does not match Multi* geometries #1346

@MikkoSteerpath

Description

@MikkoSteerpath

Describe the bug
According to the spec, a filter like `["==", "$type", "Polygon"] should match both "MultiPolygon" and "Polygon" geometries. However when using featureFilter() api, this is not the case.

To Reproduce
Jest test case:

import { featureFilter, LegacyFilterSpecification } from '@maplibre/maplibre-gl-style-spec';

test('$type == "Polygon" should match Polygon and MultiPolygon features', () => {
  const typeFilterPoly: LegacyFilterSpecification = ['==', '$type', 'Polygon'];

  const { filter: matchesPolygon } = featureFilter(typeFilterPoly);
  expect(matchesPolygon({ zoom: 14 }, { type: 'Polygon', properties: {} })).toBe(true);
  expect(matchesPolygon({ zoom: 14 }, { type: 'LineString', properties: {} })).toBe(false);
  // This one fails currently: 
  expect(matchesPolygon({ zoom: 14 }, { type: 'MultiPolygon', properties: {} })).toBe(true);
});

Expected behavior
Tests should pass, including the last one.

Desktop (please complete the following information):
tested with version 24.3.0

Additional context
Discussed briefly with Harel Mazor in slack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions