MaskLayer with holes and islands

classic Classic list List threaded Threaded
6 messages Options
lher86 lher86
Reply | Threaded
Open this post in threaded view
|

MaskLayer with holes and islands

I try to introduce a MaskLayer with a geometry of a hole with some rings that represent islands. When I run the application the hole is shown but not the islands included in it.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: MaskLayer with holes and islands

Post your earth file.
Glenn Waldron / Pelican Mapping
lher86 lher86
Reply | Threaded
Open this post in threaded view
|

Re: MaskLayer with holes and islands

I do it programmatically:

                for (osg::ref_ptr<osgEarth::Symbology::Polygon> p : recs) {
                        bbox = p->getBounds();
                        sprintf_s(value, 50, "%.3f", bbox.xMin());
                        config.add("xmin", value);
                        sprintf_s(value, 50, "%.3f", bbox.xMax());
                        config.add("xmax", value);
                        sprintf_s(value, 50, "%.3f", bbox.yMin());
                        config.add("ymin", value);
                        sprintf_s(value, 50, "%.3f", bbox.yMax());
                        config.add("ymax", value);

                        sprintf(id, "Mascara terreno %d", ++i);

                        osgEarth::Drivers::OGRFeatureOptions maskOptions;
                        maskOptions.name() = id;
                        maskOptions.geometry() = p.get();
                        maskOptions.profile() = osgEarth::ProfileOptions(config);

                        osgEarth::Features::FeatureMaskLayerOptions maskLayerOptions;
                        maskLayerOptions.name() = id;
                        maskLayerOptions.featureSource() = maskOptions;
                        map->addLayer(new osgEarth::Features::FeatureMaskLayer(maskLayerOptions));
                }

Each p is a polygon that represents a hole with some rings that are islands.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: MaskLayer with holes and islands

A MaskLayer just tells the terrain engine to make holes. It does not fill the holes with anything. You have to do that yourself.

A couple other notes:

You can make a single MaskLayer that contains all your polygons. Add all of your Polygons to a MultiGeometry and use that instead. This will be faster than using a separate MaskLayer for each hole.

Never use Config objects directly. Instead use the API on the ProfileOptions class to set the bounds.

Good luck!
Glenn Waldron / Pelican Mapping
lher86 lher86
Reply | Threaded
Open this post in threaded view
|

Re: MaskLayer with holes and islands

I understand the island issue.
In relation with your advice of making a MaskLaye with one multigeometry i have to tell you that it doesn´t work. The application fails in FeatureMaskLayer::getOrCreateMaskBoundary. This is not prepare to multigeometry, in concrete in the line:

   _boundary = f->getGeometry()->createVec3dArray(); // Not works with multigeometry

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: MaskLayer with holes and islands

OK, maybe I was mistaken about the MultiGeometry. Sorry about that, it's been a while since looking at that code :)
Glenn Waldron / Pelican Mapping