Commit 7cd7b14e authored by Pierre-antoine Comby's avatar Pierre-antoine Comby

final commit ?

parent c29d48b6
#!/usr/bin/env python
from django.core.management.base import BaseCommand
from django.conf import settings
from django.apps import apps
from indoor.models import *
from django.db import transaction
# from django.contrib.gis.geos import GEOSGeometry
import csv
import os
BDD_DIR = "media/bdd/Base"
WIFI = {"LANDMARK_ID":"landmark_id",
"MINIMUM":"min_val",
"MAXIMUM":"max_val",
"HOTSPOT_ID":"emitter_id"
"HITS":"hits",
"AVERAGE":"average",
"DEVIATION":"deviation",
}
BLUETOOTH = {
}
class Command(BaseCommand):
help = "Import a csv file to a model"
def add_arguments(self, parser):
parser.add_argument("--type",type=str,help="Bluetooth or Wifi ")
parser.add_argument("--file",type=str,help="csv file for import")
def handle(self, *args,**options):
filename=options.get("file",None)
with open(os.path.join(BDD_DIR,filename),'r',encoding='utf-8') as csv_file:
reader = csv.reader((line.replace('\0','') for line in csv_file),delimiter=";")
header = next(reader)
with transaction.atomic():
for row in reader:
for key, value in zip(header,row):
# Generated by Django 2.2.1 on 2019-08-07 22:03
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='BtEmitter',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('ssid', models.CharField(max_length=255)),
('mac_adress', models.CharField(max_length=17)),
('active_flag', models.BooleanField()),
('namespace', models.CharField(max_length=255)),
('frame_name', models.CharField(max_length=255)),
('instance', models.CharField(max_length=255)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Building',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='FileMeasure',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
('brand', models.CharField(max_length=255)),
('model', models.CharField(max_length=255)),
('write_time', models.DateTimeField()),
('lines', models.IntegerField()),
('duplicates', models.IntegerField()),
],
),
migrations.CreateModel(
name='Floor',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=255)),
('elevation', models.IntegerField()),
('building', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Building')),
],
),
migrations.CreateModel(
name='Landmark',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('active_flag', models.BooleanField()),
('pos', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('alt', models.IntegerField()),
('tag', models.CharField(max_length=255)),
('filelink', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.FileMeasure')),
('floor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Floor')),
],
),
migrations.CreateModel(
name='WifiEmitter',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('ssid', models.CharField(max_length=255)),
('mac_adress', models.CharField(max_length=17)),
('active_flag', models.BooleanField()),
('high_freq', models.BooleanField()),
('building', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Building')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='WifiMeasure',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('moment', models.DateTimeField()),
('mac_adress', models.CharField(max_length=255)),
('level', models.IntegerField()),
('count', models.IntegerField()),
('frequency', models.IntegerField()),
('capabilities', models.CharField(max_length=255)),
('ssid', models.CharField(max_length=255)),
('filelink', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.FileMeasure')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='WifiFingerprint',
fields=[
('hits', models.IntegerField()),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('min_val', models.FloatField()),
('max_val', models.FloatField()),
('average', models.FloatField()),
('deviation', models.FloatField()),
('emitter', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.WifiEmitter')),
('landmark', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Landmark')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='filemeasure',
name='floor',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Floor'),
),
migrations.CreateModel(
name='BtMeasure',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('moment', models.DateTimeField()),
('mac_adress', models.CharField(max_length=255)),
('level', models.IntegerField()),
('count', models.IntegerField()),
('frame_content', models.CharField(max_length=1024)),
('name', models.CharField(max_length=255)),
('namespace', models.CharField(max_length=255)),
('instance', models.CharField(max_length=255)),
('filelink', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.FileMeasure')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='BtFingerprint',
fields=[
('hits', models.IntegerField()),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('min_val', models.FloatField()),
('max_val', models.FloatField()),
('average', models.FloatField()),
('deviation', models.FloatField()),
('emitter', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.BtEmitter')),
('landmark', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Landmark')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='btemitter',
name='building',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='indoor.Building'),
),
]
# Generated by Django 2.2.1 on 2019-08-21 21:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('indoor', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='btfingerprint',
name='landmark',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='indoor.Landmark'),
),
migrations.AlterField(
model_name='wififingerprint',
name='landmark',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='indoor.Landmark'),
),
]
......@@ -81,9 +81,11 @@ class Landmark(models.Model):
ret = ""
fingerprints = self.wififingerprint_set.all()
for fp in fingerprints:
ret += "Emetteur:{}</br>".format(fp.emitter.ssid)
ret += "min: {} max: {}</br>".format(fp.min_val,fp.max_val)
ret += "mean: {} ,std: {} </br>".format(fp.average,fp.deviation)
ret += "<b>ssid:{} bssid: {}</b></br>".format(fp.emitter.ssid,fp.emitter.mac_adress)
ret += "min: {} max: {}mean: {} ,std: {} </br>".format(fp.min_val,
fp.max_val,
fp.average,
fp.deviation)
return ret
......
......@@ -104,8 +104,8 @@
alert("les niveaux sont en rouge, les boutiques en bleu")
for(var floor in floors){
overlaysObj[floor] = L.layerGroup(floors[floor]);
map.addLayer(overlaysObj[floor]);
}
map.addLayer(overlaysObj[2]);
L.control.layers({},overlaysObj).addTo(map);
map.fitBounds(shops.getBounds());
}
......
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