diff --git a/rog/urls.py b/rog/urls.py index b04f129..a7b4e31 100644 --- a/rog/urls.py +++ b/rog/urls.py @@ -1,6 +1,6 @@ from rest_framework import urlpatterns 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 knox import views as knox_views @@ -21,6 +21,7 @@ urlpatterns = router.urls urlpatterns += [ path('inperf/', LocationsInPerf, name="location_perf"), path('insubperf', LocationsInSubPerf, name='location_subperf'), + path('inbound', LocationInBound, name='location_bound'), path('subperfinmain/', SubPerfInMainPerf, name="sub_perf"), path('perfext/', ExtentForSubPerf, name="sub_perf_ext"), path('mainperfext/', ExtentForMainPerf, name="main_perf_ext"), diff --git a/rog/views.py b/rog/views.py index f167ae2..bef02ec 100644 --- a/rog/views.py +++ b/rog/views.py @@ -15,6 +15,7 @@ from .serializers import TestSerialiser from .models import TestModel from django.shortcuts import get_object_or_404 from django.db.models import F +from django.contrib.gis import geos @@ -69,6 +70,22 @@ def LocationsInSubPerf(request): serializer = LocationSerializer(locs, many=True) 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): prefecture = request.GET.get('perf')