mosstool.map._util.line

Module Contents

Functions

clip_line

Clip line between p1 and p2

has_multiple_turns

Determine whether LineString has multiple inflection points

line_extend

Extend line at the beginning and end

line_max_curvature

Calculate the maximum curvature of the line.

add_random_point_to_linestring

connect_line_string

Connect two line segments with a fit curve.

connect_line_string_bezier_4_t_point

Connect two line segments with a 4 point Bezier curve.

connect_line_string_straight

Connect two line segments with straight line.

offset_lane

Offset LineString to the left/right

align_line

Align line1 along the direction of advance with line2.

merge_near_xy_points

Return merged coordinates of input points coordinates

connect_split_lines

Connect split lines (especially for way items in OSM) as one line.

merge_line_start_end

Keep the start point of line_start and the end point of line_end unchanged, return merged result of the two lines

get_start_vector

Get the start vector of a LineString

get_end_vector

Get the end vector of a LineString

get_line_angle

Get the angle (-pi~pi) of the line

Data

API

mosstool.map._util.line.__all__

[‘clip_line’, ‘line_extend’, ‘connect_line_string’, ‘line_max_curvature’, ‘offset_lane’, ‘align_line…

mosstool.map._util.line.clip_line(line: shapely.geometry.LineString, p1: shapely.geometry.Point, p2: shapely.geometry.Point) shapely.geometry.LineString

Clip line between p1 and p2

Args:

  • line (LineString): LineString

  • p1 (Point): start point of the clipped line

  • p2 (Point): end point of the clipped line

Returns:

  • LineString: clipped LineString

mosstool.map._util.line.has_multiple_turns(line: shapely.geometry.LineString) bool

Determine whether LineString has multiple inflection points

mosstool.map._util.line.line_extend(line: shapely.geometry.LineString, extend_length: float)

Extend line at the beginning and end

Args:

  • line (LineString): LineString

  • extend_length (float): Length to extend line at both the beginning and end. unit: meter.

Returns:

  • LineString: extended LineString

mosstool.map._util.line.line_max_curvature(line: shapely.geometry.LineString) float

Calculate the maximum curvature of the line.

mosstool.map._util.line.add_random_point_to_linestring(line: shapely.geometry.LineString, seed: int = 0) shapely.geometry.LineString
mosstool.map._util.line.connect_line_string(line1: shapely.geometry.LineString, line2: shapely.geometry.LineString) shapely.geometry.LineString

Connect two line segments with a fit curve.

mosstool.map._util.line.connect_line_string_bezier_4_t_point(strength: float, line1: shapely.geometry.LineString, line2: shapely.geometry.LineString) shapely.geometry.LineString

Connect two line segments with a 4 point Bezier curve.

mosstool.map._util.line.connect_line_string_straight(line1: shapely.geometry.LineString, line2: shapely.geometry.LineString) shapely.geometry.LineString

Connect two line segments with straight line.

mosstool.map._util.line.offset_lane(line: shapely.geometry.LineString, distance: float) shapely.geometry.LineString

Offset LineString to the left/right

Args:

  • line (LineString): LineString

  • distance (float): offset distance. Positive for left, negative for right. unit: meter.

Returns:

  • LineString: offset LineString

mosstool.map._util.line.align_line(line1: shapely.geometry.LineString, line2: shapely.geometry.LineString) shapely.geometry.LineString

Align line1 along the direction of advance with line2.

mosstool.map._util.line.merge_near_xy_points(orig_points: list[tuple[float, float]], merge_gate: float = 100) list[tuple[float, float]]

Return merged coordinates of input points coordinates

mosstool.map._util.line.connect_split_lines(lines: list[shapely.geometry.LineString], start_point: Optional[shapely.geometry.Point] = None, max_line_length: float = 10000) list

Connect split lines (especially for way items in OSM) as one line.

mosstool.map._util.line.merge_line_start_end(line_start: shapely.geometry.LineString, line_end: shapely.geometry.LineString) shapely.geometry.LineString

Keep the start point of line_start and the end point of line_end unchanged, return merged result of the two lines

mosstool.map._util.line.get_start_vector(line: shapely.geometry.LineString)

Get the start vector of a LineString

mosstool.map._util.line.get_end_vector(line: shapely.geometry.LineString)

Get the end vector of a LineString

mosstool.map._util.line.get_line_angle(line: shapely.geometry.LineString)

Get the angle (-pi~pi) of the line