Commit d27b2769 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Add a command to create a panorama from the command-line

parent 6a5768ac
......@@ -145,3 +145,10 @@ Installing celutz
See ``.
Advanced usage
To create a panorama from the command-line, see:
./ create_pano -h
# -*- coding: utf-8 -*-
Create a panorama from the command line. This is useful when manipulating large image files.
from __future__ import unicode_literals, division, print_function
import sys
import os
from import BaseCommand, CommandError
from django.core.files import File
from django.core.exceptions import ObjectDoesNotExist
from django.conf import settings
from altitude.providers import get_altitude
from panorama.models import Panorama, ReferencePoint, Reference
class Command(BaseCommand):
help = __doc__
def add_arguments(self, parser):
parser.add_argument('--name', '-n', required=True,
help='Name of the panorama')
parser.add_argument('--image', '-i', required=True,
help='Image of the panorama to create')
parser.add_argument('--latitude', '-l', type=float, required=True)
parser.add_argument('--longitude', '-L', type=float, required=True)
parser.add_argument('--height', '-H', type=float, required=True,
help='Height above ground, in meters')
parser.add_argument('--loop', action='store_true', help='Is the image a 360° panorama?')
def handle(self, *args, **options):
self.stdout.write("Getting ground altitude for these coordinates...")
alt = get_altitude([settings.ALTITUDE_PROVIDERS[0]],
self.stdout.write("Ground altitude is {}m".format(alt))
p = Panorama(name=options["name"], latitude=options["latitude"],
with open(options['image'], "rb") as f:
self.stdout.write("Reading image file...")['image']), File(f), save=False)
self.stdout.write("Saving panorama to database...")
self.stdout.write("Launching tile generation...")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment