// parses boundingBox and returns a bbox
491275
func newBbox(boundingBox string) (b bbox, err error) {
	// If it's a named bbox return that
	b, ok := namedMapBounds[boundingBox]
	if ok {
		return
	}

	s := strings.Split(boundingBox, ",")

	b.llx, err = strconv.ParseFloat(s[0], 64)
	if err != nil {
		err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
		return
	}

	b.lly, err = strconv.ParseFloat(s[1], 64)
	if err != nil {
		err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
		return
	}

	b.urx, err = strconv.ParseFloat(s[2], 64)
	if err != nil {
		err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
		return
	}

	b.ury, err = strconv.ParseFloat(s[3], 64)
	if err != nil {
		err = fmt.Errorf("Invalid boundingBox: %s", boundingBox)
		return
	}

	if b.lly < -85.0 {
		err = fmt.Errorf("bbox out of bounds %s", boundingBox)
		return
	}

	if b.ury > 85.0 {
		err = fmt.Errorf("bbox out of bounds %s", boundingBox)
		return
	}

	b.setCrosses180()

	err = b.setRegion()

	return
}
575813
func (w *Weavebox) Box(prefix string) *Box {
	b := &Box{*w}
	b.Weavebox.prefix += prefix
	return b
}
117595
func (c *Config) FindBox(boxName string) (*Box, error) {
	return findBox(boxName, c.LocateOrder)
}
438834
func (mp MultiPoint) ForceBbox() BoundingBox {
	if len(mp.Bbox) > 0 {
		return mp.Bbox
	}
	if bbox, err := NewBoundingBox(mp.Coordinates); err == nil {
		return bbox
	}
	return []float64{}
}
1301545
func (bb BoundingBox) Valid() error {
	switch len(bb) {
	case 0:
		return nil
	case 4:
		if bb[1] > bb[3] {
			return errors.New("Bounding Box values must be in south-westerly to north-easterly order.")
		}
		return nil
	case 6:
		if bb[1] > bb[4] || bb[2] > bb[5] {
			return errors.New("Bounding Box values must be in south-westerly to north-easterly order.")
		}
		return nil
	}
	return errors.New("Bounding Box must have 0, 4, or 6 values.")
}
872411
func ring(box orb.Bound, in orb.Ring) orb.Ring {
	var out orb.Ring
	if len(in) == 0 {
		return in
	}

	f := in[0]
	l := in[len(in)-1]

	initClosed := false
	if f == l {
		initClosed = true
	}

	for edge := 1; edge <= 8; edge <<= 1 {
		out = out[:0]

		loopTo := len(in)

		// if we're not a nice closed ring, don't implicitly close it.
		prev := in[loopTo-1]
		if !initClosed {
			prev = in[0]
		}

		prevInside := bitCode(box, prev)&edge == 0

		for i := 0; i < loopTo; i++ {
			p := in[i]
			inside := bitCode(box, p)&edge == 0

			// if segment goes through the clip window, add an intersection
			if inside != prevInside {
				i := intersect(box, edge, prev, p)
				out = append(out, i)
			}
			if inside {
				out = append(out, p)
			}

			prev = p
			prevInside = inside
		}

		if len(out) == 0 {
			return nil
		}

		in, out = out, in
	}
	out = in // swap back

	if initClosed {
		// need to make sure our output is also closed.
		if l := len(out); l != 0 {
			f := out[0]
			l := out[l-1]

			if f != l {
				out = append(out, f)
			}
		}
	}

	return out
}
961705
func Box(src image.Image, radius float64) *image.RGBA {
	if radius <= 0 {
		return clone.AsRGBA(src)
	}

	length := int(math.Ceil(2*radius + 1))
	k := convolution.NewKernel(length, length)

	for x := 0; x < length; x++ {
		for y := 0; y < length; y++ {
			k.Matrix[y*length+x] = 1
		}
	}

	return convolution.Convolve(src, k.Normalized(), &convolution.Options{Bias: 0, Wrap: false, KeepAlpha: false})
}
206145
func (g *GeometryCollection) Bounds() *Bounds {
	// FIXME this needs work for mixing layouts, e.g. XYZ and XYM
	b := NewBounds(g.Layout())
	for _, g := range g.geoms {
		b = b.Extend(g)
	}
	return b
}
422932
func (s *PersonDetail) SetBoundingBox(v *BoundingBox) *PersonDetail {
	s.BoundingBox = v
	return s
}
1370073
func (b Box) OuterConstrain(bounds, other Box) Box {
	newBox := b.Clone()
	if other.Top < bounds.Top {
		delta := bounds.Top - other.Top
		newBox.Top = b.Top + delta
	}

	if other.Left < bounds.Left {
		delta := bounds.Left - other.Left
		newBox.Left = b.Left + delta
	}

	if other.Right > bounds.Right {
		delta := other.Right - bounds.Right
		newBox.Right = b.Right - delta
	}

	if other.Bottom > bounds.Bottom {
		delta := other.Bottom - bounds.Bottom
		newBox.Bottom = b.Bottom - delta
	}
	return newBox
}
1131707
func NewGeoBoundingBoxQuery(tlLat, tlLon, brLat, brLon float64) *GeoBoundingBoxQuery {
	q := &GeoBoundingBoxQuery{newFtsQueryBase()}
	q.options["top_left"] = []float64{tlLon, tlLat}
	q.options["bottom_right"] = []float64{brLon, brLat}
	return q
}
200971
func (s *Face) SetBoundingBox(v *BoundingBox) *Face {
	s.BoundingBox = v
	return s
}
629753
func ParseBox(s string) (r Box, err error) {
	_, err = fmt.Sscan(s, &r.Min[0], &r.Min[1], &r.Min[2], &r.Max[0], &r.Max[1], &r.Max[2])
	return r, err
}
124721
func (point Point) ForceBbox() BoundingBox {
	if len(point.Bbox) > 0 {
		return point.Bbox
	}
	if bbox, err := NewBoundingBox(point.Coordinates); err == nil {
		return bbox
	}
	return []float64{}
}
33494
func (self *_dclStash) getBinding(name string, throw bool) Value {
	property, exists := self.property[name]
	if !exists {
		panic(fmt.Errorf("getBinding: %s: missing", name))
	}
	if !property.mutable && !property.readable {
		if throw { // strict?
			panic(self._runtime.panicTypeError())
		}
		return Value{}
	}
	return property.value
}
1134165
func (bb BoundingBox) Equals(test BoundingBox) bool {
	bblen := len(bb)
	testlen := len(test)
	if (bblen == 0) && (testlen == 0) {
		return true
	}
	if (bblen == 0) || (testlen == 0) || (bblen != testlen) {
		return false
	}
	for inx := 0; inx < bblen; inx++ {
		if bb[inx] != test[inx] {
			return false
		}
	}
	return true
}
334437
func NewBBox(b orb.Bound) BBox {
	return []float64{
		b.Min[0], b.Min[1],
		b.Max[0], b.Max[1],
	}
}