All Projects → tsherif → mercator-gl

tsherif / mercator-gl

Licence: MIT License
Tiny library for GLSL web mercator projections

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to mercator-gl

rusty buntdb
A Rust port of BuntDB
Stars: ✭ 12 (-63.64%)
Mutual labels:  geospatial
uav-lidar-analytics-course
NCSU GIS595/MEA792: UAV/lidar Data Analytics
Stars: ✭ 23 (-30.3%)
Mutual labels:  geospatial
xyz-hub
XYZ Hub is a RESTful web service for the access and management of geospatial data.
Stars: ✭ 43 (+30.3%)
Mutual labels:  geospatial
karta
A tidy Python package for geospatial computation
Stars: ✭ 98 (+196.97%)
Mutual labels:  geospatial
blocl-bnglatlon
Converts british national grid (OSBG36) to lat lon (WGS84) and vice versa.
Stars: ✭ 16 (-51.52%)
Mutual labels:  geospatial
actinia core
Actinia Core is an open source REST API for scalable, distributed, high performance processing of geographical data that uses mainly GRASS GIS for computational tasks (DOI: https://doi.org/10.5281/zenodo.5879231)
Stars: ✭ 41 (+24.24%)
Mutual labels:  geospatial
Geospatial Python CourseV1
This is an collection of blog posts turned into a course format
Stars: ✭ 53 (+60.61%)
Mutual labels:  geospatial
geoos
A library provides spatial data and geometric algorithms
Stars: ✭ 504 (+1427.27%)
Mutual labels:  geospatial
carto-spatial-extension
A set of UDFs and Procedures to extend BigQuery, Snowflake, Redshift and Postgres with Spatial Analytics capabilities
Stars: ✭ 131 (+296.97%)
Mutual labels:  geospatial
GeoJSON.jl
Utilities for working with GeoJSON data in Julia
Stars: ✭ 46 (+39.39%)
Mutual labels:  geospatial
fake-geo-images
A module to programmatically create geotiff images which can be used for unit tests
Stars: ✭ 18 (-45.45%)
Mutual labels:  geospatial
geodot-plugin
Godot plugin for loading geospatial data
Stars: ✭ 37 (+12.12%)
Mutual labels:  geospatial
ibmpairs
open source tools for interaction with IBM PAIRS:
Stars: ✭ 23 (-30.3%)
Mutual labels:  geospatial
dea-coastlines
Extracting tidally-constrained annual shorelines and robust rates of coastal change from freely available Earth observation data at continental scale
Stars: ✭ 24 (-27.27%)
Mutual labels:  geospatial
carto-react-template
CARTO for React. The best way to develop Location Intelligence (LI) Apps usign CARTO platform and React
Stars: ✭ 24 (-27.27%)
Mutual labels:  geospatial
rafagas
Daily geospatial links curated by Raf Roset
Stars: ✭ 17 (-48.48%)
Mutual labels:  geospatial
echomap
Preview map files in the terminal
Stars: ✭ 12 (-63.64%)
Mutual labels:  geospatial
gdal-js
This is an Emscripten port of GDAL, an open source X/MIT licensed translator library for raster and vector geospatial data formats.
Stars: ✭ 81 (+145.45%)
Mutual labels:  geospatial
geojson-mongo-import.py
Import GeoJSON file into MongoDB using Python
Stars: ✭ 20 (-39.39%)
Mutual labels:  geospatial
streamlit-geospatial
A multi-page streamlit app for geospatial
Stars: ✭ 310 (+839.39%)
Mutual labels:  geospatial

MercatorGL

Build Status Coverage Status GZIP size License NPM

MercatorGL is a minimal library for calculating web mercator projections on a GPU using WebGL. It provides utilities to inject GLSL code for projecting longitude/latitude coordinates into already exisiting vertex shader code and calculate the uniforms it requires. MercatorGL focuses on numerical stability by performing most calculations at 64-bit precision, and switching to an "offset mode" at higher zoom levels (using a technique borrowed from deck.gl).

Following Mapbox conventions input coordinates are transformed to a 512x512 Mercator space, with (0, 0) at the top-left and (512, 512) at the bottom-right. Z-coordinates, if provided, are interpreted as meter elevations. The application must provide a projection matrix (via updateMercatorUniforms) to map from Mercator space into clip space.

An example of usage with MapboxGL is shown below.

    let map = new mapboxgl.Map({
        container: mapboxContainer,
        style: "mapbox://styles/mapbox/streets-v9",
        center: [-73.982130, 40.762896],
        zoom: 15
    });

    // NOTE: MercatorGL works with both GLSL 1 and 3 shaders
    let vs = `
        #version 300 es
        layout(location=0) in vec2 lngLatPosition;
        void main() {
            // mercator_gl_lngLatToClip function injected by injectMercatorGLSL().
            // mercator_gl_lngLatToMercator and mercator_gl_mercatorToClip also available to do
            // projection in multiple steps.
            gl_Position = mercator_gl_lngLatToClip(position);
        }
    `;

    let fs = `
        #version 300 es
        precision highp float;
        uniform vec4 color;
        out vec4 fragColor;
        void main() {
            fragColor = color;
        }
    `;


    // Insert projection functions into vertex shader
    let vertexShaderSource = injectMercatorGLSL(vs);
    let fragmentShaderSource =  fs;
    // Create WebGL program from vertexShaderSource and fragmentShaderSource

    let uniforms = {
        // An application uniform, not used by MercatorGL
        color: new Float32Array(1.0, 0.0, 0.0, 1.0);
    };

    // Uniforms used by MercatorGL are added to the map.
    allocateMercatorUniforms(uniforms);

    map.on("render", (e) => {
        let center = map.getCenter().toArray();
        let zoom = map.getZoom();

        // Update the values of MercatorGL uniforms in the map (including projection matrix provided by Mapbox).
        // The application must use the map to update program uniforms used by MercatorGL.
        updateMercatorUniforms(uniforms, center, zoom, map.transform.projMatrix);

        // Draw to canvas
    });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].