mapbox/tile-cover

indexes method generates empty strings for features above/below max Y coordinate

Nmargolis opened this issue · 0 comments

Context:

Not sure if this is expected behavior, but when the tile-cover indexes method is used on a geojson feature that has some coordinates above or below the max y coordinate limit for mercator maps, it generates a bunch of empty strings in addition to the quadkeys. It's not a big deal to handle this where we're using it, but just wanted to flag it in case this isn't expected behavior.

Steps to reproduce:

const tileCover = require('@mapbox/tile-cover');

const featureMaxY = {
    'type': 'Feature',
    'properties': {},
    'geometry': {
        'type': 'Polygon',
        'coordinates': [
            [
                [-110.5, 85.05],
                [-110.25, 85.05],
                [-110.25, 85.0511287798065],
                [-110.5, 85.0511287798065],
                [-110.5, 85.05]
            ]
        ]
    }
};

const featureOverMaxY = {
    'type': 'Feature',
    'properties': {},
    'geometry': {
        'type': 'Polygon',
        'coordinates': [
            [
                [-110.5, 85.05],
                [-110.25, 85.05],
                [-110.25, 85.0511287798066], // Or anything above this
                [-110.5, 85.0511287798066], // Or anything above this
                [-110.5, 85.05]
            ]
        ]
    }
};

const quadkeysAtMax = tileCover.indexes(featureMaxY.geometry, { min_zoom: 12, max_zoom: 12 });
console.log('Total quadkeys: ', quadkeysAtMax.length); // 4
console.log('Quadkeys: ', quadkeysAtMax);
// Quadkeys:  [ '001100010110', '001100010111', '001100011000', '001100011001' ]

const quadkeysOverMax = tileCover.indexes(featureOverMaxY.geometry, { min_zoom: 12, max_zoom: 12 });
console.log('Total quadkeys: ', quadkeysOverMax.length); // 8
console.log('Quadkeys: ', quadkeysOverMax);
// Quadkeys:  [ '001100010110', '001100010111', '001100011000', '001100011001', '', '', '', '' ]