Modify

Opened 17 years ago

Closed 11 years ago

Last modified 11 years ago

#1621 closed enhancement (fixed)

Align nodes to rectangle proposal

Reported by: jekader Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: Cc:

Description (last modified by skyper)

Currently, the tool works only for a closed way of four nodes.

I think, it would be useful to align any four nodes like that.

So, the Idea is - I select any 4 nodes, press Q, and voila - they are aligned in a rectangle

Attachments (4)

ortho.gif (142.6 KB ) - added by hkucharek 17 years ago.
Outcome of new orthogonalization method
josm-1054-add-ortho.patch (13.2 KB ) - added by hkucharek 17 years ago.
Patch for orthonormalization action
alignortho.png (269 bytes ) - added by hkucharek 17 years ago.
Menu icon for orthonormalization action
AlignOrthogonallyAction.java (10.5 KB ) - added by hkucharek 16 years ago.
Alignment action with orientation given by two selected nodes

Download all attachments as: .zip

Change History (21)

comment:1 by anonymous, 17 years ago

Problem is, the Rectangle is constructed from the sidelines, not the nodes...

comment:2 by jekader, 17 years ago

I don't know the internals of the algorythm. Just made a suggestion, that would help me to map :)

Moreover, my knowledge of geometry tells me, 4 nodes would be sufficient for the job :)
As well as, say, a "make lines parallel" tool - I'd consider that useful, too.

So' if it's difficult to implement, leave it alone. JOSM is a great tool, and I'll use it anyway. Thanks for the great job, and the german quality!

comment:3 by Henry Loenwind, 17 years ago

I wouldn't say it's impossible to change the tool. However, I don't really understand how it works. ;)

If someone had an algorithm for aligning 4 randomly positioned points into a rectangle, I'd be happy to implement it.

comment:4 by anonymous, 17 years ago

  1. calculate the center of the polygon descripted from the 4 nodes
  1. calculate the radius of a circle as the distance from the center of the farest node
  1. place every other node on the circunference using sin() and cos() based on the angle

comment:5 by jekader, 17 years ago

yeah, now I understood where the difficulty lies :)
I didn't notice it before - that one of the nodes can be inside a triangle of others... So if the nodes are not connected by ways - how should the program "unite" them to see the polygon?

Need an algorythm for that! The previous comment seems to have one :)

comment:6 by hkucharek, 17 years ago

I currently work on a more general approach: You have a way describing an object and all corners should be right angles. You select the way, then the general orientation of edges is computed. Then the edges are aligned to the general orientation and new corners are computed as intersections of re-orientated edges.
I've added some buildings to OSM which are not simple rectangles, but L-, U- or other shapes. With my approach, I'll get them nice. Maybe I'll allow several ways to be processed at once. This would help to orient a group of buildings nicely.

comment:7 by jekader, 17 years ago

yep! that's what I wanted to achieve with my proposal. But your idea is surely better! It's much easier to align the whole building at once, than aligning it's parts step by step.

comment:8 by hkucharek, 17 years ago

I'm now in testing my implementation.
Current results can be seen at
http://img381.imageshack.us/my.php?image=orthomn5.gif[[BR]]
Upper right are three arbitrary shapes to be orthogonalized.
Lower left is outcome of current methode which has to be applied sequentially.
Upper left is outcome of applying my new method sequentially.
Lower right is outcome of applying new method to all three shapes at once.
I modified computing the general orientation by weighting headings by the length of the segment. Thus, longer segments, which are usually better aligned to the real orientation, have more importance in the computations. After establishing the general orientation, each segment is rotated around its center to align with the new orientation. Then the newly oriented segments are intersected with each other. The original nodes are the moved to the intersection points.

by hkucharek, 17 years ago

Attachment: ortho.gif added

Outcome of new orthogonalization method

by hkucharek, 17 years ago

Attachment: josm-1054-add-ortho.patch added

Patch for orthonormalization action

by hkucharek, 17 years ago

Attachment: alignortho.png added

Menu icon for orthonormalization action

comment:9 by hkucharek, 17 years ago

I attached a patch and icon file to add the described orthonormalization action to JOSM. Patch is based on version 1054 of JOSM. Feedback welcome.

in reply to:  9 ; comment:10 by hkucharek, 17 years ago

Replying to hkucharek:

I attached a patch and icon file to add the described orthonormalization action to JOSM. Patch is based on version 1054 of JOSM. Feedback welcome.

Ooops. Don't use. Seems, every segment is turned by 180 degrees, so nodes change position more than necessary.

in reply to:  10 comment:11 by hkucharek, 17 years ago

Replying to hkucharek:

Replying to hkucharek:

I attached a patch and icon file to add the described orthonormalization action to JOSM. Patch is based on version 1054 of JOSM. Feedback welcome.

Ooops. Don't use. Seems, every segment is turned by 180 degrees, so nodes change position more than necessary.

Was even more stupid. Had it correct in the comment, but wrong in the code.
Replace the line

Node n = myWay.nodes.get(i1);


with

Node n = myWay.nodes.get(i2);



comment:12 by jekader, 17 years ago

I'm not a developer, so I can't test your work right now - but let's hope it gets into JOSM core soon - very useful for drawing buildings!

by hkucharek, 16 years ago

Alignment action with orientation given by two selected nodes

comment:13 by hkucharek, 16 years ago

I added the possibility to select besides the ways also two single nodes. The new orientation is then established by the line connecting the two nodes and not computed from the ways. This way, you can align the ways to something else, maybe a road or such things. If you already applied the patch, you can just replace the file with the attached one. If you don't select nodes, the behaviour is as before. Checks are done, that if, only two nodes will be accepted.

comment:14 by framm, 16 years ago

Resolution: fixed
Status: newclosed

I have applied this patch for r1076 with minor changes: The new action now replaces the old "align in rectangle" method, re-using the key code. There is also a "don't show again"able message warning you if you have EPSG:4326 set. There's one thing I do not like yet, and that is that multiple changes are generated if you call the function repeatedly (it doesn't recognize that the shape is already rectangular, makes minuscle adjustments). I tried to build in a treshold under which there would be no change recorded but it didn't work out well.

in reply to:  14 comment:15 by hkucharek, 16 years ago

Resolution: fixed
Status: closedreopened
Summary: Aline nodes to rectangle proposalAlign nodes to rectangle proposal

Replying to framm:

I have applied this patch for r1076 with minor changes: The new action now replaces the old "align in rectangle" method, re-using the key code. There is also a "don't show again"able message warning you if you have EPSG:4326 set. There's one thing I do not like yet, and that is that multiple changes are generated if you call the function repeatedly (it doesn't recognize that the shape is already rectangular, makes minuscle adjustments). I tried to build in a treshold under which there would be no change recorded but it didn't work out well.

First, thanks for putting it into JOSM. Good idea with the warning about the coordinate system.

Second, I already recognized that and also don't like it. I work on it.

Third, the short description says "Move nodes so all angles are 0/90/180/270deg" which better should read "Move nodes so all angles are 90 or 270deg"

comment:19 by skyper, 13 years ago

Description: modified (diff)
Owner: changed from framm to team

comment:20 by Don-vip, 11 years ago

Priority: minornormal
Resolution: fixed
Status: reopenedclosed

Handling this new enhancement through a new ticket (easier for us: #9528)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.