@@ -62,11 +62,39 @@ class ProjCoord:
6262 y : float
6363 crs : pyproj .CRS
6464
65+ def __repr__ (self ) -> str :
66+ """Short string representation."""
67+ return f"{ self .__class__ .__name__ } ({ self .x } , { self .y } )"
68+
69+ def __str__ (self ) -> str :
70+ """Extensive string representation."""
71+ n_chars = len (self .__class__ .__name__ )
72+ return (
73+ f"{ self .__class__ .__name__ } \n { '-' * n_chars } \n "
74+ f"X: \n { self .x } \n "
75+ f"Y: \n { self .y } \n "
76+ f"Projection: \n { self .crs .to_proj4 ()} "
77+ )
78+
6579
6680@dataclass (frozen = True )
6781class GeogCoord (ProjCoord ):
6882 crs : pyproj .CRS = GEOG_CRS
6983
84+ def __repr__ (self ) -> str :
85+ """Short string representation."""
86+ return f"{ self .__class__ .__name__ } ({ self .x } , { self .y } )"
87+
88+ def __str__ (self ) -> str :
89+ """Extensive string representation."""
90+ n_chars = len (self .__class__ .__name__ )
91+ return (
92+ f"{ self .__class__ .__name__ } \n { '-' * n_chars } \n "
93+ f"X: \n { self .x } \n "
94+ f"Y: \n { self .y } \n "
95+ f"Projection: \n { self .crs .to_proj4 ()} "
96+ )
97+
7098
7199def convert_geom (arg : str | shapely .Geometry ) -> shapely .Geometry :
72100 return swkt .loads (arg ) if isinstance (arg , str ) else arg
@@ -87,6 +115,19 @@ def serialize(self) -> dict:
87115 """Serialise/encode class variables."""
88116 return {"geom" : self .geom .wkt , "crs" : self .crs .to_wkt ()}
89117
118+ def __repr__ (self ) -> str :
119+ """Short string representation."""
120+ return f"{ self .__class__ .__name__ } ({ self .geom } )"
121+
122+ def __str__ (self ) -> str :
123+ """Extensive string representation."""
124+ n_chars = len (self .__class__ .__name__ )
125+ return (
126+ f"{ self .__class__ .__name__ } \n { '-' * n_chars } \n "
127+ f"Geometry: \n { self .geom } \n "
128+ f"Projection: \n { self .crs .to_proj4 ()} "
129+ )
130+
90131
91132class GeogGeom (ProjGeom ):
92133 crs : pyproj .CRS = pyproj .CRS .from_epsg (GEOG_EPSG )
0 commit comments