GDAL

ogrwarpedlayer.h
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Defines OGRWarpedLayer class
5 * Author: Even Rouault, even dot rouault at spatialys.com
6 *
7 ******************************************************************************
8 * Copyright (c) 2012-2014, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef OGRWARPEDLAYER_H_INCLUDED
14#define OGRWARPEDLAYER_H_INCLUDED
15
16#ifndef DOXYGEN_SKIP
17
18#include "ogrlayerdecorator.h"
19#include "ogrlayerwithtranslatefeature.h"
20
21#include <memory>
22
23#if defined(_MSC_VER)
24#pragma warning(push)
25// Silence warnings of the type warning C4250: 'OGRWarpedLayer': inherits 'OGRLayerDecorator::OGRLayerDecorator::GetMetadata' via dominance
26#pragma warning(disable : 4250)
27#endif
28
29/************************************************************************/
30/* OGRWarpedLayer */
31/************************************************************************/
32
33 class CPL_DLL OGRWarpedLayer final : public OGRLayerDecorator,
34 public OGRLayerWithTranslateFeature
35{
36 CPL_DISALLOW_COPY_ASSIGN(OGRWarpedLayer)
37
38 protected:
39 OGRFeatureDefn *m_poFeatureDefn = nullptr;
40 int m_iGeomField = 0;
41
42 OGRGeometryFactory::TransformWithOptionsCache m_transformCacheForward{};
43 OGRGeometryFactory::TransformWithOptionsCache m_transformCacheReverse{};
44 OGRCoordinateTransformation *m_poCT = nullptr;
45 OGRCoordinateTransformation *m_poReversedCT = nullptr; /* may be NULL */
46 OGRSpatialReference *m_poSRS = nullptr;
47
48 OGREnvelope sStaticEnvelope{};
49
50 static int ReprojectEnvelope(OGREnvelope *psEnvelope,
51 OGRCoordinateTransformation *poCT);
52
53 std::unique_ptr<OGRFeature>
54 SrcFeatureToWarpedFeature(std::unique_ptr<OGRFeature> poFeature);
55 std::unique_ptr<OGRFeature>
56 WarpedFeatureToSrcFeature(std::unique_ptr<OGRFeature> poFeature);
57
58 public:
59 OGRWarpedLayer(
60 OGRLayer *poDecoratedLayer, int iGeomField, int bTakeOwnership,
61 OGRCoordinateTransformation
62 *poCT, /* must NOT be NULL, ownership acquired by OGRWarpedLayer */
63 OGRCoordinateTransformation *
64 poReversedCT /* may be NULL, ownership acquired by OGRWarpedLayer */);
65 ~OGRWarpedLayer() override;
66
67 void TranslateFeature(
68 std::unique_ptr<OGRFeature> poSrcFeature,
69 std::vector<std::unique_ptr<OGRFeature>> &apoOutFeatures) override;
70
71 void SetExtent(double dfXMin, double dfYMin, double dfXMax, double dfYMax);
72
73 virtual OGRErr ISetSpatialFilter(int iGeomField,
74 const OGRGeometry *) override;
75
76 OGRFeature *GetNextFeature() override;
77 OGRFeature *GetFeature(GIntBig nFID) override;
78 OGRErr ISetFeature(OGRFeature *poFeature) override;
79 OGRErr ICreateFeature(OGRFeature *poFeature) override;
80 OGRErr IUpsertFeature(OGRFeature *poFeature) override;
81 OGRErr IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
82 const int *panUpdatedFieldsIdx,
83 int nUpdatedGeomFieldsCount,
84 const int *panUpdatedGeomFieldsIdx,
85 bool bUpdateStyleString) override;
86
87 const OGRFeatureDefn *GetLayerDefn() const override;
88
89 const OGRSpatialReference *GetSpatialRef() const override;
90
91 GIntBig GetFeatureCount(int bForce = TRUE) override;
92 OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
93 bool bForce = true) override;
94
95 int TestCapability(const char *) const override;
96
97 virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
98 CSLConstList papszOptions = nullptr) override;
99};
100
101#if defined(_MSC_VER)
102#pragma warning(pop)
103#endif
104
105#endif /* #ifndef DOXYGEN_SKIP */
106
107#endif // OGRWARPEDLAYER_H_INCLUDED
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition ogr_spatialref.h:772
OGREnvelope
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition ogr_feature.h:504
OGRFeature
A simple feature, including geometry and attributes.
Definition ogr_feature.h:934
OGRGeometryFactory::TransformWithOptionsCache
Opaque class used as argument to transformWithOptions()
Definition ogr_geometry.h:4282
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRLayer
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370