Skip to content

Rendering/parsing fails for files with Infinity in metadata tilestats #658

Description

@ashwinuae

Description

When a .pmtiles file contains Infinity as a value within the tilestats attribute of the metadata, the library fails to render the file.

The issue seems to probably stem from the fact that Infinity is not a valid value in strict JSON (while it's handled fine in Javascript), causing the parser to fail when reading the header/metadata. If the metadata is manually edited to replace Infinity with a standard numeric value (e.g. '99999'), the file renders perfectly.

The same file opens and displays correctly in QGIS, suggesting the underlying vector data is valid, but the JS-based metadata parsing is the bottleneck.

Environment

  • Library: pmtiles (NPM)
  • Platform: Web/Node.js
  • Version: 4.4.0

Steps to Reproduce

  1. Generate a PMTiles file where an attribute has an infinite value.
  2. Attempt to load/render this file using the library (or say pmtiles.io).
  3. Observe failure to render the file.

Metadata Snippet (Cause of failure)

{
  "tilestats": {
    "layers": [
      {
        "layer": "Detour Factor",
        "attributes": [
          {
            "attribute": "detour_factor",
            "type": "number",
            "values": [
              2.0198,
              ...,
              Infinity
            ],
            "min": 2.0198,
            "max": Infinity
          }
        ]
      }
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions