NetTalk Central

Author Topic: NetTalk Maps slow motion  (Read 9516 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
NetTalk Maps slow motion
« on: November 09, 2020, 11:49:38 AM »
In the attached example, you can see 300 markers, and 30 routes using a "flight of a bird" technique.

You can see how long it takes to draw the markers and routes just clicking on Markers and waiting them to appear.
You can also move the map and see how long it takes to draw.

Is there any way of make it faster?

If the code cannot be changed... may be having a
RefreshRoutes() and a RefreshMarkers()
and a RefreshRoute(IdRoute) and a RefreshMarker(IdRoute) may be adding a IdRoute to the NetMapWaypointsQueueType queue

and have the cursor changed to cursor:wait while its drawing or moving...

As always... thanks for your help
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #1 on: November 09, 2020, 10:40:52 PM »
Hi Alberto,

>> In the attached example, you can see 300 markers, and 30 routes

Actually 300 markers, and 300 routes.

I did a test noting the time it takes to draw the map. On my system, as a reference point, it takes 4.8 seconds to draw.
I did a bit of tracing, and because Refresh does a GetMap, and in some cases GetMap does a RefreshExtras (and then Refresh calls refreshExtras) the routes and markers were being drawn twice. I've added an optimization to prevent that happening.

This brought the drawing time down to 2.8 seconds.

I changed the icon to use a ~ as per my other mail, this brought it down to 2.4 seconds.

I noted that , by default, routes use anti-aliased lines. I added a property to make the lines not-anti-aliased and that brought the time down to 1.4 seconds. To use this you would set;

  net.antiAlias = false

Probably the next optimization would be to allow the Draw engine to load, and cache, icons which would make drawing them a lot faster. This would shave off a few more tenths - perhaps as many as 4 or 5 tenths of a second. But that's quite a big change for Draw - something I've not got the time to embark on right now.

>> If the code cannot be changed... may be having a RefreshRoutes() and a RefreshMarkers() and a RefreshRoute(IdRoute) and a RefreshMarker(IdRoute) may be adding a IdRoute to the NetMapWaypointsQueueType queue

If you follow the code in NetMaps.clw you'll see that refreshExtras already breaks into RefreshRoutes and RefreshMarkers.

>> and have the cursor changed to cursor:wait while its drawing or moving..

I'm not sure what you have in mind here, but certainly you can set the cursor in the embed points in .Refresh etc if you like.

The maps are themselves cached (into c:\temp\maps by default, if you don't specify another location) so that part will go faster as you cache an area, and various zoom levels.

cheers
Bruce




Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #2 on: November 10, 2020, 04:26:48 AM »
Thank you very much.

Should I wait for a Draw update or NetTalk update or both?
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #3 on: November 11, 2020, 09:19:39 AM »
Please Bruce, if I am on time...

May you please add a way of use SETPENSTYLE(PEN:dash)  in routes?

Thanks
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #4 on: November 11, 2020, 11:20:39 PM »
>> Should I wait for a Draw update or NetTalk update or both?

The nettalk one will come sooner - the Draw one probably only next year.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #5 on: November 11, 2020, 11:22:48 PM »
In the DrawRoutes method
before the parent call
try
self.draw.SetPenStyle(pen:dash)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #6 on: November 12, 2020, 04:25:56 AM »
Ok,
the decrease to 1.4 from 4.8 secs is in the Nettalk update?

self.draw.SetPenStyle(pen:dash)

Works for all the routes, I need to set it only for some of them.

Thanks
« Last Edit: November 12, 2020, 07:11:47 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #7 on: November 12, 2020, 05:20:48 PM »
>> The decrease to 1.4 from 4.8 secs is in the Nettalk update?

yes

>> self.draw.SetPenStyle(pen:dash)
>> Works for all the routes, I need to set it only for some of them.

then embed in _DrawRoute.

the ID of the route is passed into that method.

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #8 on: November 13, 2020, 04:50:08 AM »
Ok thanks, what is the meaning, in your code, when a procedure name starts with _ ?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #9 on: November 13, 2020, 05:58:25 AM »
it's usually an internal (ie undocumented) procedure, one I'm not expecting you to derive directly.
but they are still there for those that read the code, and want to derive from them or use them...

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #10 on: November 13, 2020, 10:14:59 AM »
New issue...

When you hover the mouse over an icon, you show the label and when you leave it you call a Refresh and two RefreshExtras...

This make it very slow the icon identification.

It is because you call a Refresh to clear the Tip, Refresh does a GetMap, which
NetMapsBase.GetMap             Procedure(Real pLatitude, Real pLongitude, Long pZoom)
does a RefreshExtras at the end
And after Refresh you call NetRefresh again

I know all this is because of a way to get rid of the Tip redrawing the zone where it is.

Is there any other way of get rid of the tip without doing having to redraw all?

Thanks
« Last Edit: November 13, 2020, 10:33:33 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #11 on: November 13, 2020, 09:33:03 PM »
>> New issue...

Actually, no - same issue. This is already fixed in 11.47

>> Is there any other way of get rid of the tip without doing having to redraw all?

Technically, yes, there's a way to do this. But it would be quite a big change to the code, so outside the scope of NetTalk 11.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #12 on: November 14, 2020, 05:51:54 AM »
Ok, 1 questions:

1- anyway to avoid tips in runtime? that way I could add a check for the user to display or not the tips and then make it faster.
   Maybe setting the window timer to 0 ?

2- if you give me an idea of how to get rid of the tipo without having to redraw all I can focus on that code.

Thanks
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetTalk Maps slow motion
« Reply #13 on: November 14, 2020, 11:48:40 PM »
1.
couple ways to do it, but the 5th parameter of the call to SetMarkerDescription determines if the description is hidden or not.
So you could use a runtime expression for that.

2.
The Netmaps drawing code would need to be refactored to use Draw Layers. This would be relatively complex to do, because it would need to handle things like map moves, and so on. However it would allow for layers to be draw separately, and then only small amounts of the actual image control to be updated. It can make performance a lot faster - but it's also a lot more complicated to do.

But if you'd like to give it a go, then by all means do so, and I'm happy to fold the code together later on.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NetTalk Maps slow motion
« Reply #14 on: November 15, 2020, 03:53:10 AM »
2.
I think theres no need to refactor all...
What if we use layers only for the Tip?
Ive tried some code and it works!!

In NetMapsBase._DrawDescription  Procedure(Long pFloat)
After line 787, Ive added:

    ! Draw Box
    if self.draw.layers[99].init = 0                   ! check whether curLayer has been initialised
        self.draw.InitLayer(99,BoxWidth, BoxHeight,pPointX, pPointY)                         ! create the new layer
    end   
    self.draw.WithLayer(99)   
    self.draw.Blank(color:white)
    pPointX = 1  !to draw in the layer
    pPointY = 1

THis will create a new layer with the same pos and shape of the tip

Then at the end of the proc... line 820 aprox

    self.draw.ShowLayer(99)   
    self.draw.Display()

This should show the tip in a new layer

Then in TakeEvent OF Event:Timer I coment the
        !self.refresh()  ! clear the hover tip
and add
        self.draw.KillLayer(99)   
        self.draw.WithLayer(1)
        self.draw.Display()

It wokr very weel, theres no need to call a Refresh() and all is faster.

If you think its a good solution may you please add it to NetMaps.clw?

Thanks




« Last Edit: November 15, 2020, 06:03:39 AM by michelis »
-----------
Regards
Alberto