Giter Club home page Giter Club logo

pg2b3dm's Introduction

pg2b3dm

Tool for converting from PostGIS to b3dm tiles. This software is a partial port of py3dtiles (https://github.com/Oslandia/py3dtiles) for generating b3dm tiles.

Differences to py3dtiles:

  • 2* performance improvement;

  • loading geometries in batches in memory instead of full datataset;

  • fixed glTF warnings;

  • add styling options;

  • Docker support.

To run this tool there must be a PostGIS table available containing triangulated polyhedralsurface geometries.

Tileset.json and b3dm tiles are created in the 'tiles' subdirectory.

History

2019-06-01: release 0.2.1 with some small fixes

2019-06-01: initial release 0.2

2019-05-01: initial release 0.1

Command line options

All parameters are optional, except the -t --table option.

If --username and/or --dbname are not specified the current username is used as default.

  -U, --username     (Default: username) Database user

  -h, --host        (Default: localhost) Database host

  -d, --dbname      (default: username) Database name

  -c, --column      (Default: geom) Geometry column

  -t, --table       (Required) Database table, include database schema if needed

  -p, --port        (Default: 5432) Database port

  --help            Display this help screen.

  --version         Display version information.  

Run from Docker

Docker image: https://hub.docker.com/r/geodan/pg2b3dm

Building image:

$ docker build -t geodan/pg2b3dm .

Running image:

Sample on Windows:

$ docker run -v C:/Users/bertt/output:/app/output -it geodan/pg2b3dm -h my_host -U my_user -d my_database -t my_table

Sample on Linux:

$ docker run -v $(pwd)/output:/app/output -it geodan/pg2b3dm -h my_host -U my_user -d my_database -t my_schema.my_table

Run from source

Requirement: Install .NET Core 2.2 SDK

https://dotnet.microsoft.com/download/dotnet-core/2.2

$ git clone https://github.com/Geodan/pg2b3dm.git

$ cd src/pg2b3dm

$ dotnet build

$ dotnet run

Debugging in Visual Studio Code

$ git clone https://github.com/Geodan/pg2b3dm.git

$ cd src

$ code .

In Visual Studio Code, open .vscode/launch.json and adjust the 'args' parameter to your environment

"args": ["-h" ,"my_host", "-U" ,"my_user", "-d", "my_database", "-t", "my_table"],            

Press F5 to start debugging.

Debugging SQL Queries

py3dtiles:

1] select 3D extent of all ST_PolyhedralSurface geometries

SELECT ST_3DExtent(geom) FROM tmptom.betterroofs_extruded where ST_GeometryType(geom) like 'ST_PolyhedralSurface'

In code: calculate center for transform

2] Select all geometries to process

SELECT ST_AsBinary(ST_RotateX(ST_Translate(geom, -3893180.29274884, -337609.41850392846, -5023897.8453492), -pi() / 2)),ST_Area(ST_Force2D(geom)) AS weight FROM tmptom.betterroofs_extruded where ST_GeometryType(geom) like 'ST_PolyhedralSurface' ORDER BY weight DESC

3] Loop through all bboxes and convert to zupboxes

Sample first geometry:

bbox: [array([ 597.0333 , -485.8998 , 261.94238], dtype=float32), array([ 749.3507, -354.325 , 508.3083], dtype=float32)]

zupbox: [-1695.9141, -2153.4897] [1695.9141, 2183.8198]

4] Calculate tree

tile 0,0: [-1695.9140625, -2153.48974609375] [304.0859375, -153.48974609375]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.