Start a new topic
Solved

avoiding the stacking of POIs

avoiding the stacking of POIs


Hi there,

you should assign a height right away.(otherwise the objects might jump)  When you use:

singlePoi.location = new AR.GeoLocation(singlePoi.latitude, singlePoi.longitude, singlePoi.height);

and additionally you can change the height afterwards within the dataFromWebservice.js easily using a call like

World.markerList.poiData.location.altitude = singlePoi.altitude;

And I would suggest to put the clustering function into the locationupdate area as well :

if (!World.alreadyRequestedData) {
             if (Tour.id > 0){
                World.requestDataFromServer(lat, lon);
                World.alreadyRequestedData = true;}
            }
        else
        {

         Do The Clustering

}

This way when you move around and come closer toward the POIs they get reclustered if necessary.

good luck !

Alexander

 

Hi Alexander,

Thanks again. I am still doing something wrong and it is not working for me. Let me explain my code flow:

Loop through json items from webservice

           create singlePoi per item

           singlePoi.location = new AR.GeoLocation

           World.markerListUnclustered.push(singlePoi);

end loop

           //DO the clustering

           World.placeGeoObjects  = ClusterHelper.createClusteredPlaces(55, World.userLocation, World.markerListUnclustered);

Loop through the cluster

          singlePoi=World.placeGeoObjects.places;

          singlePoi.altitude = World.getNewAltitude(singlePoi, j); ==> getNewAltitude method has the logic posted by you to calculate the height

          World.markerList.push(new Marker(singlePoi)); ====> This is where finally the Marker is created and added to the markerList

end loop

So, where exactly in the above sequence should I be setting the height so that it works? Thanks

K. Ramesh

 

 

Hi There,

There need to be two changes :

First:

//DO the clustering

           World.placeGeoObjects  = ClusterHelper.createClusteredPlaces(55, World.userLocation, World.markerListUnclustered);

Loop through the cluster

          singlePoi=World.placeGeoObjects.places;

          singlePoi.altitude = World.getNewAltitude(singlePoi, j); ==> getNewAltitude method has the logic posted by you to calculate the height

          //You need to set the altitude of the GeoObject  :      

          singlePoi.location.altitude = World.getNewAltitude(singlePoi, j);

          World.markerList.push(new Marker(singlePoi)); ====> This is where finally the Marker is created and added to the markerList

end loop

 

Second:

you have to change the marker.js File

there is a line :

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude); (Line 16 of the marker.js Sample phonegap app)

This line is now obsolete an can be deleted because your poiData now has a poiData.location Geolocation Object

