当前位置: 首页>>代码示例>>C++>>正文


C++ FilterContext类代码示例

本文整理汇总了C++中FilterContext的典型用法代码示例。如果您正苦于以下问题:C++ FilterContext类的具体用法?C++ FilterContext怎么用?C++ FilterContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FilterContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: obj

v8::Handle<v8::Value>
JSFilterContext::ToWorldCallback(const v8::Arguments& args)
{
    FilterContext* context = V8Util::UnwrapObject<FilterContext>(args.Holder());

    if (context && args.Length() == 1 && args[0]->IsObject())
    {
        v8::Local<v8::Object> obj( v8::Object::Cast(*args[0]) );

        /*if (V8Util::CheckObjectType(obj, JSGeometry::GetObjectType()))  // Geometry
        {
          osgEarth::Symbology::Geometry* geometry = V8Util::UnwrapObject<osgEarth::Symbology::Geometry>(obj);

          return
        }*/

        if (V8Util::CheckObjectType(obj, JSVec3d::GetObjectType()))  // Vec3d
        {
            osg::Vec3d* vec = V8Util::UnwrapObject<osg::Vec3d>(obj);
            osg::Vec3d* world = new osg::Vec3d(context->toWorld(*vec));
            return JSVec3d::WrapVec3d(world, true);
        }
    }

    return v8::Undefined();
}
开发者ID:nedbrek,项目名称:osgearth,代码行数:26,代码来源:JSWrappers.cpp

示例2: createFeatureCursor

    FeatureCursor* createFeatureCursor( const Symbology::Query& query )
    {
        FeatureCursor* result = 0L;

        std::string url = createURL( query );        

        // check the blacklist:
        if ( Registry::instance()->isBlacklisted(url) )
            return 0L;

        OE_DEBUG << LC << url << std::endl;
        URI uri(url);

        // read the data:
        ReadResult r = uri.readString( _dbOptions.get() );

        const std::string& buffer = r.getString();
        const Config&      meta   = r.metadata();

        bool dataOK = false;

        FeatureList features;
        if ( !buffer.empty() )
        {
            // Get the mime-type from the metadata record if possible
            const std::string& mimeType = r.metadata().value( IOMetadata::CONTENT_TYPE );
            dataOK = getFeatures( buffer, mimeType, features );
        }

        if ( dataOK )
        {
            OE_DEBUG << LC << "Read " << features.size() << " features" << std::endl;
        }

        //If we have any filters, process them here before the cursor is created
        if (!_options.filters().empty())
        {
            // preprocess the features using the filter list:
            if ( features.size() > 0 )
            {
                FilterContext cx;
                cx.setProfile( getFeatureProfile() );

                for( FeatureFilterList::const_iterator i = _options.filters().begin(); i != _options.filters().end(); ++i )
                {
                    FeatureFilter* filter = i->get();
                    cx = filter->push( features, cx );
                }
            }
        }

        //result = new FeatureListCursor(features);
        result = dataOK ? new FeatureListCursor( features ) : 0L;

        if ( !result )
            Registry::instance()->blacklist( url );

        return result;
    }
开发者ID:ifad-ts,项目名称:osgearth,代码行数:59,代码来源:FeatureSourceWFS.cpp

示例3: while

