-
Notifications
You must be signed in to change notification settings - Fork 91
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
Task Grid #26
Conversation
There was a problem hiding this 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/ui/background.js
Outdated
@@ -259,6 +271,58 @@ export function uiBackground(context) { | |||
updateOverlayList(); | |||
} | |||
|
|||
|
|||
function renderGridList(selection) { | |||
|
There was a problem hiding this comment.
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
Refresh master from upstream.
… etc) can be found in the background controls.
…d options on whether the task area is rectangular.
modules/core/rapid_context.js
Outdated
if (maxlon === undefined || lon > maxlon) maxlon = lon; | ||
} | ||
|
||
if (f.geometry.type === 'LineString') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/svg/data.js
Outdated
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
||
export function coreRapidContext(context) { | ||
var rapidContext = {}; | ||
rapidContext.version = '1.0.1'; | ||
var _isRect = undefined; | ||
var dispatch = d3_dispatch('task_extent_set'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
if (maxlon === undefined || lon > maxlon) maxlon = lon; | ||
} | ||
|
||
if (f.geometry.type === 'LineString') { |
There was a problem hiding this comment.
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
//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; |
There was a problem hiding this comment.
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/svg/data.js
Outdated
@@ -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; |
There was a problem hiding this comment.
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.
Pulll lated changes into master.
… etc) can be found in the background controls.
…d options on whether the task area is rectangular.
There was a problem hiding this 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 :).
… will not be considered for drawing grids.
* 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.
Task Grid (Copy of PR #26, originally merged into the v2 branch).
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.