1 /*************************************************************************** 2 qgsmssqlgeometryparser.h - description 3 ------------------- 4 begin : 2014-03-16 5 copyright : (C) 2014 by Tamas Szekeres 6 email : szekerest at gmail.com 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef QGSMSSQLGEOMETRYPARSER_H 19 #define QGSMSSQLGEOMETRYPARSER_H 20 21 #include "qgsabstractgeometry.h" 22 #include "qgsmultilinestring.h" 23 #include "qgsmultipolygon.h" 24 #include "qgsmultipoint.h" 25 #include "qgslinestring.h" 26 #include "qgscircularstring.h" 27 #include "qgscompoundcurve.h" 28 #include "qgscurvepolygon.h" 29 #include "qgspolygon.h" 30 #include "qgspoint.h" 31 32 33 34 /** 35 \class QgsMssqlGeometryParser 36 \brief Geometry parser for SqlGeometry/SqlGeography. 37 * 38 */ 39 40 class QgsMssqlGeometryParser 41 { 42 43 protected: 44 unsigned char *mData = nullptr; 45 /* version information */ 46 char mVersion = 0; 47 /* serialization properties */ 48 char mProps = 0; 49 /* point array */ 50 int mPointSize = 0; 51 int mPointPos = 0; 52 int mNumPoints = 0; 53 /* figure array */ 54 int mFigurePos = 0; 55 int mNumFigures = 0; 56 /* shape array */ 57 int mShapePos = 0; 58 int mNumShapes = 0; 59 /* segmenttype array */ 60 int mSegmentPos = 0; 61 int mNumSegments = 0; 62 int mSegment = 0; 63 int mSRSId = 0; 64 65 protected: 66 QgsPoint readCoordinates( int iPoint ); 67 void readCoordinates( int iPoint, int iNextPoint, double *x, double *y, double *z, double *m ); 68 const QgsPointSequence readPointSequence( int iPoint, int iNextPoint ); 69 std::unique_ptr< QgsPoint > readPoint( int iShape ); 70 std::unique_ptr< QgsMultiPoint > readMultiPoint( int iShape ); 71 std::unique_ptr< QgsLineString > readLineString( int iPoint, int iNextPoint ); 72 std::unique_ptr< QgsLineString > readLineString( int iFigure ); 73 std::unique_ptr< QgsCircularString > readCircularString( int iPoint, int iNextPoint ); 74 std::unique_ptr< QgsCircularString > readCircularString( int iFigure ); 75 std::unique_ptr< QgsMultiLineString > readMultiLineString( int iShape ); 76 std::unique_ptr< QgsPolygon > readPolygon( int iShape ); 77 std::unique_ptr< QgsMultiPolygon > readMultiPolygon( int iShape ); 78 std::unique_ptr< QgsCompoundCurve > readCompoundCurve( int iFigure ); 79 std::unique_ptr< QgsCurvePolygon > readCurvePolygon( int iShape ); 80 std::unique_ptr< QgsGeometryCollection > readGeometryCollection( int iShape ); 81 82 public: 83 QgsMssqlGeometryParser(); 84 std::unique_ptr<QgsAbstractGeometry> parseSqlGeometry( unsigned char *pszInput, int nLen ); GetSRSId()85 int GetSRSId() { return mSRSId; } 86 void DumpMemoryToLog( const char *pszMsg, unsigned char *pszInput, int nLen ); 87 /* sql geo type */ 88 bool mIsGeography = false; 89 }; 90 91 92 #endif // QGSMSSQLGEOMETRYPARSER_H 93