Simple line to given lat/lon position (not drawn)

classic Classic list List threaded Threaded
4 messages Options
marcoma9023 marcoma9023
Reply | Threaded
Open this post in threaded view
|

Simple line to given lat/lon position (not drawn)

Hi,

I'm looking to draw a simple line on the earth given to point in terms of latitude/longitude/altitude, but I don't see anything.

///// Start Code //////
osgEarth::Symbology::Style shapeStyle;

osgEarth::Symbology::LineSymbol* lineStyle = shapeStyle.getOrCreate<osgEarth::Symbology::LineSymbol>();
lineStyle->stroke()->color() = osgEarth::Symbology::Color::Black;
lineStyle->stroke()->width() = 4.0f;

osg::ref_ptr<osgEarth::Symbology::LineString> line = new osgEarth::Symbology::LineString();
line->push_back(lat1, long2, 10000 );
line->push_back(lat1, long2, 10000);

osgEarth::Drivers::OGRFeatureOptions featureOptions;
featureOptions.geometry() = line;

osgEarth::Drivers::FeatureGeomModelOptions geomOptions;
geomOptions.featureOptions() = featureOptions;
geomOptions.styles() = new osgEarth::Symbology::StyleSheet();

osgEarth::ModelLayerOptions layerOptions("test line", geomOptions);
s_mapNode->getMap()->addLayer(new osgEarth::ModelLayer(layerOptions));

///// End Code //////

I tried also to convert lat/long coordinate into world coordinate:

GeoPoint mapPoint(s_mapNode->getMapSRS(), lat, long, altitude, ALTMODE_ABSOLUTE);
osg::Vec3d worldLine;
mapPoint.toWorld(worldLine);

and to pass the world coordinate to the line->push_back() function.

But I have the same result!!

Instead, If I draw a polygon like that:
osgEarth::Symbology::Polygon* polygon = new osgEarth::Symbology::Polygon();
        polygon->push_back(0, 0, 50000);
        polygon->push_back(0, 100, 50000);
        polygon->push_back(100, 100, 50000);

I can see it on the map

Which is the problem?

Thanks
--

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

Re: Simple line to given lat/lon position (not drawn)

Hi Marco,
Check out this FAQ and see if that answers your question.

http://docs.osgearth.org/en/latest/faq.html#lines-or-annotations-featurenode-etc-are-not-rendering-why
Glenn Waldron / Pelican Mapping
marcoma9023 marcoma9023
Reply | Threaded
Open this post in threaded view
|

Re: Simple line to given lat/lon position (not drawn)

Thanks Glenn,

it must be said that, to see the line, in the code I added the line lineStyle->tessellationSize() = 75000;
and now I can see it perfectly.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Simple line to given lat/lon position (not drawn)

Marco,

Excellent! I must say, I am a little embarrassed, since I just gave this very advice to another user:
http://forum.osgearth.org/Great-Circle-Interpolation-for-2D-Maps-td7593069.html

Cheers :)
Glenn Waldron / Pelican Mapping