github.com/prebid/prebid-server@v0.275.0/adapters/consumable/adtypes.go (about)

     1  package consumable
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"github.com/prebid/openrtb/v19/openrtb2"
     7  )
     8  
     9  /* Turn array of openrtb formats into consumable's code*/
    10  func getSizeCodes(Formats []openrtb2.Format) []int {
    11  
    12  	codes := make([]int, 0)
    13  	for _, format := range Formats {
    14  		str := strconv.FormatInt(format.W, 10) + "x" + strconv.FormatInt(format.H, 10)
    15  		if code, ok := sizeMap[str]; ok {
    16  			codes = append(codes, code)
    17  		}
    18  	}
    19  	return codes
    20  }
    21  
    22  var sizeMap = map[string]int{
    23  	"120x90": 1,
    24  	// 120x90 is in twice in prebid.js implementation - probably as spacer
    25  	"468x60":  3,
    26  	"728x90":  4,
    27  	"300x250": 5,
    28  	"160x600": 6,
    29  	"120x600": 7,
    30  	"300x100": 8,
    31  	"180x150": 9,
    32  	"336x280": 10,
    33  	"240x400": 11,
    34  	"234x60":  12,
    35  	"88x31":   13,
    36  	"120x60":  14,
    37  	"120x240": 15,
    38  	"125x125": 16,
    39  	"220x250": 17,
    40  	"250x250": 18,
    41  	"250x90":  19,
    42  	"0x0":     20, // TODO: can this be removed - I suspect it's padding in prebid.js impl
    43  	"200x90":  21,
    44  	"300x50":  22,
    45  	"320x50":  23,
    46  	"320x480": 24,
    47  	"185x185": 25,
    48  	"620x45":  26,
    49  	"300x125": 27,
    50  	"800x250": 28,
    51  	// below order is preserved from prebid.js implementation for easy comparison
    52  	"970x90":   77,
    53  	"970x250":  123,
    54  	"300x600":  43,
    55  	"970x66":   286,
    56  	"970x280":  3230,
    57  	"486x60":   429,
    58  	"700x500":  374,
    59  	"300x1050": 934,
    60  	"320x100":  1578,
    61  	"320x250":  331,
    62  	"320x267":  3301,
    63  	"728x250":  2730,
    64  }