Skip to content

Instantly share code, notes, and snippets.

@Karry
Last active August 24, 2018 22:42
Show Gist options
  • Save Karry/af0e7f4d6a9da42f472da8adfd070db5 to your computer and use it in GitHub Desktop.
Save Karry/af0e7f4d6a9da42f472da8adfd070db5 to your computer and use it in GitHub Desktop.
Example howto use LocationInfoModel from libosmscout
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Window 2.0
import QtQml.Models 2.2
import net.sf.libosmscout.map 1.0
DelegateModel {
id: delegateModel
}
LocationInfoModel {
id: locationInfoModel
Component.onCompleted: {
locationInfoModel.setLocation(50.08923, 14.49837);
}
onReadyChanged: {
if (!ready){
console.log("Loading objects around...");
return;
}
console.log("objects around: " + locationInfoModel.rowCount());
delegateModel.model = locationInfoModel;
for (var row = 0; row < locationInfoModel.rowCount(); row++) {
var item = delegateModel.items.get(row).model;
console.log(" " + row + ":");
console.log(" label: " + item.label);
console.log(" region: " + item.region);
console.log(" address: " + item.address);
console.log(" inPlace: " + item.inPlace);
console.log(" distance: " + item.distance);
console.log(" bearing: " + item.bearing);
console.log(" poi: " + item.poi);
console.log(" type: " + item.type);
console.log(" postalCode: " + item.postalCode);
console.log(" website: " + item.website);
console.log(" phone: " + item.phone);
console.log(" addressLocation: " + item.addressLocation);
console.log(" addressNumber: " + item.addressNumber);
}
}
}
@Karry
Copy link
Author

Karry commented Aug 24, 2018

possible output:

objects around: 2
  0:
    label: Osika, Žižkov
    region: Žižkov,Praha,okres Hlavní město Praha,Hlavní město Praha,Praha,Česko
    address: 
    inPlace: false
    distance: 5.236015553798375
    bearing: S
    poi: Osika
    type: amenity_restaurant
    postalCode: 
    website: https://osikarestaurant.cz/
    phone: 
    addressLocation: 
    addressNumber: 
  1:
    label: Osiková 2882/4, 13000 Žižkov
    region: Žižkov,Praha,okres Hlavní město Praha,Hlavní město Praha,Praha,Česko
    address: Osiková 2882/4
    inPlace: false
    distance: 13.280743205245322
    bearing: S
    poi: 
    type: address
    postalCode: 13000
    website: 
    phone: 
    addressLocation: Osiková
    addressNumber: 2882/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment