/* -*-c++-*- */ /* osgEarth - Geospatial SDK for OpenSceneGraph * Copyright 2020 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 */ #ifndef OSGEARTHSYMBOLOGY_INSTANCE_SYMBOL_H #define OSGEARTHSYMBOLOGY_INSTANCE_SYMBOL_H 1 #include #include #include #include #include #include namespace osgEarth { class IconSymbol; class ModelSymbol; namespace Util { class InstanceResource; } /** * Base class for symbols that represent an instance of an external resource * like an icon or a model and can be placed at a location. */ class OSGEARTH_EXPORT InstanceSymbol : public TaggableWithConfig { public: /** * Controls the placement of the instance. */ enum Placement { /** Places an instance at each feature point (default) */ PLACEMENT_VERTEX, /** Places one instance at the centroid of the feature. */ PLACEMENT_CENTROID, /** Places instances at regular intervals within/along the feature geometry, according to density. */ PLACEMENT_INTERVAL, /** Scatter instances randomly within/along feature, according to density. */ PLACEMENT_RANDOM }; public: InstanceSymbol(const InstanceSymbol& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); /** dtor */ virtual ~InstanceSymbol() { } /** URI of the instance to use for substitution. */ optional& url() { return _url; } const optional& url() const { return _url; } /** Name of the resource library to use with this symbol (optional) */ optional& library() { return _library; } const optional& library() const { return _library; } /** How to map feature geometry to instance placement. (default is PLACEMENT_CENTROID) */ optional& placement() { return _placement; } const optional& placement() const { return _placement; } /** For PLACEMENT_RANDOM/INTERVAL, the scattering density in instances per sqkm */ optional& density() { return _density; } const optional& density() const { return _density; } /** Model instance scale factor */ optional& scale() { return _scale; } const optional& scale() const { return _scale; } /** Seeding value for the randomizer */ optional& randomSeed() { return _randomSeed; } const optional& randomSeed() const { return _randomSeed; } /** URI alias map for embedded resources */ optional& uriAliasMap() { return _uriAliasMap; } const optional& uriAliasMap() const { return _uriAliasMap; } /** Expression that returns custom geometry as a GeoJSON string. You will typically use this as a script that takes the input geometry to dumps out a new geometry for model substitution. */ optional& script() { return _script; } const optional& script() const { return _script; } public: // conversions to built-in base classes, for convenience. const IconSymbol* asIcon() const; const ModelSymbol* asModel() const; public: virtual Config getConfig() const; virtual void mergeConfig( const Config& conf ); public: // internal /** Creates a new (empty) resource appropriate for this symbol */ virtual InstanceResource* createResource() const =0; protected: InstanceSymbol( const Config& conf =Config() ); protected: optional _url; optional _library; optional _scale; optional _placement; optional _density; optional _randomSeed; optional _uriAliasMap; optional _script; }; } // namespace osgEarth #endif // OSGEARTHSYMBOLOGY_MARKER_SYMBOL_H