#!/usr/bin/env python

import sys
import yaml

with open(sys.argv[1],'r') as infile:
    locations = yaml.load(infile)

xdiff = int(sys.argv[2])
ydiff = int(sys.argv[3])

for polygon in locations['polygons']:
    num_vertices = len(polygon)/2 
    counter = 0
    for vertex in range(num_vertices): 
        polygon[counter] += xdiff
        counter += 1
        polygon[counter] += ydiff
        counter += 1

with open('out.yaml','w') as outfile:
    outfile.write(yaml.dump(locations))

print "File with translated entities written out as out.yaml"
