geopandas / pyogrio

Vectorized vector I/O using OGR
https://pyogrio.readthedocs.io
MIT License
274 stars 23 forks source link

ENH: Centralize the "driver" properties #81

Open theroggy opened 2 years ago

theroggy commented 2 years ago

Centralize the "driver" properties by expanding on the current DRIVERS dict as a dict/class/enum to add e.g. following things as properties:

jorisvandenbossche commented 2 years ago

That sounds as a good idea.

It could be something like a simple class like, or using dataclasses:

from dataclasses import dataclass

@dataclass
class DriverInfo:
    name: str
    ext: str
    ...

    def __str__(self):
        return self.name

GeoPackage = DriverInfo("GPKG", ext="gpkg", ...)

and then we can parametrize the tests with those objects, and inside the tests use driver.name or driver.ext etc?

theroggy commented 2 years ago

This is what I use in geofileops:

It's a combination of a dataclass that's filled up using a .csv configuration file + an enum to support typo-safety when using drivers.

An advantage is that the properties are maintained in a .csv, which gives a good overview and easy way to maintain all properties if many drivers and many properties need to be maintained.

A disadvantage is that the properties are maintained in a .csv, which gives some odd plumbing code. So I think there should be cleaner ways to deal with this... but didn't think of any at the time of writing.

Anyway, it could give some inspiration... both on things that might be good ideas and things that aren't ;-).