ISpatialQueryDescriptor.hpp
1 #ifndef DM_ISPATIAL_QUERY_DESCRIPTOR_HPP_INCLUDED
2 #define DM_ISPATIAL_QUERY_DESCRIPTOR_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 #include "DM/config.hpp"
9 #include "DM/Handle.hpp"
10 #include "DM/ObjectBase.hpp"
11 #include "DM/IKnnQueryDescriptor.hpp"
12 #include "DM/IGeometry.hpp"
13 #include "DM/AutoLink.hpp" //enable autolink
14 
15 DM_NAMESPACE_BEGIN
16 
17 struct SortOrder {
18  enum Type {
19  unsorted, ///< results are in unspecified order
20  asc2d, ///< results are sorted ascending by 2d distance from query position
21  asc3d, ///< results are sorted ascending by 3d distance from query position
22  };
23 };
24 
25 /// enum for ordering the spatial search strategies
26 struct QueryOrder {
27  enum Type {
28  undefined, ///< initial value or in case only one query is defined
29  knnFirst, ///< do knn search first and 'filter' knn results with region query
30  regionQueryFirst ///< do region query first and 'sort/filter' results based on the defined knn search
31  };
32 };
33 
34 
35 class DM_API ISpatialQueryDescriptor : public ObjectBase
36 {
37 public:
38  /// \brief create a new spatial query descriptor object
39  /** In case of knn queries the point are always sorted by the distance in ascending order (2d distances in case of 2d knn query
40  and 3d distances in case of 3d knn query). Hence it is not necessary to speicify a sorting order parameter.
41  */
42  static ISpatialQueryDescriptor* New(KnnQueryDescriptorHandle knnQuery, SortOrder::Type sort = SortOrder::unsorted);
43  static ISpatialQueryDescriptor* New(GeometryHandle regionQuery, SortOrder::Type sort = SortOrder::unsorted);
44  /// perform knn search and than region query (\see QueryOrder::knnFirst)
45  static ISpatialQueryDescriptor* New(KnnQueryDescriptorHandle knnQuery, GeometryHandle regionQuery, SortOrder::Type sort = SortOrder::unsorted);
46  /// perform region query and than knn search (\see QueryOrder::regionQueryFirst)
47  static ISpatialQueryDescriptor* New(GeometryHandle regionQuery, KnnQueryDescriptorHandle knnQuery, SortOrder::Type sort = SortOrder::unsorted);
48 
49 protected:
50  virtual ~ISpatialQueryDescriptor() {}
51 
52 public:
53  virtual QueryOrder::Type order() const = 0;
54 
55  virtual bool hasKnnQuery() const = 0;
56  virtual KnnQueryDescriptorHandle getKnnQuery() const = 0;
57 
58  virtual bool hasRegionQuery() const = 0;
59  virtual GeometryHandle getRegionQuery() const = 0;
60 
61  virtual bool requiresSorting() const = 0;
62  virtual SortOrder::Type getSortingOrder() const = 0;
63 };
65 
66 DM_NAMESPACE_END
67 
68 #endif //DM_ISPATIAL_QUERY_DESCRIPTOR_HPP_INCLUDED