VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tileFeature.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2015 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <features/simpleFeature.h>
13 
14 #include <vrfutil/objectCounter.h>
15 
16 namespace MAKVRinTerra
17 {
19  : public DtFeatureWrapper<DtFeature>
20  , public DtObjectDebugger<DtTileFeature>
21  {
22  public:
23  explicit DtTileFeature(
24  const DtFeatureGeometry& geom,
25  unsigned color = 0xFF00FF,
26  unsigned width = 2)
28  , myGeometry(geom)
29  , myColor(color)
30  , myWidth(width)
31  {
32  }
33 
34  explicit DtTileFeature(const DtTileFeature& f)
37  , myColor(f.myColor)
38  , myWidth(f.myWidth)
39  {
40  }
41 
43  {
44  return new DtTileFeature(*this);
45  }
46 
48  {
49  return myGeometry;
50  }
51 
53  {
54  f("color", myColor);
55  f("line width", myWidth);
56  }
57 
58  unsigned numberOfAttributes(const Key::String &k) const
59  {
60  if (k == "color")
61  return 1;
62 
63  if (k == "line width")
64  return 1;
65 
66  return 0;
67  }
68 
69  bool hasAttribute(const Key & k) const
70  {
71  if (k.index == 0)
72  {
73  if (k.name == "color")
74  return true;
75 
76  if (k.name == "line width")
77  return true;
78  }
79 
80  return false;
81  }
82 
83  boost::optional<Attribute> attribute(const Key & k) const
84  {
85  if (k.index == 0)
86  {
87  if (k.name == "color")
88  {
89  return boost::optional<Attribute>(myColor);
90  }
91 
92  if (k.name == "line width")
93  {
94  return boost::optional<Attribute>(myWidth);
95  }
96  }
97 
98  return boost::none_t();
99  }
100 
101  private:
103  const long long myColor;
104  const long long myWidth;
105  };
106 }
107 
const long long myWidth
Definition: tileFeature.h:104
const long long myColor
Definition: tileFeature.h:103
Key used to lookup attributes.
Definition: feature.h:66
bool hasAttribute(const Key &k) const
Check to see if this feature has an attribute of a specific type.
Definition: tileFeature.h:69
Wraps a feature object and makes sure all the callbacks are unhooked correctly In order to wrap a fea...
Definition: feature.h:299
unsigned numberOfAttributes(const Key::String &k) const
Number of attributes with a given key.
Definition: tileFeature.h:58
DtTileFeature * clone() const
Return a pointer to an object which represents the current feature.
Definition: tileFeature.h:42
Definition: tileFeature.h:18
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
Default on in debug, off in release.
Definition: objectCounter.h:31
const DtFeatureGeometry myGeometry
Definition: tileFeature.h:102
void forEachAttribute(ForEachFunction f) const
Calls the provided callback on each attribute.
Definition: tileFeature.h:52
String name
Definition: feature.h:99
unsigned index
Definition: feature.h:100
boost::function< void(const Key &, const Attribute &)> ForEachFunction
Callback used to iterating through attributes with ForEachAttribute.
Definition: feature.h:149
boost::optional< Attribute > attribute(const Key &k) const
Get attribute at a certain key.
Definition: tileFeature.h:83
DtTileFeature(const DtTileFeature &f)
Definition: tileFeature.h:34
DtFeatureGeometry geometry() const
Get the geometry associated with this feature.
Definition: tileFeature.h:47
static std::auto_ptr< DtFeature > CreateEmptyFeature()
Factory function for creating features with no data.
Case insensitive string.
Definition: feature.h:69
Represents a GIS feature.
Definition: feature.h:37
Represents a feature geometry.
Definition: featureGeometry.h:35
DtTileFeature(const DtFeatureGeometry &geom, unsigned color=0xFF00FF, unsigned width=2)
Definition: tileFeature.h:23

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)