The AndroidWheresMyCar_MIT.aia does not Work to Identify Lat/Long for Rooms in a House

The AndroidWheresMyCar_MIT.aia does not Work to Identify Lat/Long for Rooms. What happens with houses is that the Lat/Long is overwritten by the house address. I am trying to use the app to mark a specific room in the house. My global is to adjust the app to be able to use it to remember a room in a house or a hotel room location. However, the Lat/Long is overwritten by the house address. Can you help? That app is at the website Android, Where's My Car? for App Inventor 2 | Explore MIT App Inventor.

It will not be possible to make this app adaptation to do what you want... for simple reasons:

  • To trace the path between the memorized site and the current location are used 'ask for directions' features that use Google Maps to draw the route between the two points... and the references are the streets between the two points. Google Street would need to enter all the houses, in every room to have 'maps' where the bathroom, the kitchen or the bedroom is located, and thus be able to record the 'addresses' of each room, their respective coordinates and the possible paths between them... something unfeasible.

  • The AI2 Block that turns the coordinates into an address LocationSensor1 » CurrentAddress is based on the resources provided by Google Maps, which only mapped the streets.

Despite this, nothing prevents the coordinates of a particular internal location from being memorized to be recovered later. WhatsApp itself has a resource to share a location ... But any address linked to this will always be the street and it will not be possible to draw an internal map to reach the site, like a hotel room.

:pray:

Lito

@>-->---

This is eminently possible, but requires several conditions to be met (for practical reasons):

  1. You know in advance which locations need to be reported
  2. You create geofences for each room in a property (in advance), and include a "geofence" or range for altitude as well, if you have a multi-floor property.
  3. You create a small database of rooms: name, geofences
  4. Then when a particular lat/lon/alt is returned, it is tested against the database, and a room name is returned, which can then be included in the info box of a marker on the maps component.

I used the following html5 geolocation file to return the lat/lon/alt, this works well inside my house, and returned different values for each room (including different floors in the house). It helps if you also have wifi and data running on the device, then you are not simply relying on GPS for location services.

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<head>
	<title>glalt1</title>
</head>
<body>
<p>Get your coordinates...</p>
<p id="geo"></p>
<p id="lat"></p>
<p id="lon"></p>
<p id="alt"></p>
<script>
	
	var options = 	{
		enableHighAccuracy: true,
		timeout: 5000,
		maximumAge: 0
		};
	if (navigator.geolocation) {
		navigator.geolocation.getCurrentPosition(showPosition, error, options);
	} else { 
		document.getElementById("geo").innerHTML("Geolocation is not supported by this browser");
		if( window.AppInventor ){
			var msg = "Geolocation is not supported by this browser";
			window.AppInventor.setWebViewString(msg);
		}
	};
	function showPosition(position) {
		document.getElementById("lat").innerHTML = "lat: " + position.coords.latitude; 
		document.getElementById("lon").innerHTML = "lon: " + position.coords.longitude;
		document.getElementById("alt").innerHTML = "alt: " + position.coords.altitude;
		if( window.AppInventor ){
		var msg = "[" + position.coords.latitude + "," + position.coords.longitude + "," + position.coords.altitude + "]"
		window.AppInventor.setWebViewString(msg);
		}
	};
	function error(err) {
		document.getElementById("geo").innerHTML = 'ERROR(' + err.code + '): ' + err.message;
	};
</script>
</body>
</html>

ref

I don't believe there is any RELIABLE way of doing this.

Consider the problems:

  • what are the dimensions of a typical room? Perhaps 3 x 4 meters? On a good day the typical gps hardware receiver can at BEST resolve about 2 meters (typically about 4 to 10 meters).

  • if your room has only small windows your Android will have difficulty receiving the minimum of three gps satellite transmissions to get a satellite location fix. You gps works best outside where the Android gps has unobscured view of the sky where the satellites are continually roaming. Professionals that attempt using gps for identification of locations within a building typically use AGPS (augmented gps) to do it. Definitely beyond the capabilities of the existing LocationSensor App Inventor uses.

  • there are many more obsticales to achieving your goal when using simple coding and App Inventor.

What can you do?

  • establish a ringed fence for each of your rooms. Use it and the gps coordinates to determine which room is associated with the set of provided coordinates. A simple ringed fence is described in Figure 18-12 of Programming Your App to Make Decisions http://www.appinventor.org/bookChapters/chapter18.pdf

  • Make a Map Polygon for each room you want to resolve. The Map component has a way to determine if the location coordinates provided by your gps are within or outside the polygon boundaries. Use your app to determine if the Android is within any of your polygons.

The bad news is you still have the 'resolution' problem (the gps still doesn't know exactly where it id; read about Accuracy).

  • Instead of individual polygons, create a FeatureCollection of polygons. Here are several articles you might find useful if you attempt to see if you are in a room (other than opening your eyes and looking at the room).

Resources:

You can try lots of things. Several others have made some proposals and one of them might work for you. :wink:

Thanks Lito. Appreciate your response.

1 Like

Thanks TIMAI2. That helps me know what is possible and the limitations of the app.

What about using a transmitter with Arduino? Could I use that to get back to a specific room in the house or a specific hotel room? Geofence is a good idea but is labor intensive especially if you travel.