swissAR

swissAR is an augmented reality web app displaying relevant information about the user's surroundings.

swissAR is a project based upon Toposwiss, a Virtual Reality model of Switzerland. swissAR is a mobile web app providing geographical information about the user's surroundings. Like Toposwiss, it is driven by an open-data digital elevation model (DEM) published by the Swiss federal office of topography and by toponymy databases listing Swiss city and village names, postcodes, mountain peaks, cultural heritage sites, bus and railway stations, sports facilities etc.

Instructions

Launch your camera app, hold your smartphone upright and point it towards the QR code. Confirm website access, camera access, geolocation and motion sensor access. Hold still during calibration. As soon as swissAR displays the information you can turn around and discover any point of interest within a range of 10 kilometers.

In the center a compass will indicate your current heading. The buttons at the bottom allow for adjusting the height of the virtual camera. Tap on the arrow-up button in order to lift the cam by 1000 meters or the arrow-down button to lower it respectively; on the bottom left a cam height indicator will display your current virtual height above ground level. Hit the reload button to recalibrate the app if needed.

Settings

To avoid the camera and geolocation confirm dialogs on startup you can adjust your smartphone settings.

  • iOS Safari: Go to
    • Settings > Safari > Location Services > Allow
    • Settings > Safari > Camera > Allow
  • Android Chrome: Go to
    • Chrome > Settings > Location > Allowed
    • Chrome > Settings > Camera > Allowed

Technical

On startup swissAR will launch the camera, retrieve geolocation data, current compass heading and access motion sensor data. It will then process the elevation model in order to determine the user's height above sea level and any relevant point of interest within a given distance. swissAR will work anywhere in Switzerland; outside Switzerland it will take you to Berne (or any other place when using parameters, see below). swissAR does not store any kind of user or session data, neither on the device nor on the web server.

swissAR has been built with A-Frame and the Augmented Reality component AR.js. A-Frame XR projects are rendered by any major web browser and on any platform. Yet, swissAR has been designed for mobile use and will not work on desktop computers properly due to the lack of a rear camera or motion sensors.

Geography

swissAR makes use of the HTML 5 geolocation API. The output (world geodetic format, in decimal degrees) must be converted into Swiss coordinates (zero point in Berne, see below), the javascript processing of which is as follows:

navigator.geolocation.getCurrentPosition(function(position) { // HTML 5 geolocation API
   var n, e;
   var b1=position.coords.latitude∗3600; // conversion algorithm
   var l1=position.coords.longitude∗3600;
   var b2=(b1-169028.66)/10000;
   var l2=(l1-26782.5)/10000;
   n=200147.07+308807.95∗b2+3745.25∗Math.pow(l2,2)+76.63∗Math.pow(b2,2)+119.79∗Math.pow(b2,3)-194.56∗Math.pow(l2,2)∗b2;
   e=600072.37+211455.93∗l2-10938.51∗l2∗b2-0.36∗l2∗Math.pow(b2,2)-44.54∗Math.pow(l2,3);
}

The coordinates will then be rounded and matched against the DEM grid (further information on Wikipedia). Finally the scenery is aligned to the current compass heading which can be retrieved as follows (cross-platform solution):

window.addEventListener("deviceorientation", function(e) { // get current compass heading
   var heading;
   if (e.webkitCompassHeading) heading=e.webkitCompassHeading; // get webkit compass heading
   else heading=e.alpha; // get android compass heading
});

Parameters

swissAR is parametrizable in order to access locations other than the current one. Valid parameters are place names (case sensitive), postcodes or plain coordinates.

  • thomasweibel.ch/swissar (geolocation accepted) → current location
  • thomasweibel.ch/swissar (geolocation denied, or outside Switzerland) → zero point of the Swiss coordinate system (600 000 E/200 000 N) at the old astronomical observatory of the University of Berne
  • thomasweibel.ch/swissar?ort=Chur → Chur, Canton of Grisons
  • thomasweibel.ch/swissar?plz=8001 → Zurich
  • thomasweibel.ch/swissar?lon=637071&lat=161752 → Wengen, Canton of Berne

Data

Contact

Thomas Weibel

Edited

4 years ago ~ twb

Event finish

Start

 
Contributed 4 years ago by twb for GLAMhack 2020

Connect to our community on: forum.opendata.ch | twitter | facebook

All attendees, sponsors, partners, volunteers and staff at our hackathon are required to agree with the Hack Code of Conduct. Organisers will enforce this code throughout the event. We expect cooperation from all participants to ensure a safe environment for everybody. For more details on how the event is run, see the Guidelines on our wiki.

Creative Commons LicenceThe contents of this website, unless otherwise stated, are licensed under a Creative Commons Attribution 4.0 International License.