摘要问题:如何将 LineString geom 转储到 Django 中的 Point geom?还是原始 SQL 是唯一的方法?
想要更多详细信息……给你:
假设我有以下模型,确切的格式并不重要。
line_paths: 1 row = 1 linestring
point_paths: 1 row = 1 point from 1 linestring in line_paths
##################################################
# LINE_PATHS TABLE
##################################################
class line_paths(models.Model):
line_path_id = models.AutoField(primary_key=True)
yyyymmdd = models.CharField(max_length=8)
season = models.ForeignKey('seasons')
line_path = models.LineStringField(dim=3)
objects = models.GeoManager()
location = models.CharField(choices=LOCATION,max_length=20)
def __unicode__(self):
return "%s-%d"%(self.location, self.line_path_id)
##################################################
# POINT_PATHS TABLE
##################################################
class point_paths(models.Model):
point_path_id = models.AutoField(primary_key=True)
season = models.ForeignKey('seasons')
line_path = models.ForeignKey('line_paths')
gps_time = models.FloatField()
roll = models.FloatField()
pitch = models.FloatField()
heading = models.FloatField()
point = models.PointField(dim=3)
objects = models.GeoManager()
location = models.CharField(choices=LOCATION,max_length=20)
def __unicode__(self):
return "%s-%d"%(self.location, self.point_path_id)
在人口视图(填充数据库)中,line_path 被插入到 line_paths 表中,最终看起来像这样(给定以下查询)
SELECT line_path_id,season_id,ST_AsText(line_path) FROM rds_line_paths;
现在我想从这个表 (line_paths) 中获取 LineString GEOM 并将这些点转储到一个新表 (point_paths) 中。在原始 SQL 中,我做了这样的事情:
SELECT ST_AsText(geom) AS points FROM ST_DumpPoints((SELECT fl_line FROM greenland.line_paths WHERE ...));
然后我可以将这些点插入到新表中。在 Django 框架中是否有这样做的方法?(不回退到原始 SQL)