Debian Codegraph @

ogr/ogrsf_frmts/amigocloud/ogramigocloudresultlayer.cpp

raw symbols SCIP
1 /******************************************************************************
2 *
3 * Project: AmigoCloud Translator
4 * Purpose: Implements OGRAmigoCloudResultLayer class.
5 * Author: Victor Chernetsky, <victor at amigocloud dot com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2015, Victor Chernetsky, <victor at amigocloud dot com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13 #include "ogr_amigocloud.h"cxx . . $ `<file>/ogr/ogrsf_frmts/amigocloud/ogr_amigocloud.h`/
14
15 /************************************************************************/
16 /* OGRAmigoCloudResultLayer() */
17 /************************************************************************/
18
19 OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#OGRAmigoCloudResultLayer(ef445cb59f6da2bc).(
20 OGRAmigoCloudDataSourcecxx . . $ OGRAmigoCloudDataSource# *poDSIn, const char *pszRawQueryIn)
21 : OGRAmigoCloudLayercxx . . $ OGRAmigoCloudLayer#(poDSIn)
22 {
23 osBaseSQLcxx . . $ OGRAmigoCloudLayer#osBaseSQL. = pszRawQueryIn;
24 SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).("result");
25 poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature. = nullptr;
26 }
27
28 /************************************************************************/
29 /* ~OGRAmigoCloudResultLayer() */
30 /************************************************************************/
31
32 OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::~cxx . . $ OGRAmigoCloudResultLayer#`~OGRAmigoCloudResultLayer`(ced63f7c635d850d).OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#()
33
34 {
35 delete poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature.;
36 }
37
38 /************************************************************************/
39 /* GetLayerDefnInternal() */
40 /************************************************************************/
41
42 OGRFeatureDefncxx . . $ OGRFeatureDefn# *
43 OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::GetLayerDefnInternalcxx . . $ OGRAmigoCloudResultLayer#GetLayerDefnInternal(a338225d4e0bd9a9).(json_object *poObjIn)
44 {
45 if (poFeatureDefncxx . . $ OGRAmigoCloudLayer#poFeatureDefn. != nullptr)
46 return poFeatureDefncxx . . $ OGRAmigoCloudLayer#poFeatureDefn.;
47
48 EstablishLayerDefncxx . . $ OGRAmigoCloudLayer#EstablishLayerDefn(d16781c59d2ce9ee).("result", poObjIn);
49
50 return poFeatureDefncxx . . $ OGRAmigoCloudLayer#poFeatureDefn.;
51 }
52
53 /************************************************************************/
54 /* GetNextRawFeature() */
55 /************************************************************************/
56
57 OGRFeaturecxx . . $ OGRFeature# *OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::GetNextRawFeaturecxx . . $ OGRAmigoCloudResultLayer#GetNextRawFeature(ec9eceddec1d9563).()
58 {
59 if (poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature.)
60 {
61 OGRFeaturecxx . . $ OGRFeature# *poRet = poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature.;
62 poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature. = nullptr;
63 return poRet;
64 }
65 else
66 return OGRAmigoCloudLayercxx . . $ OGRAmigoCloudLayer#::GetNextRawFeaturecxx . . $ OGRAmigoCloudLayer#GetNextRawFeature(ec9eceddec1d9563).();
67 }
68
69 /************************************************************************/
70 /* IsOK() */
71 /************************************************************************/
72
73 int OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::IsOKcxx . . $ OGRAmigoCloudResultLayer#IsOK(b126dc7c1de90089).()
74 {
75 CPLErrorReset();
76 poFirstFeaturecxx . . $ OGRAmigoCloudResultLayer#poFirstFeature. = GetNextFeaturecxx . . $ OGRAmigoCloudLayer#GetNextFeature(ec9eceddec1d9563).();
77 return CPLGetLastErrorType() == 0;
78 }
79
80 /************************************************************************/
81 /* GetSRS_SQL() */
82 /************************************************************************/
83
84 CPLString OGRAmigoCloudResultLayercxx . . $ OGRAmigoCloudResultLayer#::GetSRS_SQLcxx . . $ OGRAmigoCloudResultLayer#GetSRS_SQL(a9d72c988d85d6d8).(const char *pszGeomCol)
85 {
86 CPLString osSQL;
87 CPLString osLimitedSQL;
88
89 size_t nPos = osBaseSQLcxx . . $ OGRAmigoCloudLayer#osBaseSQL..ifind(" LIMIT ");
90 if (nPos != stdcxx . . $ std/::string::npos)
91 {
92 osLimitedSQL = osBaseSQLcxx . . $ OGRAmigoCloudLayer#osBaseSQL.;
93 size_t nSize = osLimitedSQL.size();
94 for (size_t i = nPos + strlen(" LIMIT "); i < nSize; i++)
95 {
96 if (osLimitedSQL[i] == ' ' && osLimitedSQL[i - 1] == '0')
97 {
98 osLimitedSQL[i - 1] = '1';
99 break;
100 }
101 osLimitedSQL[i] = '0';
102 }
103 }
104 else
105 osLimitedSQL.Printf("%s LIMIT 1", osBaseSQLcxx . . $ OGRAmigoCloudLayer#osBaseSQL..c_str());
106
107 /* Assuming that the SRID of the first non-NULL geometry applies */
108 /* to geometries of all rows. */
109 osSQL.Printf("SELECT srid, srtext FROM spatial_ref_sys WHERE srid IN "
110 "(SELECT ST_SRID(%s) FROM (%s) ogr_subselect)",
111 OGRAMIGOCLOUDEscapeIdentifiercxx . . $ OGRAMIGOCLOUDEscapeIdentifier(a9d72c988d85d6d8).(pszGeomCol).c_str(),
112 osLimitedSQL.c_str());
113
114 return osSQL;
115 }