diff --git a/Pipfile b/Pipfile index 63504f1..479acca 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,7 @@ verify_ssl = true url = "https://pypi.org/simple" [dev-packages] +pytest = "*" [requires] python_version = "3.6" @@ -12,4 +13,4 @@ python_version = "3.6" click = "*" jsonschema = "*" jsonref = "*" -"e1839a8" = {path = ".", editable = true} +"e1839a8" = {editable = true, path = "."} diff --git a/Pipfile.lock b/Pipfile.lock index 7ba845d..0ab5973 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "6124de6ca69e6505f917813c1f95a7e0a3c71d7193b79ca72c36a76b7f6e1c6b" + "sha256": "979636d227e6d876719943be30c2e595f699310ee4aa7c807fe3fd23d9e949a4" }, "pipfile-spec": 6, "requires": { @@ -44,5 +44,58 @@ "version": "==2.6.0" } }, - "develop": {} + "develop": { + "atomicwrites": { + "hashes": [ + "sha256:240831ea22da9ab882b551b31d4225591e5e447a68c5e188db5b89ca1d487585", + "sha256:a24da68318b08ac9c9c45029f4a10371ab5b20e4226738e150e6e7c571630ae6" + ], + "version": "==1.1.5" + }, + "attrs": { + "hashes": [ + "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265", + "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b" + ], + "version": "==18.1.0" + }, + "more-itertools": { + "hashes": [ + "sha256:2b6b9893337bfd9166bee6a62c2b0c9fe7735dcf85948b387ec8cba30e85d8e8", + "sha256:6703844a52d3588f951883005efcf555e49566a48afd4db4e965d69b883980d3", + "sha256:a18d870ef2ffca2b8463c0070ad17b5978056f403fb64e3f15fe62a52db21cc0" + ], + "version": "==4.2.0" + }, + "pluggy": { + "hashes": [ + "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff", + "sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c", + "sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5" + ], + "version": "==0.6.0" + }, + "py": { + "hashes": [ + "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881", + "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a" + ], + "version": "==1.5.3" + }, + "pytest": { + "hashes": [ + "sha256:39555d023af3200d004d09e51b4dd9fdd828baa863cded3fd6ba2f29f757ae2d", + "sha256:c76e93f3145a44812955e8d46cdd302d8a45fbfc7bf22be24fe231f9d8d8853a" + ], + "index": "pypi", + "version": "==3.6.0" + }, + "six": { + "hashes": [ + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" + ], + "version": "==1.11.0" + } + } } diff --git a/cjio/cityjson.py b/cjio/cityjson.py index b4d8779..f8763aa 100644 --- a/cjio/cityjson.py +++ b/cjio/cityjson.py @@ -1,6 +1,8 @@ import os import sys +import re + import json import collections import jsonref @@ -57,6 +59,7 @@ class CityJSON: def __init__(self, file=None, j=None, ignore_duplicate_keys=False): if file is not None: self.read(file, ignore_duplicate_keys) + self.path = file.name elif j is not None: self.j = j else: #-- create an empty one @@ -421,6 +424,42 @@ def get_subset_cotype(self, cotype): return cm2 + + def get_texture_location(self): + """Get the location of the texture files + + Assumes that all textures are in the same location. Relative paths + are expanded to absolute paths. + """ + if "appearance" in self.j: + if "textures" in self.j["appearance"]: + p = self.j["appearance"]["textures"][0]["image"] + cj_dir = os.path.dirname(self.path) + url = re.match('http[s]?://|www\.', p) + if url: + return url + else: + d = os.path.dirname(p) + print(d) + if len(d) == 0: + # textures are in the same dir as the cityjson file + return cj_dir + elif not os.path.isabs(d): + if os.path.isdir(os.path.abspath(d)): + # texture dir is not necessarily in the same dir + # as the input file + return os.path.abspath(d) + elif os.path.isdir(os.path.join(cj_dir, d)): + # texture dir is a subdirectory at the input file + return os.path.join(cj_dir, d) + else: + raise FileNotFoundError("Texture directory '%s' not found" % d) + + + def validate_textures(self): + """Check if the texture files exist""" + + def remove_textures(self): for i in self.j["CityObjects"]: if "texture" in self.j["CityObjects"][i]: diff --git a/example_data/dummy/dummy.json b/example_data/dummy/dummy.json new file mode 100644 index 0000000..4b0597a --- /dev/null +++ b/example_data/dummy/dummy.json @@ -0,0 +1,363 @@ +{ + "type": "CityJSON", + "version": "0.6", + "metadata": { + "crs": { + "epsg": 7415 + }, + "bbox": [ 84710, 446846, -5, 84757, 446944, 40 ], + "datasetTitle": "what is this dataset?", + "datasetAbstract": "what is this dataset?", + "datasetReferenceDate": "2011-02-28", + "copyright": "CC0", + "pointOfContact": "Hugo Ledoux " + }, + "CityObjects": { + "mygroup1": { + "type": "CityObjectGroup", + "members": ["102636712", "mylake"], + "geometry": [ + { + "type": "MultiSurface", + "lod": 2, + "boundaries": [ [[2, 4, 5]] ] + } + ] + }, + "102636712": { + "type": "Building", + "attributes": { + "measuredHeight": 22.3, + "roofType": "gable", + "yearOfConstruction": 1904, + "owner": "Elvis Presley" + }, + "address": { + "CountryName": "Canada", + "LocalityName": "Chibougamau", + "ThoroughfareNumber": "666", + "ThoroughfareName": "rue du Diable", + "PostalCode": "H0H 0H0" + }, + "Parts": ["2929"], + "geometry": [ + { + "type": "Solid", + "lod": 1.1, + "boundaries": [ + [ [[0, 3, 2, 1],[0,1,2]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] ] + ], + "semantics": { + "surfaces" : [ + { + "type": "RoofSurface", + "slope": 33.4 + }, + { + "type": "RoofSurface", + "slope": 66.6 + }, + { + "type": "WallSurface", + "paint": "blue" + }, + { + "type": "WallSurface", + "paint": "red" + } + ], + "values": [ + [0, 1, null, null, 2, 3] + ] + }, + "material": { + "irradiation": { + "values": [ + [0, 0, null, null, 2, 2] + ] + }, + "irradiation-2": { + "value": 1 + } + } + }, + { + "type": "Solid", + "lod": 2.1, + "boundaries": [ + [ [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] ], + [ [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]] ] + ], + "semantics": { + "surfaces" : [ + { + "type": "RoofSurface" + }, + { + "type": "WallSurface" + } + ], + "values": [ + [0, 1, null, null, 1, 1], + null + ] + }, + "texture": { + "winter-textures": { + "values": [ + [ [[0, 10, 13, 12, 19]], [[null]], [[null]], [[0, 1, 2, 6, 5]], [[0, 2, 3, 7, 6]], [[0, 3, 0, 4, 7]] ], + [ [[null]], [[null]], [[0, 0, 1, 5, 4]], [[0, 1, 2, 6, 5]] ] + ] + }, + "summer-textures": { + "values": [ + [ [[1, 7, 3, 2, 1]], [[null]], [[null]], [[1, 1, 2, 6, 5]], [[1, 2, 3, 7, 6]], [[1, 3, 0, 4, 7]] ], + [ [[null]], [[null]], [[1, 0, 1, 5, 4]], [[1, 1, 2, 6, 5]] ] + ] + } + } + } + ] + }, + "2929": { + "type": "BuildingPart", + "attributes": { + "renovation": "2001/09/11" + }, + "geometry": [{ + "type": "Solid", + "lod": 2, + "boundaries": [ + [ [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] ] + ] + }] + }, + "onebigtree-template": { + "type": "SolitaryVegetationObject", + "geometry": [ + { + "type": "GeometryInstance", + "template": 0, + "boundaries": [2], + "transformationMatrix": [ + 2.0, 0.0, 0.0, 0.0, + 0.0, 2.0, 0.0, 0.0, + 0.0, 0.0, 2.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + ] + } + ] + }, + "itcanbeastringtoo": { + "type": "Building", + "attributes": { + "measuredHeight": 223 + }, + "Installations": ["801"], + "geometry": [{ + "type": "MultiSurface", + "lod": 2, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ], + "material": { + "blablabla": { + "value": 1 + } + } + }] + }, + "801": { + "type": "BuildingInstallation", + "attributes": { + "function": "balcony" + }, + "geometry": [{ + "type": "MultiSurface", + "lod" : 2.2, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ] + }] + }, + "myterrain01": { + "type": "TINRelief", + "geometry": [{ + "type": "CompositeSurface", + "lod": 2, + "boundaries": [ + [[0, 3, 2]], [[4, 5, 6]], [[0, 1, 5]], [[1, 2, 6]], [[2, 3, 7]], [[3, 0, 4]] + ] + }] + }, + "mycanal": { + "type": "WaterBody", + "geometry": [{ + "type": "CompositeSurface", + "lod": 1, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 8]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ], + "semantics": { + "surfaces": [], + "values": null + } + }] + }, + "LondonTower": { + "type": "Bridge", + "address": { + "CountryName": "UK", + "LocalityName": "London" + }, + "geometry": [{ + "type": "MultiSurface", + "lod": 2, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ] + }] + }, + "mylake": { + "type": "WaterBody", + "bbox": [ 84710, 446846, -5, 84757, 446944, 40 ], + "attributes": { + "usage": "leisure", + "function": "leisure" + }, + "geometry": [{ + "type": "MultiSurface", + "lod": 1, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]], [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ], + "semantics": { + "surfaces": [ + { "type":"WaterSurface" }, + { "type":"WaterGroundSurface" } + ], + "values": [0, 0, 0, 0, 1, 1] + } + }] + } + }, + "vertices": [ + [0.0, 0.0, 0.0], + [1.0, 0.0, 0.0], + [1.0, 0.0, 0.0], + [1.0, 0.0, 0.0], + [1.0, 1.0, 0.0], + [0.0, 1.0, 0.0], + [0.0, 0.0, 1.0], + [1.0, 0.0, 1.0], + [1.0, 1.0, 1.0], + [11.0, 11.0, 11.0], + [21.0, 21.0, 21.0], + [31.0, 31.0, 31.0], + [31.0, 41.0, 41.0], + [31.0, 51.0, 51.0], + [771.0, 61.0, 1.0], + [0.0, 1.0, 1.0] + ], + "something-else": { + "this": 1.0, + "that": "blablabla" + }, + "geometry-templates": { + "templates": [ + { + "type": "MultiSurface", + "lod": 2, + "boundaries": [ + [[0, 3, 2, 1]], [[4, 5, 6, 7]], [[0, 1, 5, 4]] + ] + }, + { + "type": "MultiSurface", + "lod": 2, + "boundaries": [ + [[1, 2, 6, 5]], [[2, 3, 7, 6]], [[3, 0, 4, 7]] + ] + } + ], + "vertices-templates": [ + [0.0, 0.5, 0.0], + [1.0, 0.0, 0.0], + [11.0, 0.0, 0.0], + [11.0, 10.0, 0.0], + [1.0, 12.0, 0.0], + [1.0, 40.0, 0.0], + [1.0, 1.0, 0.0], + [0.0, 1.0, 0.0] + ] + }, + "appearance": { + "default-theme-texture": "summer-textures", + "default-theme-material": "irradiation", + "vertices-texture": [ + [0.0, 0.5], + [1.0, 0.0], + [1.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0], + [0.0, 1.0] + ], + "textures": [ + { + "type": "PNG", + "image": "myfacade.png" + }, + { + "type": "JPG", + "image": "myroof.jpg" + }, + { + "type": "JPG", + "image": "mymymy.jpg" + } + ], + "materials": [ + { + "name": "irradiation-0-50", + "ambientIntensity": 0.7500, + "diffuseColor": [0.9000, 0.1000, 0.7500], + "specularColor": [0.9000, 0.1000, 0.7500], + "transparency": 1.0 + }, + { + "name": "irradiation-51-80", + "diffuseColor": [0.9000, 0.1000, 0.7500], + "shininess": 0.0, + "transparency": 0.5, + "isSmooth": true + }, + { + "name": "irradiation-81-100", + "diffuseColor": [0.1900, 0.1100, 0.1750], + "shininess": 0.2, + "transparency": 0.9, + "isSmooth": true + } + ] + } +} diff --git a/example_data/rotterdam/rotterdam_one.json b/example_data/rotterdam/rotterdam_one.json new file mode 100644 index 0000000..7b4c585 --- /dev/null +++ b/example_data/rotterdam/rotterdam_one.json @@ -0,0 +1,842 @@ +{ + "type": "CityJSON", + "version": "0.6", + "CityObjects": + { + "{CD98680D-A8DD-4106-A18E-15EE2A908D75}": + { + "type": "Building", + "attributes": + { + "TerrainHeight": 2.93, + "bron_tex": "UltraCAM-X 10cm juni 2008", + "voll_tex": "complete", + "bron_geo": "Lidar 15-30 punten - nov. 2008", + "status": "1" + }, + + "geometry": + [ + { + "type": "MultiSurface", + "boundaries": + [ + [ + [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ] + ], + + [ + [ + 7, + 8, + 8, + 9, + 10 + ] + ], + + [ + [ + 11, + 12, + 13, + 14 + ] + ], + + [ + [ + 15, + 16, + 17, + 18 + ] + ], + + [ + [ + 1, + 0, + 19, + 15 + ] + ], + + [ + [ + 0, + 6, + 20, + 19 + ] + ], + + [ + [ + 6, + 5, + 12, + 11 + ] + ], + + [ + [ + 5, + 4, + 13, + 12 + ] + ], + + [ + [ + 3, + 2, + 7, + 10 + ] + ], + + [ + [ + 2, + 1, + 21, + 22 + ] + ], + + [ + [ + 9, + 8, + 18, + 17 + ] + ], + + [ + [ + 8, + 8, + 18, + 18 + ] + ], + + [ + [ + 8, + 7, + 23, + 24 + ] + ], + + [ + [ + 11, + 14, + 16, + 20 + ] + ] + ], + + "semantics": + { + "values": + [ + 0, + 0, + 0, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ], + + "surfaces": + [ + { + "type": "RoofSurface" + }, + + { + "type": "GroundSurface" + }, + + { + "type": "WallSurface" + } + ] + }, + + "texture": + { + "rgbTexture": + { + "values": + [ + [ + [ + 0, + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ] + ], + + [ + [ + 1, + 7, + 8, + 8, + 9, + 10 + ] + ], + + [ + [ + 2, + 11, + 12, + 13, + 14 + ] + ], + + [ + [ + null + ] + ], + + [ + [ + 1, + 15, + 16, + 17, + 18 + ] + ], + + [ + [ + 1, + 19, + 20, + 21, + 22 + ] + ], + + [ + [ + 3, + 23, + 24, + 25, + 26 + ] + ], + + [ + [ + 2, + 27, + 28, + 29, + 30 + ] + ], + + [ + [ + 1, + 31, + 32, + 33, + 34 + ] + ], + + [ + [ + 2, + 35, + 36, + 37, + 38 + ] + ], + + [ + [ + 4, + 39, + 40, + 41, + 42 + ] + ], + + [ + [ + 5, + 43, + 43, + 44, + 44 + ] + ], + + [ + [ + 3, + 45, + 46, + 47, + 48 + ] + ], + + [ + [ + 4, + 49, + 50, + 51, + 52 + ] + ] + ] + } + }, + + "lod": 2 + } + ] + } + }, + + "vertices": + [ + [ + 524038, + 209058, + 15311 + ], + + [ + 523657, + 208741, + 15311 + ], + + [ + 527714, + 203869, + 15311 + ], + + [ + 532519, + 207703, + 15311 + ], + + [ + 529417, + 211476, + 15311 + ], + + [ + 525121, + 207919, + 15311 + ], + + [ + 524122, + 209126, + 15311 + ], + + [ + 527714, + 203869, + 11136 + ], + + [ + 529970, + 201158, + 11136 + ], + + [ + 534759, + 204979, + 11136 + ], + + [ + 532519, + 207703, + 11136 + ], + + [ + 524122, + 209126, + 12869 + ], + + [ + 525121, + 207919, + 12869 + ], + + [ + 529417, + 211476, + 12869 + ], + + [ + 528421, + 212688, + 12869 + ], + + [ + 523657, + 208741, + 0 + ], + + [ + 528421, + 212688, + 0 + ], + + [ + 534759, + 204979, + 0 + ], + + [ + 529970, + 201158, + 0 + ], + + [ + 524038, + 209058, + 0 + ], + + [ + 524122, + 209126, + 0 + ], + + [ + 523657, + 208741, + 15151 + ], + + [ + 527714, + 203869, + 15151 + ], + + [ + 527714, + 203869, + 10976 + ], + + [ + 529970, + 201158, + 10976 + ] + ], + + "transform": + { + "scale": + [ + 0.001, + 0.001, + 0.001 + ], + + "translate": + [ + 90409.32, + 435440.44, + 0.0 + ] + }, + + "appearance": + { + "textures": + [ + { + "type": "JPG", + "image": "appearances/0320_4_15.jpg" + }, + + { + "type": "JPG", + "image": "appearances/0320_4_16.jpg" + }, + + { + "type": "JPG", + "image": "appearances/0320_4_18.jpg" + }, + + { + "type": "JPG", + "image": "appearances/0320_4_19.jpg" + }, + + { + "type": "JPG", + "image": "appearances/0320_4_13.jpg" + }, + + { + "type": "JPG", + "image": "appearances/0320_4_17.jpg" + } + ], + + "vertices-texture": + [ + [ + 0.033, + 0.8854 + ], + + [ + 0.0372, + 0.8803 + ], + + [ + 0.1023, + 0.9349 + ], + + [ + 0.0507, + 0.9991 + ], + + [ + 0.0003, + 0.9573 + ], + + [ + 0.0482, + 0.9 + ], + + [ + 0.0321, + 0.8865 + ], + + [ + 0.314, + 0.3067 + ], + + [ + 0.2779, + 0.2764 + ], + + [ + 0.3291, + 0.2126 + ], + + [ + 0.3654, + 0.2427 + ], + + [ + 0.2542, + 0.25 + ], + + [ + 0.2703, + 0.2634 + ], + + [ + 0.2225, + 0.3206 + ], + + [ + 0.2064, + 0.3073 + ], + + [ + 0.455, + 0.0706 + ], + + [ + 0.4507, + 0.0756 + ], + + [ + 0.3687, + 0.0328 + ], + + [ + 0.3729, + 0.0279 + ], + + [ + 0.8032, + 0.3657 + ], + + [ + 0.8023, + 0.3668 + ], + + [ + 0.7203, + 0.3239 + ], + + [ + 0.7212, + 0.3228 + ], + + [ + 0.6559, + 0.4971 + ], + + [ + 0.6721, + 0.5104 + ], + + [ + 0.6587, + 0.5213 + ], + + [ + 0.6426, + 0.508 + ], + + [ + 0.5318, + 0.9429 + ], + + [ + 0.4835, + 0.9991 + ], + + [ + 0.4704, + 0.992 + ], + + [ + 0.5186, + 0.9359 + ], + + [ + 0.9671, + 0.1619 + ], + + [ + 0.9159, + 0.2256 + ], + + [ + 0.8889, + 0.222 + ], + + [ + 0.9399, + 0.1584 + ], + + [ + 0.1395, + 0.0753 + ], + + [ + 0.2038, + 0.1301 + ], + + [ + 0.2028, + 0.1305 + ], + + [ + 0.1385, + 0.0758 + ], + + [ + 0.1218, + 0.8882 + ], + + [ + 0.071, + 0.9515 + ], + + [ + 0.0, + 0.9421 + ], + + [ + 0.0504, + 0.8794 + ], + + [ + 0.7683, + 0.9476 + ], + + [ + 0.6973, + 0.9382 + ], + + [ + 0.4918, + 0.2573 + ], + + [ + 0.5275, + 0.2877 + ], + + [ + 0.5265, + 0.2881 + ], + + [ + 0.4908, + 0.2578 + ], + + [ + 0.4863, + 0.3843 + ], + + [ + 0.4381, + 0.4404 + ], + + [ + 0.3698, + 0.4039 + ], + + [ + 0.4175, + 0.3483 + ] + ] + }, + + "metadata": + { + "crs": + { + "epsg": 28992 + }, + + "bbox": + [ + 90932.97700000001, + 435641.598, + 0.0, + 90944.07900000001, + 435653.128, + 15.311 + ], + + "presentLoDs": + [ + 2 + ] + } +} \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 60bd34d..fd78971 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,4 +2,7 @@ universal = 1 [metadata] -license_file = LICENSE \ No newline at end of file +license_file = LICENSE + +[tool:pytest] +log_cli = true \ No newline at end of file diff --git a/test/conftest.py b/test/conftest.py deleted file mode 100644 index 8b13789..0000000 --- a/test/conftest.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/subset_cmd.sh b/test/subset_cmd.sh deleted file mode 100644 index ec5b1c7..0000000 --- a/test/subset_cmd.sh +++ /dev/null @@ -1 +0,0 @@ -cjio /home/balazs/Data/cityjson/rotterdam/rotterdam/3-20-DELFSHAVEN_uncompressed.json subset --id {23D8CA22-0C82-4453-A11E-B3F2B3116DB4} --id {8244B286-63E2-436E-9D4E-169B8ACFE9D0} --id {6271F75F-E8D8-4EE4-AC46-9DB02771A031} --id {87316D28-7574-4763-B9CE-BF6A2DF8092C} --id {DE77E78F-B110-43D2-A55C-8B61911192DE} --id {237D41CC-991E-4308-8986-42ABFB4F7431} --id {C6AAF95B-8C09-4130-AB4D-6777A2A18A2E} --id {C9D4A5CF-094A-47DA-97E4-4A3BFD75D3AE} --id {64A9018E-4F56-47CD-941F-43F6F0C4285B} --id {8D716FDE-18DD-4FB5-AB06-9D207377240E} --id {71B60053-BC28-404D-BAB9-8A642AAC0CF4} --id {953BC999-2F92-4B38-95CF-218F7E05AFA9} --id {72390BDE-903C-4C8C-8A3F-2DF5647CD9B4} --id {459F183A-D0C2-4F8A-8B5F-C498EFDE366D} --id {19935DFC-F7B3-4D6E-92DD-C48EE1D1519A} --id {CD98680D-A8DD-4106-A18E-15EE2A908D75} save ./data/rotterdam.json diff --git a/test/__init__.py b/tests/__init__.py similarity index 100% rename from test/__init__.py rename to tests/__init__.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..052336c --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,29 @@ +import os.path + +import pytest + +from cjio import cityjson + + +@pytest.fixture(scope='session') +def data_dir(): + yield os.path.abspath('example_data') + +@pytest.fixture(scope='session') +def rotterdam(data_dir): + p = os.path.join(data_dir, 'rotterdam', '3-20-DELFSHAVEN_uncompressed.json') + with open(p, 'r') as f: + yield cityjson.CityJSON(file=f) + +@pytest.fixture(scope='session') +def rotterdam_subset(data_dir): + p = os.path.join(data_dir, 'rotterdam', 'rotterdam_subset.json') + with open(p, 'r') as f: + yield cityjson.CityJSON(file=f) + +@pytest.fixture(scope='session') +def dummy(data_dir): + p = os.path.join(data_dir, 'dummy', 'dummy.json') + with open(p, 'r') as f: + yield cityjson.CityJSON(file=f) + diff --git a/tests/subset_cmd.sh b/tests/subset_cmd.sh new file mode 100644 index 0000000..7216b63 --- /dev/null +++ b/tests/subset_cmd.sh @@ -0,0 +1,3 @@ +cjio /home/balazs/Data/cityjson/rotterdam/3-20-DELFSHAVEN_uncompressed.json subset --id {23D8CA22-0C82-4453-A11E-B3F2B3116DB4} --id {8244B286-63E2-436E-9D4E-169B8ACFE9D0} --id {6271F75F-E8D8-4EE4-AC46-9DB02771A031} --id {87316D28-7574-4763-B9CE-BF6A2DF8092C} --id {DE77E78F-B110-43D2-A55C-8B61911192DE} --id {237D41CC-991E-4308-8986-42ABFB4F7431} --id {C6AAF95B-8C09-4130-AB4D-6777A2A18A2E} --id {C9D4A5CF-094A-47DA-97E4-4A3BFD75D3AE} --id {64A9018E-4F56-47CD-941F-43F6F0C4285B} --id {8D716FDE-18DD-4FB5-AB06-9D207377240E} --id {71B60053-BC28-404D-BAB9-8A642AAC0CF4} --id {953BC999-2F92-4B38-95CF-218F7E05AFA9} --id {72390BDE-903C-4C8C-8A3F-2DF5647CD9B4} --id {459F183A-D0C2-4F8A-8B5F-C498EFDE366D} --id {19935DFC-F7B3-4D6E-92DD-C48EE1D1519A} --id {CD98680D-A8DD-4106-A18E-15EE2A908D75} save ./data/rotterdam.json + +cjio /home/balazs/Data/cityjson/rotterdam/3-20-DELFSHAVEN.json subset --id {23D8CA22-0C82-4453-A11E-B3F2B3116DB4} --id {8244B286-63E2-436E-9D4E-169B8ACFE9D0} --id {6271F75F-E8D8-4EE4-AC46-9DB02771A031} --id {87316D28-7574-4763-B9CE-BF6A2DF8092C} --id {DE77E78F-B110-43D2-A55C-8B61911192DE} --id {237D41CC-991E-4308-8986-42ABFB4F7431} --id {C6AAF95B-8C09-4130-AB4D-6777A2A18A2E} --id {C9D4A5CF-094A-47DA-97E4-4A3BFD75D3AE} --id {64A9018E-4F56-47CD-941F-43F6F0C4285B} --id {8D716FDE-18DD-4FB5-AB06-9D207377240E} --id {71B60053-BC28-404D-BAB9-8A642AAC0CF4} --id {953BC999-2F92-4B38-95CF-218F7E05AFA9} --id {72390BDE-903C-4C8C-8A3F-2DF5647CD9B4} --id {459F183A-D0C2-4F8A-8B5F-C498EFDE366D} --id {19935DFC-F7B3-4D6E-92DD-C48EE1D1519A} --id {CD98680D-A8DD-4106-A18E-15EE2A908D75} save ./data/rotterdam2.json \ No newline at end of file diff --git a/tests/test_subset.py b/tests/test_subset.py new file mode 100644 index 0000000..d52e901 --- /dev/null +++ b/tests/test_subset.py @@ -0,0 +1,13 @@ +import os.path + +import pytest + +def test_get_texture_location_subdir(rotterdam_subset): + d = rotterdam_subset.get_texture_location() + loc = os.path.abspath('example_data/rotterdam/appearances') + assert d == loc + +def test_get_texture_location_same(dummy): + d = dummy.get_texture_location() + loc = os.path.abspath('example_data/dummy') + assert d == loc \ No newline at end of file