Polyline

class Polyline

Bases: CommonBaseModel

Represents a polyline, a series of connected 3D points forming a continuous line or path.

Useful in geometric modeling and spatial analysis, the Polyline class enables the representation of linear paths, edges, or trajectories in three-dimensional space, facilitating calculations and visualizations related to lines.

points

A series of 3D points defining the polyline.

Type:

List[Point]

metadata

Additional metadata for the polyline.

Type:

Metadata

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

add_point(point)

Add a new point object to the end of the polyline, extending its path.

length()

Calculate the total length of the polyline by summing the distances between consecutive points.

simplify(tolerance)

Simplify the polyline by removing redundant points based on a specified tolerance.

validate_points(value)

Validate the 'points' list to ensure it contains at least two points.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Documentation

add_point(point)

Add a new point object to the end of the polyline, extending its path.

Parameters:

point (Point) – The point object to be appended to the polyline.

Return type:

None

length()

Calculate the total length of the polyline by summing the distances between consecutive points.

Returns:

The total length of the polyline.

Return type:

float

simplify(tolerance)

Simplify the polyline by removing redundant points based on a specified tolerance.

The simplification algorithm iteratively removes points that deviate from the line segment formed by their neighboring points by a distance less than the specified tolerance. This process continues until no more points can be removed without exceeding the tolerance.

Parameters:

tolerance (float) – The maximum deviation allowed for a point to be considered redundant.

Returns:

A new simplified polyline with redundant points removed.

Return type:

Polyline

classmethod validate_points(value)

Validate the ‘points’ list to ensure it contains at least two points.

Parameters:

value (List[Point]) – The list of points being validated.

Returns:

The validated list of points.

Raises:

ValueError – If the list contains fewer than two points.

Return type:

List[Point]

Methods:

validate_points(value)

Validate the 'points' list to ensure it contains at least two points.

add_point(point)

Add a new point object to the end of the polyline, extending its path.

length()

Calculate the total length of the polyline by summing the distances between consecutive points.

simplify(tolerance)

Simplify the polyline by removing redundant points based on a specified tolerance.

Attributes:

__pydantic_setattr_handlers__

__setattr__ handlers.

classmethod validate_points(value)

Validate the ‘points’ list to ensure it contains at least two points.

Parameters:

value (List[Point]) – The list of points being validated.

Returns:

The validated list of points.

Raises:

ValueError – If the list contains fewer than two points.

Return type:

List[Point]

add_point(point)

Add a new point object to the end of the polyline, extending its path.

Parameters:

point (Point) – The point object to be appended to the polyline.

Return type:

None

length()

Calculate the total length of the polyline by summing the distances between consecutive points.

Returns:

The total length of the polyline.

Return type:

float

simplify(tolerance)

Simplify the polyline by removing redundant points based on a specified tolerance.

The simplification algorithm iteratively removes points that deviate from the line segment formed by their neighboring points by a distance less than the specified tolerance. This process continues until no more points can be removed without exceeding the tolerance.

Parameters:

tolerance (float) – The maximum deviation allowed for a point to be considered redundant.

Returns:

A new simplified polyline with redundant points removed.

Return type:

Polyline

__pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}

__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__