update for location extent

This commit is contained in:
Mohamed Nouffer
2022-12-27 18:01:18 +05:30
parent 393be1bea4
commit 64ed859210
2 changed files with 9 additions and 1 deletions

View File

@ -1,7 +1,7 @@
from sys import prefix from sys import prefix
from rest_framework import urlpatterns from rest_framework import urlpatterns
from rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet, ExtentForLocations
from django.urls import path, include from django.urls import path, include
from knox import views as knox_views from knox import views as knox_views
@ -30,6 +30,7 @@ urlpatterns += [
path('subperfinmain/', SubPerfInMainPerf, name="sub_perf"), path('subperfinmain/', SubPerfInMainPerf, name="sub_perf"),
path('allgifuareas/', GetAllGifuAreas, name="gifu_area"), path('allgifuareas/', GetAllGifuAreas, name="gifu_area"),
path('perfext/', ExtentForSubPerf, name="sub_perf_ext"), path('perfext/', ExtentForSubPerf, name="sub_perf_ext"),
path('locsext/', ExtentForLocations, name="locs_ext"),
path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"), path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"),
path('cats/', CatView, name='cats'), path('cats/', CatView, name='cats'),
path('catbycity/', CatByCity, name='cat_by_city'), path('catbycity/', CatByCity, name='cat_by_city'),

View File

@ -12,6 +12,7 @@ from rest_framework.parsers import JSONParser, MultiPartParser
from .serializers import LocationSerializer from .serializers import LocationSerializer
from django.http import JsonResponse from django.http import JsonResponse
from rest_framework.permissions import IsAuthenticated from rest_framework.permissions import IsAuthenticated
from django.contrib.gis.db.models import Extent, Union
from .serializers import TestSerialiser from .serializers import TestSerialiser
from .models import TestModel from .models import TestModel
@ -204,6 +205,12 @@ def ExtentForMainPerf(request):
# iata = serializers.serialize("json",ext) # iata = serializers.serialize("json",ext)
return JsonResponse(ext, safe=False) return JsonResponse(ext, safe=False)
def ExtentForLocations(request):
locs = Location.objects.aggregate(Extent('geom'), Union('geom'))
return JsonResponse(locs['geom__extent'], safe=False)
def ExtentForSubPerf(request): def ExtentForSubPerf(request):
sub_perf_id = request.GET.get('sub_perf') sub_perf_id = request.GET.get('sub_perf')
sub_perf = JpnSubPerf.objects.get(id=sub_perf_id) sub_perf = JpnSubPerf.objects.get(id=sub_perf_id)