Skip to content

Commit

Permalink
Add LandCover classes; add LandCoverLayer to core namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Feb 13, 2017
1 parent de15bee commit 187a54e
Show file tree
Hide file tree
Showing 6 changed files with 808 additions and 29 deletions.
31 changes: 2 additions & 29 deletions data/splat/splat_catalog.xml
@@ -1,42 +1,15 @@
<catalog name="Default" version="1">
<description>Default texture splatting catalog</description>
<classes>
<class name="cropland1">
<class name="cropland">
<image>cropland2.jpg</image>
</class>
<class name="cropland2">
<image>cropland5.jpg</image>
</class>
<class name="cropland3">
<image>cropland6.jpg</image>
</class>
<class name="cropland4">
<image>cropland6.jpg</image>
</class>
<class name="forest">
<image>forest5.jpg</image>
</class>
<class name="forest1">
<image>forest5.jpg</image>
</class>
<class name="forest2">
<image>forest6.jpg</image>
</class>
<class name="forest3">
<image>forest7.jpg</image>
</class>
<class name="forest4">
<image>forest8.jpg</image>
</class>
<class name="forest5">
<image>forest9.jpg</image>
</class>
<class name="grassland">
<image>grass5.jpg</image>
</class>
<class name="grassland2">
<image>grass6.jpg</image>
</class>
<class name="savanna">
<image>savanna1.jpg</image>
</class>
Expand All @@ -52,7 +25,7 @@
<scale>9.0</scale>
</detail>
</class>
<class name="mountain">
<class name="rock">
<image>rock_dark.jpg</image>
</class>
<class name="tundra">
Expand Down
4 changes: 4 additions & 0 deletions src/osgEarth/CMakeLists.txt
Expand Up @@ -106,6 +106,8 @@ SET(LIB_PUBLIC_HEADERS
IntersectionPicker
IOTypes
JsonUtils
LandCover
LandCoverLayer
Layer
LayerListener
Lighting
Expand Down Expand Up @@ -279,6 +281,8 @@ set(TARGET_SRC
IntersectionPicker.cpp
IOTypes.cpp
JsonUtils.cpp
LandCover.cpp
LandCoverLayer.cpp
Layer.cpp
Lighting.cpp
Locators.cpp
Expand Down
129 changes: 129 additions & 0 deletions src/osgEarth/LandCover
@@ -0,0 +1,129 @@
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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 OSGEARTH_LAND_COVER_H
#define OSGEARTH_LAND_COVER_H 1

#include <osgEarth/Config>
#include <vector>

namespace osgEarth
{
/**
* A single classification definition of land cover.
* For example, "forest" or "water".
* A set of these makes up a land cover dictionary.
*/
class OSGEARTH_EXPORT LandCoverClass : public osg::Object
{
public:
META_Object(osgEarth, LandCoverClass);

LandCoverClass();
LandCoverClass(const Config& conf);
LandCoverClass(const LandCoverClass& rhs, const osg::CopyOp& op);

public:
void fromConfig(const Config& conf);
Config getConfig() const;
};
typedef std::vector< osg::ref_ptr<LandCoverClass> > LandCoverClassVector;


/**
* A complete set of available land cover classes.
*/
class OSGEARTH_EXPORT LandCoverDictionary : public osg::Object
{
public:
META_Object(osgEarth, LandCoverDictionary);

LandCoverDictionary();
LandCoverDictionary(const LandCoverDictionary& rhs, const osg::CopyOp& op);

public:
LandCoverClassVector& getClasses() { return _landCoverClasses; }
const LandCoverClassVector& getClasses() const { return _landCoverClasses; }

public:
void fromConfig(const Config& conf);
Config getConfig() const;

private:
LandCoverClassVector _landCoverClasses;
};


/**
* Maps an integral value from a land cover data source to one of the
* land cover classes in the dictionary.
* For example, 42 --> "tundra".
*/
class OSGEARTH_EXPORT LandCoverValueMapping : public osg::Object
{
public:
META_Object(osgEarth, LandCoverValueMapping);

LandCoverValueMapping();
LandCoverValueMapping(const Config& conf);
LandCoverValueMapping(const LandCoverValueMapping& rhs, const osg::CopyOp& op);

public:
void setValue(int value) { _value = value; }
int getValue() const { return _value.get(); }

void setLandCoverClass(LandCoverClass* lcClass) { _lcClass = lcClass; }
const LandCoverClass* getLandCoverClass() const { return _lcClass.get(); }

void fromConfig(const Config&);
Config getConfig() const;

private:
optional<int> _value;
osg::ref_ptr<LandCoverClass> _lcClass;
};
typedef std::vector< osg::ref_ptr<LandCoverValueMapping> > LandCoverValueMappingVector;


/**
* Defines a particular data source for land cover data, and stores
* the set of mappings from the source's values to the dictionary's
* classes.
*/
class OSGEARTH_EXPORT LandCoverDataSource : public osg::Object
{
public:
META_Object(osgEarth, LandCoverDataSource);

LandCoverDataSource();
LandCoverDataSource(const Config& conf);
LandCoverDataSource(const LandCoverDataSource& rhs, const osg::CopyOp& op);

LandCoverValueMappingVector& getMappings() { return _valueMappings; }
const LandCoverValueMappingVector& getMappings() const { return _valueMappings; }

void fromConfig(const Config& conf);
Config getConfig() const;

private:
LandCoverValueMappingVector _valueMappings;
};

} // namespace osgEarth

#endif // OSGEARTH_LAND_COVER_H

0 comments on commit 187a54e

Please sign in to comment.