本文整理汇总了C++中QgsVector::perpVector方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVector::perpVector方法的具体用法?C++ QgsVector::perpVector怎么用?C++ QgsVector::perpVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVector
的用法示例。
在下文中一共展示了QgsVector::perpVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkRingIntersections
void QgsGeometryValidator::checkRingIntersections(
int p0, int i0, const QgsPolyline &ring0,
int p1, int i1, const QgsPolyline &ring1 )
{
for ( int i = 0; !mStop && i < ring0.size() - 1; i++ )
{
QgsVector v = ring0[i+1] - ring0[i];
for ( int j = 0; !mStop && j < ring1.size() - 1; j++ )
{
QgsVector w = ring1[j+1] - ring1[j];
QgsPoint s;
if ( intersectLines( ring0[i], v, ring1[j], w, s ) )
{
double d = -distLine2Point( ring0[i], v.perpVector(), s );
if ( d >= 0 && d <= v.length() )
{
d = -distLine2Point( ring1[j], w.perpVector(), s );
if ( d > 0 && d < w.length() &&
ring0[i+1] != ring1[j+1] && ring0[i+1] != ring1[j] &&
ring0[i+0] != ring1[j+1] && ring0[i+0] != ring1[j] )
{
QString msg = QObject::tr( "segment %1 of ring %2 of polygon %3 intersects segment %4 of ring %5 of polygon %6 at %7" )
.arg( i0 ).arg( i ).arg( p0 )
.arg( i1 ).arg( j ).arg( p1 )
.arg( s.toString() );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg, s ) );
mErrorCount++;
}
}
}
}
}
}
示例2: validatePolyline
void QgsGeometryValidator::validatePolyline( int i, QgsPolyline line, bool ring )
{
if ( ring )
{
if ( line.size() < 4 )
{
QString msg = QObject::tr( "ring %1 with less than four points" ).arg( i );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg ) );
mErrorCount++;
return;
}
if ( line[0] != line[ line.size()-1 ] )
{
QString msg = QObject::tr( "ring %1 not closed" ).arg( i );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg ) );
mErrorCount++;
return;
}
}
else if ( line.size() < 2 )
{
QString msg = QObject::tr( "line %1 with less than two points" ).arg( i );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg ) );
mErrorCount++;
return;
}
int j = 0;
while ( j < line.size() - 1 )
{
int n = 0;
while ( j < line.size() - 1 && line[j] == line[j+1] )
{
line.remove( j );
n++;
}
if ( n > 0 )
{
QString msg = QObject::tr( "line %1 contains %n duplicate node(s) at %2", "number of duplicate nodes", n ).arg( i ).arg( j );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg, line[j] ) );
mErrorCount++;
}
j++;
}
for ( j = 0; !mStop && j < line.size() - 3; j++ )
{
QgsVector v = line[j+1] - line[j];
double vl = v.length();
int n = ( j == 0 && ring ) ? line.size() - 2 : line.size() - 1;
for ( int k = j + 2; !mStop && k < n; k++ )
{
QgsVector w = line[k+1] - line[k];
QgsPoint s;
if ( !intersectLines( line[j], v, line[k], w, s ) )
continue;
double d = 0.0;
try
{
d = -distLine2Point( line[j], v.perpVector(), s );
}
catch ( QgsException & e )
{
Q_UNUSED( e );
QgsDebugMsg( "Error validating: " + e.what() );
continue;
}
if ( d < 0 || d > vl )
continue;
try
{
d = -distLine2Point( line[k], w.perpVector(), s );
}
catch ( QgsException & e )
{
Q_UNUSED( e );
QgsDebugMsg( "Error validating: " + e.what() );
continue;
}
if ( d <= 0 || d >= w.length() )
continue;
QString msg = QObject::tr( "segments %1 and %2 of line %3 intersect at %4" ).arg( j ).arg( k ).arg( i ).arg( s.toString() );
QgsDebugMsg( msg );
emit errorFound( QgsGeometry::Error( msg, s ) );
mErrorCount++;
}
//.........这里部分代码省略.........