LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/flatgeobuf - geometrywriter.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 15 15 100.0 %
Date: 2024-11-21 22:18:42 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  FlatGeobuf driver
       4             :  * Purpose:  GeometryWriter class declarations.
       5             :  * Author:   Björn Harrtell <bjorn at wololo dot org>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2018-2019, Björn Harrtell <bjorn at wololo dot org>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef FLATGEOBUF_GEOMETRYWRITER_H_INCLUDED
      14             : #define FLATGEOBUF_GEOMETRYWRITER_H_INCLUDED
      15             : 
      16             : #include "ogrsf_frmts.h"
      17             : #include "ogr_p.h"
      18             : 
      19             : #include "feature_generated.h"
      20             : 
      21             : namespace ogr_flatgeobuf
      22             : {
      23             : 
      24             : class GeometryWriter
      25             : {
      26             :   private:
      27             :     flatbuffers::FlatBufferBuilder &m_fbb;
      28             :     const OGRGeometry *m_ogrGeometry;
      29             :     FlatGeobuf::GeometryType m_geometryType;
      30             :     const bool m_hasZ;
      31             :     const bool m_hasM;
      32             :     std::vector<double> m_xy;
      33             :     std::vector<double> m_z;
      34             :     std::vector<double> m_m;
      35             :     std::vector<uint32_t> m_ends;
      36             : 
      37             :     void writePoint(const OGRPoint *p);
      38             :     void writeMultiPoint(const OGRMultiPoint *mp);
      39             :     uint32_t writeSimpleCurve(const OGRSimpleCurve *sc);
      40             :     void writeMultiLineString(const OGRMultiLineString *mls);
      41             :     void writePolygon(const OGRPolygon *p);
      42             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      43             :     writeMultiPolygon(const OGRMultiPolygon *mp, int depth);
      44             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      45             :     writeGeometryCollection(const OGRGeometryCollection *gc, int depth);
      46             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      47             :     writeCompoundCurve(const OGRCompoundCurve *cc, int depth);
      48             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      49             :     writeCurvePolygon(const OGRCurvePolygon *cp, int depth);
      50             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      51             :     writePolyhedralSurface(const OGRPolyhedralSurface *p, int depth);
      52             :     void writeTIN(const OGRTriangulatedSurface *p);
      53             : 
      54             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      55          77 :     writePart(const OGRGeometry *part, int depth)
      56             :     {
      57         154 :         return GeometryWriter(m_fbb, part, m_hasZ, m_hasM).write(depth);
      58             :     }
      59             : 
      60             :     const flatbuffers::Offset<FlatGeobuf::Geometry>
      61          33 :     writePart(const OGRGeometry *part,
      62             :               const FlatGeobuf::GeometryType geometryType, int depth)
      63             :     {
      64          66 :         return GeometryWriter(m_fbb, part, geometryType, m_hasZ, m_hasM)
      65          66 :             .write(depth);
      66             :     }
      67             : 
      68             :   public:
      69         232 :     GeometryWriter(flatbuffers::FlatBufferBuilder &fbb,
      70             :                    const OGRGeometry *ogrGeometry,
      71             :                    const FlatGeobuf::GeometryType geometryType, const bool hasZ,
      72             :                    const bool hasM)
      73         232 :         : m_fbb(fbb), m_ogrGeometry(ogrGeometry), m_geometryType(geometryType),
      74         232 :           m_hasZ(hasZ), m_hasM(hasM)
      75             :     {
      76         232 :     }
      77             : 
      78          77 :     GeometryWriter(flatbuffers::FlatBufferBuilder &fbb,
      79             :                    const OGRGeometry *ogrGeometry, const bool hasZ,
      80             :                    const bool hasM)
      81          77 :         : m_fbb(fbb), m_ogrGeometry(ogrGeometry),
      82          77 :           m_geometryType(GeometryWriter::translateOGRwkbGeometryType(
      83          77 :               ogrGeometry->getGeometryType())),
      84         154 :           m_hasZ(hasZ), m_hasM(hasM)
      85             :     {
      86          77 :     }
      87             : 
      88             :     const flatbuffers::Offset<FlatGeobuf::Geometry> write(int depth);
      89             :     static FlatGeobuf::GeometryType
      90             :     translateOGRwkbGeometryType(const OGRwkbGeometryType eGType);
      91             : };
      92             : 
      93             : }  // namespace ogr_flatgeobuf
      94             : 
      95             : #endif /* ndef FLATGEOBUF_GEOMETRYWRITER_H_INCLUDED */

Generated by: LCOV version 1.14