本文整理汇总了Python中models.Location.lat方法的典型用法代码示例。如果您正苦于以下问题:Python Location.lat方法的具体用法?Python Location.lat怎么用?Python Location.lat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.lat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addEditObstacle
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import lat [as 别名]
def addEditObstacle(oid):
obstacle = None
form = ObstacleForm()
if oid is not None:
obstacle = Obstacle.query.get(oid) # @UndefinedVariable
if request.method == 'GET':
if obstacle is None:
form.new.data = True
else:
form.new.data = False
form.id.data = obstacle.id
form.location.lat.data = obstacle.location.lat
form.location.lon.data = obstacle.location.lon
if request.method == 'POST' and form.validate(): # @UndefinedVariable
if obstacle is None:
#new obstacle has passed validation, add to db
location = Location(lat=form.location.lat.data, lon=form.location.lon.data)
db.session.add(location) # @UndefinedVariable
obstacle= Obstacle(location=location)
db.session.add(obstacle) # @UndefinedVariable
db.session.commit() # @UndefinedVariable
flash("Obstacle has been created")
else:
#node has been updated. save updates
location = Location.query.get(obstacle.loc_id) # @UndefinedVariable
location.lat = form.location.lat.data
location.lon = form.location.lon.data
db.session.commit() # @UndefinedVariable
flash("Obstacle has been updated")
# after creating the new state, redirect them back to dce config page
return redirect(url_for("obstaclePage"))
return render_template("obstacleForm.html", form=form)
示例2: list_location
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import lat [as 别名]
def list_location():
l = Location()
l.lat = 1.0
l.lng = 1.0
l.put()
vals = ''
q = Location.query()
n = q.count()
for e in q:
vals += str(e) + '<br><br>'
# e.key.delete()
return '<h3>%d</h3><br>%s' % (n, vals)
示例3: addEditNode
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import lat [as 别名]
def addEditNode(node_id):
node = None
# get choices for node leaders
leader_choices = [(0, 'Self')]
for x in Node.query.filter_by(leader_id=0): # @UndefinedVariable
leader_choices.append((x.id,x.name))
form = NodeForm()
form.leader.choices = leader_choices
form.leader.default = 0
if node_id is not None:
node = Node.query.get(node_id) # @UndefinedVariable
if request.method == 'GET':
if node is None:
form.new.data = True
else:
form.new.data = False
form.id.data = node.id
form.name.data = node.name
form.rid.data = node.rid
form.ip.data = node.ip
form.location.lat.data = node.location.lat
form.location.lon.data = node.location.lon
form.leader.data = node.leader_id
jumppoints = []
for jp in node.jumppoints:
form.jumppoints.append_entry({"jp_id": jp.id, "lat": jp.location.lat, "lon":jp.location.lon })
goals = []
for goal in node.goals:
form.goals.append_entry({"goal_id": goal.id, "lat": goal.location.lat, "lon":goal.location.lon })
elif request.method == 'POST' and form.validate(): # @UndefinedVariable
if node is None:
#new node has passed validation, add to db
location = Location(lat=form.location.lat.data, lon=form.location.lon.data)
db.session.add(location) # @UndefinedVariable
node = Node(name=form.name.data, leader_id=form.leader.data, location=location, rid=form.rid.data, ip=form.ip.data)
db.session.add(node) # @UndefinedVariable
db.session.commit() # @UndefinedVariable
for index, point in enumerate(form.jumppoints.data):
jp = JumpPoint()
location = Location(lat=point['lat'], lon=point['lon'])
db.session.add(location) # @UndefinedVariable
jp.location = location
jp.position = int(point['pos']) + 1
db.session.add(jp)
node.jumppoints.append(jp)
for index, point in enumerate(form.goals.data):
goal = Goal()
location = Location(lat=point['lat'], lon=point['lon'])
db.session.add(location) # @UndefinedVariable
goal.location = location
goal.position = int(point['pos']) + 1
db.session.add(goal)
node.goals.append(goal)
db.session.commit() # @UndefinedVariable
flash("Node has been created")
else:
#node has been updated. save updates
node.name = form.name.data
node.rid = form.rid.data
node.ip = form.ip.data
location = Location.query.get(node.loc_id) # @UndefinedVariable
location.lat = form.location.lat.data
location.lon = form.location.lon.data
node.location = location
node.leader_id = form.leader.data
# create a list of all points already included on this path. will be used to determine if
# any points were deleted from the list.
deleteList = []
for jp in node.jumppoints:
deleteList.append(jp.id)
for index, jp in enumerate(form.jumppoints.data):
if int(jp['jp_id']) == 0:
newjp = JumpPoint()
location = Location(lat=jp['lat'], lon=jp['lon'])
db.session.add(location) # @UndefinedVariable
newjp.location = location
newjp.position = int(jp['pos']) + 1
db.session.add(newjp)
node.jumppoints.append(newjp)
else:
# found existing point. update and remove from delete list
savedjp = JumpPoint.query.get(jp['jp_id']) # @UndefinedVariable
savedjp.position = int(jp['pos']) + 1
savedLoc = Location.query.get(savedjp.loc_id) # @UndefinedVariable
savedLoc.lat = jp['lat']
#.........这里部分代码省略.........