def mark_totem(dbmap, posx, posy, posz, width, height, rate, node, nodeempty): for y in range(posy, posy + height + 1): for x in range(posx - width, posx + width): for z in range(posz - width, posz + width): lnode = nodeempty if y - posy <= height * rate and rate > 0.0: lnode = node setblock(dbmap, Pos(x, y, z), lnode)
def lineblock(dbmap: libminetest.map.MapInterface, from_x: object, from_y: object, from_z: object, to_x: object, to_y: object, to_z: object, node: Node): """ Draw a line of bloc in the map beetween (from_x, from_y) and (to_x, to_y) at from_z altitude :param dbmap: libminetest.map.MapInterface to sqlite minetest map :param from_x: from X bloc position :param from_y: from Y bloc position :param from_z: from Z bloc position :param to_x: to X bloc position :param to_y: to Y bloc position :param to_z: to Z bloc position :param node: bloc identification to use """ point = bresenham(from_x, from_y, to_x, to_y) for pt in point: setblock(dbmap, Pos(pt[0], from_z, pt[1]), node)
def lineblock(dbmap, from_x, from_y, from_z, to_x, to_y, to_z, node): point = bresenham(from_x, from_y, to_x, to_y) for pt in point: setblock(dbmap, Pos(pt[0], from_z, pt[1]), node)
miny = 1000000 maxx = -1000000 maxy = -1000000 nbfeature = 0 solbloc = 0 start_time = time.time() print("construction du sol") chunk = 32 for zg in range(int(startbox[1]), int(endbox[1]), chunk): for xg in range(int(startbox[0]), int(endbox[0]), chunk): for z in range(zg, zg + chunk): for x in range(xg, xg + chunk): setblock(db, Pos(int(x - cx), 0, int(z - cy)), dirtnode) solbloc += 1 if solbloc % 8192 == 0: print("Z={0} blocs = {1} {2} blocs / s".format( z - cy, solbloc, solbloc / (time.time() - start_time))) db.save() for feature in testfile: #print(feature.geometry.type) #print(feature.geometry.coordinates) #print(feature.properties) nbfeature = nbfeature + 1 if (nbfeature > 1000): break
dispo = fields['nombreplacesdisponibles'] disporate = 0 if capacite > 0: disporate = dispo / capacite print(disporate * 100.0) startsignal = 1 maxsignal = 25 signal_level = 1 minetest_util.mark_totem(db, parkx, signal_level, parky, 2, 25, disporate, minetest_util.airnode, minetest_util.airnode) parkoffset = [offset[0] + parkx, offset[1] + parky, floorlevel + 30] print(parkoffset) for y in range(boundingbox[1]): for z in range(boundingbox[2]): for x in range(boundingbox[0]): lnode = minetest_util.wrednode if z <= boundingbox[2] * disporate: lnode = minetest_util.wgreennode if vol[z][x][y]: minetest_util.setblock( db, Pos(x + parkoffset[0], z + parkoffset[2], y + parkoffset[1]), minetest_util.airnode) db.save()
start_time = time.time() if (prune != 0): time.sleep(1) if create_floor > 0: print("building floor...") chunk = 32 for zg in range(int(startbox[1]), int(endbox[1]), chunk): for xg in range(int(startbox[0]), int(endbox[0]), chunk): for z in range(zg, zg + chunk): for x in range(xg, xg + chunk): if prune == 0: minetest_util.setblock( db, Pos(int(x - cx), floor_level, int(z - cy)), minetest_util.dirtnode) solbloc += 1 if solbloc % 8192 == 0: print("Z={0} blocs = {1} {2} blocs / s".format( z - cy, solbloc, solbloc / (time.time() - start_time))) if prune == 0: db.save() else: print("skip floor building") print("building shape") total_feature = len(testfile) for feature in testfile: #print(feature.geometry.type)
nids = len(ids) print(r"nb blocks") print(nids) map.close() #create block array db = libminetest.map.MapInterface (r"./map.sqlite") defnode = Node("default:stone") dirtnode = Node("default:dirt") for x in range (-100,100): print(x) for z in range (-100,100): mapblock = libminetest.utils.determineMapBlock(Pos(x,0,z)) mapblockpos = libminetest.utils.getMapBlockPos(mapblock) #print (mapblockpos) #print (type(mapblockpos)) bexist = db.check_for_pos(mapblockpos) #print (bexist) #print(type(bexist)) if not bexist: db.init_mapblock(mapblockpos) #db.init_mapblock(libminet) try: db.set_node(Pos(x,0,z), defnode) except libminetest.errors.IgnoreContentReplacementError: print ("oops")
minetest_util.wgreennode, minetest_util.wrednode) parkoffset = [offset[0] + parkx, offset[1] + parky, floorlevel + 30] print(parkoffset) for y in range(boundingbox[1]): for z in range(boundingbox[2]): for x in range(boundingbox[0]): lnode = minetest_util.wrednode if z <= boundingbox[2] * disporate and disporate > 0.0: lnode = minetest_util.wgreennode if vol[z][x][y]: minetest_util.setblock( db, Pos(x + parkoffset[0], z + parkoffset[2], y + parkoffset[1]), lnode) #display gauge gauge_rayon = 15 gaugeoffset = [parkx, parky, 31 + boundingbox[2] + 3] minetest_util.lineblock(db, int(gaugeoffset[0] - gauge_rayon), int(gaugeoffset[1]), int(gaugeoffset[2] - 1), int(gaugeoffset[0] + gauge_rayon), int(gaugeoffset[1]), int(gaugeoffset[2] - 1), minetest_util.sandnode) for angl in range(0, 180): radangl = math.radians(angl) x = math.cos(radangl) * gauge_rayon z = math.sin(radangl) * gauge_rayon y = 0
print(mappath) print(__name__) mmap = libminetest.map.MapVessel(mappath) mmap.create(mappath) ids = mmap.get_all_mapblock_ids() nids = len(ids) print(r"nb blocks") print(nids) mmap.empty_map() ids = mmap.get_all_mapblock_ids() nids = len(ids) print(r"nb blocks") print(nids) mmap.commit() mmap.close() db = libminetest.map.MapInterface(mappath) db.set_maxcachesize(2048) lineblock(db, 10, 10, 20, -10, 10, 20, dirtnode) lineblock(db, -10, 10, 20, -10, -10, 20, dirtnode) lineblock(db, -10, -10, 20, 10, -10, 20, dirtnode) lineblock(db, 10, -10, 20, 10, 10, 20, dirtnode) lineblock(db, 10, 10, 20, -10, -10, 20, defnode) for ix in range(-10, 10): for iz in range(-10, 10): setblock(db, Pos (ix, 0, iz), claynode) db.save()