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