Original Translation [Osgearth] API Development Earth (OE Official document translator)

Source: Internet
Author: User

Original reference: Http://docs.osgearth.org/en/latest/developer/maps.html#programmatic-map-creation

I have limited translation skills ...

Loading Earth Map File

osg::node* globe = osgdb::readnodefile ("myglobe.earth");

The simplest way

API-Programmed Map creation

The basic steps for creating a map with the API are:

1. Create a Map object
2. Add the image layer and elevation layer where you think fit
3. Create a mapnode that can draw "map objects"
4. Add the Mapnode to the scene map.

You can add layers to the map at any time:

using namespaceOsgearth;using namespaceOsgearth::D Rivers; #include<osgEarth/Map>#include<osgEarth/MapNode>#include<osgEarthDrivers/tms/TMSOptions>#include<osgEarthDrivers/gdal/GDALOptions>using namespaceOsgearth;using namespaceOsgearth::D Rivers;//Create a Map and set it to geocentric to display a Globemap* map =NewMap ();//ADD an imagery layer (blue marble from a TMS source){tmsoptions TMS; Tms.url ()="http://labs.metacarta.com/wms-c/Basic.py/1.0.0/satellite/"; Imagelayer* Layer =NewImagelayer ("NASA", TMS); Map-addimagelayer (layer);}//Add an Elevationlayer (SRTM from a local GeoTiff file){gdaloptions gdal; Gdal.url ()="c:/data/srtm.tif"; Elevationlayer* Layer =NewElevationlayer ("SRTM", Gdal); Map-addelevationlayer (layer);}//Create a mapnode to render this map:mapnode* Mapnode =NewMapnode (map); .... viewer->setscenedata (Mapnode);

(Note: The Official document is OE2.4, the current API is OE2.9, time: February 7, 2017 10:27:15)

Using Mapnode at run time

Mapnode is the node that draws the map in the scene graph

If you are not using the API to create a mapnode, you need to first use the static function get to get it:

// Load the maposg::node* Loadedmodel = Osgdb::readnodefile ("mymap.earth"); // Find the Mapnodeosgearth::mapnode* mapnode = Mapnode::get(Loadedmodel);

If you have a mapnode, you can use the map:

//Add an OpenStreetMap image sourcetmsoptions Driveropt;driveropt.url ()="http://tile.openstreetmap.org/";d Riveropt.tmstype ()="Google"; imagelayeroptions layeropt ("OSM", driveropt); Layeropt.profile ()= Profileoptions ("Global-mercator"); Imagelayer* Osmlayer =NewImagelayer (layeropt); Mapnode->getmap ()->addimagelayer (Osmlayer);

Original Translation [Osgearth] API Development Earth (OE Official document translator)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.