-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtnpoint_methods.py
More file actions
239 lines (199 loc) · 9.02 KB
/
Copy pathtnpoint_methods.py
File metadata and controls
239 lines (199 loc) · 9.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# Copyright (c) 2016-2026, Université libre de Bruxelles and PyMEOS
# contributors. Licensed under the PostgreSQL License (see LICENSE).
#
# ============================================================================
# GENERATED by tools/oo_codegen/codegen.py -- DO NOT EDIT.
# Regenerate:
# python3 tools/oo_codegen/codegen.py --mixin npoint \
# --mixin-out pymeos/main/_generated/npoint_methods.py
# ============================================================================
#
# Wired into pymeos.main.TNpoint via TNpointRegularMixin. Every method
# dispatches by argument type to the EXACT pymeos_cffi backing the
# hand-written method used -- same native call, same transforms, same
# result, never reimplemented: identical by construction.
"""Generated regular OO methods for the TNpoint family."""
from __future__ import annotations
from typing import TYPE_CHECKING
import shapely.geometry.base as shpb
from pymeos_cffi import *
from ...temporal import Temporal
from ...collections.npoint import Npoint, NpointSet
if TYPE_CHECKING:
from ..tnpoint import TNpoint
class TNpointRegularMixin:
"""Generated regular families (comparison, spatial relationship,
distance, restriction) for :class:`TNpoint`."""
def always_equal(self, other):
"""Generated regular ``always_equal``.
MEOS Functions:
always_eq_npoint_tnpoint, always_eq_tnpoint_npoint, always_eq_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, Npoint):
result = always_eq_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = always_eq_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return result > 0
def always_not_equal(self, other):
"""Generated regular ``always_not_equal``.
MEOS Functions:
always_ne_npoint_tnpoint, always_ne_tnpoint_npoint, always_ne_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, Npoint):
result = always_ne_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = always_ne_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return result > 0
def at(self, other):
"""Generated regular ``at``.
MEOS Functions:
tnpoint_at_geom, tnpoint_at_npoint, tnpoint_at_npointset, tnpoint_at_stbox
"""
from ...boxes import STBox
if isinstance(other, shpb.BaseGeometry):
result = tnpoint_at_geom(self._inner, geo_to_gserialized(other, False))
elif isinstance(other, Npoint):
result = tnpoint_at_npoint(self._inner, other._inner)
elif isinstance(other, NpointSet):
result = tnpoint_at_npointset(self._inner, other._inner)
elif isinstance(other, STBox):
result = tnpoint_at_stbox(self._inner, other._inner, True)
else:
return super().at(other)
return Temporal._factory(result)
def distance(self, other):
"""Generated regular ``distance``.
MEOS Functions:
tdistance_tnpoint_npoint, tdistance_tnpoint_point, tdistance_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, shpb.BaseGeometry):
result = tdistance_tnpoint_point(
self._inner, geo_to_gserialized(other, False)
)
elif isinstance(other, Npoint):
result = tdistance_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = tdistance_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return Temporal._factory(result)
def ever_equal(self, other):
"""Generated regular ``ever_equal``.
MEOS Functions:
ever_eq_npoint_tnpoint, ever_eq_tnpoint_npoint, ever_eq_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, Npoint):
result = ever_eq_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = ever_eq_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return result > 0
def ever_not_equal(self, other):
"""Generated regular ``ever_not_equal``.
MEOS Functions:
ever_ne_npoint_tnpoint, ever_ne_tnpoint_npoint, ever_ne_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, Npoint):
result = ever_ne_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = ever_ne_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return result > 0
def minus(self, other):
"""Generated regular ``minus``.
MEOS Functions:
tnpoint_minus_geom, tnpoint_minus_npoint, tnpoint_minus_npointset, tnpoint_minus_stbox
"""
from ...boxes import STBox
if isinstance(other, shpb.BaseGeometry):
result = tnpoint_minus_geom(self._inner, geo_to_gserialized(other, False))
elif isinstance(other, Npoint):
result = tnpoint_minus_npoint(self._inner, other._inner)
elif isinstance(other, NpointSet):
result = tnpoint_minus_npointset(self._inner, other._inner)
elif isinstance(other, STBox):
result = tnpoint_minus_stbox(self._inner, other._inner, True)
else:
return super().minus(other)
return Temporal._factory(result)
def nearest_approach_distance(self, other):
"""Generated regular ``nearest_approach_distance``.
MEOS Functions:
nad_tnpoint_geo, nad_tnpoint_npoint, nad_tnpoint_stbox, nad_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
from ...boxes import STBox
if isinstance(other, shpb.BaseGeometry):
result = nad_tnpoint_geo(self._inner, geo_to_gserialized(other, False))
elif isinstance(other, Npoint):
result = nad_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = nad_tnpoint_tnpoint(self._inner, other._inner)
elif isinstance(other, STBox):
result = nad_tnpoint_stbox(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return result
def nearest_approach_instant(self, other):
"""Generated regular ``nearest_approach_instant``.
MEOS Functions:
nai_tnpoint_geo, nai_tnpoint_npoint, nai_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, shpb.BaseGeometry):
result = nai_tnpoint_geo(self._inner, geo_to_gserialized(other, False))
elif isinstance(other, Npoint):
result = nai_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = nai_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return Temporal._factory(result)
def shortest_line(self, other, precision: int = 15):
"""Generated regular ``shortest_line``.
MEOS Functions:
shortestline_tnpoint_geo, shortestline_tnpoint_npoint, shortestline_tnpoint_tnpoint
"""
from ..tnpoint import TNpoint
if isinstance(other, shpb.BaseGeometry):
result = shortestline_tnpoint_geo(
self._inner, geo_to_gserialized(other, False)
)
elif isinstance(other, Npoint):
result = shortestline_tnpoint_npoint(self._inner, other._inner)
elif isinstance(other, TNpoint):
result = shortestline_tnpoint_tnpoint(self._inner, other._inner)
else:
raise TypeError(f"Operation not supported with type " f"{other.__class__}")
return gserialized_to_shapely_geometry(result, precision)
def temporal_equal(self, other):
"""Generated regular ``temporal_equal``.
MEOS Functions:
teq_tnpoint_npoint
"""
if isinstance(other, Npoint):
result = teq_tnpoint_npoint(self._inner, other._inner)
else:
return super().temporal_equal(other)
return Temporal._factory(result)
def temporal_not_equal(self, other):
"""Generated regular ``temporal_not_equal``.
MEOS Functions:
tne_tnpoint_npoint
"""
if isinstance(other, Npoint):
result = tne_tnpoint_npoint(self._inner, other._inner)
else:
return super().temporal_not_equal(other)
return Temporal._factory(result)