We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ENH: New geoaccessor to filter geometry via spatial relationship
<!--
Thanks for contributing a pull request!

Please follow these standard acronyms to start the commit message:

- ENH: enhancement
- BUG: bug fix
- DOC: documentation
- TYP: type annotations
- TST: addition or modification of tests
- MAINT: maintenance commit (refactoring, typos, etc.)
- BLD: change related to building
- REL: related to releasing
- API: an (incompatible) API change
- DEP: deprecate something, or remove a deprecated object
- DEV: development tool or utility
- REV: revert an earlier commit
- PERF: performance improvement
- BOT: always commit via a bot
- CI: related to CI or CD
- CLN: Code cleanup
-->

- [ ] closes #xxxx
- [x] whatsnew entry

A sugar syntax wraps for `s[s.contains(geometry, **kwargs)]`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dtoolkit/geoaccessor/geoseries/filter_geometry.py`
Content:
```
1 from __future__ import annotations
2 
3 from typing import get_args
4 from typing import Literal
5 from typing import TYPE_CHECKING
6 
7 import geopandas as gpd
8 import pandas as pd
9 from pandas.util._decorators import doc
10 
11 from dtoolkit.geoaccessor.register import register_geoseries_method
12 
13 
14 if TYPE_CHECKING:
15     from shapely.geometry.base import BaseGeometry
16 
17 
18 BINARY_PREDICATE = Literal[
19     "intersects",
20     "disjoint",
21     "crosses",
22     "overlaps",
23     "touches",
24     "covered_by",
25     "contains",
26     "within",
27     "covers",
28 ]
29 
30 
31 @register_geoseries_method
32 @doc(klass="GeoSeries")
33 def filter_geometry(
34     s: gpd.GeoSeries,
35     /,
36     geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
37     predicate: BINARY_PREDICATE,
38     complement: bool = False,
39     **kwargs,
40 ) -> gpd.GeoSeries:
41     """
42     Filter {klass} via the spatial relationship between {klass} and ``geometry``.
43 
44     A sugar syntax wraps::
45 
46         s[s.{{predicate}}(geometry, **kwargs)]
47 
48     Parameters
49     ----------
50     geometry : Geometry, GeoSeries, or GeoDataFrame
51 
52     predicate : {{"intersects", "disjoint", "crosses", "overlaps", "touches", \
53 "covered_by", "contains", "within", "covers"}}
54         Binary predicate.
55 
56     complement : bool, default False
57         If True, do operation reversely.
58 
59     **kwargs
60         See the documentation for ``{klass}.{{predicate}}`` for complete details on the
61         keyword arguments.
62 
63     Returns
64     -------
65     {klass}
66 
67     See Also
68     --------
69     geopandas.GeoSeries.intersects
70     geopandas.GeoSeries.covered_by
71     geopandas.GeoSeries.contains
72     dtoolkit.geoaccessor.geoseries.filter_geometry
73     dtoolkit.geoaccessor.geodataframe.filter_geometry
74 
75     Examples
76     --------
77     >>> import dtoolkit.geoaccessor
78     >>> import geopandas as gpd
79     >>> from shapely.geometry import Polygon, LineString, Point, box
80     >>> df = gpd.GeoDataFrame(
81     ...     geometry=[
82     ...         Polygon([(0, 0), (1, 1), (0, 1)]),
83     ...         LineString([(0, 0), (0, 2)]),
84     ...         LineString([(0, 0), (0, 1)]),
85     ...         Point(0, 1),
86     ...         Point(-1, -1),
87     ...     ],
88     ... )
89     >>> df
90                                                 geometry
91     0  POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....
92     1      LINESTRING (0.00000 0.00000, 0.00000 2.00000)
93     2      LINESTRING (0.00000 0.00000, 0.00000 1.00000)
94     3                            POINT (0.00000 1.00000)
95     4                          POINT (-1.00000 -1.00000)
96 
97     Filter the geometries out of the bounding ``box(0, 0, 2, 2)``.
98 
99     >>> df.filter_geometry(box(0, 0, 2, 2), "covered_by", complement=True)
100                           geometry
101     4    POINT (-1.00000 -1.00000)
102 
103     This method is actually faster than the following one::
104 
105         def is_in_geometry(s: gpd.GeoSeries, geometry: BaseGeometry) -> pd.Series:
106             s_bounds, g_bounds = s.bounds, geometry.bounds
107 
108             return (
109                 (s_bounds.minx >= g_bounds[0])
110                 & (s_bounds.miny >= g_bounds[1])
111                 & (s_bounds.maxx <= g_bounds[2])
112                 & (s_bounds.maxy <= g_bounds[3])
113             )
114     """
115 
116     return s[
117         _filter_geometry(
118             s,
119             geometry=geometry,
120             predicate=predicate,
121             complement=complement,
122             **kwargs,
123         )
124     ]
125 
126 
127 def _filter_geometry(
128     s: gpd.GeoSeries,
129     geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
130     predicate: BINARY_PREDICATE,
131     complement: bool,
132     **kwargs,
133 ) -> pd.Series:
134     if predicate not in get_args(BINARY_PREDICATE):
135         raise ValueError(
136             f"Got {predicate=!r}, expected one of {get_args(BINARY_PREDICATE)!r}.",
137         )
138 
139     mask = getattr(s, predicate)(geometry, **kwargs)
140     return ~mask if complement else mask
141
```

Path: `dtoolkit/geoaccessor/geodataframe/filter_geometry.py`
Content:
```
1 from __future__ import annotations
2 
3 from typing import TYPE_CHECKING
4 
5 import geopandas as gpd
6 from pandas.util._decorators import doc
7 
8 from dtoolkit.geoaccessor.geoseries import filter_geometry as s_filter_geometry
9 from dtoolkit.geoaccessor.geoseries.filter_geometry import _filter_geometry
10 from dtoolkit.geoaccessor.geoseries.filter_geometry import BINARY_PREDICATE
11 from dtoolkit.geoaccessor.register import register_geodataframe_method
12 
13 
14 if TYPE_CHECKING:
15     from shapely.geometry.base import BaseGeometry
16 
17 
18 @register_geodataframe_method
19 @doc(s_filter_geometry, klass="GeoDataFrame")
20 def filter_geometry(
21     df: gpd.GeoDataFrame,
22     /,
23     geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
24     predicate: BINARY_PREDICATE,
25     complement: bool = False,
26     **kwargs,
27 ) -> gpd.GeoDataFrame:
28 
29     return df[
30         _filter_geometry(
31             df,
32             geometry=geometry,
33             predicate=predicate,
34             complement=complement,
35             **kwargs,
36         )
37     ]
38
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dtoolkit/geoaccessor/geodataframe/filter_geometry.py b/dtoolkit/geoaccessor/geodataframe/filter_geometry.py
--- a/dtoolkit/geoaccessor/geodataframe/filter_geometry.py
+++ b/dtoolkit/geoaccessor/geodataframe/filter_geometry.py
@@ -20,7 +20,7 @@
 def filter_geometry(
     df: gpd.GeoDataFrame,
     /,
-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
     predicate: BINARY_PREDICATE,
     complement: bool = False,
     **kwargs,
@@ -29,7 +29,7 @@
     return df[
         _filter_geometry(
             df,
-            geometry=geometry,
+            other=other,
             predicate=predicate,
             complement=complement,
             **kwargs,
diff --git a/dtoolkit/geoaccessor/geoseries/filter_geometry.py b/dtoolkit/geoaccessor/geoseries/filter_geometry.py
--- a/dtoolkit/geoaccessor/geoseries/filter_geometry.py
+++ b/dtoolkit/geoaccessor/geoseries/filter_geometry.py
@@ -33,7 +33,7 @@
 def filter_geometry(
     s: gpd.GeoSeries,
     /,
-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
     predicate: BINARY_PREDICATE,
     complement: bool = False,
     **kwargs,
@@ -43,11 +43,11 @@
 
     A sugar syntax wraps::
 
-        s[s.{{predicate}}(geometry, **kwargs)]
+        s[s.{{predicate}}(other, **kwargs)]
 
     Parameters
     ----------
-    geometry : Geometry, GeoSeries, or GeoDataFrame
+    other : Geometry, GeoSeries, or GeoDataFrame
 
     predicate : {{"intersects", "disjoint", "crosses", "overlaps", "touches", \
 "covered_by", "contains", "within", "covers"}}
@@ -102,8 +102,8 @@
 
     This method is actually faster than the following one::
 
-        def is_in_geometry(s: gpd.GeoSeries, geometry: BaseGeometry) -> pd.Series:
-            s_bounds, g_bounds = s.bounds, geometry.bounds
+        def is_in_geometry(s: gpd.GeoSeries, other: BaseGeometry) -> pd.Series:
+            s_bounds, g_bounds = s.bounds, other.bounds
 
             return (
                 (s_bounds.minx >= g_bounds[0])
@@ -116,7 +116,7 @@
     return s[
         _filter_geometry(
             s,
-            geometry=geometry,
+            other=other,
             predicate=predicate,
             complement=complement,
             **kwargs,
@@ -126,7 +126,7 @@
 
 def _filter_geometry(
     s: gpd.GeoSeries,
-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,
     predicate: BINARY_PREDICATE,
     complement: bool,
     **kwargs,
@@ -136,5 +136,5 @@
             f"Got {predicate=!r}, expected one of {get_args(BINARY_PREDICATE)!r}.",
         )
 
-    mask = getattr(s, predicate)(geometry, **kwargs)
+    mask = getattr(s, predicate)(other, **kwargs)
     return ~mask if complement else mask

{"golden_diff": "diff --git a/dtoolkit/geoaccessor/geodataframe/filter_geometry.py b/dtoolkit/geoaccessor/geodataframe/filter_geometry.py\n--- a/dtoolkit/geoaccessor/geodataframe/filter_geometry.py\n+++ b/dtoolkit/geoaccessor/geodataframe/filter_geometry.py\n@@ -20,7 +20,7 @@\n def filter_geometry(\n     df: gpd.GeoDataFrame,\n     /,\n-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n     predicate: BINARY_PREDICATE,\n     complement: bool = False,\n     **kwargs,\n@@ -29,7 +29,7 @@\n     return df[\n         _filter_geometry(\n             df,\n-            geometry=geometry,\n+            other=other,\n             predicate=predicate,\n             complement=complement,\n             **kwargs,\ndiff --git a/dtoolkit/geoaccessor/geoseries/filter_geometry.py b/dtoolkit/geoaccessor/geoseries/filter_geometry.py\n--- a/dtoolkit/geoaccessor/geoseries/filter_geometry.py\n+++ b/dtoolkit/geoaccessor/geoseries/filter_geometry.py\n@@ -33,7 +33,7 @@\n def filter_geometry(\n     s: gpd.GeoSeries,\n     /,\n-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n     predicate: BINARY_PREDICATE,\n     complement: bool = False,\n     **kwargs,\n@@ -43,11 +43,11 @@\n \n     A sugar syntax wraps::\n \n-        s[s.{{predicate}}(geometry, **kwargs)]\n+        s[s.{{predicate}}(other, **kwargs)]\n \n     Parameters\n     ----------\n-    geometry : Geometry, GeoSeries, or GeoDataFrame\n+    other : Geometry, GeoSeries, or GeoDataFrame\n \n     predicate : {{\"intersects\", \"disjoint\", \"crosses\", \"overlaps\", \"touches\", \\\n \"covered_by\", \"contains\", \"within\", \"covers\"}}\n@@ -102,8 +102,8 @@\n \n     This method is actually faster than the following one::\n \n-        def is_in_geometry(s: gpd.GeoSeries, geometry: BaseGeometry) -> pd.Series:\n-            s_bounds, g_bounds = s.bounds, geometry.bounds\n+        def is_in_geometry(s: gpd.GeoSeries, other: BaseGeometry) -> pd.Series:\n+            s_bounds, g_bounds = s.bounds, other.bounds\n \n             return (\n                 (s_bounds.minx >= g_bounds[0])\n@@ -116,7 +116,7 @@\n     return s[\n         _filter_geometry(\n             s,\n-            geometry=geometry,\n+            other=other,\n             predicate=predicate,\n             complement=complement,\n             **kwargs,\n@@ -126,7 +126,7 @@\n \n def _filter_geometry(\n     s: gpd.GeoSeries,\n-    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n+    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n     predicate: BINARY_PREDICATE,\n     complement: bool,\n     **kwargs,\n@@ -136,5 +136,5 @@\n             f\"Got {predicate=!r}, expected one of {get_args(BINARY_PREDICATE)!r}.\",\n         )\n \n-    mask = getattr(s, predicate)(geometry, **kwargs)\n+    mask = getattr(s, predicate)(other, **kwargs)\n     return ~mask if complement else mask\n", "issue": "ENH: New geoaccessor to filter geometry via spatial relationship\n<!--\r\nThanks for contributing a pull request!\r\n\r\nPlease follow these standard acronyms to start the commit message:\r\n\r\n- ENH: enhancement\r\n- BUG: bug fix\r\n- DOC: documentation\r\n- TYP: type annotations\r\n- TST: addition or modification of tests\r\n- MAINT: maintenance commit (refactoring, typos, etc.)\r\n- BLD: change related to building\r\n- REL: related to releasing\r\n- API: an (incompatible) API change\r\n- DEP: deprecate something, or remove a deprecated object\r\n- DEV: development tool or utility\r\n- REV: revert an earlier commit\r\n- PERF: performance improvement\r\n- BOT: always commit via a bot\r\n- CI: related to CI or CD\r\n- CLN: Code cleanup\r\n-->\r\n\r\n- [ ] closes #xxxx\r\n- [x] whatsnew entry\r\n\r\nA sugar syntax wraps for `s[s.contains(geometry, **kwargs)]`\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import get_args\nfrom typing import Literal\nfrom typing import TYPE_CHECKING\n\nimport geopandas as gpd\nimport pandas as pd\nfrom pandas.util._decorators import doc\n\nfrom dtoolkit.geoaccessor.register import register_geoseries_method\n\n\nif TYPE_CHECKING:\n    from shapely.geometry.base import BaseGeometry\n\n\nBINARY_PREDICATE = Literal[\n    \"intersects\",\n    \"disjoint\",\n    \"crosses\",\n    \"overlaps\",\n    \"touches\",\n    \"covered_by\",\n    \"contains\",\n    \"within\",\n    \"covers\",\n]\n\n\n@register_geoseries_method\n@doc(klass=\"GeoSeries\")\ndef filter_geometry(\n    s: gpd.GeoSeries,\n    /,\n    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool = False,\n    **kwargs,\n) -> gpd.GeoSeries:\n    \"\"\"\n    Filter {klass} via the spatial relationship between {klass} and ``geometry``.\n\n    A sugar syntax wraps::\n\n        s[s.{{predicate}}(geometry, **kwargs)]\n\n    Parameters\n    ----------\n    geometry : Geometry, GeoSeries, or GeoDataFrame\n\n    predicate : {{\"intersects\", \"disjoint\", \"crosses\", \"overlaps\", \"touches\", \\\n\"covered_by\", \"contains\", \"within\", \"covers\"}}\n        Binary predicate.\n\n    complement : bool, default False\n        If True, do operation reversely.\n\n    **kwargs\n        See the documentation for ``{klass}.{{predicate}}`` for complete details on the\n        keyword arguments.\n\n    Returns\n    -------\n    {klass}\n\n    See Also\n    --------\n    geopandas.GeoSeries.intersects\n    geopandas.GeoSeries.covered_by\n    geopandas.GeoSeries.contains\n    dtoolkit.geoaccessor.geoseries.filter_geometry\n    dtoolkit.geoaccessor.geodataframe.filter_geometry\n\n    Examples\n    --------\n    >>> import dtoolkit.geoaccessor\n    >>> import geopandas as gpd\n    >>> from shapely.geometry import Polygon, LineString, Point, box\n    >>> df = gpd.GeoDataFrame(\n    ...     geometry=[\n    ...         Polygon([(0, 0), (1, 1), (0, 1)]),\n    ...         LineString([(0, 0), (0, 2)]),\n    ...         LineString([(0, 0), (0, 1)]),\n    ...         Point(0, 1),\n    ...         Point(-1, -1),\n    ...     ],\n    ... )\n    >>> df\n                                                geometry\n    0  POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....\n    1      LINESTRING (0.00000 0.00000, 0.00000 2.00000)\n    2      LINESTRING (0.00000 0.00000, 0.00000 1.00000)\n    3                            POINT (0.00000 1.00000)\n    4                          POINT (-1.00000 -1.00000)\n\n    Filter the geometries out of the bounding ``box(0, 0, 2, 2)``.\n\n    >>> df.filter_geometry(box(0, 0, 2, 2), \"covered_by\", complement=True)\n                          geometry\n    4    POINT (-1.00000 -1.00000)\n\n    This method is actually faster than the following one::\n\n        def is_in_geometry(s: gpd.GeoSeries, geometry: BaseGeometry) -> pd.Series:\n            s_bounds, g_bounds = s.bounds, geometry.bounds\n\n            return (\n                (s_bounds.minx >= g_bounds[0])\n                & (s_bounds.miny >= g_bounds[1])\n                & (s_bounds.maxx <= g_bounds[2])\n                & (s_bounds.maxy <= g_bounds[3])\n            )\n    \"\"\"\n\n    return s[\n        _filter_geometry(\n            s,\n            geometry=geometry,\n            predicate=predicate,\n            complement=complement,\n            **kwargs,\n        )\n    ]\n\n\ndef _filter_geometry(\n    s: gpd.GeoSeries,\n    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool,\n    **kwargs,\n) -> pd.Series:\n    if predicate not in get_args(BINARY_PREDICATE):\n        raise ValueError(\n            f\"Got {predicate=!r}, expected one of {get_args(BINARY_PREDICATE)!r}.\",\n        )\n\n    mask = getattr(s, predicate)(geometry, **kwargs)\n    return ~mask if complement else mask\n", "path": "dtoolkit/geoaccessor/geoseries/filter_geometry.py"}, {"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport geopandas as gpd\nfrom pandas.util._decorators import doc\n\nfrom dtoolkit.geoaccessor.geoseries import filter_geometry as s_filter_geometry\nfrom dtoolkit.geoaccessor.geoseries.filter_geometry import _filter_geometry\nfrom dtoolkit.geoaccessor.geoseries.filter_geometry import BINARY_PREDICATE\nfrom dtoolkit.geoaccessor.register import register_geodataframe_method\n\n\nif TYPE_CHECKING:\n    from shapely.geometry.base import BaseGeometry\n\n\n@register_geodataframe_method\n@doc(s_filter_geometry, klass=\"GeoDataFrame\")\ndef filter_geometry(\n    df: gpd.GeoDataFrame,\n    /,\n    geometry: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool = False,\n    **kwargs,\n) -> gpd.GeoDataFrame:\n\n    return df[\n        _filter_geometry(\n            df,\n            geometry=geometry,\n            predicate=predicate,\n            complement=complement,\n            **kwargs,\n        )\n    ]\n", "path": "dtoolkit/geoaccessor/geodataframe/filter_geometry.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import get_args\nfrom typing import Literal\nfrom typing import TYPE_CHECKING\n\nimport geopandas as gpd\nimport pandas as pd\nfrom pandas.util._decorators import doc\n\nfrom dtoolkit.geoaccessor.register import register_geoseries_method\n\n\nif TYPE_CHECKING:\n    from shapely.geometry.base import BaseGeometry\n\n\nBINARY_PREDICATE = Literal[\n    \"intersects\",\n    \"disjoint\",\n    \"crosses\",\n    \"overlaps\",\n    \"touches\",\n    \"covered_by\",\n    \"contains\",\n    \"within\",\n    \"covers\",\n]\n\n\n@register_geoseries_method\n@doc(klass=\"GeoSeries\")\ndef filter_geometry(\n    s: gpd.GeoSeries,\n    /,\n    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool = False,\n    **kwargs,\n) -> gpd.GeoSeries:\n    \"\"\"\n    Filter {klass} via the spatial relationship between {klass} and ``geometry``.\n\n    A sugar syntax wraps::\n\n        s[s.{{predicate}}(other, **kwargs)]\n\n    Parameters\n    ----------\n    other : Geometry, GeoSeries, or GeoDataFrame\n\n    predicate : {{\"intersects\", \"disjoint\", \"crosses\", \"overlaps\", \"touches\", \\\n\"covered_by\", \"contains\", \"within\", \"covers\"}}\n        Binary predicate.\n\n    complement : bool, default False\n        If True, do operation reversely.\n\n    **kwargs\n        See the documentation for ``{klass}.{{predicate}}`` for complete details on the\n        keyword arguments.\n\n    Returns\n    -------\n    {klass}\n\n    See Also\n    --------\n    geopandas.GeoSeries.intersects\n    geopandas.GeoSeries.covered_by\n    geopandas.GeoSeries.contains\n    dtoolkit.geoaccessor.geoseries.filter_geometry\n    dtoolkit.geoaccessor.geodataframe.filter_geometry\n\n    Examples\n    --------\n    >>> import dtoolkit.geoaccessor\n    >>> import geopandas as gpd\n    >>> from shapely.geometry import Polygon, LineString, Point, box\n    >>> df = gpd.GeoDataFrame(\n    ...     geometry=[\n    ...         Polygon([(0, 0), (1, 1), (0, 1)]),\n    ...         LineString([(0, 0), (0, 2)]),\n    ...         LineString([(0, 0), (0, 1)]),\n    ...         Point(0, 1),\n    ...         Point(-1, -1),\n    ...     ],\n    ... )\n    >>> df\n                                                geometry\n    0  POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....\n    1      LINESTRING (0.00000 0.00000, 0.00000 2.00000)\n    2      LINESTRING (0.00000 0.00000, 0.00000 1.00000)\n    3                            POINT (0.00000 1.00000)\n    4                          POINT (-1.00000 -1.00000)\n\n    Filter the geometries out of the bounding ``box(0, 0, 2, 2)``.\n\n    >>> df.filter_geometry(box(0, 0, 2, 2), \"covered_by\", complement=True)\n                          geometry\n    4    POINT (-1.00000 -1.00000)\n\n    This method is actually faster than the following one::\n\n        def is_in_geometry(s: gpd.GeoSeries, other: BaseGeometry) -> pd.Series:\n            s_bounds, g_bounds = s.bounds, other.bounds\n\n            return (\n                (s_bounds.minx >= g_bounds[0])\n                & (s_bounds.miny >= g_bounds[1])\n                & (s_bounds.maxx <= g_bounds[2])\n                & (s_bounds.maxy <= g_bounds[3])\n            )\n    \"\"\"\n\n    return s[\n        _filter_geometry(\n            s,\n            other=other,\n            predicate=predicate,\n            complement=complement,\n            **kwargs,\n        )\n    ]\n\n\ndef _filter_geometry(\n    s: gpd.GeoSeries,\n    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool,\n    **kwargs,\n) -> pd.Series:\n    if predicate not in get_args(BINARY_PREDICATE):\n        raise ValueError(\n            f\"Got {predicate=!r}, expected one of {get_args(BINARY_PREDICATE)!r}.\",\n        )\n\n    mask = getattr(s, predicate)(other, **kwargs)\n    return ~mask if complement else mask\n", "path": "dtoolkit/geoaccessor/geoseries/filter_geometry.py"}, {"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport geopandas as gpd\nfrom pandas.util._decorators import doc\n\nfrom dtoolkit.geoaccessor.geoseries import filter_geometry as s_filter_geometry\nfrom dtoolkit.geoaccessor.geoseries.filter_geometry import _filter_geometry\nfrom dtoolkit.geoaccessor.geoseries.filter_geometry import BINARY_PREDICATE\nfrom dtoolkit.geoaccessor.register import register_geodataframe_method\n\n\nif TYPE_CHECKING:\n    from shapely.geometry.base import BaseGeometry\n\n\n@register_geodataframe_method\n@doc(s_filter_geometry, klass=\"GeoDataFrame\")\ndef filter_geometry(\n    df: gpd.GeoDataFrame,\n    /,\n    other: BaseGeometry | gpd.GeoSeries | gpd.GeoDataFrame,\n    predicate: BINARY_PREDICATE,\n    complement: bool = False,\n    **kwargs,\n) -> gpd.GeoDataFrame:\n\n    return df[\n        _filter_geometry(\n            df,\n            other=other,\n            predicate=predicate,\n            complement=complement,\n            **kwargs,\n        )\n    ]\n", "path": "dtoolkit/geoaccessor/geodataframe/filter_geometry.py"}]}