Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pirireis/gpu-analysis

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pirireis/gpu-analysis

Analysis with gpu processing and webworkers and indexeddb. viewShed with r3 for now

  • 2.0.2
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

clientUtil

This module helps client create the correct parameters for the application. Loading tiles also accessible from here. - loading tiles: tiles that are in the fetching stages and not downloaded yet. loading tiles are important because tiles that are not loaded represented by textures of zeros and not quite understandable.

GeographicalShapeShifterObserver

I called it shape shifter because there is some sort of builder pattern inside. The implementation is not reflected to the client. Additional pipelines are constructed based on the customlayer they pushed in, on top of base pipelines

This approach is followed considering the performance upgrade when using the same base on multiple different custom layers.

loading tiles

GeographicalShapeShifterObserver.getLoadingTilesAsObservable() gives the tiles that on fecthing stage which have intersaction with the observers range

clientUtil.TileManager.LoadingTilesAsObservable gives the all tiles that are fetching.

  • type Class

Constructor

export class GeographicalShapeShifterObserver{
    /**
     * 
     * @param {string} name name of the object
     * @param {rxjs.Observable<number> int preferably} height$ Unit of observer height. Same unit as texture data(dem).
     * @param {rxjs.Observable<Dictionary{lng:number,lat:number}>} lngLat$ 
     * @param {rxjs.Observable<number> int preferably} range$ Unit of range. Default unite type is "meter". Can be changed via turfOptions
     * @param {rxjs.Observable<number>} zoomLevel$ Floor zoom level.
     * @param {int} rasterTileResolution int value for MxM tile resolution. DEM texture resolution 
     * @param {mapboxgl} map_toCalculateMercatorCoordinate Dependent to mapboxgl for coordinate calculations
     * @param {rxjs.Observable<[(0 - 1),(0 - 1),(0 - 1)]>} rgb$ red green blue values to adjust color
     * @param {rxjs.Observable<(0 - 1)>} alpha$ visiblity of color aka opacity.
     * @param {TileManager} tileDB Manages texture data. Fetches it, caches it, memories it, clears it.
     * @param {boolean}  antiAliasing Choice process program
     * @param {int} samplingMilliseconds To adjust workload. Can be assigned only on construction.
     *                                   There should be a scheduler that manages resourches instead of this parameter
     * @param {String} textureType 'dem' Digital Elevation model is the only type for now. It should be enum instead of string
     * @param {Dictionary} turfOptions for detial https://www.npmjs.com/package/@turf/destination
     */
    constructor( 
        name, 
        height$, 
        lngLat$, 
        range$, // range observable
        zoomLevel$, // zoomLevel observable // probably created from event with rxjs.fromEvent('', object)
        rasterTileResolution, 
        map_toCalculateMercatorCoordinate,
        rgb$, // combinedLatest of {r:r, g:g, b:b} // make it a funciton
        alpha$, 
        tileDB,
        antiAliasing = true,
        samplingMilliseconds = 50,
        textureType = 'dem', 
        turfOptions = {"units":"meters"},
    )

Usage

    const mouseGozlemci = new GeographicalShapeShifterObserver(
        'mouseGozlemcisi',
        mouseHeight$,
        mouselngLat$,
        mouseRange$,
        zoomFloorLevel$,
        RASTERSIZE,
        mapboxgl,
        rgb$,
        alpha$, 
        tileTB,
        'dem');
    const gozlemciListesi = [mouseGozlemci];

viewShedCustomLayer

  • type Class

Constructor

  • constantObserverList,
  • mapboxgl,
  • id='highlight'

Usage

    map.on('load', () => {
        console.log('index on load viewShedOfObservers is loading...');
        map.addLayer(new viewShedOfObservers( gozlemciListesi, mapboxgl), 'building');
        });

TileManager

Constructor

  • urlCreater type TileServiceUrlCreaterFactory

Two methods are used by client

    deleteIndexedDBAllTiles(){// use for cache invalidation.
        textureDBManager.clear() // clear indexeddb 
    }
    deleteRamDBAllTiles(){ // use when textures getting too much space on ram.
        // manage some things 
        this.requestedTileKeySet = new Set(); // Clear x,y,z,textureType cache
        tilesOnRam.clear(); // clears textures On ram
    }

TileServiceUrlCreaterFactory

TileServiceUrlCreaterFactory returns url creater function for texture services. TileManager class is dependent to TileServiceUrlCreaterFactory:new = TileManager(TileServiceUrlCreaterFactory).

function demTileService(x,y,z,resolution){
    return `https://servis.pirireis.com.tr/mesh_service/elevation_xyz?FLOAT=1&MESHN=${resolution}&CN=1&C1z=${z}&C1x=${x}&C1y=${y}`;
}

function demTilesServiceNew(x,y,z,resolution){
    return `http://192.168.1.64:5602/elevation_xyz_new?FLOAT=1&MESHN=${resolution}&CN=1&C1z=${z}&C1x=${x}&C1y=${y}`;
}

export default function TileServiceUrlCreaterFactory(textureType){
    switch ( textureType ){
        case "dem":
            return demTileService;
        case "newDem":
            return demTilesServiceNew;
        default:
            throw new Error(`texture type ${textureType} is not in the menu`);
    }
}

Developer of this project

Folders and Submodules

CustomLayers

This module is a connection to mapbox customlayer

DataManagement

Data needs to be fetched, cached in ram and indexedDB. Data format is designed to be used by gpujs, webgl programs.

Geometry

Coords, indexes to pixel index, lat long, all geometrical conversation takes place here. Clipping and merging Tiles also takes place here.

GPU

GPU js programs and kernels are here. There is factory pattern file for creating and caching appropriate sized kernels.

Produceses image output in Logic.

Logic

Work flow is here. It is reactive pattern with rxjs.

WebGlMapboxRenderer

WebGl for rendering image. Shape of the image and alpha(opacity) is here.

workers

This project might use webworkers in the future

FAQs

Package last updated on 23 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc