Answer the question
In order to leave comments, you need to log in
How to create a dictionary with a dictionary inside and an array inside that dictionary?
Porting code from JavaScript to Python. I can't figure out how arrays work here.
Here is the simplified Python code:
mapdata = dict()
#Непонятно, какой определять массив, ведь в нём словарь, а в словаре массив.
mapdata['tiles'] = np.zeros((width,height), ???)
for x in range(0, width):
for y in range(0, height):
mapdata['tiles'][x][y] = dict()
mapdata['tiles'][x][y]['coords'] = np.zeros((2,2), np.float32)
mapdata['tiles'][x][y]['coords'][0] = массив с 2 элементами
mapdata['tiles'][x][y]['coords'][1] = массив с 2 элементами
var mapdata = {
tiles: []
};
for (var x = 0, x2 = txy[0][0]; x < tsize.width; x++, x2++) {
mapdata.tiles[x] = [];
for (var y = 0, y2 = txy[0][1]; y < tsize.height; y++, y2++) {
mapdata.tiles[x][y] = {
coords: [
Bing.PixelXYToLatLong(x2 * 256, y2 * 256, level),// возвращает 2 элемента
Bing.PixelXYToLatLong(x2 * 256 + 255, y2 * 256 + 255, level)// возвращает 2 элемента
]
};
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question