/usr/include/osgEarthFeatures/Feature is in libosgearth-dev 2.5.0+dfsg-2+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2008-2013 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHFEATURES_FEATURE_H
#define OSGEARTHFEATURES_FEATURE_H 1
#include <osgEarthFeatures/Common>
#include <osgEarthFeatures/FilterContext>
#include <osgEarthSymbology/Geometry>
#include <osgEarthSymbology/Style>
#include <osgEarth/GeoCommon>
#include <osgEarth/SpatialReference>
#include <osg/Array>
#include <osg/Shape>
#include <map>
#include <list>
namespace osgEarth { namespace Features
{
using namespace osgEarth;
using namespace osgEarth::Symbology;
class FilterContext;
/**
* Metadata and schema information for feature data.
*/
class OSGEARTHFEATURES_EXPORT FeatureProfile : public osg::Referenced
{
public:
FeatureProfile( const GeoExtent& extent );
virtual ~FeatureProfile() { }
/** Gets the spatial extents of the features in this profile. */
const GeoExtent& getExtent() const {
return _extent; }
/** Gets the spatial reference system of feature shapes in this class. */
const SpatialReference* getSRS() const {
return _extent.getSRS(); }
bool getTiled() const;
void setTiled(bool tiled);
int getFirstLevel() const;
void setFirstLevel(int firstLevel );
int getMaxLevel() const;
void setMaxLevel(int maxLevel);
const osgEarth::Profile* getProfile() const;
void setProfile( const osgEarth::Profile* profile );
protected:
osg::ref_ptr< const osgEarth::Profile > _profile;
GeoExtent _extent;
bool _tiled;
int _firstLevel;
int _maxLevel;
};
struct AttributeValueUnion
{
std::string stringValue;
double doubleValue;
int intValue;
bool boolValue;
//Whether the value is set. A value of false means the value is effectively NULL
bool set;
};
enum AttributeType
{
ATTRTYPE_UNSPECIFIED,
ATTRTYPE_STRING,
ATTRTYPE_INT,
ATTRTYPE_DOUBLE,
ATTRTYPE_BOOL
};
struct OSGEARTHFEATURES_EXPORT AttributeValue : public std::pair<AttributeType,AttributeValueUnion>
{
std::string getString() const;
double getDouble( double defaultValue =0.0 ) const;
int getInt( int defaultValue =0 ) const;
bool getBool( bool defaultValue =false ) const;
};
typedef std::map<std::string, AttributeValue> AttributeTable;
typedef unsigned long FeatureID;
/**
* Wraps a FeatureID in a referenced object.
*/
class RefFeatureID : public osg::Referenced
{
public:
RefFeatureID( FeatureID fid ) : _fid(fid) { }
virtual ~RefFeatureID() { }
operator FeatureID () const { return _fid; }
protected:
FeatureID _fid;
};
typedef std::map< std::string, AttributeType > FeatureSchema;
class Feature;
typedef std::list< osg::ref_ptr<Feature> > FeatureList;
/**
* Basic building block of vector feature data.
*/
class OSGEARTHFEATURES_EXPORT Feature : public osg::Object
{
public:
Feature( Geometry* geom, const SpatialReference* srs, const Style& style =Style(), FeatureID fid =0L );
/** Copy contructor */
Feature( const Feature& rhs, const osg::CopyOp& copyop =osg::CopyOp::DEEP_COPY_ALL );
virtual ~Feature() { }
META_Object( osgEarthFeatures, Feature );
public:
/**
* The unique ID of this feature (unique relative to its provider)
*/
FeatureID getFID() const;
/**
* The geometry in this feature.
*/
void setGeometry( Symbology::Geometry* geom );
Symbology::Geometry* getGeometry() { dirty(); return _geom.get(); }
const Symbology::Geometry* getGeometry() const { return _geom.get(); }
/**
* The spatial reference of the geometry in this feature.
*/
const SpatialReference* getSRS() const { return _srs.get(); }
void setSRS( const SpatialReference* srs );
/**
* Computes the bound of this feature in the specified SRS.
*/
bool getWorldBound( const SpatialReference* srs, osg::BoundingSphered& out_bound ) const;
/**
* Gets a polytope, in world coordinates (proj or ECEF) that bounds the
* geographic extents covered by this feature. This is useful for roughly
* intersecting the feature with the terrain graph.
*/
bool getWorldBoundingPolytope( const SpatialReference* srs, osg::Polytope& out_polytope ) const;
const AttributeTable& getAttrs() const { return _attrs; }
void set( const std::string& name, const std::string& value );
void set( const std::string& name, double value );
void set( const std::string& name, int value );
void set( const std::string& name, bool value );
/** Sets the attribute to NULL */
void setNull( const std::string& name );
void setNull( const std::string& name, AttributeType type );
bool hasAttr( const std::string& name ) const;
std::string getString( const std::string& name ) const;
double getDouble( const std::string& name, double defaultValue =0.0 ) const;
int getInt( const std::string& name, int defaultValue =0 ) const;
bool getBool( const std::string& name, bool defaultValue =false ) const;
/**
* Gets whether the attribute is set, meaning it is non-NULL
*/
bool isSet( const std::string& name ) const;
/** Embedded style. */
optional<Style>& style() { return _style; }
const optional<Style>& style() const { return _style; }
/** Geodetic interpolation method. */
optional<GeoInterpolation>& geoInterp() { dirty(); return _geoInterp; }
const optional<GeoInterpolation>& geoInterp() const { return _geoInterp; }
/** populates the variables of an expression with attribute values and evals the expression. */
double eval( NumericExpression& expr, FilterContext const* context=0L ) const;
/** populates the variables of an expression with attribute values and evals the expression. */
const std::string& eval( StringExpression& expr, FilterContext const* context=0L ) const;
public:
/** Gets a GeoJSON representation of this Feature */
std::string getGeoJSON();
/** Gets a FeatureList as a GeoJSON FeatureCollection */
static std::string featuresToGeoJSON( FeatureList& features);
public:
/**
* Transforms this Feature to the given SpatialReference
*/
void transform( const SpatialReference* srs );
protected:
Feature( FeatureID fid =0L );
FeatureID _fid;
osg::ref_ptr<Symbology::Geometry> _geom;
osg::ref_ptr<const SpatialReference> _srs;
AttributeTable _attrs;
optional<Style> _style;
optional<GeoInterpolation> _geoInterp;
GeoExtent _cachedExtent;
void dirty();
};
} } // namespace osgEarth::Features
#endif // OSGEARTHFEATURES_FEATURE_H
|