fix tile size

This commit is contained in:
HF 2020-01-28 13:01:50 +01:00
parent 5d37d277d7
commit 6b8ff37133
2 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,11 @@
/* @flow */
import { getChunkOfPixel, getOffsetOfPixel } from '../../core/utils';
import { TILE_SIZE, THREE_CANVAS_HEIGHT } from '../../core/constants';
import {
TILE_SIZE,
THREE_TILE_SIZE,
THREE_CANVAS_HEIGHT,
} from '../../core/constants';
import canvases from '../../canvases.json';
import logger from '../../core/logger';
@ -13,7 +17,7 @@ const UINT_SIZE = 'u8';
const EMPTY_CACA = new Uint8Array(TILE_SIZE * TILE_SIZE);
const EMPTY_CHUNK_BUFFER = Buffer.from(EMPTY_CACA.buffer);
const THREE_EMPTY_CACA = new Uint8Array(
TILE_SIZE * TILE_SIZE * THREE_CANVAS_HEIGHT,
THREE_TILE_SIZE * THREE_TILE_SIZE * THREE_CANVAS_HEIGHT,
);
const THREE_EMPTY_CHUNK_BUFFER = Buffer.from(THREE_EMPTY_CACA.buffer);

View File

@ -8,7 +8,11 @@
import type { Request, Response } from 'express';
import etag from 'etag';
import RedisCanvas from '../data/models/RedisCanvas';
import { TILE_SIZE } from '../core/constants';
import {
TILE_SIZE,
THREE_TILE_SIZE,
THREE_CANVAS_HEIGHT,
} from '../core/constants';
import logger from '../core/logger';
/*
@ -49,8 +53,10 @@ export default async (req: Request, res: Response, next) => {
}
// for temporary logging to see if we have invalid chunks in redis
if (chunk.length !== TILE_SIZE * TILE_SIZE) {
logger.error(`Chunk ${x},${y},${z} has invalid length ${chunk.length}!`);
if (chunk.length !== TILE_SIZE * TILE_SIZE
&& chunk.length !== (THREE_TILE_SIZE ** 2) * THREE_CANVAS_HEIGHT) {
logger.error(`Chunk ${x},${y}/${c} has invalid length ${chunk.length}!`);
}
const curEtag = etag(chunk, { weak: true });