{"id":1301,"date":"2024-09-12T07:58:52","date_gmt":"2024-09-12T07:58:52","guid":{"rendered":"https:\/\/www.gislxz.com\/?p=1301"},"modified":"2024-09-12T07:58:53","modified_gmt":"2024-09-12T07:58:53","slug":"%e4%bb%8e0%e5%bc%80%e5%a7%8b%e7%9a%84gis%e5%bc%80%e5%8f%91%e8%ae%b0%e5%bd%951","status":"publish","type":"post","link":"https:\/\/www.gislxz.com\/index.php\/2024\/09\/12\/%e4%bb%8e0%e5%bc%80%e5%a7%8b%e7%9a%84gis%e5%bc%80%e5%8f%91%e8%ae%b0%e5%bd%951\/","title":{"rendered":"\u4ece0\u5f00\u59cb\u7684GIS\u5f00\u53d1\u8bb0\u5f55(1)"},"content":{"rendered":"\n<p>\u65b0\u5efa\u4e2aQT\u5de5\u7a0b\uff0c\u4f7f\u7528git\u505a\u7248\u672c\u63a7\u5236<\/p>\n\n\n\n<p>\u505aGIS\u7cfb\u7edf\uff0c\u603b\u79bb\u4e0d\u5f00GDAL\u5e93\uff0c\u5148\u5bfc\u5165\u5e93<\/p>\n\n\n\n<p>\u4e4b\u524d\u88c5QGIS\u4e8c\u6b21\u5f00\u53d1\u73af\u5883\u7528OSGEO4W\u81ea\u52a8\u4e0b\u8f7d\u8fc7GDAL\u5e93\uff0c\u53ea\u8981\u5bfc\u5165\u4e00\u4e0b\u5c31\u884c\u4e86<\/p>\n\n\n\n<p>\u5728pro\u6587\u4ef6\u91cc\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u5bfc\u5165GDAL\u5e93\nINCLUDEPATH += D:\/coding\/OSGeo4w\/apps\/gdal-dev\/include\nLIBS += -LD:\/coding\/OSGeo4w\/apps\/gdal-dev\/lib -lgdal_i<\/code><\/pre>\n\n\n\n<p>\u4e4b\u540e\u5728\u7f16\u8bd1\u8f93\u51fa\u76ee\u5f55\u590d\u5236\u8fdb\u76f8\u5e94\u7684dll\u6587\u4ef6<\/p>\n\n\n\n<p>\u5728main\u51fd\u6570\u91cc\u6d4b\u8bd5\u4e00\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include \"mainwindow.h\"\n#include \"gdal_priv.h\"\n#include &lt;QApplication&gt;\n\nint main(int argc, char *argv&#91;])\n{\n    QApplication a(argc, argv);\n\n    \/\/CPLSetConfigOption(\"GDAL_FILENAME_IS_UTF8\", \"NO\");\n    GDALAllRegister();  \/\/ \u6ce8\u518c\u6240\u6709GDAL\u9a71\u52a8\n    \/\/ \u5c1d\u8bd5\u6253\u5f00\u4e00\u4e2a\u6570\u636e\u96c6\uff0c\u786e\u4fdd\u8fd9\u91cc\u7684\u8def\u5f84\u6307\u5411\u4e00\u4e2a\u6709\u6548\u7684\u5730\u7406\u6570\u636e\u6587\u4ef6\n    const char *pszFilename = \"E:\\\\\u5b81\u590f\\\\\u6d4b\u8bd5\u56fe\u50cf\\\\test159.tif\";  \/\/ \u66f4\u6539\u4e3a\u4f60\u7684\u6587\u4ef6\u8def\u5f84\n\n    GDALDatasetUniquePtr poDataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen(pszFilename, GA_ReadOnly)));\n\n    if (poDataset == nullptr) {\n        qDebug() &lt;&lt; \"GDAL could not open the file: \" &lt;&lt; pszFilename;\n        return 1;  \/\/ \u6587\u4ef6\u6253\u5f00\u5931\u8d25\n    } else {\n        qDebug() &lt;&lt; \"File opened successfully!\";\n        qDebug() &lt;&lt; poDataset-&gt;GetRasterCount();\n\n        \/\/ \u6253\u5370\u5730\u7406\u53d8\u6362\u4fe1\u606f\n        double adfGeoTransform&#91;6];\n        if (poDataset-&gt;GetGeoTransform(adfGeoTransform) == CE_None) {\n            qDebug() &lt;&lt; \"Origin = (\" &lt;&lt; adfGeoTransform&#91;0] &lt;&lt; \", \" &lt;&lt; adfGeoTransform&#91;3] &lt;&lt; \")\";\n            qDebug() &lt;&lt; \"Pixel Size = (\" &lt;&lt; adfGeoTransform&#91;1] &lt;&lt; \", \" &lt;&lt; adfGeoTransform&#91;5] &lt;&lt; \")\";\n        }\n    }\n\n    MainWindow w;\n    w.show();\n    return a.exec();\n}<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u62a5\u9519\u8bf4\u51fd\u6570\u672a\u5b9a\u4e49\uff0c\u7422\u78e8\u4e86\u4e00\u4e0b\u5e94\u8be5\u662f\u7f16\u8bd1\u914d\u7f6e\u7684\u95ee\u9898\uff0c\u628a\u6784\u5efa\u5957\u4ef6\u4ecemingw\u6539\u6210MSVC\u5c31\u6ca1\u95ee\u9898\u4e86<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5f00\u59cb\u5b9e\u73b0\u6700\u7b80\u5355\u7684\u77e2\u91cf\u8bfb\u53d6\u4e0e\u663e\u793a<\/p>\n\n\n\n<p>\u5148\u8bbe\u8ba1ui\uff0c\u81ea\u5b9a\u4e49\u4e00\u4e2aMapView\u7c7b\u7ee7\u627f\u81eaQGraphicsView\uff0c\u7136\u540e\u518d\u754c\u9762\u4e2d\u62c9\u4e00\u4e2aGraphics Viw\u7136\u540e\u63d0\u5347\u81f3MapView\u7c7b<\/p>\n\n\n\n<p>\u540e\u7eed\u505a\u5b8c\u6ca1\u8bb0\u5f55\uff0c\u653e\u4e2agithub\u94fe\u63a5\u5427<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/GISlxz\/drawShpwithQGraphicsView\" target=\"_blank\"  rel=\"nofollow\" >GISlxz\/drawShpwithQGraphicsView (github.com)<\/a><\/p>\n\n\n\n<p>\u4e3b\u8981\u662fQGraphicsView\u7684\u6027\u80fd\u592a\u5dee\u4e86\uff0c\u6bcf\u6b21\u6539\u53d8\u89c6\u53e3\u90fd\u8981\u91cd\u7b97\u4e00\u904d\u5750\u6807\uff0c\u5f88\u9ebb\u70e6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u5efa\u4e2aQT\u5de5\u7a0b\uff0c\u4f7f\u7528git\u505a\u7248\u672c\u63a7\u5236 \u505aGIS\u7cfb\u7edf\uff0c\u603b\u79bb\u4e0d\u5f00GDAL\u5e93\uff0c\u5148\u5bfc\u5165\u5e93 \u4e4b\u524d\u88c5QGIS\u4e8c\u6b21\u5f00\u53d1\u73af\u5883\u7528OSGEO4W\u81ea\u52a8\u4e0b &#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-1301","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\/1301","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=1301"}],"version-history":[{"count":4,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":1359,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/posts\/1301\/revisions\/1359"}],"wp:attachment":[{"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/media?parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/categories?post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gislxz.com\/index.php\/wp-json\/wp\/v2\/tags?post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}