Exemple #1
0
        protected virtual uint queueTasks(Profile profile, TaskManager task_man)
        {
            uint level = 0;

            foreach (MapLayerLevelOfDetail i in map_layer.getLevels())
            {
                MapLayerLevelOfDetail level_def = i;

                string s = level.ToString();

                FilterEnv cell_env = getSession().createFilterEnv();
                cell_env.setExtent(map_layer.getAreaOfInterest()); //GeoExtent.infinite() );
                cell_env.setTerrainNode(getTerrainNode());
                cell_env.setTerrainSRS(getTerrainSRS());
                foreach (Property prop in level_def.getEnvProperties())
                {
                    cell_env.setProperty(prop);
                }

                Task task = new CellCompiler(s,
                                             s,
                                             level_def.getFeatureLayer(),
                                             level_def.getFilterGraph(),
                                             level_def.getMinRange(),
                                             level_def.getMaxRange(),
                                             cell_env,
                                             null, null, null);

                task_man.queueTask(task);
            }
            return(level);
        }
Exemple #2
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));
                        }
                    }
                }
            }
        }
Exemple #3
0
        protected virtual void processCompletedTask(CellCompiler task)
        {
            if (task.getResult().isOK() && task.getResultNode())
            {
                if (!lod.valid())
                {
                    lod = new osg.LOD();
                }

                uint key = uint.Parse(task.getName());
                MapLayerLevelOfDetail def = getLodForKey(key, getMapLayer());
                if (def != null)
                {
                    lod.addChild(task.getResultNode(), def.getMinRange(), def.getMaxRange());
                }
            }
        }
Exemple #4
0
        protected Task createQuadKeyTask(QuadKey key)
        {
            // construct a filter environment template to use for all tasks:
            FilterEnv cell_env = getSession().createFilterEnv();

            cell_env.setTerrainNode(getTerrainNode());
            cell_env.setTerrainSRS(getTerrainSRS());

            string abs_path = createAbsPathFromTemplate("g" + key.toString());

            Task task = null;

            MapLayerLevelOfDetail def = getDefinition(key.createParentKey(), map_layer);

            if (def != null)
            {
                cell_env.setInputSRS(def.getFeatureLayer().getSRS());
                cell_env.setExtent(map_layer.getAreaOfInterest().getSRS().transform(key.getExtent()));
                cell_env.setProperty(new Property("compiler.cell_id", key.toString()));
                foreach (Property i in def.getEnvProperties())
                {
                    cell_env.setProperty(i);
                }

                task = new CellCompiler(
                    key.toString(),
                    abs_path,
                    def.getFeatureLayer(),
                    def.getFilterGraph(),
                    def.getMinRange(),
                    def.getMaxRange(),
                    cell_env,
                    def.getResourcePackager() ? def.getResourcePackager() : resource_packager.get(),
                    getArchive(),
                    def.getUserData());

                // osgGIS.info()
                //    << "Task: Key = " << key.toString() << ", LOD = " << key.getLOD() << ", Extent = " << key.getExtent().toString()
                //    << " (w=" << key.getExtent().getWidth() << ", h=" << key.getExtent().getHeight() << ")"
                //    << std.endl;
            }

            return(task);
        }
Exemple #5
0
        protected virtual void buildIndex(Profile _profile, osg.Group scene_graph)
        {
            QuadTreeProfile profile = (QuadTreeProfile)_profile;

            if (profile == null)
            {
                return;
            }

            //osgGIS.notice() << "Rebuilding index..." << std.endl;

            // first, determine the SRS of the output scene graph so that we can
            // make pagedlod/lod centroids.
            SpatialReference output_srs = map_layer.getOutputSRS(getSession(), getTerrainSRS());

            // first build the very top level.
            //scene_graph = new osg.Group();

            // the starting LOD is the best fit the the cell size:
            uint top_lod = getTopLod(profile.getQuadMap(), map_layer);

            SmartReadCallback reader = new SmartReadCallback();

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

                MapLayerLevelOfDetail sub_level_def = i + 1 != map_layer.getLevels().end() ? (i + 1).get() : null;
                float min_range, max_range;
                if (sub_level_def != null)
                {
                    min_range = sub_level_def.getMinRange();
                    max_range = sub_level_def.getMaxRange();
                }

                // get the extent of tiles that we will build based on the AOI:
                uint cell_xmin, cell_ymin, cell_xmax, cell_ymax;
                profile.getQuadMap().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++)
                    {
                        osg.Node node;

                        QuadKey key = new QuadKey(x, y, lod, profile.getQuadMap());

                        //osgGIS.notify( osg.NOTICE )
                        //    << "Cell: " << std.endl
                        //    << "   Quadkey = " << key.toString() << std.endl
                        //    << "   LOD = " << key.getLOD() << std.endl
                        //    << "   Extent = " << key.getExtent().toString() << " (w=" << key.getExtent().getWidth() << ", h=" << key.getExtent().getHeight() << ")" << std.endl
                        //    << std.endl;

                        node = sub_level_def ?
                               createIntermediateIndexNode(key, min_range, max_range, reader.get()) :
                               createLeafIndexNode(key, reader);

                        if (node.valid())
                        {
                            string out_file = createAbsPathFromTemplate("i" + key.toString());

                            if (!osgDB.writeNodeFile(*(node.get()), out_file))
                            {
                                // osgGIS.warn() << "FAILED to write index file " << out_file << std.endl;
                            }

                            // at the top level, assemble the root node
                            if (i == map_layer.getLevels().begin())
                            {
                                double top_min_range = sub_level_def != null ? 0 : level_def.getMinRange();

                                osg.PagedLOD plod = new osg.PagedLOD();
                                plod.setName(key.toString());
                                plod.setFileName(0, createRelPathFromTemplate("i" + key.toString()));
                                plod.setRange(0, top_min_range, level_def.getMaxRange());
                                plod.setPriorityScale(0, MY_PRIORITY_SCALE);
                                setCenterAndRadius(plod, key.getExtent(), reader.get());

                                //osgGIS.notice() << "QK=" << key.toString() << ", Ex=" << key.getExtent().toString() << ", Cen=" << key.getExtent().getCentroid().toString() << std.endl;


                                scene_graph.addChild(plod);
                            }
                        }
                    }
                }
            }
        }