GDAL

ogrgeojsonwriter.h
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Defines GeoJSON reader within OGR OGRGeoJSON Driver.
5 * Author: Mateusz Loskot, mateusz@loskot.net
6 *
7 ******************************************************************************
8 * Copyright (c) 2007, Mateusz Loskot
9 * Copyright (c) 2011-2013, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef OGR_GEOJSONWRITER_H_INCLUDED
15#define OGR_GEOJSONWRITER_H_INCLUDED
16
19#include "ogr_core.h"
20
21#include "cpl_json_header.h"
22#include "cpl_string.h"
23
24 class OGRFeature;
25 class OGRGeometry;
26 class OGRPolygon;
27
28/************************************************************************/
29/* GeoJSON Geometry Translators */
30/************************************************************************/
31
32 class CPL_DLL OGRGeoJSONWriteOptions
33{
34 public:
35 bool bWriteBBOX = false;
36 bool bBBOXRFC7946 = false;
37 int nXYCoordPrecision = -1;
38 int nZCoordPrecision = -1;
39 int nSignificantFigures = -1;
40 bool bPolygonRightHandRule = false;
41 bool bCanPatchCoordinatesWithNativeData = true;
42 bool bHonourReservedRFC7946Members = false;
43 CPLString osIDField{};
44 bool bForceIDFieldType = false;
45 bool bGenerateID = false;
46 OGRFieldType eForcedIDFieldType = OFTString;
47 bool bAllowNonFiniteValues = false;
48 bool bAutodetectJsonStrings = true;
49 bool bAllowCurve = false;
50 bool bAllowMeasure = false;
51
52 void SetRFC7946Settings();
53 void SetIDOptions(CSLConstList papszOptions);
54};
55
56 OGREnvelope3D CPL_DLL OGRGeoJSONGetBBox(const OGRGeometry *poGeometry,
57 const OGRGeoJSONWriteOptions &oOptions);
58
59json_object CPL_DLL *
60OGRGeoJSONWriteFeature(OGRFeature *poFeature,
61 const OGRGeoJSONWriteOptions &oOptions);
62
63 void OGRGeoJSONWriteId(const OGRFeature *poFeature, json_object *poObj,
64 bool bIdAlreadyWritten,
65 const OGRGeoJSONWriteOptions &oOptions);
66
67json_object *OGRGeoJSONWriteAttributes(
68 OGRFeature *poFeature, bool bWriteIdIfFoundInAttributes = true,
69 const OGRGeoJSONWriteOptions &oOptions = OGRGeoJSONWriteOptions());
70
71json_object CPL_DLL *
72OGRGeoJSONWriteGeometry(const OGRGeometry *poGeometry,
73 const OGRGeoJSONWriteOptions &oOptions);
74
75json_object *OGRGeoJSONWritePolygon(const OGRPolygon *poPolygon,
76 const OGRGeoJSONWriteOptions &oOptions);
77
80#endif /* OGR_GEOJSONWRITER_H_INCLUDED */
CPLString
Convenient string class based on std::string.
Definition cpl_string.h:320
OGREnvelope3D
Simple container for a bounding region in 3D.
Definition ogr_core.h:199
OGRFeature
A simple feature, including geometry and attributes.
Definition ogr_feature.h:934
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRPolygon
Concrete class representing polygons.
Definition ogr_geometry.h:2635
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
cpl_string.h
Various convenience functions for working with strings and string lists.
ogr_core.h
Core portability services for cross-platform OGR code.
OGRFieldType
OGRFieldType
List of feature field types.
Definition ogr_core.h:772
OFTString
@ OFTString
String of ASCII chars.
Definition ogr_core.h:777