PyANGKernel.GKPoints

class GKPoints

Synopsis

Methods

Static functions

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

This Vector of GKPoints adds methods to the collection of points that operates all over points. These methods are oriented to the collection of points not to a single point.

class GKPointsCompressType
PyANGKernel.GKPoints.gkDefaultBezierPoints
PyANGKernel.GKPoints.gkDefaultBezierPointsEpsilon
__init__()
add(points2)
Parameters:

points2GKPoints

This function returns a new polygon constructed adding points2 to this. This function mix the points from both polygons adding each point in order taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.

add(offsetPercent)
Parameters:

offsetPercent – float

Return type:

int

Adds a new point to this polyline at distance offsetPercent * length2D from the beginning. Returns the new point position. If offsetPercent <= 0.0 or offsetPercent >= 1.0 or polyline.size() < 2, it returns -1.

allIntersections(from, to, closed)
Parameters:
Return type:

GKPoints

Returns all the intersections of the line [from,to] with this object. If closed is true the this object is interpreted as a Polygon, if not as a Polyline

angleBetweenLines(p1, p2, p3, p4)
Parameters:
Return type:

float

It returns the angle between the lines (from p1 to p2) and (from p3 to p4) in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0

angleToPoints(pointsTo)
Parameters:

pointsToGKPoints

Return type:

float

It returns the angle between the two last points of this object and the two first points in ‘pointsTo’ in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0

append(arg__1)
Parameters:

arg__1GKPoint

append(l)
Parameters:

l – .list of GKPoint

at(i)
Parameters:

i – int

Return type:

GKPoint

back()
Return type:

GKPoint

beforeLast()
Return type:

GKPoint

Returns the before last point (a.k.a “penultimate”).

bufferize([_width=0.1[, _closed=true]])
Parameters:
  • _width – float

  • _closed – bool

Return type:

GKPoints

Scales the current points vector,

calculateBezier(bezier[, nbmaxpoints=0[, simplify=true]])
Parameters:
  • bezierGKPoints

  • nbmaxpoints – int

  • simplify – bool

Calculates a polyline that represents a bezier curve with “this” as control points of the bezier curve. The result is stored in bezier. The bezier will have as much points as nbpoints. The bezier will be simplified using epsilon as the minimum distance allowed between points not to be discarded

If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.

If epsilon is -1 then the value of GKPoints::gkDefaultBezierPointsEpsilon will be used.

calculateBezierLength2D([nbmaxpoints=0])
Parameters:

nbmaxpoints – int

Return type:

float

Calculates the length 2D of the polyline that represents a bezier curve with “this” as control points of the bezier curve Equivaled, but faster than, to:

calculateBezier( points, nbmaxpoints );
length = points.legth2D();

if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.

calculateBezierLength3D([nbpoints=0])
Parameters:

nbpoints – int

Return type:

float

Calculates the length 3D of the polyline that represents a bezier curve with “this” as control points of the bezier curve Equivaled, but faster than, to:

calculateBezier( points, nbPoints );
length = points.legth3D();

if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.

calculateTangentAngle(pos)
Parameters:

posGKPoint

Return type:

float

capacity()
Return type:

int

center()
Return type:

GKPoint

Returns the center of this closed polygon.

centroid()
Return type:

GKPoint

Returns the centroid of this closed polygon.

clear()
compress(sizeToReduce, type)
Parameters:
Return type:

GKPoints

Returns a compressed version of this polyline (this method doesn’t works on polygons). It reduce the length of the polyline in “sizeToReduce” m. The reduction on each segment is proportional to each segment length.

The reduction type can be: - eStart: reduces from the start point (included), all the points except the end point are changed. - eEnd: reduces from the end point (included), all the points except the start point are changed. - eBoth: reduces all the segments. All the points are changed.

computeProjectionIntervalPoints(secondPoints, initial, final)
Parameters:
Return type:

bool

