pyinterp.geometry.geographic.Segment

Contents

pyinterp.geometry.geographic.Segment#

class pyinterp.geometry.geographic.Segment(self, a: tuple[float, float] | None = None, b: tuple[float, float] | None = None)#

Bases: object

A segment in geographic coordinates.

A Segment is defined by two endpoints (points) on the ellipsoid surface.

Examples

>>> from pyinterp.geometry.geographic import Segment
>>> s = Segment((0.0, 0.0), (10.0, 5.0))
>>> len(s)
2

Construct a segment from two endpoints or four coordinates.

Parameters:
  • a – a tuple of two floats representing the first endpoint as lon, lat.

  • b – a tuple of two floats representing the second endpoint as lon, lat.

Attributes

a

First endpoint.

b

Second endpoint.

Public Methods

to_arrays(self)

Get the coordinate arrays of the segment endpoints.

Special Methods

__bool__(self)

Return True if the segment has non-default endpoints.

__eq__(self, other)

Check if two segments are equal.

__getitem__(self, idx)

Get endpoint at index (0 or 1).

__getstate__(self)

Return the serialized state for pickling.

__len__(self)

Return the number of endpoints (always 2).

__ne__(self, other)

Check if two segments are not equal.

__new__(*args, **kwargs)

__repr__(self)

Return the official string representation of the segment.

__setitem__(self, idx, point)

Set endpoint at index (0 or 1).

__setstate__(self, state)

Restore the segment from the serialized state.

__str__(self)

Return the informal string representation of the segment.