diff --git a/rog/migrations/0007_auto_20220418_1503.py b/rog/migrations/0007_auto_20220418_1503.py new file mode 100644 index 0000000..2a263be --- /dev/null +++ b/rog/migrations/0007_auto_20220418_1503.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2022-04-18 06:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rog', '0006_auto_20220408_1654'), + ] + + operations = [ + migrations.AddField( + model_name='location', + name='latitude', + field=models.FloatField(blank=True, null=True, verbose_name='Latitude'), + ), + migrations.AddField( + model_name='location', + name='longitude', + field=models.FloatField(blank=True, null=True, verbose_name='Latitude'), + ), + ] diff --git a/rog/models.py b/rog/models.py index 802f848..4ea2aaa 100644 --- a/rog/models.py +++ b/rog/models.py @@ -123,6 +123,8 @@ class Location(models.Model): prefecture = models.CharField(_('Prefecture'), max_length=255, blank=True, null=True) area= models.CharField(_('Area'), max_length=255, blank=True, null=True) city= models.CharField(_('City'), max_length=255, blank=True, null=True) + latitude = models.FloatField('Latitude', blank=True, null=True) + longitude = models.FloatField('Latitude', blank=True, null=True) photos=models.CharField(_('Phptos'), max_length=255, blank=True, null=True) videos=models.CharField(_('Videos'), max_length=255, blank=True, null=True) webcontents=models.CharField(_('Web Content'), max_length=255, blank=True, null=True) @@ -442,19 +444,21 @@ def updateLocation(mdl, fields): prefecture = fields[5] if len(fields) > 1 else '', area = fields[6] if len(fields) > 1 else '', city = fields[7] if len(fields) > 1 else '', - photos = fields[8] if len(fields) > 1 else '', - videos = fields[9] if len(fields) > 1 else '', - webcontents = fields[10] if len(fields) > 1 else '', - status = fields[11] if len(fields) > 1 else '', - portal = fields[12] if len(fields) > 1 else '', - group = fields[13] if len(fields) > 1 else '', - phone = fields[14] if len(fields) > 1 else '', - fax = fields[15] if len(fields) > 1 else '', - email = fields[16] if len(fields) > 1 else '', - facility = fields[17] if len(fields) > 1 else '', - remark = fields[18] if len(fields) > 1 else '', - parammeters = fields[19] if len(fields) > 1 else '', - tags = fields[20] if len(fields) > 1 else '' + latitude = fields[8] if len(fields) > 1 else '', + longitude = fields[9] if len(fields) > 1 else '', + photos = fields[10] if len(fields) > 1 else '', + videos = fields[11] if len(fields) > 1 else '', + webcontents = fields[12] if len(fields) > 1 else '', + status = fields[13] if len(fields) > 1 else '', + portal = fields[14] if len(fields) > 1 else '', + group = fields[15] if len(fields) > 1 else '', + phone = fields[16] if len(fields) > 1 else '', + fax = fields[17] if len(fields) > 1 else '', + email = fields[18] if len(fields) > 1 else '', + facility = fields[19] if len(fields) > 1 else '', + remark = fields[20] if len(fields) > 1 else '', + parammeters = fields[21] if len(fields) > 1 else '', + tags = fields[22] if len(fields) > 1 else '' ) def updateLineTable(mdl, fields): diff --git a/rog/urls.py b/rog/urls.py index 3263353..6f7322b 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 +from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, Jpn_PerfViewSet, LocationsInPerf, SubInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf from django.urls import path, include @@ -17,6 +17,7 @@ urlpatterns = router.urls urlpatterns += [ path('inperf/', LocationsInPerf, name="location_perf"), + path('insubperf', LocationsInSubPerf, name='location_subperf'), 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 466c8e0..dc9f4ac 100644 --- a/rog/views.py +++ b/rog/views.py @@ -6,7 +6,6 @@ from .serializers import LocationSerializer, Location_lineSerializer, Location_p from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.parsers import JSONParser, MultiPartParser -from .models import Location from .serializers import LocationSerializer from django.http import JsonResponse @@ -45,6 +44,14 @@ def LocationsInPerf(request): serializer = LocationSerializer(locs, many=True) return JsonResponse(serializer.data, safe=False) #return JsonResponse({}) + +def LocationsInSubPerf(request): + subperfecture = request.GET.get('subperf') + perf_geom = JpnSubPerf.objects.get(id=subperfecture) + locs = Location.objects.filter(geom__within=perf_geom.geom) + serializer = LocationSerializer(locs, many=True) + return JsonResponse(serializer.data, safe=False) + def SubInPerf(request): prefecture = request.GET.get('perf')