|
|
|
@ -117,6 +117,10 @@ def member2feature(member):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def normalize(x, y):
|
|
|
|
|
return x % 180 if x > 0 else x % -180, y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MemberResource(flask_restful.Resource):
|
|
|
|
|
@flask_restful.marshal_with(member_fields)
|
|
|
|
|
def get(self, id):
|
|
|
|
@ -136,8 +140,7 @@ class MemberResource(flask_restful.Resource):
|
|
|
|
|
if not member:
|
|
|
|
|
member = Member(id=id, created_at=now)
|
|
|
|
|
member.nick = args['nick']
|
|
|
|
|
member.x = args['x']
|
|
|
|
|
member.y = args['y']
|
|
|
|
|
member.x, member.y = normalize(args['x'], args['y'])
|
|
|
|
|
member.updated_at = now
|
|
|
|
|
db.session.add(member)
|
|
|
|
|
db.session.commit()
|
|
|
|
@ -196,8 +199,7 @@ class MembersResource(flask_restful.Resource):
|
|
|
|
|
if not member:
|
|
|
|
|
member = Member(created_at=now)
|
|
|
|
|
member.user = args['nick']
|
|
|
|
|
member.x = args['x']
|
|
|
|
|
member.y = args['y']
|
|
|
|
|
member.x, member.y = normalize(args['x'], args['y'])
|
|
|
|
|
member.updated_at = now
|
|
|
|
|
db.session.add(member)
|
|
|
|
|
db.session.commit()
|
|
|
|
@ -238,7 +240,7 @@ class FeaturesResource(flask_restful.Resource):
|
|
|
|
|
if not member:
|
|
|
|
|
member = Member(created_at=now)
|
|
|
|
|
member.nick = properties_args['nick']
|
|
|
|
|
member.x, member.y = geometry_args['coordinates']
|
|
|
|
|
member.x, member.y = normalize(*geometry_args['coordinates'])
|
|
|
|
|
member.updated_at = now
|
|
|
|
|
db.session.add(member)
|
|
|
|
|
db.session.commit()
|
|
|
|
|