本文整理汇总了Python中models.Activity.setGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.setGeometry方法的具体用法?Python Activity.setGeometry怎么用?Python Activity.setGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.setGeometry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _parse_activities_response
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import setGeometry [as 别名]
def _parse_activities_response(self, jsonBody):
"""
"""
activities = []
data = json.loads(str(jsonBody))
for activity in data['data']:
# Create a new activity
a = Activity(id=activity['id'], version=activity['version'])
# Get the coords and set the geometry
# Check first the geometry type
# Handle MultiPoint geometries
if activity['geometry']['type'].lower() == "multipoint":
points = []
for coords in activity['geometry']['coordinates']:
points.append(QgsPoint(coords[0], coords[1]))
a.setGeometry(QgsGeometry.fromMultiPoint(points))
# Handle Point geometries
if activity['geometry']['type'].lower() == "point":
coords = activity['geometry']['coordinates']
a.setGeometry(QgsGeometry.fromPoint(QgsPoint(coords[0], coords[1])))
# Append it to the list
activities.append(a)
return activities
示例2: _createNewActivity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import setGeometry [as 别名]
def _createNewActivity(id=None, otherActivity=None):
# Connect to the protocol signal
self.connect(self.activityProtocol, SIGNAL("created( bool, int, QString )"), _createNewActivityFinished)
# Create a new Uuid
if id is not None:
uid = QPlainUuid(id)
else:
uid = QPlainUuid(QUuid.createUuid())
tagGroups = list(TagGroup() for i in range(len(groups)))
# attrs is a dictionary: key = field index, value = QgsFeatureAttribute
# show all attributes and their values
self.log("Attribute list:")
for (k, attr) in attrs.iteritems():
if k is not identifierColumnIndex:
self.log("%s: %s" % (fieldIndexMap[k], attr.toString()))
# First search the correct taggroup to append
attributeName = provider.fields()[k].name()
currentTagGroup = 0
for g in groups:
if attributeName in g:
break
else:
currentTagGroup += 1
if attr is not None and attr.toString() != '':
tag = Tag(key=fieldIndexMap[k], value=attr.toString())
tagGroups[currentTagGroup].addTag(tag)
if tagGroups[currentTagGroup].mainTag() is None:
tagGroups[currentTagGroup].setMainTag(tag)
a = Activity(id=uid)
a.setGeometry(feature.geometry())
for tg in tagGroups:
if len(tg.tags) > 0:
a.addTagGroup(tg)
wrapperObj = {}
wrapperObj['activities'] = [a.createDiff(otherActivity)]
self.activityProtocol.add(json.dumps(wrapperObj, sort_keys=True, indent=4 * ' '))
示例3: _parse_activities_response
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import setGeometry [as 别名]
def _parse_activities_response(self, jsonBody):
"""
"""
activities = []
data = json.loads(str(jsonBody))
for activity in data["data"]:
# Create a new activity
a = Activity(id=activity["id"], version=activity["version"])
# Get the point coords and set the geometry
coords = activity["geometry"]["coordinates"]
a.setGeometry(QgsGeometry.fromPoint(QgsPoint(coords[0], coords[1])))
# Append it to the list
activities.append(a)
return activities