Dynmap-timemachine.py

마인크래프트Dynmap 플러그인으로 생성된 웹 지도 서버에서 타일을 다운로드하고 인쇄에 적합한 매우 높은 해상도의 단일 이미지를 제작할 수 있는 Python 2.7, 3.3+ 및 PyPy 명령줄 스크립트이다.

모든 매개 변수 보기:

$ dynmap-timemachine.py -h
usage: dynmap-timemachine.py [-h] [--list-worlds] [--list-maps] [-t [THRESHOLD]] [-q] [-v]
               base_url [world] [map] [center] [boundary_size] [zoom] [dest]

positional arguments:
  base_url              Dynamp server URL
  world                 world name, use --list-worlds to list available worlds
  map                   map name, use --list-maps to list available maps
  center                minecraft cooridnates, use format: [x,y,z]
  boundary_size         size in tiles, use format: [h,v]
  zoom                  zoom level, 0 = maximum zoom
  dest                  output file name or directory

optional arguments:
  -h, --help            show this help message and exit
  --list-worlds         list available worlds from this Dynmap server and exit
  --list-maps           list available maps for this world and exit
  -t [THRESHOLD], --threshold [THRESHOLD]
                        threshold for timelapse images
  -q, --quiet
  -v, --verbose

설치

pip를 사용하면 쉽고 간편합니다.

  • $ pip install dynmap_timemachine
  • $ pip3 install dynmap_timemachine - python3

사용

다음은 플레이시티 블록에서 사용하는 설정입니다. 이를 참고하여 사용해주세요. 제작 방식의 문제로 이미지 제작에 시간이 다소 소요될 수 있습니다.

1:1 지도란, dynmap-timemachine.py 스크립트를 사용했을 때 1px = 1블록에 대응되는 이미지를 의미합니다.

주간 업데이트 그룹

  • 자유섬 1:1 추적 지도 dynmap-timemachine.py http://map.throgo.com block16 flat [-17320,64,4572] [22,22] 2 block16-freee-230520.png
  • 자유섬 1:1 추적 지도 입체 dynmap-timemachine.py http://localhost:8120 block16 surface [-17320,64,4572] [29,15] 2 block16-freee3d-240313.png
  • 서버 전체 지도 dynmap-timemachine.py http://map.throgo.com block16 flat [0,64,480] [64,64] 4 block16-all2-240313.png

도시 별 1:1 지도 및 기준 좌표

아래 명령어는 5월 기준으로 최신 명령어와 다소 일치하지 않을 수 있습니다.

  • 좌표 변환 방법론
  • 극점 좌표
최북단 (최대 y 값): y 좌표 중 가장 큰 값
최서단 (최소 x 값): x 좌표 중 가장 작은 값
최동단 (최대 x 값): x 좌표 중 가장 큰 값
최남단 (최소 y 값): y 좌표 중 가장 작은 값
  • 중앙값 계산 및 128의 배수로 조정

중앙값을 계산하고 이를 128의 배수로 가장 가까운 값으로 조정합니다.

x 중앙값: (최서단 + 최동단) / 2 → 가장 가까운 128의 배수로 반올림
y 중앙값: (최북단 + 최남단) / 2 → 가장 가까운 128의 배수로 반올림
  • 거리 정보 계산

동서 및 남북 길이를 128으로 나누고, 소수점은 올림하여 거리 정보를 구합니다.

동서 길이 (a): ceil((최동단 - 최서단) / 128)
남북 길이 (b): ceil((최북단 - 최남단) / 128)
  • 최종 좌표 및 거리 정보 포맷팅
좌표 형식: [x,64,y]
x: 중앙값으로 조정된 x 좌표
y: 중앙값으로 조정된 y 좌표
거리 정보 형식: [a,b]
a: 동서 길이 정보
b: 남북 길이 정보

컴퓨터 성능은 조금이라도 절약할 수록 이득이니까, 효율적인 좌표를 자동으로 계산해주는 python 스크립트

import math

