func drawPolygon(ctxt draw2d.GraphicContext, g *geos.Geometry, fillColor color.Color, strokeColor color.Color, width float64, scale func(x, y float64) (float64, float64)) { ctxt.SetFillColor(fillColor) ctxt.SetStrokeColor(strokeColor) ctxt.SetLineWidth(width) // exterior ring ring := geos.Must(g.ExteriorRing()) cs, err := ring.coordSeq() if err != nil { log.Fatal(err) } lineCoordSeq(ctxt, cs, scale) ctxt.FillStroke() // interior rings... }
func drawLine(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, width float64, scale func(x, y float64) (float64, float64)) { if c != nil { ctxt.SetStrokeColor(c) } if width != 0.0 { ctxt.SetLineWidth(width) } // XXX: should get a [] of points cs, err := g.coordSeq() if err != nil { log.Fatal(err) } lineCoordSeq(ctxt, cs, scale) ctxt.Stroke() }
func drawPoint(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, radius float64, scale func(x, y float64) (float64, float64)) { if c != nil { ctxt.SetFillColor(c) } x, err := g.X() if err != nil { log.Fatal(err) } y, err := g.Y() if err != nil { log.Fatal(err) } x, y = scale(x, y) ctxt.MoveTo(x, y) ctxt.ArcTo(x, y, radius, radius, 0, 2*math.Pi) ctxt.Fill() }
func envelope(g *geos.Geometry) Envelope { env, err := g.Envelope() if err != nil { log.Fatal(err) } ring, err := env.ExteriorRing() if err != nil { log.Fatal(err) } cs, err := ring.coordSeq() if err != nil { log.Fatal(err) } getX := getOrd(cs, (*geos.CoordSeq).GetX) getY := getOrd(cs, (*geos.CoordSeq).GetY) return Env(getX(0), getY(0), getX(2), getY(2)) }