void MGRSGraticule::setUpDefaultStyles() { if (!options().gzdStyle().isSet()) { LineSymbol* line = options().gzdStyle()->getOrCreate<LineSymbol>(); line->stroke()->color() = Color::Gray; line->stroke()->width() = 1.0; line->tessellation() = 20; TextSymbol* text = options().gzdStyle()->getOrCreate<TextSymbol>(); text->fill()->color() = Color(Color::White, 0.3f); text->halo()->color() = Color(Color::Black, 0.2f); text->alignment() = TextSymbol::ALIGN_CENTER_CENTER; } if (!options().sqidStyle().isSet()) { LineSymbol* line = options().sqidStyle()->getOrCreate<LineSymbol>(); line->stroke()->color() = Color(Color::White, 0.5f); line->stroke()->stipplePattern() = 0x1111; TextSymbol* text = options().sqidStyle()->getOrCreate<TextSymbol>(); text->fill()->color() = Color(Color::White, 0.3f); text->halo()->color() = Color(Color::Black, 0.1f); text->alignment() = TextSymbol::ALIGN_CENTER_CENTER; } }
void compute() { //Tell the calculator about the new start/end points _profileCalculator->setStartEnd( GeoPoint(_mapNode->getMapSRS(), _start.x(), _start.y(), 0), GeoPoint(_mapNode->getMapSRS(), _end.x(), _end.y(), 0)); if (_featureNode.valid()) { _root->removeChild( _featureNode.get() ); _featureNode = 0; } LineString* line = new LineString(); line->push_back( _start ); line->push_back( _end ); Feature* feature = new Feature(line, _mapNode->getMapSRS()); feature->geoInterp() = GEOINTERP_GREAT_CIRCLE; //Define a style for the line Style style; LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>(); ls->stroke()->color() = Color::Yellow; ls->stroke()->width() = 2.0f; ls->tessellation() = 20; style.getOrCreate<AltitudeSymbol>()->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN; feature->style() = style; _featureNode = new FeatureNode( _mapNode, feature ); //Disable lighting _featureNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); _root->addChild( _featureNode.get() ); }
void KML_LineString::parseStyle( const Config& conf, KMLContext& cs, Style& style ) { KML_Geometry::parseStyle(conf, cs, style); // need a line symbol minimally LineSymbol* line = style.get<LineSymbol>(); if ( !line ) { line = style.getOrCreate<LineSymbol>(); line->stroke()->color() = osg::Vec4f(1,1,1,1); } if ( conf.value("tessellate") == "1" ) { line->tessellation() = 20; // KML default } }
void KML_LinearRing::parseStyle( xml_node<>* node, KMLContext& cs, Style& style ) { KML_Geometry::parseStyle(node, cs, style); // need a line symbol minimally LineSymbol* line = style.get<LineSymbol>(); if ( !line ) { line = style.getOrCreate<LineSymbol>(); line->stroke()->color() = osg::Vec4f(1,1,1,1); } if ( getValue(node, "tessellate") == "1" ) { line->tessellation() = 20; } }
Style buildStyle( const osg::Vec4 &color, float width ) { // Define a style for the feature data. Since we are going to render the // vectors as lines, configure the line symbolizer: Style style; LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>(); ls->stroke()->color() = color; ls->stroke()->width() = width; ls->tessellation() = 10; AltitudeSymbol* as = style.getOrCreate<AltitudeSymbol>(); as->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN; as->technique() = AltitudeSymbol::TECHNIQUE_SCENE; RenderSymbol* rs = style.getOrCreateSymbol<RenderSymbol>(); rs->depthOffset()->enabled() = true; rs->depthOffset()->minBias() = 1000; return style; }
void UTMGraticule::rebuild() { if (_root.valid() == false) return; osg::ref_ptr<const Map> map; if (!_map.lock(map)) return; // clear everything out _root->removeChildren( 0, _root->getNumChildren() ); // requires a geocentric map if ( !map->isGeocentric() ) { OE_WARN << LC << "Projected map mode is not yet supported" << std::endl; return; } const Profile* mapProfile = map->getProfile(); _profile = Profile::create( mapProfile->getSRS(), mapProfile->getExtent().xMin(), mapProfile->getExtent().yMin(), mapProfile->getExtent().xMax(), mapProfile->getExtent().yMax(), 8, 4 ); _featureProfile = new FeatureProfile(_profile->getSRS()); //todo: do this right.. osg::StateSet* set = this->getOrCreateStateSet(); GLUtils::setLighting(set, 0); set->setMode( GL_BLEND, 1 ); set->setMode( GL_CLIP_DISTANCE0, 1 ); // set up default options if the caller did not supply them if ( !options().gzdStyle().isSet() ) { options().gzdStyle() = Style(); LineSymbol* line = options().gzdStyle()->getOrCreate<LineSymbol>(); line->stroke()->color() = Color::Gray; line->stroke()->width() = 1.0; line->tessellation() = 20; TextSymbol* text = options().gzdStyle()->getOrCreate<TextSymbol>(); text->fill()->color() = Color(Color::White, 0.3f); text->halo()->color() = Color(Color::Black, 0.2f); text->alignment() = TextSymbol::ALIGN_CENTER_CENTER; } // initialize the UTM sector tables for this profile. _utmData.rebuild(_profile.get()); // now build the lateral tiles for the GZD level. for( UTMData::SectorTable::iterator i = _utmData.sectorTable().begin(); i != _utmData.sectorTable().end(); ++i ) { osg::Node* tile = _utmData.buildGZDTile(i->first, i->second, options().gzdStyle().get(), _featureProfile.get(), map.get()); if ( tile ) _root->addChild( tile ); } }
void UTMGraticule::init() { if ( !_mapNode.valid() ) { OE_WARN << LC << "Illegal NULL map node" << std::endl; return; } if ( !_mapNode->isGeocentric() ) { OE_WARN << LC << "Projected map mode is not yet supported" << std::endl; return; } // safely generate a unique ID for this graticule: _id = Registry::instance()->createUID(); { Threading::ScopedMutexLock lock( s_graticuleMutex ); s_graticuleRegistry[_id] = this; } const Profile* mapProfile = _mapNode->getMap()->getProfile(); _profile = Profile::create( mapProfile->getSRS(), mapProfile->getExtent().xMin(), mapProfile->getExtent().yMin(), mapProfile->getExtent().xMax(), mapProfile->getExtent().yMax(), 8, 4 ); _featureProfile = new FeatureProfile(_profile->getSRS()); //todo: do this right.. osg::StateSet* set = this->getOrCreateStateSet(); set->setMode( GL_LIGHTING, 0 ); set->setMode( GL_BLEND, 1 ); // set up default options if the caller did not supply them if ( !_options.isSet() ) { _options->primaryStyle()= Style(); LineSymbol* line = _options->primaryStyle()->getOrCreate<LineSymbol>(); line->stroke()->color() = Color::Gray; line->stroke()->width() = 1.0; line->tessellation() = 20; AltitudeSymbol* alt = _options->primaryStyle()->getOrCreate<AltitudeSymbol>(); //alt->verticalOffset() = NumericExpression(4900.0); TextSymbol* text = _options->primaryStyle()->getOrCreate<TextSymbol>(); text->fill()->color() = Color(Color::White, 0.3f); text->halo()->color() = Color(Color::Black, 0.2f); text->alignment() = TextSymbol::ALIGN_CENTER_CENTER; } // make the shared depth attr: _depthAttribute = new osg::Depth(osg::Depth::LEQUAL,0,1,false); // this will intialize the graph. rebuild(); }
void UTMGraticule::rebuild() { // clear everything out this->removeChildren( 0, this->getNumChildren() ); // requires a map node if ( !getMapNode() ) { return; } // requires a geocentric map if ( !getMapNode()->isGeocentric() ) { OE_WARN << LC << "Projected map mode is not yet supported" << std::endl; return; } const Profile* mapProfile = getMapNode()->getMap()->getProfile(); _profile = Profile::create( mapProfile->getSRS(), mapProfile->getExtent().xMin(), mapProfile->getExtent().yMin(), mapProfile->getExtent().xMax(), mapProfile->getExtent().yMax(), 8, 4 ); _featureProfile = new FeatureProfile(_profile->getSRS()); //todo: do this right.. osg::StateSet* set = this->getOrCreateStateSet(); set->setMode( GL_LIGHTING, 0 ); set->setMode( GL_BLEND, 1 ); // set up default options if the caller did not supply them if ( !_options.isSet() ) { _options->primaryStyle() = Style(); LineSymbol* line = _options->primaryStyle()->getOrCreate<LineSymbol>(); line->stroke()->color() = Color::Gray; line->stroke()->width() = 1.0; line->tessellation() = 20; AltitudeSymbol* alt = _options->primaryStyle()->getOrCreate<AltitudeSymbol>(); TextSymbol* text = _options->primaryStyle()->getOrCreate<TextSymbol>(); text->fill()->color() = Color(Color::White, 0.3f); text->halo()->color() = Color(Color::Black, 0.2f); text->alignment() = TextSymbol::ALIGN_CENTER_CENTER; } // rebuild the graph: _root = new DrapeableNode( getMapNode(), false ); this->addChild( _root ); #if 0 // set up depth offsetting. osg::StateSet* s = _root->getOrCreateStateSet(); s->setAttributeAndModes( DepthOffsetUtils::getOrCreateProgram(), 1 ); s->addUniform( DepthOffsetUtils::getIsNotTextUniform() ); osg::Uniform* u = DepthOffsetUtils::createMinOffsetUniform(); u->set( 10000.0f ); s->addUniform( u ); #endif // build the base Grid Zone Designator (GZD) loolup table. This is a table // that maps the GZD string to its extent. static std::string s_gzdRows( "CDEFGHJKLMNPQRSTUVWX" ); const SpatialReference* geosrs = _profile->getSRS()->getGeographicSRS(); // build the lateral zones: for( unsigned zone = 0; zone < 60; ++zone ) { for( unsigned row = 0; row < s_gzdRows.size(); ++row ) { double yMaxExtra = row == s_gzdRows.size()-1 ? 4.0 : 0.0; // extra 4 deg for row X GeoExtent cellExtent( geosrs, -180.0 + double(zone)*6.0, -80.0 + row*8.0, -180.0 + double(zone+1)*6.0, -80.0 + double(row+1)*8.0 + yMaxExtra ); _gzd[ Stringify() << (zone+1) << s_gzdRows[row] ] = cellExtent; } } // the polar zones (UPS): _gzd["1Y"] = GeoExtent( geosrs, -180.0, 84.0, 0.0, 90.0 ); _gzd["1Z"] = GeoExtent( geosrs, 0.0, 84.0, 180.0, 90.0 ); _gzd["1A"] = GeoExtent( geosrs, -180.0, -90.0, 0.0, -80.0 ); _gzd["1B"] = GeoExtent( geosrs, 0.0, -90.0, 180.0, -80.0 ); // replace the "exception" zones in Norway and Svalbard _gzd["31V"] = GeoExtent( geosrs, 0.0, 56.0, 3.0, 64.0 ); _gzd["32V"] = GeoExtent( geosrs, 3.0, 56.0, 12.0, 64.0 ); _gzd["31X"] = GeoExtent( geosrs, 0.0, 72.0, 9.0, 84.0 ); _gzd["33X"] = GeoExtent( geosrs, 9.0, 72.0, 21.0, 84.0 ); _gzd["35X"] = GeoExtent( geosrs, 21.0, 72.0, 33.0, 84.0 ); _gzd["37X"] = GeoExtent( geosrs, 33.0, 72.0, 42.0, 84.0 ); // ..and remove the non-existant zones: _gzd.erase( "32X" ); _gzd.erase( "34X" ); _gzd.erase( "36X" ); // now build the lateral tiles for the GZD level. for( SectorTable::iterator i = _gzd.begin(); i != _gzd.end(); ++i ) { osg::Node* tile = buildGZDTile( i->first, i->second ); if ( tile ) _root->addChild( tile ); } DepthOffsetUtils::prepareGraph( _root ); }