Pseudo Code Generator

Range Marker Visualization on Map

This pseudocode outlines a function to display range markers and a radar icon on a map, centered at given coordinates. It effectively uses geometrical calculations to create concentric circles and textual markers to indicate distances.


Empty image or helper icon

Prompt

void ows_map_display::draw_range_markers(double latitude,double longitude)
{
    QString directoryPath = ":/new/prefix1/image_file/radar.png";
    QDir::setCurrent(directoryPath);

    Point centerPoint(longitude, latitude, SpatialReference::wgs84());

    // Field of View
    qreal distance = 1000000.0;
    qreal FOV = 45.0 * M_PI / 180.0;
    qreal targetDistance = distance / sin(FOV / 2);
    Viewpoint viewpoint(centerPoint, targetDistance);
    m_mapView->setViewpoint(viewpoint);

    // Draw center point
    SimpleMarkerSymbol* centerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::green), 5, this);
    Graphic* graphicCenter = new Graphic(centerPoint, centerSymbol);
    graphicCenter->setZIndex(2);
    m_graphicsOverlay->graphics()->append(graphicCenter);

    //Radar Icon
    PictureMarkerSymbol* radarSymbol = new PictureMarkerSymbol(directoryPath, this);
    radarSymbol->setWidth(40);
    radarSymbol->setHeight(40);

    // Add the radar icon at the center
    Point iconPoint(centerPoint.x(), centerPoint.y(), centerPoint.spatialReference());
    Graphic* radarGraphic = new Graphic(iconPoint, radarSymbol);
    radarGraphic->setZIndex(3);
    m_graphicsOverlay->graphics()->append(radarGraphic);

    // Draw Range Markers
    double semiMajorAxisIncrement = maxRange / number_range_markers;
    for (int i = 1; i <= number_range_markers; i++)
    {
        double semiMajorAxisLength = i * semiMajorAxisIncrement;

        GeodesicEllipseParameters parameters = GeodesicEllipseParameters();
        parameters.setCenter(Point(centerPoint));
        parameters.setGeometryType(GeometryType::Polygon);
        parameters.setSemiAxis1Length(semiMajorAxisLength);
        parameters.setSemiAxis2Length(0);
        parameters.setAxisDirection(90);
        parameters.setAngularUnit(AngularUnit(AngularUnitId::Degrees));
        parameters.setLinearUnit(LinearUnit(LinearUnitId::Kilometers));
        parameters.setMaxSegmentLength(1);
        parameters.setMaxPointCount(360);

        const Polygon ellipsePolygon = geometry_cast(GeometryEngine::ellipseGeodesic(parameters));
        SimpleLineSymbol *ellipseSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::ShortDash, QColor(Qt::green), 2, this);
        Graphic* range_graphic = new Graphic(ellipsePolygon, ellipseSymbol);
        range_graphic->attributes()->insertAttribute("type", "range_marker");
        range_graphic->setZIndex(2);
        m_graphicsOverlay->graphics()->append(range_graphic);

        // Adding Text symbols
        Envelope envelope = ellipsePolygon.extent();
        Point textPosition(envelope.center().x(), envelope.yMax(), envelope.spatialReference());

        QString rangeText = QString::number(semiMajorAxisLength) + " km";
        TextSymbol* textSymbol = new TextSymbol(rangeText, QColor(Qt::red), 10, HorizontalAlignment::Left, VerticalAlignment::Bottom, this);
        Graphic* textGraphic = new Graphic(textPosition, textSymbol);

        m_graphicsOverlay->graphics()->append(textGraphic);
    }

}

Answer

Pseudo Code: draw_range_markers

Purpose:

To display range markers on a map centered at a specified latitude and longitude, including a radar icon and concentric range markers with accompanying text.

Input:

  • latitude: Latitude of the center point.
  • longitude: Longitude of the center point.

Variables:

  • directoryPath: Path to the radar icon image.
  • centerPoint: Geographical point object representing the center.
  • distance: Initial distance for field of view.
  • FOV: Field of view angle in radians.
  • targetDistance: Distance to the target based on field of view.
  • viewpoint: Viewpoint object for the map.
  • centerSymbol: Symbol for the center point.
  • graphicCenter: Graphic object for center point.
  • radarSymbol: Symbol for the radar icon.
  • radarGraphic: Graphic object for the radar icon.
  • semiMajorAxisIncrement: Increment for semi-major axis length of range markers.
  • MaxRange: Maximum range value (Assumed preset value).
  • number_range_markers: Number of range markers (Assumed preset value).

Pseudo Code:

Function draw_range_markers(latitude, longitude):

    Set directoryPath to ":/new/prefix1/image_file/radar.png"
    Change current directory to directoryPath

    Create centerPoint as Point(longitude, latitude, SpatialReference.wgs84)

    // Calculate Field of View
    Set distance to 1000000.0
    Set FOV to 45.0 degrees in radians
    Set targetDistance to distance divided by sine(FOV / 2)
    Create viewpoint as Viewpoint(centerPoint, targetDistance)
    Set the map view's viewpoint to viewpoint

    // Draw center point
    Create centerSymbol as SimpleMarkerSymbol of Circle style, green color, size 5
    Create graphicCenter as Graphic(centerPoint, centerSymbol)
    Set ZIndex of graphicCenter to 2
    Append graphicCenter to graphics overlay

    // Draw radar icon
    Create radarSymbol as PictureMarkerSymbol with directoryPath
    Set width of radarSymbol to 40
    Set height of radarSymbol to 40
    Create radarGraphic as Graphic(centerPoint with radarSymbol)
    Set ZIndex of radarGraphic to 3
    Append radarGraphic to graphics overlay

    // Draw Range Markers
    Set semiMajorAxisIncrement to MaxRange divided by number_range_markers

    For i from 1 to number_range_markers, do:
        Set semiMajorAxisLength to i * semiMajorAxisIncrement

        Create parameters as GeodesicEllipseParameters
        Set center of parameters to centerPoint
        Set geometry type of parameters to Polygon
        Set semi-axis lengths and directions (semiMajorAxis1Length, semiMajorAxis2Length, axisDirection)
        Set angular and linear units (Degrees, Kilometers)
        Set maximum segment length and point count

        Create ellipsePolygon as the ellipse geometry based on parameters

        Create ellipseSymbol as SimpleLineSymbol of ShortDash style, green color, width 2
        Create range_graphic as Graphic(ellipsePolygon, ellipseSymbol)
        Set attribute "type" to "range_marker" in range_graphic
        Set ZIndex of range_graphic to 2
        Append range_graphic to graphics overlay

        // Adding Text symbols
        Get envelope from ellipsePolygon
        Create textPosition as the top center point of envelope

        Create rangeText as a string with semiMajorAxisLength and " km"
        Create textSymbol as TextSymbol with rangeText, red color, size 10, left alignment, bottom alignment
        Create textGraphic as Graphic(textPosition, textSymbol)

        Append textGraphic to graphics overlay

End Function

Notes:

  • Assumed constants MaxRange and number_range_markers are predefined.
  • Simplified some geometric calculations and spatial parameter settings for clarity.

This pseudo code provides a clear and logical representation of the original function, structuring the map display process in a step-by-step manner.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This pseudocode outlines a function to display range markers and a radar icon on a map, centered at given coordinates. It effectively uses geometrical calculations to create concentric circles and textual markers to indicate distances.