QGIS API Documentation
3.14.0-Pi (9f7028fd23)
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
z
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
c
e
f
g
h
k
l
m
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Related Functions
a
c
d
e
f
g
i
l
m
n
o
p
q
r
s
t
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Variables
a
b
c
d
e
f
g
h
i
l
n
o
p
q
r
s
t
u
w
Typedefs
a
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
Enumerator
Macros
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
w
y
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
src
core
geometry
qgswkbptr.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgswkbptr.cpp
3
---------------------
4
begin : May 2015
5
copyright : (C) 2015 by Marco Hugentobler
6
email : marco dot hugentobler at sourcepole dot ch
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
#include "
qgswkbptr.h
"
16
#include "
qgsapplication.h
"
17
18
QgsWkbPtr::QgsWkbPtr
( QByteArray &wkb )
19
{
20
mP =
reinterpret_cast<
unsigned
char
*
>
( wkb.data() );
21
mStart = mP;
22
mEnd = mP + wkb.length();
23
}
24
25
QgsWkbPtr::QgsWkbPtr
(
unsigned
char
*p,
int
size )
26
{
27
mP = p;
28
mStart = mP;
29
mEnd = mP +
size
;
30
}
31
32
void
QgsWkbPtr::verifyBound(
int
size )
const
33
{
34
if
( !mP || mP +
size
> mEnd )
35
throw
QgsWkbException
( QStringLiteral(
"wkb access out of bounds"
) );
36
}
37
38
QgsConstWkbPtr::QgsConstWkbPtr
(
const
QByteArray &wkb )
39
{
40
mP
=
reinterpret_cast<
unsigned
char
*
>
(
const_cast<
char
*
>
( wkb.constData() ) );
41
mEnd
=
mP
+ wkb.length();
42
mEndianSwap
=
false
;
43
mWkbType
=
QgsWkbTypes::Unknown
;
44
}
45
46
QgsConstWkbPtr::QgsConstWkbPtr
(
const
unsigned
char
*p,
int
size )
47
{
48
mP
=
const_cast<
unsigned
char
*
>
( p );
49
mEnd
=
mP
+ size;
50
mEndianSwap
=
false
;
51
mWkbType
=
QgsWkbTypes::Unknown
;
52
}
53
54
QgsWkbTypes::Type
QgsConstWkbPtr::readHeader
()
const
55
{
56
if
( !
mP
)
57
return
QgsWkbTypes::Unknown
;
58
59
char
wkbEndian;
60
*
this
>> wkbEndian;
61
mEndianSwap
= wkbEndian !=
QgsApplication::endian
();
62
63
int
wkbType;
64
*
this
>> wkbType;
65
mWkbType
=
static_cast<
QgsWkbTypes::Type
>
( wkbType );
66
67
return
mWkbType
;
68
}
69
70
void
QgsConstWkbPtr::verifyBound
(
int
size )
const
71
{
72
if
( !
mP
||
mP
+ size >
mEnd
)
73
throw
QgsWkbException
( QStringLiteral(
"wkb access out of bounds"
) );
74
}
75
76
const
QgsConstWkbPtr
&
QgsConstWkbPtr::operator>>
( QPointF &point )
const
77
{
78
read
( point.rx() );
79
read
( point.ry() );
80
return
*
this
;
81
}
82
83
const
QgsConstWkbPtr
&
QgsConstWkbPtr::operator>>
( QPolygonF &points )
const
84
{
85
int
skipZM = (
QgsWkbTypes::coordDimensions
(
mWkbType
) - 2 ) *
sizeof
(
double
);
86
Q_ASSERT( skipZM >= 0 );
87
88
unsigned
int
nPoints;
89
read
( nPoints );
90
91
points.resize( nPoints );
92
QPointF *ptr = points.data();
93
94
for
(
unsigned
int
i = 0; i < nPoints; ++i, ++ptr )
95
{
96
read
( ptr->rx() );
97
read
( ptr->ry() );
98
mP
+= skipZM;
99
}
100
return
*
this
;
101
}
QgsConstWkbPtr::mP
unsigned char * mP
Definition:
qgswkbptr.h:130
qgswkbptr.h
QgsWkbTypes::coordDimensions
static int coordDimensions(Type type)
Returns the coordinate dimension of the geometry type as an integer.
Definition:
qgswkbtypes.h:924
QgsConstWkbPtr::QgsConstWkbPtr
QgsConstWkbPtr(const QByteArray &wkb)
Construct WKB pointer from QByteArray.
Definition:
qgswkbptr.cpp:38
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition:
qgswkbtypes.h:68
QgsWkbPtr::size
int size() const
size
Definition:
qgswkbptr.h:107
QgsConstWkbPtr::mWkbType
QgsWkbTypes::Type mWkbType
Definition:
qgswkbptr.h:133
qgsapplication.h
QgsWkbTypes::Unknown
@ Unknown
Definition:
qgswkbtypes.h:70
QgsConstWkbPtr::mEnd
unsigned char * mEnd
Definition:
qgswkbptr.h:131
QgsConstWkbPtr
Definition:
qgswkbptr.h:127
QgsWkbException
Definition:
qgswkbptr.h:30
QgsConstWkbPtr::operator>>
const QgsConstWkbPtr & operator>>(double &v) const
Definition:
qgswkbptr.h:165
QgsApplication::endian
static endian_t endian()
Returns whether this machine uses big or little endian.
Definition:
qgsapplication.cpp:1230
QgsWkbPtr::QgsWkbPtr
QgsWkbPtr(QByteArray &wkb)
Construct WKB pointer from QByteArray.
Definition:
qgswkbptr.cpp:18
QgsConstWkbPtr::verifyBound
void verifyBound(int size) const
Verify bounds.
Definition:
qgswkbptr.cpp:70
QgsConstWkbPtr::readHeader
QgsWkbTypes::Type readHeader() const
readHeader
Definition:
qgswkbptr.cpp:54
QgsConstWkbPtr::read
void read(T &v) const
Read a value.
Definition:
qgswkbptr.h:145
QgsConstWkbPtr::mEndianSwap
bool mEndianSwap
Definition:
qgswkbptr.h:132
Generated on Mon Jun 22 2020 05:14:09 for QGIS API Documentation by
1.8.17