Fixed unit tests, updated docs

pull/230/head
Piero Toffanin 2017-07-10 10:30:33 -04:00
rodzic 9039dca53d
commit af47383a6c
7 zmienionych plików z 39 dodań i 27 usunięć

Wyświetl plik

@ -5,10 +5,10 @@ from __future__ import unicode_literals
from django.contrib.gis.gdal import GDALRaster, OGRGeometry
from django.contrib.gis.geos import GEOSGeometry
from django.db import migrations
from app.models import Task
import os
def transfer_existing_orthophoto_extent_values(apps, schema_editor):
Task = apps.get_model('app', 'Task')
for t in Task.objects.all():
print("Checking {}".format(t))

Wyświetl plik

@ -4,10 +4,11 @@ from __future__ import unicode_literals
import django.contrib.postgres.fields
from django.db import migrations, models
from app.models import Task
def detect_available_assets(apps, schema_editor):
Task = apps.get_model('app', 'Task')
for t in Task.objects.all():
print("Updating {}".format(t))
t.update_available_assets_field(True)

Wyświetl plik

@ -450,6 +450,7 @@ class Task(models.Model):
logger.info("Populated orthophoto_extent for {}".format(self))
self.update_available_assets_field()
self.save()
else:
# FAILED, CANCELED

Wyświetl plik

@ -7,6 +7,7 @@ import shutil
import logging
from datetime import timedelta
import json
import requests
from django.contrib.auth.models import User
from django.contrib.gis.gdal import GDALRaster
@ -172,8 +173,8 @@ class TestApiTask(BootTransactionTestCase):
self.assertTrue(res.status_code == status.HTTP_404_NOT_FOUND)
# Cannot download assets (they don't exist yet)
for asset in task.ASSET_DOWNLOADS:
res = client.get("/api/projects/{}/tasks/{}/download/{}/".format(project.id, task.id, asset))
for asset in list(task.ASSETS_MAP.keys()):
res = client.get("/api/projects/{}/tasks/{}/download/{}".format(project.id, task.id, asset))
self.assertTrue(res.status_code == status.HTTP_404_NOT_FOUND)
# Cannot access raw assets (they don't exist yet)
@ -213,21 +214,28 @@ class TestApiTask(BootTransactionTestCase):
self.assertTrue(task.status == status_codes.COMPLETED)
# Can download assets
for asset in task.ASSET_DOWNLOADS:
res = client.get("/api/projects/{}/tasks/{}/download/{}/".format(project.id, task.id, asset))
for asset in list(task.ASSETS_MAP.keys()):
res = client.get("/api/projects/{}/tasks/{}/download/{}".format(project.id, task.id, asset))
self.assertTrue(res.status_code == status.HTTP_200_OK)
# A textured mesh archive file should exist
self.assertTrue(os.path.exists(task.assets_path(task.get_textured_model_filename())))
self.assertTrue(os.path.exists(task.assets_path(task.ASSETS_MAP["textured_model.zip"]["deferred_path"])))
# Can download raw assets
res = client.get("/api/projects/{}/tasks/{}/assets/odm_orthophoto/odm_orthophoto.tif".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_200_OK)
# Can access tiles.json and individual tiles
# Can access tiles.json
res = client.get("/api/projects/{}/tasks/{}/tiles.json".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_200_OK)
# Bounds are what we expect them to be
# (4 coords in lat/lon)
tiles = json.loads(res.content)
self.assertTrue(len(tiles['bounds']) == 4)
self.assertTrue(tiles['bounds'][0] == -91.99451323800884)
# Can access individual tiles
res = client.get("/api/projects/{}/tasks/{}/tiles/16/16020/42443.png".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_200_OK)
@ -371,11 +379,11 @@ class TestApiTask(BootTransactionTestCase):
# orthophoto_extent should be none
self.assertTrue(task.orthophoto_extent is None)
# Available assets should be missing the geotiff type
# but others such as texturedmodel should be available
# Available assets should be missing orthophoto.tif type
# but others such as textured_model.zip should be available
res = client.get("/api/projects/{}/tasks/{}/".format(project.id, task.id))
self.assertFalse('geotiff' in res.data['available_assets'])
self.assertTrue('texturedmodel' in res.data['available_assets'])
self.assertFalse('orthophoto.tif' in res.data['available_assets'])
self.assertTrue('textured_model.zip' in res.data['available_assets'])
image1.close()
image2.close()

Wyświetl plik

@ -76,7 +76,7 @@ if 'token' in res:
sys.stdout.write("\rProcessing... [%02d:%02d:%02d]" % (h, m, s))
sys.stdout.flush()
res = requests.get("http://localhost:8000/api/projects/{}/tasks/{}/download/geotiff/".format(project_id, task_id),
res = requests.get("http://localhost:8000/api/projects/{}/tasks/{}/download/orthophoto.tif".format(project_id, task_id),
headers={'Authorization': 'JWT {}'.format(token)},
stream=True)
with open("orthophoto.tif", 'wb') as f:

Wyświetl plik

@ -86,7 +86,7 @@ We periodically check for the [Task](#task) status using a loop.
<div class="clear"></div>
```python
res = requests.get("http://localhost:8000/api/projects/{}/tasks/{}/download/geotiff/".format(project_id, task_id),
res = requests.get("http://localhost:8000/api/projects/{}/tasks/{}/download/orthophoto.tif".format(project_id, task_id),
headers={'Authorization': 'JWT {}'.format(token)},
stream=True)
with open("orthophoto.tif", 'wb') as f:

Wyświetl plik

@ -9,12 +9,13 @@
"processing_node": 10,
"images_count": 48,
"available_assets": [
"all",
"geotiff",
"texturedmodel",
"las",
"csv",
"ply"
"all.zip",
"orthophoto.tif",
"orthophoto.png",
"georeferenced_model.las",
"georeferenced_model.ply",
"georeferenced_model.csv",
"textured_model.zip"
],
"uuid": "4338d684-91b4-49a2-b907-8ba171894393",
"name": "Task Name",
@ -118,16 +119,17 @@ Retrieves all [Task](#task) items associated with `project_id`.
`GET /api/projects/{project_id}/tasks/{task_id}/download/{asset}/`
After a task has been successfully processed, the user can download several assets from this URL. Not all assets are always available. For example if GPS information is missing from the input images, the `geotiff` asset will be missing. You can check the `available_assets` property of a [Task](#task) to see which assets are available for download.
After a task has been successfully processed, the user can download several assets from this URL. Not all assets are always available. For example if GPS information is missing from the input images, the `orthophoto.tif` asset will be missing. You can check the `available_assets` property of a [Task](#task) to see which assets are available for download.
Asset | Description
----- | -----------
all | Archive (.zip) containing all assets, including an orthophoto, TMS tiles, a textured 3D model and point cloud in various formats.
geotiff | GeoTIFF orthophoto.
texturedmodel | Archive (.zip) containing the textured 3D model
las | Point cloud in .LAS format.
ply | Point cloud in .PLY format.
csv | Point cloud in .CSV format.
all.zip | Archive (.zip) containing all assets, including an orthophoto, TMS tiles, a textured 3D model and point cloud in various formats.
orthophoto.tif | GeoTIFF orthophoto.
orthophoto.png | PNG orthophoto.
textured_model.zip | Archive containing the textured 3D model
georeferenced_model.las | Point cloud in .LAS format.
georeferenced_model.ply | Point cloud in .PLY format.
georeferenced_model.csv | Point cloud in .CSV format.
### Download assets (raw path)