Quantized-mesh-tile is a Python encoder/decoder and topology builder for terrain tiles.
Doc is hosted on Readthedocs: https://quantized-mesh-tile.readthedocs.io/en/latest/
Quantized-Mesh encoder/decoder and topology builder
License: MIT License
Quantized-mesh-tile is a Python encoder/decoder and topology builder for terrain tiles.
Doc is hosted on Readthedocs: https://quantized-mesh-tile.readthedocs.io/en/latest/
Hi Loic,
merry Christmas and a happy new year ... and so on :)
I was preparing a PR for a solution of the vertex normals on the tile edges and stumbled over the (for me irritating) behavior of the method utils.collapseIntoTriangles.
Long story short, i try to give the TerrainTopology a 'effectiveBoundary' and a list of overlapping triangles ( i guess you mentioned something like this in a earlier discussion).
The TerrainTopology splits the triangles on the boundary and creates so a outer and a inner (effective) List of Faces.
For this design i used the collapseIntoTriangles-Method, but came up with irritating artefacts.
Then i tried to replace 'collapseIntoTriangles'-Method with the shapely.ops.triangulate-Method.
The result with 'shapely.ops.triangulate'-method (delauney-triangulation from geos-lib) gives a expected result of outer and inner faces.
And...of course.. the unittests in TestCollapseIntoTriangle all failed, if i substitute the result of 'shapely.ops.triangulate' into 'collapseIntoTriangles'.
So , for now i dont get into the algorithmus of collapseIntoTriangles. Can you give me any hints to understand the concept?
Oh, i forgot...what i want to achieve...calculateNormals with all faces and use only the effective faces for the terrain tile.
Hi.
Did you plan to switch to a full Python3 support? (Or maybe it's already the case and I missed it?)
Because I can read that:
Quantized mesh tile requires Python >=2.7 (not including Python 3.x) and GEOS >= 3.3.
Here: https://quantized-mesh-tile.readthedocs.io/en/latest/index.html
And Python 2 is now deprecated, I'm just wondering...
Thanks.
Thank you for making this open source and your informative talk. We are looking to implement a workflow for world topo coverage using QM. What does your workflow look like going from DEM to a fully tiled set? Right now we are unsure how to best create the triangles from DEMS. Thank you again for you work.
Hi @loicgasser ,
i used successfully your library to create terrain-files from my mesh-data.
Thanks a lot for this great tool!
Unfortunately is the shading in cesium not correct. In #6 you mentioned, that lighting is not correct yet.
After some stumbling around in the code i've got following question:
Why you use wheightedNormals in computeNormals (utils.py line 185)?
According to the code in Cesium's GeometryPipeline it is not neccessary to get the vertex-normals.
for i in xrange(0, numFaces):
face = faces[i]
for j in face:
normalsPerVertex[j] = c3d.add(normalsPerVertex[j], normalsPerFace[i])
instead of:
for i in xrange(0, numFaces):
face = faces[i]
weightedNormal = [c * areasPerFace[i] for c in normalsPerFace[i]]
# alternative?
#weightedNormal = c3d.multiplyByScalar(normalsPerFace[i],areasPerFace[i])
for j in face:
normalsPerVertex[j] = c3d.add(normalsPerVertex[j], weightedNormal)
https://github.com/loicgasser/quantized-mesh-tile/blob/master/quantized_mesh_tile/terrain.py#L702
When selecting indices on the border of the tile, one should provide a threshold according to the current resolution and not only compare strictly equal lon/lat.
Hi,
I have a terrain mesh tile, and another one containing only terrain inside a polygon, and I want to modify the first tile by embedding the terrain from the second tile's polygon into it.
Is there a way to accomplish this using this library?
I'm trying to parse a terrain tile with the following code but got an error about uVertexCount.
Tile 1608.zip
I've checked the Gzip compression. Tile is rendered well in the Cesium viewer.
Code:
from quantized_mesh_tile.global_geodetic import GlobalGeodetic
from quantized_mesh_tile.terrain import TerrainTile
geodetic = GlobalGeodetic(True)
[z, x, y] = [11,2107,1608]
[minx, miny, maxx, maxy] = geodetic.TileBounds(x, y, z)
ter = TerrainTile(west=minx, south=miny, east=maxx, north=maxy)
ter.fromFile('1608.terrain')
Stacktrace:
Traceback (most recent call last):
File "test.py", line 24, in <module>
ter.fromFile('1608.terrain')
File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 433, in fromFile
self.fromStringIO(f, hasLighting=hasLighting, hasWatermask=hasWatermask)
File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 334, in fromStringIO
unpackEntry(f, TerrainTile.vertexData['uVertexCount'])
File "C:\Python27\lib\site-packages\quantized_mesh_tile\utils.py", line 19, in unpackEntry
return unpack('<%s' % entry, f.read(calcsize(entry)))[0]
struct.error: unpack requires a string argument of length 2
Any idea whats going on?
when I run the following code, an error about the unpack method
is returned. Any ideas how to fix this?
from quantized_mesh_tile.global_geodetic import GlobalGeodetic
from quantized_mesh_tile.terrain import TerrainTile
geodetic = GlobalGeodetic(True)
[z, x, y] = [9, 533, 383]
[minx, miny, maxx, maxy] = geodetic.TileBounds(x, y, z)
ter = TerrainTile(west=minx, south=miny, east=maxx, north=maxy)
ter.fromFile('9_533_383.terrain')
Error:
Traceback (most recent call last):
File "test.py", line 24, in <module>
ter.fromFile('9_533_383.terrain')
File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 433, in fromFile
self.fromStringIO(f, hasLighting=hasLighting, hasWatermask=hasWatermask)
File "C:\Python27\lib\site-packages\quantized_mesh_tile\terrain.py", line 334, in fromStringIO
unpackEntry(f, TerrainTile.vertexData['uVertexCount'])
File "C:\Python27\lib\site-packages\quantized_mesh_tile\utils.py", line 19, in unpackEntry
return unpack('<%s' % entry, f.read(calcsize(entry)))[0]
struct.error: unpack requires a string argument of length 2
in terrain.py line 653:
if self.vLight:
should become if len(self.vLight) > 0:
since self.vLight is a list.
Currently it results in a numpy error mentioning The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I generated terrain-tiles with the docker- version of cesium-terrain-builder . The tiles are working with Cesium, all looks good to me.
Now I would like to decode and edit single tiles with "quantized-mesh-tile". I follow the tutorial but face an error: "unpack requires a buffer of 2 bytes"
It seems to me, the terrain-tiles built with ctb are not compatible to this library. Are there any ideas how to fix this?
Issue also reported here: geo-data/cesium-terrain-builder#89
In other words I TerrainTile should extend TerrainTopology
Hi there
I'm not a python programmer,this is my first meet python tools.I used CTB before to generate quantized-mesh.But there may have some bugs.Because the CesiumJS not only need layer.json but also need metadata extension in 0/0/0.terrain and 0/1/0.terrain and every tile in level10 to init the availbility.We can trace the code at Cesium Source Code.
This rule can be find by Cesium World Terrain which provide by Cesium ion.
So I'm looking for a new tools to generate the quantized-mesh tiles
,and my problem is does the tiles created by this python tools has metadata extension in 0/0/0.terrain and 0/1/0.terrain and every tile in level10 ?
Best,zhangiser
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.