Beispiel #1
0
func LoLaFileName(lo, la float64) string {
	var err error
	if lo, err = LonTileDegree(lo, 0); err != nil {
		panic(err)
	}
	if la, err = LatTileDegree(la, 0); err != nil {
		panic(err)
	}
	return fmt.Sprintf("%s%02.0f%s%03.0f", coreutil.Ifstr(la < 0, "S", "N"), math.Abs(la), coreutil.Ifstr(lo < 0, "W", "E"), math.Abs(lo))
}
Beispiel #2
0
func BsonMapToObject(bmap interface{}, ptr interface{}) {
	var objPtr = reflect.ValueOf(ptr)
	var objType = objPtr.Elem()
	var objField reflect.Value
	if objType.Kind() == reflect.Struct {
		if bsonM, isBsonM := bmap.(bson.M); isBsonM {
			for mapKey, mapVal := range bsonM {
				if objField = objType.FieldByName(coreutil.Ifstr(mapKey == "_id", "Id", strings.Title(mapKey))); objField.IsValid() && objField.CanSet() {
					objField.Set(reflect.ValueOf(mapVal))
				}
			}
		}
	}
}