/GDALforUE5

Provides access to the GDAL/OGR API inside the Unreal Engine

Primary LanguageC++MIT LicenseMIT

UnrealGDAL: Unreal Engine GDAL plugin

This is a fork of TensorWork's UnrealGDAL Plugin, which upgrades the plugin to contemporary (UE5.3) engine versions and simplifies the dependency chain (removing ue4cli and ue4-conan) to make incorporating GDAL source builds easier.

This plugin provides access to the GDAL/OGR C++ API inside the Unreal Engine, allowing Unreal projects and plugins to easily import and manipulate geospatial data. In addition to providing access to the full GDAL/OGR C++ API surface, the plugin bundles the header-only mergetiff library for providing convenient smart pointer types, and includes interoperability functionality for accessing the GDAL/OGR API using native Unreal Engine datatypes.

Contents

Installation

Clone the repository to your Plugins directory.

Using release binaries

You can download release binaries for the plugin from the releases page, so you can simply copy the plugin directory into your project or Unreal Engine installation and start using it immediately. Release binaries are currently provided for 64-bit versions of Windows.

Building everything from source

This plugin is effectively a container for linking against GDAL, and no longer has any built-in rules for a GDAL source build. Instead, you are expected to build GDAL separately and install the binaries to the root directory of the GDAL module (Where GDAL.build.cs is contained).

GDAL should produce the following folders in your specified install directory (CMAKE_INSTALL_PREFIX):

bin/
include/
lib/
share/

Copy these directly into the GDAL module directory (or even tell CMAKE to install them there).

Any dependencies should be placed into dependencies/, with includes in dependencies/include. The number of dependencies will depend on your specific source build. The distributed build ships with PROJ, GEOS, NetCDF, libtiff, webp, zlib, libcurl, lerc and jpeg62, sourced from OSGEO.

Usage

Step 1: List the UnrealGDAL plugin as a dependency. In the descriptor file (.uproject or .uplugin) for any project or plugin which will consume the GDAL/OGR API, add the following lines:

"Plugins": [
  {
    "Name": "UnrealGDAL",
    "Enabled": true
  }
]

Step 2: List the GDAL and UnrealGDAL modules as build dependencies. In the module rules file (.Build.cs) for any C++ code module which will consume the GDAL/OGR API, add the following lines:

PublicDependencyModuleNames.AddRange(
  new string[]
  {
    "GDAL",
    "UnrealGDAL"
  }
);

Step 3: Ensure the UnrealGDAL module is loaded at startup and GDAL is correctly configured. In the source file containing the StartupModule() method of the module implementation class for any C++ code module which will consume the GDAL/OGR API, add the following lines:

//Add this line at the top of the source file
#include "UnrealGDAL.h"

//Add these lines to your StartupModule() method
void YourModuleNameGoesHere::StartupModule()
{
  FUnrealGDALModule* UnrealGDAL = FModuleManager::Get().LoadModulePtr<FUnrealGDALModule>("UnrealGDAL");
  UnrealGDAL->InitGDAL();
}

This will ensure the UnrealGDAL module is loaded into memory, all GDAL drivers are registered and GDAL is able locate its bundled data files, which are necessary for certain functionality (e.g. manipulating spatial reference systems) to work correctly. This code must be added to every C++ code module which will consume the GDAL/OGR API in order to ensure correct behaviour.

Legal

Copyright © 2020, TensorWorks Pty Ltd. Licensed under the MIT License, see the file LICENSE for details.

Binary releases of this plugin contain the following third-party libraries, which are covered by their respective licenses:

GDAL and PROJ are linked statically, whereas GEOS is linked dynamically due to the static linking requirements of the LGPL License and mergetiff is a header-only library.