Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pierre-antoine Comby
winaps-server
Commits
0a636999
Commit
0a636999
authored
May 24, 2019
by
grisel-davy
Browse files
Commit finale foure tout
parent
6a23b57d
Changes
5
Hide whitespace changes
Inline
Side-by-side
maps/models.py
View file @
0a636999
...
...
@@ -15,4 +15,8 @@ class Mesure(models.Model):
class
Meta
:
unique_together
=
(
'time'
,
'point'
,
'bssid'
)
def
__str__
(
self
):
return
'Mesure en {}'
.
format
(
self
.
point
.
coords
)
return
'Mesure du {}'
.
format
(
self
.
time
)
@
property
def
popupContent
(
self
):
return
"<p>{}</p><p>{}</p>"
.
format
(
self
.
ssid
,
self
.
puissance
)
maps/templates/maps/heat.html
0 → 100644
View file @
0a636999
<!DOCTYPE html>
<html>
{% load leaflet_tags %}
{% load geojson_tags %}
{% load static %}
<head>
<meta
charset=
"utf-8"
/>
<title>
Puissance des signaux wifi
</title>
{% leaflet_js %}
{% leaflet_css %}
<script
src=
"{% static 'leaflet-heatmap/leaflet-heat.js' %}"
></script>
<style>
body
{
padding
:
0
;
margin
:
0
;
}
html
,
body
,
#map
{
height
:
100%
;
width
:
100%
;
}
</style>
</head>
<body>
<script
type=
"text/javascript"
>
function
geoJson2heat
(
geojson
,
intensity
)
{
return
geojson
.
features
.
map
(
function
(
feature
)
{
return
[
feature
.
geometry
.
coordinates
[
1
],
feature
.
geometry
.
coordinates
[
0
],
100
+
feature
.
properties
[
intensity
],
];
});
}
function
map_init
(
map
,
options
){
var
collection
=
{{
queryset
|
geojsonfeature
:
"
puissance:point
"
|
safe
}};
var
geoData
=
geoJson2heat
(
collection
,
"
puissance
"
);
L
.
heatLayer
(
geoData
,{
radius
:
50
,
max
:
30
}).
addTo
(
map
)
}
</script>
{% leaflet_map "map" callback="map_init" %}
</body>
</html>
maps/templates/maps/index.html
View file @
0a636999
...
...
@@ -2,6 +2,7 @@
<html>
{% load leaflet_tags %}
{% load geojson_tags %}
{% load static %}
<head>
<meta
charset=
"utf-8"
/>
...
...
@@ -27,26 +28,21 @@
</head>
<body>
{% leaflet_map "map" callback="main_map_init" %}
<script
type=
"text/javascript"
>
function
main_map_init
(
map
,
options
)
{
var
dataurl
=
"
{% url 'maps:data' %}
"
;
var
request
=
new
XMLHttpRequest
();
request
.
open
(
'
GET
'
,
dataurl
,
true
);
request
.
onload
=
function
()
{
if
(
request
.
status
>=
200
&&
request
.
status
<
400
)
{
// Success!
var
data
=
JSON
.
parse
(
request
.
responseText
);
var
markers
=
L
.
markerClusterGroup
();
L
.
geoJson
(
data
).
addTo
(
markers
);
map
.
addLayer
(
markers
);
};
};
request
.
onerror
=
function
()
{
// There was a connection error of some sort
};
request
.
send
();
};
function
onEachFeature
(
feature
,
layer
){
if
(
feature
.
properties
&&
feature
.
properties
.
popupContent
)
{
layer
.
bindPopup
(
feature
.
properties
.
popupContent
);
}
}
var
collection
=
{{
queryset
|
geojsonfeature
:
"
popupContent:point
"
|
safe
}};
function
map_init
(
map
,
options
){
var
markers
=
L
.
markerClusterGroup
();
L
.
geoJson
(
collection
,
{
onEachFeature
:
onEachFeature
}).
addTo
(
markers
);
map
.
addLayer
(
markers
);
}
</script>
{% leaflet_map "map" callback="map_init" %}
</body>
</html>
maps/urls.py
View file @
0a636999
...
...
@@ -23,10 +23,8 @@ from . import models
app_name
=
'maps'
urlpatterns
=
[
path
(
'data'
,
GeoJSONLayerView
.
as_view
(
model
=
models
.
Mesure
,
geometry_field
=
'point'
,
fields
=
(
"puissance"
,
"ssid"
)),
name
=
'data'
),
path
(
''
,
views
.
IndexView
.
as_view
(),
name
=
'index'
),
path
(
'heat/<ssid>'
,
views
.
HeatMapView
.
as_view
(),
name
=
"heatmap"
),
path
(
'all'
,
views
.
NetworkView
.
as_view
()),
path
(
'ssid/<ssid>'
,
views
.
NetworkView
.
as_view
(),
name
=
'map'
),
path
(
'send/'
,
views
.
receive
,
name
=
'POST request'
),
]
maps/views.py
View file @
0a636999
from
django.shortcuts
import
render
,
HttpResponse
# Create your views here.
#
from
django.views.generic.base
import
View
,
TemplateView
from
django.http.response
import
HttpResponse
from
.parser
import
request_parser
from
.models
import
Mesure
class
Index
View
(
TemplateView
):
class
Network
View
(
TemplateView
):
template_name
=
'maps/index.html'
def
get_context_data
(
self
,
**
kwargs
):
return
kwargs
ssid
=
self
.
kwargs
.
get
(
"ssid"
)
if
ssid
:
queryset
=
Mesure
.
objects
.
filter
(
ssid
=
ssid
)
else
:
queryset
=
Mesure
.
objects
.
all
()
return
{
"queryset"
:
queryset
}
pass
class
HeatMapView
(
NetworkView
):
template_name
=
'maps/heat.html'
pass
def
receive
(
request
):
"""Reception des request POST ou GET et utilisation des données"""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment