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

Task Grid #26

Merged
merged 17 commits into from
Oct 8, 2019
Merged

Task Grid #26

merged 17 commits into from
Oct 8, 2019

Conversation

Bonkles
Copy link
Contributor

@Bonkles Bonkles commented Aug 29, 2019

Currently, If a URL query param such as gpx=https://tm.nsosm.com/project/1915/task/1897.gpx&map=15.18/-4.0972/131.3184

is supplied to Rapid, we draw a task box around the area according to the gpx bounding box.

This PR adds the ability to subdivide the bounding box into a 2x2, 3x3, 4x4, 5x5, or 6x6 grid.

Updated .gif: As per @gaoxm's excellent feedback I've made some refinements, and the grid options will only be available when the task boundary is a rectangle.
grid_pr

@Bonkles Bonkles changed the title Add an NxN grid to the task box if a gpx URL is supplied. Task Grid Aug 29, 2019
Copy link

@gaoxm gaoxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall - the major thing to consider I think is whether to limit this to only rectangle tasks. Also could you check the build failures? From past experience builds with node.js 8 and 10 should pass.

modules/operations/delete.js Outdated Show resolved Hide resolved
modules/renderer/map.js Outdated Show resolved Hide resolved
modules/renderer/map.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
modules/ui/background.js Outdated Show resolved Hide resolved
@Bonkles
Copy link
Contributor Author

Bonkles commented Sep 6, 2019

Now that this PR checks for rectangular geometry of the task box, I ran a negative test case by manually creating my own local .gpx file with one odd side.

The grid/grid options do not render in the UI as per this screenshot:
image

modules/core/rapid_context.js Outdated Show resolved Hide resolved
@@ -259,6 +271,58 @@ export function uiBackground(context) {
updateOverlayList();
}


function renderGridList(selection) {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resurfacing - let's follow the convention in the same file and avoid empty line at beginning of function

Bonkles and others added 2 commits September 13, 2019 16:00
Refresh master from upstream.
… etc) can be found in the background controls.
if (maxlon === undefined || lon > maxlon) maxlon = lon;
}

if (f.geometry.type === 'LineString') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I should leave a comment here explaining that the 'LineString' portion of the task geoJson explicitly defines just the task bbox.

Actually, @gaoxm @zlavergne is that a valid assumption to make? Are there other formats to consider for task bboxes/gpx urls?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what could possibly be returned by TM - I think we should also allow 'Polygon'. @zlavergne could you help check what could be returned by TM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I did some further digging and it does look like I need to keep the 'LineString' constraint here. Here's why- the .gpx data fed to us by TM also contains points that show the task id/ state. These points do not necessarily share the same lats/lngs as the four corners of the task box- sometimes the points will be along the interior of a line segment.

modules/renderer/map.js Outdated Show resolved Hide resolved
modules/renderer/map.js Outdated Show resolved Hide resolved
@@ -475,7 +475,7 @@ export function svgData(projection, context, dispatch) {
d3_text(url)
.then(function(data) {
drawData.setFile(extension, data);
var isTaskBoundsUrl = extension === '.gpx' && url.indexOf('project') > 0 && url.indexOf('task') > 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaoxm @zlavergne @jeffdefacto this is one thing we definitely need to discuss- is this change okay to make? Seems like it would totally break stuff, but I see the value in allowing somebody to just send .gpx data without a project/task associated with it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we will be unsure about whether their gpx URL is for the purpose of defining the boundary of a mapping task; e.g. some users may load GPS traces through gpx URL and use them to guide mapping roads. I'm leaning towards keeping the checks.

modules/ui/background.js Show resolved Hide resolved

export function coreRapidContext(context) {
var rapidContext = {};
rapidContext.version = '1.0.1';
var _isRect = undefined;
var dispatch = d3_dispatch('task_extent_set');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you there, wondering why I need to use pub-sub to display a static option correctly.

The simple answer is- the gpx task URL is read sometime AFTER the first few renders are called for the layer sidebar. That means at time t=0, no task gpx exists, so we render the control with no grid options.

The 'task_extent_set' event fires once the extent info has been read from the URL and is available for the sidebar to re-render.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the task extent is not rectangular, we don't bother re-rendering the sidebar. If it IS rectangular, then we re-render the sidebar with the grid controls in place.

modules/core/rapid_context.js Outdated Show resolved Hide resolved
if (maxlon === undefined || lon > maxlon) maxlon = lon;
}

if (f.geometry.type === 'LineString') {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what could possibly be returned by TM - I think we should also allow 'Polygon'. @zlavergne could you help check what could be returned by TM?

modules/core/rapid_context.js Outdated Show resolved Hide resolved
//If there are only two unique lngs and two unique lats in the geometry of the
//task area, congrats- we have a rectangle!
if (uniqueLatCount === 2 && uniqueLngCount === 2) {
_isRect = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

besides this condition, we should also make sure that along each unique lat/lon value, there are at least 2 points. e.g. one counter-case could be a linestring containing only two points: uniqueLatCount === 2 && uniqueLngCount === 2 will be true but it's not a rectangle. Using a two dicts keyed on lat/lon values might be the easies way to help with that.

modules/geo/extent.js Show resolved Hide resolved
@@ -475,7 +475,7 @@ export function svgData(projection, context, dispatch) {
d3_text(url)
.then(function(data) {
drawData.setFile(extension, data);
var isTaskBoundsUrl = extension === '.gpx' && url.indexOf('project') > 0 && url.indexOf('task') > 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we will be unsure about whether their gpx URL is for the purpose of defining the boundary of a mapping task; e.g. some users may load GPS traces through gpx URL and use them to guide mapping roads. I'm leaning towards keeping the checks.

modules/ui/background.js Show resolved Hide resolved
@Bonkles Bonkles changed the base branch from master to track_id_v2.15 September 23, 2019 15:28
Copy link

@gaoxm gaoxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good now - only one minor inline comment about naming of _isRect. Don't forget to rebase and squash commits before merging :).

modules/core/rapid_context.js Outdated Show resolved Hide resolved
@Bonkles Bonkles merged commit 37c6b93 into facebook:track_id_v2.15 Oct 8, 2019
Bonkles added a commit to bonkles-worldai/RapiD that referenced this pull request Jun 25, 2020
* Grid has been added if a GPX url is supplied- Grid options (2x2, 3x3, etc) can be found in the background controls if and only if the bounding area is a rectangle.
bhousel added a commit that referenced this pull request Jul 7, 2020
Task Grid (Copy of PR #26, originally merged into the v2 branch).
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.

4 participants