A lean, efficient, accurate geohash encoder and decoder library implemented in C

Related tags

geohash
Overview

Geohash encoder/decoder in C

A lean, efficient, accurate geohash encoder and decoder library implemented in C. It does not depend on the C standard library and is well-suited for use in embedded systems. Care has been taken to ensure results are as accurate as possible within the limitations of IEEE 754 double precision. It's also very fast, decoding ~50 million and encoding ~80 million latlons per second on modern desktop and laptop hardware.

This is the fastest, most correct, and most accurate (to double precision) geohash decoder and encoder currently available.

// Validate and decode a geohash into a lat/lon pair. Returns 1 on success,
// or 0 if the buffer does not contain a valid geohash.
int geohash_decode(double *lat, double *lon, const char *buf, int len);

// Store a 21-byte geohash encoding of a lat/lon pair. Does not write a
// terminating null byte. Truncate as needed.
void geohash_encode(char *buf, double lat, double lon);

Example usage

The source file tests/example.c demonstrates decoding and encoding lat/lon coordinates as command line arguments.

$ ./example -d ezs42 dppn59uz86jzd 000000000000 zzzzzzzzzzzz
ezs42          [email protected] 36' 17.929" N    [email protected] 36' 10.898" W
dppn59uz86jzd  [email protected] 26' 26.160" N   [email protected] 59' 45.239" W
000000000000   [email protected] 59' 59.999" S  [email protected] 59' 59.999" W
zzzzzzzzzzzz   [email protected] 59' 59.999" N  [email protected] 59' 59.999" E

$ ./example -e "[email protected]'26.160\"N [email protected]'45.239\"W"
dppn59uz86jzd  [email protected] 26' 26.160" N   [email protected] 59' 45.239" W
Issues
  • Decoding is faster than encoding

    Decoding is faster than encoding

    encode 53.711 M-ops/sec
    decode 61.235 M-ops/sec
    

    This is the case at least for my machine. I wonder why.

                .-/+oossssoo+/-.               [email protected] 
            `:+ssssssssssssssssss+:`           ----------- 
          -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.2 LTS x86_64 
        .ossssssssssssssssssdMMMNysssso.       Host: HP EliteBook 840 G6 
       /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.11.0-25-generic 
      +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 3 days, 52 mins 
     /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 2519 (dpkg), 8 (snap) 
    .ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.0.17 
    +sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080 
    ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 
    ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
    +sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
    .ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Yaru-dark [GTK2/3] 
     /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru [GTK2/3] 
      +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: gnome-terminal 
       /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel i7-8565U (8) @ 4.600GHz 
        .ossssssssssssssssssdMMMNysssso.       GPU: Intel UHD Graphics 620 
          -+sssssssssssssssssyyyssss+-         Memory: 10658MiB / 15818MiB 
            `:+ssssssssssssssssss+:`
                .-/+oossssoo+/-.                                       
                                                                       
    
    
    opened by aquiire 0
Owner
Christopher Wellons
Christopher Wellons
Earth observation data cubes from GDAL image collections

gdalcubes - Earth observation data cubes from GDAL image collections gdalcubes is a library to represent collections of Earth Observation (EO) images

Marius Appel 68 Oct 20, 2021
Mapnik implemention of Mapbox Vector Tile specification

mapnik-vector-tile A Mapnik implemention of Mapbox Vector Tile specification. Provides C++ headers that support rendering geodata into vector tiles an

Mapbox 523 Sep 26, 2021
C++ library for geographical raster data analysis

Pronto Raster library The Pronto Raster Library is a C++ library to work with raster data. The core idea of the library is to make raster data accessi

Alex Hagen-Zanker 39 Oct 6, 2021
Open Source Routing Engine for OpenStreetMap

██▒ █▓ ▄▄▄ ██▓ ██░ ██ ▄▄▄ ██▓ ██▓ ▄▄▄ ▓██░ █▒▒████▄ ▓██▒ ▓██░ ██▒▒████▄ ▓██▒ ▓██▒ ▒████▄ ▓██ █▒░▒██ ▀█▄

valhalla 1.7k Oct 14, 2021
A C++17 image representation, processing and I/O library.

Selene Selene is a C++17 image representation, processing, and I/O library, focusing on ease of use and a clean, modern, type-safe API. Overview: Brie

Michael Hofmann 268 Aug 28, 2021
Build vector tilesets from large collections of GeoJSON features.

tippecanoe Builds vector tilesets from large (or small) collections of GeoJSON, Geobuf, or CSV features, like these. ⚡ Mapbox has a new service for cr

Mapbox 1.9k Oct 14, 2021
A fast algorithm for finding the pole of inaccessibility of a polygon (in JavaScript and C++)

A fast algorithm for finding polygon pole of inaccessibility, the most distant internal point from the polygon outline (not to be confused with centroid), implemented as a JavaScript library. Useful for optimal placement of a text label on a polygon.

Mapbox 1.1k Oct 7, 2021
Computational geometry and spatial indexing on the sphere

S2 Geometry Library Overview This is a package for manipulating geometric shapes. Unlike many geometry libraries, S2 is primarily designed to work wit

Google 1.5k Oct 14, 2021
2D and 3D map renderer using OpenGL ES

Tangram ES Tangram ES is a C++ library for rendering 2D and 3D maps from vector data using OpenGL ES. It is a counterpart to Tangram. This repository

Tangram 705 Oct 10, 2021
gSLICr: Real-time super-pixel segmentation

gSLICr: SLIC superpixels at over 250Hz This is the software bundle "gSLICr", a library for real-time superpixel segmentation written in C++ and CUDA.

Carl Yuheng Ren 285 Oct 11, 2021
A command-line tool for converting heightmaps in GeoTIFF format into tiled optimized meshes.

TIN Terrain TIN Terrain is a command-line tool for converting heightmaps presented in GeoTIFF format into tiled optimized meshes (Triangulated Irregul

HERE Technologies 425 Oct 19, 2021
Entwine - point cloud organization for massive datasets

Build Status Entwine is a data organization library for massive point clouds, designed to conquer datasets of hundreds of billions of points as well a

Connor Manning 276 Oct 8, 2021
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Mapbox 4.1k Oct 18, 2021
a language for fast, portable data-parallel computation

Halide Halide is a programming language designed to make it easier to write high-performance image and array processing code on modern machines. Halid

Halide 4.6k Oct 16, 2021
A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, balloon or kite images. 📷

An open source command line toolkit for processing aerial drone imagery. ODM turns simple 2D images into: Classified Point Clouds 3D Textured Models G

OpenDroneMap 3.2k Oct 12, 2021
experimental project to create PBF vector tiles

Vector tiles producer This is an experimental project to create vector tiles. What does this do? This creates vector tiles based on the mapnik proto f

vross 30 Jan 19, 2021
OpenOrienteering Mapper is a software for creating maps for the orienteering sport.

OpenOrienteering Mapper OpenOrienteering Mapper is an orienteering mapmaking program and provides a free and open source alternative to existing comme

null 278 Oct 5, 2021
Terrain Analysis Using Digital Elevation Models (TauDEM) software for hydrologic terrain analysis and channel network extraction.

TauDEM (Terrain Analysis Using Digital Elevation Models) is a suite of Digital Elevation Model (DEM) tools for the extraction and analysis of hydrolog

David Tarboton 171 Oct 21, 2021
A geometry dash modding sdk that contains cocos2d headers

Adrikikicp-SDK GD SDK that i use for my mods What is the meaning of SDK???? SDK is Software Development Kit. This is a GD modding sdk that i use for m

adrikikicp el programador 1 Oct 17, 2021