| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: OpenGIS Simple Features Reference Implementation |
| 4 | * Purpose: GeoJSON feature sequence driver |
| 5 | * Author: Even Rouault <even.rouault at spatialys.com> |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2018, Even Rouault <even.rouault at spatialys.com> |
| 9 | * |
| 10 | * SPDX-License-Identifier: MIT |
| 11 | ****************************************************************************/ |
| 12 | |
| 13 | #include "cpl_port.h"cxx . . $ `<file>/port/cpl_port.h`/ |
| 14 | #include "cpl_vsi_virtual.h"cxx . . $ `<file>/port/cpl_vsi_virtual.h`/ |
| 15 | #include "cpl_http.h"cxx . . $ `<file>/port/cpl_http.h`/ |
| 16 | #include "cpl_vsi_error.h"cxx . . $ `<file>/port/cpl_vsi_error.h`/ |
| 17 | |
| 18 | #include "ogr_geojson.h"cxx . . $ `<file>/ogr/ogrsf_frmts/geojson/ogr_geojson.h`/ |
| 19 | #include "ogrlibjsonutils.h"cxx . . $ `<file>/ogr/ogrlibjsonutils.h`/ |
| 20 | #include "ogrgeojsonreader.h"cxx . . $ `<file>/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.h`/ |
| 21 | #include "ogrgeojsonwriter.h"cxx . . $ `<file>/ogr/ogrgeojsonwriter.h`/ |
| 22 | #include "ogrgeojsongeometry.h"cxx . . $ `<file>/ogr/ogrgeojsongeometry.h`/ |
| 23 | |
| 24 | #include <algorithm> |
| 25 | #include <memory> |
| 26 | |
| 27 | constexpr char RScxx . . $ RS. = '\x1e'; |
| 28 | |
| 29 | /************************************************************************/ |
| 30 | /* OGRGeoJSONSeqDataSource */ |
| 31 | /************************************************************************/ |
| 32 | |
| 33 | class OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# final : public GDALDatasetcxx . . $ GDALDataset# |
| 34 | { |
| 35 | friend class OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#; |
| 36 | |
| 37 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRLayercxx . . $ OGRLayer#>> m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers.{}; |
| 38 | CPLString m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile.; |
| 39 | VSILFILE *m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = nullptr; |
| 40 | bool m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead. = true; |
| 41 | bool m_bAtEOFcxx . . $ OGRGeoJSONSeqDataSource#m_bAtEOF. = false; |
| 42 | bool m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. = false; |
| 43 | |
| 44 | public: |
| 45 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#OGRGeoJSONSeqDataSource(49f6e7a06ebc5aa8).(); |
| 46 | ~cxx . . $ OGRGeoJSONSeqDataSource#`~OGRGeoJSONSeqDataSource`(ced63f7c635d850d).OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#() override; |
| 47 | |
| 48 | int GetLayerCountcxx . . $ OGRGeoJSONSeqDataSource#GetLayerCount(455f465bc33b4cdf).() const override |
| 49 | { |
| 50 | return static_cast<int>(m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..size()); |
| 51 | } |
| 52 | |
| 53 | const OGRLayercxx . . $ OGRLayer# *GetLayercxx . . $ OGRGeoJSONSeqDataSource#GetLayer(3ead67c79a3185c4).(int) const override; |
| 54 | OGRLayercxx . . $ OGRLayer# *ICreateLayercxx . . $ OGRGeoJSONSeqDataSource#ICreateLayer(d0342318947b6f88).(const char *pszName, |
| 55 | const OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poGeomFieldDefn, |
| 56 | CSLConstListcxx . . $ CSLConstList# papszOptions) override; |
| 57 | int TestCapabilitycxx . . $ OGRGeoJSONSeqDataSource#TestCapability(78f035161ffa9fe2).(const char *pszCap) const override; |
| 58 | |
| 59 | bool Opencxx . . $ OGRGeoJSONSeqDataSource#Open(f8566f36da6962f1).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo, GeoJSONSourceTypecxx . . $ GeoJSONSourceType# nSrcType); |
| 60 | bool Createcxx . . $ OGRGeoJSONSeqDataSource#Create(16997358fa22d8dc).(const char *pszName, CSLConstListcxx . . $ CSLConstList# papszOptions); |
| 61 | }; |
| 62 | |
| 63 | /************************************************************************/ |
| 64 | /* OGRGeoJSONSeqLayer */ |
| 65 | /************************************************************************/ |
| 66 | |
| 67 | class OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer# final : public OGRLayercxx . . $ OGRLayer# |
| 68 | { |
| 69 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS. = nullptr; |
| 70 | OGRFeatureDefncxx . . $ OGRFeatureDefn# *m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn. = nullptr; |
| 71 | bool m_bLayerDefnEstablishedcxx . . $ OGRGeoJSONSeqLayer#m_bLayerDefnEstablished. = false; |
| 72 | bool m_bWriteOnlyLayercxx . . $ OGRGeoJSONSeqLayer#m_bWriteOnlyLayer. = false; |
| 73 | |
| 74 | OGRGeoJSONBaseReadercxx . . $ OGRGeoJSONBaseReader# m_oReadercxx . . $ OGRGeoJSONSeqLayer#m_oReader.; |
| 75 | CPLString m_osFIDColumncxx . . $ OGRGeoJSONSeqLayer#m_osFIDColumn.; |
| 76 | |
| 77 | size_t m_nMaxObjectSizecxx . . $ OGRGeoJSONSeqLayer#m_nMaxObjectSize. = 0; |
| 78 | stdcxx . . $ std/::string m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer.; |
| 79 | stdcxx . . $ std/::string m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer.; |
| 80 | size_t m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. = 0; |
| 81 | size_t m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. = 0; |
| 82 | |
| 83 | vsi_l_offset m_nFileSizecxx . . $ OGRGeoJSONSeqLayer#m_nFileSize. = 0; |
| 84 | GIntBigcxx . . $ GIntBig# m_nItercxx . . $ OGRGeoJSONSeqLayer#m_nIter. = 0; |
| 85 | |
| 86 | GIntBigcxx . . $ GIntBig# m_nTotalFeaturescxx . . $ OGRGeoJSONSeqLayer#m_nTotalFeatures. = 0; |
| 87 | GIntBigcxx . . $ GIntBig# m_nNextFIDcxx . . $ OGRGeoJSONSeqLayer#m_nNextFID. = 0; |
| 88 | |
| 89 | stdcxx . . $ std/::unique_ptr<OGRCoordinateTransformationcxx . . $ OGRCoordinateTransformation#> m_poCTcxx . . $ OGRGeoJSONSeqLayer#m_poCT.{}; |
| 90 | OGRGeometryFactorycxx . . $ OGRGeometryFactory#::TransformWithOptionsCachecxx . . $ OGRGeometryFactory#TransformWithOptionsCache# m_oTransformCachecxx . . $ OGRGeoJSONSeqLayer#m_oTransformCache.; |
| 91 | OGRGeoJSONWriteOptionscxx . . $ OGRGeoJSONWriteOptions# m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions.; |
| 92 | |
| 93 | json_object *GetNextObjectcxx . . $ OGRGeoJSONSeqLayer#GetNextObject(a85131c35b0089d).(bool bLooseIdentification); |
| 94 | |
| 95 | public: |
| 96 | OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#OGRGeoJSONSeqLayer(e2d4682bdc62fb6a).(OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS, const char *pszName); |
| 97 | |
| 98 | // Write-only constructor |
| 99 | OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#OGRGeoJSONSeqLayer(18deb1c4a1a083a).(OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS, const char *pszName, |
| 100 | CSLConstListcxx . . $ CSLConstList# papszOptions, |
| 101 | stdcxx . . $ std/::unique_ptr<OGRCoordinateTransformationcxx . . $ OGRCoordinateTransformation#> &&poCT); |
| 102 | |
| 103 | ~cxx . . $ OGRGeoJSONSeqLayer#`~OGRGeoJSONSeqLayer`(ced63f7c635d850d).OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#() override; |
| 104 | |
| 105 | bool Initcxx . . $ OGRGeoJSONSeqLayer#Init(f2cb034b043a1ce9).(bool bLooseIdentification, bool bEstablishLayerDefn); |
| 106 | |
| 107 | const char *GetNamecxx . . $ OGRGeoJSONSeqLayer#GetName(a9f41ea0e82d88cf).() const override |
| 108 | { |
| 109 | return GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(); |
| 110 | } |
| 111 | |
| 112 | void ResetReadingcxx . . $ OGRGeoJSONSeqLayer#ResetReading(49f6e7a06ebc5aa8).() override; |
| 113 | OGRFeaturecxx . . $ OGRFeature# *GetNextFeaturecxx . . $ OGRGeoJSONSeqLayer#GetNextFeature(ec9eceddec1d9563).() override; |
| 114 | const OGRFeatureDefncxx . . $ OGRFeatureDefn# *GetLayerDefncxx . . $ OGRGeoJSONSeqLayer#GetLayerDefn(448b209f43d15bcc).() const override; |
| 115 | |
| 116 | const char *GetFIDColumncxx . . $ OGRGeoJSONSeqLayer#GetFIDColumn(a9f41ea0e82d88cf).() const override |
| 117 | { |
| 118 | return m_osFIDColumncxx . . $ OGRGeoJSONSeqLayer#m_osFIDColumn..c_str(); |
| 119 | } |
| 120 | |
| 121 | GIntBigcxx . . $ GIntBig# GetFeatureCountcxx . . $ OGRGeoJSONSeqLayer#GetFeatureCount(9ccc33c3ebad048d).(int) override; |
| 122 | int TestCapabilitycxx . . $ OGRGeoJSONSeqLayer#TestCapability(78f035161ffa9fe2).(const char *) const override; |
| 123 | OGRErr ICreateFeaturecxx . . $ OGRGeoJSONSeqLayer#ICreateFeature(2048609adab03aab).(OGRFeaturecxx . . $ OGRFeature# *poFeature) override; |
| 124 | OGRErr CreateFieldcxx . . $ OGRGeoJSONSeqLayer#CreateField(2cf5282e6e90de1e).(const OGRFieldDefncxx . . $ OGRFieldDefn# *, int) override; |
| 125 | |
| 126 | GDALDatasetcxx . . $ GDALDataset# *GetDatasetcxx . . $ OGRGeoJSONSeqLayer#GetDataset(76c1989f6ffbc048).() override |
| 127 | { |
| 128 | return m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.; |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | /************************************************************************/ |
| 133 | /* OGRGeoJSONSeqDataSource() */ |
| 134 | /************************************************************************/ |
| 135 | |
| 136 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#OGRGeoJSONSeqDataSource(49f6e7a06ebc5aa8).() |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | /************************************************************************/ |
| 141 | /* ~OGRGeoJSONSeqDataSource() */ |
| 142 | /************************************************************************/ |
| 143 | |
| 144 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::~cxx . . $ OGRGeoJSONSeqDataSource#`~OGRGeoJSONSeqDataSource`(ced63f7c635d850d).OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#() |
| 145 | { |
| 146 | if (m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) |
| 147 | { |
| 148 | VSIFCloseL(m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.); |
| 149 | } |
| 150 | if (!m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile..empty()) |
| 151 | { |
| 152 | VSIUnlink(m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile.); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /************************************************************************/ |
| 157 | /* GetLayer() */ |
| 158 | /************************************************************************/ |
| 159 | |
| 160 | const OGRLayercxx . . $ OGRLayer# *OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::GetLayercxx . . $ OGRGeoJSONSeqDataSource#GetLayer(3ead67c79a3185c4).(int nIndex) const |
| 161 | { |
| 162 | if (nIndex < 0 || nIndex >= GetLayerCountcxx . . $ OGRGeoJSONSeqDataSource#GetLayerCount(455f465bc33b4cdf).()) |
| 163 | return nullptr; |
| 164 | return m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers.[nIndex].get(); |
| 165 | } |
| 166 | |
| 167 | /************************************************************************/ |
| 168 | /* ICreateLayer() */ |
| 169 | /************************************************************************/ |
| 170 | |
| 171 | OGRLayercxx . . $ OGRLayer# *OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::ICreateLayercxx . . $ OGRGeoJSONSeqDataSource#ICreateLayer(d0342318947b6f88).( |
| 172 | const char *pszNameIn, const OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poSrcGeomFieldDefn, |
| 173 | CSLConstListcxx . . $ CSLConstList# papszOptions) |
| 174 | { |
| 175 | if (!TestCapabilitycxx . . $ OGRGeoJSONSeqDataSource#TestCapability(78f035161ffa9fe2).(ODsCCreateLayercxx . . $ `ogr/ogr_core.h:1040:9`!)) |
| 176 | return nullptr; |
| 177 | |
| 178 | const auto poSRS = |
| 179 | poSrcGeomFieldDefn ? poSrcGeomFieldDefn->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).() : nullptr; |
| 180 | |
| 181 | stdcxx . . $ std/::unique_ptr<OGRCoordinateTransformationcxx . . $ OGRCoordinateTransformation#> poCT; |
| 182 | if (poSRS == nullptr) |
| 183 | { |
| 184 | CPLError( |
| 185 | CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 186 | "No SRS set on layer. Assuming it is long/lat on WGS84 ellipsoid"); |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | OGRSpatialReferencecxx . . $ OGRSpatialReference# oSRSWGS84cxx . . $ OGRSpatialReference#OGRSpatialReference(85c52e162fed56f9).; |
| 191 | oSRSWGS84.SetWellKnownGeogCScxx . . $ OGRSpatialReference#SetWellKnownGeogCS(5c4306d8553b3696).("WGS84"); |
| 192 | oSRSWGS84.SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(OAMS_TRADITIONAL_GIS_ORDER); |
| 193 | const char *const apszOptions[] = { |
| 194 | "IGNORE_DATA_AXIS_TO_SRS_AXIS_MAPPING=YES", nullptr}; |
| 195 | if (!poSRS->IsSamecxx . . $ OGRSpatialReference#IsSame(237d09acedc929c6).(&oSRSWGS84, apszOptions)) |
| 196 | { |
| 197 | poCT.reset(OGRCreateCoordinateTransformationcxx . . $ OGRCreateCoordinateTransformation(2d3c2de25cb16c6e).(poSRS, &oSRSWGS84)); |
| 198 | if (poCT == nullptr) |
| 199 | { |
| 200 | CPLError( |
| 201 | CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 202 | "Failed to create coordinate transformation between the " |
| 203 | "input coordinate system and WGS84."); |
| 204 | |
| 205 | return nullptr; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | const char *pszRS = CSLFetchNameValue(papszOptions, "RS"); |
| 211 | if (pszRS) |
| 212 | { |
| 213 | m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. = CPLTestBool(pszRS); |
| 214 | } |
| 215 | |
| 216 | CPLStringList aosOptions(papszOptions); |
| 217 | |
| 218 | double dfXYResolution = OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.; |
| 219 | double dfZResolution = OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.; |
| 220 | if (const char *pszCoordPrecision = |
| 221 | CSLFetchNameValue(papszOptions, "COORDINATE_PRECISION")) |
| 222 | { |
| 223 | dfXYResolution = stdcxx . . $ std/::pow(10.0, -CPLAtof(pszCoordPrecision)); |
| 224 | dfZResolution = dfXYResolution; |
| 225 | } |
| 226 | else if (poSrcGeomFieldDefn) |
| 227 | { |
| 228 | const auto &oCoordPrec = poSrcGeomFieldDefn->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).(); |
| 229 | OGRSpatialReferencecxx . . $ OGRSpatialReference# oSRSWGS84cxx . . $ OGRSpatialReference#OGRSpatialReference(85c52e162fed56f9).; |
| 230 | oSRSWGS84.SetWellKnownGeogCScxx . . $ OGRSpatialReference#SetWellKnownGeogCS(5c4306d8553b3696).("WGS84"); |
| 231 | const auto oCoordPrecWGS84 = |
| 232 | oCoordPrec.ConvertToOtherSRScxx . . $ OGRGeomCoordinatePrecision#ConvertToOtherSRS(f28e1c7fc24b7047).(poSRS, &oSRSWGS84); |
| 233 | |
| 234 | if (oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. != OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.) |
| 235 | { |
| 236 | dfXYResolution = oCoordPrecWGS84.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution.; |
| 237 | |
| 238 | aosOptions.SetNameValue( |
| 239 | "XY_COORD_PRECISION", |
| 240 | CPLSPrintf("%d", |
| 241 | OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::ResolutionToPrecisioncxx . . $ OGRGeomCoordinatePrecision#ResolutionToPrecision(620b9ac44d2573a6).( |
| 242 | dfXYResolution))); |
| 243 | } |
| 244 | if (oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. != OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.) |
| 245 | { |
| 246 | dfZResolution = oCoordPrecWGS84.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution.; |
| 247 | |
| 248 | aosOptions.SetNameValue( |
| 249 | "Z_COORD_PRECISION", |
| 250 | CPLSPrintf("%d", |
| 251 | OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::ResolutionToPrecisioncxx . . $ OGRGeomCoordinatePrecision#ResolutionToPrecision(620b9ac44d2573a6).( |
| 252 | dfZResolution))); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..emplace_back(stdcxx . . $ std/::make_unique<OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#>( |
| 257 | this, pszNameIn, aosOptions.List(), stdcxx . . $ std/::move(poCT))); |
| 258 | |
| 259 | auto poLayer = m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..back().get(); |
| 260 | if (poLayer->GetGeomTypecxx . . $ OGRLayer#GetGeomType(5a40c54c5ff210ce).() != wkbNone && |
| 261 | dfXYResolution != OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.) |
| 262 | { |
| 263 | auto poGeomFieldDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0); |
| 264 | OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision# oCoordPrec( |
| 265 | poGeomFieldDefn->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).()); |
| 266 | oCoordPrec.dfXYResolutioncxx . . $ OGRGeomCoordinatePrecision#dfXYResolution. = dfXYResolution; |
| 267 | poGeomFieldDefn->SetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#SetCoordinatePrecision(a66dcf8fa4d01368).(oCoordPrec); |
| 268 | } |
| 269 | |
| 270 | if (poLayer->GetGeomTypecxx . . $ OGRLayer#GetGeomType(5a40c54c5ff210ce).() != wkbNone && |
| 271 | dfZResolution != OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision#::UNKNOWNcxx . . $ OGRGeomCoordinatePrecision#UNKNOWN.) |
| 272 | { |
| 273 | auto poGeomFieldDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0); |
| 274 | OGRGeomCoordinatePrecisioncxx . . $ OGRGeomCoordinatePrecision# oCoordPrec( |
| 275 | poGeomFieldDefn->GetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#GetCoordinatePrecision(4cbff8bea018030e).()); |
| 276 | oCoordPrec.dfZResolutioncxx . . $ OGRGeomCoordinatePrecision#dfZResolution. = dfZResolution; |
| 277 | poGeomFieldDefn->SetCoordinatePrecisioncxx . . $ OGRGeomFieldDefn#SetCoordinatePrecision(a66dcf8fa4d01368).(oCoordPrec); |
| 278 | } |
| 279 | |
| 280 | return poLayer; |
| 281 | } |
| 282 | |
| 283 | /************************************************************************/ |
| 284 | /* TestCapability() */ |
| 285 | /************************************************************************/ |
| 286 | |
| 287 | int OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::TestCapabilitycxx . . $ OGRGeoJSONSeqDataSource#TestCapability(78f035161ffa9fe2).(const char *pszCap) const |
| 288 | { |
| 289 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCCreateLayercxx . . $ `ogr/ogr_core.h:1040:9`!)) |
| 290 | return eAccesscxx . . $ GDALDataset#eAccess. == GA_Update; |
| 291 | |
| 292 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 293 | } |
| 294 | |
| 295 | /************************************************************************/ |
| 296 | /* OGRGeoJSONSeqLayer() */ |
| 297 | /************************************************************************/ |
| 298 | |
| 299 | OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#OGRGeoJSONSeqLayer(e2d4682bdc62fb6a).(OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS, |
| 300 | const char *pszName) |
| 301 | : m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.(poDS) |
| 302 | { |
| 303 | SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(pszName); |
| 304 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn. = new OGRFeatureDefncxx . . $ OGRFeatureDefn#(pszName); |
| 305 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 306 | |
| 307 | OGRSpatialReferencecxx . . $ OGRSpatialReference# *poSRSWGS84 = new OGRSpatialReferencecxx . . $ OGRSpatialReference#OGRSpatialReference(85c52e162fed56f9).(); |
| 308 | poSRSWGS84->SetWellKnownGeogCScxx . . $ OGRSpatialReference#SetWellKnownGeogCS(5c4306d8553b3696).("WGS84"); |
| 309 | poSRSWGS84->SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(OAMS_TRADITIONAL_GIS_ORDER); |
| 310 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSRSWGS84); |
| 311 | poSRSWGS84->Releasecxx . . $ OGRSpatialReference#Release(49f6e7a06ebc5aa8).(); |
| 312 | |
| 313 | const double dfTmp = |
| 314 | CPLAtof(CPLGetConfigOption("OGR_GEOJSON_MAX_OBJ_SIZE", "200")); |
| 315 | m_nMaxObjectSizecxx . . $ OGRGeoJSONSeqLayer#m_nMaxObjectSize. = dfTmp > 0 ? static_cast<size_t>(dfTmp * 1024 * 1024) : 0; |
| 316 | } |
| 317 | |
| 318 | /************************************************************************/ |
| 319 | /* OGRGeoJSONSeqLayer() */ |
| 320 | /************************************************************************/ |
| 321 | |
| 322 | // Write-only constructor |
| 323 | OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#OGRGeoJSONSeqLayer(18deb1c4a1a083a).( |
| 324 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS, const char *pszName, |
| 325 | CSLConstListcxx . . $ CSLConstList# papszOptions, |
| 326 | stdcxx . . $ std/::unique_ptr<OGRCoordinateTransformationcxx . . $ OGRCoordinateTransformation#> &&poCT) |
| 327 | : m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.(poDS), m_bWriteOnlyLayercxx . . $ OGRGeoJSONSeqLayer#m_bWriteOnlyLayer.(true) |
| 328 | { |
| 329 | m_bLayerDefnEstablishedcxx . . $ OGRGeoJSONSeqLayer#m_bLayerDefnEstablished. = true; |
| 330 | |
| 331 | SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(pszName); |
| 332 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn. = new OGRFeatureDefncxx . . $ OGRFeatureDefn#(pszName); |
| 333 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 334 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).( |
| 335 | OGRSpatialReferencecxx . . $ OGRSpatialReference#::GetWGS84SRScxx . . $ OGRSpatialReference#GetWGS84SRS(447f5c7241f58050).()); |
| 336 | m_poCTcxx . . $ OGRGeoJSONSeqLayer#m_poCT. = stdcxx . . $ std/::move(poCT); |
| 337 | |
| 338 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..bWriteBBOXcxx . . $ OGRGeoJSONWriteOptions#bWriteBBOX. = |
| 339 | CPLTestBool(CSLFetchNameValueDef(papszOptions, "WRITE_BBOX", "FALSE")); |
| 340 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..SetRFC7946Settingscxx . . $ OGRGeoJSONWriteOptions#SetRFC7946Settings(49f6e7a06ebc5aa8).(); |
| 341 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..SetIDOptionscxx . . $ OGRGeoJSONWriteOptions#SetIDOptions(ac4b840ac9fbb56d).(papszOptions); |
| 342 | |
| 343 | const char *pszCoordPrecision = |
| 344 | CSLFetchNameValue(papszOptions, "COORDINATE_PRECISION"); |
| 345 | if (pszCoordPrecision) |
| 346 | { |
| 347 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..nXYCoordPrecisioncxx . . $ OGRGeoJSONWriteOptions#nXYCoordPrecision. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszCoordPrecision); |
| 348 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..nZCoordPrecisioncxx . . $ OGRGeoJSONWriteOptions#nZCoordPrecision. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszCoordPrecision); |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..nXYCoordPrecisioncxx . . $ OGRGeoJSONWriteOptions#nXYCoordPrecision. = |
| 353 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(CSLFetchNameValueDef(papszOptions, "XY_COORD_PRECISION", "7")); |
| 354 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..nZCoordPrecisioncxx . . $ OGRGeoJSONWriteOptions#nZCoordPrecision. = |
| 355 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(CSLFetchNameValueDef(papszOptions, "Z_COORD_PRECISION", "3")); |
| 356 | } |
| 357 | |
| 358 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..nSignificantFigurescxx . . $ OGRGeoJSONWriteOptions#nSignificantFigures. = |
| 359 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(CSLFetchNameValueDef(papszOptions, "SIGNIFICANT_FIGURES", "-1")); |
| 360 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..bAllowNonFiniteValuescxx . . $ OGRGeoJSONWriteOptions#bAllowNonFiniteValues. = CPLTestBool( |
| 361 | CSLFetchNameValueDef(papszOptions, "WRITE_NON_FINITE_VALUES", "FALSE")); |
| 362 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions..bAutodetectJsonStringscxx . . $ OGRGeoJSONWriteOptions#bAutodetectJsonStrings. = CPLTestBool( |
| 363 | CSLFetchNameValueDef(papszOptions, "AUTODETECT_JSON_STRINGS", "TRUE")); |
| 364 | } |
| 365 | |
| 366 | /************************************************************************/ |
| 367 | /* ~OGRGeoJSONSeqLayer() */ |
| 368 | /************************************************************************/ |
| 369 | |
| 370 | OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::~cxx . . $ OGRGeoJSONSeqLayer#`~OGRGeoJSONSeqLayer`(ced63f7c635d850d).OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#() |
| 371 | { |
| 372 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->Releasecxx . . $ OGRFeatureDefn#Release(49f6e7a06ebc5aa8).(); |
| 373 | } |
| 374 | |
| 375 | /************************************************************************/ |
| 376 | /* GetLayerDefn() */ |
| 377 | /************************************************************************/ |
| 378 | |
| 379 | const OGRFeatureDefncxx . . $ OGRFeatureDefn# *OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::GetLayerDefncxx . . $ OGRGeoJSONSeqLayer#GetLayerDefn(448b209f43d15bcc).() const |
| 380 | { |
| 381 | if (!m_bLayerDefnEstablishedcxx . . $ OGRGeoJSONSeqLayer#m_bLayerDefnEstablished.) |
| 382 | { |
| 383 | const_cast<OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer# *>(this)->Initcxx . . $ OGRGeoJSONSeqLayer#Init(f2cb034b043a1ce9).( |
| 384 | /* bLooseIdentification = */ false, |
| 385 | /* bEstablishLayerDefn = */ true); |
| 386 | } |
| 387 | return m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.; |
| 388 | } |
| 389 | |
| 390 | /************************************************************************/ |
| 391 | /* Init() */ |
| 392 | /************************************************************************/ |
| 393 | |
| 394 | bool OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::Initcxx . . $ OGRGeoJSONSeqLayer#Init(f2cb034b043a1ce9).(bool bLooseIdentification, |
| 395 | bool bEstablishLayerDefn) |
| 396 | { |
| 397 | if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(m_poDS->GetDescription(), "/vsimem/") || |
| 398 | !STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(m_poDS->GetDescription(), "/vsi")) |
| 399 | { |
| 400 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp., 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!); |
| 401 | m_nFileSizecxx . . $ OGRGeoJSONSeqLayer#m_nFileSize. = VSIFTellL(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.); |
| 402 | } |
| 403 | |
| 404 | // Set m_bLayerDefnEstablished = true early to avoid infinite recursive |
| 405 | // calls. |
| 406 | if (bEstablishLayerDefn) |
| 407 | m_bLayerDefnEstablishedcxx . . $ OGRGeoJSONSeqLayer#m_bLayerDefnEstablished. = true; |
| 408 | |
| 409 | ResetReadingcxx . . $ OGRGeoJSONSeqLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 410 | |
| 411 | stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::string, int> oMapFieldNameToIdxcxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 412 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRFieldDefncxx . . $ OGRFieldDefn#>> apoFieldDefn; |
| 413 | gdalcxx . . $ gdal/::DirectedAcyclicGraphcxx . . $ gdal/DirectedAcyclicGraph#<int, stdcxx . . $ std/::string> dagcxx . . $ gdal/DirectedAcyclicGraph#DirectedAcyclicGraph(49f6e7a06ebc5aa8).; |
| 414 | bool bOK = false; |
| 415 | |
| 416 | while (true) |
| 417 | { |
| 418 | auto poObject = GetNextObjectcxx . . $ OGRGeoJSONSeqLayer#GetNextObject(a85131c35b0089d).(bLooseIdentification); |
| 419 | if (!poObject) |
| 420 | break; |
| 421 | const auto eObjectType = OGRGeoJSONGetTypecxx . . $ OGRGeoJSONGetType(8f348bce9e630dca).(poObject); |
| 422 | if (bEstablishLayerDefn && eObjectType == GeoJSONObjectcxx . . $ GeoJSONObject#::eFeaturecxx . . $ GeoJSONObject#eFeature.) |
| 423 | { |
| 424 | m_oReadercxx . . $ OGRGeoJSONSeqLayer#m_oReader..GenerateFeatureDefncxx . . $ OGRGeoJSONBaseReader#GenerateFeatureDefn(ae3dc1480d9e23c7).(oMapFieldNameToIdx, apoFieldDefn, dag, |
| 425 | this, poObject); |
| 426 | } |
| 427 | json_object_put(poObject); |
| 428 | if (!bEstablishLayerDefn) |
| 429 | { |
| 430 | bOK = (eObjectType == GeoJSONObjectcxx . . $ GeoJSONObject#::eFeaturecxx . . $ GeoJSONObject#eFeature.); |
| 431 | break; |
| 432 | } |
| 433 | m_nTotalFeaturescxx . . $ OGRGeoJSONSeqLayer#m_nTotalFeatures.++; |
| 434 | } |
| 435 | |
| 436 | if (bEstablishLayerDefn) |
| 437 | { |
| 438 | // CPLDebug("GEOJSONSEQ", "Establish layer definition"); |
| 439 | |
| 440 | const auto sortedFields = dag.getTopologicalOrderingcxx . . $ gdal/DirectedAcyclicGraph#getTopologicalOrdering(71f49d351eab9123).(); |
| 441 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(sortedFields.size() == apoFieldDefn.size()); |
| 442 | for (int idx : sortedFields) |
| 443 | { |
| 444 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(apoFieldDefn[idx].get()); |
| 445 | } |
| 446 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->Sealcxx . . $ OGRFeatureDefn#Seal(b45ddcbc8423892c).(true); |
| 447 | m_oReadercxx . . $ OGRGeoJSONSeqLayer#m_oReader..FinalizeLayerDefncxx . . $ OGRGeoJSONBaseReader#FinalizeLayerDefn(2c8d638038c97519).(this, m_osFIDColumncxx . . $ OGRGeoJSONSeqLayer#m_osFIDColumn.); |
| 448 | } |
| 449 | |
| 450 | ResetReadingcxx . . $ OGRGeoJSONSeqLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 451 | |
| 452 | m_nFileSizecxx . . $ OGRGeoJSONSeqLayer#m_nFileSize. = 0; |
| 453 | m_nItercxx . . $ OGRGeoJSONSeqLayer#m_nIter. = 0; |
| 454 | |
| 455 | return bOK || m_nTotalFeaturescxx . . $ OGRGeoJSONSeqLayer#m_nTotalFeatures. > 0; |
| 456 | } |
| 457 | |
| 458 | /************************************************************************/ |
| 459 | /* ResetReading() */ |
| 460 | /************************************************************************/ |
| 461 | |
| 462 | void OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::ResetReadingcxx . . $ OGRGeoJSONSeqLayer#ResetReading(49f6e7a06ebc5aa8).() |
| 463 | { |
| 464 | if (!m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead. || |
| 465 | (m_bWriteOnlyLayercxx . . $ OGRGeoJSONSeqLayer#m_bWriteOnlyLayer. && m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..size() > 1)) |
| 466 | { |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bAtEOFcxx . . $ OGRGeoJSONSeqDataSource#m_bAtEOF. = false; |
| 471 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 472 | // Undocumented: for testing purposes only |
| 473 | const size_t nBufferSize = static_cast<size_t>(stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).( |
| 474 | 1, atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetConfigOption("OGR_GEOJSONSEQ_CHUNK_SIZE", "40960")))); |
| 475 | const size_t nBufferSizeValidated = |
| 476 | nBufferSize > static_cast<size_t>(100 * 1000 * 1000) |
| 477 | ? static_cast<size_t>(100 * 1000 * 1000) |
| 478 | : nBufferSize; |
| 479 | m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..resize(nBufferSizeValidated); |
| 480 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..clear(); |
| 481 | m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. = nBufferSizeValidated; |
| 482 | m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. = nBufferSizeValidated; |
| 483 | m_nNextFIDcxx . . $ OGRGeoJSONSeqLayer#m_nNextFID. = 0; |
| 484 | } |
| 485 | |
| 486 | /************************************************************************/ |
| 487 | /* GetNextObject() */ |
| 488 | /************************************************************************/ |
| 489 | |
| 490 | json_object *OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::GetNextObjectcxx . . $ OGRGeoJSONSeqLayer#GetNextObject(a85131c35b0089d).(bool bLooseIdentification) |
| 491 | { |
| 492 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..clear(); |
| 493 | while (true) |
| 494 | { |
| 495 | // If we read all the buffer, then reload it from file |
| 496 | if (m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. >= m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize.) |
| 497 | { |
| 498 | if (m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. < m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..size()) |
| 499 | { |
| 500 | return nullptr; |
| 501 | } |
| 502 | m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. = |
| 503 | VSIFReadL(&m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer.[0], 1, m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..size(), m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.); |
| 504 | m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. = 0; |
| 505 | if (VSIFTellL(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) == m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. && |
| 506 | m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. > 0) |
| 507 | { |
| 508 | m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. = (m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer.[0] == RScxx . . $ RS.); |
| 509 | if (m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated.) |
| 510 | { |
| 511 | m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer.++; |
| 512 | } |
| 513 | } |
| 514 | m_nItercxx . . $ OGRGeoJSONSeqLayer#m_nIter.++; |
| 515 | |
| 516 | if (m_nFileSizecxx . . $ OGRGeoJSONSeqLayer#m_nFileSize. > 0 && (m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. < m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..size() || |
| 517 | (m_nItercxx . . $ OGRGeoJSONSeqLayer#m_nIter. % 100) == 0)) |
| 518 | { |
| 519 | CPLDebug("GeoJSONSeq", "First pass: %.2f %%", |
| 520 | 100.0 * VSIFTellL(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) / m_nFileSizecxx . . $ OGRGeoJSONSeqLayer#m_nFileSize.); |
| 521 | } |
| 522 | if (m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. >= m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize.) |
| 523 | { |
| 524 | return nullptr; |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | // Find next feature separator in buffer |
| 529 | const size_t nNextSepPos = m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..find( |
| 530 | m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. ? RScxx . . $ RS. : '\n', m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer.); |
| 531 | if (nNextSepPos != stdcxx . . $ std/::string::npos) |
| 532 | { |
| 533 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..append(m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..data() + m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer., |
| 534 | nNextSepPos - m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer.); |
| 535 | m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. = nNextSepPos + 1; |
| 536 | } |
| 537 | else |
| 538 | { |
| 539 | // No separator ? then accumulate |
| 540 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..append(m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..data() + m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer., |
| 541 | m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. - m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer.); |
| 542 | if (m_nMaxObjectSizecxx . . $ OGRGeoJSONSeqLayer#m_nMaxObjectSize. > 0 && |
| 543 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..size() > m_nMaxObjectSizecxx . . $ OGRGeoJSONSeqLayer#m_nMaxObjectSize.) |
| 544 | { |
| 545 | CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 546 | "Too large feature. You may define the " |
| 547 | "OGR_GEOJSON_MAX_OBJ_SIZE configuration option to " |
| 548 | "a value in megabytes (larger than %u) to allow " |
| 549 | "for larger features, or 0 to remove any size limit.", |
| 550 | static_cast<unsigned>(m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..size() / 1024 / |
| 551 | 1024)); |
| 552 | return nullptr; |
| 553 | } |
| 554 | m_nPosInBuffercxx . . $ OGRGeoJSONSeqLayer#m_nPosInBuffer. = m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize.; |
| 555 | if (m_nBufferValidSizecxx . . $ OGRGeoJSONSeqLayer#m_nBufferValidSize. == m_osBuffercxx . . $ OGRGeoJSONSeqLayer#m_osBuffer..size()) |
| 556 | { |
| 557 | continue; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | while (!m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..empty() && |
| 562 | (m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..back() == '\r' || |
| 563 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..back() == '\n')) |
| 564 | { |
| 565 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..pop_back(); |
| 566 | } |
| 567 | if (!m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..empty()) |
| 568 | { |
| 569 | json_object *poObject = nullptr; |
| 570 | CPL_IGNORE_RET_VAL( |
| 571 | OGRJSonParsecxx . . $ OGRJSonParse(260f20870814049b).(m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..c_str(), &poObject)); |
| 572 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..clear(); |
| 573 | if (json_object_get_type(poObject) == json_type_object) |
| 574 | { |
| 575 | return poObject; |
| 576 | } |
| 577 | json_object_put(poObject); |
| 578 | if (bLooseIdentification) |
| 579 | { |
| 580 | return nullptr; |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | /************************************************************************/ |
| 587 | /* GetNextFeature() */ |
| 588 | /************************************************************************/ |
| 589 | |
| 590 | OGRFeaturecxx . . $ OGRFeature# *OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::GetNextFeaturecxx . . $ OGRGeoJSONSeqLayer#GetNextFeature(ec9eceddec1d9563).() |
| 591 | { |
| 592 | if (!m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead.) |
| 593 | { |
| 594 | return nullptr; |
| 595 | } |
| 596 | if (m_bWriteOnlyLayercxx . . $ OGRGeoJSONSeqLayer#m_bWriteOnlyLayer. && m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..size() > 1) |
| 597 | { |
| 598 | CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 599 | "GetNextFeature() not supported when appending a new layer"); |
| 600 | return nullptr; |
| 601 | } |
| 602 | |
| 603 | GetLayerDefncxx . . $ OGRGeoJSONSeqLayer#GetLayerDefn(448b209f43d15bcc).(); // force scan if not already done |
| 604 | while (true) |
| 605 | { |
| 606 | auto poObject = GetNextObjectcxx . . $ OGRGeoJSONSeqLayer#GetNextObject(a85131c35b0089d).(false); |
| 607 | if (!poObject) |
| 608 | return nullptr; |
| 609 | OGRFeaturecxx . . $ OGRFeature# *poFeature; |
| 610 | auto type = OGRGeoJSONGetTypecxx . . $ OGRGeoJSONGetType(8f348bce9e630dca).(poObject); |
| 611 | if (type == GeoJSONObjectcxx . . $ GeoJSONObject#::eFeaturecxx . . $ GeoJSONObject#eFeature.) |
| 612 | { |
| 613 | poFeature = m_oReadercxx . . $ OGRGeoJSONSeqLayer#m_oReader..ReadFeaturecxx . . $ OGRGeoJSONBaseReader#ReadFeature(c542662af19ed95a).(this, poObject, |
| 614 | m_osFeatureBuffercxx . . $ OGRGeoJSONSeqLayer#m_osFeatureBuffer..c_str()); |
| 615 | json_object_put(poObject); |
| 616 | } |
| 617 | else if (type == GeoJSONObjectcxx . . $ GeoJSONObject#::eFeatureCollectioncxx . . $ GeoJSONObject#eFeatureCollection. || |
| 618 | type == GeoJSONObjectcxx . . $ GeoJSONObject#::eUnknowncxx . . $ GeoJSONObject#eUnknown.) |
| 619 | { |
| 620 | json_object_put(poObject); |
| 621 | continue; |
| 622 | } |
| 623 | else |
| 624 | { |
| 625 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = |
| 626 | m_oReadercxx . . $ OGRGeoJSONSeqLayer#m_oReader..ReadGeometrycxx . . $ OGRGeoJSONBaseReader#ReadGeometry(1221286730db23f1).(poObject, GetSpatialRefcxx . . $ OGRLayer#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 627 | json_object_put(poObject); |
| 628 | if (!poGeom) |
| 629 | { |
| 630 | continue; |
| 631 | } |
| 632 | poFeature = new OGRFeaturecxx . . $ OGRFeature#OGRFeature(dc2636911e7adfe).(m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.); |
| 633 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 634 | } |
| 635 | |
| 636 | if (poFeature->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).() == OGRNullFIDcxx . . $ `ogr/ogr_core.h:848:9`!) |
| 637 | { |
| 638 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(m_nNextFIDcxx . . $ OGRGeoJSONSeqLayer#m_nNextFID.); |
| 639 | m_nNextFIDcxx . . $ OGRGeoJSONSeqLayer#m_nNextFID.++; |
| 640 | } |
| 641 | if ((m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr || |
| 642 | FilterGeometrycxx . . $ OGRLayer#FilterGeometry(fed901b2566802ff).(poFeature->GetGeomFieldRefcxx . . $ OGRFeature#GetGeomFieldRef(ea443ccec24c6360).(m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter.))) && |
| 643 | (m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr || m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery.->Evaluatecxx . . $ OGRFeatureQuery#Evaluate(2048609adab03aab).(poFeature))) |
| 644 | { |
| 645 | return poFeature; |
| 646 | } |
| 647 | delete poFeature; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | /************************************************************************/ |
| 652 | /* GetFeatureCount() */ |
| 653 | /************************************************************************/ |
| 654 | |
| 655 | GIntBigcxx . . $ GIntBig# OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::GetFeatureCountcxx . . $ OGRGeoJSONSeqLayer#GetFeatureCount(9ccc33c3ebad048d).(int bForce) |
| 656 | { |
| 657 | if (m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr && m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr) |
| 658 | { |
| 659 | GetLayerDefncxx . . $ OGRGeoJSONSeqLayer#GetLayerDefn(448b209f43d15bcc).(); // force scan if not already done |
| 660 | return m_nTotalFeaturescxx . . $ OGRGeoJSONSeqLayer#m_nTotalFeatures.; |
| 661 | } |
| 662 | return OGRLayercxx . . $ OGRLayer#::GetFeatureCountcxx . . $ OGRLayer#GetFeatureCount(9ccc33c3ebad048d).(bForce); |
| 663 | } |
| 664 | |
| 665 | /************************************************************************/ |
| 666 | /* TestCapability() */ |
| 667 | /************************************************************************/ |
| 668 | |
| 669 | int OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::TestCapabilitycxx . . $ OGRGeoJSONSeqLayer#TestCapability(78f035161ffa9fe2).(const char *pszCap) const |
| 670 | { |
| 671 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCStringsAsUTF8cxx . . $ `ogr/ogr_core.h:1016:9`!)) |
| 672 | return true; |
| 673 | if (m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr && m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr && |
| 674 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastFeatureCountcxx . . $ `ogr/ogr_core.h:983:9`!)) |
| 675 | { |
| 676 | return true; |
| 677 | } |
| 678 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCCreateFieldcxx . . $ `ogr/ogr_core.h:990:9`!) || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCSequentialWritecxx . . $ `ogr/ogr_core.h:978:9`!)) |
| 679 | { |
| 680 | return m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->GetAccesscxx . . $ GDALDataset#GetAccess(104a36ce1815e5a3).() == GA_Update; |
| 681 | } |
| 682 | |
| 683 | return false; |
| 684 | } |
| 685 | |
| 686 | /************************************************************************/ |
| 687 | /* ICreateFeature() */ |
| 688 | /************************************************************************/ |
| 689 | |
| 690 | OGRErr OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::ICreateFeaturecxx . . $ OGRGeoJSONSeqLayer#ICreateFeature(2048609adab03aab).(OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 691 | { |
| 692 | if (m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->GetAccesscxx . . $ GDALDataset#GetAccess(104a36ce1815e5a3).() != GA_Update) |
| 693 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 694 | |
| 695 | if (!m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bAtEOFcxx . . $ OGRGeoJSONSeqDataSource#m_bAtEOF.) |
| 696 | { |
| 697 | m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bAtEOFcxx . . $ OGRGeoJSONSeqDataSource#m_bAtEOF. = true; |
| 698 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp., 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!); |
| 699 | } |
| 700 | |
| 701 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poFeatureToWrite; |
| 702 | if (m_poCTcxx . . $ OGRGeoJSONSeqLayer#m_poCT. != nullptr) |
| 703 | { |
| 704 | poFeatureToWrite.reset(new OGRFeaturecxx . . $ OGRFeature#OGRFeature(dc2636911e7adfe).(m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.)); |
| 705 | poFeatureToWrite->SetFromcxx . . $ OGRFeature#SetFrom(325443864107984b).(poFeature); |
| 706 | poFeatureToWrite->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(poFeature->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).()); |
| 707 | OGRGeometrycxx . . $ OGRGeometry# *poGeometry = poFeatureToWrite->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).(); |
| 708 | if (poGeometry) |
| 709 | { |
| 710 | const char *const apszOptions[] = {"WRAPDATELINE=YES", nullptr}; |
| 711 | OGRGeometrycxx . . $ OGRGeometry# *poNewGeom = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::transformWithOptionscxx . . $ OGRGeometryFactory#transformWithOptions(62b9b22baac743b).( |
| 712 | poGeometry, m_poCTcxx . . $ OGRGeoJSONSeqLayer#m_poCT..get(), const_cast<char **>(apszOptions), |
| 713 | m_oTransformCachecxx . . $ OGRGeoJSONSeqLayer#m_oTransformCache.); |
| 714 | if (poNewGeom == nullptr) |
| 715 | { |
| 716 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 717 | } |
| 718 | |
| 719 | OGREnvelope sEnvelope; |
| 720 | poNewGeom->getEnvelopecxx . . $ OGRGeometry#getEnvelope(e5217c1f2a4fd7ce).(&sEnvelope); |
| 721 | if (sEnvelope.MinX < -180.0 || sEnvelope.MaxX > 180.0 || |
| 722 | sEnvelope.MinY < -90.0 || sEnvelope.MaxY > 90.0) |
| 723 | { |
| 724 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 725 | "Geometry extent outside of " |
| 726 | "[-180.0,180.0]x[-90.0,90.0] bounds"); |
| 727 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 728 | } |
| 729 | |
| 730 | poFeatureToWrite->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poNewGeom); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | ++m_nTotalFeaturescxx . . $ OGRGeoJSONSeqLayer#m_nTotalFeatures.; |
| 735 | |
| 736 | json_object *poObj = OGRGeoJSONWriteFeaturecxx . . $ OGRGeoJSONWriteFeature(631f140fdd136df6).( |
| 737 | poFeatureToWrite.get() ? poFeatureToWrite.get() : poFeature, |
| 738 | m_oWriteOptionscxx . . $ OGRGeoJSONSeqLayer#m_oWriteOptions.); |
| 739 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nullptr != poObj); |
| 740 | |
| 741 | const char *pszJson = json_object_to_json_string_ext( |
| 742 | poObj, JSON_C_TO_STRING_PLAINcxx . . $ `<external>/5475662611906901010/json_object.h:43:9`! |
| 743 | #ifdef JSON_C_TO_STRING_NOSLASHESCAPEcxx . . $ `<external>/5475662611906901010/json_object.h:75:9`! |
| 744 | | JSON_C_TO_STRING_NOSLASHESCAPEcxx . . $ `<external>/5475662611906901010/json_object.h:75:9`! |
| 745 | #endif |
| 746 | ); |
| 747 | |
| 748 | char chEOL = '\n'; |
| 749 | OGRErr eErr = OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 750 | if ((m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. && |
| 751 | VSIFWriteL(&RScxx . . $ RS., 1, 1, m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) != 1) || |
| 752 | VSIFWriteL(pszJson, strlen(pszJson), 1, m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) != 1 || |
| 753 | VSIFWriteL(&chEOL, 1, 1, m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) != 1) |
| 754 | { |
| 755 | CPLError(CE_Failure, CPLE_FileIOcxx . . $ `port/cpl_error.h:112:9`!, "Cannot write feature"); |
| 756 | eErr = OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 757 | } |
| 758 | |
| 759 | json_object_put(poObj); |
| 760 | |
| 761 | return eErr; |
| 762 | } |
| 763 | |
| 764 | /************************************************************************/ |
| 765 | /* CreateField() */ |
| 766 | /************************************************************************/ |
| 767 | |
| 768 | OGRErr OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#::CreateFieldcxx . . $ OGRGeoJSONSeqLayer#CreateField(2cf5282e6e90de1e).(const OGRFieldDefncxx . . $ OGRFieldDefn# *poField, |
| 769 | int /* bApproxOK */) |
| 770 | { |
| 771 | if (m_poDScxx . . $ OGRGeoJSONSeqLayer#m_poDS.->GetAccesscxx . . $ GDALDataset#GetAccess(104a36ce1815e5a3).() != GA_Update) |
| 772 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 773 | m_poFeatureDefncxx . . $ OGRGeoJSONSeqLayer#m_poFeatureDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(poField); |
| 774 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 775 | } |
| 776 | |
| 777 | /************************************************************************/ |
| 778 | /* Open() */ |
| 779 | /************************************************************************/ |
| 780 | |
| 781 | bool OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::Opencxx . . $ OGRGeoJSONSeqDataSource#Open(f8566f36da6962f1).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo, |
| 782 | GeoJSONSourceTypecxx . . $ GeoJSONSourceType# nSrcType) |
| 783 | { |
| 784 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nullptr == m_fp); |
| 785 | |
| 786 | CPLString osLayerName("GeoJSONSeq"); |
| 787 | |
| 788 | const char *pszUnprefixedFilename = poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.; |
| 789 | if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poOpenInfo->pszFilename, "GeoJSONSeq:")) |
| 790 | { |
| 791 | pszUnprefixedFilename = poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename. + strlen("GeoJSONSeq:"); |
| 792 | } |
| 793 | |
| 794 | if (nSrcType == eGeoJSONSourceFilecxx . . $ eGeoJSONSourceFile.) |
| 795 | { |
| 796 | if (pszUnprefixedFilename != poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.) |
| 797 | { |
| 798 | osLayerName = CPLGetBasenameSafe(pszUnprefixedFilename); |
| 799 | m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = VSIFOpenL(pszUnprefixedFilename, |
| 800 | poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update ? "rb+" : "rb"); |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | osLayerName = CPLGetBasenameSafe(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.); |
| 805 | stdcxx . . $ std/::swap(m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp., poOpenInfo->fpLcxx . . $ GDALOpenInfo#fpL.); |
| 806 | } |
| 807 | } |
| 808 | else if (nSrcType == eGeoJSONSourceTextcxx . . $ eGeoJSONSourceText.) |
| 809 | { |
| 810 | if (poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update) |
| 811 | return false; |
| 812 | |
| 813 | m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile. = VSIMemGenerateHiddenFilename("geojsonseq"); |
| 814 | m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = VSIFileFromMemBuffer( |
| 815 | m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile..c_str(), |
| 816 | reinterpret_cast<GBytecxx . . $ GByte# *>(CPLStrdup(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.)), |
| 817 | strlen(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.), true); |
| 818 | } |
| 819 | else if (nSrcType == eGeoJSONSourceServicecxx . . $ eGeoJSONSourceService.) |
| 820 | { |
| 821 | if (poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update) |
| 822 | return false; |
| 823 | |
| 824 | char *pszStoredContent = |
| 825 | OGRGeoJSONDriverStealStoredContentcxx . . $ OGRGeoJSONDriverStealStoredContent(a8b8e32347182212).(pszUnprefixedFilename); |
| 826 | if (pszStoredContent) |
| 827 | { |
| 828 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszStoredContent, INVALID_CONTENT_FOR_JSON_LIKE) || |
| 829 | !GeoJSONSeqIsObjectcxx . . $ GeoJSONSeqIsObject(f1b58c377e804f9b).(pszStoredContent, poOpenInfo)) |
| 830 | { |
| 831 | OGRGeoJSONDriverStoreContentcxx . . $ OGRGeoJSONDriverStoreContent(611124a97efc52dd).(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename., |
| 832 | pszStoredContent); |
| 833 | return false; |
| 834 | } |
| 835 | else |
| 836 | { |
| 837 | m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile. = VSIMemGenerateHiddenFilename("geojsonseq"); |
| 838 | m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = VSIFileFromMemBuffer( |
| 839 | m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile..c_str(), |
| 840 | reinterpret_cast<GBytecxx . . $ GByte# *>(pszStoredContent), |
| 841 | strlen(pszStoredContent), true); |
| 842 | } |
| 843 | } |
| 844 | else |
| 845 | { |
| 846 | CPLHTTPResult *pResult = GeoJSONHTTPFetchWithContentTypeHeadercxx . . $ GeoJSONHTTPFetchWithContentTypeHeader(d64012b975ca0241).( |
| 847 | pszUnprefixedFilename, false, nullptr); |
| 848 | if (!pResult) |
| 849 | { |
| 850 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 851 | } |
| 852 | |
| 853 | m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile. = VSIMemGenerateHiddenFilename("geojsonseq"); |
| 854 | m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = VSIFileFromMemBuffer(m_osTmpFilecxx . . $ OGRGeoJSONSeqDataSource#m_osTmpFile..c_str(), pResult->pabyData, |
| 855 | pResult->nDataLen, true); |
| 856 | pResult->pabyData = nullptr; |
| 857 | pResult->nDataLen = 0; |
| 858 | CPLHTTPDestroyResult(pResult); |
| 859 | } |
| 860 | } |
| 861 | if (m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. == nullptr) |
| 862 | { |
| 863 | return false; |
| 864 | } |
| 865 | SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename.); |
| 866 | auto poLayer = new OGRGeoJSONSeqLayercxx . . $ OGRGeoJSONSeqLayer#OGRGeoJSONSeqLayer(e2d4682bdc62fb6a).(this, osLayerName.c_str()); |
| 867 | const bool bLooseIdentification = |
| 868 | nSrcType == eGeoJSONSourceServicecxx . . $ eGeoJSONSourceService. && |
| 869 | !STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poOpenInfo->pszFilename, "GeoJSONSeq:"); |
| 870 | if (bLooseIdentification) |
| 871 | { |
| 872 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 873 | } |
| 874 | const bool bEstablishLayerDefn = poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. != GA_Update; |
| 875 | auto ret = poLayer->Initcxx . . $ OGRGeoJSONSeqLayer#Init(f2cb034b043a1ce9).(bLooseIdentification, bEstablishLayerDefn); |
| 876 | if (bLooseIdentification) |
| 877 | { |
| 878 | CPLPopErrorHandler(); |
| 879 | CPLErrorReset(); |
| 880 | } |
| 881 | if (!ret) |
| 882 | { |
| 883 | delete poLayer; |
| 884 | return false; |
| 885 | } |
| 886 | m_apoLayerscxx . . $ OGRGeoJSONSeqDataSource#m_apoLayers..emplace_back(stdcxx . . $ std/::move(poLayer)); |
| 887 | eAccesscxx . . $ GDALDataset#eAccess. = poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess.; |
| 888 | return true; |
| 889 | } |
| 890 | |
| 891 | /************************************************************************/ |
| 892 | /* Create() */ |
| 893 | /************************************************************************/ |
| 894 | |
| 895 | bool OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#::Createcxx . . $ OGRGeoJSONSeqDataSource#Create(16997358fa22d8dc).(const char *pszName, |
| 896 | CSLConstListcxx . . $ CSLConstList# /* papszOptions */) |
| 897 | { |
| 898 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nullptr == m_fp); |
| 899 | |
| 900 | if (strcmp(pszName, "/dev/stdout") == 0) |
| 901 | pszName = "/vsistdout/"; |
| 902 | |
| 903 | /* -------------------------------------------------------------------- */ |
| 904 | /* Create the output file. */ |
| 905 | /* -------------------------------------------------------------------- */ |
| 906 | m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead. = |
| 907 | VSIFileManagercxx . . $ VSIFileManager#::GetHandlercxx . . $ VSIFileManager#GetHandler(3e3fedcbcf703caa).(pszName)->SupportsReadcxx . . $ VSIFilesystemHandler#SupportsRead(c5f7da30cbc0f4e9).(pszName) && |
| 908 | VSIFileManagercxx . . $ VSIFileManager#::GetHandlercxx . . $ VSIFileManager#GetHandler(3e3fedcbcf703caa).(pszName)->SupportsRandomWritecxx . . $ VSIFilesystemHandler#SupportsRandomWrite(e96b1cf346ae2c6).(pszName, |
| 909 | false); |
| 910 | m_bAtEOFcxx . . $ OGRGeoJSONSeqDataSource#m_bAtEOF. = !m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead.; |
| 911 | m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp. = VSIFOpenExL(pszName, m_bSupportsReadcxx . . $ OGRGeoJSONSeqDataSource#m_bSupportsRead. ? "wb+" : "wb", true); |
| 912 | if (nullptr == m_fpcxx . . $ OGRGeoJSONSeqDataSource#m_fp.) |
| 913 | { |
| 914 | CPLError(CE_Failure, CPLE_OpenFailedcxx . . $ `port/cpl_error.h:114:9`!, "Failed to create %s: %s", |
| 915 | pszName, VSIGetLastErrorMsg()); |
| 916 | return false; |
| 917 | } |
| 918 | |
| 919 | eAccesscxx . . $ GDALDataset#eAccess. = GA_Update; |
| 920 | |
| 921 | m_bIsRSSeparatedcxx . . $ OGRGeoJSONSeqDataSource#m_bIsRSSeparated. = EQUALcxx . . $ `port/cpl_port.h:532:9`!(CPLGetExtensionSafe(pszName).c_str(), "GEOJSONS"); |
| 922 | |
| 923 | return true; |
| 924 | } |
| 925 | |
| 926 | /************************************************************************/ |
| 927 | /* OGRGeoJSONSeqDriverIdentify() */ |
| 928 | /************************************************************************/ |
| 929 | |
| 930 | static int OGRGeoJSONSeqDriverIdentifyInternalcxx . . $ OGRGeoJSONSeqDriverIdentifyInternal(8d8ed2e18f0346ae).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo, |
| 931 | GeoJSONSourceTypecxx . . $ GeoJSONSourceType# &nSrcType) |
| 932 | { |
| 933 | nSrcType = GeoJSONSeqGetSourceTypecxx . . $ GeoJSONSeqGetSourceType(65c02b8a52088083).(poOpenInfo); |
| 934 | if (nSrcType == eGeoJSONSourceUnknowncxx . . $ eGeoJSONSourceUnknown.) |
| 935 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 936 | if (nSrcType == eGeoJSONSourceServicecxx . . $ eGeoJSONSourceService.) |
| 937 | { |
| 938 | if (poOpenInfo->IsSingleAllowedDrivercxx . . $ GDALOpenInfo#IsSingleAllowedDriver(7d4bdb1abc417636).("GeoJSONSeq")) |
| 939 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 940 | if (!STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poOpenInfo->pszFilename, "GeoJSONSeq:")) |
| 941 | { |
| 942 | return -1; |
| 943 | } |
| 944 | } |
| 945 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 946 | } |
| 947 | |
| 948 | /************************************************************************/ |
| 949 | /* OGRGeoJSONSeqDriverIdentify() */ |
| 950 | /************************************************************************/ |
| 951 | |
| 952 | static int OGRGeoJSONSeqDriverIdentifycxx . . $ OGRGeoJSONSeqDriverIdentify(48f695ac6b30cd84).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo) |
| 953 | { |
| 954 | GeoJSONSourceTypecxx . . $ GeoJSONSourceType# nSrcType; |
| 955 | return OGRGeoJSONSeqDriverIdentifyInternalcxx . . $ OGRGeoJSONSeqDriverIdentifyInternal(8d8ed2e18f0346ae).(poOpenInfo, nSrcType); |
| 956 | } |
| 957 | |
| 958 | /************************************************************************/ |
| 959 | /* Open() */ |
| 960 | /************************************************************************/ |
| 961 | |
| 962 | static GDALDatasetcxx . . $ GDALDataset# *OGRGeoJSONSeqDriverOpencxx . . $ OGRGeoJSONSeqDriverOpen(905b7966ba8c1649).(GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo) |
| 963 | { |
| 964 | GeoJSONSourceTypecxx . . $ GeoJSONSourceType# nSrcType; |
| 965 | if (OGRGeoJSONSeqDriverIdentifyInternalcxx . . $ OGRGeoJSONSeqDriverIdentifyInternal(8d8ed2e18f0346ae).(poOpenInfo, nSrcType) == FALSEcxx . . $ `port/cpl_port.h:1180:9`!) |
| 966 | { |
| 967 | return nullptr; |
| 968 | } |
| 969 | |
| 970 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS = new OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#(); |
| 971 | |
| 972 | if (!poDS->Opencxx . . $ OGRGeoJSONSeqDataSource#Open(f8566f36da6962f1).(poOpenInfo, nSrcType)) |
| 973 | { |
| 974 | delete poDS; |
| 975 | poDS = nullptr; |
| 976 | } |
| 977 | |
| 978 | return poDS; |
| 979 | } |
| 980 | |
| 981 | /************************************************************************/ |
| 982 | /* Create() */ |
| 983 | /************************************************************************/ |
| 984 | |
| 985 | static GDALDatasetcxx . . $ GDALDataset# * |
| 986 | OGRGeoJSONSeqDriverCreatecxx . . $ OGRGeoJSONSeqDriverCreate(2a509bdc7a404bec).(const char *pszName, int /* nBands */, |
| 987 | int /* nXSize */, int /* nYSize */, |
| 988 | GDALDataType /* eDT */, CSLConstListcxx . . $ CSLConstList# papszOptions) |
| 989 | { |
| 990 | OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource# *poDS = new OGRGeoJSONSeqDataSourcecxx . . $ OGRGeoJSONSeqDataSource#(); |
| 991 | |
| 992 | if (!poDS->Createcxx . . $ OGRGeoJSONSeqDataSource#Create(16997358fa22d8dc).(pszName, papszOptions)) |
| 993 | { |
| 994 | delete poDS; |
| 995 | poDS = nullptr; |
| 996 | } |
| 997 | |
| 998 | return poDS; |
| 999 | } |
| 1000 | |
| 1001 | /************************************************************************/ |
| 1002 | /* RegisterOGRGeoJSONSeq() */ |
| 1003 | /************************************************************************/ |
| 1004 | |
| 1005 | void RegisterOGRGeoJSONSeqcxx . . $ RegisterOGRGeoJSONSeq(49f6e7a06ebc5aa8).() |
| 1006 | { |
| 1007 | if (GDALGetDriverByName("GeoJSONSeq") != nullptr) |
| 1008 | return; |
| 1009 | |
| 1010 | GDALDrivercxx . . $ GDALDriver# *poDriver = new GDALDrivercxx . . $ GDALDriver#GDALDriver(49f6e7a06ebc5aa8).(); |
| 1011 | |
| 1012 | poDriver->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).("GeoJSONSeq"); |
| 1013 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_VECTORcxx . . $ `gcore/gdal.h:682:9`!, "YES"); |
| 1014 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_CREATE_LAYERcxx . . $ `gcore/gdal.h:691:9`!, "YES"); |
| 1015 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_CREATE_FIELDcxx . . $ `gcore/gdal.h:701:9`!, "YES"); |
| 1016 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_Z_GEOMETRIEScxx . . $ `gcore/gdal.h:780:9`!, "YES"); |
| 1017 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_LONGNAMEcxx . . $ `gcore/gdal.h:443:9`!, "GeoJSON Sequence"); |
| 1018 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_EXTENSIONScxx . . $ `gcore/gdal.h:461:9`!, "geojsonl geojsons"); |
| 1019 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_HELPTOPICcxx . . $ `gcore/gdal.h:446:9`!, |
| 1020 | "drivers/vector/geojsonseq.html"); |
| 1021 | |
| 1022 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).( |
| 1023 | GDAL_DS_LAYER_CREATIONOPTIONLISTcxx . . $ `gcore/gdal.h:1330:9`!, |
| 1024 | "<LayerCreationOptionList>" |
| 1025 | " <Option name='RS' type='boolean' description='whether to prefix " |
| 1026 | "records with RS=0x1e character' default='NO'/>" |
| 1027 | " <Option name='COORDINATE_PRECISION' type='int' description='Number " |
| 1028 | "of decimal for coordinates. Default is 7'/>" |
| 1029 | " <Option name='SIGNIFICANT_FIGURES' type='int' description='Number " |
| 1030 | "of significant figures for floating-point values' default='17'/>" |
| 1031 | " <Option name='ID_FIELD' type='string' description='Name of the " |
| 1032 | "source field that must be used as the id member of Feature features'/>" |
| 1033 | " <Option name='ID_TYPE' type='string-select' description='Type of " |
| 1034 | "the id member of Feature features'>" |
| 1035 | " <Value>AUTO</Value>" |
| 1036 | " <Value>String</Value>" |
| 1037 | " <Value>Integer</Value>" |
| 1038 | " </Option>" |
| 1039 | " <Option name='WRITE_BBOX' type='boolean' description='whether to " |
| 1040 | "write a bbox property with the bounding box of each geometry' " |
| 1041 | "default='NO'/>" |
| 1042 | "</LayerCreationOptionList>"); |
| 1043 | |
| 1044 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_VIRTUALIOcxx . . $ `gcore/gdal.h:674:9`!, "YES"); |
| 1045 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_CREATIONFIELDDATATYPEScxx . . $ `gcore/gdal.h:518:9`!, |
| 1046 | "Integer Integer64 Real String IntegerList " |
| 1047 | "Integer64List RealList StringList"); |
| 1048 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_CREATIONFIELDDATASUBTYPEScxx . . $ `gcore/gdal.h:523:9`!, "Boolean"); |
| 1049 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_SUPPORTED_SQL_DIALECTScxx . . $ `gcore/gdal.h:991:9`!, "OGRSQL SQLITE"); |
| 1050 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_HONOR_GEOM_COORDINATE_PRECISIONcxx . . $ `gcore/gdal.h:890:9`!, "YES"); |
| 1051 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_APPENDcxx . . $ `gcore/gdal.h:662:9`!, "YES"); |
| 1052 | |
| 1053 | poDriver->pfnOpencxx . . $ GDALDriver#pfnOpen. = OGRGeoJSONSeqDriverOpencxx . . $ OGRGeoJSONSeqDriverOpen(905b7966ba8c1649).; |
| 1054 | poDriver->pfnIdentifycxx . . $ GDALDriver#pfnIdentify. = OGRGeoJSONSeqDriverIdentifycxx . . $ OGRGeoJSONSeqDriverIdentify(48f695ac6b30cd84).; |
| 1055 | poDriver->pfnCreatecxx . . $ GDALDriver#pfnCreate. = OGRGeoJSONSeqDriverCreatecxx . . $ OGRGeoJSONSeqDriverCreate(2a509bdc7a404bec).; |
| 1056 | |
| 1057 | GetGDALDriverManager()->RegisterDrivercxx . . $ GDALDriverManager#RegisterDriver(ed1dabcc01594d64).(poDriver); |
| 1058 | } |