LuciadCPillar 2023.1.04
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
 
MgrsGridoperator= (const MgrsGrid &other) noexcept
 
MgrsGridoperator= (MgrsGrid &&other) noexcept
 

Static Public Member Functions

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

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);
MgrsGrid build() const
Returns the MGRS grid.
static Builder newBuilder()
Returns a new builder for creating a 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);
Represents a color based on RGBA (red, green, blue, alpha).
Definition: Color.h:15
static constexpr Color green()
The color green.
Definition: Color.h:52
static constexpr Color white()
The color white.
Definition: Color.h:60
static constexpr Color yellow()
The color yellow.
Definition: Color.h:92
static constexpr Color black()
The color black.
Definition: Color.h:68
static Builder newBuilder()
Returns a new builder for creating a LineStyle.
Builder & scaleMultiplier(double scaleMultiplier)
Indicates the scale multiplier to use for the MGRS grid scale ranges.
Builder & primaryLineStyle(LineStyle lineStyle)
Indicates the primary line style to use for the MGRS grid.
Builder & secondaryLineStyle(LineStyle lineStyle)
Indicates the secondary line style to use for the MGRS grid.
Builder & secondaryLabelStyle(TextStyle labelStyle)
Indicates the secondary label style to use for the MGRS grid.
Builder & tertiaryLabelStyle(TextStyle labelStyle)
Indicates the tertiary label style to use for the MGRS grid.
Builder & tertiaryLineStyle(LineStyle lineStyle)
Indicates the tertiary line style to use for the MGRS grid.
Builder & primaryLabelStyle(TextStyle labelStyle)
Indicates the primary label style to use for the MGRS grid.
The MGRS grid class represents how to visualize the MGRS grid on a map.
Definition: MgrsGrid.h:375
static Builder newBuilder()
Creates a new builder with the default values.
static Builder newBuilder()
Creates a new builder for creating a TextStyle.
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);
static constexpr Color red()
The color red.
Definition: Color.h:44
MgrsGrid build() const
Returns the MGRS grid.
AdvancedBuilder & setting(const MgrsGridSetting &gridSetting)
Includes the setting within the MGRS grid.
static AdvancedBuilder newAdvancedBuilder()
Creates a new builder with the default values.
MGRS grid setting.
Definition: MgrsGrid.h:34
static Builder newBuilder()
Creates a new builder with the default values.
@ Squares100Km
The 100 kilometer square level.
@ GridZones
The grid zone designation level.
@ Squares10Km
The 10 kilometer square level.
This class represents a map scale, a ratio of a distance on the map to the corresponding actual dista...
Definition: MapScale.h:24
static constexpr MapScale fromDenominator(double denominator)
Creates a map scale from a denominator value.
Definition: MapScale.h:55
static const MapScale & maxZoomedOut()
The value that represents a maximally zoomed out map scale (1:inf == 0)
static const MapScale & maxZoomedIn()
The value that represents a maximally zoomed in map scale (1:0 ≈ the maximum double value)
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

◆ newAdvancedBuilder()

static 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()

static 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