-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add project for street level imagery #980
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
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
6779347
feat(street): add street project draft fixture
ofr1tz 40cdc66
feat: add new street project
Gigaszi 33bc5ec
feat: add tutorial to street project
Gigaszi ec59ee0
refactor: move process_mapillary.py to utils
Gigaszi 78f28df
feat: add functions to process mapillary data
Gigaszi 3a7ac21
refactor: removed unused imports and classes
Gigaszi 8e5c55c
feat: add function to convert input geojson to polygon
Gigaszi dd4e220
tests: add unittests for process_mapillary
Gigaszi b274af3
fix: wrong indention and patch in test_process_mapillary
Gigaszi 7ec92ee
feat: add filtering and handling of mapillary response
Gigaszi 97e552c
tests: add tests for filtering and handling of mapillary response
Gigaszi 53dfda5
refactor: use mapillary incredentials in variables
Gigaszi 481030c
refactor: reformat file process_mapillary.py
Gigaszi 1187561
feat: add geometry to StreetTask and refactoring
Gigaszi 0bef2e0
tests(street): use simpler geometry and add filter parameters to test…
Gigaszi 789b027
refactor: tests for mapillary processing and street project
Gigaszi c1f1a79
fix: add missing parameter
Gigaszi a12a803
tests(street): add integration test for street project
Gigaszi 2fb3bc7
tests(street): add street.json for testing of street project
Gigaszi 14ff237
fix: test after refactoring
Gigaszi 80ecf28
feat: add functions for spatial sampling and tests for it
Gigaszi 984d821
feat: use filtering in street project
Gigaszi 4ab528d
feat: add spatial sampling to street project
Gigaszi f7fc5f3
feat: add size restriction for too many images
Gigaszi f11f75e
breaking: change geom column in postgres to allow all geometry types
Gigaszi 98f82c9
feat: save location of image as geometry
Gigaszi 6a1d15e
feat: use spatial filter on downloaded images
Gigaszi 05f1449
fix: adapt mapillary token entry in example env
ofr1tz 263d738
fix: do not return failed_rows and do not use functions on empty df
Gigaszi 5ac3620
Merge branch 'feature/street' of https://github.com/mapswipe/python-m…
Gigaszi df17d3c
fix: testing for removed funcionality
Gigaszi 9f2ac81
style: code formatting
ofr1tz 8593a3c
fix: fixed tests and removed return of failed rows for download from …
Gigaszi 81d44ed
Merge branch 'feature/street' of https://github.com/mapswipe/python-m…
Gigaszi 9503a7d
fix: tests for removed failing rows
Gigaszi c0016e2
style: fix flake8 errors and isort
ofr1tz 2f3d523
style: isort
ofr1tz 6ad174f
build: add requirements
ofr1tz 315d239
build: add dummy mapillary key to github workflow
ofr1tz 2b88cf7
fix: use os.getenv instead of os.environ
ofr1tz 24c7eec
test: rename class and correct comments
ofr1tz 7f46e80
fix: remove left overs of failed rows
Gigaszi 652e885
Merge branch 'feature/street' of https://github.com/mapswipe/python-m…
Gigaszi bfa0818
fix: unittests for tile download
Gigaszi 816b1e6
fix: add condition to raise valueerror if no features are found in aoi
Gigaszi f287b3a
fix: use mapillary api key secret in github workflow
ofr1tz 020178d
fix: use square brackets with os.environ
ofr1tz dcaab3d
fix: add mapillary key to docker compose
ofr1tz 8128488
fix: allow tasks with point geom in postgres
ofr1tz 74064f8
fix: change geometry type in tasks table in initdb
Gigaszi f712340
Merge branch 'feature/street' of https://github.com/mapswipe/python-m…
Gigaszi 729a4be
fix: change to all geometries in tasks table in setup db
Gigaszi 994f398
fix: use lower case in setup db
Gigaszi 57dc509
feat(django): add new project types to project type model
ofr1tz 26c822c
fix: sort imports
ofr1tz 4787dd4
fix: add new project types to schema.graphql
ofr1tz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
134 changes: 134 additions & 0 deletions
134
mapswipe_workers/mapswipe_workers/project_types/street/project.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| import math | ||
| from dataclasses import dataclass | ||
| from typing import Dict, List | ||
|
|
||
| from mapswipe_workers.definitions import logger | ||
| from mapswipe_workers.firebase.firebase import Firebase | ||
| from mapswipe_workers.firebase_to_postgres.transfer_results import ( | ||
| results_to_file, | ||
| save_results_to_postgres, | ||
| truncate_temp_results, | ||
| ) | ||
| from mapswipe_workers.generate_stats.project_stats import ( | ||
| get_statistics_for_integer_result_project, | ||
| ) | ||
| from mapswipe_workers.project_types.project import BaseGroup, BaseProject, BaseTask | ||
| from mapswipe_workers.utils.process_mapillary import get_image_metadata | ||
| from mapswipe_workers.utils.validate_input import ( | ||
| build_multipolygon_from_layer_geometries, | ||
| check_if_layer_has_too_many_geometries, | ||
| check_if_layer_is_empty, | ||
| load_geojson_to_ogr, | ||
| multipolygon_to_wkt, | ||
| save_geojson_to_file, | ||
| ) | ||
|
|
||
|
|
||
| @dataclass | ||
| class StreetGroup(BaseGroup): | ||
| # todo: does client use this, or only for the implementation of project creation? | ||
| pass | ||
|
|
||
|
|
||
| @dataclass | ||
| class StreetTask(BaseTask): | ||
| geometry: str | ||
|
|
||
|
|
||
| class StreetProject(BaseProject): | ||
| def __init__(self, project_draft): | ||
| super().__init__(project_draft) | ||
| self.groups: Dict[str, StreetGroup] = {} | ||
| self.tasks: Dict[str, List[StreetTask]] = {} | ||
|
|
||
| self.geometry = project_draft["geometry"] | ||
|
|
||
| # TODO: validate inputs | ||
| ImageMetadata = get_image_metadata( | ||
| self.geometry, | ||
| is_pano=project_draft.get("isPano", None), | ||
| start_time=project_draft.get("startTimestamp", None), | ||
| end_time=project_draft.get("endTimestamp", None), | ||
| organization_id=project_draft.get("organizationId", None), | ||
| sampling_threshold=project_draft.get("samplingThreshold", None), | ||
| ) | ||
|
|
||
| self.imageIds = ImageMetadata["ids"] | ||
| self.imageGeometries = ImageMetadata["geometries"] | ||
|
|
||
| def save_tasks_to_firebase(self, projectId: str, tasks: dict): | ||
| firebase = Firebase() | ||
| firebase.save_tasks_to_firebase(projectId, tasks, useCompression=False) | ||
|
|
||
| @staticmethod | ||
| def results_to_postgres(results: dict, project_id: str, filter_mode: bool): | ||
| """How to move the result data from firebase to postgres.""" | ||
| results_file, user_group_results_file = results_to_file(results, project_id) | ||
| truncate_temp_results() | ||
| save_results_to_postgres(results_file, project_id, filter_mode) | ||
| return user_group_results_file | ||
|
|
||
| @staticmethod | ||
| def get_per_project_statistics(project_id, project_info): | ||
| """How to aggregate the project results.""" | ||
| return get_statistics_for_integer_result_project( | ||
| project_id, project_info, generate_hot_tm_geometries=False | ||
| ) | ||
|
|
||
| def validate_geometries(self): | ||
| self.inputGeometriesFileName = save_geojson_to_file( | ||
| self.projectId, self.geometry | ||
| ) | ||
| layer, datasource = load_geojson_to_ogr( | ||
| self.projectId, self.inputGeometriesFileName | ||
| ) | ||
|
|
||
| # check if inputs fit constraints | ||
| check_if_layer_is_empty(self.projectId, layer) | ||
|
|
||
| multi_polygon, project_area = build_multipolygon_from_layer_geometries( | ||
| self.projectId, layer | ||
| ) | ||
|
|
||
| check_if_layer_has_too_many_geometries(self.projectId, multi_polygon) | ||
|
|
||
| del datasource | ||
| del layer | ||
|
|
||
| logger.info( | ||
| f"{self.projectId}" f" - validate geometry - " f"input geometry is correct." | ||
| ) | ||
| wkt_geometry = multipolygon_to_wkt(multi_polygon) | ||
| return wkt_geometry | ||
|
|
||
| def create_groups(self): | ||
| self.numberOfGroups = math.ceil(len(self.imageIds) / self.groupSize) | ||
| for group_id in range(self.numberOfGroups): | ||
| self.groups[f"g{group_id}"] = StreetGroup( | ||
| projectId=self.projectId, | ||
| groupId=f"g{group_id}", | ||
| progress=0, | ||
| finishedCount=0, | ||
| requiredCount=0, | ||
| numberOfTasks=self.groupSize, | ||
| ) | ||
|
|
||
| def create_tasks(self): | ||
| if len(self.groups) == 0: | ||
| raise ValueError("Groups needs to be created before tasks can be created.") | ||
| for group_id, group in self.groups.items(): | ||
| self.tasks[group_id] = [] | ||
| for i in range(self.groupSize): | ||
| task = StreetTask( | ||
| projectId=self.projectId, | ||
| groupId=group_id, | ||
| geometry=self.imageGeometries.pop(), | ||
| taskId=self.imageIds.pop(), | ||
| ) | ||
| self.tasks[group_id].append(task) | ||
|
|
||
| # list now empty? if usual group size is not reached | ||
| # the actual number of tasks for the group is updated | ||
| if not self.imageIds: | ||
| group.numberOfTasks = i + 1 | ||
| break |
14 changes: 14 additions & 0 deletions
14
mapswipe_workers/mapswipe_workers/project_types/street/tutorial.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from mapswipe_workers.project_types.tutorial import BaseTutorial | ||
|
|
||
|
|
||
| class StreetTutorial(BaseTutorial): | ||
| """The subclass for an TMS Grid based Tutorial.""" | ||
|
|
||
| def save_tutorial(self): | ||
| raise NotImplementedError("Currently Street has no Tutorial") | ||
|
|
||
| def create_tutorial_groups(self): | ||
| raise NotImplementedError("Currently Street has no Tutorial") | ||
|
|
||
| def create_tutorial_tasks(self): | ||
| raise NotImplementedError("Currently Street has no Tutorial") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.