geodjango

Running PostGIS with Django on Heroku

谁都会走 提交于 2020-06-27 15:11:49
问题 Trying to run a GeoDjango app on Heroku and it's being a really piece of work. After struggling through a variety of problems, I've come to one I can't seem to hack my way out of. File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 673, in db_parameters type_string = self.db_type(connection) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 105, in db_type return connection.ops.geo_db_type(self)

Running PostGIS with Django on Heroku

末鹿安然 提交于 2020-06-27 15:11:29
问题 Trying to run a GeoDjango app on Heroku and it's being a really piece of work. After struggling through a variety of problems, I've come to one I can't seem to hack my way out of. File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 673, in db_parameters type_string = self.db_type(connection) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 105, in db_type return connection.ops.geo_db_type(self)

GeoDjango: Can't save a model with PointField(), Error: SpatialProxy (POINT) with value of type: <class 'users.models.Point'>

独自空忆成欢 提交于 2020-06-27 04:15:21
问题 The idea is to integrate Google Maps instead of the default map for GeoDjango v1.11.5 PointField() . Currently, in my models.py class Teacher(models.Model): user = models.OneToOneField(User, on_delete=models.PROTECT, related_name='Teacher') placename = models.CharField(blank=True,max_length=255) latitude = models.FloatField(blank=True, null=True, verbose_name='Latitude') longitude = models.FloatField(blank=True, null=True, verbose_name='Longitude') location = models.PointField(blank = True,

Django - GeoDjango read coordinates in the wrong order

[亡魂溺海] 提交于 2020-06-26 12:25:27
问题 first of all thanks for your help. I'm making a form with Django which uses the OSMWidget to save coordinates (Polygons, Lines and Points) to a Geometry field in a PostgreSQL database. It works well, I can save the information in the database without any problem. And when I make a query with PgAdmin I can see the geometric fields data displayed in a Leaflet map correctly. . Here's some of what I have in my forms.py: from django import forms from django_select2 import forms as select2_forms

Django - GeoDjango read coordinates in the wrong order

[亡魂溺海] 提交于 2020-06-26 12:25:13
问题 first of all thanks for your help. I'm making a form with Django which uses the OSMWidget to save coordinates (Polygons, Lines and Points) to a Geometry field in a PostgreSQL database. It works well, I can save the information in the database without any problem. And when I make a query with PgAdmin I can see the geometric fields data displayed in a Leaflet map correctly. . Here's some of what I have in my forms.py: from django import forms from django_select2 import forms as select2_forms

How to get distance field in REST response?

你。 提交于 2020-05-16 13:57:33
问题 I am using GeoDjango GIS for proximity search result based on latitude and longitude. The model, is quiet simple: class Address(gismodels.Model): # partner = models.ForeignKey(Partner, related_name="partner_addresses", on_delete=models.CASCADE) street = gismodels.CharField(max_length=255) city = gismodels.CharField(max_length=255) postcode = gismodels.CharField(max_length=255, null=True, blank=True, default='0000') country = gismodels.CharField(max_length=255) businesses = gismodels

django geo admin

╄→尐↘猪︶ㄣ 提交于 2020-04-20 19:08:08
背景 景区业务需要使用geodjango geodjango admin 4326-3578 拾取坐标 坐标系概念 geodjango 参考文档 geodjango settings.py # install apps 'django.contrib.gis', # DATABASES 'django.contrib.gis.db.backends.postgis' srid 默认是84坐标系 admin.py #!/usr/bin/env python from django.contrib.gis.admin import OSMGeoAdmin class MyOSMGeoAdmin(OSMGeoAdmin): """ 3. 对于 Web Map 开发人员的意义 对于 Web Map 开发人员来说,最熟悉的应该是 EPSG:4326 (WGS84) and EPSG:3857(Pseudo-Mercator) 3.1 EPSG:4326 (WGS84) 前面说了WGS84是目前最流行的地理坐标系统。 在国际上,每个坐标系统都会被分配一个 EPSG 代码,EPSG:4326就是WGS84 的代码。 GPS是基于WGS84的,所以通常我们得到的坐标数据都是WGS84的. 一般我们在存储数据时,仍然按WGS84存储。 3.2 EPSG:3857 (Pseudo-Mercator

Django sort by distance

独自空忆成欢 提交于 2020-03-07 08:50:52
问题 I have the following model: class Vacancy(models.Model): lat = models.FloatField('Latitude', blank=True) lng = models.FloatField('Longitude', blank=True) How should I make a query to sort by distance (distance is infinity)? Working on PosgreSQL, GeoDjango if it is required. 回答1: First of all, it is better to make a point field instead of making lat and lnt separated: from django.contrib.gis.db import models location = models.PointField(null=False, blank=False, srid=4326, verbose_name=

Django sort by distance

倖福魔咒の 提交于 2020-03-07 08:50:30
问题 I have the following model: class Vacancy(models.Model): lat = models.FloatField('Latitude', blank=True) lng = models.FloatField('Longitude', blank=True) How should I make a query to sort by distance (distance is infinity)? Working on PosgreSQL, GeoDjango if it is required. 回答1: First of all, it is better to make a point field instead of making lat and lnt separated: from django.contrib.gis.db import models location = models.PointField(null=False, blank=False, srid=4326, verbose_name=

Distance between two 3D point in geodjango (postgis)

北战南征 提交于 2020-02-25 07:25:07
问题 I have the following problem: I created two points, for example: SRID=3857;POINT Z (62780.8532226825 5415035.177460473 100) SRID=3857;POINT Z (62785.8532226825 5415035.177460473 70) As you can see, there is 5m difference in X coordinates, and 30m in Z coordinates. When I run a.distance(b) in django shell, it returns 5 , which is wrong. However, whenIi run in a psql shell: SELECT ST_3DDistance(a.coordinates, b.coordinates) FROM restapi_entityxyz a, restapi_entityxyz b WHERE a.external_id=