Skip to content

Commit 1392fbd

Browse files
authored
GeoDjango spatial reference fixes (#1265)
* Make SpatialReference accept int * Make CoordTransform only accept SpatialReference * Narrow OGRGeometry.transform's accepted types * Narrow GEOSGeometryBase.transform's accepted types
1 parent eff8175 commit 1392fbd

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

django-stubs/contrib/gis/gdal/geometries.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any
22

3+
from django.contrib.gis.gdal import CoordTransform, SpatialReference
34
from django.contrib.gis.gdal.base import GDALBase as GDALBase
45

56
class OGRGeometry(GDALBase):
@@ -63,7 +64,7 @@ class OGRGeometry(GDALBase):
6364
def ewkt(self) -> Any: ...
6465
def clone(self) -> Any: ...
6566
def close_rings(self) -> None: ...
66-
def transform(self, coord_trans: Any, clone: bool = ...) -> Any: ...
67+
def transform(self, coord_trans: CoordTransform | SpatialReference | str | int, clone: bool = ...) -> Any: ...
6768
def intersects(self, other: Any) -> Any: ...
6869
def equals(self, other: Any) -> Any: ...
6970
def disjoint(self, other: Any) -> Any: ...

django-stubs/contrib/gis/gdal/srs.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SpatialReference(GDALBase):
1111
destructor: Any
1212
axis_order: Any
1313
ptr: Any
14-
def __init__(self, srs_input: str = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ...
14+
def __init__(self, srs_input: str | int = ..., srs_type: str = ..., axis_order: Any | None = ...) -> None: ...
1515
def __getitem__(self, target: Any) -> Any: ...
1616
def attr_value(self, target: Any, index: int = ...) -> Any: ...
1717
def auth_name(self, target: Any) -> Any: ...
@@ -64,4 +64,4 @@ class SpatialReference(GDALBase):
6464
class CoordTransform(GDALBase):
6565
destructor: Any
6666
ptr: Any
67-
def __init__(self, source: Any, target: Any) -> None: ...
67+
def __init__(self, source: SpatialReference, target: SpatialReference) -> None: ...

django-stubs/contrib/gis/geos/geometry.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, TypeVar
22

33
from _typeshed import Self
4+
from django.contrib.gis.gdal import CoordTransform, SpatialReference
45
from django.contrib.gis.geometry import hex_regex as hex_regex # noqa: F401
56
from django.contrib.gis.geometry import json_regex as json_regex
67
from django.contrib.gis.geometry import wkt_regex as wkt_regex
@@ -92,7 +93,7 @@ class GEOSGeometryBase(GEOSBase):
9293
@property
9394
def crs(self) -> Any: ...
9495
ptr: Any
95-
def transform(self, ct: Any, clone: bool = ...) -> Any: ...
96+
def transform(self, ct: CoordTransform | SpatialReference | str | int, clone: bool = ...) -> Any: ...
9697
@property
9798
def boundary(self) -> Any: ...
9899
def buffer(self, width: Any, quadsegs: int = ...) -> Any: ...

0 commit comments

Comments
 (0)