// reads a chunk of features into a memory cache; do this for performance
// and to avoid needing the OGR Mutex every time
void
FeatureCursorOGR::readChunk()
{
    if ( !_resultSetHandle )
        return;
    
    OGR_SCOPED_LOCK;

    while( _queue.size() < _chunkSize && !_resultSetEndReached )
    {
        FeatureList filterList;
        while( filterList.size() < _chunkSize && !_resultSetEndReached )
        {
            OGRFeatureH handle = OGR_L_GetNextFeature( _resultSetHandle );
            if ( handle )
            {
                osg::ref_ptr<Feature> feature = OgrUtils::createFeature( handle, _profile.get() );

                if (feature.valid() &&
                    !_source->isBlacklisted( feature->getFID() ) &&
                    validateGeometry( feature->getGeometry() ))
                {
                    filterList.push_back( feature.release() );
                }
                OGR_F_Destroy( handle );
            }
            else
            {
                _resultSetEndReached = true;
            }
        }

        // preprocess the features using the filter list:
        if ( !_filters.empty() )
        {
            FilterContext cx;
            cx.setProfile( _profile.get() );
            if (_query.bounds().isSet())
            {
                cx.extent() = GeoExtent(_profile->getSRS(), _query.bounds().get());
            }
            else
            {
                cx.extent() = _profile->getExtent();
            }

            for( FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i )
            {
                FeatureFilter* filter = i->get();
                cx = filter->push( filterList, cx );
            }
        }

        for(FeatureList::const_iterator i = filterList.begin(); i != filterList.end(); ++i)
        {
            _queue.push( i->get() );
        }
    }
}
开发者ID:469447793,项目名称:osgearth,代码行数:61,代码来源:FeatureCursorOGR.cpp

示例4: OGR_L_ResetReading

void FeatureCursorCDBV::Read_Data_Directly(void)
{
	FeatureList preProcessList;

	OGR_SCOPED_LOCK;

	OGR_L_ResetReading(_layerHandle);
	OGRFeatureH feat_handle;

	OGRLayer * thislayer = (OGRLayer *)_layerHandle;
	int totalCount = thislayer->GetFeatureCount();
	int fcount = -1;
	while ((feat_handle = OGR_L_GetNextFeature(_layerHandle)) != NULL)
	{
		++fcount;
		if (feat_handle)
		{
			osg::ref_ptr<Feature> f = OgrUtils::createFeature(feat_handle, _profile.get());
			if (f.valid() && !_source->isBlacklisted(f->getFID()))
			{
				if (isGeometryValid(f->getGeometry()))
				{
					_queue.push(f);

					if (_filters.size() > 0)
					{
						preProcessList.push_back(f.release());
					}
				}
				else
				{
					OE_DEBUG << LC << "Skipping feature with invalid geometry: " << f->getGeoJSON() << std::endl;
				}
			}
			OGR_F_Destroy(feat_handle);
		}
	}

	// preprocess the features using the filter list:
	if (preProcessList.size() > 0)
	{
		FilterContext cx;
		cx.setProfile(_profile.get());

		for (FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i)
		{
			FeatureFilter* filter = i->get();
			cx = filter->push(preProcessList, cx);
		}
	}

}
开发者ID:gajgeospatial,项目名称:osgEarth-2.7,代码行数:52,代码来源:FeatureCursorCDBV.cpp

示例5: eq

FilterContext
ClampFilter::push( FeatureList& features, const FilterContext& cx )
{
    const Session* session = cx.getSession();
    if ( !session ) {
        OE_WARN << LC << "No session - session is required for elevation clamping" << std::endl;
        return cx;
    }

    // the map against which we'll be doing elevation clamping
    MapFrame mapf = session->createMapFrame( Map::ELEVATION_LAYERS );

    const SpatialReference* mapSRS     = mapf.getProfile()->getSRS();
    const SpatialReference* featureSRS = cx.profile()->getSRS();
    bool isGeocentric = session->getMapInfo().isGeocentric();

    // establish an elevation query interface based on the features' SRS.
    ElevationQuery eq( mapf );

    for( FeatureList::iterator i = features.begin(); i != features.end(); ++i )
    {
        Feature* feature = i->get();
        
        GeometryIterator gi( feature->getGeometry() );
        while( gi.hasMore() )
        {
            Geometry* geom = gi.next();

            if ( isGeocentric )
            {
                // convert to map coords:
                cx.toWorld( geom );
                mapSRS->transformFromECEF( geom );

                // populate the elevations:
                eq.getElevations( geom, mapSRS );

                // convert back to geocentric:
                mapSRS->transformToECEF( geom );
                cx.toLocal( geom );
            }

            else
            {
                // clamps the entire array to the highest available resolution.
                eq.getElevations( geom, featureSRS );
            }
        }
    }

    return cx;
}
开发者ID:sourcepole,项目名称:osgearth,代码行数:52,代码来源:ClampFilter.cpp

示例6: textColor

bool
BuildGeometryFilter::pushTextAnnotation( TextAnnotation* anno, const FilterContext& context )
{
    // find the centroid
    osg::Vec3d centroid = anno->getGeometry()->getBounds().center();

    osgText::Text* t = new osgText::Text();
    t->setText( anno->text() );
    t->setFont( "fonts/arial.ttf" );
    t->setAutoRotateToScreen( true );
    t->setCharacterSizeMode( osgText::TextBase::SCREEN_COORDS );
    t->setCharacterSize( 32.0f );
    //t->setCharacterSizeMode( osgText::TextBase::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT );
    //t->setCharacterSize( 300000.0f );
    t->setPosition( centroid );
    t->setAlignment( osgText::TextBase::CENTER_CENTER );
    t->getOrCreateStateSet()->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS), osg::StateAttribute::ON );
    t->getOrCreateStateSet()->setRenderBinDetails( 99999, "RenderBin" );

    // apply styling as appropriate:
    osg::Vec4f textColor(1,1,1,1);
    osg::Vec4f haloColor(0,0,0,1);

    const TextSymbol* textSymbolizer = getStyle().getSymbol<TextSymbol>();
    if ( textSymbolizer )
    {
        textColor = textSymbolizer->fill()->color();
        if ( textSymbolizer->halo().isSet() )
        {
            haloColor = textSymbolizer->halo()->color();
        }
    }

    t->setColor( textColor );
    t->setBackdropColor( haloColor );
    t->setBackdropType( osgText::Text::OUTLINE );

    if ( context.isGeocentric() )
    {
        // install a cluster culler: note that the CCC control point and normal must be
        // in world coordinates
        const osg::EllipsoidModel* ellip = context.profile()->getSRS()->getEllipsoid();
        osg::Vec3d cp = centroid * context.inverseReferenceFrame();
        osg::Vec3d normal = ellip->computeLocalUpVector( cp.x(), cp.y(), cp.z() );
        osg::ClusterCullingCallback* ccc = new osg::ClusterCullingCallback( cp, normal, 0.0f );
        t->setCullCallback( ccc );
    }

    _geode->addDrawable( t );

    return true;    
}
开发者ID:korash,项目名称:osgearth,代码行数:52,代码来源:BuildGeometryFilter.cpp

示例7: i

void
TessellateOperator::operator()( Feature* feature, FilterContext& context ) const
{
    if (_numPartitions <= 1 ||
        !feature || 
        !feature->getGeometry() || 
        feature->getGeometry()->getComponentType() == Geometry::TYPE_POINTSET )
    {
        return;
    }

    bool isGeo = context.profile() ? context.profile()->getSRS()->isGeographic() : true;
    GeoInterpolation interp = feature->geoInterp().isSet() ? *feature->geoInterp() : _defaultInterp;

    GeometryIterator i( feature->getGeometry(), true );
    while( i.hasMore() )
    {
        Geometry* g = i.next();
        bool isRing = dynamic_cast<Ring*>( g ) != 0L;

        Vec3dVector newVerts;
        newVerts.reserve( g->size() * _numPartitions );

        for( Geometry::const_iterator v = g->begin(); v != g->end(); ++v )
        {
            const osg::Vec3d& p0 = *v;
            if ( v != g->end()-1 ) // not last vert
            {
                if ( isGeo )
                    tessellateGeo( *v, *(v+1), _numPartitions, interp, newVerts );
                else
                    tessellateLinear( *v, *(v+1), _numPartitions, newVerts );
            }
            else if ( isRing )
            {
                if ( isGeo )
                    tessellateGeo( *v, *g->begin(), _numPartitions, interp, newVerts );
                else
                    tessellateLinear( *v, *g->begin(), _numPartitions, newVerts );
            }
            else 
            {
                // get the final vert.
                newVerts.push_back( *v );
            }
        }

        g->swap( newVerts );
    }
}
开发者ID:chuckshaw,项目名称:osgearth,代码行数:50,代码来源:TessellateOperator.cpp

