Skip to content

Commit

Permalink
Merge pull request #559 from mapswipe/adjust-python-script
Browse files Browse the repository at this point in the history
add google y tiles as an attribute to the output tasks geojson
  • Loading branch information
Hagellach37 committed Aug 25, 2022
2 parents 1a73296 + 19ca8e8 commit e97c059
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mapswipe_workers/python_scripts/tasks_to_geojson.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import os
import sys

Expand Down Expand Up @@ -76,6 +77,7 @@ def tasks_to_geojson(project_extent_file, zoomlevel, outfile):
outLayer.CreateField(ogr.FieldDefn("taskId", ogr.OFTString))
outLayer.CreateField(ogr.FieldDefn("tile_x", ogr.OFTInteger))
outLayer.CreateField(ogr.FieldDefn("tile_y", ogr.OFTInteger))
outLayer.CreateField(ogr.FieldDefn("tile_y_google", ogr.OFTInteger))
outLayer.CreateField(ogr.FieldDefn("tile_z", ogr.OFTInteger))

for task in tasks:
Expand All @@ -85,13 +87,16 @@ def tasks_to_geojson(project_extent_file, zoomlevel, outfile):
tile_z, tile_x, tile_y = task["taskId"].split("-")
geom = ogr.CreateGeometryFromWkt(geometry)

tile_y_google = int(math.pow(2, int(tile_z)) - int(tile_y)) - 1

featureDefn = outLayer.GetLayerDefn()
outFeature = ogr.Feature(featureDefn)
outFeature.SetGeometry(geom)
outFeature.SetField("groupId", group_id)
outFeature.SetField("taskId", task_id)
outFeature.SetField("tile_x", int(tile_x))
outFeature.SetField("tile_y", (tile_y))
outFeature.SetField("tile_y_google", (tile_y_google))
outFeature.SetField("tile_z", (tile_z))
outLayer.CreateFeature(outFeature)
outFeature = None
Expand Down

0 comments on commit e97c059

Please sign in to comment.