Skip to content
Snippets Groups Projects
Commit e07542ab authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

First version of observation masking

parent 044b574f
No related branches found
No related tags found
1 merge request!5Observation masking
...@@ -83,6 +83,7 @@ def maintenance(request): ...@@ -83,6 +83,7 @@ def maintenance(request):
@cache_page(60 * 10) @cache_page(60 * 10)
@gzip_page @gzip_page
def vipslogicproxy(request, path): def vipslogicproxy(request, path):
""" """
Proxy to use cross domain Ajax GET and POST requests Proxy to use cross domain Ajax GET and POST requests
request: Django request object request: Django request object
...@@ -96,6 +97,8 @@ def vipslogicproxy(request, path): ...@@ -96,6 +97,8 @@ def vipslogicproxy(request, path):
else: else:
return HttpResponseNotAllowed("Permitted methods are POST and GET") return HttpResponseNotAllowed("Permitted methods are POST and GET")
params = request.urlencode() params = request.urlencode()
#print "Params:" + params #print "Params:" + params
try: try:
url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path) url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path)
......
...@@ -134,6 +134,10 @@ var initMap = function( ...@@ -134,6 +134,10 @@ var initMap = function(
{ {
params.push("cropCategoryId=" + cropCategoryId); params.push("cropCategoryId=" + cropCategoryId);
} }
if(settings.userUuid != null)
{
params.push("userUUID=" + settings.userUuid);
}
// Get observations from backend // Get observations from backend
$.getJSON( "/vipslogicproxy/rest/observation/list/filter/" + organizationId + (params.length > 0 ? "?" + params.join("&") : ""), function( data ) { $.getJSON( "/vipslogicproxy/rest/observation/list/filter/" + organizationId + (params.length > 0 ? "?" + params.join("&") : ""), function( data ) {
...@@ -211,24 +215,40 @@ var displayFeatureDetails = function(pixel, coordinate) { ...@@ -211,24 +215,40 @@ var displayFeatureDetails = function(pixel, coordinate) {
var renderObservationFeatures = function() var renderObservationFeatures = function()
{ {
var geoJSON = {"type":"FeatureCollection","features":[]}; var geoJSON = {"type":"FeatureCollection","features":[]};
for(var i=0;i<allObservations.length;i++) for(var i=0;i<allObservations.length;i++)
{ {
var observation = allObservations[i]; var observation = allObservations[i];
var obsFeatures = null; var obsFeatures = null;
// Showing only publicly shared observations with geolocation information // Showing only publicly shared observations with geolocation information
if(!observation.locationIsPrivate && observation.geoInfo !== null && observation.geoInfo.trim() !== "") if(observation.locationIsPrivate)
{
obsFeatures = JSON.parse(observation.geoInfo).features;
}
else
{ {
continue; continue;
} }
for(var j=0; j<obsFeatures.length; j++) // Have we got geoInfo to show?
if(observation.geoInfo !== null && observation.geoInfo.trim() !== "")
{ {
geoJSON.features.push(obsFeatures[j]); obsFeatures = JSON.parse(observation.geoInfo).features;
if(obsFeatures !== null)
{
// We have parsed geoinfo successfully.
// If the observation has registered a polygonService,
// that means that the location should be masked by this
// service (for privacy reasons). Otherwise: Add as-is
//if(observation.polygonService !== undefined && observation.polygonService !== null)
//{
// maskedFeatures.push(obsFeatures[0]); // Using only first feature for simplicity
//}
//else
//{
for(var j=0; j<obsFeatures.length; j++)
{
geoJSON.features.push(obsFeatures[j]);
}
//}
}
} }
} }
...@@ -239,6 +259,7 @@ var renderObservationFeatures = function() ...@@ -239,6 +259,7 @@ var renderObservationFeatures = function()
}); });
observationLayer.getSource().clear(); observationLayer.getSource().clear();
observationLayer.getSource().addFeatures(drawnfeatures); observationLayer.getSource().addFeatures(drawnfeatures);
//console.info(maskedFeatures);
} }
/** /**
......
...@@ -60,7 +60,8 @@ ...@@ -60,7 +60,8 @@
<script type="text/javascript" src="{% static "observations/js/observationViewMap.js" %}"></script> <script type="text/javascript" src="{% static "observations/js/observationViewMap.js" %}"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$.getJSON( "/vipslogicproxy/rest/observation/{{observation_id}}/" , function( observation ) { var uuidParam = settings.userUuid != null ? "?userUUID=" + settings.userUuid : "";
$.getJSON( "/vipslogicproxy/rest/observation/{{observation_id}}/" + uuidParam , function( observation ) {
//console.log(observation); //console.log(observation);
document.getElementById("organismName").innerHTML = getLocalizedOrganismName(observation.organism) + " <i>(" + observation.organism.latinName + ")</i>"; document.getElementById("organismName").innerHTML = getLocalizedOrganismName(observation.organism) + " <i>(" + observation.organism.latinName + ")</i>";
document.getElementById("cropOrganismName").innerHTML = getLocalizedOrganismName(observation.cropOrganism) + " <i>(" + observation.cropOrganism.latinName + ")</i>"; document.getElementById("cropOrganismName").innerHTML = getLocalizedOrganismName(observation.cropOrganism) + " <i>(" + observation.cropOrganism.latinName + ")</i>";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment