Esempio n. 1
0
        protected void collectGeometryKeys(QuadMap qmap, QuadKeyList geom_keys)
        {
            // the starting LOD is the best fit the the cell size:
            uint top_lod = getTopLod(qmap, map_layer);

            foreach (MapLayerLevelOfDetail i in map_layer.getLevels())
            {
                MapLayerLevelOfDetail level_def = i;
                uint lod = top_lod + level_def.getDepth();

                // get the extent of tiles that we will build based on the AOI:
                uint cell_xmin, cell_ymin, cell_xmax, cell_ymax;
                qmap.getCells(
                    map_layer.getAreaOfInterest(), lod,
                    cell_xmin, cell_ymin, cell_xmax, cell_ymax);

                for (uint y = cell_ymin; y <= cell_ymax; y++)
                {
                    for (uint x = cell_xmin; x <= cell_xmax; x++)
                    {
                        QuadKey key = new QuadKey(x, y, lod, qmap);
                        for (uint k = 0; k < 4; k++)
                        {
                            geom_keys.push_back(key.createSubKey(k));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected osg.Node createLeafIndexNode(QuadKey key, SmartReadCallback cb)
        {
            osg.Group group = null;

            for (uint i = 0; i < 4; i++)
            {
                QuadKey quadrant_key = key.createSubKey(i);

                if (osgDB.fileExists(createAbsPathFromTemplate("g" + quadrant_key.toString())))
                {
                    if (!group)
                    {
                        group = new osg.Group();
                        group.setName(key.toString());
                    }

#if USE_PAGEDLODS_IN_INDEX
                    osg.PagedLOD *pointer = new osg.PagedLOD();
                    pointer.setFileName(0, createRelPathFromTemplate("g" + quadrant_key.toString()));
                    pointer.setRange(0, 0, 1e10);
                    pointer.setPriorityScale(0, 1000.0f); // top priority!
                    pointer.setPriorityOffset(0, 1000.0f);
                    setCenterAndRadius(pointer, quadrant_key.getExtent(), reader);
#else
                    osg.ProxyNode pointer = new osg.ProxyNode();
                    pointer.setLoadingExternalReferenceMode(osg.ProxyNode.LOAD_IMMEDIATELY);
                    pointer.setFileName(0, createRelPathFromTemplate("g" + quadrant_key.toString()));
                    //setCenterAndRadius( pointer, quadrant_key.getExtent(), reader );
#endif

                    group.addChild(pointer);
                }
            }

            return(group);
        }
Esempio n. 3
0
        protected osg.Node createIntermediateIndexNode(QuadKey key, float min_range, float max_range, SmartReadCallback cb)
        {
            osg.Group group = null;

            for (uint quadrant = 0; quadrant < 4; quadrant++)
            {
                QuadKey subkey = key.createSubKey(quadrant);

                if (osgDB.fileExists(createAbsPathFromTemplate("g" + subkey.toString())))
                {
                    if (!group)
                    {
                        group = new osg.Group();
                        group.setName(key.toString());
                    }

                    //osgGIS.notice() << "QK=" << subkey.toString() << ", Extent=" << subkey.getExtent().toString() << std.endl;

                    // enter the subtile set as a paged index node reference:
                    osg.PagedLOD plod = new osg.PagedLOD();
                    setCenterAndRadius(plod, subkey.getExtent(), reader);


#if USE_PAGEDLODS_IN_INDEX
                    osg.PagedLOD *pointer = new osg.PagedLOD();
                    pointer.setFileName(0, createRelPathFromTemplate("g" + subkey.toString()));
                    pointer.setRange(0, 0, 1e10);
                    pointer.setPriorityScale(0, 1000.0f); // top priority, hopefully
                    pointer.setPriorityOffset(0, 1000.0f);
                    pointer.setCenter(plod.getCenter());
                    pointer.setRadius(plod.getRadius());
#else
                    osg.ProxyNode pointer = new osg.ProxyNode();
                    pointer.setLoadingExternalReferenceMode(osg.ProxyNode.LOAD_IMMEDIATELY);
                    pointer.setFileName(0, createRelPathFromTemplate("g" + subkey.toString()));
                    //setCenterAndRadius( pointer, subkey.getExtent(), reader );
#endif

                    plod.addChild(pointer, max_range, 1e10);
                    plod.setFileName(1, createRelPathFromTemplate("i" + subkey.toString()));
                    plod.setRange(1, 0, max_range); // last one should always be min=0
                    plod.setPriorityScale(1, MY_PRIORITY_SCALE);

                    group.addChild(plod);



                    //osg.Geode* geode = new osg.Geode();

                    //osg.Sphere* g1 = new osg.Sphere( osg.Vec3(0,0,0), plod.getRadius() );
                    //osg.ShapeDrawable* sd1 = new osg.ShapeDrawable( g1 );
                    //sd1.setColor( osg.Vec4f(1,0,0,.2) );
                    //geode.addDrawable( sd1 );

                    ////osg.Vec3d p = terrain_srs.transform( subkey.getExtent().getCentroid() );
                    ////osg.Vec3d n = p; n.normalize();

                    ////osg.Geometry* g3 = new osg.Geometry();
                    ////osg.Vec3Array* v3 = new osg.Vec3Array(2);
                    ////(*v3)[0] = osg.Vec3d(0,0,0);
                    ////(*v3)[1] = n * 3000.0;
                    ////g3.setVertexArray( v3 );
                    ////osg.Vec4Array* c3 = new osg.Vec4Array(1);
                    ////(*c3)[0].set(1,1,0,1);
                    ////g3.setColorArray( c3 );
                    ////g3.setColorBinding(osg.Geometry.BIND_OVERALL);
                    ////g3.addPrimitiveSet( new osg.DrawArrays(GL_LINES, 0, 2) );
                    ////g3.getOrCreateStateSet().setMode( GL_LIGHTING, osg.StateAttribute.OFF );
                    ////geode.addDrawable( g3 );

                    ////osg.Sphere* g2 = new osg.Sphere( osg.Vec3(0,0,0), 25 );
                    ////osg.ShapeDrawable* sd2 = new osg.ShapeDrawable( g2 );
                    ////sd2.setColor( osg.Vec4f(1,1,0,1) );
                    ////geode.addDrawable( sd2 );

                    ////osg.Matrixd mx = osg.Matrixd.translate( p );
                    //osg.Matrixd mx = osg.Matrixd.translate( plod.getCenter() );
                    //osg.MatrixTransform* mt = new osg.MatrixTransform( mx );

                    //mt.addChild( geode );
                    //mt.getOrCreateStateSet().setMode( GL_BLEND, osg.StateAttribute.ON );
                    //mt.getOrCreateStateSet().setRenderingHint( osg.StateSet.TRANSPARENT_BIN );
                    //group.addChild( mt );
                }
            }

            return(group);
        }