PROJ C++ API
metadata.hpp
1 /******************************************************************************
2  *
3  * Project: PROJ
4  * Purpose: ISO19111:2018 implementation
5  * Author: Even Rouault <even dot rouault at spatialys dot com>
6  *
7  ******************************************************************************
8  * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  ****************************************************************************/
28 
29 #ifndef METADATA_HH_INCLUDED
30 #define METADATA_HH_INCLUDED
31 
32 #include <memory>
33 #include <string>
34 #include <vector>
35 
36 #include "io.hpp"
37 #include "util.hpp"
38 
39 NS_PROJ_START
40 
41 namespace common {
42 class UnitOfMeasure;
43 using UnitOfMeasurePtr = std::shared_ptr<UnitOfMeasure>;
44 using UnitOfMeasureNNPtr = util::nn<UnitOfMeasurePtr>;
45 class IdentifiedObject;
46 } // namespace common
47 
52 namespace metadata {
53 
54 // ---------------------------------------------------------------------------
55 
65 class Citation : public util::BaseObject {
66  public:
67  PROJ_DLL explicit Citation(const std::string &titleIn);
69  PROJ_DLL Citation();
70  PROJ_DLL Citation(const Citation &other);
71  PROJ_DLL ~Citation();
73 
74  PROJ_DLL const util::optional<std::string> &title() PROJ_CONST_DECL;
75 
76  protected:
77  PROJ_FRIEND_OPTIONAL(Citation);
78  Citation &operator=(const Citation &other);
79 
80  private:
81  PROJ_OPAQUE_PRIVATE_DATA
82 };
83 
84 // ---------------------------------------------------------------------------
85 
86 class GeographicExtent;
88 using GeographicExtentPtr = std::shared_ptr<GeographicExtent>;
90 using GeographicExtentNNPtr = util::nn<GeographicExtentPtr>;
91 
99  public:
101  PROJ_DLL ~GeographicExtent() override;
103 
104  // GeoAPI has a getInclusion() method. We assume that it is included for our
105  // use
106 
107  PROJ_DLL bool
108  isEquivalentTo(const util::IComparable *other,
109  util::IComparable::Criterion criterion =
110  util::IComparable::Criterion::STRICT) const override = 0;
111 
113  PROJ_DLL virtual bool
114  contains(const GeographicExtentNNPtr &other) const = 0;
115 
117  PROJ_DLL virtual bool
118  intersects(const GeographicExtentNNPtr &other) const = 0;
119 
121  PROJ_DLL virtual GeographicExtentPtr
122  intersection(const GeographicExtentNNPtr &other) const = 0;
123 
124  protected:
126 
127  private:
128  PROJ_OPAQUE_PRIVATE_DATA
129 };
130 
131 // ---------------------------------------------------------------------------
132 
135 using GeographicBoundingBoxPtr = std::shared_ptr<GeographicBoundingBox>;
137 using GeographicBoundingBoxNNPtr = util::nn<GeographicBoundingBoxPtr>;
138 
149  public:
151  PROJ_DLL ~GeographicBoundingBox() override;
153 
154  PROJ_DLL double westBoundLongitude() PROJ_CONST_DECL;
155  PROJ_DLL double southBoundLatitude() PROJ_CONST_DECL;
156  PROJ_DLL double eastBoundLongitude() PROJ_CONST_DECL;
157  PROJ_DLL double northBoundLatitude() PROJ_CONST_DECL;
158 
159  PROJ_DLL static GeographicBoundingBoxNNPtr
160  create(double west, double south, double east, double north);
161 
162  PROJ_DLL bool
163  isEquivalentTo(const util::IComparable *other,
164  util::IComparable::Criterion criterion =
165  util::IComparable::Criterion::STRICT) const override;
166 
167  PROJ_DLL bool contains(const GeographicExtentNNPtr &other) const override;
168 
169  PROJ_DLL bool intersects(const GeographicExtentNNPtr &other) const override;
170 
171  PROJ_DLL GeographicExtentPtr
172  intersection(const GeographicExtentNNPtr &other) const override;
173 
174  protected:
175  GeographicBoundingBox(double west, double south, double east, double north);
176  INLINED_MAKE_SHARED
177 
178  private:
179  PROJ_OPAQUE_PRIVATE_DATA
180 };
181 
182 // ---------------------------------------------------------------------------
183 
184 class TemporalExtent;
186 using TemporalExtentPtr = std::shared_ptr<TemporalExtent>;
188 using TemporalExtentNNPtr = util::nn<TemporalExtentPtr>;
189 
197  public:
199  PROJ_DLL ~TemporalExtent() override;
201 
202  PROJ_DLL const std::string &start() PROJ_CONST_DECL;
203  PROJ_DLL const std::string &stop() PROJ_CONST_DECL;
204 
205  PROJ_DLL static TemporalExtentNNPtr create(const std::string &start,
206  const std::string &stop);
207 
208  PROJ_DLL bool
209  isEquivalentTo(const util::IComparable *other,
210  util::IComparable::Criterion criterion =
211  util::IComparable::Criterion::STRICT) const override;
212 
213  PROJ_DLL bool contains(const TemporalExtentNNPtr &other) const;
214 
215  PROJ_DLL bool intersects(const TemporalExtentNNPtr &other) const;
216 
217  protected:
218  TemporalExtent(const std::string &start, const std::string &stop);
219  INLINED_MAKE_SHARED
220 
221  private:
222  PROJ_OPAQUE_PRIVATE_DATA
223 };
224 
225 // ---------------------------------------------------------------------------
226 
227 class VerticalExtent;
229 using VerticalExtentPtr = std::shared_ptr<VerticalExtent>;
231 using VerticalExtentNNPtr = util::nn<VerticalExtentPtr>;
232 
240  public:
242  PROJ_DLL ~VerticalExtent() override;
244 
245  PROJ_DLL double minimumValue() PROJ_CONST_DECL;
246  PROJ_DLL double maximumValue() PROJ_CONST_DECL;
247  PROJ_DLL common::UnitOfMeasureNNPtr &unit() PROJ_CONST_DECL;
248 
249  PROJ_DLL static VerticalExtentNNPtr
250  create(double minimumValue, double maximumValue,
251  const common::UnitOfMeasureNNPtr &unitIn);
252 
253  PROJ_DLL bool
254  isEquivalentTo(const util::IComparable *other,
255  util::IComparable::Criterion criterion =
256  util::IComparable::Criterion::STRICT) const override;
257 
258  PROJ_DLL bool contains(const VerticalExtentNNPtr &other) const;
259 
260  PROJ_DLL bool intersects(const VerticalExtentNNPtr &other) const;
261 
262  protected:
263  VerticalExtent(double minimumValue, double maximumValue,
264  const common::UnitOfMeasureNNPtr &unitIn);
265  INLINED_MAKE_SHARED
266 
267  private:
268  PROJ_OPAQUE_PRIVATE_DATA
269 };
270 
271 // ---------------------------------------------------------------------------
272 
273 class Extent;
275 using ExtentPtr = std::shared_ptr<Extent>;
277 using ExtentNNPtr = util::nn<ExtentPtr>;
278 
285 class Extent : public util::BaseObject, public util::IComparable {
286  public:
288  PROJ_DLL Extent(const Extent &other);
289  PROJ_DLL ~Extent() override;
291 
292  PROJ_DLL const util::optional<std::string> &description() PROJ_CONST_DECL;
293  PROJ_DLL const std::vector<GeographicExtentNNPtr> &
294  geographicElements() PROJ_CONST_DECL;
295  PROJ_DLL const std::vector<TemporalExtentNNPtr> &
296  temporalElements() PROJ_CONST_DECL;
297  PROJ_DLL const std::vector<VerticalExtentNNPtr> &
298  verticalElements() PROJ_CONST_DECL;
299 
300  PROJ_DLL static ExtentNNPtr
301  create(const util::optional<std::string> &descriptionIn,
302  const std::vector<GeographicExtentNNPtr> &geographicElementsIn,
303  const std::vector<VerticalExtentNNPtr> &verticalElementsIn,
304  const std::vector<TemporalExtentNNPtr> &temporalElementsIn);
305 
306  PROJ_DLL static ExtentNNPtr
307  createFromBBOX(double west, double south, double east, double north,
308  const util::optional<std::string> &descriptionIn =
310 
311  PROJ_DLL bool
312  isEquivalentTo(const util::IComparable *other,
313  util::IComparable::Criterion criterion =
314  util::IComparable::Criterion::STRICT) const override;
315 
316  PROJ_DLL bool contains(const ExtentNNPtr &other) const;
317 
318  PROJ_DLL bool intersects(const ExtentNNPtr &other) const;
319 
320  PROJ_DLL ExtentPtr intersection(const ExtentNNPtr &other) const;
321 
322  PROJ_DLL static const ExtentNNPtr WORLD;
323 
324  protected:
325  Extent();
326  INLINED_MAKE_SHARED
327 
328  private:
329  PROJ_OPAQUE_PRIVATE_DATA
330  Extent &operator=(const Extent &other) = delete;
331 };
332 
333 // ---------------------------------------------------------------------------
334 
335 class Identifier;
337 using IdentifierPtr = std::shared_ptr<Identifier>;
339 using IdentifierNNPtr = util::nn<IdentifierPtr>;
340 
347  public:
349  PROJ_DLL Identifier(const Identifier &other);
350  PROJ_DLL ~Identifier() override;
352 
353  PROJ_DLL static IdentifierNNPtr
354  create(const std::string &codeIn = std::string(),
355  const util::PropertyMap &properties =
356  util::PropertyMap()); // throw(InvalidValueTypeException)
357 
358  PROJ_DLL static const std::string AUTHORITY_KEY;
359  PROJ_DLL static const std::string CODE_KEY;
360  PROJ_DLL static const std::string CODESPACE_KEY;
361  PROJ_DLL static const std::string VERSION_KEY;
362  PROJ_DLL static const std::string DESCRIPTION_KEY;
363  PROJ_DLL static const std::string URI_KEY;
364 
365  PROJ_DLL static const std::string EPSG;
366  PROJ_DLL static const std::string OGC;
367 
368  PROJ_DLL const util::optional<Citation> &authority() PROJ_CONST_DECL;
369  PROJ_DLL const std::string &code() PROJ_CONST_DECL;
370  PROJ_DLL const util::optional<std::string> &codeSpace() PROJ_CONST_DECL;
371  PROJ_DLL const util::optional<std::string> &version() PROJ_CONST_DECL;
372  PROJ_DLL const util::optional<std::string> &description() PROJ_CONST_DECL;
373  PROJ_DLL const util::optional<std::string> &uri() PROJ_CONST_DECL;
374 
375  PROJ_DLL static bool isEquivalentName(const char *a, const std::string &b);
376 
377  PROJ_DLL static bool isEquivalentName(const std::string &a,
378  const std::string &b);
379 
380  PROJ_PRIVATE :
382  static std::string
383  canonicalizeName(const std::string &str);
384 
385  void _exportToWKT(io::WKTFormatter *formatter)
386  const override; // throw(io::FormattingException)
387 
389 
390  protected:
391  explicit Identifier(const std::string &codeIn,
392  const util::PropertyMap &properties);
393 
394  PROJ_FRIEND_OPTIONAL(Identifier);
395  INLINED_MAKE_SHARED
396  Identifier &operator=(const Identifier &other) = delete;
397 
398  PROJ_FRIEND(common::IdentifiedObject);
399 
400  private:
401  PROJ_OPAQUE_PRIVATE_DATA
402 };
403 
404 // ---------------------------------------------------------------------------
405 
406 class PositionalAccuracy;
408 using PositionalAccuracyPtr = std::shared_ptr<PositionalAccuracy>;
411 
418 class PositionalAccuracy : public util::BaseObject {
419  public:
421  PROJ_DLL ~PositionalAccuracy() override;
423 
424  PROJ_DLL const std::string &value() PROJ_CONST_DECL;
425 
426  PROJ_DLL static PositionalAccuracyNNPtr create(const std::string &valueIn);
427 
428  protected:
429  explicit PositionalAccuracy(const std::string &valueIn);
430  INLINED_MAKE_SHARED
431 
432  private:
433  PROJ_OPAQUE_PRIVATE_DATA
434  PositionalAccuracy(const PositionalAccuracy &other) = delete;
435  PositionalAccuracy &operator=(const PositionalAccuracy &other) = delete;
436 };
437 
438 } // namespace metadata
439 
440 NS_PROJ_END
441 
442 #endif // METADATA_HH_INCLUDED
util::nn< UnitOfMeasurePtr > UnitOfMeasureNNPtr
Definition: common.hpp:54
static const std::string DESCRIPTION_KEY
Key to set the natural language description of the meaning of the code value of a metadata::Identifie...
Definition: metadata.hpp:362
Interface for an object that can be compared to another.
Definition: util.hpp:292
Value uniquely identifying an object within a namespace.
Definition: metadata.hpp:346
util::nn< VerticalExtentPtr > VerticalExtentNNPtr
Definition: metadata.hpp:231
std::shared_ptr< VerticalExtent > VerticalExtentPtr
Definition: metadata.hpp:229
Information about spatial, vertical, and temporal extent.
Definition: metadata.hpp:285
std::shared_ptr< PositionalAccuracy > PositionalAccuracyPtr
Definition: metadata.hpp:408
static const std::string CODESPACE_KEY
Key to set the organization responsible for definition and maintenance of the code of a metadata::Ide...
Definition: metadata.hpp:360
Vertical domain of dataset.
Definition: metadata.hpp:239
static const ExtentNNPtr WORLD
World extent.
Definition: metadata.hpp:322
static const std::string EPSG
EPSG codespace.
Definition: metadata.hpp:365
std::shared_ptr< Identifier > IdentifierPtr
Definition: metadata.hpp:337
util::nn< IdentifierPtr > IdentifierNNPtr
Definition: metadata.hpp:339
Time period covered by the content of the dataset.
Definition: metadata.hpp:196
std::shared_ptr< TemporalExtent > TemporalExtentPtr
Definition: metadata.hpp:186
static const std::string CODE_KEY
Key to set the code of a metadata::Identifier.
Definition: metadata.hpp:359
Criterion
Comparison criterion.
Definition: util.hpp:299
std::shared_ptr< Extent > ExtentPtr
Definition: io.hpp:56
Geographic position of the dataset.
Definition: metadata.hpp:148
util::nn< GeographicBoundingBoxPtr > GeographicBoundingBoxNNPtr
Definition: metadata.hpp:137
Accuracy of the position of features.
Definition: metadata.hpp:418
util::nn< TemporalExtentPtr > TemporalExtentNNPtr
Definition: metadata.hpp:188
std::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
Definition: common.hpp:52
Base interface for geographic area of the dataset.
Definition: metadata.hpp:98
Wrapper of a std::map<std::string, BaseObjectNNPtr>
Definition: util.hpp:410
Class that can be derived from, to emulate Java&#39;s Object behaviour.
Definition: util.hpp:268
Standardized resource reference.
Definition: metadata.hpp:65
static const std::string VERSION_KEY
Key to set the version identifier for the namespace of a metadata::Identifier.
Definition: metadata.hpp:361
util::nn< PositionalAccuracyPtr > PositionalAccuracyNNPtr
Definition: metadata.hpp:410
static const std::string OGC
OGC codespace.
Definition: metadata.hpp:366
static const std::string AUTHORITY_KEY
Key to set the authority citation of a metadata::Identifier.
Definition: metadata.hpp:358
util::nn< GeographicExtentPtr > GeographicExtentNNPtr
Definition: metadata.hpp:90
Interface for an object that can be exported to WKT.
Definition: io.hpp:423
std::shared_ptr< GeographicExtent > GeographicExtentPtr
Definition: metadata.hpp:88
std::shared_ptr< GeographicBoundingBox > GeographicBoundingBoxPtr
Definition: metadata.hpp:135
Loose transposition of std::optional available from C++17.
Definition: util.hpp:178
util::nn< ExtentPtr > ExtentNNPtr
Definition: io.hpp:57
static const std::string URI_KEY
Key to set the URI of a metadata::Identifier.
Definition: metadata.hpp:363