--- /dev/null
+#include <stdexcept>
+#include "terraintype.h"
+
+using namespace std;
+using namespace Msp;
+
+namespace R2C2 {
+
+TerrainType::TerrainType(const ArticleNumber &an):
+ ObjectType(an),
+ tile_size(1),
+ elevation_granularity(0.1)
+{ }
+
+const TerrainType::SurfaceType &TerrainType::get_surface_type(unsigned i) const
+{
+ if(i>=surface_types.size())
+ throw out_of_range("TerrainType::get_surface_type");
+ return surface_types[i];
+}
+
+
+TerrainType::SurfaceType::SurfaceType():
+ r(0.8),
+ g(0.8),
+ b(0.8)
+{ }
+
+
+TerrainType::Loader::Loader(TerrainType &tt):
+ DataFile::ObjectLoader<TerrainType>(tt)
+{
+ add("elevation_granularity", &TerrainType::elevation_granularity);
+ add("surface", &Loader::surface);
+ add("tile_size", &TerrainType::tile_size);
+}
+
+void TerrainType::Loader::surface()
+{
+ SurfaceType srf;
+ load_sub(srf);
+ obj.surface_types.push_back(srf);
+}
+
+
+TerrainType::SurfaceType::Loader::Loader(SurfaceType &st):
+ DataFile::ObjectLoader<SurfaceType>(st)
+{
+}
+
+} // namespace R2C2