示例#1
0
        /**
         * Pushes source data onto the level of detail queue. Levels of detail are
         * interpreted from front to back.
         *
         * @param layer
         *      Feature layer from which to read source data
         * @param graph
         *      Filter graph to use to build scene graph
         * @param min_range
         *      Minimum visibility range of this level of detail
         * @param max_range
         *      Maximum visibility range of this level of detail
         * @param replace
         *      If true, this detail level will replace the ones before it. If false, it
         *      will join the scene graph without removing the previous levels.
         * @param depth
         *      Level of detail depth (0 = top level)
         * @param user_data
         *      User-defined data to pass to the cell compiler
         */
        public void push(FeatureLayer layer,
            FilterGraph graph,
            Properties env_props,
            ResourcePackager packager,
            float min_range,
            float max_range,
            bool replace,
            uint depth,
            object user_data)
        {
            if (layer != null)
            {
                // update the automatic AOI:
                if (!aoi_auto.isValid())
                    aoi_auto = layer.getExtent();
                else
                    aoi_auto.expandToInclude(layer.getExtent());

                // store the LOD definition:
                levels.Add(new MapLayerLevelOfDetail(
                    layer, graph, env_props, packager, min_range, max_range, replace, depth, user_data));

                grid_valid = false;
            }
        }
示例#2
0
        public Node compile(FeatureLayer layer, FeatureCursor cursor, string output_file)
        {
            osg.Node *result = NULL;

            if (!layer)
            {
                osgGIS.notify(osg.WARN) << "Illegal null feature layer" << std.endl;
                return(NULL);
            }

            osg.ref_ptr <osg.LOD> lod = new osg.LOD();

            if (getFadeLODs())
            {
                FadeHelper.enableFading(lod.getOrCreateStateSet());
            }

            for (FilterGraphRangeList.iterator i = graph_ranges.begin(); i != graph_ranges.end(); i++)
            {
                osg.Node *range = compile(layer, cursor, i.graph.get());
                if (range)
                {
                    lod.addChild(range, i.min_range, i.max_range);

                    if (getFadeLODs())
                    {
                        FadeHelper.setOuterFadeDistance(i.max_range, range.getOrCreateStateSet());
                        FadeHelper.setInnerFadeDistance(i.max_range - .2 * (i.max_range - i.min_range), range.getOrCreateStateSet());
                    }
                }
            }

            if (GeomUtils.hasDrawables(lod.get()))
            {
                if (getOverlay())
                {
                    result = convertToOverlay(lod.get());
                }
                else
                {
                    result = lod.release();
                }

                osgUtil.Optimizer opt;
                opt.optimize(result,
                             osgUtil.Optimizer.SPATIALIZE_GROUPS |
                             osgUtil.Optimizer.STATIC_OBJECT_DETECTION |
                             osgUtil.Optimizer.SHARE_DUPLICATE_STATE);

                if (getRenderOrder() >= 0)
                {
                    string bin_name = result.getOrCreateStateSet().getBinName();
                    result.getOrCreateStateSet().setRenderBinDetails(getRenderOrder(), bin_name);
                    result.getOrCreateStateSet().setAttributeAndModes(new osg.Depth(osg.Depth.ALWAYS), osg.StateAttribute.ON);
                }

                localizeResourceReferences(result);

                if (output_file.length() > 0)
                {
                    localizeResources(osgDB.getFilePath(output_file));
                }
            }

            return(result);
        }
示例#3
0
 /**
  * Compiles a feature layer.
  *
  * @param layer
  *      Feature layer to compile
  * @param cursor
  *      Iterator over custom connection of features to compile
  * @param output_file
  *      If getLocalizeResources() == true, the compiler will localize
  *      external resources to the directory containing the specified
  *      file. This compiler does not actually write anything to the
  *      named file however.
  * @return
  *      Resulting scene graph, or NULL upon error
  */
 public Node compile(FeatureLayer layer, FeatureCursor cursor)
 {
     return(compile(layer, cursor, ""));
 }
示例#4
0
        public Node compile(FeatureLayer layer, string output_file)
        {
            FeatureCursor cursor = layer.getCursor();

            return(compile(layer, cursor, output_file));
        }
示例#5
0
 /**
  * Compiles a feature layer.
  *
  * @param layer
  *      Feature layer to compile
  * @param output_file
  *      If getLocalizeResources() == true, the compiler will localize
  *      external resources to the directory containing the specified
  *      file. This compiler does not actually write anything to the
  *      named file however.
  * @return
  *      Resulting scene graph, or NULL upon error
  */
 public Node compile(FeatureLayer layer)
 {
     return(compile(layer, null));
 }
示例#6
0
        /**
         * Creates a feature layer by connecting to a feature store.
         *
         * @param uri
         *      URI of the feature store to use as the underlying data
         *      source for this layer.
         * @return
         *      A new feature layer. Caller is responsible for deleting
         *      the return object.
         */
        public FeatureLayer createFeatureLayer(string uri)
        {
            FeatureLayer result = null;
            if (getFeatureStoreFactory() != null)
            {
                FeatureStore store = getFeatureStoreFactory().connectToFeatureStore(uri);

                if (store != null && store.isReady())
                {
                    result = new FeatureLayer(store);

            #if TODO
                    // if the store doesn't provide a spatial reference, try to load one from
                    // a PRJ file:
                    if (result != null && result.getSRS() == null)
                    {
                        if (osgDB.fileExists(uri)) // make sure it's a file:
                        {
                            string prj_file = osgDB.getNameLessExtension(uri) + ".prj";
                            fstream istream;
                            istream.open(prj_file.c_str());
                            if (istream.is_open())
                            {
                                istream.seekg(0, std.ios.end);
                                int length = istream.tellg();
                                istream.seekg(0, std.ios.beg);
                                char[] buf = new char[length];
                                istream.read(buf, length);
                                istream.close();
                                string prj = buf;
                                SpatialReference prj_srs =
                                 Registry.instance().getSRSFactory().createSRSfromWKT(prj);
                                result.setSRS(prj_srs);
                            }
                        }
                    }
            #endif
                }
            }
            return result;
        }