Computes the initial and final projection points of the given “secondPoints” polyline over the current polyline. Returns true if there is at least one point projected, false is returned otherwise. If the return is false the initial and final parameters are set to GKPoint::null.

computeProjectionIntervalPositions(secondPoints, initial, final)
Parameters:
  • secondPointsGKPoints

  • initialdouble

  • finaldouble

Return type:

bool

Computes the initial and final projection positions of the given “secondPoints” polyline over the current polyline. Returns true if there is at least one point projected, false is returned otherwise. If the return is false the initial and final parameters are not changed.

constData()
Return type:

GKPoint

constFirst()
Return type:

GKPoint

constLast()
Return type:

GKPoint

contains2D(point[, epsilon=0.01[, checkEdges=false]])
Parameters:
  • pointGKPoint

  • epsilon – float

  • checkEdges – bool

Return type:

bool

If this GKPoints is a polygon (it’s closed), returns true if p is inside it.

contains3D(point[, epsilon=0.01])
Parameters:
  • pointGKPoint

  • epsilon – float

Return type:

bool

If this GKPoints is a polygon (it’s closed), returns true if p is inside it in 3D.

count()
Return type:

int

cut(p, leftPart, rightPart)
Parameters:

Calculates the left and right part of this polyline based on a cut point. LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point p, R: right part).

The cut point (p) will be part of left and right parts.

cut(distance, leftPart, rightPart)
Parameters:

Calculates the left and right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this-> length2D() + distance.

cutIn3(distanceIni, distanceEnd, leftPart, midPart, rightPart)
Parameters:

Calculates the left, middle and right part of this polyline based on two distances (the beginning of the polysection is at a distance 0.0). Both distances are from the beginning of the polyline: LLLLLLL/MMUnknownCommand (L: left part, /:point at distanceIni, M: Middle part, :point at distanceEnd (>distanceIni) R: right part). The cut points (at distanceIni and distanceEnd) will be part of both parts.

If distance is negative then distance = this-> length2D() + distance.

data()
Return type:

GKPoint

distToPoint2D(p[, resPoint=None])
Parameters:
Return type:

float

It returns the minimum distance from the GKPoints segments to the input point p. If GKPoints has a single point, it returns the 2D distance between that point and p. Finally, if GKPoints has no points it returns GK::Inf.

empty()
Return type:

bool

expand(extraSize, type)
Parameters:
Return type:

GKPoints

Returns a expanded version of this polyline (this method doesn’t works on polygons). It expand the length of the polyline in “extraSize” m.

The expand type can be: - eStart: expands from the start point (included), only the start point is changed. - eEnd: expands from the end point (included), only the end point is changed.

first()
Return type:

GKPoint

first(n)
Parameters:

n – int

Return type:

.list of GKPoint

static fromList(list)
Parameters:

list – .list of GKPoint

Return type:

.list of GKPoint

static fromQtVector(vector)
Parameters:

vector – .list of GKPoint

Return type:

GKPoints

Returns GKPoints depth copy from QtVector

static fromVector(vector)
Parameters:

vector – .list of GKPoint

Return type:

.list of GKPoint

front()
Return type:

GKPoint

getAltitude()
Return type:

float

Returns the lower Z of any point of this polyline

getArea()
Return type:

float

Returns the area of the polygon described by this array of points. Assumes points are all at z = 0.

getConvexHull()
Return type:

GKPoints

Gets the convexhull of the collection of points

getLeftParallelPolyline(distance)
Parameters:

distance – float

Return type:

GKPoints

getParallelPolyline(side, distance)
Parameters:
Return type:

GKPoints

Returns a parallel polyline to this at a distance “distance” on the specified side (side = 1 LEFT, side = 0 RIGHT)

getParallelPolylineExtended(side, distance, extendedLength)
Parameters:
  • sideRoadSide

  • distance – float

  • extendedLength – float

Return type:

GKPoints

Returns a parallel polyline to this at a distance “distance” on the specified side (side = 1 LEFT, side = 0 RIGHT) and with an extra segment at the beginning and at the end of extendedLength

