This commit is contained in:
Mohamed Nouffer
2022-05-16 18:36:38 +05:30
parent c230cf4781
commit 033ffba5a6
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,6 @@
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 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
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
@ -21,6 +21,7 @@ urlpatterns = router.urls
urlpatterns += [ urlpatterns += [
path('inperf/', LocationsInPerf, name="location_perf"), path('inperf/', LocationsInPerf, name="location_perf"),
path('insubperf', LocationsInSubPerf, name='location_subperf'), path('insubperf', LocationsInSubPerf, name='location_subperf'),
path('inbound', LocationInBound, name='location_bound'),
path('subperfinmain/', SubPerfInMainPerf, name="sub_perf"), path('subperfinmain/', SubPerfInMainPerf, name="sub_perf"),
path('perfext/', ExtentForSubPerf, name="sub_perf_ext"), path('perfext/', ExtentForSubPerf, name="sub_perf_ext"),
path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"), path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"),

View File

@ -15,6 +15,7 @@ from .serializers import TestSerialiser
from .models import TestModel from .models import TestModel
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.db.models import F from django.db.models import F
from django.contrib.gis import geos
@ -69,6 +70,22 @@ def LocationsInSubPerf(request):
serializer = LocationSerializer(locs, many=True) serializer = LocationSerializer(locs, many=True)
return JsonResponse(serializer.data, safe=False) return JsonResponse(serializer.data, safe=False)
def LocationInBound(request):
lat1 = float(request.GET.get('la1'))
lon1 = float(request.GET.get('ln1'))
lat2 = float(request.GET.get('la2'))
lon2 = float(request.GET.get('ln2'))
lat3 = float(request.GET.get('la3'))
lon3 = float(request.GET.get('ln3'))
pl = geos.Polygon(((lon1, lat1), (lon2, lat2), (lon3, lat3), (lon1, lat1)), srid=4326)
res = Location.objects.filter(geom__within=pl)
serializer = LocationSerializer(res, many=True)
return JsonResponse(serializer.data, safe=False)
def SubInPerf(request): def SubInPerf(request):
prefecture = request.GET.get('perf') prefecture = request.GET.get('perf')