Skip to content

Commit

Permalink
Revert "Use TypedDict instead of regular Python dict for the GeoMetaD…
Browse files Browse the repository at this point in the history
…ata"

This reverts commit 847998e.
  • Loading branch information
weiji14 committed Apr 20, 2022
1 parent 847998e commit 801d09c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
17 changes: 3 additions & 14 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
import re
import sys
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypedDict, cast
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, cast

import fiona
import fiona.transform
Expand Down Expand Up @@ -37,13 +37,6 @@
ImageFolder.__module__ = "torchvision.datasets"


class GeoMetaData(TypedDict):
"""A dictionary for metadata to be stored in the rtree index."""

filepath: str
crs: CRS


class GeoDataset(Dataset[Dict[str, Any]], abc.ABC):
"""Abstract base class for datasets containing geospatial information.
Expand Down Expand Up @@ -375,9 +368,7 @@ def __init__(

coords = (minx, maxx, miny, maxy, mint, maxt)
self.index.insert(
id=i,
coordinates=coords,
obj=GeoMetaData(filepath=filepath, crs=crs),
id=i, coordinates=coords, obj=dict(filepath=filepath, crs=crs)
)
i += 1

Expand Down Expand Up @@ -566,9 +557,7 @@ def __init__(
maxt = sys.maxsize
coords = (minx, maxx, miny, maxy, mint, maxt)
self.index.insert(
id=i,
coordinates=coords,
obj=GeoMetaData(filepath=filepath, crs=crs),
id=i, coordinates=coords, obj=dict(filepath=filepath, crs=crs)
)
i += 1

Expand Down
4 changes: 2 additions & 2 deletions torchgeo/datasets/openbuildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from rasterio.crs import CRS
from rtree.index import Index, Property

from .geo import GeoMetaData, VectorDataset
from .geo import VectorDataset
from .utils import BoundingBox, check_integrity


Expand Down Expand Up @@ -281,7 +281,7 @@ def __init__(
filepath = os.path.join(
self.root, feature["properties"]["tile_url"].split("/")[-1]
)
self.index.insert(i, coords, GeoMetaData(filepath=filepath, crs=crs))
self.index.insert(i, coords, dict(filepath=filepath, crs=crs))
i += 1

if i == 0:
Expand Down

0 comments on commit 801d09c

Please sign in to comment.