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


C# Feature.getExtent方法代码示例

本文整理汇总了C#中Feature.getExtent方法的典型用法代码示例。如果您正苦于以下问题:C# Feature.getExtent方法的具体用法?C# Feature.getExtent怎么用?C# Feature.getExtent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Feature的用法示例。


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

示例1: applyOverlayTexturing

        protected void applyOverlayTexturing(osg.Geometry geom, Feature input, FilterEnv env)
        {
            GeoExtent tex_extent;

            if (getRasterOverlayScript() != null)
            {
                // if there's a raster script for this filter, we're applying textures per-feature:
                tex_extent = new GeoExtent(
                    input.getExtent().getSouthwest().getAbsolute(),
                    input.getExtent().getNortheast().getAbsolute());
            }
            else
            {
                // otherwise prepare the geometry for an overlay texture covering the entire working extent:
                tex_extent = env.getExtent();
            }

            float width = (float)tex_extent.getWidth();
            float height = (float)tex_extent.getHeight();

            // now visit the verts and calculate texture coordinates for each one.
            osg.Vec3Array verts = (osg.Vec3Array)(geom.getVertexArray());
            if (verts != null)
            {
                // if we are dealing with geocentric data, we will need to xform back to a real
                // projection in order to determine texture coords:
                GeoExtent tex_extent_geo;
                if (env.getInputSRS().isGeocentric())
                {
                    tex_extent_geo = new GeoExtent(
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getSouthwest()),
                        tex_extent.getSRS().getGeographicSRS().transform(tex_extent.getNortheast()));
                }

                osg.Vec2Array texcoords = new osg.Vec2Array(verts.size());
                for (int j = 0; j < verts.size(); j++)
                {
                    // xform back to raw SRS w.o. ref frame:
                    GeoPoint vert = new GeoPoint(verts[j], env.getInputSRS());
                    GeoPoint vert_map = vert.getAbsolute();
                    float tu, tv;
                    if (env.getInputSRS().isGeocentric())
                    {
                        tex_extent_geo.getSRS().transformInPlace(vert_map);
                        tu = (vert_map.X - tex_extent_geo.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent_geo.getYMin()) / height;
                    }
                    else
                    {
                        tu = (vert_map.X - tex_extent.getXMin()) / width;
                        tv = (vert_map.Y - tex_extent.getYMin()) / height;
                    }
                    (*texcoords)[j].set(tu, tv);
                }
                geom.setTexCoordArray(0, texcoords);
            }

            // if we are applying the raster per-feature, do so now.
            // TODO: deprecate? will we ever use this versus the BuildNodesFilter overlay? maybe
            if (getRasterOverlayScript() != null)
            {
                ScriptResult r = env.getScriptEngine().run(getRasterOverlayScript(), input, env);
                if (r.isValid())
                {
                    RasterResource raster = env.getSession().getResources().getRaster(r.asString());
                    if (raster != null)
                    {
                        Image image = null;
                        std.stringstream builder;
                        builder << "rtex_" << input.getOID() << ".jpg"; //TODO: dds with DXT1 compression

                        osg.StateSet raster_ss = new osg.StateSet();
                        if (raster.applyToStateSet(raster_ss.get(), tex_extent, getRasterOverlayMaxSize(), out image))
                        {
                            image.setFileName(builder.str());
                            geom.setStateSet(raster_ss.get());

                            // add this as a skin resource so the compiler can properly localize and deploy it.
                            env.getResourceCache().addSkin(raster_ss.get());
                        }
                    }
                }
                else
                {
                    env.getReport().error(r.asString());
                }
            }
        }
开发者ID:agustinsantos,项目名称:mogregis3d,代码行数:88,代码来源:BuildGeomFilter.cs

示例2: process

        protected virtual FragmentList process(Feature input, FilterEnv env)
        {
            FragmentList output;

            // the text string:
            string text;
            if (getTextScript() != null)
            {
                ScriptResult r = env.getScriptEngine().run(getTextScript(), input, env);
                if (r.isValid())
                    text = r.asString();
                else
                    env.getReport().error(r.asString());
            }

            // resolve the size:
            double font_size = 16.0;
            if (getFontSizeScript() != null)
            {
                ScriptResult r = env.getScriptEngine().run(getFontSizeScript(), input, env);
                if (r.isValid())
                    font_size = r.asDouble(font_size);
                else
                    env.getReport().error(r.asString());
            }

            // the text color:
            Vector4D color = getColorForFeature(input, env);

            // calculate the 3D centroid of the feature:
            // TODO: move this to the geoshapelist class
            Vector3D point = new Vector3D(input.getExtent().getCentroid());
            ZCalc zc;
            input.getShapes().accept(zc);
            point.z() = zc.z_count > 0 ? zc.z_sum / (double)zc.z_count : 0.0;

            // build the drawable:
            osgText.Text t = new osgText.Text();
            t.setAutoRotateToScreen(true);
            t.setCharacterSizeMode(osgText.Text.SCREEN_COORDS);
            t.setAlignment(osgText.Text.CENTER_CENTER);
            t.setText(text.c_str());
            t.setColor(color);
            t.setCharacterSize((float)font_size);
            t.setPosition(point);
            t.setBackdropType(osgText.Text.OUTLINE);
            t.setBackdropColor(osg.Vec4(0, 0, 0, 1));

            #if PENDING
            // testing the flat-label approach here:
            osg.Matrix cell2map = env.getInputSRS().getInverseReferenceFrame();
            osg.Vec3d feature_center = point * cell2map;
            feature_center.normalize();
            osg.Vec3d cell_center = osg.Vec3d(0,0,1) * cell2map;
            cell_center.normalize();
            osg.Quat q;
            q.makeRotate( cell_center, feature_center );
            t.setRotation( q );
            t.setAutoRotateToScreen( false );
            // end of flat label approach
            #endif

            if (font.valid())
            {
                t.setFont(font.get());
            }

            if (getDisableDepthTest())
            {
                t.getOrCreateStateSet().setAttribute(new osg.Depth(osg.Depth.ALWAYS, 0, 1, false), osg.StateAttribute.ON);
            }

            output.Add(new Fragment(t));

            return output;
        }
开发者ID:agustinsantos,项目名称:mogregis3d,代码行数:76,代码来源:BuildLabelsFilter.cs


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