Commit 028abfd9 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Separate altitude into two parts: ground altitude, and height above ground

parent 9dde1b8c
......@@ -22,7 +22,7 @@ class PanoramaAdmin(admin.ModelAdmin):
inlines = (ReferenceInline, )
list_display = ('name', 'has_tiles', 'latitude', 'longitude', 'altitude', 'loop')
fields = ('name', ('image', 'image_width', 'image_height'),
'loop', ('latitude', 'longitude'), 'altitude')
'loop', ('latitude', 'longitude'), ('ground_altitude', 'height_above_ground'))
readonly_fields = ('image_width', 'image_height')
actions = ('regenerate_tiles', )
......@@ -38,4 +38,4 @@ class PanoramaAdmin(admin.ModelAdmin):
class ReferencePointAdmin(admin.ModelAdmin):
model = ReferencePoint
list_display = ('name', 'latitude', 'longitude', 'altitude', 'kind')
fields = ('name', ('latitude', 'longitude'), 'altitude', 'kind')
fields = ('name', ('latitude', 'longitude'), ('ground_altitude', 'height_above_ground'), 'kind')
......@@ -19,7 +19,7 @@ class CustomPointForm(forms.ModelForm):
class Meta:
model = Point
fields = ['latitude', 'longitude', 'altitude']
fields = ['latitude', 'longitude', 'ground_altitude', 'height_above_ground']
class PanoramaForm(forms.ModelForm):
"""Form to insert a new panorama."""
......@@ -27,7 +27,7 @@ class PanoramaForm(forms.ModelForm):
class Meta:
model = Panorama
fields = ['name', 'image', 'loop', 'latitude', 'longitude', 'altitude']
fields = ['name', 'image', 'loop', 'latitude', 'longitude', 'ground_altitude', 'height_above_ground']
class ReferencePointForm(forms.ModelForm):
"""Form to insert a new reference point"""
......@@ -35,4 +35,4 @@ class ReferencePointForm(forms.ModelForm):
class Meta:
model = ReferencePoint
fields = ['name', 'latitude', 'longitude', 'altitude', 'kind']
fields = ['name', 'latitude', 'longitude', 'ground_altitude', 'height_above_ground', 'kind']
......@@ -40,7 +40,7 @@ class Command(BaseCommand):
data = json.load(sys.stdin)
p = Panorama(name=data["titre"], latitude=float(data["latitude"]),
longitude=float(data["longitude"]),
altitude=float(data["altitude"]),
ground_altitude=float(data["altitude"]),
loop=data["image_loop"])
# http://www.revsys.com/blog/2014/dec/03/loading-django-files-from-code/
with open(args[0], "rb") as f:
......
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-07-01 15:05
from __future__ import unicode_literals
from django.db import migrations, models
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('panorama', '0005_auto_20170912_2147'),
]
operations = [
migrations.RenameField(
model_name='referencepoint',
old_name='altitude',
new_name='ground_altitude',
),
migrations.AlterField(
model_name='referencepoint',
name='ground_altitude',
field=models.FloatField(help_text='In meters', validators=[django.core.validators.MinValueValidator(0.0)], verbose_name='altitude at ground level'),
),
migrations.AddField(
model_name='referencepoint',
name='height_above_ground',
field=models.FloatField(default=0.0, help_text='In meters', verbose_name='height above ground'),
),
migrations.AlterUniqueTogether(
name='reference',
unique_together=set([('reference_point', 'panorama')]),
),
]
......@@ -30,6 +30,17 @@ class Point(models.Model):
altitude = models.FloatField(verbose_name=_("altitude"), help_text=_("In meters"),
validators=[MinValueValidator(0.)])
ground_altitude = models.FloatField(verbose_name=_("altitude at ground level"),
help_text=_("In meters"),
validators=[MinValueValidator(0.)])
height_above_ground = models.FloatField(verbose_name=_("height above ground"),
help_text=_("In meters"),
default=0.)
@property
def altitude(self):
return self.ground_altitude + self.height_above_ground
@property
def latitude_rad(self):
return radians(self.latitude)
......
......@@ -144,9 +144,9 @@
$('#id_newrefpoint-longitude').val(lng);
$.get("/altitude/" + lat + "/" + lng + "/").done(
function(data) {
$('#id_custompoint-altitude').val(parseInt(data));
$('#id_newpano-altitude').val(parseInt(data));
$('#id_newrefpoint-altitude').val(parseInt(data));
$('#id_custompoint-ground_altitude').val(parseInt(data));
$('#id_newpano-ground_altitude').val(parseInt(data));
$('#id_newrefpoint-ground_altitude').val(parseInt(data));
});
}
function SearchPlace() {
......
......@@ -12,7 +12,8 @@
<form action="{% url 'panorama:locate_custompoint' %}" enctype="multipart/form-data" method="post">{% csrf_token %}
{{ custom_point_form.latitude.label_tag }}{{ custom_point_form.latitude }}
{{ custom_point_form.longitude.label_tag }}{{ custom_point_form.longitude }}
{{ custom_point_form.altitude.label_tag }}{{ custom_point_form.altitude }}
{{ custom_point_form.ground_altitude.label_tag }}{{ custom_point_form.ground_altitude }}
{{ custom_point_form.height_above_ground.label_tag }}{{ custom_point_form.height_above_ground }}
<input type="submit" class="btn btn-primary btn-sm" value={% trans "Locate" %} />
</form>
</li>
......@@ -26,7 +27,8 @@
{{ newrefpoint_form.name.label_tag }}{{ newrefpoint_form.name }}
{{ newrefpoint_form.latitude.label_tag }}{{ newrefpoint_form.latitude }}
{{ newrefpoint_form.longitude.label_tag }}{{ newrefpoint_form.longitude }}
{{ newrefpoint_form.altitude.label_tag }}{{ newrefpoint_form.altitude }}
{{ newrefpoint_form.ground_altitude.label_tag }}{{ newrefpoint_form.ground_altitude }}
{{ newrefpoint_form.height_above_ground.label_tag }}{{ newrefpoint_form.height_above_ground }}
{{ newrefpoint_form.kind.label_tag }}{{ newrefpoint_form.kind }}
<input type="submit" class="btn btn-primary btn-sm" value={% trans "Add" %} />
</form>
......@@ -43,7 +45,8 @@
<label for="{{ newpanorama_form.loop.id_for_label }}">{{ newpanorama_form.loop }} {{ newpanorama_form.loop.label }}</label>
{{ newpanorama_form.latitude.label_tag }}{{ newpanorama_form.latitude }}
{{ newpanorama_form.longitude.label_tag }}{{ newpanorama_form.longitude }}
{{ newpanorama_form.altitude.label_tag }}{{ newpanorama_form.altitude }}
{{ newpanorama_form.ground_altitude.label_tag }}{{ newpanorama_form.ground_altitude }}
{{ newpanorama_form.height_above_ground.label_tag }}{{ newpanorama_form.height_above_ground }}
<input type="submit" class="btn btn-primary btn-sm" value={% trans "Add" %} />
</form>
</li>
......
......@@ -135,6 +135,8 @@
<div>
<p>{% trans "latitude:" %} <em><span id="pos_lat">{{ panorama.latitude }}</span>°</em></p>
<p>{% trans "longitude:" %} <em><span id="pos_lon">{{ panorama.longitude }}</span>°</em></p>
<p>{% trans "ground altitude:" %} <em><span id="pos_ground_alt">{{ panorama.ground_altitude }}</span> m</em></p>
<p>{% trans "height above ground:" %} <em><span id="pos_height">{{ panorama.height_above_ground }}</span> m</em></p>
<p>{% trans "altitude:" %} <em><span id="pos_alt">{{ panorama.altitude }}</span> m</em></p>
</div>
</li>
......
......@@ -31,7 +31,7 @@ class CelutzLoginMixin(LoginRequiredMixin):
class PanoramaUpload(CelutzLoginMixin, CreateView):
model = Panorama
fields = ('name', 'image', 'loop', 'latitude', 'longitude', 'altitude')
fields = ('name', 'image', 'loop', 'latitude', 'longitude', 'ground_altitude', 'height_above_ground')
template_name = "panorama/new.html"
prefix = 'newpano'
......@@ -94,7 +94,7 @@ class MainView(CelutzLoginMixin, TemplateView):
class CreateReferencePoint(CelutzLoginMixin, CreateView):
model = ReferencePoint
fields = ('name', 'latitude', 'longitude', 'altitude')
fields = ('name', 'latitude', 'longitude', 'ground_altitude', 'height_above_ground')
template_name = 'panorama/new-refpoint.html'
prefix = 'newrefpoint'
......
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