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 ¶
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 ¶
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 ¶
LinearPalette interpolates linearly between two colors.
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 ¶
StepPalette maps discrete values to colors via a list.