本文整理汇总了Python中models.City.world_city方法的典型用法代码示例。如果您正苦于以下问题:Python City.world_city方法的具体用法?Python City.world_city怎么用?Python City.world_city使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.City
的用法示例。
在下文中一共展示了City.world_city方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_city
# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import world_city [as 别名]
def run_city(verbose=True, step=10, begin=0, end=0):
import csv
filename = os.path.join(settings.BASE_PATH, 'apps', 'world', 'data', 'cities.csv')
reader = csv.reader(open(filename, 'rb'), delimiter=',', quotechar="'")
for row in reader:
c = City()
c.name = row[4]
c.capital = bool(int(row[9]))
c.world_city = bool(int(row[12]))
c.mega_city = bool(int(row[13]))
c.point = Point(float(row[22]), float(row[21]))
#don't save the city if a country can't be found for it
try:
c.country = CountryBorder.objects.get(iso3=row[17])
except :
continue
try:
c.state = StateBorder.objects.get(name=row[18])
except :
try:
c.state = StateBorder.objects.get(mpoly__contains=c.point)
except :
pass
c.sqkm = int(row[40])
topleft = Point(float(row[48]), float(row[55]))
topright = Point(float(row[51]), float(row[55]))
bottomleft = Point(float(row[48]), float(row[52]))
bottomright = Point(float(row[51]), float(row[52]))
c.mpoly = MultiPolygon(Polygon(LinearRing(topleft, topright, bottomright, bottomleft, topleft)))
c.save()
print c.name