{"id":1363,"date":"2024-09-15T07:02:57","date_gmt":"2024-09-15T07:02:57","guid":{"rendered":"https:\/\/www.gislxz.com\/?p=1363"},"modified":"2024-09-21T10:31:04","modified_gmt":"2024-09-21T10:31:04","slug":"osgearth%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%881%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.gislxz.com\/index.php\/2024\/09\/15\/osgearth%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%881%ef%bc%89\/","title":{"rendered":"OSGEarth\u5b66\u4e60\u7b14\u8bb0\uff081\uff09\u52a0\u8f7d\u57fa\u672c\u5730\u7406\u6570\u636e"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u73af\u5883\u914d\u7f6e<\/h2>\n\n\n\n<p>\u9996\u5148\u7f16\u8bd1OSGEarth<\/p>\n\n\n\n<p>\u7528vcpkg\u7f16\u8bd1\u5f88\u65b9\u4fbf\uff0c\u5982\u679c\u6e90\u7801\u7f16\u8bd1\u7684\u8bdd\u524d\u7f6e\u4f9d\u8d56\u5e93\u592a\u591a\u4e86\u5f88\u590d\u6742\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/yao_hou\/article\/details\/124705995\" target=\"_blank\"  rel=\"nofollow\" >C++\u7b2c\u4e09\u65b9\u5e93\u7ba1\u7406\u5de5\u5177vcpkg\u4f7f\u7528\u6559\u7a0b-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/download.csdn.net\/blog\/column\/12507341\/105827222?ydreferer=aHR0cHM6Ly93d3cuYmFpZHUuY29tL2xpbms%2FdXJsPU41bkRIUjI1N2NwTTlhdEJ0azZKdDZZMVd5ZENqZXpUaVVDOEJjMEJYeVk0aGthV2NGTFhfRkYxSUFMTUgxYXhVMldPQUVXM0RTemFGcmQxLTczeGEtbnFvOGVKT0hsOGV4c21mc2VfNWw3JndkPSZlcWlkPWVkMWE1MDBmMDIxYTg3OGIwMDAwMDAwNjY2ZTA5MmE0\" target=\"_blank\"  rel=\"nofollow\" >OSG\u7f16\u7a0b\u6307\u5357\uff1c\u4e8c\uff1e\uff1a\u5229\u7528Vcpkg\u7f16\u8bd1OSG\uff08OSGEarth\uff09_OSG\u4e09\u7ef4\u5f15\u64ce\u5165\u95e8\u53ca\u8fdb\u9636-CSDN\u4e13\u680f<\/a><\/p>\n\n\n\n<p>\u9996\u5148\u8981\u5b89\u88c5powershell 7\uff0c\u7136\u540e\u7528git clone vcpkg\uff0c\u5b89\u88c5\u5c31\u884c\u3002\u4e4b\u540e\u4e00\u952e\u914d\u7f6eosgearth\uff0c\u6700\u540e\u8981\u548cvs\u73af\u5883\u540c\u6b65\u3002<\/p>\n\n\n\n<p>\u8fd0\u884c\u6d4b\u8bd5\u4ee3\u7801\uff0c\u8e29\u4e86\u51e0\u4e2a\u5751\u3002<\/p>\n\n\n\n<p>\u4e00\u4e2a\u662fosgearth\u5e93\u91ccmath\u5934\u6587\u4ef6\u7528\u7684std::max\u548cstd::min\u548cwindows.h\u7684max\u3001min\u5b8f\u51b2\u7a81\uff0c\u8981\u5728\u5f15\u5165windows.h\u524ddefine NOMINMAX\u3002\u7b2c\u4e8c\u4e2a\u662fopengl\u5934\u6587\u4ef6\u91cd\u590d\u5f15\u5165\u7684\u95ee\u9898\uff0c\u8fd9\u5728\u4e4b\u524d\u5b66\u4e60opengl\u9047\u5230\u8fc7\u7684\u3002\u7b2c\u4e09\u662f\u8981\u628aosg plugins\u7684dll\u653e\u5230\u7f16\u8bd1\u8f93\u51fa\u76ee\u5f55\uff0c\u6b64\u5916debug\u6a21\u5f0f\u4e0bosg plugins\u7684dll\u7248\u672c\u4e0d\u4e00\u6837<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u52a0\u8f7dTMS\uff08\u5f71\u50cf&amp;\u9ad8\u7a0b\uff09\u53caGeoTIFF<\/h2>\n\n\n\n<p>\u6700\u7b80\u5355\u7684\u52a0\u8f7d\u5728\u7ebf\u5730\u56fe\u5c42 (TMS \u74e6\u7247\u5730\u56fe)\u6216\u8005\u662f\u672c\u5730geotiff\uff0c3.5\u7248\u672capi\u6539\u4e86\u5f88\u591a\uff0c\u4e0d\u662f\u539f\u6765osg::ref_ptr &lt;osgEarth::Map&gt;\u3001osgdriver\u90a3\u4e00\u5957\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define NOMINMAX\n#include &lt;windows.h&gt;\n#include &lt;GL\/gl.h&gt;\n#include &lt;osgViewer\/Viewer&gt;\n#include &lt;osgEarth\/Notify&gt;\n#include &lt;osgEarth\/EarthManipulator&gt;\n#include &lt;osgEarth\/MapNode&gt;\n#include &lt;osgEarth\/Threading&gt;\n#include &lt;osgEarth\/ShaderGenerator&gt;\n#include &lt;osgDB\/ReadFile&gt;\n#include &lt;osgGA\/TrackballManipulator&gt;\n#include &lt;osgUtil\/Optimizer&gt;\n#include &lt;iostream&gt;\n#include &lt;osgEarth\/Metrics&gt;\n#include &lt;osgEarth\/TMS&gt;\n#include &lt;osgEarth\/EarthManipulator&gt;\n#include &lt;osg\/ArgumentParser&gt;\n#include &lt;osgEarth\/GDAL&gt;\nusing namespace osgEarth;\nusing namespace osgEarth::Util;\n\n\nint main(int argc, char** argv)\n{\n    \/\/ \u521d\u59cb\u5316osgEarth\n    osgEarth::initialize();\n\n    \/\/ \u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570\n    osg::ArgumentParser args(&amp;argc, argv);\n\n    \/\/ \u521b\u5efaViewer\n    osgViewer::Viewer viewer(args);\n    viewer.setUpViewInWindow(0, 100, 1200, 800);\n    viewer.setReleaseContextAtEndOfFrameHint(false); \n\n    \/\/ \u521b\u5efa\u4e00\u4e2a\u5730\u56fe\u8282\u70b9\n    \/\/osgEarth::MapNode* mapNode = new osgEarth::MapNode();\n    osgEarth::Map* map = new osgEarth::Map();\n\n    \/\/ \u6dfb\u52a0\u5728\u7ebf\u5730\u56fe\u5c42 (TMS \u74e6\u7247\u5730\u56fe)\n    \/\/osgEarth::TMSImageLayer* imagery = new osgEarth::TMSImageLayer();\n    \/\/imagery-&gt;setURL(\"https:\/\/readymap.org\/readymap\/tiles\/1.0.0\/7\/\");\n    \/\/osgEarth::Map* map = new osgEarth::Map();\n\n    \/\/\u52a0\u8f7d\u672c\u5730geotiff\n    std::string myTifFilename = \"D:\/coding\/testdata\/world.tif\"; \n    auto gdalLayer = new osgEarth::GDALImageLayer();\n    gdalLayer-&gt;setURL(osgEarth::URI(myTifFilename));\n    map-&gt;addLayer(gdalLayer);\n\n    auto mapNode = new osgEarth::MapNode(map);\n\n    \/\/ \u8bbe\u7f6e\u573a\u666f\u6570\u636e\n    viewer.setSceneData(mapNode);\n\n    \/\/ \u8bbe\u7f6e\u5730\u7403\u7684\u64cd\u7eb5\u5668\n    viewer.setCameraManipulator(new osgEarth::EarthManipulator(args));\n\n    \/\/ \u8fd0\u884cviewer\n    return viewer.run();\n}<\/code><\/pre>\n\n\n\n<p>\u4f46\u662f\u6211\u5728\u8bd5\u56fe\u52a0\u8f7d\u672c\u5730\u9ad8\u5206\u5f71\u50cf\u65f6\u5374\u4e0d\u80fd\u6b63\u5e38\u663e\u793a\uff0c\u6709\u53ef\u80fd\u662f\u56fe\u50cf\u592a\u5927\u5374\u6ca1\u505a\u9884\u5904\u7406\uff0c\u6309\u7167\u6587\u6863\u5c1d\u8bd5\u8fdb\u884cBuild internal tiles&amp;Build overviews<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.osgearth.org\/en\/latest\/data.html\" target=\"_blank\"  rel=\"nofollow\" >Working with Data \u2014 osgEarth 3.5 documentation<\/a><\/p>\n\n\n\n<p>\u76f8\u5173\u811a\u672c\u5728.\\vcpkg\\installed\\x64-windows\\share\\bash-completion\\completions\u76ee\u5f55\u4e0b(COMPRESS=JPEG\uff0c\u4e0d\u662fJPG\uff0c\u4e0d\u77e5\u9053\u8fd9\u5b98\u65b9\u6587\u6863\u4e3a\u4ec0\u4e48\u4e0d\u66f4\u65b0\uff0c\u538b\u7f29\u5b8c\u5c0f\u4e86\u5f88\u591a)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gdal_translate -of GTiff -co TILED=YES -co COMPRESS=JPEG input.tif output.tif<\/code><\/pre>\n\n\n\n<p>\u505a\u5b8ctiles\u662f\u80fd\u663e\u793a\u4e86\uff0c\u4f46\u5185\u5b58\u7206\u70b8\uff0c\u800c\u4e14\u52a0\u8f7d\u5de8\u6162\uff0c\u518d\u505a\u4e2aBuild overviews<\/p>\n\n\n\n<p>gdaladdo --config BIGTIFF YES -r nearest D:\\coding\\testdata\\output.tif 2 4 8 16<\/p>\n\n\n\n<p>\u8fd9\u6837\u5c31\u80fd\u6b63\u5e38\u8bfb\u53d6\u4e86<\/p>\n\n\n\n<p>\u663e\u793a\u9ad8\u7a0b\u7684\u8bdd\u6bd4\u8f83\u7b80\u5355\uff0c\u4e00\u6837\u7684\u52a0\u8f7dTMS\u5c31\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>auto elevLayer2 = new TMSElevationLayer;\n    elevLayer2->setURL(osgEarth::URI(\"http:\/\/readymap.org\/readymap\/tiles\/1.0.0\/116\/\"));\n    elevLayer2->setVerticalDatum(\"egm96\");\n    map->addLayer(elevLayer2);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u52a0\u8f7dmbtiles\u548cshp<\/h2>\n\n\n\n<p>\u52a0\u8f7dmbtiles<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;osgEarth\/EarthManipulator>\n#include &lt;osgEarth\/MapNode>\n#include &lt;osgEarth\/Threading>\n#include &lt;osgEarth\/ShaderGenerator>\n#include &lt;osgDB\/ReadFile>\n#include &lt;osgGA\/TrackballManipulator>\n#include &lt;osgUtil\/Optimizer>\n#include &lt;iostream>\n#include &lt;osgEarth\/Metrics>\n#include &lt;osgEarth\/TMS>\n#include &lt;osgEarth\/EarthManipulator>\n#include &lt;osg\/ArgumentParser>\n#include &lt;osgEarth\/GDAL>\n#include &lt;osgEarth\/Notify>\n#include &lt;osgEarth\/MBTiles>\nusing namespace osgEarth;\nusing namespace osgEarth::Util;\nint main()\n{\n\t_putenv_s(\"PROJ_LIB\", \"D:\\\\coding\\\\vcpkg\\\\installed\\\\x64-windows\\\\share\\\\proj\");\n\tosgEarth::initialize();\n\t\/\/create a viewer\n\tosgViewer::Viewer viewer;\n\tviewer.setUpViewInWindow(0, 100, 800, 600);\n\t\/\/ ? why\n\tviewer.setReleaseContextAtEndOfFrameHint(false);\n\t\/\/set camera manipulator\n\tviewer.setCameraManipulator(new EarthManipulator);\n\t\/\/ Map is datamodel for collection of layers.\n\tauto rootMap = new osgEarth::Map;\n\t\/\/GeoTiff Layer\n\tstd::string worldTifFilename = \"D:\/coding\/testdata\/world.tif\";\n\tauto gdalLayer = new GDALImageLayer();\n\tgdalLayer->setURL(osgEarth::URI(worldTifFilename));\n\t\/\/mbtiles layer\n\tstd::string mbtilesFilename = \"D:\/coding\/testdata\/world_countries.mbtiles\";\n\tauto mbtLayer = new MBTilesImageLayer();\n\tmbtLayer->setURL(osgEarth::URI(mbtilesFilename));\n\tosgEarth::GeoExtent mbtExtent = mbtLayer->getExtent();\n\t\/\/ MapNode is the render or visualization of Map.\n\tosg::ref_ptr&lt;osgEarth::MapNode> rootMapNode = new osgEarth::MapNode(rootMap);\n\trootMap->addLayer(gdalLayer);\n\trootMap->addLayer(mbtLayer);\n\tviewer.setSceneData(rootMapNode);\n\t\/\/? what\n\treturn viewer.run();\n}<\/code><\/pre>\n\n\n\n<p>\u663e\u793ashp\u82b1\u4e86\u8001\u5927\u52b2\u4e86\uff0c\u4e00\u4e2a\u662fmap\u5f97\u6539\u6210osg::ref_ptr&lt;map&gt; = new Map();\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u5fc5\u987b\u662f\u8fd9\u79cd\u6307\u9488\u3002\u7b2c\u4e8c\u4e2a\u662f\u8001\u95ee\u9898\u4e86\uff0cproj.db\u7684\u7248\u672c\u95ee\u9898\uff0c\u5988\u7684\u8fd9\u4e2a\u95ee\u9898\u7ea0\u7f20\u6211\u5f88\u4e45\u4e86\uff0c\u6bcf\u6b21\u65b0\u7528\u4e00\u4e2a\u5730\u7406\u76f8\u5173\u7684\u5e93\u90fd\u4f1a\u6709\u65b0\u7684proj\u7248\u672c\u51fa\u6765\uff0c\u6211\u4e00\u5f00\u59cb\u770b\u5230\u62a5\u9519\u4e86\uff0c\u4f46\u662f\u6ca1\u5728\u610f\uff0c\u56e0\u4e3a\u6211\u89c9\u5f97\u65b0\u7248\u672c\u7684proj.db\u80fd\u517c\u5bb9\u8001\u7684\uff0c\u7ed3\u679c\u82b1\u4e86\u516d\u4e2a\u5c0f\u65f6\u624d\u6392\u67e5\u8fd9\u70b9\u3002\u3002\u3002\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u628a\u539f\u6765postgresql\u5360\u7528\u7684proj\u5e93\u7684\u5730\u5740\u9876\u6389\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u4ee3\u7801\u957f\u8fd9\u6837<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define NOMINMAX\n#include &lt;osgViewer\/Viewer>\n#include &lt;osgEarth\/Notify>\n#include &lt;osgEarth\/EarthManipulator>\n#include &lt;osgEarth\/MapNode>\n#include &lt;osgEarth\/Threading>\n#include &lt;osgEarth\/ShaderGenerator>\n#include &lt;osgDB\/ReadFile>\n#include &lt;osgGA\/TrackballManipulator>\n#include &lt;osgUtil\/Optimizer>\n#include &lt;iostream>\n#include &lt;osgEarth\/Metrics>\n#include &lt;osgEarth\/TMS>\n#include &lt;osgEarth\/EarthManipulator>\n#include &lt;osg\/ArgumentParser>\n#include &lt;osgEarth\/ExampleResources>\n#include &lt;osgEarth\/GDAL>\n#include &lt;osgEarth\/Style>\n#include &lt;osgEarth\/OGRFeatureSource>\n#include &lt;osgEarth\/FeatureModelLayer>\n#include &lt;osgEarth\/FeatureImageLayer>\n#include &lt;osgEarth\/MBTiles>\n#include &lt;osgEarth\/ContourMap>\n#include &lt;osgEarth\/GLUtils>\n#include &lt;osg\/LineWidth>\nusing namespace osgEarth;\nusing namespace osgEarth::Util;\n\nint main(int argc, char** argv)\n{\n    _putenv_s(\"PROJ_LIB\", \"D:\\\\coding\\\\vcpkg\\\\installed\\\\x64-windows\\\\share\\\\proj\");\n    \/\/ \u521d\u59cb\u5316osgEarth\n    osgEarth::initialize();\n\n    \/\/ \u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570\n    osg::ArgumentParser args(&amp;argc, argv);\n\n    \/\/\u67e5\u770b\u8be6\u7ec6\u7684\u65e5\u5fd7\n    \/\/osg::setNotifyLevel(osg::INFO);\n\n    \/\/ \u521b\u5efaViewer\n    osgViewer::Viewer viewer(args);\n    \/\/ \u8bbe\u7f6e\u5730\u7403\u7684\u64cd\u7eb5\u5668\n    viewer.setCameraManipulator(new osgEarth::EarthManipulator(args));\n    viewer.setUpViewInWindow(0, 100, 1200, 800);\n    viewer.setReleaseContextAtEndOfFrameHint(false); \n    \/\/\u8bfb\u53d6shp\u5fc5\u987b\u7528osg::ref_ptr&lt;Map>\u6307\u9488\u63a5map\u5bf9\u8c61\n    osg::ref_ptr&lt;Map> map = new Map();\n    \n    \/\/ \u6dfb\u52a0\u5728\u7ebf\u5730\u56fe\u5c42 (TMS \u74e6\u7247\u5730\u56fe)\n    osgEarth::TMSImageLayer* imagery = new osgEarth::TMSImageLayer();\n    imagery->setURL(\"https:\/\/readymap.org\/readymap\/tiles\/1.0.0\/7\/\");\n    map->addLayer(imagery);\n\n    \/\/\u6dfb\u52a0\u5728\u7ebf\u9ad8\u7a0b\n    auto elevLayer2 = new TMSElevationLayer;\n    elevLayer2->setURL(osgEarth::URI(\"http:\/\/readymap.org\/readymap\/tiles\/1.0.0\/116\/\"));\n    elevLayer2->setVerticalDatum(\"egm96\");\n    map->addLayer(elevLayer2);\n    \/\/\u7ed8\u5236\u9ad8\u7a0b\u56fe\uff08\u8272\u5f69\u5316\uff09\n    \/*ContourMapLayer::Options eOpts;\n    ContourMapLayer::Options::Stop stop0, stop1, stop2, stop3, stop4;\n    stop0.elevation = -625;\n    stop0.color = osgEarth::Color(0, 0, 0.8, 1);\n    stop1.elevation = 0.0;\n    stop1.color = osgEarth::Color(0, 0.4, 1, 1);\n    stop2.elevation = 10.0;\n    stop2.color = osgEarth::Color(0, 1, 0, 1);\n    stop3.elevation = 1000.0;\n    stop3.color = osgEarth::Color(1, 1, 0, 1);\n    stop4.elevation = 2000.0;\n    stop4.color = osgEarth::Color(1, 0, 0, 1);\n    eOpts.stops().push_back(stop0);\n    eOpts.stops().push_back(stop1);\n    eOpts.stops().push_back(stop2);\n    eOpts.stops().push_back(stop3);\n    eOpts.stops().push_back(stop4);\n    auto contour = new ContourMapLayer(eOpts);*\/\n    \n    \/\/\u6dfb\u52a0\u672c\u5730\u5c40\u90e8\u9ad8\u5206\u5f71\u50cf\uff08geotiff\uff09\n    \/*std::string myTifFilename = \"D:\/coding\/testdata\/kenli.tif\"; \n    auto gdalLayer = new osgEarth::GDALImageLayer();\n    gdalLayer->setURL(osgEarth::URI(myTifFilename));\n    map->addLayer(gdalLayer);*\/\n\n    \/\/\u6dfb\u52a0mbtiles\n    \/\/std::string mbtilesFilename = \"D:\/coding\/testdata\/world.mbtiles\"; \n    \/\/osg::ref_ptr&lt;MBTilesImageLayer> mbtLayer = new MBTilesImageLayer(); \n    \/\/mbtLayer->setURL(osgEarth::URI(mbtilesFilename));\n    \/\/map->addLayer(mbtLayer);\n\n    \/\/\u6dfb\u52a0shp\u6587\u4ef6\n    OGRFeatureSource* features = new OGRFeatureSource();\n    features->setURL(\"D:\/coding\/testdata\/world.shp\");\n    map->addLayer(features);\n    \/\/\u8bbe\u7f6estyle\n    Style style;\n    \/\/\u8bbe\u7f6e\u7ebfstyle\n    LineSymbol* ls = style.getOrCreateSymbol&lt;LineSymbol>();\n    ls->stroke()->color() = Color::Yellow; \/\/\u7ebf\u8272\n    ls->stroke()->width() = 4;\/\/ \u7ebf\u5bbd\uff0c\u9ed8\u8ba4\u5355\u4f4d\u662f\u50cf\u7d20\n    ls->tessellationSize()->set(10, Units::KILOMETERS);\/\/Tessellate the line geometry such that no segment is longer than this value\n    \/\/ \u8bbe\u7f6e\u586b\u5145\u7b26\u53f7\uff08\u5982\u679c\u662f\u591a\u8fb9\u5f62\uff09\n    \/\/PolygonSymbol* polygonSymbol = style.getOrCreate&lt;PolygonSymbol>();\n    \/\/polygonSymbol->fill()->color() = Color(Color::Green, 0.5);  \/\/ \u7eff\u8272\u586b\u5145\uff0c50%\u900f\u660e\u5ea6\n    \/\/\u8bbe\u7f6e\u9ad8\u7a0bstyle\n    AltitudeSymbol* alt = style.getOrCreate&lt;AltitudeSymbol>();\n    alt->clamping() = alt->CLAMP_TO_TERRAIN;\/\/ \u8d34\u7d27\u5730\u9762\n    alt->technique() = alt->TECHNIQUE_DRAPE;\n\n    \/\/\u8bfb\u53d6shp\uff0c\u5efa\u7acb\u56fe\u5c42\u5e76\u8bbe\u7f6estyle\n    osg::ref_ptr&lt;FeatureModelLayer> shpLayer = new FeatureModelLayer();\n    shpLayer->setName(\"Shapefile Layer\");\n    shpLayer->setFeatureSource(features);\n    StyleSheet* styleSheet = new StyleSheet();\n    styleSheet->addStyle(style);\n    shpLayer->setStyleSheet(styleSheet);\n    shpLayer->getOrCreateStateSet()->addUniform(new osg::Uniform(\"oe_GL_LineStipplePattern\", (int)0xffff), osg::StateAttribute::ON);\/\/\u8fd9\u884c\u4ee3\u7801\u5f88\u91cd\u8981\u5fc5\u987b\u8bbe\u7f6eoe_GL_LineStipplePattern \u4e3a 0xffff\n    map->addLayer(shpLayer);\n\n    osg::ref_ptr&lt;osgEarth::MapNode> mapNode = new osgEarth::MapNode(map.get());\n    \/\/ \u8bbe\u7f6e\u573a\u666f\u6570\u636e\n    viewer.setSceneData(mapNode);\n    \/\/ \u8fd0\u884cviewer\n    \/\/return Metrics::run(viewer);\n    return viewer.run();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u663e\u793aWFS\u56fe\u5c42<\/h2>\n\n\n\n<p>\u5173\u4e8epostgis\u3001geoserver\u53d1\u5e03wfs\u56fe\u5c42\u4e4b\u524d\u535a\u5ba2\u6709\u8bb0\u5f55<\/p>\n\n\n\n<p>\u4f7f\u7528geoserver\u7684\u5168\u7403\u5730\u56fe\u793a\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/\u52a0\u8f7dwfs\u56fe\u5c42\n    std::string source = \"http:\/\/localhost:8084\/geoserver\/ne\/ows?\";\n    osg::ref_ptr&lt;WFSFeatureSource> wfsSource = new WFSFeatureSource;\n    wfsSource->setURL(osgEarth::URI(source));\n    wfsSource->setTypeName(\"countries\");\n    \/\/wfsSource->setOutputFormat(\"gml2\");\n    wfsSource->setOutputFormat(\"json\");\n\n    osg::ref_ptr&lt;FeatureModelLayer> wfsLayer = new FeatureModelLayer();\n    wfsLayer->setName(\"wfs Layer\");\n    wfsLayer->setFeatureSource(wfsSource);\n    map->addLayer(wfsLayer);<\/code><\/pre>\n\n\n\n<p>\u9057\u61be\u7684\u662f\u5e76\u4e0d\u80fd\u6210\u529f\u8bfb\u53d6\uff0cwfsSource\u8fd9\u6b65\u6ca1\u80fd\u8bfb\u53d6\u5230\u4efb\u4f55\u4fe1\u606f\uff0c\u770b\u4e86\u6e90\u7801\u56db\u4e2a\u5c0f\u65f6\u4e5f\u4e0d\u77e5\u9053\u95ee\u9898\u51fa\u5728\u54ea\u3002\u68c0\u67e5\u4e86\u6e90\u7801\u4e2durl\u7684\u62fc\u63a5\u65b9\u6cd5\uff0c\u6211\u80fd\u786e\u8ba4\u8fd9\u6837\u8bbe\u7f6eurl\u3001typename\u548coutputFormat\u662f\u80fd\u6b63\u786e\u62fc\u63a5\u7684\uff0c\u4f46\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6b63\u5e38\u8bfb\u53d6\u3002<\/p>\n\n\n\n<p>\u53bbgithub\u4e0a\u63d0\u4e86\u4e2adiscussion\u5e0c\u671b\u6709\u597d\u5fc3\u4eba\u6551\u6551\u3002\u8bdd\u8bf4\u6211\u76ee\u524d\u9700\u8981\u7684\u662f\u4e00\u4e2a\u80fd\u9ad8\u6027\u80fd\u52a0\u8f7d\u5927\u89c4\u6a21\u77e2\u91cf\u6570\u636e\u5e76\u6e32\u67d3\u7684\u6a21\u5f0f\uff0c\u660e\u5929\u8bd5\u4e00\u8bd5\u76f4\u63a5\u8bfb\u53d6postgis\u6216SQLite\/SpatiaLite\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u914d\u7f6e \u9996\u5148\u7f16\u8bd1OSGEarth \u7528vcpkg\u7f16\u8bd1\u5f88\u65b9\u4fbf\uff0c\u5982\u679c\u6e90\u7801\u7f16\u8bd1\u7684\u8bdd\u524d\u7f6e\u4f9d\u8d56\u5e93\u592a\u591a\u4e86\u5f88\u590d\u6742\u3002 C++\u7b2c\u4e09\u65b9\u5e93\u7ba1\u7406\u5de5\u5177vcp &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1363","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/comments?post=1363"}],"version-history":[{"count":8,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1363\/revisions"}],"predecessor-version":[{"id":1379,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1363\/revisions\/1379"}],"wp:attachment":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/media?parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/categories?post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/tags?post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}