示例8: outcx

FilterContext
TransformFilter::push( FeatureList& input, FilterContext& incx )
{
    _bbox = osg::BoundingBoxd();

    // first transform all the points into the output SRS, collecting a bounding box as we go:
    bool ok = true;
    for( FeatureList::iterator i = input.begin(); i != input.end(); i++ )
        if ( !push( i->get(), incx ) )
            ok = false;

    FilterContext outcx( incx );
    outcx.isGeocentric() = _makeGeocentric;

    if ( _outputSRS.valid() )
    {
        if ( incx.extent()->isValid() )
            outcx.profile() = new FeatureProfile( incx.extent()->transform( _outputSRS.get() ) );
        else
            outcx.profile() = new FeatureProfile( incx.profile()->getExtent().transform( _outputSRS.get() ) );
    }

    // set the reference frame to shift data to the centroid. This will
    // prevent floating point precision errors in the openGL pipeline for
    // properly gridded data.
    if ( _bbox.valid() && _localize )
    {
        // create a suitable reference frame:
        osg::Matrixd localizer;
        if ( _makeGeocentric )
        {
            localizer = createGeocentricInvRefFrame( _bbox.center(), _outputSRS.get() );
            localizer.invert( localizer );
        }
        else
        {
            localizer = osg::Matrixd::translate( -_bbox.center() );
        }

        // localize the geometry relative to the reference frame.
        for( FeatureList::iterator i = input.begin(); i != input.end(); i++ )
        {
            localizeGeometry( i->get(), localizer );
        }
        outcx.setReferenceFrame( localizer );
    }

    return outcx;
}
开发者ID:rdelmont,项目名称:osgearth,代码行数:49,代码来源:TransformFilter.cpp

示例9: getFeatureProfile

