#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 )
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)
Change History (21)
comment:1 by , 17 years ago
comment:2 by , 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 , 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 , 17 years ago
- calculate the center of the polygon descripted from the 4 nodes
- calculate the radius of a circle as the distance from the center of the farest node
- place every other node on the circunference using sin() and cos() based on the angle
comment:5 by , 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 , 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 , 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 , 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.
follow-up: 10 comment:9 by , 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.
follow-up: 11 comment:10 by , 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.
comment:11 by , 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 , 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 , 16 years ago
Attachment: | AlignOrthogonallyAction.java added |
---|
Alignment action with orientation given by two selected nodes
comment:13 by , 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.
follow-up: 15 comment:14 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.
comment:15 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Summary: | Aline nodes to rectangle proposal → Align 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 , 13 years ago
Description: | modified (diff) |
---|---|
Owner: | changed from | to
comment:20 by , 11 years ago
Priority: | minor → normal |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
Handling this new enhancement through a new ticket (easier for us: #9528)
Problem is, the Rectangle is constructed from the sidelines, not the nodes...