programmatic model-layer example

classic Classic list List threaded Threaded
3 messages Options
FF FF
Reply | Threaded
Open this post in threaded view
|

programmatic model-layer example

Hi,
following Glenn's tips (here below)
http://n2.nabble.com/set-options-programmatically-tt4551938.html#a4551938

I'm trying to reproduce programmatically this:
<map name="Feature Geometry Demo" type="geocentric">
    <image name="world" driver="gdal">
        <url>../data/world.tif</url>
    </image>
    <model name="states" driver="feature_geom">
        <features name="states" driver="ogr">
            <url>../data/usa.shp</url>
            <ogr_driver>ESRI Shapefile</ogr_driver>
        </features>

        <geometry_type>line</geometry_type>
       
        <height_offset>10000</height_offset>
    </model>
</map>

-------------------------------
with this code:
-------------------------------

osgEarth::Map* map = new osgEarth::Map( osgEarth::Map::CSTYPE_GEOCENTRIC );

// Add an imagery layer (blue marble from a TMS source)
{
        osgEarth::Config conf;
        conf.add("url", "..\\data\\world.tif");
        osgEarth::MapLayer* layer = new osgEarth::MapLayer( "world", osgEarth::MapLayer::TYPE_IMAGE, "gdal", conf );
        map->addMapLayer( layer );
}

// create model
{
        osgEarth::Config features("features");
        features.add("driver", "ogr");
        features.add("url", "..\\data\\usa.shp");
        features.add("ogr_driver", "ESRI Shapefile");

        osgEarth::Config modelConf;
        modelConf.add("geometry_type", "line");
        modelConf.add("height_offset", "10000");
        modelConf.addChild(features);

        osgEarth::ModelLayer * model = new osgEarth::ModelLayer("states", "feature_geom", modelConf);

        map->addModelLayer(model);
}

But it only shows the map layer (world.tif) without the white vector layer that results from the model. What am I missing?
Thanks.
Fausto
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: programmatic model-layer example

Fausto,
If you can wait a day or two, I am going to check in some new code that will allow you to programmatically create layers without having to manually build Config objects.

In the meantime, try replacing
   features.add("driver", "ogr")
with
   features.attr("driver")="ogr";

and see if that works.
Glenn
Glenn Waldron / Pelican Mapping
FF FF
Reply | Threaded
Open this post in threaded view
|

Re: programmatic model-layer example

Oh great!!
Thanks Glenn.


On Thu, Feb 18, 2010 at 2:09 PM, gwaldron [via osgEarth] <[hidden email]> wrote:
Fausto,
If you can wait a day or two, I am going to check in some new code that will allow you to programmatically create layers without having to manually build Config objects.

In the meantime, try replacing
   features.add("driver", "ogr")
with
   features.attr("driver")="ogr";

and see if that works.
Glenn


View message @ http://n2.nabble.com/programmatic-model-layer-example-tp4591210p4591641.html
To unsubscribe from programmatic model-layer example, click here.