Start a new topic

Use a MySQL Database as POIData: how to do it ?

Hi all


I need to get the POI data from a database because I have more than 200 000 POI and using the method provided in the example made the app crashed (method here : From a Local Resource ).


So that's why I need to create a DB and put only the POI I need on the view.


I took the code found in the example file  : "fromwebservice.js" and add the following lines :


var db = Titanium.Database.install('rawpeak.db','mydb');

var PoiValue = db.execute('SELECT id, lat, lon, alt, name FROM PeakTest;');


while (PoiValue.isValidRow()) {

        var singlePoi = {

        "id": PoiValue.fieldByName('id'),

        "latitude": parseFloat(PoiValue.fieldByName('lat')),

        "longitude": parseFloat(PoiValue.fieldByName('lon')),

        "altitude": parseFloat(PoiValue.fieldByName('alt')),

        "title": PoiValue.fieldByName('name'),

        "description": PoiValue.fieldByName('name'),

        };

 

 World.markerList.push(new Marker(singlePoi));

 PoiValue.next();

 currentPlaceNr = currentPlaceNr + 1;

    }

    PoiValue.close();

 db.close();



but it doesn't work :-(


What is wrong ? 

Is it because, I add javascript and titanium method in the file ? 


Thanks for your support


// called to inject new POI data
loadPoisFromJsonData: function loadPoisFromJsonDataFn() {

 // empty list of visible markers
World.markerList = [];
 // start loading marker assets
World.markerDrawable_idle = new AR.ImageResource("assets/marker_idle.png");
World.markerDrawable_selected = new AR.ImageResource("assets/marker_selected.png");
World.markerDrawable_directionIndicator = new AR.ImageResource("assets/indi.png");

        World.updateStatusMessage('Before DataBase');

var db = Titanium.Database.install('rawpeak.db','mydb');
var PoiValue = db.execute('SELECT id, lat, lon, alt, name FROM PeakTest;');
var resultSet = db.execute('SELECT COUNT(*) FROM PeakTest;');

 World.updateStatusMessage('Result : ' + resultSet);

 for(var i = 0; i < resultSet;i++) {

// while (PoiValue.isValidRow()) {

        var singlePoi = {
        "id": PoiValue.fieldByName('id'),
        "latitude": parseFloat(PoiValue.fieldByName('lat')),
        "longitude": parseFloat(PoiValue.fieldByName('lon')),
        "altitude": parseFloat(PoiValue.fieldByName('alt')),
        "title": PoiValue.fieldByName('name'),
        "description": PoiValue.fieldByName('name'),
        };

 World.markerList.push(new Marker(singlePoi));
 PoiValue.next();
 currentPlaceNr = currentPlaceNr + 1;
    }
    PoiValue.close();
 db.close();

World.updateStatusMessage(currentPlaceNr + ' places loaded');

 },

 


Hi Patrick,


It's sad to hear that you're switching the provider. As mentioned, unfortunately at the moment, as this topic is not directly related to our AR SDK and we'll need to plan our efforts for samples carefully, we can't provide samples for different storage options. 


We've added the request for adding a MySQL sample to our samples app, to our feature request list now, but I can't give any timeline when/if this will be added.


Should you need anything further, just let me know anytime.


Greetings

Nicola

OK Too complicated use of wikitude


No examples provided


I drop wikitude to use something else



Will try so... 


I tried with 100 000 POI in a file and the ARWorld crashed.


It's strange that no one use a My SQL Database, that's the most efficient way to store data...

Hi,


As far as we know a huge user/developer base is using json - this is also why we offer json samples. I will pass on the request internall if we could add a mysql sample, but can't promise anything. As mentioned the retrieval / storing of POI data is more a than JS/php/mySQL related topic and we as we need to plan the effort for providing samples very carefully, we currently don't offer different samples for different storage mechanisms.


Greetings

Nicola

Sorry no, this does not help.


Why don't you add a sample with MySQL Database connection ? 


I am sure most of users use a DB to store their POI, better than a JSON file ?


Can you provide me a very simple sample ?


Thanks a lot

Hi Patrick,


Does this forum post help:


https://support.wikitude.com/support/discussions/topics/5000079735


Greetings

Nicola

Login or Signup to post a comment