QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
vectortile
qgsvectortilemvtutils.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsvectortilemvtutils.cpp
3
--------------------------------------
4
Date : April 2020
5
Copyright : (C) 2020 by Martin Dobias
6
Email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgsvectortilemvtutils.h
"
17
18
#include "
qgslinestring.h
"
19
20
bool
QgsVectorTileMVTUtils::isExteriorRing
(
const
QgsLineString
*lineString )
21
{
22
// Exterior rings have POSITIVE area while interior rings have NEGATIVE area
23
// when calculated with https://en.wikipedia.org/wiki/Shoelace_formula
24
// The orientation of axes is that X grows to the right and Y grows to the bottom.
25
// the input data are expected to form a closed ring, i.e. first pt == last pt.
26
27
double
total = 0.0;
28
const
int
count = lineString->
numPoints
();
29
const
double
*xData = lineString->
xData
();
30
const
double
*yData = lineString->
yData
();
31
32
for
(
int
i = 0; i < count - 1; i++ )
33
{
34
const
double
val = ( xData[i + 1] - xData[i] ) * ( yData[i + 1] + yData[i] );
35
//double val = xData[i] * (-yData[i+1]) - xData[i+1] * (-yData[i]); // gives the same result
36
total += val;
37
}
38
return
total >= 0;
39
}
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition
qgslinestring.h:49
QgsSimpleCurve::numPoints
int numPoints() const override
Returns the number of points in the curve.
Definition
qgssimplecurve.cpp:192
QgsSimpleCurve::yData
const double * yData() const
Returns a const pointer to the y vertex data.
Definition
qgssimplecurve.h:178
QgsSimpleCurve::xData
const double * xData() const
Returns a const pointer to the x vertex data.
Definition
qgssimplecurve.h:171
QgsVectorTileMVTUtils::isExteriorRing
static bool isExteriorRing(const QgsLineString *lineString)
Returns whether this linear ring forms an exterior ring according to MVT spec (depending on the orien...
Definition
qgsvectortilemvtutils.cpp:20
qgslinestring.h
qgsvectortilemvtutils.h
Generated on
for QGIS API Documentation by
1.17.0