getParallelPosAtDist(pos, side, distance)
Parameters:
  • pos – float

  • sideRoadSide

  • distance – float

Return type:

float

Returns the position in the parallel polyline to this at a distance “distance” on the specified side (side = 1 LEFT, side = 0 RIGHT) of the point perpendicular to the one located at pos in this polyline.

getPolygonFromCentralPolyline(width)
Parameters:

width – float

Return type:

GKPoints

Returns the polygon formed by the parallel polylines at distance “width/2” on each side of the given polyline, taking it as the central polilyne of the polygon. This is usefull for roads or lane geometry.

getPolylineOnPolyline(from, to)
Parameters:
  • from – float

  • to – float

Return type:

GKPoints

Finds the polyline over this polyline that starts at a distance of “from” from the beginning of the “polyline” and ends at a distance of “to” again from the beginning of the “polyline”

getPolylineOnPolyline(from, to)
Parameters:
  • from – int

  • to – int

Return type:

GKPoints

Finds the polyline over this polyline that starts at a distance of “from” from the beginning of the “polyline” and ends at a distance of “to” again from the beginning of the “polyline”

getProjectionPointsPosition(secondPoints)
Parameters:

secondPointsGKPoints

Return type:

.list of double

Returns the positions on this polyline of the projections of each point from the given polyline.

getRightParallelPolyline(distance)
Parameters:

distance – float

Return type:

GKPoints

getSlope(segmentPos)
Parameters:

segmentPos – int

Return type:

float

It returns the slope for the segment ‘segmentPos’ that is, between point at ‘segmentPos’ and point at ‘segmentPos+1’

getSlope(pointPos1, pointPos2)
Parameters:
  • pointPos1 – int

  • pointPos2 – int

Return type:

float

It returns the slope for the segment definet by ‘pointPos1’ and ‘pointPos2’. Warning: Position must exist or crash.

hasSlope()
Return type:

bool

It returns true if at least two point are at a different height. It returns false if all the points are at the same height.

insert(arg__1, arg__2)
Parameters:
  • arg__1 – int

  • arg__2GKPoint

intersects2D(poli2[, includeVertexs=true[, closed=true[, resPoint=None]]])
Parameters:
  • poli2GKPoints

  • includeVertexs – bool

  • closed – bool

  • resPointGKPoint

Return type:

bool

Returns true if poli2 (polygon if closed = true or polyline if closed = false ) intersects with this object. If this object and poly2 have only vertexs in commom it will return true if include vertexs is true and false if includeVertexs is false. The intersection point is returned in resPoint if resPoint is not NULL (so it’s a pointer to a valid GKPoint )

intersects2D(from, to[, resPoint=None[, considerThisAsClosed=false[, includeVertexs=true]]])
Parameters:
  • fromGKPoint

  • toGKPoint

  • resPointGKPoint

  • considerThisAsClosed – bool

  • includeVertexs – bool

Return type:

bool

Returns true if the line [from,to] intersects this object. The intersection point is returned in resPoint if resPoint is not NULL (so it’s a pointer to a valid GKPoint ). It considerThisAsClosed is true then the segment between the last point and the first one is also considered. includeVertexs variable indicates if intersections on the vertexs have to be taken into account or not.

isConvex()
Return type:

bool

Returns true if the points define a convex polygon.

isEmpty()
Return type:

bool

isPointAtRightArea(p)
Parameters:

pGKPoint

Return type:

bool

Returns true if point p is located at the right side of this polyline (right going from the first point to the last one) and false if p is located at the left side

isSharedWith(other)
Parameters:

other – .list of GKPoint

Return type:

bool

last()
Return type:

GKPoint

last(n)
Parameters:

n – int

Return type:

.list of GKPoint

leftOf(distance)
Parameters:

distance – float

Return type:

GKPoints

Returns the left part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this-> length2D() + distance.

length()
Return type:

