Move string hashing from mbtiles to text

This commit is contained in:
Erica Fischer
2024-02-01 15:43:16 -08:00
parent 9af42515ec
commit 910aff8fe7
4 changed files with 30 additions and 15 deletions
-13
View File
@@ -101,19 +101,6 @@ sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable) {
return outdb;
}
unsigned long long fnv1a(std::string const &s) {
// Store tiles by a hash of their contents (fnv1a 64-bit)
// http://www.isthe.com/chongo/tech/comp/fnv/
const unsigned long long fnv_offset_basis = 14695981039346656037u;
const unsigned long long fnv_prime = 1099511628211u;
unsigned long long h = fnv_offset_basis;
for (size_t i = 0; i < s.size(); i++) {
h ^= (unsigned char) s[i];
h *= fnv_prime;
}
return h;
}
void mbtiles_write_tile(sqlite3 *outdb, int z, int tx, int ty, const char *data, int size) {
std::string hash = std::to_string(fnv1a(std::string(data, size)));