maprender

package
v0.0.0-...-83b8ea0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package maprender provides a geographic-map placeholder renderer for the go-fastreport MapObject component.

Full vector rendering requires ESRI Shapefile data that is not bundled with the library. This package renders a visually recognisable map-style image:

  • Ocean background
  • Latitude/longitude graticule grid (every 30°)
  • Equator and Prime-Meridian highlight lines
  • A simplified world-outline silhouette drawn from a small embedded polygon dataset (major continental outlines only)
  • Layer count and palette label in the corner

The output is an image.Image that callers encode to PNG and store in the report BlobStore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(opts Options) image.Image

Render returns a map-style image for the given options. Width and Height default to 400×200 when zero.

Types

type Bubble

type Bubble struct {
	Lon, Lat float64 // centre in degrees
	Value    float64 // controls radius scaling
	Color    color.NRGBA
	Label    string
}

Bubble represents a circle overlay at a geographic position.

type ChoroplethPalette

type ChoroplethPalette interface {
	Color(t float64) color.NRGBA
}

ChoroplethPalette maps a normalised value [0,1] to a color.

func NamedPalette

func NamedPalette(name string) ChoroplethPalette

NamedPalette returns a ChoroplethPalette for common palette names.

type GeoFeature

type GeoFeature struct {
	// ID is the feature identifier (optional — from properties or "id" field).
	ID string
	// Name is a human-readable name (e.g. from properties.name).
	Name string
	// Polygons holds all polygon rings for this feature.
	// Each polygon is a slice of [lon, lat] pairs (exterior ring only).
	Polygons [][][2]float64
	// Value is a numeric data value for choropleth/bubble sizing (set by caller).
	Value float64
	// BubbleLon/BubbleLat is the bubble centre (centroid if not specified).
	BubbleLon, BubbleLat float64
}

GeoFeature is a single GeoJSON Feature.

func ParseGeoJSON

func ParseGeoJSON(data []byte) ([]GeoFeature, error)

ParseGeoJSON decodes a GeoJSON FeatureCollection or Geometry string and returns the extracted features.

type Layer

type Layer struct {
	Shapefile string
	Palette   string
	Type      string // "Choropleth", "Bubble", etc.

	// GeoFeatures contains user-supplied geographic features for this layer.
	// When non-nil, the built-in continental outlines are replaced by these.
	GeoFeatures []GeoFeature

	// Bubbles is the list of bubble overlays for "Bubble" type layers.
	Bubbles []Bubble

	// ShowLegend enables a legend for this layer.
	ShowLegend bool
}

Layer carries the minimal information extracted from a MapLayer that affects how the map is rendered.

type LinearPalette

type LinearPalette struct {
	Low, High color.NRGBA
}

LinearPalette interpolates linearly between two colors.

func (*LinearPalette) Color

func (p *LinearPalette) Color(t float64) color.NRGBA

type Options

type Options struct {
	Width   int
	Height  int
	OffsetX float64 // pan offset in degrees longitude
	OffsetY float64 // pan offset in degrees latitude
	Zoom    float64 // 1.0 = full world (-180..180 × -90..90)
	Layers  []Layer
}

Options control the rendering.

type StepPalette

type StepPalette struct {
	Colors []color.NRGBA
}

StepPalette maps discrete values to colors via a list.

func (*StepPalette) Color

func (p *StepPalette) Color(t float64) color.NRGBA

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL