www.sdlsuite.com Forum Index www.sdlsuite.com
Discussion of technical aspects of the SDL Component Suite
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removing or deleting landmarks

 
Post new topic   Reply to topic    www.sdlsuite.com Forum Index -> GeoPack
View previous topic :: View next topic  
Author Message
jvgoor



Joined: 07 Sep 2011
Posts: 42
Location: Maasland, The Netherlands

PostPosted: Sat Oct 08, 2011 5:20 pm    Post subject: Removing or deleting landmarks Reply with quote

When adding landmarks I tag them with a counter that I increase for every landmark that I add. Next to the map I have a stringgrid to show a list of my landmarks. When I click on a row in the Stringrid I highlight the landmark on the Geomap. I do this by setting Geomap.HightLightLandmark:=Stringrid.Row.
All works fine.

Now I want to be able to delete a landmark from the list. When removing the last landmark from the list there is no problem. The problem starts when deleting the first or a landmark somewhere in the list.

I use the command Geomap.RemoveLandmark(lat,long,classflag) and then I empty the whole stringgrid and fill it while reading all landmarkdata. However it seems that the order of the landmarks then has been changed. Also when I want to highlight the landmark that came after the deleted landmark this does not seem to work properly anymore. So somehow the call Geomap.HightLightLandmark:=Stringrid.Row does not work anymore. When I had a list of only 3 landmarks, delete one and then adding another one. Then the highlighting would result in 2 landmarks being highlighted.

So all rather unexpected behaviour. I am curious to find a solution.

Greetings,

Jaap
_________________
Jaap van Goor
Promanent b.v.
Back to top
View user's profile Send private message Visit poster's website
hlohning



Joined: 08 Sep 2006
Posts: 277
Location: Austria

PostPosted: Wed Oct 12, 2011 6:49 pm    Post subject: Reply with quote

Jaap,

the landmark removal mechanism tries to minimize the number of copy operations in the landmark array. There are two phases of the algorithm: first, all landmarks which qualify for removal are marked; second, beginning with the first landmark to be removed, each of these are overwritten with the last valid landmarks of the list.

Thus the number of copy operations is exactly equal to the number of landmarks to be removed while maintaining a contiguous array of landmarks. The minimization of copy operations is especially important if your have hundred thousands of landmarks.

On the other hand, this algorithm mixes up the order of the landmarks, so it is almost impossible to keep an external list in sync. The simplest solution to it is to assign the index of the external list to the "Tag" parameter of each landmark. This way you can easily track your landmarks.

As far as the highlighting of landmarks is concerned: there is a bug in the code which does not reset the highlighting index before deleting a landmark. The workaround is simple: just set the property HighLightLandMark to a zero value before attempting to remove landmarks.

Hope this helps,

Hans
_________________
Hans Lohninger
Software Development Lohninger
http://www.lohninger.com/
Back to top
View user's profile Send private message Visit poster's website
jvgoor



Joined: 07 Sep 2011
Posts: 42
Location: Maasland, The Netherlands

PostPosted: Thu Oct 13, 2011 11:46 am    Post subject: Reply with quote

Hans,

Thanks for the reply and the explanation how the array of landmarks is maintained in memory. I agree that speed and performance is key.

I already started to use a sorted list of those landmarks (points in a track) that require to keep their order. Good idea to synchronise these index with the tag in the landmarks.

The tip to work around the highlighting issue works very well.

Greetings,

Jaap
_________________
Jaap van Goor
Promanent b.v.
Back to top
View user's profile Send private message Visit poster's website
jvgoor



Joined: 07 Sep 2011
Posts: 42
Location: Maasland, The Netherlands

PostPosted: Thu Oct 13, 2011 3:36 pm    Post subject: Reply with quote

Hans,

I implemented your suggestions, but it still gave some behaviour that I did not like.

Setting the tag of the Landmark to the index in the ordered list does not work. When I delete a landmark I would have to change all the tags that came after this landmark. I now just ignore this tag.

So the trick was writing a FindWaypoint(lat,long) routine. That works more or less like the FindLandMark routine, but checks my Sorted list instead of the landmarkdata. I store the lat and long of each point in the track in this sorted list, and with this I fill FindLandMark. This way the sorted list works like a list in between. Works fine. I can delete waypoints and the link with the landmarks is always pointing to the correct landmark.

I can select a point on the map or in a stringlist next to the map. I can delete a point in the stringlist or by simply clicking on the map and selecting delete from a pulldown menu. All works like I wanted and both map and stringlist show the correct data in the correct order.

The trick with switching the highlight off before a delete was needed and does the trick.

Many thanks.

Greetings,

Jaap
_________________
Jaap van Goor
Promanent b.v.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.sdlsuite.com Forum Index -> GeoPack All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group