mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-04 17:35:42 +02:00
Thread safety fix for decoding quadkeys to coordinates
This commit is contained in:
+4
-3
@@ -2,6 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <atomic>
|
||||||
#include "projection.hpp"
|
#include "projection.hpp"
|
||||||
|
|
||||||
struct projection projections[] = {
|
struct projection projections[] = {
|
||||||
@@ -107,11 +108,11 @@ unsigned long long encode(unsigned int wx, unsigned int wy) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char decodex[256];
|
static std::atomic<unsigned char> decodex[256];
|
||||||
static unsigned char decodey[256];
|
static std::atomic<unsigned char> decodey[256];
|
||||||
|
|
||||||
void decode(unsigned long long index, unsigned *wx, unsigned *wy) {
|
void decode(unsigned long long index, unsigned *wx, unsigned *wy) {
|
||||||
static int initialized = 0;
|
static std::atomic<int> initialized(0);
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
for (size_t ix = 0; ix < 256; ix++) {
|
for (size_t ix = 0; ix < 256; ix++) {
|
||||||
size_t xx = 0, yy = 0;
|
size_t xx = 0, yy = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user