Geodan / pg2b3dm

Tool for creating 3D Tiles from PostGIS geometries
MIT License
361 stars 70 forks source link

Unable to create the 3D Line using pg2b3dm 2.13.0.0 #189

Closed rahulkanani09 closed 3 months ago

rahulkanani09 commented 3 months ago

Screenshot from 2024-08-08 10-00-10

When attempting to create a 3D line using pg2b3dm version 2.13.0.0, an error occurs, preventing the tile creation. The error message indicates a type casting issue between System.Int32 and System.Single.

Error details: Creating tile: 0_0_0.glb
Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.Single'. at B3dm.Tileset.GeometryRepository.GetGeometries(NpgsqlConnection conn, String shaderColumn, String attributesColumns, String sql, String radiusColumn) at B3dm.Tileset.GeometryRepository.GetGeometrySubset(NpgsqlConnection conn, String geometry_table, String geometry_column, Double[] bbox, Int32 source_epsg, Int32 target_srs, String shaderColumn, String attributesColumns, String query, String radiusColumn)

Environement Details: Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal

bertt commented 3 months ago

The radius column must be of type 'real', not of type int

bertt commented 3 months ago

See PR https://github.com/Geodan/pg2b3dm/pull/190 , next release will also support int column type https://github.com/Geodan/pg2b3dm/pull/190

rahulkanani09 commented 3 months ago

I tried with real datatype as well. It is giving me the following error:

Start generating tiles... Creating tile: 0_0_0.glb Unhandled exception. System.InvalidOperationException: Nullable object must have a value. at System.Nullable1.get_Value() at Triangulate.Triangulator.GetPoints(LineString lineString) at Triangulate.Triangulator.Triangulate(LineString lineString, Single radius, Nullable1 radialSegments, Boolean closed) at Wkb2Gltf.GeometryProcessor.GetTrianglesFromLines(LineString line, Single radius, Double[] translation, Double[] scale, Nullable1 tabularSegments, Nullable1 radialSegments) at Wkb2Gltf.GeometryProcessor.GetTriangles(Geometry geometry, Int32 batchId, Double[] translation, Double[] scale, ShaderColors shadercolors, Nullable1 radius) at Wkb2Gltf.GeometryRecord.GetTriangles(Double[] translation, Double[] scale) at pg2b3dm.TileWriter.GetTriangles(List1 geomrecords, Double[] translation, Double[] scale) at pg2b3dm.TileWriter.ToTile(List1 geometries, Double[] translation, Double[] scale, String copyright, Boolean addOutlines, String defaultColor, String defaultMetallicRoughness, Boolean doubleSided, Boolean createGltf, Boolean YAxisUp) at pg2b3dm.QuadtreeTiler.GenerateTiles(BoundingBox bbox, Tile tile, List1 tiles, Int32 lod, Boolean addOutlines, String defaultColor, String defaultMetallicRoughness, Boolean doubleSided, Boolean createGltf) at pg2b3dm.Program.<>c__DisplayClass2_0.

b__0(Options o) at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult1 result, Action1 action) at pg2b3dm.Program.Main(String[] args) Aborted (core dumped)

bertt commented 3 months ago

The vertices of the lines should have z values

mittermichal commented 3 months ago

@rahulkanani09 using -nlt "LINESTRING Z" in ogr2ogr arguments adds Z to 2d lines

bertt commented 3 months ago

I'll probably make a PR that uses z=0 when there are no z values in the line

rahulkanani09 commented 3 months ago

@rahulkanani09 using -nlt "LINESTRING Z" in ogr2ogr arguments adds Z to 2d lines

ogr2ogr command : ogr2ogr -nlt "LINESTRING Z" -f "ESRI Shapefile" output.shp checked_fe_200_mp.shp.

It is working now. @bertt and @mittermichal Thanks for prompt support.

bertt commented 3 months ago

note: both issues should no longer appear in 2.14