Skip to content

Commit 0829b20

Browse files
authored
Merge pull request #75 from osmlab/dev
Merge dev > master
2 parents d29c922 + f097f8d commit 0829b20

25 files changed

Lines changed: 872 additions & 268 deletions

CHANGELOG.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,45 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [v1.5.0](https://github.com/osmlab/maproulette-python-client/compare/v1.4.0...v1.5.0)
8+
9+
> 3 September 2020
10+
11+
- Merge dev > master [`#66`](https://github.com/osmlab/maproulette-python-client/pull/66)
12+
- Fix for challenge model mediumPriorityRule [`#65`](https://github.com/osmlab/maproulette-python-client/pull/65)
13+
- Adding endpoint for challenge keywords/tags [`#64`](https://github.com/osmlab/maproulette-python-client/pull/64)
14+
15+
#### [v1.4.0](https://github.com/osmlab/maproulette-python-client/compare/v1.3.0...v1.4.0)
16+
17+
> 19 August 2020
18+
19+
- Merging dev -> master [`#62`](https://github.com/osmlab/maproulette-python-client/pull/62)
20+
- Adding batch functionality for posting new tasks [`#61`](https://github.com/osmlab/maproulette-python-client/pull/61)
21+
- Improve exceptions and fix JSON decoding bug [`#57`](https://github.com/osmlab/maproulette-python-client/pull/57)
22+
23+
#### [v1.3.0](https://github.com/osmlab/maproulette-python-client/compare/v1.2.1...v1.3.0)
24+
25+
> 15 July 2020
26+
27+
- Dev -> master version fix [`#60`](https://github.com/osmlab/maproulette-python-client/pull/60)
28+
- Merging dev -> master [`#59`](https://github.com/osmlab/maproulette-python-client/pull/59)
29+
- Added keywords property to challenge model [`#53`](https://github.com/osmlab/maproulette-python-client/pull/53)
30+
- Fix challenge model and api bugs [`#51`](https://github.com/osmlab/maproulette-python-client/pull/51)
31+
732
#### [v1.2.1](https://github.com/osmlab/maproulette-python-client/compare/v1.2.0...v1.2.1)
833

934
> 24 June 2020
1035
1136
- Merging dev > master [`#49`](https://github.com/osmlab/maproulette-python-client/pull/49)
1237
- Add changelog [`#47`](https://github.com/osmlab/maproulette-python-client/pull/47)
1338
- Fixed challenge model issue [`#48`](https://github.com/osmlab/maproulette-python-client/pull/48)
14-
- add changelog [`a735e45`](https://github.com/osmlab/maproulette-python-client/commit/a735e45693dad6ea501ccfefbaced77d3fd3ab63)
15-
- Update __init__.py [`dbdf591`](https://github.com/osmlab/maproulette-python-client/commit/dbdf5911762f7de01dfe1c4bf350a835794e43bb)
1639

1740
#### [v1.2.0](https://github.com/osmlab/maproulette-python-client/compare/v1.1.0...v1.2.0)
1841

1942
> 24 June 2020
2043
2144
- dev > master [`#46`](https://github.com/osmlab/maproulette-python-client/pull/46)
2245
- Add task and challenge endpoints [`#45`](https://github.com/osmlab/maproulette-python-client/pull/45)
23-
- Added new task and challenge methods [`1df0c9b`](https://github.com/osmlab/maproulette-python-client/commit/1df0c9bbcba4a801494938d9936f3bbb74fb675c)
24-
- Started adding task endpoints [`c3083a2`](https://github.com/osmlab/maproulette-python-client/commit/c3083a2adf766e5ef669fa8ec05e16a1598c603f)
25-
- Fixing formatting [`731e19c`](https://github.com/osmlab/maproulette-python-client/commit/731e19c2ff01acfc8379c01711cde36e5c31a8e5)
2646

2747
#### [v1.1.0](https://github.com/osmlab/maproulette-python-client/compare/v1.0.0...v1.1.0)
2848

@@ -33,9 +53,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
3353
- Add travis & pypi badges [`#42`](https://github.com/osmlab/maproulette-python-client/pull/42)
3454
- Add new properties [`#38`](https://github.com/osmlab/maproulette-python-client/pull/38)
3555
- Added new user methods [`#40`](https://github.com/osmlab/maproulette-python-client/pull/40)
36-
- Added enums [`a65566a`](https://github.com/osmlab/maproulette-python-client/commit/a65566affac5a9a311fca4099870cc0d8bbebc5d)
37-
- Add more challenge properties [`280d70c`](https://github.com/osmlab/maproulette-python-client/commit/280d70cc5e081f32213a13132ee6a9e54954f485)
38-
- Change properties [`6660f05`](https://github.com/osmlab/maproulette-python-client/commit/6660f058ce6ab99a93bd2efd778d9c7f1a4287c2)
3956

4057
#### v1.0.0
4158

@@ -60,6 +77,3 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6077
- [Travis] Set tox python version to 3.6 [`#5`](https://github.com/osmlab/maproulette-python-client/pull/5)
6178
- Add tox to requirements.txt & PR template [`#4`](https://github.com/osmlab/maproulette-python-client/pull/4)
6279
- Build initial scaffolding for project [`#1`](https://github.com/osmlab/maproulette-python-client/pull/1)
63-
- Initial commit with scaffolding [`9bd6cbb`](https://github.com/osmlab/maproulette-python-client/commit/9bd6cbb5a9cf277a841a2b1add8ddccd6af4aac4)
64-
- Create LICENSE [`90af651`](https://github.com/osmlab/maproulette-python-client/commit/90af651113f97537c20ab8b6996305d2c1cb0335)
65-
- Add new features to project api [`04488da`](https://github.com/osmlab/maproulette-python-client/commit/04488dab8ba396bc05aa265ee748d129caec64ad)

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Welcome to MapRoulette's documentation!
1717
usage/models/project
1818
usage/models/challenge
1919
usage/models/task
20+
usage/models/cooperative_work
21+
usage/models/parent_operation
22+
usage/models/child_operation
2023
usage/models/priority_rule
2124
usage/exceptions
2225

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Child Operation Model
2+
=====================================================
3+
4+
.. automodule:: maproulette.models.child_operation
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Cooperative Work Model
2+
=====================================================
3+
4+
.. automodule:: maproulette.models.cooperative_work
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:

docs/usage/models/enums.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Enums
2+
=====================================================
3+
4+
.. autoclass:: maproulette.models.enums.Conditions
5+
:members:
6+
7+
.. autoclass:: maproulette.models.enums.Types
8+
:members:
9+
:undoc-members:
10+
11+
.. autoclass:: maproulette.models.enums.StringOperators
12+
:members:
13+
:undoc-members:
14+
15+
.. autoclass:: maproulette.models.enums.NumericOperators
16+
:members:
17+
:undoc-members:
18+
19+
.. autoclass:: maproulette.models.enums.OSMObjects
20+
:members:
21+
:undoc-members:
22+
23+
.. autoclass:: maproulette.models.enums.OperationTypes
24+
:members:
25+
:undoc-members:
26+
27+
.. autoclass:: maproulette.models.enums.Operations
28+
:members:
29+
:undoc-members:
30+
31+
.. autoclass:: maproulette.models.enums.CooperativeWorkTypes
32+
:members:
33+
:undoc-members:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Parent Operation Model
2+
=====================================================
3+
4+
.. automodule:: maproulette.models.parent_operation
5+
:members:
6+
:undoc-members:
7+
:inherited-members:
8+
:show-inheritance:

docs/usage/models/priority_rule.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,3 @@ Priority Rule Model
66

77
.. autoclass:: maproulette.models.priority_rule.PriorityRuleModel
88
:members:
9-
10-
.. autoclass:: maproulette.models.priority_rule.Conditions
11-
:members:
12-
13-
.. autoclass:: maproulette.models.priority_rule.Types
14-
:members:
15-
:undoc-members:
16-
17-
.. autoclass:: maproulette.models.priority_rule.Conditions
18-
:members:
19-
:undoc-members:
20-
21-
.. autoclass:: maproulette.models.priority_rule.StringOperators
22-
:members:
23-
:undoc-members:
24-
25-
.. autoclass:: maproulette.models.priority_rule.NumericOperators
26-
:members:
27-
:undoc-members:
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import maproulette
2+
import json
3+
import base64
4+
5+
# Create a configuration object for MapRoulette using your API key:
6+
config = maproulette.Configuration(api_key="API_KEY")
7+
8+
# Create an API objects with the above config object:
9+
api = maproulette.Task(config)
10+
11+
# Setting a challenge ID in which we'll place our cooperative task
12+
challenge_id = 14452
13+
14+
# We'll start by creating some 'child' operations to apply to the target objects add them to a list:
15+
child_operations_list = [maproulette.ChildOperationModel(operation="setTags",
16+
data={"test_tag_1": "True",
17+
"test_tag_2": "True",
18+
"test_tag_3": "True"}).to_dict(),
19+
maproulette.ChildOperationModel(operation="setTags",
20+
data={"test_tag_4": "True"}).to_dict(),
21+
maproulette.ChildOperationModel(operation="setTags",
22+
data={"test_tag_5": "True"}).to_dict()]
23+
24+
# Now we'll pass these operations into a 'parent' operation list to specify the objects to which the changes
25+
# will be applied:
26+
test_parent_relation = [maproulette.ParentOperationModel(operation_type="modifyElement",
27+
element_type="way",
28+
osm_id="175208404",
29+
child_operations=child_operations_list).to_dict()]
30+
31+
# The below flags error when handling is in the constructor, but not when in the setter:
32+
test_2 = maproulette.ParentOperationModel(operation_type="modifyElement",
33+
element_type="way",
34+
osm_id="175208404",
35+
child_operations=child_operations_list)
36+
37+
38+
# Now that we have a Parent Operation containing the Child Operations we'd like to implement, we
39+
# can pass this into our Cooperative Work model:
40+
41+
test_cooperative_work = maproulette.CooperativeWorkModel(version=2,
42+
type=1,
43+
parent_operations=test_parent_relation).to_dict()
44+
45+
# Now we can create a basic task to apply these suggested changes to:
46+
with open('data/Example_Geometry.geojson', 'r') as data_file:
47+
data = json.loads(data_file.read())
48+
49+
test_task = maproulette.TaskModel(name="Test_Coop_Task_Kastellet",
50+
parent=challenge_id,
51+
geometries=data,
52+
cooperative_work=test_cooperative_work).to_dict()
53+
54+
55+
# Finally, we'll pass our task object to into the create_task method to call the /task
56+
# endpoint, creating this new task with our cooperative work model applied
57+
print(json.dumps(api.create_task(test_task), indent=4, sort_keys=True))
58+
59+
60+
# Alternatively, cooperative work can be populated as in-progress edits via an OSM changefile (osc file)
61+
# as 'type 2' cooperative work:
62+
with open('data/ExampleChangefile.osc', 'rb') as data_file:
63+
osc_file = base64.b64encode(data_file.read()).decode('ascii')
64+
65+
test_osc_cooperative_work = maproulette.CooperativeWorkModel(type=2,
66+
content=osc_file).to_dict()
67+
68+
test_osc_task = maproulette.TaskModel(name="Test_Coop_Task_Kastellet_OSC_2",
69+
parent=challenge_id,
70+
geometries=data,
71+
cooperative_work=test_osc_cooperative_work).to_dict()
72+
73+
print(json.dumps(api.create_task(test_osc_task), indent=4, sort_keys=True))
74+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<osmChange version="0.6" generator="acme osm editor">
2+
<create>
3+
<node id="-1" changeset="-1" version="1" lat="55.69378277487475" lon="12.593096457148427" />
4+
<node id="-2" changeset="-1" version="1" lat="55.689697320811575" lon="12.597881450158676" />
5+
<way id="-3" changeset="-1" version="1">
6+
<nd ref="-1"/>
7+
<nd ref="-2"/>
8+
</way>
9+
</create>
10+
</osmChange>

maproulette/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from .models.challenge import ChallengeModel
99
from .models.task import TaskModel
1010
from .models.priority_rule import PriorityRule, PriorityRuleModel
11+
from .models.child_operation import ChildOperationModel
12+
from .models.parent_operation import ParentOperationModel
13+
from .models.cooperative_work import CooperativeWorkModel
1114
from .models import priority_rule
1215
from .api.project import Project
1316
from .api.challenge import Challenge

0 commit comments

Comments
 (0)