int

length2D([closed=false])
Parameters:

closed – bool

Return type:

float

Returns the length of the polyline represented by this points in a 2D space (the Z coordinate is not used). If closed is true then the segment from the last point to the first point is considered.

length2DFromPointToPoint(pointIni, pointEnd)
Parameters:
  • pointIni – int

  • pointEnd – int

Return type:

float

Returns the length of the segments from pointIni to pointEnd (both inclusive). pointIni and pointEnd go from 0 to nbpoints in the polyline-1

length3D([closed=false])
Parameters:

closed – bool

Return type:

float

Returns the length of this polyline in a 3D space. If closed is true then the segment from the last point to the first point is considered.

static maxSize()
Return type:

int

max_size()
Return type:

int

mid(pos[, length=-1])
Parameters:
  • pos – int

  • length – int

Return type:

GKPoints

Returns a vector whose elements are copied from this vector, starting at position pos. If length is -1 (the default), all elements after pos are copied

move(from, to)
Parameters:
  • from – int

  • to – int

onPolyline(point, epsilon[, closed=false])
Parameters:
  • pointGKPoint

  • epsilon – float

  • closed – bool

Return type:

int

Returns the segment number where the point “point” is. If closed is true then the segment from the last point to the first point is considered.

This method is similar to segmentAtPos but considering an epsilon.

__ne__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

__add__(l)
Parameters:

l – .list of GKPoint

Return type:

.list of GKPoint

__iadd__(l)
Parameters:

l – .list of GKPoint

Return type:

.list of GKPoint

__lt__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

__lshift__(l)
Parameters:

l – .list of GKPoint

Return type:

.list of GKPoint

__le__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

__eq__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

__gt__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

__ge__(arg__1)
Parameters:

arg__1GKPoints

Return type:

bool

operator(i)
Parameters:

i – int

Return type:

GKPoint

order()

This function orders the points taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.

pointAtPos(pos[, closed=false])
Parameters:
  • pos – float

  • closed – bool

Return type:

GKPoint

Returns the point in the polyline at position “pos” relative to its start (pos = 0.0 is the start point, pos = length2D() is the end point). Is pos is negative then it will take as initial reference the last point, so it these two calls are equivalent: line.pointAtPos( -3.0 ) and line.pointAtPos( line. length2D() - 3.0 ).

If closed is true then the segment from the last point to the first point is considered.

polygonIntersection(secondPoints)
Parameters:

secondPointsGKPoints

Return type:

.list of GKPoints

Returns a set of polygons that define the intersection polygons between this and the secondPoints group of points. The intersection can be none, then an empty GKPoints will be returned, just one set of GKPoints defining a closed polygon or a group of closed polygons.

polylineIntersection(secondPoints)
Parameters:

secondPointsGKPoints

Return type:

.list of GKPoints

Returns a set of polygons that define the intersection between this and the secondPoints group of points. The intersection can be none, then an empty GKPoints will be returned, just one set of GKPoints or several groups of GKPoints .

pop_back()
pop_front()
posAtPoint(p[, maxDistToPoints=0.01[, closed=false]])
Parameters:
  • pGKPoint

  • maxDistToPoints – float

  • closed – bool

Return type:

float

Returns the position in the polyline at point “p”. The point can be outside of the center line at a maximum distance “maxDistToPoints” from it and, if so, the method will calculate the point at the more close segment (perpendicular to p) and will use this new point.

If closed is true then the segment from the last point to the first point is also considered.

prepend(arg__1)
Parameters:

arg__1GKPoint

push_back(arg__1)
Parameters:

arg__1GKPoint

push_front(arg__1)
Parameters:

arg__1GKPoint

remove(i[, n=1])
Parameters:
  • i – int

  • n – int

removeAll(arg__1)
Parameters:

arg__1GKPoint

removeAt(i)
Parameters:

i – int

removeFirst()
removeIntersectingEdges()
Return type:

GKPoints

