As I'm in the library reality complement

picture for engaging of attention
Picture to attract attention.
I'm the one who first used navigation technology for building augmented reality.
Geolocation technology has long been known and well documented in all language parts of the Internet, including Russian. But, it is surprising that so far has not been applied properly in practice. A few years ago, all on the same habrahabr'e I read about plans to use the augmented reality cards. But as far as I can see nowhere but in ingress this, again, was not used.
In December 2011, the year Voronezh regional children's library has created its own regional resource Children of the Voronezh region and since then systematically filled his short annotations on the monuments, memorable places and other information about the Voronezh region. Users at any time may receive this information and send to the regional literature, which is available in the library.
Everything to the extreme, just. The information is already on the website. Each such article is the only record in the database as html code. To display it, enough to make one request. But we have to somehow deliver it to the user. Here was born the idea of "guide".
In Voronezh, a lot of guests. This and students from other cities, and foreigners who came on duty, and tourists. They all love to explore our sights and monuments. And always better to have something than not have to mess around and find out.
So I decided to bind each entry to a set of coordinates on the ground. If it's not augmented reality, then what?
Let us examine a concrete implementation.
Searching a week or ready-made solutions and not finding anything suitable, decided to do things his own way. First, the method of determining the coordinates of the user.
the
<body onload="getLocation();">
...
geolocationOptions: 
{
enableHighAccuracy: true;
}

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.watchPosition(showPosition);
} else { 
x.innerHTML = "Geolocation is not supported by this browser or device.";
}

As you can see here, all extremely simple. Helped me a lot watchPosition method, which is triggered not once, as getCurrentPosition, but works constantly as you change the user coordinate. Therefore it was extremely convenient to show the content depending on the situation.
The next moment, it's just checking coordinates. I long thought, how better to do? First I visited the idea of a sufficient coarsening of the accuracy of the specified location. But this method proved unsuitable, as it proved difficult to find such error, which would give the desired radius and I dropped it.
Then I began to think in the direction of the contours bounding the square on the ground. But it's very complicated and weighted code and from this idea I also abandoned.
The third solution seemed the most simple and correct. It is expressed in the following line of code:
the
var data = <?php echo $myArray ?>; //output array obtained from database data

In the end, obviously, transformed into code view:
the
var data = [["293","51.6569823","51.6583003","39.2145828","39.2174366"],["294","51.630048","51.630752","39.156333","39.157132"],["295","51.693474","51.693709","39.20857","39.209728"],["296","51.6704160","51.6718383","39.2093698","39.2117104"],["297","51.6644532","51.6647234","39.2065102","39.2066389"],["298","51.6640640","51.6645244","39.2074646","39.2079206"],["300","51.6664147","51.6669751","39.2019236","39.2021328"],["301","51.6624973","51.6629277","39.2063693","39.2069325"],["302","51.6610044","51.6621621","39.2011539","39.2019854"],["303","51.6735303","51.6739639","39.2071490","39.2077873"],["304","51.6644936","51.6652675","39.2038072","39.2049820"],["305","51.6715535","51.6722906","39.2086361","39.2097626"],["306","51.6615435","51.6622841","39.1990161","39.1997027"],["308","51.6554642","51.6559213","39.1859334","39.1865128"],["312","51.6735318","51.6740154","39.2113578","39.2124253"],["313","51.6758248","51.6762417","39.2107791","39.2114228"],["315","51.7115548","51.7120380","39.2272416","39.2277244"],["316","51.7564548","51.7572128","39.1742317","39.1752658"],["434","51.6659232","51.6664169","39.2051209","39.2057968"],["435","51.7064638","51.7071071","39.1711776","39.1726474"]];

And here is the most important:
the
function showPosition(position) {
for (i = 0; i < data.length; i++) {
if ((position.coords.latitude >= data[i][1] && position.coords.latitude <= data[i][2]) && (position.coords.longitude >= data[i][3] && position.coords.longitude <= data[i][4]))
{
showArticle(data[i][0]);
x.innerHTML = ("<h1>We will update and display information about the next monument when You're with him.</h1>");
}
} 
}

That is, summarizing the above, every time you change coordinates, we check the entire array and a comparison of current values with those that are in the array. Thus, if the user entered the rectangle that we specified when creating a tag, the script will automatically fetch article from the database. Of course, with ajax, that's such a simple way:
the
function showArticle(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else { 
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 &&xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getArticle.php?q="+str,true);
xmlhttp.send();
}
}

Of course, the above-described method has obvious shortcomings.

In the highlighted rectangle is a memorial to the victims of the bombing in the garden of Pioneers. But to specify it as something else in the area did not fall standing next to the house, when using this approach is simply impossible. But, fortunately, in this case, it doesn't matter, because, as a rule, the density of monuments per unit area is extremely small, and therefore, it does not hurt.
Another challenge is the problem most of the navigation technology. Sometimes she gives a surprisingly large errors. So, the monument to S. Yesenin is about more than five hundred meters from the monument to A. Koltsov. But because of the surrounding buildings, at times, instead of Esenin you can see information by A. Koltsov.
Nevertheless, the "Guide" started and they are already used by residents and visitors. The work for improvement will continue. I will be glad to constructive criticism and suggestions.
The "guide" can be found at the following link: www.okrae.odbvrn.ru/guide
I think with that, you can finish the review. I hope this information is helpful to the community.
UPD: video from local TV.
UPD 2: soon roll out a new version. This is already old.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Performance comparison of hierarchical models, Django and PostgreSQL

Transport Tycoon Deluxe / Emscripten part 2

google life search