Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-04-30 9f2ef60949ced4fab4d077a7e1c6d913f3620c9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**********************************************************************
 *
 * PostGIS - Spatial Types for PostgreSQL
 * http://postgis.net
 *
 * PostGIS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * PostGIS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PostGIS.  If not, see <http://www.gnu.org/licenses/>.
 *
 **********************************************************************
 *
 * Copyright 2021 Björn Harrtell
 *
 **********************************************************************/
 
#ifndef FLATGEOBUF_GEOMETRYWRITER_H
#define FLATGEOBUF_GEOMETRYWRITER_H
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include "lwgeom_log.h"
#include "liblwgeom.h"
 
#ifdef __cplusplus
}
#endif
 
#include "feature_generated.h"
 
namespace FlatGeobuf {
 
class GeometryWriter {
    private:
        flatbuffers::FlatBufferBuilder &m_fbb;
        const LWGEOM *m_lwgeom;
        FlatGeobuf::GeometryType m_geometry_type;
        const bool m_has_z;
        const bool m_has_m;
        std::vector<double> m_xy;
        std::vector<double> m_z;
        std::vector<double> m_m;
 
        void writePoint(const LWPOINT *p);
        void writeMultiPoint(const LWMPOINT *mp);
        void writeLineString(const LWLINE *l);
        void writeMultiLineString(const LWMLINE *ml);
        void writePolygon(const LWPOLY *p);
        const flatbuffers::Offset<FlatGeobuf::Geometry> writeMultiPolygon(const LWMPOLY *mp, int depth);
        const flatbuffers::Offset<FlatGeobuf::Geometry> writeGeometryCollection(const LWCOLLECTION *gc, int depth);
 
        void writePA(POINTARRAY *pa);
        void writePPA(POINTARRAY **ppa, uint32_t len);
        /*
        const flatbuffers::Offset<FlatGeobuf::Geometry> writeCompoundCurve(const OGRCompoundCurve *cc, int depth);
        const flatbuffers::Offset<FlatGeobuf::Geometry> writeCurvePolygon(const OGRCurvePolygon *cp, int depth);
        const flatbuffers::Offset<FlatGeobuf::Geometry> writePolyhedralSurface(const OGRPolyhedralSurface *p, int depth);
        void writeTIN(const OGRTriangulatedSurface *p);
        */
 
    public:
        GeometryWriter(
            flatbuffers::FlatBufferBuilder &fbb,
            const LWGEOM *lwgeom,
            const FlatGeobuf::GeometryType geometry_type,
            const bool has_z,
            const bool has_m) :
            m_fbb (fbb),
            m_lwgeom (lwgeom),
            m_geometry_type (geometry_type),
            m_has_z (has_z),
            m_has_m (has_m)
            { }
        std::vector<uint32_t> m_ends;
        const flatbuffers::Offset<FlatGeobuf::Geometry> write(int depth);
        static const FlatGeobuf::GeometryType get_geometrytype(const LWGEOM *lwgeom);
};
 
}
 
 
#endif /* FLATGEOBUF_GEOMETRYWRITER_H */