Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting extra properties assignment #1007

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

praveen-k-g
Copy link

No description provided.

@pgiraud
Copy link
Collaborator

pgiraud commented Jun 27, 2018

This obviously breaks the tests because it was not meant to be handled that way. extra_properties was designed to get anything from the JSON properties key.

@praveen-k-g
Copy link
Author

What I understand by looking at the code is that properties contains few fields like x,y,zoom, geometry and extra_properties(which is a map used for 'per task instructions').
If you look at the function def init(self, x, y, zoom, geometry=None, properties=None): in models.py
properties already contains x,y,zoom,geometry. and if you assign properties which is passed as argument to extra_properties( i.e self.extra_properties = unicode(_dumps(properties)) ) then extra_properties not only contains the extra _properties that one provide but also contains x,y,zoom, geometry and other stuff and it breaks when you actually select a task for mapping for the projects where you have provided 'Per Task Instructions’.

For e.g.. lets say If I create a single task with the following properties
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[174.7002,-36.53508],[174.7002,-36.54586],[174.71066,-36.54632],[174.71066,-36.53555],[174.7002,-36.53508]]]]},"properties":{"x":null,"y":null,"zoom":null,"extra_properties":{"p1":"v1"}}}]}

Then if you check extra_properties in pgsql it would be something like {"y": null, "x": null, "zoom": null, "extra_properties": {"p1": "v1”}}
which is wrong

It should be something like {"p1": "v1”}. This you would get if you make the change that I made.

Moreover you can try creating a task with extra_properties, by copying the above geojson and putting the below code snippet in per Task instructions in UI while creating the task.
Code snippet —> value - {p1}
or you can put any random geojson with extra_properties(instructions per task) it will fail, when you will try loading that task for contribution.

Let me know if I have misunderstood anything here.

@pgiraud
Copy link
Collaborator

pgiraud commented Jun 27, 2018

The input JSON is supposed to be formatted like so:

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [174.7002, -36.53508],
                        [174.7002, -36.54586],
                        [174.71066, -36.54632],
                        [174.71066, -36.53555],
                        [174.7002, -36.53508]
                    ]
                ]
            ]
        },
        "properties": {
            "p1": "v1"
        }
    }]
}

@praveen-k-g
Copy link
Author

Got it. One question here. What's the use of these extra_properties here then?

@pgiraud
Copy link
Collaborator

pgiraud commented Jun 27, 2018

As you mentioned, it's meant to be used for "per task" instructions.
For example you could decide to divide a region into small divisions each of which has it's own unique identifier. Then you could ask the user to download some data for the division by providing a url built with the division id which would point to a document stored somewhere on a server.

The JSON could be:

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "MultiPolygon",
            "coordinates": [
                [
                    [
                        [174.7002, -36.53508],
                        [174.7002, -36.54586],
                        [174.71066, -36.54632],
                        [174.71066, -36.53555],
                        [174.7002, -36.53508]
                    ]
                ]
            ]
        },
        "properties": {
            "name": "San_Francisco"
        }
    }]
}

And per task instructions:

Please download extra information about this location at [wikipedia](https://en.wikipedia.org/wiki/{name})

It has been used in the past for Africa with links to data to import into OSM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants