catatom2osm.geo.point module

class catatom2osm.geo.point.Point(arg1, arg2=None)[source]

Bases: qgis._core.QgsPointXY

Extend QgsPoint with some utility methods.

boundingBox(radius)[source]

Return a bounding box of 2*radius centered in point.

get_angle(geom)[source]

Get angle for nearest vertex in a geometry.

For the vertex in geom nearest to this point, give the angle between its adjacent vertexs.

Parameters

geom (QgsGeometry) – Geometry to test.

Returns

(float) Angle between the vertex and their adjacents,

get_corner_context(geom, acute_thr=10, straight_thr=2, cath_thr=0.02)[source]

Test if nearest vertex in a geometry is a corner.

For the vertex in a geometry nearest to this point, give context to determine if it is a corner (the angle differs by more than straight_thr of 180 and if the distance from the vertex to the segment formed by their adjacents is greater than cath_thr).

Parameters
  • geom (QgsGeometry) – Geometry to test.

  • acute_thr (float) – Acute angle threshold.

  • straight_thr (float) – Straight angle threshold.

  • cath_thr (float) – Cathetus threshold.

Returns

(float) Angle between the vertex and their adjacents. (bool) True if the angle is too low (< acute_thr). (bool) True for a corner (float) Distance to the nearest segment.

get_spike_context(geom, acute_thr=5, straight_thr=2, threshold=0.1)[source]

Test if nearest vertex in geometry is spike.

For the vertex in a geometry nearest to this point, give context to determine if its a zig-zag or a spike. It’s a zig-zag if both the angles of this vertex and the closest adjacents are acute. It’s a spike if the angle of this vertex is acute and the angle of the closest vertex is not straight.

Parameters
  • geom (QgsGeometry) – Geometry to test.

  • acute_thr (float) – Acute angle threshold.

  • straight_thr (float) – Straight angle threshold.

  • threshold (float) – # Filter for angles.

Returns

(float) angle_v = angle between the vertex and their adjacents. (float) angle_a = angle between the closest adjacent and their adjacents. (int) ndx = index of the vertex (int) ndxa = index of the closest adjacent (bool) is_acute = True if the angle is too low (< acute_thr). (bool) is_zigzag = True if both angle_v and angle_a are acute and the distance from va to the segment v-vb is lower than threshold. (bool) is_spike = True if is_acute and angle_a is not straight and the distance from va to the segment v-vb is lower than threshold. (Point) vx = projection of va over the segment v-vb.