Documentation
¶
Overview ¶
Package topojson contains all the needed logic for converting GeoJSON from/to TopoJSON.
Implements the TopoJSON specification: https://github.com/mbostock/topojson-specification
Uses the GeoJSON implementation of paulmach: https://github.com/paulmach/go.geojson
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Geometry ¶
type Geometry struct {
ID string `json:"id,omitempty"`
Type geojson.GeometryType `json:"type"`
Properties map[string]interface{} `json:"properties,omitempty"`
BoundingBox []float64 `json:"bbox,omitempty"`
Point []float64
MultiPoint [][]float64
LineString []int
MultiLineString [][]int
Polygon [][]int
MultiPolygon [][][]int
Geometries []*Geometry
}
func (*Geometry) MarshalJSON ¶
MarshalJSON converts the geometry object into the correct JSON. This fulfills the json.Marshaler interface.
func (*Geometry) UnmarshalJSON ¶
UnmarshalJSON decodes the data into a TopoJSON geometry. This fulfills the json.Unmarshaler interface.
type Topology ¶
type Topology struct {
Type string `json:"type"`
Transform *Transform `json:"transform,omitempty"`
BoundingBox []float64 `json:"bbox,omitempty"`
Objects map[string]*Geometry `json:"objects"`
Arcs [][][]float64 `json:"arcs"`
// contains filtered or unexported fields
}
func NewTopology ¶
func NewTopology(fc *geojson.FeatureCollection, opts *TopologyOptions) *Topology
func UnmarshalTopology ¶
UnmarshalTopology decodes the data into a TopoJSON topology. Alternately one can call json.Unmarshal(topo) directly for the same result.
func (*Topology) Filter ¶
Filter topology into a new topology that only contains features with the given IDs
func (*Topology) MarshalJSON ¶
MarshalJSON converts the topology object into the proper JSON. It will handle the encoding of all the child geometries. Alternately one can call json.Marshal(t) directly for the same result.
func (*Topology) ToGeoJSON ¶
func (t *Topology) ToGeoJSON() *geojson.FeatureCollection
