摘要問題:如何將一個LineString geom轉儲到Django中的Point geom?或者是原始SQL唯一的方法?將一個LineString geom轉儲到Django中的一個Point geom(與ST_DumpPoints())相似
想要了解更多詳細信息...這裏亞去:
說我有以下的車型,確切的格式並不重要。
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)
在人口視圖(填充DATABSE)的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)