Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21172 closed enhancement (fixed)

[PATCH] Add method to create geometric distances from a point

Reported by: taylor.smock Owned by: Don-vip
Priority: normal Milestone: 21.07
Component: Core Version:
Keywords: Cc:

Description

Use cases:

  • Creating sidewalks at specified distances from a road (I really ought to release the plugin where I did this, or fold it into a different plugin)
  • Expanding bboxes by a set distance (I'm using this code in the Mapillary plugin to set the expansion of the search bbox for selection)

Attachments (3)

21172.patch (2.6 KB ) - added by taylor.smock 3 years ago.
21172.2.patch (9.6 KB ) - added by taylor.smock 3 years ago.
Add tests, correct math
21172.3.patch (9.6 KB ) - added by taylor.smock 3 years ago.
Drop some angles and distances from the test matrix (1 minute -> 14 seconds)

Download all attachments as: .zip

Change History (10)

by taylor.smock, 3 years ago

Attachment: 21172.patch added

comment:1 by anonymous, 3 years ago

Summary: [PATCH] Add method to create geometric distances from a point[Wip PATCH] Add method to create geometric distances from a point

by taylor.smock, 3 years ago

Attachment: 21172.2.patch added

Add tests, correct math

comment:2 by taylor.smock, 3 years ago

Summary: [Wip PATCH] Add method to create geometric distances from a point[PATCH] Add method to create geometric distances from a point

attachment:21172.2.patch has the following additions:

  • TestUtils gets a new method, createTestMatrix
  • Tests for the following (using createTestMatrix):
    • Projection: EPSG:3857 (WGS84)
    • Latitudes: 0, 89, -89
    • Longitudes: 0, -179, 179
    • Angles: 0, 90, 180, 270, 15, 30, 45, 60, 75
    • Distances: 1, 10, 100, 1000, 10000

The second point means there are 1 * 3 * 3 * 9 * 5 = 405 separate tests. The test checks that the expected distance between the new point and the original point are correct, and that the bearing from the original point to the new point matches the expected angle. On my machine, the 405 tests takes ~1 minute. The test matrix can probably be reduced (I'll upload another patch with that done).

by taylor.smock, 3 years ago

Attachment: 21172.3.patch added

Drop some angles and distances from the test matrix (1 minute -> 14 seconds)

comment:3 by Don-vip, 3 years ago

Milestone: 21.07
Owner: changed from team to Don-vip
Status: newassigned

comment:4 by Don-vip, 3 years ago

Resolution: fixed
Status: assignedclosed

In 18109/josm:

fix #21172 - Add method to create geometric distances from a point (patch by taylor.smock)

comment:5 by skyper, 3 years ago

Would it be possible to make this function available in mapcss? Atm, I think about validator like #17188 or checking that footway=sidewalk has a nearby main road, though, it might be useful for styles, too.

in reply to:  5 comment:6 by taylor.smock, 3 years ago

Replying to skyper:

Would it be possible to make this function available in mapcss? Atm, I think about validator like #17188 or checking that footway=sidewalk has a nearby main road, though, it might be useful for styles, too.

Probably. How would it be used?

Possible example:

node[bus=yes][public_transport=stop_position] !<some random symbol, e.g. >(0, 5) node[highway=bus_stop] {
  throwError("Bad public transport stop");
}

I can't think of a good way to just make a function, as I don't think our MapCSS implementation would allow us to parse recursive MapCSS, although I could be wrong (I haven't checked). Example:

node[bus=yes][public_transport=stop_position][distance(node[highway=bus_stop], 0, 5)] {
  throwError("Bad public transport stop");
}

The function definition would look something like this:

public List<IPrimitive> nearbyPrimitives(Predicate<OsmPrimitive> predicate, double minDistance, double maxDistance)

comment:7 by skyper, 3 years ago

See #21193.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
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.