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

Support defining size of features in GMF draw tool #5345

Merged
merged 2 commits into from Dec 12, 2019

Conversation

adube
Copy link
Contributor

@adube adube commented Dec 4, 2019

This patch introduces a new component in GMF to specify sizes (length, width, height, radius) while drawing features in the draw tool.

gmf-drawfeatureoptions

A new component is born: gmf-drawfeatureoptions

The parameters it must have are:

  • the OpenLayers map
  • a single interaction responsible to draw the feature (can be a measure interaction from ngeo, or an OpenLayers Draw interaction directly)

The behaves according to the type of interaction it was given. The possible ones are:

  • the ngeo length measure interaction
  • the ngeo area measure interaction
  • the ngeo azimut measure interaction
  • a draw interaction (used to draw rectangles)

Use of the Snap interaction

The Snap interaction of OpenLayers is used as main way to force the drawing tool to "snap" to an invisible grid while drawing and while sizes are set.

A single feature is created and its geometry is set in a way that the mouse always snaps to it while drawing. This is done using an enormous pixel tolerance of 10,000 pixels.

Hack to allow draw end on double-click

Double-clicking ends the drawing of a LineString or Polygon. While snapping with a 10,000 pixel tolerance, the event is eaten up by the Snap interaction, and messes with the Draw interaction.

To fix this, we manually end the drawing on double clicking, when necessary.

All Draw interactions are required

In order for the feature used by the Snap interaction to have its geometry created, we need to have access to the feature being drawn. A feature being drawn is only accessible from its Draw interaction.

There was currently no way to have access to those, which are created and nested in the NGEO drawfeature directive.

To obtain them, they were given unique ids, and then obtained through the map itself, in the GMF drawfeature directive, by using their given unique ids as a way to find them.

@adube adube force-pushed the gsgmf-1031-draw-feature-defined-length branch 2 times, most recently from 7c539dd to 68ffa5f Compare December 4, 2019 19:50
@adube adube force-pushed the gsgmf-1031-draw-feature-defined-length branch from 68ffa5f to b6eb1fe Compare December 4, 2019 19:57
@adube adube changed the title [WIP] Support defining size of features in GMF draw tool Support defining size of features in GMF draw tool Dec 4, 2019
@adube adube requested review from sbrunner and fredj December 4, 2019 20:23
@adube
Copy link
Contributor Author

adube commented Dec 6, 2019

Thanks. Was there anything more to review?

@sbrunner
Copy link
Member

sbrunner commented Dec 6, 2019

Just tow remarks on testing the example:

  • I enforce the line length to 1000m and I get (in the tooltip) 1km vertically and 997m horizontally. It's probably a projection - geodetic issue, but we should do the same on booth cases...
  • I don't know what's specified but when we draw a rectangle we can't enforce only the width or only the height...

@adube
Copy link
Contributor Author

adube commented Dec 6, 2019

I enforce the line length to 1000m and I get (in the tooltip) 1km vertically and 997m horizontally. It's probably a projection - geodetic issue, but we should do the same on booth cases...

I highly suspect that's an OpenLayers issue. I don't think this should be addressed as part of this PR.

I don't know what's specified but when we draw a rectangle we can't enforce only the width or only the height...

It was not specified. I'll ask the question on JIRA.

@adube
Copy link
Contributor Author

adube commented Dec 9, 2019

I don't know what's specified but when we draw a rectangle we can't enforce only the width or only the height...

Enforcing only one side at a time is not required, but we need to let the user know about it. I'll add a message to the panel.

@adube adube force-pushed the gsgmf-1031-draw-feature-defined-length branch from f21c7ba to 609a528 Compare December 9, 2019 14:18
@adube
Copy link
Contributor Author

adube commented Dec 10, 2019

@sbrunner or @fredj Ready for review.

@adube adube merged commit 6e11c27 into master Dec 12, 2019
@adube adube deleted the gsgmf-1031-draw-feature-defined-length branch December 12, 2019 13:41
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.

None yet

3 participants