41 unsigned int wkbType = *((
int* ) wkb );
42 wkb +=
sizeof(
unsigned int );
43 unsigned int nPoints = *((
int* ) wkb );
44 wkb +=
sizeof(
unsigned int );
48 int sizeOfDoubleX =
sizeof( double );
49 int sizeOfDoubleY = hasZValue ? 2 *
sizeof( double ) :
sizeof(
double );
51 double p0x, p0y, p1x = 0.0, p1y = 0.0;
53 double lastClipX = 0.0, lastClipY = 0.0;
56 line.reserve( nPoints + 1 );
58 for (
unsigned int i = 0; i < nPoints; ++i )
62 memcpy( &p1x, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleX;
63 memcpy( &p1y, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleY;
72 memcpy( &p1x, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleX;
73 memcpy( &p1y, wkb,
sizeof(
double ) ); wkb += sizeOfDoubleY;
75 p1x_c = p1x; p1y_c = p1y;
77 p0x, p0y, p1x_c, p1y_c ) )
79 bool newLine = line.size() > 0 && ( p0x != lastClipX || p0y != lastClipY );
85 if ( line.size() < 1 || newLine )
88 line << QPointF( p0x, p0y );
92 lastClipX = p1x_c; lastClipY = p1y_c;
93 line << QPointF( p1x_c, p1y_c );
static const double MAX_Y
A rectangle specified with double values.
static const double SMALL_NUM
double yMaximum() const
Get the y maximum value (top side of rectangle)
static const unsigned char * clippedLineWKB(const unsigned char *wkb, const QgsRectangle &clipExtent, QPolygonF &line)
Reads a polyline from WKB and clips it to clipExtent.
static bool clipLineSegment(double xLeft, double xRight, double yBottom, double yTop, double &x0, double &y0, double &x1, double &y1)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static const double MIN_X
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
static void connectSeparatedLines(double x0, double y0, double x1, double y1, const QgsRectangle &clipRect, QPolygonF &pts)
Connects two lines split by the clip (by inserting points on the clip border)
static const double MIN_Y
static const double MAX_X
double xMinimum() const
Get the x minimum value (left side of rectangle)