mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 17:30:04 -05:00
Feature/geojson (#2595)
Add the option to add geojson components to globes, from geojson files. One geojson file creates one GeoJsonComponent, which in turn may contain multiple GlobeGeometryFeatures
Geojson is a format that supports points, lines, and polygons. In addition to the basic functionality, extra features have been added that will long-term allow rendering the geometry needed to represent KML files (another format for geospatial geometry data). Here are links to references for both formats:
Geojson: https://geojson.org/
KML: https://developers.google.com/kml/documentation/kmlreference
data/assets/examples/geojson includes some example files that I have used for testing. Any geojson file can also be added through drag-n-drop. Note however that you might need to change the AltitudeMode or HeightOffset properties for the feature to be visible.
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
#include <modules/globebrowsing/src/dashboarditemglobelocation.h>
|
||||
#include <modules/globebrowsing/src/gdalwrapper.h>
|
||||
#include <modules/globebrowsing/src/geodeticpatch.h>
|
||||
#include <modules/globebrowsing/src/geojson/geojsoncomponent.h>
|
||||
#include <modules/globebrowsing/src/geojson/geojsonmanager.h>
|
||||
#include <modules/globebrowsing/src/geojson/geojsonproperties.h>
|
||||
#include <modules/globebrowsing/src/globelabelscomponent.h>
|
||||
#include <modules/globebrowsing/src/globetranslation.h>
|
||||
#include <modules/globebrowsing/src/globerotation.h>
|
||||
@@ -98,6 +101,14 @@ namespace {
|
||||
openspace::properties::Property::Visibility::AdvancedUser
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo
|
||||
DefaultGeoPointTextureInfo =
|
||||
{
|
||||
"DefaultGeoPointTexture",
|
||||
"Default Geo Point Texture",
|
||||
"A path to a texture to use as default for GeoJson points"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MRFCacheEnabledInfo = {
|
||||
"MRFCacheEnabled",
|
||||
"MRF Cache Enabled",
|
||||
@@ -173,6 +184,9 @@ namespace {
|
||||
// [[codegen::verbatim(TileCacheSizeInfo.description)]]
|
||||
std::optional<int> tileCacheSize;
|
||||
|
||||
// [[codegen::verbatim(DefaultGeoPointTextureInfo.description)]]
|
||||
std::optional<std::string> defaultGeoPointTexture;
|
||||
|
||||
// [[codegen::verbatim(MRFCacheEnabledInfo.description)]]
|
||||
std::optional<bool> mrfCacheEnabled [[codegen::key("MRFCacheEnabled")]];
|
||||
|
||||
@@ -187,10 +201,14 @@ namespace openspace {
|
||||
GlobeBrowsingModule::GlobeBrowsingModule()
|
||||
: OpenSpaceModule(Name)
|
||||
, _tileCacheSizeMB(TileCacheSizeInfo, 1024)
|
||||
, _defaultGeoPointTexturePath(DefaultGeoPointTextureInfo)
|
||||
, _mrfCacheEnabled(MRFCacheEnabledInfo, false)
|
||||
, _mrfCacheLocation(MRFCacheLocationInfo, "${BASE}/cache_mrf")
|
||||
{
|
||||
addProperty(_tileCacheSizeMB);
|
||||
|
||||
addProperty(_defaultGeoPointTexturePath);
|
||||
|
||||
addProperty(_mrfCacheEnabled);
|
||||
addProperty(_mrfCacheLocation);
|
||||
}
|
||||
@@ -200,6 +218,28 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
|
||||
const Parameters p = codegen::bake<Parameters>(dict);
|
||||
_tileCacheSizeMB = p.tileCacheSize.value_or(_tileCacheSizeMB);
|
||||
|
||||
_defaultGeoPointTexturePath.onChange([this]() {
|
||||
if (_defaultGeoPointTexturePath.value().empty()) {
|
||||
_hasDefaultGeoPointTexture = false;
|
||||
return;
|
||||
}
|
||||
std::filesystem::path path = _defaultGeoPointTexturePath.value();
|
||||
if (std::filesystem::exists(path)) {
|
||||
_hasDefaultGeoPointTexture = true;
|
||||
}
|
||||
else {
|
||||
LWARNINGC("GlobeBrowsingModule", fmt::format(
|
||||
"The provided texture file {} for the default geo point texture "
|
||||
"does not exist", path
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
if (p.defaultGeoPointTexture.has_value()) {
|
||||
_defaultGeoPointTexturePath = absPath(*p.defaultGeoPointTexture).string();
|
||||
}
|
||||
|
||||
_mrfCacheEnabled = p.mrfCacheEnabled.value_or(_mrfCacheEnabled);
|
||||
_mrfCacheLocation = p.mrfCacheLocation.value_or(_mrfCacheLocation);
|
||||
|
||||
@@ -298,6 +338,9 @@ std::vector<documentation::Documentation> GlobeBrowsingModule::documentations()
|
||||
globebrowsing::TemporalTileProvider::Documentation(),
|
||||
globebrowsing::TileProviderByIndex::Documentation(),
|
||||
globebrowsing::TileProviderByLevel::Documentation(),
|
||||
globebrowsing::GeoJsonManager::Documentation(),
|
||||
globebrowsing::GeoJsonComponent::Documentation(),
|
||||
globebrowsing::GeoJsonProperties::Documentation(),
|
||||
GlobeLabelsComponent::Documentation(),
|
||||
RingsComponent::Documentation(),
|
||||
ShadowComponent::Documentation()
|
||||
@@ -634,6 +677,14 @@ const std::string GlobeBrowsingModule::mrfCacheLocation() const {
|
||||
return _mrfCacheLocation;
|
||||
}
|
||||
|
||||
bool GlobeBrowsingModule::hasDefaultGeoPointTexture() const {
|
||||
return _hasDefaultGeoPointTexture;
|
||||
}
|
||||
|
||||
std::string_view GlobeBrowsingModule::defaultGeoPointTexture() const {
|
||||
return _defaultGeoPointTexturePath;
|
||||
}
|
||||
|
||||
scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const {
|
||||
return {
|
||||
.name = "globebrowsing",
|
||||
@@ -651,7 +702,10 @@ scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const {
|
||||
codegen::lua::GetGeoPositionForCamera,
|
||||
codegen::lua::LoadWMSCapabilities,
|
||||
codegen::lua::RemoveWMSServer,
|
||||
codegen::lua::CapabilitiesWMS
|
||||
codegen::lua::CapabilitiesWMS,
|
||||
codegen::lua::AddGeoJson,
|
||||
codegen::lua::DeleteGeoJson,
|
||||
codegen::lua::AddGeoJsonFromFile
|
||||
},
|
||||
.scripts = {
|
||||
absPath("${MODULE_GLOBEBROWSING}/scripts/layer_support.lua")
|
||||
|
||||
Reference in New Issue
Block a user