Skip to content

Commit

Permalink
fix: rename content.url -> content.uri
Browse files Browse the repository at this point in the history
The specification has changed so adapt the code.
  • Loading branch information
peppsac committed Oct 18, 2018
1 parent 7010e30 commit a8bd062
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion py3dtiles/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def to_tileset_r(self, error):
}
if len(self.features) != 0:
tile["content"] = {
"url": "tiles/{0}.b3dm".format(self.id)
"uri": "tiles/{0}.b3dm".format(self.id)
}

return tile
Expand Down
16 changes: 8 additions & 8 deletions py3dtiles/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_root_tile(tileset, filename):

pnts_filename = os.path.join(
folder,
tileset['root']['content']['url'])
tileset['root']['content']['uri'])

return TileReader().read_file(pnts_filename)

Expand Down Expand Up @@ -175,7 +175,7 @@ def build_tileset_quadtree(out_folder, aabb, tilesets, base_transform, inv_base_
'geometricError': insides[0]['root']['geometricError'],
'boundingVolume': _3dtiles_bounding_box_from_aabb(box),
'content': {
'url': os.path.relpath(insides[0]['filename'], out_folder)
'uri': os.path.relpath(insides[0]['filename'], out_folder)
}
}
else:
Expand Down Expand Up @@ -225,23 +225,23 @@ def build_tileset_quadtree(out_folder, aabb, tilesets, base_transform, inv_base_
np.concatenate((xyz.view(np.uint8).ravel(), rgb.ravel())),
out_folder,
rgb.shape[0] > 0)[1]
result['content'] = { 'url': os.path.relpath(filename, out_folder) }
result['content'] = { 'uri': os.path.relpath(filename, out_folder) }
result['geometricError'] = sum([t['root']['geometricError'] for t in insides])
result['boundingVolume'] = _3dtiles_bounding_box_from_aabb(union_aabb, inv_base_transform)

return result


def extract_content_urls(tileset):
def extract_content_uris(tileset):
contents = []
for key in tileset:
if key == 'content':
contents += [tileset[key]['url']]
contents += [tileset[key]['uri']]
elif key == 'children':
for child in tileset['children']:
contents += extract_content_urls(child)
contents += extract_content_uris(child)
elif key == 'root':
contents += extract_content_urls(tileset['root'])
contents += extract_content_uris(tileset['root'])

return contents

Expand All @@ -250,7 +250,7 @@ def remove_tileset(tileset_filename):
folder = os.path.dirname(tileset_filename)
with open(tileset_filename, 'r') as f:
tileset = json.load(f)
contents = extract_content_urls(tileset)
contents = extract_content_uris(tileset)
for content in contents:
ext = os.path.splitext(content)[1][1:]
if ext == 'pnts':
Expand Down
4 changes: 2 additions & 2 deletions py3dtiles/points/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def to_tileset(executor, name, parent_aabb, parent_spacing, folder, scale):

children = []
if os.path.exists(ondisk_tile):
tile['content'] = {'url': os.path.relpath(ondisk_tile, folder)}
tile['content'] = {'uri': os.path.relpath(ondisk_tile, folder)}
for child in ['0', '1', '2', '3', '4', '5', '6', '7']:
child_name = '{}{}'.format(name.decode('ascii'), child).encode('ascii')
ondisk_tile = name_to_filename(folder, child_name, '.pnts')
Expand Down Expand Up @@ -244,7 +244,7 @@ def to_tileset(executor, name, parent_aabb, parent_spacing, folder, scale):
tileset_name = 'tileset.{}.json'.format(name.decode('ascii'))
with open('{}/{}'.format(folder, tileset_name), 'w') as f:
f.write(json.dumps(tile_root))
tile['content'] = {'url': tileset_name}
tile['content'] = {'uri': tileset_name}
tile['children'] = []

return tile
2 changes: 1 addition & 1 deletion tests/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"geometricError": 0,
"content": {
"url": "pointCloudRGB.pnts"
"uri": "pointCloudRGB.pnts"
}
}
}

0 comments on commit a8bd062

Please sign in to comment.