Exemplo n.º 1
0
        static XmlElement encodeSlice(XmlDocument doc, BuildLayerSlice slice)
        {
            XmlElement e = null;

            if (slice != null)
            {
                e = doc.CreateElement("slice");
                if (slice.getMinRange() > 0)
                {
                    Property p = new Property("ignore", slice.getMinRange());
                    e.SetAttribute("min_range", p.getValue());
                }
                if (slice.getMaxRange() < float.MaxValue)
                {
                    Property p = new Property("ignore", slice.getMaxRange());
                    e.SetAttribute("max_range", p.getValue());
                }
                e.SetAttribute("graph", slice.getFilterGraph().getName());

                if (slice.getSource() != null)
                {
                    e.SetAttribute("source", slice.getSource().getName());
                }

                foreach (Property it in slice.getProperties())
                {
                    e.AppendChild(encodeProperty(doc, it));
                }

                foreach (BuildLayerSlice it in slice.getSubSlices())
                {
                    e.AppendChild(encodeSlice(doc, it));
                }
            }
            return(e);
        }
Exemplo n.º 2
0
        /*** Class methods ***************************************************/



        bool Builder.addSlicesToMapLayer(BuildLayerSliceList slices,
                                         Properties env_properties,
                                         MapLayer map_layer,
                                         ResourcePackager default_packager,
                                         uint depth,
                                         Session session,
                                         Source parent_source)
        {
            foreach (BuildLayerSlice i in slices)
            {
                BuildLayerSlice slice = i;

                if (slice.getSource() != null && !build(slice.getSource(), session))
                {
                    // osgGIS.warn()
                    //    << "Unable to build source \"" << slice.getSource().getName() << "\" or one of its dependencies."
                    //    << std.endl;
                    return(false);
                }

                Source slice_source = slice.getSource() != null?slice.getSource() : parent_source;

                ResourcePackager packager = default_packager ? default_packager.clone() : null;
                if (packager != null)
                {
                    packager.setMaxTextureSize(
                        slice.getProperties().getIntValue("max_texture_size", default_packager.getMaxTextureSize()));
                    packager.setCompressTextures(
                        slice.getProperties().getBoolValue("compress_textures", default_packager.getCompressTextures()));
                    packager.setInlineTextures(
                        slice.getProperties().getBoolValue("inline_textures", default_packager.getInlineTextures()));
                }

                if (slice_source != null)
                {
                    FeatureLayer feature_layer = Registry.instance().createFeatureLayer(
                        slice_source.getAbsoluteURI());

                    if (feature_layer == null)
                    {
                        //osgGIS.warn() << "Cannot access source \"" << slice_source.getName() << std.endl;
                        return(false);
                    }

                    map_layer.push(
                        feature_layer,
                        slice.getFilterGraph(),
                        env_properties,
                        packager.get(),
                        slice.getMinRange(),
                        slice.getMaxRange(),
                        true,
                        depth,
                        null);
                }

                // now add any sub-slice children:
                if (!addSlicesToMapLayer(slice.getSubSlices(), env_properties, map_layer, packager.get(), depth + 1, session, slice_source))
                {
                    return(false);
                }
            }

            return(true);
        }