AND:

 var markerObject = new AR.GeoObject(markerLocation, {   (Line 54 of marker.js phonegap sample)

needs to be changed to

 var markerObject = new AR.GeoObject(poiData.location, {   (Line 54 of marker.js phonegap sample)

I hope you get it running. If not you should try to do some debugging. Pass some fixed values of height to see if it works and use colsole.log to debug output your caculations to see if the right vales get returned.

kind regards,

Alexander

Hi Alexander,

Sorry to bother you again. I had already done the changes as suggested by you and had done debugging also. For some reason it doesn't seem to work for me. I have tried hard coding the altitude for one of the POIs, even that is not working.

            for (var i=0; i<World.placeGeoObjects.length; i++) {
            //go through all items in each cluster
                for (var j=0; j<World.placeGeoObjects.places.length; j++) {
                    singlePoi = World.placeGeoObjects.places;
                    // the singlePoi altitude is originally 0
                    // it will be increased by 250 for each item remaining in the cluster
                    try{
                        singlePoi.altitude = World.getNewAltitude(singlePoi, j);
                        singlePoi.location.altitude = singlePoi.altitude;
                    }catch(e){
                        alert(e.message);
                    }
                    
                    if (singlePoi.title.indexOf('Blah Blah') != -1) {
                        singlePoi.location.altitude = 1500;  ===> hard coding the altitude for one POI
                    }
                    World.markerList.push(new Marker(singlePoi));
                }
            }

I have done the marker.js change also through this line: var markerLocation = poiData.location;. This is slightly different than what you had suggested but it should be fine. Is there something else I could be missing. I read somewhere in the forum that the accuracy that is received by onLocationChanged matters for altitude setting. Does it?

I really appreciate your help. Thanks

K. Ramesh

Hi,

i just developed a working sample which uses the clustering based on the Wikitude Sample. You can use it to integrate it into the PhoneGap Sample of wikitude 3.1. You just have to add the modified clustering.js and poisFromWebService.js which are attachted to this message.

(dont forget to include <script type="text/javascript" src="js/clustering.js"></script>  in the <HEAD> area of the index.html inside the world folder :)

kind regards,

Alexander

 

Hi,

you could try to work it out step by step.

First take the marker.js an do

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, 250);

if this works then you can try the next change like :

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, 0);

markerLocation.altitude = 250;

if this works then you can set

markerLocation = poiData.location;

poiData.location.altitude = 250;

and so on, try to make as little change as possible from the original to see where the problem lies.

kind regards,

Alexaner

I added the below code in the markerObject creation where I am increasing the altitude on a click. Even this is not working! The alert shows up corretly and the altitude number keeps increasing by 500. But the marker remains at the same height!

     markerObject = new AR.GeoObject(markerLocation, {
            drawables: {
                cam: ,
                indicator: this.directionIndicatorDrawable
            }
        });
        if (this.poiData.title.indexOf('Pai') != -1) {
            markerObject.onClick = function() {
                alert(markerObject.locations.altitude);
                markerObject.locations.altitude = markerObject.locations.altitude+500;
            };
        }

Hi Alexander,

Do you have any feedback based on my latest reply? I know I am bothering you, but I am stuck and no one else,  including Wikitude support team, seem to have an answer. Please help.

Thx

K. Ramesh

Hello Andreas,

Can you guys help out? Alexander gave some good leads on the issue. Apparently it is working for him. But whatever I have tried, it doesn't seem to work for me. I have provided enough details on the various thigs I have tried. Anything else I need to try to make this altitude thing work correctly?

Why is it so difficult to get answers from Wikitude support team? I know I am still on the trial version, but without getting the issues sorted out, how can I decide to buy the paid version? Please help out.

K. Ramesh

Hi there!

Note that it is not enough to "just define a clustering" once in your code.

* You need to ensure that the user's location is repoted properly to the AR-view (via setLocation).

* Also note that you need to re-cluster your pois when the user moves or location updates arrive (letting user "jump for several meters", which destroys your previous calculations)

Also consider to implement your own clustering approach, the one I provided in the old posts is very basic and groups the POIs by view-angles.

Best regards

Hi there,

I was a little busy lately :)

I checked your code and found something:
ert shows up corretly and the altitude number keeps increasing by 500. But the marker remains at the same height!

     markerObject = new AR.GeoObject(markerLocation, {
            drawables: {
                cam: ,
                indicator: this.directionIndicatorDrawable
            }
        });
        if (this.poiData.title.indexOf('Pai') != -1) {
            markerObject.onClick = function() {
                alert(markerObject.locations.altitude);
                markerObject.locations.altitude = markerObject.locations.altitude+500;
            };
        }

there is no locations array. Try to replace the highlighted lines with :

alert(markerLocation.altitude);
markerLocation.altitude = markerLocation.altitude + 50;

That should do the trick.

regards,

Alexander

 

Hi there!

Besides the hints of Alexander please also ensure you pass altitude '0' information to architectView on Location updates. Otherwise your altitude clustering is not working as you expect it - as states in page 1 of this post already.

Kind regards,
Andreas

 

Please find clustering.js attached - just n case you came across but noticed that public dropbox link is no longer working

zip
(49.9 KB)

Hi Andreas,

Thanks for the response. I understood what you are saying, finally! All along I was trying to set the altitude as '0' when I was creating the singlePoi obj and trying to increase it later using the clustering code. Finally it dawned on me that you are talking about the setLocation call on the architectView. Once I realized my mistake and set it, it started working. Now the markers are showing up at different heights. Thanks to you and Alexander.

K. Ramesh

Hi , I'm also trying to do this to avoid clusteing my POIs , but I don't get what is the difference between "clusterAngle" and "bubbleAngle" ? the bubbleAngle isn't even defined in the code. and even if I assume them the same by 'var bubbleAngle = clusterAngle;' and try to run the code , when I debug I see the cluster clusteredPois array is empty. I'll appreciate if you can help me with this. 

thanks
Login or Signup to post a comment