LuciadCPillar 2026.0
Loading...
Searching...
No Matches
luciad::MgrsGrid Class Reference

The MGRS grid class represents how to visualize the MGRS grid on a map. More...

#include <luciad/layers/grids/mgrs/MgrsGrid.h>

Classes

class  AdvancedBuilder
 Advanced builder for a MGRS grid. More...
class  Builder
 Builder for a MGRS grid. More...

Public Member Functions

 MgrsGrid (const MgrsGrid &other)
 MgrsGrid (MgrsGrid &&other) noexcept
 ~MgrsGrid ()
const std::vector< MgrsGridSetting > & getSettings () const
 Returns the MgrsGridSettings used to create this grid.
MgrsGridoperator= (const MgrsGrid &other) noexcept
MgrsGridoperator= (MgrsGrid &&other) noexcept

Static Public Member Functions

static AdvancedBuilder newAdvancedBuilder ()
 Creates a new builder with the default values.
static Builder newBuilder ()
 Creates a new builder with the default values.

Detailed Description

The MGRS grid class represents how to visualize the MGRS grid on a map.

It combines one or more settings which determine which MGRS levels are displayed and how they are styled.

Default styling

Create a default MGRS grid with predefined scale ranges and styling.

auto mgrsGridLayer = MgrsGridLayer::newBuilder().build();
map->getLayerList()->add(mgrsGridLayer);
Default styling with tweaks

Create a default MGRS grid, with some tweaks to the default styling and scale ranges.

Color primaryColor = Color::white();
Color secondaryColor = Color::green();
Color tertiaryColor = Color::yellow();
auto primaryLabelStyle = TextStyle::newBuilder() //
.fontSize(12)
.fontName("monospace")
.textColor(primaryColor)
.haloWidth(1.0)
.haloColor(Color::black())
.build();
auto secondaryLabelStyle = TextStyle::newBuilder() //
.fontSize(14)
.fontName("monospace")
.textColor(secondaryColor)
.haloWidth(1.0)
.haloColor(Color::black())
.build();
auto tertiaryLabelStyle = TextStyle::newBuilder() //
.fontSize(16)
.fontName("monospace")
.textColor(tertiaryColor)
.haloWidth(1.0)
.haloColor(Color::black())
.build();
.primaryLineStyle(LineStyle::newBuilder().color(primaryColor).width(1.0).build())
.primaryLabelStyle(primaryLabelStyle)
.secondaryLineStyle(LineStyle::newBuilder().color(secondaryColor).width(2.0).build())
.secondaryLabelStyle(secondaryLabelStyle)
.tertiaryLineStyle(LineStyle::newBuilder().color(tertiaryColor).width(3.0).build())
.tertiaryLabelStyle(tertiaryLabelStyle)
.scaleMultiplier(1.5) // make the grid more coarse
.build();
auto mgrsGridLayer = MgrsGridLayer::newBuilder().grid(mgrsGrid).build();
map->getLayerList()->add(mgrsGridLayer);
Custom styling

Start from an empty MGRS grid and add custom scale ranges and styling for a few MGRS levels.

// Styling with completely custom scale ranges and styles
auto labelStyle = TextStyle::newBuilder() // Label style used on all levels
.fontSize(20)
.fontName("monospace")
.textColor(Color::white())
.haloColor(Color::black())
.haloWidth(1)
.build();
// Always show grid zones with thick red lines, regardless of the zoom level
.lineStyle(LineStyle::newBuilder() // Thick red line
.color(Color::red())
.width(5.0)
.build())
.labelStyle(labelStyle)
.build();
// When zoomed in far enough, show 100km grid squares in yellow.
// Hide them when zoomed in beyond the 10km grid square scale range start
MapScale startScale100Km = MapScale::fromDenominator(3'000'000.0);
MapScale startScale10Km = MapScale::fromDenominator(750'000.0);
.scaleRange(startScale100Km, startScale10Km)
.lineStyle(LineStyle::newBuilder() // Yellow line
.color(Color::yellow())
.width(3.0)
.build())
.labelStyle(labelStyle)
.build();
// When zoomed in beyond the 100km squares, show 10km squares in green
.scaleRange(startScale10Km, MapScale::maxZoomedIn())
.lineStyle(LineStyle::newBuilder() // Green line
.color(Color::green())
.width(2.0)
.build())
.labelStyle(labelStyle)
.build();
// Don't show any lower MGRS levels (Squares1Km, Squares100M, Squares10M and Squares1M)
.setting(gridZoneSetting) // grid zones
.setting(square100KmSetting) // 100km squares
.setting(square10KmSetting) // 10km squares
.build();
auto mgrsGridLayer = MgrsGridLayer::newBuilder().grid(mgrsGrid).build();
map->getLayerList()->add(mgrsGridLayer);
Constraints for MGRS grid

The style settings in the grid may not overlap. Overlap occurs when the new style setting has the same type, same level and an overlapping scale range with an existing style setting.

Since
2023.1

Constructor & Destructor Documentation

◆ MgrsGrid() [1/2]

luciad::MgrsGrid::MgrsGrid ( const MgrsGrid & other)

◆ MgrsGrid() [2/2]

luciad::MgrsGrid::MgrsGrid ( MgrsGrid && other)
noexcept

◆ ~MgrsGrid()

luciad::MgrsGrid::~MgrsGrid ( )

Member Function Documentation

◆ getSettings()

const std::vector< MgrsGridSetting > & luciad::MgrsGrid::getSettings ( ) const

Returns the MgrsGridSettings used to create this grid.

Returns
the settings.

◆ newAdvancedBuilder()

AdvancedBuilder luciad::MgrsGrid::newAdvancedBuilder ( )
static

Creates a new builder with the default values.

This builder allows you to configure the MGRS grid styling for every level, type, and scale range.

Returns
the new builder.

◆ newBuilder()

Builder luciad::MgrsGrid::newBuilder ( )
static

Creates a new builder with the default values.

This builder comes with pre-defined settings for MGRS levels, types, and scale ranges. It allows you to customize the styling, for example the line style to use.

Returns
the new builder.

◆ operator=() [1/2]

MgrsGrid & luciad::MgrsGrid::operator= ( const MgrsGrid & other)
noexcept

◆ operator=() [2/2]

MgrsGrid & luciad::MgrsGrid::operator= ( MgrsGrid && other)
noexcept