kopia lustrzana https://github.com/OpenDroneMap/WebODM
Bbox server side filtering
rodzic
1b3be7eee2
commit
424fb7a2cc
|
@ -17,6 +17,7 @@ from django.db import transaction
|
||||||
from django.http import FileResponse
|
from django.http import FileResponse
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.http import StreamingHttpResponse
|
from django.http import StreamingHttpResponse
|
||||||
|
from django.contrib.gis.geos import Polygon
|
||||||
from app.vendor import zipfly
|
from app.vendor import zipfly
|
||||||
from rest_framework import status, serializers, viewsets, filters, exceptions, permissions, parsers
|
from rest_framework import status, serializers, viewsets, filters, exceptions, permissions, parsers
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
|
@ -175,7 +176,15 @@ class TaskViewSet(viewsets.ViewSet):
|
||||||
for a in assets:
|
for a in assets:
|
||||||
query['available_assets__contains'] = "{" + a + "}"
|
query['available_assets__contains'] = "{" + a + "}"
|
||||||
|
|
||||||
# TODO bounding box filtering
|
bbox = request.query_params.get('bbox')
|
||||||
|
if bbox is not None:
|
||||||
|
try:
|
||||||
|
xmin, ymin, xmax, ymax = [float(v) for v in bbox.split(",")]
|
||||||
|
except:
|
||||||
|
raise exceptions.ValidationError("Invalid bbox parameter")
|
||||||
|
|
||||||
|
geom = Polygon.from_bbox((xmin, ymin, xmax, ymax))
|
||||||
|
query['orthophoto_extent__intersects'] = geom
|
||||||
|
|
||||||
tasks = self.queryset.filter(**query)
|
tasks = self.queryset.filter(**query)
|
||||||
tasks = filters.OrderingFilter().filter_queryset(self.request, tasks, self)
|
tasks = filters.OrderingFilter().filter_queryset(self.request, tasks, self)
|
||||||
|
|
|
@ -226,13 +226,13 @@ _('Example:'),
|
||||||
}
|
}
|
||||||
|
|
||||||
computeBbox = exifData => {
|
computeBbox = exifData => {
|
||||||
// minx, maxx, miny, maxy
|
// minx, miny, maxx, maxy
|
||||||
let bbox = [Infinity, -Infinity, Infinity, -Infinity];
|
let bbox = [Infinity, Infinity, -Infinity, -Infinity];
|
||||||
exifData.forEach(ed => {
|
exifData.forEach(ed => {
|
||||||
if (ed.gps){
|
if (ed.gps){
|
||||||
bbox[0] = Math.min(bbox[0], ed.gps.longitude);
|
bbox[0] = Math.min(bbox[0], ed.gps.longitude);
|
||||||
bbox[1] = Math.max(bbox[1], ed.gps.longitude);
|
bbox[1] = Math.min(bbox[1], ed.gps.latitude);
|
||||||
bbox[2] = Math.min(bbox[2], ed.gps.latitude);
|
bbox[2] = Math.max(bbox[2], ed.gps.longitude);
|
||||||
bbox[3] = Math.max(bbox[3], ed.gps.latitude);
|
bbox[3] = Math.max(bbox[3], ed.gps.latitude);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -76,11 +76,10 @@ class NewTaskPanel extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAlignTasks = (bbox) => {
|
loadAlignTasks = (bbox) => {
|
||||||
// TODO: filter by bbox
|
|
||||||
this.setState({alignTasks: [], alignTo: "auto", loadingAlignTasks: true});
|
this.setState({alignTasks: [], alignTo: "auto", loadingAlignTasks: true});
|
||||||
|
|
||||||
this.alignTasksRequest =
|
this.alignTasksRequest =
|
||||||
$.getJSON(`/api/projects/${this.props.projectId}/tasks/?ordering=-created_at&status=${statusCodes.COMPLETED}&available_assets=georeferenced_model.laz`, tasks => {
|
$.getJSON(`/api/projects/${this.props.projectId}/tasks/?ordering=-created_at&status=${statusCodes.COMPLETED}&available_assets=georeferenced_model.laz&bbox=${bbox.join(",")}`, tasks => {
|
||||||
if (Array.isArray(tasks)){
|
if (Array.isArray(tasks)){
|
||||||
this.setState({loadingAlignTasks: false, alignTasks: tasks});
|
this.setState({loadingAlignTasks: false, alignTasks: tasks});
|
||||||
}else{
|
}else{
|
||||||
|
@ -179,7 +178,6 @@ class NewTaskPanel extends React.Component {
|
||||||
|
|
||||||
handleImagesBboxChange = (bbox) => {
|
handleImagesBboxChange = (bbox) => {
|
||||||
if (this.props.showAlign){
|
if (this.props.showAlign){
|
||||||
console.log("TODO! Load alignment tasks that fit within", bbox);
|
|
||||||
this.loadAlignTasks(bbox);
|
this.loadAlignTasks(bbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue