// map3857 contains information for drawing map on EPSG3857
12891
func (b *bbox) newMap3857(width int) (m map3857, err error) {
	// bbox on 3857
	// tried using st_MakeEnvelope so that only needed to hit DB once
	// but it does not do what I for crossing 180
	err = db.QueryRow(`with p as (
		select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt 
		)
	select ST_X(pt), ST_Y(pt) from p;`, b.llx, b.lly).Scan(&m.llx, &m.lly)
	if err != nil {
		return
	}

	err = db.QueryRow(`with p as (
		select st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857) as pt 
		)
	select ST_X(pt), ST_Y(pt) from p;`, b.urx, b.ury).Scan(&m.urx, &m.ury)
	if err != nil {
		return
	}

	// Minimum across the top of the bbox on 3857
	// Allows for crossing 180
	var x float64
	err = db.QueryRow(`select ST_Distance(
	st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857),
	st_transform(st_setsrid(st_makepoint($3, $4), 4326), 3857)
	)`, b.llx, b.ury, b.urx, b.ury).Scan(&x)
	if err != nil {
		return
	}

	if b.crosses180 {
		m.crossesCentral = true
		x = width3857 - x
	}

	m.width = width
	m.dx = 1 / (x / float64(m.width))
	m.height = int(math.Abs(m.ury-m.lly)*m.dx) + 1

	// shift the map area into SVG view based on upper left corner.
	m.xshift = m.llx * -1
	m.yshift = m.ury * -1

	m.width = width

	m.region = b.region

	mPix := x / float64(m.width) // m per pixel

	// region 1 has higher zoom data.
	switch m.region {
	case 1:
		switch {
		case mPix < 50:
			m.zoom = 3
		case mPix < 500:
			m.zoom = 2
		case mPix < 5000.0:
			m.zoom = 1
		default:
			m.zoom = 0
		}

	case 0:
		m.zoom = 0
	}

	return
}
749736
func (s Session) sessionDataFromMap(key string) (result interface{}, err error) {
	var mapValue map[string]interface{}
	uncastMapValue, found := s[SessionMapKeyName]
	if !found {
		mapValue = map[string]interface{}{}
		s[SessionMapKeyName] = mapValue
	} else if mapValue, found = uncastMapValue.(map[string]interface{}); !found {
		// Unusual means that the value in the session was not expected
		sessionLog.Errorf("Unusual means that the value in the session was not expected", "session", uncastMapValue)
		mapValue = map[string]interface{}{}
		s[SessionMapKeyName] = mapValue
	}

	// Try to extract the key from the map
	result, found = mapValue[key]
	if !found {
		result, err = s.convertSessionData(key, nil)
		if err == nil {
			mapValue[key] = result
		}
	}
	return
}
1063167
func (ss *simpleSource) OutputMap() map[string]interface{} {
	var jsonMap map[string]interface{}
	if err := json.Unmarshal(ss.rawData, &jsonMap); err != nil {
		fmt.Println(err)
		return nil
	}
	return jsonMap
}
987741
func (iter *Iter) rowMap() (map[string]interface{}, error) {
	if iter.err != nil {
		return nil, iter.err
	}

	rowData, _ := iter.RowData()
	iter.Scan(rowData.Values...)
	m := make(map[string]interface{}, len(rowData.Columns))
	rowData.rowMap(m)
	return m, nil
}
206131
func (a *Application) QueueUpdateDraw(f func()) *Application {
	a.QueueUpdate(func() {
		f()
		a.draw()
	})
	return a
}
111808
func Int32Map(src map[string]int32) map[string]*int32 {
	dst := make(map[string]*int32)
	for k, val := range src {
		v := val
		dst[k] = &v
	}
	return dst
}
349647
func (f *regularFieldsPrinter) VisitMap(m *proto.Map) {
	m.SubType.Accept(f)
}
1280249
func UintValueMap(src map[string]*uint) map[string]uint {
	dst := make(map[string]uint)
	for k, val := range src {
		if val != nil {
			dst[k] = *val
		}
	}
	return dst
}
1056352
func MapRGB(format *PixelFormat, r, g, b uint8) uint32 {
	return uint32(C.SDL_MapRGB((*C.SDL_PixelFormat)(unsafe.Pointer(format)),
		C.Uint8(r), C.Uint8(g), C.Uint8(b)))
}
1273214
func PrintMap(m interface{}) string {
	var outputText string

	v := reflect.ValueOf(m)
	if v.Kind() != reflect.Map {
		outputText = fmt.Sprintf("error while printing map\nreceived a %T\n  %s\n", m, m)
	} else {

		keys := v.MapKeys()
		var xs []string

		for _, k := range keys {
			xs = append(xs, fmt.Sprintf("[%s]=%s", k, v.MapIndex(k)))
		}

		sort.Strings(xs)
		if len(xs) == 0 {
			outputText = "len(map) == 0"
		} else {
			outputText = strings.Join(xs, "\n")
		}
	}

	return outputText
}
103219
func (v *Validator) ErrorMap() map[string][]string {
	errMap := map[string][]string{}
	for _, vr := range v.results {
		if _, found := errMap[vr.field]; found {
			errMap[vr.field] = append(errMap[vr.field], vr.message)
		} else {
			errMap[vr.field] = []string{vr.message}
		}
	}
	return errMap
}
1321946
func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
	dst := make(map[string]uint32)
	for k, val := range src {
		if val != nil {
			dst[k] = *val
		}
	}
	return dst
}
1191168
func (v mergeStrategy) doMergeMap(e map[string]apply.Element) (apply.Result, error) {

	// Merge each item in the list
	merged := map[string]interface{}{}
	for key, value := range e {
		// Recursively merge the map element before adding the value to the map
		result, err := value.Merge(v.strategic)
		if err != nil {
			return apply.Result{}, err
		}

		switch result.Operation {
		case apply.SET:
			// Keep the map item value
			merged[key] = result.MergedResult
		case apply.DROP:
			// Drop the map item value
		default:
			panic(fmt.Errorf("Unexpected result operation type %+v", result))
		}
	}

	// Return the merged map, and tell the caller to keep it
	if len(merged) == 0 {
		// Special case the empty map to set the field value to nil, but keep the field key
		// This is how the tests expect the structures to look when parsed from yaml
		return apply.Result{Operation: apply.SET, MergedResult: nil}, nil
	}
	return apply.Result{Operation: apply.SET, MergedResult: merged}, nil
}
106947
func (c *GraphClause) BindingsMap() map[string]int {
	bm := make(map[string]int)

	addToBindings(bm, c.SBinding)
	addToBindings(bm, c.SAlias)
	addToBindings(bm, c.STypeAlias)
	addToBindings(bm, c.SIDAlias)
	addToBindings(bm, c.PAlias)
	addToBindings(bm, c.PAnchorBinding)
	addToBindings(bm, c.PBinding)
	addToBindings(bm, c.PLowerBoundAlias)
	addToBindings(bm, c.PUpperBoundAlias)
	addToBindings(bm, c.PIDAlias)
	addToBindings(bm, c.PAnchorAlias)
	addToBindings(bm, c.OBinding)
	addToBindings(bm, c.OAlias)
	addToBindings(bm, c.OTypeAlias)
	addToBindings(bm, c.OIDAlias)
	addToBindings(bm, c.OAnchorAlias)
	addToBindings(bm, c.OAnchorBinding)
	addToBindings(bm, c.OLowerBoundAlias)
	addToBindings(bm, c.OUpperBoundAlias)

	return bm
}
1075026
func ValidatorFromMap(in map[string]interface{}) (FieldValidatorFunc, error) {
	validators := make([]FieldValidatorFunc, 0)

	for name, defn := range in {
		if validator, err := GetValidator(name, defn); err == nil {
			validators = append(validators, validator)
		} else {
			return nil, fmt.Errorf("Invalid validator configuration %v: %v", name, err)
		}
	}

	return ValidateAll(validators...), nil
}
439997
func MapRGBA(format *PixelFormat, r, g, b, a uint8) uint32 {
	return uint32(C.SDL_MapRGBA((*C.SDL_PixelFormat)(unsafe.Pointer(format)),
		C.Uint8(r), C.Uint8(g), C.Uint8(b), C.Uint8(a)))
}
719917
func (c *Callbacks) OnCDOTAUserMsg_MapLine(fn func(*dota.CDOTAUserMsg_MapLine) error) {
	c.onCDOTAUserMsg_MapLine = append(c.onCDOTAUserMsg_MapLine, fn)
}