Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pymeos/collections/npoint/npointset.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,31 @@ def routes(self) -> Set[int]:
from ...factory import _CollectionFactory

return _CollectionFactory.create_collection(npointset_routes(self._inner))

# ------------------------- Set Operations --------------------------------
# NpointSet shipped abstract in #88 (a pre-existing base-collection
# defect, unrelated to the OO codegen switch): the base ``Set`` declares
# contains/intersection/minus/subtract_from/union as abstract. These thin
# overrides delegate to the generic base implementation (the established
# pattern, e.g. ``GeoSet.contains``), making NpointSet concrete. Npoint-
# element-specific set overloads (intersection_set_npoint, ...) are a
# separate base-collection follow-up.
def contains(self, content: Union[NpointSet, Npoint]) -> bool:
"""Returns whether ``self`` contains ``content``."""
return super().contains(content)

def intersection(self, other: NpointSet) -> Optional[NpointSet]:
"""Returns the intersection of ``self`` and ``other``."""
return super().intersection(other)

def minus(self, other: NpointSet) -> Optional[NpointSet]:
"""Returns the difference of ``self`` and ``other``."""
return super().minus(other)

def subtract_from(self, other: Npoint) -> Optional[Npoint]:
"""Returns the difference of ``other`` and ``self``."""
return super().subtract_from(other)

def union(self, other: NpointSet) -> NpointSet:
"""Returns the union of ``self`` and ``other``."""
return super().union(other)
239 changes: 239 additions & 0 deletions pymeos/main/_generated/tnpoint_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
Loading