void
FeatureSource::applyFilters(FeatureList& features, const GeoExtent& extent) const
{
    // apply filters before returning.
    if ( !getFilters().empty() )
    {
        FilterContext cx;
        cx.setProfile( getFeatureProfile() );
        cx.extent() = extent;
        for(FeatureFilterList::const_iterator filter = getFilters().begin(); filter != getFilters().end(); ++filter)
        {
            cx = filter->get()->push( features, cx );
        }
    }
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:15,代码来源:FeatureSource.cpp

示例10: getFeatureProfile

void
FeatureSource::applyFilters(FeatureList& features, const GeoExtent& extent) const
{
    // apply filters before returning.
    if (_filters.valid() && _filters->empty() == false)
    {
        FilterContext cx;
        cx.setProfile( getFeatureProfile() );
        cx.extent() = extent;
        for(FeatureFilterChain::const_iterator filter = _filters->begin(); filter != _filters->end(); ++filter)
        {
            cx = filter->get()->push( features, cx );
        }
    }
}
开发者ID:damiandixon,项目名称:osgearth,代码行数:15,代码来源:FeatureSource.cpp

示例11: makeRef

BufferSrcFilterContext::BufferSrcFilterContext(const FilterContext &baseContext)
{
    if (baseContext && isFilterValid(baseContext.getFilter()))
    {
        makeRef(baseContext);
    }
}
开发者ID:Adenilson,项目名称:avcpp,代码行数:7,代码来源:buffersrc.cpp

示例12: pushAndClamp

FilterContext
AltitudeFilter::push( FeatureList& features, FilterContext& cx )
{
    bool clamp = 
        _altitude.valid() && 
        _altitude->clamping() != AltitudeSymbol::CLAMP_NONE &&
        cx.getSession()       != 0L &&
        cx.profile()          != 0L;

    if ( clamp )
        pushAndClamp( features, cx );
    else
        pushAndDontClamp( features, cx );

    return cx;
}
开发者ID:airwzz999,项目名称:osgearth-for-android,代码行数:16,代码来源:AltitudeFilter.cpp

示例13: createBoundary

    osg::Vec3dArray* createBoundary( const SpatialReference* srs, ProgressCallback* progress )
    {
        if ( _failed )
            return 0L;

        if ( _features.valid() )
        {
            if ( _features->getFeatureProfile() )
            {
                osg::ref_ptr<FeatureCursor> cursor = _features->createFeatureCursor();
                if ( cursor )
                {
                    if ( cursor->hasMore() )
                    {
                        Feature* f = cursor->nextFeature();
                        if ( f && f->getGeometry() )
                        {
                            // Init a filter to tranform feature in desired SRS 
                            if (!srs->isEquivalentTo(_features->getFeatureProfile()->getSRS())) {
                                FilterContext cx;
                                cx.profile() = new FeatureProfile(_features->getFeatureProfile()->getExtent());
                                //cx.isGeocentric() = _features->getFeatureProfile()->getSRS()->isGeographic();

                                TransformFilter xform( srs );
                                FeatureList featureList;
                                featureList.push_back(f);
                                cx = xform.push(featureList, cx);
                            }

                            return f->getGeometry()->toVec3dArray();
                        }
                    }
                }
            }
            else
            {
                OE_WARN << LC << "Failed to create boundary; feature source has no SRS" << std::endl;
                _failed = true;
            }
        }
        else
        {
            OE_WARN << LC << "Unable to create boundary; invalid feature source" << std::endl;
            _failed = true;
        }
        return 0L;
    }
开发者ID:JohnDr,项目名称:osgearth,代码行数:47,代码来源:FeatureMaskSource.cpp

示例14: iter

bool
TransformFilter::push( Feature* input, FilterContext& context )
{
    if ( !input || !input->getGeometry() )
        return true;

    bool needsSRSXform =
        _outputSRS.valid() &&
        ( ! context.profile()->getSRS()->isEquivalentTo( _outputSRS.get() ) );

    bool needsMatrixXform = !_mat.isIdentity();

    // optimize: do nothing if nothing needs doing
    if ( !needsSRSXform && !_makeGeocentric && !_localize && !needsMatrixXform )
        return true;

    // iterate over the feature geometry.
    GeometryIterator iter( input->getGeometry() );
    while( iter.hasMore() )
    {
        Geometry* geom = iter.next();

        // pre-transform the point before doing an SRS transformation.
        if ( needsMatrixXform )
        {
            for( unsigned i=0; i < geom->size(); ++i )
                (*geom)[i] = (*geom)[i] * _mat;
        }

        // first transform the geometry to the output SRS:            
        if ( needsSRSXform )
            context.profile()->getSRS()->transformPoints( _outputSRS.get(), geom->asVector(), false );

        // convert to ECEF if required:
        if ( _makeGeocentric )
            _outputSRS->transformToECEF( geom->asVector(), false );

        // update the bounding box.
        if ( _localize )
        {
            for( unsigned i=0; i<geom->size(); ++i )
                _bbox.expandBy( (*geom)[i] );
        }
    }

    return true;
}
开发者ID:rdelmont,项目名称:osgearth,代码行数:47,代码来源:TransformFilter.cpp

示例15: Feature

Feature*
GeometryFeatureCursor::nextFeature()
{
    if ( hasMore() )
    {        
        _lastFeature = new Feature( _geom.get(), _featureProfile.valid() ? _featureProfile->getSRS() : 0L );
        FilterContext cx;
        cx.profile() = _featureProfile.get();
        FeatureList list;
        list.push_back( _lastFeature.get() );
        for( FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i ) {
            cx = i->get()->push( list, cx );
        }
        _geom = 0L;
    }
    return _lastFeature.get();
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:17,代码来源:FeatureCursor.cpp


注:本文中的FilterContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。