Skip to content

REGR: fiona 1.10 doesn't support multiple int widths in the same file #1501

@m-richards

Description

@m-richards

This has the same underlying issue as my comment in #1469 but is probably more straightforward to understand. This setup below works, Bnode has a value larger than an int32.

import logging

logging.basicConfig(
    level=logging.DEBUG,  # capture debug and above
    format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
)

logger = logging.getLogger(__name__)
import fiona
schema={'properties': {'Anode': 'int64', 'Bnode': 'int64'}, 'geometry': 'LineString'}
crs = "EPSG:4326"
coordinates = [(115.638812, -32.62857), (115.637933, -32.631091)]
records = [fiona.Feature(geometry=fiona.Geometry(coordinates=coordinates, type='LineString'), id='23998', 
                         properties=fiona.Properties(Anode=25194, Bnode=2519425196))]

with fiona.open(
    "test_links.gpkg",
    "w",
    driver='GPKG',
    crs=crs,
    schema=schema,
) as f:
    print(records)

but if the schema for Anode is updated to be an int32, writing bnode will result in an overflow error

schema={'properties': {'Anode': 'int32', 'Bnode': 'int64'}, 'geometry': 'LineString'}
with fiona.open(
    "test_links.gpkg",
    "w",
    driver='GPKG',
    crs=crs,
    schema=schema,
) as f:
    print(records)

This seems to work on fiona 1.9.6 and up to ea24f55 and is broken
from b6e62cc.

I think this case can be solved by defining the property_setter_cache in ogrext.pyx to cache on both the input type and the schema type, rather than doing anything around determining the int width.

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