Skip to content

Commit 500c64a

Browse files
committedAug 18, 2012
MSSQL: Fix for the parser when reading multipoint geometries (fixes #6190)
1 parent ceea621 commit 500c64a

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed
 

‎src/providers/mssql/qgsmssqlgeometryparser.cpp

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,56 @@
2020
#include "qgslogger.h"
2121
#include "qgsapplication.h"
2222

23+
/* SqlGeometry serialization format
24+
25+
Simple Point (SerializationProps & IsSinglePoint)
26+
[SRID][0x01][SerializationProps][Point]
27+
28+
Simple Line Segment (SerializationProps & IsSingleLineSegment)
29+
[SRID][0x01][SerializationProps][Point][Point]
30+
31+
Complex Geometries
32+
[SRID][0x01][SerializationProps][NumPoints][Point]..[Point]
33+
[NumFigures][Figure]..[Figure][NumShapes][Shape]..[Shape]
34+
35+
SRID
36+
Spatial Reference Id (4 bytes)
37+
38+
SerializationProps (bitmask) 1 byte
39+
0x01 = HasZValues
40+
0x02 = HasMValues
41+
0x04 = IsValid
42+
0x08 = IsSinglePoint
43+
0x10 = IsSingleLineSegment
44+
0x20 = IsWholeGlobe
45+
46+
Point (2-4)x8 bytes, size depends on SerializationProps & HasZValues & HasMValues
47+
[x][y][z][m] - SqlGeometry
48+
[latitude][longitude][z][m] - SqlGeography
49+
50+
Figure
51+
[FigureAttribute][PointOffset]
52+
53+
FigureAttribute (1 byte)
54+
0x00 = Interior Ring
55+
0x01 = Stroke
56+
0x02 = Exterior Ring
57+
58+
Shape
59+
[ParentFigureOffset][FigureOffset][ShapeType]
60+
61+
ShapeType (1 byte)
62+
0x00 = Unknown
63+
0x01 = Point
64+
0x02 = LineString
65+
0x03 = Polygon
66+
0x04 = MultiPoint
67+
0x05 = MultiLineString
68+
0x06 = MultiPolygon
69+
0x07 = GeometryCollection
70+
71+
*/
72+
2373
/************************************************************************/
2474
/* Geometry parser macros */
2575
/************************************************************************/
@@ -179,10 +229,8 @@ void QgsMssqlGeometryParser::ReadPoint( int iShape )
179229

180230
void QgsMssqlGeometryParser::ReadMultiPoint( int iShape )
181231
{
182-
int iFigure, iPoint, iNextPoint, iCount;
183-
iFigure = FigureOffset( iShape );
184-
iNextPoint = NextPointOffset( iFigure );
185-
iCount = iNextPoint - PointOffset( iFigure );
232+
int i, iCount;
233+
iCount = nNumShapes - iShape - 1;
186234
if ( iCount <= 0 )
187235
return;
188236
// copy byte order
@@ -197,9 +245,13 @@ void QgsMssqlGeometryParser::ReadMultiPoint( int iShape )
197245
// copy point count
198246
CopyBytes( &iCount, 4 );
199247
// copy points
200-
for ( iPoint = PointOffset( iFigure ); iPoint < iNextPoint; iPoint++ )
248+
for ( i = iShape + 1; i < nNumShapes; i++ )
201249
{
202-
CopyPoint( iShape );
250+
if ( ParentOffset( i ) == ( unsigned int )iShape )
251+
{
252+
if ( ShapeType( i ) == ST_POINT )
253+
ReadPoint( i );
254+
}
203255
}
204256
}
205257

0 commit comments

Comments
 (0)
Please sign in to comment.