Adding existing location information

To allow a controller to find things in its vicinity, we must register the location of the devices it wants to find. We can do this either using numeric longitude, latitude, and altitude values or using geographic reference tags. The longitude, latitude, and altitude values might be valuable if you do applications that are geographically sensitive. But they are difficult to use in smart city applications since vicinity is not defined by concepts of geographical distance, but by other concepts, such as room, apartment, office, department, address, and so on.

In our examples, we will use the second approach. We first check if we have these values available. If so, we add them to our metadata information about the device, using the tags COUNTRY, REGION, CITY, AREA, STREET, STREETNR, BLD, APT, ROOM, and NAME, some of which can be empty. By the virtue of having these values, we also assume we update an existing registration:

if (await RuntimeSettings.GetAsync( 
   "ThingRegistry.Location", false)) 
{ 
   s = await RuntimeSettings.GetAsync( 
         "ThingRegistry.Country", string.Empty); 
   if (!string.IsNullOrEmpty(s)) 
         MetaInfo.Add(new MetaDataStringTag("COUNTRY", s)); 
 
   ... 
 
   this.UpdateRegistration(MetaInfo.ToArray()); 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset