Browse Source

Add kind field to reference points

Olivier Le Brouster 7 years ago
parent
commit
3fee668011

+ 2 - 2
panorama/admin.py

@@ -37,5 +37,5 @@ class PanoramaAdmin(admin.ModelAdmin):
 @admin.register(ReferencePoint)
 class ReferencePointAdmin(admin.ModelAdmin):
     model = ReferencePoint
-    list_display = ('name', 'latitude', 'longitude', 'altitude')
-    fields = ('name', ('latitude', 'longitude'), 'altitude')
+    list_display = ('name', 'latitude', 'longitude', 'altitude', 'kind')
+    fields = ('name', ('latitude', 'longitude'), 'altitude', 'kind')

+ 1 - 1
panorama/forms.py

@@ -35,4 +35,4 @@ class ReferencePointForm(forms.ModelForm):
 
     class Meta:
         model = ReferencePoint
-        fields = ['name', 'latitude', 'longitude', 'altitude']
+        fields = ['name', 'latitude', 'longitude', 'altitude', 'kind']

+ 62 - 0
panorama/migrations/0005_auto_20170912_2147.py

@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.13 on 2017-09-12 21:47
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('panorama', '0004_auto_20150310_1906'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='panorama',
+            options={'verbose_name': 'panorama', 'verbose_name_plural': 'panoramas'},
+        ),
+        migrations.AlterModelOptions(
+            name='reference',
+            options={'verbose_name': 'reference', 'verbose_name_plural': 'references'},
+        ),
+        migrations.AlterModelOptions(
+            name='referencepoint',
+            options={'verbose_name': 'reference point', 'verbose_name_plural': 'reference points'},
+        ),
+        migrations.AddField(
+            model_name='referencepoint',
+            name='kind',
+            field=models.CharField(choices=[('waiting', 'waiting'), ('subscriber', 'subscriber'), ('other', 'other')], default='waiting', max_length=255, verbose_name='kind'),
+        ),
+        migrations.AlterField(
+            model_name='panorama',
+            name='image_height',
+            field=models.PositiveIntegerField(default=0, verbose_name='image height'),
+        ),
+        migrations.AlterField(
+            model_name='panorama',
+            name='image_width',
+            field=models.PositiveIntegerField(default=0, verbose_name='image width'),
+        ),
+        migrations.AlterField(
+            model_name='panorama',
+            name='references',
+            field=models.ManyToManyField(related_name='referenced_panorama', through='panorama.Reference', to='panorama.ReferencePoint', verbose_name='references'),
+        ),
+        migrations.AlterField(
+            model_name='reference',
+            name='panorama',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='panorama_references', to='panorama.Panorama', verbose_name='panorama'),
+        ),
+        migrations.AlterField(
+            model_name='reference',
+            name='reference_point',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='refpoint_references', to='panorama.ReferencePoint', verbose_name='reference point'),
+        ),
+        migrations.AlterUniqueTogether(
+            name='reference',
+            unique_together=set([]),
+        ),
+    ]

+ 12 - 0
panorama/models.py

@@ -107,6 +107,18 @@ class ReferencePoint(Point):
     name = models.CharField(verbose_name=_("name"), max_length=255,
                             help_text=_("Name of the point"))
 
+    KIND_OTHER = 'other'
+    KIND_SUBSCRIBER = 'subscriber'
+    KIND_WAITING = 'waiting'
+    KIND_CHOICES = (
+        (KIND_WAITING, _('waiting')),
+        (KIND_SUBSCRIBER, _('subscriber')),
+        (KIND_OTHER, _('other')),
+    )
+
+    kind = models.CharField(verbose_name=_('kind'), max_length=255,
+                            choices=KIND_CHOICES, default=KIND_WAITING)
+
     def __str__(self):
         return self.name
 

BIN
panorama/static/panorama/img/marker-circle-orange.png


BIN
panorama/static/panorama/img/marker-circle-purple.png


+ 3 - 0
panorama/static/panorama/js/pano.js

@@ -31,6 +31,9 @@ var point_colors = {
     'pano_point' : '255,128,128', // red
     'ref_point'  : '128,128,255', // blue
     'loc_point'  : '128,255,128', // green
+    'loc_point_other'  : '128,255,128', // green
+    'loc_point_subscriber'  : '255,128,255', // purple
+    'loc_point_waiting'  : '255,196,128', // orange
     'temporary'  : '255,255,128', // yellow
     'unlocated'  : '255,255,255'  // white
 };

+ 25 - 9
panorama/templates/panorama/main.html

@@ -94,12 +94,27 @@
             iconAnchor: [11, 35],
             popupAnchor: [0,-50]
         });
-        var poiIcon = L.icon({
-            iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
-            iconSize: [20, 20],
-            iconAnchor: [10, 10],
-            popupAnchor: [0,-20]
-        });
+        var poiIcons = {
+          subscriber: L.icon({
+              iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
+              iconSize: [20, 20],
+              iconAnchor: [10, 10],
+              popupAnchor: [0,-20]
+          }),
+          waiting: L.icon({
+              iconUrl: '{% static "panorama/img/marker-circle-orange.png" %}',
+              iconSize: [20, 20],
+              iconAnchor: [10, 10],
+              popupAnchor: [0,-20]
+          }),
+          other: L.icon({
+              iconUrl: '{% static "panorama/img/marker-circle-purple.png" %}',
+              iconSize: [20, 20],
+              iconAnchor: [10, 10],
+              popupAnchor: [0,-20]
+          }),
+        };
+
         var legend = L.control({position: 'bottomright'});
     
         function accordionMenus() {
@@ -250,9 +265,8 @@
             map.addLayer( markerClusters );
             // Add POI
             var pointsOfInterest = L.layerGroup();
-            var options = {icon: poiIcon, riseOnHover: true};
             {% for poi in poi_list %}
-                var poiMarker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], options);
+                var poiMarker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], {icon: poiIcons['{{ poi.kind }}'], riseOnHover: true});
                 var poiPopup = poiMarker.bindPopup('{{ poi.name }}', {className : 'markerpopup', closeButton: false});
                 poiPopup.on('mouseover', poiMarker.openPopup);
                 poiPopup.on('mouseout', poiMarker.closePopup);
@@ -264,7 +278,9 @@
                 div.innerHTML += '<div class="legendtitle"><p><i class="fa fa-fw fa-caret-down"></i>{% trans "Legend" %}</p></div>';
                 div.innerHTML += '<img src={% static "panorama/img/marker-red.png" %} ><p>{% trans "Panorama" %}</p></br>';
                 div.innerHTML += '<img src={% static "panorama/img/marker-blue.png" %} ><p>{% trans "Control" %}</p></br>';
-                div.innerHTML += '<img src={% static "panorama/img/marker-circle-green.png" %} ><p>{% trans "Point of interest" %}</p></br>';
+                div.innerHTML += '<img src={% static "panorama/img/marker-circle-green.png" %} ><p>{% trans "Point of interest (subscriber)" %}</p></br>';
+                div.innerHTML += '<img src={% static "panorama/img/marker-circle-orange.png" %} ><p>{% trans "Point of interest (waiting)" %}</p></br>';
+                div.innerHTML += '<img src={% static "panorama/img/marker-circle-purple.png" %} ><p>{% trans "Point of interest (other)" %}</p></br>';
                 return div;
             };
             map.addLayer(pointsOfInterest);

+ 1 - 0
panorama/templates/panorama/sidebar-all.html

@@ -27,6 +27,7 @@
                         {{ 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.kind.label_tag }}{{ newrefpoint_form.kind }}
                         <input type="submit" class="btn btn-primary btn-sm" value={% trans "Add" %} />
                     </form>
                 </li>

+ 17 - 5
panorama/templates/panorama/view.html

@@ -73,14 +73,27 @@
           iconAnchor: [11, 35],
           popupAnchor: [0,-50]
       });
-      var poiIcon = L.icon({
+      var poiIcons = {
+        subscriber: L.icon({
             iconUrl: '{% static "panorama/img/marker-circle-green.png" %}',
             iconSize: [20, 20],
             iconAnchor: [10, 10],
             popupAnchor: [0,-20]
-      });
+        }),
+        waiting: L.icon({
+            iconUrl: '{% static "panorama/img/marker-circle-orange.png" %}',
+            iconSize: [20, 20],
+            iconAnchor: [10, 10],
+            popupAnchor: [0,-20]
+        }),
+        other: L.icon({
+            iconUrl: '{% static "panorama/img/marker-circle-purple.png" %}',
+            iconSize: [20, 20],
+            iconAnchor: [10, 10],
+            popupAnchor: [0,-20]
+        }),
+      };
 
-      
       {% for pano in panoramas %}
           {% if panorama.name != pano.name  %}
               var marker = L.marker([{{ pano.latitude }}, {{ pano.longitude }}], {icon: panoIcon, riseOnHover: true});
@@ -93,9 +106,8 @@
       {% endfor %}
 
       var pointsOfInterest = L.layerGroup();
-      var poiOptions = {icon: poiIcon, riseOnHover: true};
       {% for poi in poi_list %}
-          var marker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], poiOptions);
+          var marker = L.marker([{{ poi.latitude }}, {{ poi.longitude }}], {icon: poiIcons['{{ poi.kind }}'], riseOnHover: true});
           var poiPopup = marker.bindPopup('{{ poi.name }}', {className : 'markerpopup', closeButton: false});
           poiPopup.on('mouseover', marker.openPopup);
           poiPopup.on('mouseout', marker.closePopup);