私は、指定された緯度/経度から半径4km以内の近くのキッチンを取得しようとしています。 私の空間的なバックエンドはここで、GeoDjango距離クエリでsrid 4326が返されます。 '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と設定されている私のモデルでは、Djangoのシェルから私のクエリは、以下の値エラーを返す
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)))
ある
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()
ある 、
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