Returns a new group of points with the same number of points, in the same order and just taking out the points that make the edges intersect and substituting them by the point located in the middle of both taken out points. So, let’s say that segment with point 0 and point 1 intersects with segment with point 2 and 3, then, point 1 and 2 will be taken out and substituted by a new point that is located in the middle of the line that point 2 and 3 made. This point will be added twice to get a group of points with the same number of points as the original one

removeLast()
removeOne(arg__1)
Parameters:

arg__1GKPoint

reserve(size)
Parameters:

size – int

resize(size)
Parameters:

size – int

resizeForOverwrite(size)
Parameters:

size – int

reverse()

Reverses the points order.

rightOf(distance)
Parameters:

distance – float

Return type:

GKPoints

Returns the right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this-> length2D() + distance.

rotate(center, angle)
Parameters:
  • centerGKPoint

  • angle – float

Rotates all the points in this polyline an angle ‘angle’ in radians taking ‘center’ as the center of rotation

scale(scale)
Parameters:

scaleGKPoint

Scales all the points in this polyline multiplying all them by a scale point

second()
Return type:

GKPoint

Returns the second point (index == 1).

segmentAtPoint(seg_res, p[, maxDistToPoints=0.5])
Parameters:
Return type:

int

Returns the position in the vector of points that identifies the initial point of the segment where p is located or -1 if p is outside this group of points. If p is inside this group of points it also updates the segment “seg_res” with the ith and (i+1)th points if p is inside the ith segment. The point can be outside of the center line at a maximum distance “maxDistToPoints” from it to return true.

segmentAtPos(pos[, closed=false[, length=None]])
Parameters:
  • pos – float

  • closed – bool

  • lengthdouble

Return type:

int

Returns the position in the vector of points that identifies the initial point of the segment where the point at position “pos” relative to the start of the polyline is located (pos = 0.0 is the start point, pos = length2D() is the end point). The length of the 0 –> pos - 1 segments is returned too if “length” is not NULL (it’s a pointer to a double).

Examples: This -> Polyline with 3 points: p[0], p[1], p[2] Distance between p[0] & p[1] = 1.0 Distance between p[1] & p[2] = 2.0

segmentAtPos(0.0) = 0 segmentAtPos(1.0) = 0 segmentAtPos(1.5) = 1 segmentAtPos(3.0) = 1

If closed is true then the segment from the last point to the first point is considered.

setAltitude(value)
Parameters:

value – float

Moves the Z coords of this polyline to make the lower Z equal to “value”

shrink_to_fit()
simplifyPolyline([distance=0.00001])
Parameters:

distance – float

Removes all the unnecesary points, that is the ones that belong to the same segment as their precedent and posterior points, as well as all the loops found in the polyline.

Uses distance to consider points that are too close and must be eliminated.

size()
Return type:

int

sliced(pos)
Parameters:

pos – int

Return type:

.list of GKPoint

sliced(pos, n)
Parameters:
  • pos – int

  • n – int

Return type:

.list of GKPoint

squeeze()
swap(other)
Parameters:

other – .list of GKPoint

swapItemsAt(i, j)
Parameters:
  • i – int

  • j – int

takeAt(i)
Parameters:

i – int

Return type:

GKPoint

toList()
Return type:

.list of GKPoint

toRectangle(angle)
Parameters:

angle – float

Return type:

GKPoints

Returns the 4 points that form a rectangle rotated angle degrees from the horizontal and containing all the points in this object

toRectangle(otherPol, angle)
Parameters:
Return type:

GKPoints

Returns the 4 points that form a rectangle rotated angle degrees from the horizontal and containing all the points in this object and all the points in otherPol

toVector()
Return type:

.list of GKPoint

translate(delta)
Parameters:

deltaGKPoint

Applies a translation delta to all the points in this polyline

translateFromCS(CS)
Parameters:

CS – str

Translates an object from a Coordinate System

value(i)
Parameters:

i – int

Return type:

GKPoint