1
주어진 위도/경도에서 반경 4km 이내 인근 부엌을 가져 오려고합니다. 다음 srid 4326이있는 GeoDjango 거리 쿼리는 'SpatiaLite가 측지 좌표계가있는 기하학 필드의 거리 쿼리를 지원하지 않습니다.'를 반환합니다.
INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', 'rest_framework', 'oauth2_provider', 'kitchen', ) DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.spatialite', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }내 모델입니다, 내 공간 백엔드 spatialite과 설정은
from django.contrib.gis.db import models from django.contrib.gis.geos import Point class Kitchen(models.Model): id = models.CharField(max_length=100,primary_key=True) #id = models.AutoField(primary_key=True) name = models.CharField(max_length=100,blank=False) address = models.CharField(max_length=1000, blank=True, default='') contact_no = models.CharField(max_length=100,blank=True, default='') location = models.PointField(srid=4326, geography=True, blank=True, null=True) objects = models.GeoManager()장고 쉘에서 내 쿼리가
, 아래 값 오류를 반환
from kitchen.models import Kitchen from django.contrib.gis import measure from django.contrib.gis import geos current_point = geos.fromstr('POINT(%s %s)' % (76.7698996, 17.338993), srid=4326) Kitchen.objects.filter(location__distanc e_lte=(current_point, measure.D(km=4))),
SpatiaLite does not support distance queries on geometry fields with a geodetic coordinate system. Distance objects; use a numeric value of your distance in degrees instead.
모델에서 다른 투영 srid 설정 (예 : 3857, 24381 등) 잘못된 결과를 반환합니다. 여기에 큰 도움을 주실 수 있습니다.
'srid = 3857, geography = False'를 사용하면 잘못된 결과 (모든 부엌)가 반환됩니다. – Dev