### QtSimpleEarth Hello World Example Source: https://github.com/geo-linux-calculations/qtearth/blob/master/README.md This C++ code snippet demonstrates how to instantiate a WorldObject, set its label and geodetic position, and add it to the WorldObjectManager for rendering in QtSimpleEarth. It requires the WorldObject and WorldObjectManager classes, and the GeodeticPosition struct. ```cpp //instantiate world object and set label WorldObject* worldObject = new WorldObject(); worldObject->setLabel("Hello World!"); //set world object position GeodeticPosition position; position.latitude = 0.0; //in decimal degrees position.longitude = 0.0; position.altitude = 1.0; //in Km worldObject->setGeodeticPosition(position); //add world object to manager so that it gets rendered WorldObjectManager::getInstance()->addWorldObject(worldObject); ``` -------------------------------- ### Download Satellite Imagery with SatelliteImageDownloader Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Fetches satellite imagery tiles from Microsoft Bing Maps for high-resolution terrain visualization. Requires the Proj4 library. This example shows how to enable web downloads, set imagery type, enable elevation mode, and manage the download thread. ```cpp #include "SatelliteImageDownloader.h" void demonstrateSatelliteImagery() { SatelliteImageDownloader* downloader = new SatelliteImageDownloader(); // Enable web downloads downloader->setWebDownloadEnabled(true); // Set imagery type downloader->setImageryType(SatelliteImageDownloader::SATELLITE); // Options: MAP, SATELLITE, SATELLITE_WITH_ROADS // Enable elevation mode for terrain draping downloader->setElevationMode(true); // Start download thread downloader->start(); // Stop downloader when done downloader->stop(); } ``` -------------------------------- ### Build QtEarth Project with Make Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Provides instructions for building the QtEarth project using qmake and make. It outlines the basic build process and includes commented-out options for enabling features like GDAL, Proj4, and Assimp by editing the QtEarth.pro file. Finally, it shows how to run the compiled application. ```bash # Basic build with Qt qmake QtEarth.pro make # Build with optional features (edit QtEarth.pro first) # Uncomment desired CONFIG lines: # CONFIG += using_gdal # For elevation databases # CONFIG += using_proj4 # For satellite imagery # CONFIG += using_assimp # For 3D model loading # Then build: qmake QtEarth.pro make # Run the application ./QtEarth ``` -------------------------------- ### Control Camera Navigation and View (C++) Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Illustrates the functionality of the Camera singleton for controlling the OpenGL camera. It covers setting positions via geodetic coordinates, animated navigation to destinations, discrete movements, and screen-based control. Dependencies include Camera.h. Inputs range from GeodeticPosition and ScreenCoordinates to camera state queries. ```cpp #include "Camera.h" void demonstrateCameraControl() { Camera* camera = Camera::getInstance(); // Set camera position using geodetic coordinates GeodeticPosition cameraPos; cameraPos.latitude = 40.7128; cameraPos.longitude = -74.0060; cameraPos.altitude = 500.0; // 500 Km altitude camera->setGeodeticPosition(cameraPos); // Navigate to a destination point (animated) GeodeticPosition destination; destination.latitude = 34.0522; destination.longitude = -118.2437; destination.altitude = 100.0; camera->moveByDestinationPoint(destination); // Discrete keyboard-style movements camera->moveByDiscrete(Camera::SHIFT_LEFT); camera->moveByDiscrete(Camera::SHIFT_RIGHT); camera->moveByDiscrete(Camera::SHIFT_UP); camera->moveByDiscrete(Camera::SHIFT_DOWN); camera->moveByDiscrete(Camera::ZOOM_IN); camera->moveByDiscrete(Camera::ZOOM_OUT); camera->moveByDiscrete(Camera::YAW_LEFT); camera->moveByDiscrete(Camera::YAW_RIGHT); camera->moveByDiscrete(Camera::PITCH_UP); camera->moveByDiscrete(Camera::PITCH_DOWN); // Mouse/touch-based movement ScreenCoordinates startPoint, endPoint; startPoint.x = 400; startPoint.y = 300; endPoint.x = 450; endPoint.y = 320; camera->moveByScreen(startPoint, endPoint); // Toggle orbit vs perspective mode camera->setCameraOrbitMove(true); // Orbit mode (default) camera->setCameraOrbitMove(false); // Perspective mode // Set camera yaw angle camera->setYaw(45.0); // Get current camera state GeodeticPosition currentPos = camera->getGeodeticPosition(); SimpleVector lookAt = camera->getLookAt(); SimpleVector upVector = camera->getUpVector(); double yaw = camera->getYaw(); // Set screen size for calculations ScreenCoordinates screenSize; screenSize.x = 1920; screenSize.y = 1080; camera->setScreenSize(screenSize); } ``` -------------------------------- ### Read and Write Data with FileIO Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Handles reading and writing of labels, paths, and volumes to persistent storage using the FileIO class. It supports auto-detection of file types by extension or content for reading and specific types for writing. ```cpp #include "FileIO.h" void demonstrateFileIO() { FileIO fileIO; // Read data file (auto-detects type by extension/content) fileIO.readFile("/path/to/data/labels.txt"); fileIO.readFile("/path/to/data/paths.txt"); fileIO.readFile("/path/to/data/volumes.txt"); // Write labels to file fileIO.writeFile("/path/to/output/labels.txt", FileIO::LABELS_FILE); // Write paths to file fileIO.writeFile("/path/to/output/paths.txt", FileIO::PATHS_FILE); // Write volumes to file fileIO.writeFile("/path/to/output/volumes.txt", FileIO::VOLUMES_FILE); } ``` -------------------------------- ### Create World Object with Icon and 3D Model in QtSimpleEarth Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Illustrates creating a WorldObject that includes both a 2D icon and a 3D model, along with its position, rotation, and scale. This requires the Assimp library for 3D model loading. The object is configured for tracking purposes. ```cpp #include "WorldObject.h" #include "WorldObjectManager.h" // Create an object with icon and 3D model WorldObject* createIconObject() { WorldObject* obj = new WorldObject(); obj->setName("AircraftTrack001"); // Load icon (2D representation) obj->loadIcon(":/images/icons/fixedWingFriend.png"); // Load 3D model (requires Assimp library) obj->loadModel(":/models/jeep1.3ds"); // Set position GeodeticPosition position; position.latitude = 34.0522; position.longitude = -118.2437; position.altitude = 10.0; // 10 Km altitude obj->setGeodeticPosition(position); // Set rotation (in degrees) SimpleVector rotation; rotation.x = -90.0; rotation.y = 180.0; rotation.z = 0.0; obj->setRotation(rotation); // Set scale SimpleVector scale; scale.x = 1.0; scale.y = 1.0; scale.z = 1.0; obj->setScale(scale); obj->setGroup(WorldObject::TRACK); WorldObjectManager::getInstance()->addWorldObject(obj); return obj; } ``` -------------------------------- ### Manage Interactive Tools with ToolManager Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt A singleton class that manages the application's interactive tools, such as Path Tool, Volume Tool, Measuring Tool, and Label Tool. It handles tool selection, retrieval, and rendering of the currently active tool. Dependencies include ToolManager and Tool classes. ```cpp #include "ToolManager.h" #include "Tool.h" void demonstrateToolManager() { ToolManager* toolMgr = ToolManager::getInstance(); // Select a tool by ID toolMgr->selectTool("PathTool"); toolMgr->selectTool("VolumeTool"); toolMgr->selectTool("MeasuringTool"); toolMgr->selectTool("LabelTool"); // Get a specific tool Tool* pathTool = toolMgr->getTool("PathTool"); if (pathTool != NULL) { QToolButton* button = pathTool->getToolButton(); QDialog* dialog = pathTool->getDialog(); } // Render currently selected tool (called in render loop) toolMgr->renderSelectedTool(); } ``` -------------------------------- ### Create 3D Volume Shapes with VolumeRenderer Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Demonstrates creating different 3D geometric volumes (spheres, pyramids) for representing areas of interest. Requires VolumeRenderer, WorldObject, and WorldObjectManager classes. Sets volume type, position, scale, color, and attaches the renderer to a WorldObject. ```cpp #include "VolumeRenderer.h" #include "WorldObject.h" #include "WorldObjectManager.h" WorldObject* createCoverageVolume() { WorldObject* volumeObject = new WorldObject(); volumeObject->setName("RadarCoverage001"); volumeObject->setGroup(WorldObject::VOLUME); // Create volume renderer VolumeRenderer* volumeRenderer = new VolumeRenderer(); // Set volume type: SPHERE, CUBE, or PYRAMID volumeRenderer->setType(VolumeRenderer::SPHERE); // Set volume position GeodeticPosition position; position.latitude = 38.8977; position.longitude = -77.0365; position.altitude = 0.0; volumeObject->setGeodeticPosition(position); // Set volume scale (size in Km) SimpleVector scale; scale.x = 50.0; // 50 Km radius X scale.y = 50.0; // 50 Km radius Y scale.z = 20.0; // 20 Km height volumeObject->setScale(scale); // Set semi-transparent color SimpleColor volumeColor; volumeColor.red = 0.0f; volumeColor.green = 0.5f; volumeColor.blue = 1.0f; volumeColor.alpha = 0.3f; // 30% opacity volumeObject->setColor(volumeColor); // Attach renderer volumeObject->setMeshRenderer(volumeRenderer); volumeRenderer->setWorldObject(volumeObject); WorldObjectManager::getInstance()->addWorldObject(volumeObject); return volumeObject; } WorldObject* createPyramidVolume() { WorldObject* volumeObject = new WorldObject(); volumeObject->setName("SensorCone001"); volumeObject->setGroup(WorldObject::VOLUME); VolumeRenderer* volumeRenderer = new VolumeRenderer(); volumeRenderer->setType(VolumeRenderer::PYRAMID); GeodeticPosition position; position.latitude = 35.0; position.longitude = -100.0; position.altitude = 5.0; volumeObject->setGeodeticPosition(position); // Rotation for pyramid orientation SimpleVector rotation; rotation.x = 0.0; rotation.y = 0.0; rotation.z = 45.0; volumeObject->setRotation(rotation); SimpleVector scale; scale.x = 10.0; scale.y = 10.0; scale.z = 30.0; volumeObject->setScale(scale); volumeObject->setMeshRenderer(volumeRenderer); volumeRenderer->setWorldObject(volumeObject); WorldObjectManager::getInstance()->addWorldObject(volumeObject); return volumeObject; } ``` -------------------------------- ### Coordinate Conversion Functions with Utilities Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt The Utilities class offers static functions for various coordinate system transformations, including geodetic, XYZ, DMS, ECEF, and UTM. It also handles screen-world transformations and texture creation from QImage objects. Dependencies include Qt libraries for QString and QImage. ```cpp #include "Utilities.h" void demonstrateUtilities() { // Convert geodetic to XYZ (Cartesian) GeodeticPosition geoPos; geoPos.latitude = 40.7128; geoPos.longitude = -74.0060; geoPos.altitude = 0.5; SimpleVector xyz = Utilities::geodeticToXYZ(geoPos); // Convert XYZ back to geodetic GeodeticPosition converted = Utilities::xyzToGeodetic(xyz); // Convert decimal degrees to DMS string QString latDMS = Utilities::decimalDegreesToDMS(40.7128, true); // "40° 42' 46.08" N" QString lonDMS = Utilities::decimalDegreesToDMS(-74.0060, false); // "74° 0' 21.6" W" // Convert DMS string to decimal degrees double decimalLat = Utilities::dmsToDecimalDegrees("40° 42' 46.08" N"); // Convert ECEF to geodetic SimpleVector ecef; ecef.x = 1334.0; ecef.y = -4654.0; ecef.z = 4138.0; GeodeticPosition fromEcef = Utilities::ecefToGeodetic(ecef); // Convert UTM to geodetic GeodeticPosition fromUtm = Utilities::utmToGeodetic("18T 583960 4507523"); // Screen to world coordinate conversion ScreenCoordinates screenPos; screenPos.x = 500; screenPos.y = 400; SimpleVector worldPos = Utilities::screenToWorld(screenPos); // World to screen coordinate conversion SimpleVector worldCoord; worldCoord.x = 100.0; worldCoord.y = 200.0; worldCoord.z = 50.0; SimpleVector screenCoord = Utilities::worldToScreen(worldCoord); // Check if object is obscured by Earth GeodeticPosition camPos, objPos; camPos.latitude = 40.0; camPos.longitude = -74.0; camPos.altitude = 100.0; objPos.latitude = -40.0; objPos.longitude = 106.0; objPos.altitude = 0.0; bool isObscured = Utilities::checkObscure(camPos, objPos); // Convert QImage to OpenGL texture QImage image(":/images/icons/icon.jpg"); unsigned int textureId = Utilities::imageToTexture(image); } ``` -------------------------------- ### Simulate Flying Object with Qt Thread Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Demonstrates a complete threaded simulation of an object flying around the equator. It utilizes Qt's threading capabilities to update the object's position in real-time. The simulation creates a WorldObject, assigns an icon and 3D model, sets its initial geodetic position and rotation, and then enters a loop to update its longitude, simulating flight. ```cpp #include #include "WorldObject.h" #include "WorldObjectManager.h" class FlyingObjectSimulation : public QThread { public: void run() override { // Create world object with icon and model WorldObject* aircraft = new WorldObject(); aircraft->setName("SimulatedAircraft"); aircraft->loadIcon(":/images/icons/fixedWingFriend.png"); aircraft->loadModel(":/models/jeep1.3ds"); // Initial position and orientation GeodeticPosition position; position.latitude = 0.0; position.longitude = 0.0; position.altitude = 10.0; aircraft->setGeodeticPosition(position); SimpleVector rotation; rotation.x = -90.0; rotation.y = 180.0; rotation.z = 0.0; aircraft->setRotation(rotation); // Add to scene WorldObjectManager::getInstance()->addWorldObject(aircraft); // Animation loop (10 updates per second) while (true) { // Update longitude position.longitude += 0.01; if (position.longitude > 180.0) { position.longitude -= 360.0; } aircraft->setGeodeticPosition(position); msleep(100); } } }; // Usage: // FlyingObjectSimulation* sim = new FlyingObjectSimulation(); // sim->start(); ``` -------------------------------- ### Manage World Objects with WorldObjectManager (C++) Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Demonstrates the usage of WorldObjectManager, a singleton class for managing the lifecycle of WorldObjects. It covers adding, retrieving, finding, and removing objects by name or index. Dependencies include WorldObjectManager.h and WorldObject.h. The input is WorldObject pointers and names, with operations returning success status or pointers to objects. ```cpp #include "WorldObjectManager.h" #include "WorldObject.h" void demonstrateWorldObjectManager() { // Get singleton instance WorldObjectManager* manager = WorldObjectManager::getInstance(); // Add a new object WorldObject* obj = new WorldObject(); obj->setName("TrackedVehicle01"); obj->loadIcon(":/images/icons/groundVehicleFriend.png"); GeodeticPosition pos; pos.latitude = 48.8566; pos.longitude = 2.3522; pos.altitude = 0.1; obj->setGeodeticPosition(pos); bool success = manager->addWorldObject(obj); // Retrieve object by name WorldObject* retrieved = manager->getWorldObject("TrackedVehicle01"); if (retrieved != NULL) { // Update position GeodeticPosition newPos = retrieved->getGeodeticPosition(); newPos.longitude += 0.01; retrieved->setGeodeticPosition(newPos); // Reset expiration timer if expirable if (retrieved->getIsExpirable()) { retrieved->setExpirationTime(5); } } // Retrieve object by index int count = manager->getNumberOfObjects(); for (int i = 0; i < count; i++) { WorldObject* item = manager->getWorldObject(i); if (item != NULL && item->getIsVisible()) { // Process visible objects } } // Find object index by name int index = manager->findWorldObject("TrackedVehicle01"); if (index >= 0) { // Object found at index } // Remove object by name manager->removeWorldObject("TrackedVehicle01"); // Remove object by index manager->removeWorldObject(0); } ``` -------------------------------- ### Create Labeled World Object in QtSimpleEarth Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Demonstrates how to create a basic WorldObject with a name, label, type, geodetic position, and color. The object is then added to the WorldObjectManager for rendering on the globe. This is a fundamental operation for placing markers or points of interest. ```cpp #include "WorldObject.h" #include "WorldObjectManager.h" // Create a basic labeled world object WorldObject* createLabeledObject() { WorldObject* obj = new WorldObject(); // Set identifying properties obj->setName("MyUniqueObject"); obj->setLabel("Hello World!"); obj->setType("marker"); // Set geodetic position GeodeticPosition position; position.latitude = 38.8977; // Washington DC position.longitude = -77.0365; position.altitude = 1.0; // 1 Km above ground obj->setGeodeticPosition(position); // Set color (RGBA) SimpleColor color; color.red = 0.0f; color.green = 1.0f; color.blue = 0.0f; color.alpha = 1.0f; obj->setColor(color); // Set visibility obj->setIsVisible(true); obj->setIsClickable(true); // Assign to a group obj->setGroup(WorldObject::LABEL); // Add to manager for rendering WorldObjectManager::getInstance()->addWorldObject(obj); return obj; } ``` -------------------------------- ### Create Flight Paths with PathRenderer Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt The PathRenderer class is used to generate visual representations of line paths connecting multiple geographic points. These paths can signify flight routes, boundaries, or historical tracks. It utilizes the Utilities class for coordinate conversions and integrates with WorldObject and WorldObjectManager. ```cpp #include "PathRenderer.h" #include "WorldObject.h" #include "WorldObjectManager.h" #include "Utilities.h" WorldObject* createFlightPath() { WorldObject* pathObject = new WorldObject(); pathObject->setName("FlightRoute001"); pathObject->setGroup(WorldObject::PATH); // Create path renderer PathRenderer* pathRenderer = new PathRenderer(); // Add waypoints (converted from geodetic to XYZ) GeodeticPosition waypoint1, waypoint2, waypoint3; waypoint1.latitude = 40.6413; // JFK Airport waypoint1.longitude = -73.7781; waypoint1.altitude = 10.0; waypoint2.latitude = 41.9742; // Chicago O'Hare waypoint2.longitude = -87.9073; waypoint2.altitude = 12.0; waypoint3.latitude = 33.9425; // LAX waypoint3.longitude = -118.4081; waypoint3.altitude = 10.0; pathRenderer->addPoint(Utilities::geodeticToXYZ(waypoint1)); pathRenderer->addPoint(Utilities::geodeticToXYZ(waypoint2)); pathRenderer->addPoint(Utilities::geodeticToXYZ(waypoint3)); // Set path color SimpleColor pathColor; pathColor.red = 1.0f; pathColor.green = 0.0f; pathColor.blue = 0.0f; pathColor.alpha = 1.0f; pathObject->setColor(pathColor); // Attach renderer to object pathObject->setMeshRenderer(pathRenderer); pathRenderer->setWorldObject(pathObject); // Set position at first waypoint pathObject->setGeodeticPosition(waypoint1); WorldObjectManager::getInstance()->addWorldObject(pathObject); return pathObject; } ``` -------------------------------- ### Load and Query Elevation Data with ElevationManager Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt The ElevationManager class facilitates loading and querying digital terrain elevation data using the GDAL library. It requires a path to a DEM (Digital Elevation Model) file as input and can then provide elevation values for specific geographic coordinates. ```cpp #include "ElevationManager.h" void demonstrateElevationManager() { ElevationManager* elevMgr = ElevationManager::getInstance(); // Load elevation database (requires GDAL) elevMgr->loadElevationDatabase("/path/to/elevation/dem.tif"); // Query elevation at specific coordinates double latitude = 39.7392; // Denver, CO double longitude = -104.9903; float elevation = elevMgr->getElevation(latitude, longitude); // Returns elevation in Km // Use elevation for terrain-following objects WorldObject* groundVehicle = new WorldObject(); groundVehicle->setName("GroundVehicle"); GeodeticPosition pos; pos.latitude = latitude; pos.longitude = longitude; pos.altitude = elevation + 0.001; // 1 meter above terrain groundVehicle->setGeodeticPosition(pos); } ``` -------------------------------- ### Create Expirable World Object in QtSimpleEarth Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Shows how to create a WorldObject that is set to expire automatically after a specified time. This is useful for temporary markers or transient events displayed on the globe. The object is configured with an icon and position before being added to the manager. ```cpp #include "WorldObject.h" #include "WorldObjectManager.h" // Create an expirable object (auto-removes after timeout) WorldObject* createExpirableObject() { WorldObject* obj = new WorldObject(); obj->setName("TemporaryMarker"); obj->loadIcon(":/images/icons/unknown.png"); GeodeticPosition position; position.latitude = 51.5074; position.longitude = -0.1278; position.altitude = 5.0; obj->setGeodeticPosition(position); // Enable expiration obj->setIsExpirable(true); obj->setExpirationTime(5); // Expires after 5 seconds WorldObjectManager::getInstance()->addWorldObject(obj); return obj; } ``` -------------------------------- ### Define Core Data Structures for QtSimpleEarth Source: https://context7.com/geo-linux-calculations/qtearth/llms.txt Defines fundamental data structures for representing 3D positions, geodetic coordinates, screen coordinates, and RGBA colors within the QtSimpleEarth application. These structures are essential for all spatial and visual data handling. ```cpp #include "globals.h" // 3D position vector (x, y, z in Km) SimpleVector position; position.x = 100.0; position.y = 200.0; position.z = 50.0; // Geodetic position (latitude/longitude in decimal degrees, altitude in Km) GeodeticPosition geoPos; geoPos.latitude = 40.7128; // New York latitude geoPos.longitude = -74.0060; // New York longitude geoPos.altitude = 0.5; // 500 meters above ground // Screen coordinates (pixels) ScreenCoordinates screen; screen.x = 800; screen.y = 600; // RGBA color (floating point 0.0-1.0) SimpleColor color; color.red = 1.0f; color.green = 0.5f; color.blue = 0.0f; color.alpha = 1.0f; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.