Modify

Opened 6 years ago

Closed 6 years ago

Last modified 3 months ago

#17745 closed defect (fixed)

Unexpected result from element of (∉) with unclosed ways

Reported by: GerdP Owned by: team
Priority: normal Milestone: 19.05
Component: Core Version:
Keywords: template_report Cc:

Description (last modified by GerdP)

What steps will reproduce the problem?

  1. See example hw-in-building.osm attached to ticket:10391
  2. Open Search dialog in expert mode and select "MapCSS selector"
  3. Enter
    *[highway]  area[building]
    

What is the expected result?

The three examples all have a highway within a building. I think it would be good when JOSM would find all three buildings.

What happens instead?

The building in the middle is selected.

Please provide any additional information below. Attach a screenshot if possible.

The problem is in the java code: The selectors don't detect that they use "polygon" methods with unclosed ways and the "polygon" methods simply draw a line from the last point to the first and thus create a closed way before calculating the results.
In r15031 this is also true for unclosed ways matching the right selectors.
In r15102 the problem only exists for the left selectors.

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2019-04-28 04:36:41 +0200 (Sun, 28 Apr 2019)
Build-Date:2019-04-28 02:37:58
Revision:15031
Relative:URL: ^/trunk

Identification: JOSM/1.5 (15031 en) Windows 10 64-Bit
OS Build number: Windows 10 Home 1803 (17134)
Memory Usage: 558 MB / 1820 MB (337 MB allocated, but free)
Java version: 1.8.0_201-b09, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1920x1080
Maximum Screen Size: 1920x1080
VM arguments: [-XX:StartFlightRecording=name=MyRecording2,settings=d:\dbg\gerd.jfc, -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=e:\ld\perf_20190523_061454.jfr]
Dataset consistency test: No problems found

Plugins:
+ OpeningHoursEditor (34977)
+ apache-commons (34908)
+ buildings_tools (34982)
+ continuosDownload (82)
+ ejml (34908)
+ geotools (34908)
+ jaxb (34908)
+ jts (34908)
+ o5m (34908)
+ opendata (34997)
+ pbf (34908)
+ poly (34991)
+ reverter (34999)
+ undelete (34977)
+ utilsplugin2 (34977)

Validator rules:
+ c:\josm\core\data\validator\geometry.mapcss

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.

Attachments (1)

17745.patch (3.7 KB ) - added by GerdP 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by GerdP, 6 years ago

Description: modified (diff)

by GerdP, 6 years ago

Attachment: 17745.patch added

comment:2 by GerdP, 6 years ago

Milestone: 19.05

The attached patch changes JOSM so that unclosed ways or multipolygons with unclosed outer rings are never considered to be inside a polygon. If I hear no complains I'll commit this on saturday as a work around.

I think the better solution would be to have an algorithm that works with unclosed ways like this:
Regard the way as a collection of all the points which are on the line segments. If all points are inside or on the edges of the polygon the way is inside the polygon. In other words: If any of the points is outside of the polygon it is not inside.
The existing code in MultipolygonTest might be a base for that new algorithm...

comment:3 by GerdP, 6 years ago

In 15107/josm:

see #17745: ignore unclosed ways and multipolygons with unclosed outer rings in methods Geometry.filterInsidePolygon() and Geometry.filterInsideMultipolygon()
TODO: implement correct algorithm for unclosed ways

comment:4 by GerdP, 6 years ago

Resolution: fixed
Status: newclosed

in reply to:  3 comment:5 by mikhukh, 3 months ago

TODO: implement correct algorithm for unclosed ways

Hello,
is there an algorithm for unclosed ways now? I cannot select them, only nodes or closed ways/areas.
I tried to find the correct case of selecting unclosed ways in actual validator, but I couldn't.

way[highway] ∈ area[building] {
  throwError: tr("Highway is inside {0}", "building");
}

comment:6 by GerdP, 3 months ago

I don't think that any new logic was added. I solved a similar problem by searching for the nodes of a highway way, but that doesn't work if a segment of a way is in the area while all the nodes are outside.

Last edited 3 months ago by GerdP (previous) (diff)

in reply to:  6 comment:7 by mikhukh, 3 months ago

Replying to GerdP:

I don't think that any new logic was added. I solved a similar problem by searching for the nodes of a highway way, but that doesn't work if a segment of a way is in the area while all the nodes are outside.

Thanks a lot! It is strange, but I can't select nodes of a highway even if they are inside the area, i.e.:

way[highway] node {
  set highway_nodes;
}

node[is_prop_set(highway_nodes)] ∈ area[building] {
  throwError: tr("Node of highway is inside {0}", "building");
}

This method also doesn't work:

node[parent_tag(highway)] ∈ area[building] {
  throwError: tr("Node of highway is inside {0}", "building");
}

comment:8 by GerdP, 3 months ago

Maybe you use the wrong operator. I use these rules to find waterway nodes in farmland areas. Hope it helps

way[waterway][area!=yes] > node {
  set node_in_waterway;
}

area:closed:areaStyle[landuse=farmland] ⊇  node[any(tag("layer"),"0") = any(parent_tag("layer"),"0")]:in-downloaded-area.node_in_waterway {
  throwWarning: tr("wayterway node on farmland");
}

comment:9 by mikhukh, 3 months ago

It's a magic, thank you <3
This is how it works:

way[highway] > node {
  set highway_nodes;
}

area[building] ⊇ node[is_prop_set(highway_nodes)] {
  throwWarning: tr("Node of highway is inside {0}", "building");
}

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.