Documentation ¶
Overview ¶
Example ¶
package main import ( "log" mapnik "github.com/flywave/flywave-mapnik" ) func main() { m := mapnik.New() if err := m.Load("test/map.xml"); err != nil { log.Fatal(err) } m.Resize(1000, 500) m.ZoomTo(-180, -90, 180, 90) opts := mapnik.RenderOpts{Format: "png32"} if err := m.RenderToFile(opts, "/tmp/go-mapnik-example-1.png"); err != nil { log.Fatal(err) } }
Output:
Index ¶
- Variables
- func Encode(img image.Image, format string) ([]byte, error)
- func LogSeverity(level LogLevel)
- func RegisterDatasources(path string) error
- func RegisterFonts(path string) error
- type Datasource
- type DatasourceType
- type Feature
- func NewCollectionFeature(geos []Geometry, id interface{}, prop map[string]interface{}) *Feature
- func NewFeature(geo *Geometry, id interface{}, prop map[string]interface{}) *Feature
- func NewLineFeature(l [][]float64, id interface{}, prop map[string]interface{}) *Feature
- func NewMultiLineFeature(p [][][]float64, id interface{}, prop map[string]interface{}) *Feature
- func NewMultiPointFeature(p [][]float64, id interface{}, prop map[string]interface{}) *Feature
- func NewMultiPolygonFeature(p [][][][]float64, id interface{}, prop map[string]interface{}) *Feature
- func NewPointFeature(p []float64, id interface{}, prop map[string]interface{}) *Feature
- func NewPolygonFeature(p [][][]float64, id interface{}, prop map[string]interface{}) *Feature
- type FeatureCollection
- func (fc *FeatureCollection) AddCollectionFeature(geos []Geometry, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddLineFeature(l [][]float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddMultiLineFeature(p [][][]float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddMultiPointFeature(p [][]float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddMultiPolygonFeature(p [][][][]float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddPointFeature(p []float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) AddPolygonFeature(p [][][]float64, id interface{}, prop map[string]interface{})
- func (fc *FeatureCollection) Free()
- type GeoType
- type Geometry
- func NewCollection(geos []Geometry) *Geometry
- func NewGeometry(tp GeoType) *Geometry
- func NewLine(l [][]float64) *Geometry
- func NewMultiLine(p [][][]float64) *Geometry
- func NewMultiPoint(p [][]float64) *Geometry
- func NewMultiPolygon(p [][][][]float64) *Geometry
- func NewPoint(p []float64) *Geometry
- func NewPolygon(p [][][]float64) *Geometry
- func (m *Geometry) Free()
- func (m *Geometry) SetCollection(geos []Geometry)
- func (m *Geometry) SetLine(l [][]float64)
- func (m *Geometry) SetMultiLine(l [][][]float64)
- func (m *Geometry) SetMultiPoint(p1 [][]float64)
- func (m *Geometry) SetMultiPolygon(pl [][][][]float64)
- func (m *Geometry) SetPoint(p1 []float64)
- func (m *Geometry) SetPolygon(pl [][][]float64)
- func (m *Geometry) Type() GeoType
- type Identifier
- type Layer
- func (f *Layer) AddStyle(style string)
- func (f *Layer) Free()
- func (f *Layer) GetMaxExtent() [4]float64
- func (f *Layer) GetMaxZoom() float64
- func (f *Layer) GetMinZoom() float64
- func (f *Layer) GetName() string
- func (f *Layer) GetSrs() string
- func (f *Layer) SetDatasource(ds *Datasource)
- func (f *Layer) SetMaxExtent(bbox [4]float64)
- func (f *Layer) SetMaxZoom(v float64)
- func (f *Layer) SetMinZoom(v float64)
- func (f *Layer) SetName(name string)
- func (f *Layer) SetSrs(srs string)
- func (f *Layer) SetVirtualDatasource(ds string)
- type LayerSelector
- type LogLevel
- type Map
- func (m *Map) AddLayer(l *Layer)
- func (m *Map) BackgroundColor() color.NRGBA
- func (m *Map) Free()
- func (m *Map) Load(stylesheet string) error
- func (m *Map) LoadString(str string) error
- func (m *Map) RemoveAllLayer()
- func (m *Map) Render(opts RenderOpts) ([]byte, error)
- func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error)
- func (m *Map) RenderToFile(opts RenderOpts, path string) error
- func (m *Map) RenderToMvtTile(tile *MvtTile, buffSize, tileSize uint32) error
- func (m *Map) RenderToTile(tile *Tile, buffSize, tileSize uint32) error
- func (m *Map) RenderToUtfgridTile(tile *UtfgridTile, key string, buffSize uint32) error
- func (m *Map) ResetLayers()
- func (m *Map) ResetMaxExtent()
- func (m *Map) Resize(width, height int)
- func (m *Map) SRS() string
- func (m *Map) ScaleDenominator() float64
- func (m *Map) SelectLayers(selector LayerSelector) bool
- func (m *Map) SetBackgroundColor(c color.NRGBA)
- func (m *Map) SetBufferSize(s int)
- func (m *Map) SetMaxExtent(minx, miny, maxx, maxy float64)
- func (m *Map) SetSRS(srs string)
- func (m *Map) ZoomAll() error
- func (m *Map) ZoomTo(minx, miny, maxx, maxy float64)
- type MvtTile
- type MvtTileData
- type MvtTiler
- type Property
- type Raster
- type RasterData
- type RasterTiledData
- type RasterType
- type RenderOpts
- type SelectorFunc
- type Status
- type Tile
- type TileData
- type Tiler
- type TilerGrid
- func NewGeodeticGrid(tileSize uint32, box [4]float64) *TilerGrid
- func NewGlobalGeodeticGrid(tileSize uint32) *TilerGrid
- func NewGlobalGeodeticLocalGrid(tileSize uint32, box [4]float64) *TilerGrid
- func NewGlobalMercatorGrid(tileSize uint32) *TilerGrid
- func NewGlobalMercatorLocalGrid(tileSize uint32, box [4]float64) *TilerGrid
- func NewMercatorGrid(tileSize uint32, box [4]float64) *TilerGrid
- type TilerSource
- type UtfgridTile
- type UtfgridTileData
- type UtfgridTiler
- type Vaule
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DatasourceVector = DatasourceType(C.DATASOURCE_VECTOR) DatasourceRaster = DatasourceType(C.DATASOURCE_RASTER) )
View Source
var ( UNKNOWN = GeoType(C.GEO_UNKNOWN) POINT = GeoType(C.GEO_POINT) MULTIPOINT = GeoType(C.GEO_MULTIPOINT) LINESTRING = GeoType(C.GEO_LINESTRING) MULTILINESTRING = GeoType(C.GEO_MULTILINESTRING) POLYGON = GeoType(C.GEO_POLYGON) MULTIPOLYGON = GeoType(C.GEO_MULTIPOLYGON) COLLECTION = GeoType(C.GEO_COLLECTION) )
View Source
var ( None = LogLevel(C.MAPNIK_NONE) Debug = LogLevel(C.MAPNIK_DEBUG) Warn = LogLevel(C.MAPNIK_WARN) Error = LogLevel(C.MAPNIK_ERROR) )
View Source
var ( RASTER_DTYPE_RGBA8 = RasterType(C.RASTER_DTYPE_RGBA8) RASTER_DTYPE_GRAY8 = RasterType(C.RASTER_DTYPE_GRAY8) RASTER_DTYPE_GRAY8S = RasterType(C.RASTER_DTYPE_GRAY8S) RASTER_DTYPE_GRAY16 = RasterType(C.RASTER_DTYPE_GRAY16) RASTER_DTYPE_GRAY16S = RasterType(C.RASTER_DTYPE_GRAY16S) RASTER_DTYPE_GRAY32 = RasterType(C.RASTER_DTYPE_GRAY32) RASTER_DTYPE_GRAY32S = RasterType(C.RASTER_DTYPE_GRAY32S) RASTER_DTYPE_GRAY32F = RasterType(C.RASTER_DTYPE_GRAY32F) RASTER_DTYPE_GRAY64 = RasterType(C.RASTER_DTYPE_GRAY64) RASTER_DTYPE_GRAY64S = RasterType(C.RASTER_DTYPE_GRAY64S) RASTER_DTYPE_GRAY64F = RasterType(C.RASTER_DTYPE_GRAY64F) )
View Source
var Version version
Functions ¶
func LogSeverity ¶
func LogSeverity(level LogLevel)
func RegisterDatasources ¶
func RegisterFonts ¶
Types ¶
type Datasource ¶
type Datasource struct {
// contains filtered or unexported fields
}
func NewRasterDatasource ¶
func NewRasterDatasource(rs *RasterData) *Datasource
func NewTiledRasterDatasource ¶
func NewTiledRasterDatasource(rs *RasterTiledData) *Datasource
func NewVectorDatasource ¶
func NewVectorDatasource(fc *FeatureCollection) *Datasource
func (*Datasource) Envelope ¶
func (d *Datasource) Envelope() [4]float64
func (*Datasource) Free ¶
func (d *Datasource) Free()
func (*Datasource) Type ¶
func (d *Datasource) Type() DatasourceType
type DatasourceType ¶
type DatasourceType int
type Feature ¶
type Feature struct {
// contains filtered or unexported fields
}
func NewCollectionFeature ¶
func NewFeature ¶
func NewLineFeature ¶
func NewMultiLineFeature ¶
func NewMultiPointFeature ¶
func NewMultiPolygonFeature ¶
func NewPointFeature ¶
func NewPolygonFeature ¶
type FeatureCollection ¶
type FeatureCollection struct {
// contains filtered or unexported fields
}
func NewFeatureCollection ¶
func NewFeatureCollection() *FeatureCollection
func (*FeatureCollection) AddCollectionFeature ¶
func (fc *FeatureCollection) AddCollectionFeature(geos []Geometry, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddLineFeature ¶
func (fc *FeatureCollection) AddLineFeature(l [][]float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddMultiLineFeature ¶
func (fc *FeatureCollection) AddMultiLineFeature(p [][][]float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddMultiPointFeature ¶
func (fc *FeatureCollection) AddMultiPointFeature(p [][]float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddMultiPolygonFeature ¶
func (fc *FeatureCollection) AddMultiPolygonFeature(p [][][][]float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddPointFeature ¶
func (fc *FeatureCollection) AddPointFeature(p []float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) AddPolygonFeature ¶
func (fc *FeatureCollection) AddPolygonFeature(p [][][]float64, id interface{}, prop map[string]interface{})
func (*FeatureCollection) Free ¶
func (fc *FeatureCollection) Free()
type Geometry ¶
type Geometry struct {
// contains filtered or unexported fields
}
func NewCollection ¶
func NewGeometry ¶
func NewMultiLine ¶
func NewMultiPoint ¶
func NewMultiPolygon ¶
func NewPolygon ¶
func (*Geometry) SetCollection ¶
func (*Geometry) SetMultiLine ¶
func (*Geometry) SetMultiPoint ¶
func (*Geometry) SetMultiPolygon ¶
func (*Geometry) SetPolygon ¶
type Identifier ¶
type Identifier struct {
// contains filtered or unexported fields
}
func NewIdentifier ¶
func NewIdentifier(t interface{}) *Identifier
func (*Identifier) Free ¶
func (id *Identifier) Free()
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
func (*Layer) GetMaxExtent ¶
func (*Layer) GetMaxZoom ¶
func (*Layer) GetMinZoom ¶
func (*Layer) SetDatasource ¶
func (f *Layer) SetDatasource(ds *Datasource)
func (*Layer) SetMaxExtent ¶
func (*Layer) SetMaxZoom ¶
func (*Layer) SetMinZoom ¶
func (*Layer) SetVirtualDatasource ¶
type LayerSelector ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) BackgroundColor ¶
func (*Map) LoadString ¶
func (*Map) RemoveAllLayer ¶
func (m *Map) RemoveAllLayer()
func (*Map) RenderImage ¶
func (m *Map) RenderImage(opts RenderOpts) (*image.NRGBA, error)
func (*Map) RenderToFile ¶
func (m *Map) RenderToFile(opts RenderOpts, path string) error
func (*Map) RenderToMvtTile ¶
func (*Map) RenderToUtfgridTile ¶
func (m *Map) RenderToUtfgridTile(tile *UtfgridTile, key string, buffSize uint32) error
func (*Map) ResetLayers ¶
func (m *Map) ResetLayers()
func (*Map) ResetMaxExtent ¶
func (m *Map) ResetMaxExtent()
func (*Map) ScaleDenominator ¶
func (*Map) SelectLayers ¶
func (m *Map) SelectLayers(selector LayerSelector) bool
Example (Function) ¶
package main import ( "log" mapnik "github.com/flywave/flywave-mapnik" ) func main() { m := mapnik.New() if err := m.Load("test/map.xml"); err != nil { log.Fatal(err) } selector := func(layername string) mapnik.Status { if layername == "labels" { return mapnik.Exclude } return mapnik.Default } m.SelectLayers(mapnik.SelectorFunc(selector)) opts := mapnik.RenderOpts{Format: "png32"} if err := m.RenderToFile(opts, "/tmp/go-mapnik-example-2.png"); err != nil { log.Fatal(err) } m.ResetLayers() }
Output:
func (*Map) SetBackgroundColor ¶
func (*Map) SetBufferSize ¶
func (*Map) SetMaxExtent ¶
type MvtTile ¶
type MvtTile struct {
// contains filtered or unexported fields
}
func NewMvtTile ¶
func (*MvtTile) GetAllData ¶
func (r *MvtTile) GetAllData() []*MvtTileData
type MvtTiler ¶
type MvtTiler struct {
// contains filtered or unexported fields
}
func NewMvtTiler ¶
func NewMvtTiler(map_name string, layer []string, source *TilerSource, grid *TilerGrid) *MvtTiler
func (*MvtTiler) RenderForSelect ¶
type Property ¶
type Property struct {
// contains filtered or unexported fields
}
func NewProperty ¶
type Raster ¶
type Raster struct {
// contains filtered or unexported fields
}
func (*Raster) Type ¶
func (r *Raster) Type() RasterType
type RasterData ¶
type RasterData struct {
// contains filtered or unexported fields
}
func NewRasterData ¶
func NewRasterData(width, height int, tp RasterType, data []byte, bbox [4]float64, tileSize int) *RasterData
func (*RasterData) Free ¶
func (r *RasterData) Free()
type RasterTiledData ¶
type RasterTiledData struct {
// contains filtered or unexported fields
}
func NewRasterTiledData ¶
func NewRasterTiledData(rs [][]RasterData, tileSize int) *RasterTiledData
func (*RasterTiledData) Free ¶
func (r *RasterTiledData) Free()
type RasterType ¶
type RasterType int
type RenderOpts ¶
type SelectorFunc ¶
func (SelectorFunc) Select ¶
func (f SelectorFunc) Select(layername string) Status
type Tile ¶
type Tile struct {
// contains filtered or unexported fields
}
func (*Tile) GetAllData ¶
type Tiler ¶
type Tiler struct {
// contains filtered or unexported fields
}
func NewTiler ¶
func NewTiler(map_name string, layer []string, source *TilerSource, grid *TilerGrid) *Tiler
func (*Tiler) RenderForSelect ¶
type TilerGrid ¶
type TilerGrid struct {
// contains filtered or unexported fields
}
func NewGeodeticGrid ¶
func NewGlobalGeodeticGrid ¶
func NewGlobalMercatorGrid ¶
func NewMercatorGrid ¶
type TilerSource ¶
type TilerSource struct {
// contains filtered or unexported fields
}
func NewTilerSource ¶
func NewTilerSource(maps map[string]Map) *TilerSource
func (*TilerSource) AddDatasource ¶
func (r *TilerSource) AddDatasource(name string, ds Datasource)
func (*TilerSource) Free ¶
func (r *TilerSource) Free()
type UtfgridTile ¶
type UtfgridTile struct {
// contains filtered or unexported fields
}
func NewUtfgridTile ¶
func NewUtfgridTile(x, y, z, width, height uint32) *UtfgridTile
func (*UtfgridTile) Count ¶
func (r *UtfgridTile) Count() int
func (*UtfgridTile) Free ¶
func (r *UtfgridTile) Free()
func (*UtfgridTile) GetAllData ¶
func (r *UtfgridTile) GetAllData() []*UtfgridTileData
func (*UtfgridTile) GetData ¶
func (r *UtfgridTile) GetData(i int) (*UtfgridTileData, error)
type UtfgridTiler ¶
type UtfgridTiler struct {
// contains filtered or unexported fields
}
func NewUtfgridTiler ¶
func NewUtfgridTiler(map_name string, layer []string, source *TilerSource, grid *TilerGrid) *UtfgridTiler
func (*UtfgridTiler) Free ¶
func (r *UtfgridTiler) Free()
func (*UtfgridTiler) Render ¶
func (r *UtfgridTiler) Render(start, end uint32, cb func(*UtfgridTile))
func (*UtfgridTiler) RenderForSelect ¶
func (r *UtfgridTiler) RenderForSelect(selects []uint16, cb func(*UtfgridTile))
Click to show internal directories.
Click to hide internal directories.