def round_to_128n_minus1(x_target):
    n_float = (x_target + 1) / 128.0
    n_int = round(n_float)
    return 128*n_int - 1

def round_to_128n(x_target):
    n_float = x_target / 128.0
    n_int = round(n_float)
    return 128*n_int

def round_to_128n_minus32(y_target):
    n_float = (y_target + 32) / 128.0
    n_int = round(n_float)
    return 128*n_int - 32

def round_to_128n_minus33(y_target):
    n_float = (y_target + 33) / 128.0
    n_int = round(n_float)
    return 128*n_int - 33

def compute_min_radius(cx, cy, xs, ys):
    x_min, x_max = min(xs), max(xs)
    y_min, y_max = min(ys), max(ys)
    
    a_min_1 = (x_min + 64 - cx) / 128.0
    a_min_2 = (cx - (x_max - 63)) / 128.0
    a_candidate = max(a_min_1, a_min_2, 0)
    a = math.ceil(a_candidate)
    
    b_min_1 = (y_min + 64 - cy) / 128.0
    b_min_2 = (cy - (y_max - 63)) / 128.0
    b_candidate = max(b_min_1, b_min_2, 0)
    b = math.ceil(b_candidate)
    
    return a, b

def find_tiles_to_render(coords):
    xs = [c[0] for c in coords]
    ys = [c[1] for c in coords]
    
    x_min, x_max = min(xs), max(xs)
    y_min, y_max = min(ys), max(ys)
    
    if x_min >= 1:
        # 전부 양수 -> 128n - 1
        cx_guess = (x_min + x_max) / 2.0
        cx_1step = round_to_128n_minus1(cx_guess)
    elif x_max <= 0:
        cx_guess = (x_min + x_max) / 2.0
        cx_1step = round_to_128n(cx_guess)
    else:
        cx_guess = (x_min + x_max) / 2.0
        if (abs(x_min) > x_max):
            cx_1step = round_to_128n(cx_guess)
        else:
            cx_1step = round_to_128n_minus1(cx_guess)
    
    if y_min >= 1:
        cy_guess = (y_min + y_max) / 2.0
        cy_1step = round_to_128n_minus33(cy_guess)
    elif y_max <= 0:
        cy_guess = (y_min + y_max) / 2.0
        cy_1step = round_to_128n_minus32(cy_guess)
    else:
        cy_guess = (y_min + y_max) / 2.0
        if (abs(y_min) > y_max):
            cy_1step = round_to_128n_minus32(cy_guess)
        else:
            cy_1step = round_to_128n_minus33(cy_guess)
    
    a, b = compute_min_radius(cx_1step, cy_1step, xs, ys)
    
    cx_final = cx_1step
    cy_final = cy_1step
    
    if x_min >= 1:
        pass # cx_final = cx_1step
    elif x_max <= 0:
        cx_final = cx_1step - 1

    if y_min >= 1:
        pass # cy_final = cy_1step
    elif y_max <= 0:
        cy_final = cy_1step - 1
    
    return f"[{cx_final},64,{cy_final}] [{a},{b}]"

if __name__ == "__main__":
    # 예시 1) x=양수, y=음수
    coords1 = [(885, -1790), (558, -1367), (1196, -1407), (934, -1180)]
    result1 = find_tiles_to_render(coords1)
    print("Example 1:", result1)

    # 예시 2) x=음수, y=양수
    coords2 = [(-173, 260), (-253, 333), (-91, 340), (-178, 428)]
    result2 = find_tiles_to_render(coords2)
    print("Example 2:", result2)

청라특별시, 평천군, 북청군

  • dynmap-timemachine.py http://mc.throgo.com:8120 block16 flat [-1000,64,2000] [20,39] 2 block16-cheongna-240501.png
  • dynmap-timemachine.py http://localhost:8120 block16 flat [5555,64,432] [29,21] 2 block16-pyeongcheon-240501.png
  • dynmap-timemachine.py http://localhost:8120 block16 flat [-4256,64,-3120] [20,18] 2 block16-bukcheong-240501.png

남해도

청산도

해강도

염안도

미등록