Modify

Opened 16 years ago

Closed 16 years ago

#720 closed enhancement (fixed)

about draw.rawgps.max-line-length cost of computation

Reported by: anonymous Owned by: framm
Priority: minor Milestone:
Component: Core Version: latest
Keywords: Cc:

Description

At the moment you (re-)compute the distance fairly oftern, if I understand it correctly. However, if the assumption "if a org.openstreetmap.josm.data.gpx.WayPoint has a previous org.openstreetmap.josm.data.gpx.WayPoint, that will never change" is true, you could cache the result of the computation in org.openstreetmap.josm.data.gpx.WayPoint. e.g.

org.openstreetmap.josm.data.gpx.WayPoint:
19 public int cachedDistance = -1;

org.openstreetmap.josm.gui.layer.GpxLayer:
323 if (maxLineLength > -1) {
324 if (trkPnt.cachedDistance <= -1)
325 trkPnt.cachedDistance = trkPnt.latlon.distance(oldWp.latlon);
326 if (trkPnt.cachedDistance > maxLineLength) continue;
327 }

Attachments (2)

patch.diff (9.0 KB ) - added by Henry Loenwind 16 years ago.
patch.2.diff (9.0 KB ) - added by Henry Loenwind 16 years ago.
Patch v2

Download all attachments as: .zip

Change History (8)

comment:1 by framm, 16 years ago

I think that the assumption may be broken by loading new GPX data (which might just be sorted in between the existing data, I'm not sure) but in that case one could clear the cache on loading.

comment:2 by ramack, 16 years ago

I don't think that data will be sorted in between atm. But updating the distance cache should be easy on inserting new data.

comment:3 by Henry Loenwind, 16 years ago

Owner: changed from framm to Henry Loenwind

I thought on storing a flag about the validity of the data in the layer instead in the points. So it can easily be cleared when loading data or merging layers. I think, I'll separate the compute-loop from the draw-loop, too. That may save some ifs in the draw loop.

by Henry Loenwind, 16 years ago

Attachment: patch.diff added

comment:4 by Henry Loenwind, 16 years ago

Owner: changed from Henry Loenwind to framm

ok, here's the patch.

I added 2 new configuration values (einstein mode only for now):

draw.rawgps.alternatedirection
Set to "true" to have arrows drawn with less math. They will be off by up to 22.5°, but MAY be rendered faster. On my machine the effect was not really noticeable.

draw.rawgps.trianglelines
Set to "true" to have lines rendered as 2 lines, like the arrow lines, but over the whole length of the line. Does not look really nice, but on my machine this renders more than 10 times faster than straight lines!

by Henry Loenwind, 16 years ago

Attachment: patch.2.diff added

Patch v2

comment:5 by Henry Loenwind, 16 years ago

a minor update for the patch, no need to paint the arrows if the line was ommited because it would have had 0-length

comment:6 by ramack, 16 years ago

Resolution: fixed
Status: newclosed

patch from #966 applied in [721]

Modify Ticket

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