OpenVR, the Story Behind the Story

Our guest blogger today is Femi Taiwo, lead developer for the OpenVR project. The OpenVR Application was used to register more than 70 million voters in the just concluded general elections in Nigeria. Read on as Femi takes us behind the scenes of an application that has possibly changed the face of elections in Nigeria for ever.

OpenVR – short for Open Voters Registration – is a free and completely open-source biometrics capture solution built on open standards.

OpenVR is the software that was used to register over 73million people during the voters registration exercise held earlier this year in Nigeria. And it was BUILT (from scratch) BY NIGERIANS – all members of the team are volunteers – software engineers born, bred, trained in Nigeria.

The Team

Nyimbi ODERO – System Architect

Ronke DOMINGO – Project Manager

Femi TAIWO – Lead Software Developer

Sola AJAYI – Software Developer

Fisayo ORIMOLOYE – Software Developer

Doyin KASSEM – UI Designer

CHUKWUEMEKA Ujam – Biometrics Expert

To its credit, OpenVR can boast of

– Aggregating over 85 Tera-bytes of Data

– Printing 73M+ Voter’s Cards

– Generating over 4,600,000 Pages of Reports in PDF

– Collecting over 500,000,000 Fingerprints

– Installation on over 132,000 machines and hundreds of servers

– An effective one-click patching system

– Full Integrated AFIS

From gtug_blog

Built from ground up to be very secure and unobtrusive at the same time, OpenVR software runs on Ubuntu – a Linux Operating System and supports a variety of fingerprint scanners, external hard drives, printers and web-cameras. It also features an in-built Automatic Fingerprint Identification System (AFIS) to reject multiple registration attempts. It comes as a bundled solution that works right out of the box, without any configuration required on most hardware.

We created it as a one-click-to-install solution – it automatically installs and configures the video drivers, sound drivers, network and wireless card drivers, scanners, printers and other devices. We chose Ubuntu for several reasons including – ease of customization, rigorous quality assurance, hardware compatibility and a renowned security track record.

So, why did INEC choose to go Open-source on a very important, critical and failure-intolerant project? And why did we volunteer to build it?

For me to answer the first question, I’d like to explain what open-source really means.

Free Software and Open-Source Software

These terms are easily misunderstood.

Open source describes practices in production and development that promote access to the end product’s source materials – in this case – the sourcecode for OpenVR. Phrased from the free sharing of technological information, Open source software is software whose source code is published and made available to the public, enabling anyone to copy, modify and redistribute the source code without paying royalties or fees. Open source code evolves through community cooperation. These communities are composed of individual programmers as well as very large companies. The Linux operating system is a great example of opensource software – and in this case, it’s the complete operating system that is opensource.

Free software is a matter of the users’ freedom to run, copy, distribute, study, change and improve the software. More precisely, it means that the program’s users have the four essential freedoms:

The freedom to run the program, for any purpose.

The freedom to study how the program works, and change it to make it do what you wish. Access to the source code is a precondition for this.

The freedom to redistribute copies so you can help your neighbor.

The freedom to distribute copies of your modified versions to others. By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

This essentially means that anyone with the publicly available source-code of the OpenVR software can make modifications to the software, and release such changes, without payment to the developers of the original version.

Essentially, for INEC, this meant complete freedom from proprietary software and vendor lock-ins,It which is something that has left many institutions and other government bodies with a bitter after-taste in their mouth. It also meant that there were no hidden backdoors, no quick hacks “just make it work mentality” and that they could get independent resources at any point in time to run a peer-review of the entire software – architecture, source code and implementation. Now that’s complete control.

At the onset of this project in August (did I already mention it took under 3 months from start to finish?), there were 9 core questions

1. Will it work?

2. Will it be ready in time?

3. Will it be secure?

4. Will it be easy to use?

5. Will it be fast?

6. Will it be stable?

7. Will it be scalable?

8. Will it be re-usable?

9. Will it be extend-able?

From gtug_blog

Will it work? Yes!

By using Linux, and a baseline API for accessing all peripherals we were able to support 8 different types of fingerprint scanners, any video camera supported by Linux (for the Photo capture), and over 3500 printers (we had at least 2000 HP printer drivers installed!)

Will it be ready in time?

Good programmers thrive when working with impossible deadlines. We had a ‘healthy’ set of milestones and an incredible amount of pressure, not to mention the negative articles in the media.

Nights turned into days and the only other times we were not in front of our laptops or white-board, we were crashed out. We drew up feature quadrant – Must Have, Should Have, Could Have, Good to Have. With lots of feedback, criticism and insight from people who were around during the previous exercises we got a pretty clear idea of where each ‘brilliant’ feature went and the direction.

Will it be secure?

128 Bit Encryption. Built with fraud in mind. Used a white-list approach. Restrictive, but works like magic. Every bit (or byte if you choose) of data was encrypted – inside and outside the machine. Since there was no possibility of network coverage, the only other option was to use a removable drive to backup and transfer data – using the encrypted file-system support in the Linux kernel to protect the data and additional hashing algorithms to detect any unauthorized modifications during transfer.

Will it be easy to use?

After one of our demonstrations, a security guard sat in front of the machine and registered himself without supervision. In programmers lingo, there’s this thing called KISS. Keep It Short and Simple (there are other less polite versions). The KISS principle states that simplicity should be a key goal in design, and that unnecessary complexity should be avoided.

Effectively and intensely training 240,000 operators to learn how to use a software within a short space of time is a really difficult task.

With this understanding and knowing that the operators would have varying degrees of computer-literacy, anything that was NOT downright obvious and intuitive was considered unusable.

Will it be fast?

Our target was a maximum of 8 minutes per individual. We ended up with 4minutes (less really). A lot of things were sent to the background and managed to pull 1260 comparisons per second.

Will it be stable?

Linux prizes itself in its stability. Even when operated under ‘hectic’ conditions for extended periods of time. We had our fare share of untrappable interrupts from hardware devices which kept crashing the software. There was also the expected hardware faults. Crashed hard drives, faulty backup removables, motherboards burnouts, broken screens, faulty keyboard, corrupt boot sectors – a mile-long list of things that could possibly happen to render a system unusable after it’s been on the field and been used to capture a few hundred people.

We had a two-pronged approach. First ensure the system itself is as stable as possible – a barrage of tests of extended use with a large amount of data. Two, in the event of a failure, use the Swiss Army Knife – the OpenVR Recovery DVD. We created a DVD containing tools specifically customized for

a purpose – recovering data and restoring broken machines without data loss. The ability to recover data when everything else has gone wrong – we think this was a critical singular component and success factor in the OpenVR deployment.

Will it be scalable?

What happens when you have 10 people registered? Or 250 or 500 or 2000? Will it slow down at all? Or slow down considerably or crash outright? Will it make use of the multitasking/multi-threading capabilities of the underlying hardware? Will it handle growing amounts of work and features in a graceful manner or not?

First we identified the bottlenecks in the system – Fingerprint – AFIS. When a fingerprint is captured, we need to compare that finger against the existing database of fingerprints to check for multiple registration. The larger the database, the longer that process will take. Initially we had a sequential process – the search ran in a straight sequence – like going through (potential) records from id 1 to id 300. Instead we break up the records into sets, with each set containing a number of records – 30 for example and run a threaded process against each set. The size of each set and comparison is determined by the underlying hardware – processor, memory (free memory) and very importantly – the true multitasking features of the Linux operating system.

Will it be reusable?

It needed to be – for continuous registration and for similar implementations.

Will it be extend-able?

We needed to be able to make changes to the software – out there on the field- on 120,000 machines. And we needed to update the machine, change the way it operated, fix bugs with minimal user interaction and without data loss. If we lived in a connected environment – Internet, that would have been a walk in a park.

However, there’s no Internet. No network coverage. The GSM networks effectively cover less than 60% of the country, not to talk about how much of that amount can carry data consistently. Beyond software updates, we also needed to transfer all registration data from each machine down to the central database at the state level. Therefore using a network would have been prohibitively expensive. So we made the entire software – including the operating system itself PATCHABLE. We used Sneaker-net – the transfer of electronic information, especially computer files, by physically couriering removable media such as magnetic tape, floppy disks, compact discs, USB flash drives, or external hard drives from one computer to another. We created patches (encrypted archives as well) that work just like a virus – except that it needed users to click the Update OpenVR. This came in especially handy after the first four days of registration that was the most trying period in the entire exercise. Nothing worked as expected.

From gtug_blog

What helped, what worked and what didn’t

What helped?

Immense feedback and ideas from the ICT department in the commission, and technical advisory from IFES (International Foundation for Electoral Systems), and UNDP (United Nations Development Programme). This helped in clearing up the gray areas and think through the best approach in each scenario.

The most used phrase? : It’s not working.

Anticipate problems. Because they will come. Every time we were reminded of Murphy’s law: “Anything that can go wrong will go wrong”.

If you perceive that there are four possible ways in which something can go wrong, and circumvent these, then a fifth way, unprepared for, will promptly develop.

From gtug_blog

All of 3 months – that’s all it took for 3 young and determined programmers, 1 brilliant architect, 1 persistent project manager, 1 intuitive designer and 1 knowledgeable biometric expert to build the entire OpenVR from scratch and deploy for the voters registration exercise. And we did it for free.

This is the biggest Open source effort (and Linux Based effort too) yet to come out of Nigeria – and Africa as a whole. Disruptive technology. That’s what this is all about.

We strongly desire the growth of the software industry here in Nigeria and Africa. It is our passion and love for our country that was the fuel that drove us to succeed and even exceed expectations in many aspects.

Femi TAIWO

Partner at INITS Limited, a firm specialized in creating custom desktop solutions and web apps.

Ardent C++ and PHP Programmer.

Over 9 years of experience creating applications.

Heavy Linux user.

Things to have in mind as the deadlines for the Google Android Challenge Approaches

As the deadlines for the Android Challenge approach we should bear the following in mind:

July 1st is the first deadline, this means that latest by this weekend, you should have settled on your ideas as you will have less than a month to put it all together for the first submission (which is less than a day in developer land)

If you feel that your project idea is small enough for just you or a small team (that you should have already selected) to work on then you are good to go and should have already gone far in hashing out your app.

If on the other hand you think that your idea is something that is bigger than you given the timeframe, you may want to consider looking for team mates that would help you acheieve your goals faster. Several of us have put up links that can help us put our ideas out there and source for team mates (remember, time is short, you should have finished this step by now, in case you have not, you can look here and here),

If your team has three or more members, you may want to look at ways in which you can work together remotely. A good idea would be to set up a repository online (you can use git or any one of your choosing depending on your needs)

Again if you are in a team and like many people are tied up in school work or work-work and can hardly find time to collaborate, you may want to consider organizing a mini-hackathon preferably on weekends to get things rolling. This will come in particularly handy in the initial stages of the project as you struggle to overcome inertia.

Depending on what the response is, the Lagos GTUG could organize a hackathon for interested parties to polish up their code sometime after G-Nigeria where we could try and get our resident Android gurus to assist those who may have questions as they code.

Again, if you are in a team or trying to form one, remember that you may need more than just android skills in your project, particularly if your project has a cloud component. Skills like PHP, python, J2EE, html and even technical writing (yes, documentation is key) could come in handy.

Also take out time to learn the best practices in Android application development, many of them are spelt out in the videos on the Anroid developer challenge CD. Like we said before, a limited number of these CDs are available for collection/copying. For information on how to get/copy it send an email to gtuglagos@gmail.com. Note that the contents of the CD are also available online, so if you have a fast internet connection, you can also download the content online.

We would like to wish everyone well as they embark on their projects, looking forward to seeing interesting submissions.

Anrdroid Challange Open House, Unilag

The Lagos Google Technology User group (Lagos GTUG) held its Andorid focused open house on Saturday the 23rd of April 2011 at the Centre of information Technology Systems in the University of Lagos. It was a well attended event with 57 attendees. The attendees included people from Ibadan and our neighboring GTUGs (Akure and Abeokuta).

From Lagos_GTUG_AndroidSSA

The event kicked off at about a quarter past three in the afternoon with a welcome address from Emeka Afigbo, the manager of the Lagos GTUG. who explained what the event was all about and ran through a the agenda for the day. He then handed the mic to our first guest speaker Chinedu Efoagui, a developer with System Specs who took us through a lecture on Google Maps to whet the appetite of the audience in prepration of things to come.

From Lagos_GTUG_AndroidSSA

The lecture covered the basic aspects of Google Maps such as :

  • Proximity Detection.
  • Geocoding.
  • Directions Services
  • Calculation of Distance
  • Markers (Clustering),InfoWindows,polylines.
  • Location Detection.

One good thing about the presentation was that he gave us insights as to how to apply Google Maps which brought to light that fact that many applications of Google Maps did not need to have a map displayed.
He also showcased a site that he had created: The Very Place that applied a number of features of Google Maps.

From Lagos_GTUG_AndroidSSA

Next up was the Android Trivia Quiz, where the audience had to split themselves into groups of 8 and answer 21 questions on relating to the Google Android Platform. As Emeka reeled out the questions, team members scrambled to provide the answers. After all the team members had submitted their answers, we moved on to the high point of the occassion which was a talk introducing the Google Android platform delivered by Bolaji and Bobola of the Fans Connect Online Team. Their talk covered the introductory aspects of the Android platform and also how to use the Android SDK to develop a “Hello World” application on Eclipse. They also gave us some useful tips and tricks to use when developing Android applications such as the android garbage collection model. They then took us through an Android application which they had developed called Naija Places.
After the talk it was finally time to announce the winners of the Android quiz and the honors went to the Minders team.

From Lagos_GTUG_AndroidSSA

For their troubles the eight team members each left the event with special branded Android T-Shirts.
The last talk was by Emeka who took the audience through an overview of the Android Challenge which included things like:
What the challenge was meant to achieve
The prize money (obviously!)
The important dates
. The audience was encouraged to form teams so as to stand a better chance of winning.
Attendees went home with some branded Google goodies such as Android stickers, bags and key holders to cap off a fun filled evening
We would like to thank the following for making the event possible:

  • Google for all the swag and support
  • Staff of the CITS in the University of Lagos for being there even on Easter Saturday
  • Chinedu Efoagui for his talk and helping with some of the pictures and videos
  • Bobola Oniwura , Bolaji Olawoye and the rest of the Fans Connect Team for their talk and support
  • Parkway Projects Ltd for sparing some of their staff to make this event happen
  • and White Chapel and Partners for handling a lot of the logistics

You can see the slides from the Open House here

Pictures of the event are available in the picasa album below:

Lagos_GTUG_AndroidSSA

You can also see some videos of the event below:

What to expect at the Lagos Google Technology Open House on 23rd April 2011

Its almost here people, the much talked about open house that will pave the way for the Big One (G-Nigeria)
will be taking place on the 23rd of April at the University of Lagos at the Center for Information Technology.

Like we have said earlier, the event will be focused on Android and mobile technologies (with a trickle of other Google technologies thrown in)
As usual , the event promises to be a great forum for networking and keeping up with the latest in Google and Open source technologies.
The Program will be as follows:

  • Welcome Address and General Introductions
  • Android Trends & Brief Discussion based on a special announcement from Google
  • Talks on Google Android from subject matter experts including Fans Connect Online (developers of the Naija Places Android Application)
  • A talk on Google Maps from Chinedu Efoagui (developer of theveryplace.com)
  • Refreshments & Networking

Who is invited?

  • Mobile developers , android fans and of course people who are interested in Google Technology.
  • Students will be required to register online at http://sites.google.com/site/lagosgtug/

What do i need to come with ?

  • Yourself (compulsory)
  • As much knowledge about Android as my brain can carry (Compulsory)
  • Laptop with internet connection (optional)
  • Flash drive for copying code and tools (optional)

How long would the event last ?
Kick off time is 3pm prompt and we intend to be there for at most 3 hours. So we should be done by 6.00pm

We look forward to having you there…it will be fun

Google Technology Open House 23rd April 2011

Its happening again folks!
We are finalizing arrangements for the next Google Technology Open House in Lagos.
It will be taking place in the same venue as the last one (University Of Lagos Akoka).
The theme for this open house will be centered around mobile applications and the Android platform.
So make sure you keep 23rd of April free….and we gurrantee you that you will not regret it!

Enter the Google Map

Our guest blogger Chinedu Efoagui is a Sun Certified Java Programmer as well as a Sun Certified Business Component Developer with a Masters degree in Computer Science from the University of Hertfordshire. He is very passionate about technology and envisions a world entirely driven by it.

His interests include Object Oriented Analysis and Design, Java/.NET technology, Functional programming, Database technology and Open Source efforts.

When he is not fooling around with his computer, he likes to analyse chess games and write fiction.


https://profiles.google.com/chinedubond/

http://twitter.com/chinedubond

Requirements

Pretty Fast Internet Connection.

JQuery 1.4+

Assumed Knowledge of XML, XSLT, JavaScript

Introduction

Google Maps is an exciting technology. Since it was first lunched, it has been applied in lots of interesting ways e.g. in measuring actual sizes of buildings to resolving border conflicts! Over the years,I have had very good experience using Google Maps . I developed http://www.theveryplace.com/ – a website that uses a lot of Google Map features which give users the ability to get driving instructions and other location based stuff. Anyway, this blog entry won’t be as far reaching in showing what can be achieved using Google maps.

Before we go to the sample application proper, let me follow tradition and display a “hello world” example. We will be using JQuery- a popular JavaScript library, to simply the code. To run the hello world example, copy and paste the code below and view it on your browser. Also, you can just open the hello.html included in downloadable sample app.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

<html>

<head>

<title>Ezenna Group of Companies Ltd</title>

<style type=”text/css”>
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#zamap { height: 400px,width:600px}
</style>

<script type=”text/javascript” src=”js/jquery.min.js”>

</script>

<script type=”text/javascript”

src=”http://maps.google.com/maps/api/js?v=3.2&sensor=false”>

</script>

<script type=”text/javascript”>

$(document).ready(function () {

showmap();

});

function showmap(){

//Lagos Nigeria

var latlng = new google.maps.LatLng(6.43616,3.41647 );

var myOptions = {

zoom: 12,

center: latlng,

mapTypeControlOptions: {

style: google.maps.MapTypeControlStyle.DROPDOWN_MENU

},

mapTypeId: google.maps.MapTypeId.ROADMAP

};

var map = new google.maps.Map(document.getElementById(“zamap”), myOptions);

}

</script>

</head>

<body><div id=”zamap” ></div></body>

</html>

Step 1.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

The strict XHTML declaration instructs the browser to show the html document as is so the browser load the page faster than transitional declaration for instance because there is no extra step of validating html document.

Step 2.

<style
type=“text/css”>
html
{ height:
100%
}
body
{ height:
100%; margin:
0px; padding:
0px
}
#zamap { height: 400px,width:600px}
</style>

The CSS describes how the html document will be shown. the height, margin and also describes the height and width of the <div id=”zamap”> which acts as a placeholder for our map.

Step 3.

<script type=”text/javascript”

src=”http://maps.google.com/maps/api/js?v=3.2&sensor=false”>

</script>

This script tag loads the Google Maps Api necessary to create the map and version is 3.2 and sensor is false which means that the device does NOT use a sensor e.g. GPS to detect the user’s location.

STEP 4.

$(document).ready(function () {

showmap();

});

What this JQuery function pretty much does is execute any function or code after the entire HTML document has been fully rendered. In this case it runs the showMap function which has the instructions to create the Google Map. Note: Don’t forget to load the JQuery like so.

<script type=”text/javascript” src=”js/jquery.min.js”>

STEP 5

var latlng = new google.maps.LatLng(6.43616,3.41647 );

Inside the showMap function, the first step in creating a Map is to declare the latitude and longitude coordinates of the location, in this case, the city of Lagos Nigeria. The latlng of the location (Lagos) has already been got through a process known as Geocoding. Google Maps comes with that feature but I won’t talk about it since it is beyond the scope of this blog. If one doesn’t know what latitude and longitude are then you might want to get a geography lesson or better still google it.

Steps 6.

var myOptions = {

zoom: 12,

center: latlng,

mapTypeControlOptions: {

style: google.maps.MapTypeControlStyle.DROPDOWN_MENU

},

mapTypeId: google.maps.MapTypeId.ROADMAP

};

Step 7

var map = new google.maps.Map(document.getElementById(“zamap”), myOptions);

Takes the initialization settingstored in the myOptions variable, and id of the div which we get the reference of via the document.getElementById method and loads the MAP on the div.

<div id=”zamap” ></div>

Remember the DIV acts a placeholder for the Google Map.

The Options variable holds the Map initialization variables like the “zoom”. “Center” indicates the actual location from the latlng coordinates. “mapTypeId” here is initialized as “RoadMap”., there are other options like terrain , satellite, hybrid. “MapTypeControlOptions “shows the MapType options as a dropdown menu if one wishes to conserve space.

Behold The Map!

Figure 1 showing the Google Map

If you can see the image above then congratulations, for creating your first Google map.

Right now the Map does not look like much. It just shows Lagos. We will now proceed to adding a marker to indicate exactly where we are in Lagos.

//adding a marker

var marker = new google.maps.Marker({

position:latlng,

map: map,

title: “I am here!”

});

The piece code displays the marker on the map by setting the position to the latlng coordinates and the map to the map variable and we will create a title for the marker.

One can change the marker icon. That I will illustrate in the sample app so stay tuned.

Hover your mouse above the marker to see the title.

So see the marker below:

Figure 2 showing a marker

Now I promised a hello world example and not a “I am here” so we will take the tutorial a notch up by display an Infowindow with the Famous words.

//add an infowindow

var infocontentDiv = ‘<div id=”content”>’+

‘Hello World!’+

‘</div>’;

var infowindow = new google.maps.InfoWindow({

content: infocontentDiv

});

//event listener to open the infowindow on click

google.maps.event.addListener(marker, ‘click’, function() {

infowindow.open(map,marker);

});

The variable infocontentwindow holds the content we would like to display.

google.maps.InfoWindow creates an Infowindow and uses the infocontentwindow as its content.

Since we want the infowindow to open when the marker is clicked on, we add the event listener to the marker.

Click on the marker and VOILA! The infowindow pops up with the”Hello world” message.

Figure 3 Showing the “Hello World” Infowindow

Now I will illustrate the following Google Maps capability such as detecting user location, populating several locations on a single map using a sample project as a case study. This application will be called “Ezenna Group of Companies”. Legend has it that Ezenna as a typical Igbo man, had so many businesses scattered all over the world. Since they were so many, he forgot the whereabouts of some of them. Fortunately for him, he met an I.T consultant who advised him (at a huge cost) to get a directory of all his businesses so they will easy to find. I won’t tell you who the consultant was; I am sure by now you have a pretty good idea.

To make everything simple, the data of Ezenna’s business will be stored in xml instead of a RDBMS.

See below at a snippet of the xml

<STORE id=”1″>

<NAME>YouLike Clothes</NAME>

<DESCRIPTION>Best collection of designer clothes and accessories. Cool Perfumes, watches in stock.</DESCRIPTION>

<TYPE>Boutique</TYPE>

<LOGO>clothes.png</LOGO>

<LOCATION>

<Address>No 12 Aba Road, Port-Harcourt</Address>

<CITY>Rivers</CITY>

<COORDINATES>

<LAT>4.83573</LAT>

<LONG>7.03035</LONG>

</COORDINATES>

</LOCATION>

</STORE>

It contains attributes describing store such as name, description, location and so on. We shall employ JQuery to load and manipulate our XML data to show all the locations on the map. So enough talking, let’s see some code.

$(document).ready(function () {

// showmap();

$.ajax({

type:”GET”,

url:”stores.xml”,

datatype:”xml”,

success:showEzennaStoresOnTheMap

});

});

We use the ajax to asynchronously fetch the xml data.

To loop through the data, we use find method to get all the <STORE> tags and iterates through and initializes the Store properties leike name,description and so on.

$(xml).find(“STORE”).each(function(){


var id=$(this).attr(‘id’);

var name=$(this).find(‘NAME’).text();

var description=$(this).find(‘DESCRIPTION’).text();

var type=$(this).find(‘TYPE’).text();

var lat=$(this).find(‘LAT’).text();

var
long=$(this).find(‘LONG’).text();


We create the Map the usual way then add the

var bounds = new google.maps.LatLngBounds();

// Extending the bounds object with each LatLng

bounds.extend(new google.maps.LatLng(lat,long));

// Adjusting the map to new bounding box

map.fitBounds(bounds);


The bounds object adjusts the map so that the different markers fit inside the bounds being passed to it.

var marker = new google.maps.Marker({

position: new google.maps.LatLng(lat,long),

map: map,

title: name

});

The title of the marker is set to the name property of the <STORE> tag.

Figure 4 showing all of Ezenna’s stores

The Ezenna’s stores are shown on the map but there seems to be different the type of stores on the map.
So we change the marker code to reflect the marker image we’ve got.

var zapic=$(this).find(‘LOGO’).text();


imageloch=”images/”+zapic;

recycleh = new google.maps.MarkerImage(imageloch);

// Adding the markers

var marker = new google.maps.Marker({

position: new google.maps.LatLng(lat,long),

map: map,

icon: recycleh,

title: name

});

Figure 5 Showing different set of Marker Images

The icons can be downloaded here from this URL. http://code.google.com/p/google-maps-icons/

Meanwhile, the rest of the Store properties are set on the InfoWindow. As shown below with Zoom In and Zoom out link configured on it.

var infocontent=document.createElement(‘div’);

var title=document.createElement(‘strong’);

title.innerHTML =name;

var descriptionlink = document.createElement(‘p’);

descriptionlink.innerHTML=description;

var breakr = document.createElement(‘br’);

var plink = document.createElement(‘p’);

var websitelink = document.createElement(‘a’);

websitelink.innerHTML = ‘Website’;

websitelink.href = “http://www.theveryplace.com”;

websitelink.target=”_blank”;

var a = document.createElement(‘a’);

a.innerHTML = ‘ Zoom In’;

a.href = ‘#’;

// Adding a click event to the link that performs

// the zoom in, and cancels its default action

a.onclick = function() {

// Setting the center of the map to the same as the clicked marker

map.setCenter(marker.getPosition());

// Setting the zoom level to 15

map.setZoom(15);

// Canceling the default action

return
false;

};

var zoomout = document.createElement(‘a’);

zoomout.innerHTML = ‘ Zoom Out’;

zoomout.href = ‘#’;

// Adding a click event to the link that performs

// the zoom in, and cancels its default action

zoomout.onclick = function() {

// Setting the center of the map to the same as the clicked marker

map.setCenter(marker.getPosition());

// Setting the zoom level to 15

map.setZoom(5);

// Canceling the default action

return
false;

};

// Appending the link to the second paragraph element

plink.appendChild(websitelink);

plink.appendChild(a);

plink.appendChild(zoomout);

// Appending the two paragraphs to the content container

infocontent.appendChild(title);

infocontent.appendChild(descriptionlink);

infocontent.appendChild(breakr);

infocontent.appendChild(descriptionlink);

infocontent.appendChild(plink);

// Setting the content of the InfoWindow


infowindoww.setContent(infocontent);

This piece of code set the zoom level as the bounds are increased .

var listener = google.maps.event.addListener(map, “idle”, function() {

if (map.getZoom() > 16) map.setZoom(16);

google.maps.event.removeListener(listener);

});

Figure 6: showing the infowindows.

If we click on ZOOM IN .We get to see what is shown in the picture below.

User Location detection

Detecting a visitor’s location to one’s website is useful feature and has many applications in fraud management for example if the user’s credit card address is far from the location at which transaction is being carried out would be an indication of high risk transcation. Also one can get useful analytics to the demographics of one’s website visitors.

To detect user’s location, one can use gears, browser based geolocation or Ip based geolocation. Ip based geolocation is the least accurate.

To use gears, one needs to add the script tag to the header of the web page

<script type=“text/javascript”

src=“http://code.google.com/apis/gears/gears_init.js”>

</script>

For IP-based

One could use The Google API for

// Getting the position

if (google.loader.ClientLocation.latitude && google.loader.ClientLocation.longitude) {

// Defining the position

var latLng = new google.maps.LatLng(google.loader.ClientLocation.latitude,

google.loader.ClientLocation.longitude);

From my experience, I found out that Google’s client location though is bit more accurate than other offerings but in the case of Nigeria, it returns null on most IP addresses so I decided to switch to a different ip-based geolocation provider.

I assume they depend on your Google Key for something because it is one of the parameters needed.

You can get it here http://www.maxmind.com/app/geolitecity

<script type=“text/javascript” src=“http://ip-geo.appspot.com/geo_data.js?key=ABQIAAAAB1D5xVb4mI8xxT8KFKKwzRSErSB8v-HR33wr-yJFmv6d0Y_MuhTMyw2HB3rb_IKp1nyiWRjlYETbtA”>

</script>

Either way, IP-based geolocation is not very accurate. Actually, they are the least accurate as seen it the picture below which shows my location as Ikeja while I am on the Lagos Island.

Some smart mobile phones have GPS which provide very accurate location. Also GSM cell sites use triangulation to determine one’s position.

The Geolocation API specification is found at www.w3.org/TR/geolocation-API/.

To use the standard browser based geolocation API download the geo.js file which is the W3C standard. Please note that Internet explorer does NOT support this.

if (geo_position_js.init()){

geo_position_js.getCurrentPosition(setPosition, handleError,{enableHighAccuracy:false,options:6000});

}

To get around any of the hiccups associated with the lack of I.E support, Google Gears becomes a good alternative. Although, one of the problems of gears is that it is not ubiquitous. User geolocation with Gears is quite accurate as in shown in the picture. As at the time of writing this blog , I was at Lagos Island and voila , Gears shows me on the Island exactly.


To include Gears add this to the header of your webpage

<script type=”text/javascript”

src=”http://code.google.com/apis/gears/gears_init.js”>

</script>

Then the following option to your control flow.

if (google.gears) {

UseGears();

}

function UseGears() {

browserSupportFlag = true;

var geo = google.gears.factory.create(‘beta.geolocation’);

geo.getCurrentPosition(function(position) {

longir=position.longitude;

latituder=position.latitude;

}

If you are concerned about privacy issue concerning auto detection of your location, don’ be since you will have to accent to any of it.


Therefore as a rule of the thumb one should use Ip.based Geo-coding as a fall-back and either Gears or the W3C standard as the first options as shown in the sample code.


Next Steps

So we have learnt how to detect user location, transverse through xml data with JQuery, show multiple locations on a map. Some nice features I left out are getting driving directions to any of the Ezenna stores and proximity detection i.e. showing the user, the nearest Ezeani Store to the user’s location. You may want to look at see below for a working example of calculating distance between two coordinates [1]

For example, Murtala Mohammed Airport Coordinates are

Latitude= 6.57722, Longitude 3.32111

Great Circle Distance Formula using radians:

3963.0 * arccos[sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 – lon1)]

If you do NOT first convert the latitude and longitude values in the database to radians, you must include the degrees-to-radians conversion in the calculation. Substituting degrees for radians, the formula becomes:

Great Circle Distance Formula using decimal degrees:

3963.0 * arccos[sin(lat1/57.2958) * sin(lat2/57.2958) + cos(lat1/57.2958) * cos(lat2/57.2958) * cos(lon2/57.2958 -lon1/57.2958)]

OR

r * acos[sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 – lon1)]

Where r is the radius of the earth in whatever units you desire.
r=3437.74677 (nautical miles)
r=6378.7 (kilometers)
r=3963.0 (statute miles)

One can see all these concepts on display on this website –

http://www.theveryplace.com/

Get the source code for the example
here

References

1. Wikipedia http://en.wikipedia.org/wiki/Great-circle_distance

2. Google Maps Api http://code.google.com/apis/maps/documentation/javascript/

3. Developer Guide http://code.google.com/apis/maps/documentation/javascript/basics.html

4. http://code.google.com/apis/maps/documentation/javascript/overlays.html

5. Beginning Google Map API 3, Gabriel (Svennerberg, 2010)

6. W3C, www.w3.org/TR/geolocation-API/.

http://www.meridianworlddata.com/Distance-Calculation.asp

Why Should I Use Google Big Table or any non relational database for that matter?

One of the very first things that comes to a web developer’s mind when faced with the option of developing an application on
Google App Engine is the fact that the database is non relational and also that you cannot instantly do “Joins” on your data!
At first glance this seems like a major bottle neck but then it all begins to make sense once you get one thing straight and that is :
Non-relational databases (Google Big Table, CouchDb, Mongo etc) are not nessecarily a one size fits all replacement for relational Databases (e.g. My SQL, Oracle, SQL Server) .
They each have situations to which they are best suited and once you have understood that, life becomes a whole lot easier.
Having said that, there are developers who have sworn to stick to one side of the divide (relational or none relational ) and as such have done everything within their power to adapt their applications to their databases of choice.
So the big question is: When is it best to use a non-relational database like BigTable ?
Well…the answer varies depending on who you talk to, but some digging around the web yielded the following answers:

  • Your data is stored and retrieved mainly by primary key, without complex joins.
  • You have a non-trivial amount of data, and want to avoid the pains of RDMS management such as Replication etc
  • Your data mirrors a real life document or log/audit trail (e.g. a ticket, a receipt or even an invoice) whose contents will not change once it has been created and/or is used in an “append-only” mode

Another possible reason is if you have a strong suspicion that your database will NOT age gracefully (see http://push.cx/2009/rules-of-database-app-aging )
Putting the above scenarios together could result in the following picture:
You have to build an application that underneath is very simple in structure, but will potentially handle a lot of data with high traffic and you want to be able to retrieve data from this application using a primary key and/or also some key words/tags (a many to many relationship). Such an application is a good candidate for a database such as BigTable.

Of course like was said earlier a lot of developers have over the years found ingenious ways to use non-relational databases to achieve a lot of the things that are currently being done with relational databases today.
Also suffice to say that Google has unleashed App Engine for Business and in the second quarter of this year this will support hosted SQL databases. This initiative will make it easier for business to migrate their business applications and databases to the Google Cloud.

http://code.google.com/appengine/business/

http://code.google.com/appengine/business/roadmap.html

It would be interesting to hear from you about situations where you have considered moving from a relational database to a non-relational database and vice versa.
Here are some articles that should make interesting reading:

http://www.metabrew.com/article/anti-rdbms-a-list-of-distributed-key-value-stores

http://blog.boxedice.com/2009/07/25/choosing-a-non-relational-database-why-we-migrated-from-mysql-to-mongodb/

What could the Microsoft – Nokia Collabo mean for Android?

If you have not been living on the cyber moon and if you have not been so bogged down by work or play that you did not have time to scan the web (which is the same thing as saying that you have been living on the cyber moon), then i am sure you have heard about the recently announced partnership between Nokia and Microsoft.
If you have not heard or read about it , you can quickly bring yourself up to speed by reading the announcement from Microsoft’s site.
In case you do not want to read through the whole thing, here are the highlights:
Nokia and Microsoft are engaging in a partnership such that:

” 1.) Nokia would adopt Windows Phone as its principal Smartphone strategy, innovating on top of the platform in areas such as imaging, where Nokia is a market leader.

2.) Nokia would help drive the future of Windows Phone. Nokia would contribute its expertise on hardware design, language support, and help bring Windows Phone to a larger range of price points, market segments and geographies.
3) Nokia and Microsoft would closely collaborate on joint marketing initiatives and a shared development roadmap to align on the future evolution of mobile products.
4.) Bing would power Nokia’s search services across Nokia devices and services, giving customers access to Bing’s next generation search capabilities. Microsoft adCenter would provide search advertising services on Nokia’s line of devices and services.
5.) Nokia Maps would be a core part of Microsoft’s mapping services. For example, Maps would be integrated with Microsoft’s Bing search engine and adCenter advertising platform to form a unique local search and advertising experience
6.) Nokia’s extensive operator billing agreements would make it easier for consumers to purchase Nokia Windows Phone services in countries where credit-card use is low.
7.) Microsoft development tools would be used to create applications to run on Nokia Windows Phones, allowing developers to easily leverage the ecosystem’s global reach.
8.) Nokia’s content and application store would be integrated with Microsoft Marketplace for a more compelling consumer experience.”

Most of the commentary i have seen online touts this as Nokia’s reaction to the threat of the IPhone. However it was after reading this article that another angle became a bit evident (thanks Tunde for the Facebook post!)
The main gist of this article is that with this move a lot of Symbian developers will be left without a platform in the coming years and as such the developers will be left with a number of options:

A.) Migrate with Nokia to Windows (How many pure blooded Symbian developers will do this is anybody’s guess)
B.) Migrate to IPhone (An attractive choice as this platform has probably the biggest appstore around)
C.) Migrate to Android (An upcoming platform, but perhaps the most open of all the options
D.)Migrate to BlackBerry another platform of choice
E.) Give it all up and start maintaining blogs like this one (That’s what I would choose:-D)

So what’s the point of this little piece?
The thing is that with so many mobile platform developers pondering their future over the next 6 months, the battle for their souls will soon start in earnest and it is just possible of all the options, Android being the most open of them might be the most attractive. Of course this depends on how Google chooses to play the game and also on what the android community does to welcome in these developers from the cold.
Only time will tell…..
We are watching.

Lagos GTUG holds open house at University of Lagos



The Lagos Google Technology Group held its first open house at the Centre for Information Technology in the University of Lagos.This event was basically a forum that allowed those of us who are interested in Google technology to have some face time with Googlers and hear from them first hand in a semi formal environment.There were a total of 5 Googlers on hand and a total of more than 30 attendees which was pretty impressive considering that it was a work day.The event was fun filled and interactive with everyone eager to join and contribute.


The event kicked off with a talk from Ben, a project manager with Google who walked us through the Google corporate philosophy (the famous “Ten things).
Next we had Ayite ( a Google Engineer) take us through the fundamentals of Google App Engine.

To round up the talks Bridgette (Google Program manager for West Africa) took us through a number of tools that we could use to maximize on our innovations, these included the likes of:

After this came the most interesting part of the evening…when the floor was thrown open for questions and they came flooding in.They included questions like:

  • Why are PHP and Ruby not supported on Google App Engine?
  • Does Google have an equivalent of YQL (for Yahoo)?
  • What is the Google software development lifecycle like?
  • Does Google App Engine have any tool that makes it easy to build RESTful web services?

and much much more,

The discussion became even more passionate when we discussed what the challenges that preventing developers in this part of the world from maximizing and monetizing their innovations.
The event closed with some light refreshments after about 2 hours of intense interaction.
Many many thanks to Bridgette, Lanre, Ben, Ayite, Fiona for making it a wonderful event.

Watch this space for more info on Google activities around here starting with one in Unilag within the next one month and of course the BIG ONE!!!G-Nigeria in May 2011!

Google Web Dev Spoon Feed (A fresher’s experience)

SYNOPSIS
When I got a buzz on my Facebook message asking for volunteers to get the Lagos GTUG’s (Google Technology User Group) website running, I felt that it would be an opportunity for me to horn my interest in Web development by watching the “masters” do their thing and get to learn new tools, but that didn’t hold true because I got an approval with a condition that I spearhead the project. What?!

Eventually, we were able to register our site, design and apply various feels using the Googleweb development environment with a basic WYSIWYG interface for creating and editing pages and, believe me, it was easier than I thought.

When you hear “Google” what comes to mind is search engine! But Google has come a long way to provide services beyond just search engines, emails and contact information  management to actually help you create and develop your own world directly on the web with unlimited, likewise, controlled access to supplied information files, ranging from video, images, books, applications and more.

Anyway, here we are with a functioning site that is not only dynamic and simple but also easy to implement and deploy all by yourself! All you need to get cracking is a Google username and password (just like you have your Yahoo login name and password) voila! You are good to go.

Basic tools: A functioning internet service, your hands and interest!

INTRODUCTION Google Web Creator is a free Google service that allows you to create a website using an online web creation wizard together with an online What-You-See-Is-What-You-Get (WYSIWYG) web editor. The pages are published and hosted on Google’s web servers free of charge.

GETTING STARTED It’s fairly easy to get started. If you don’t have a Google Gmail account, you’ll have to sign up for one. With that same account name and password, you will be able to log into the Google Page Creator. You should choose your Google Gmail account name carefully, however, before you start, because whatever name you select for that Google webpage will wind up as part of your URL e.g.  Given that your sites name is deespetproject, then your sites url will be https://sites.google.com/site/deespetproject/.

 DESIGNING AND MANAGING YOUR SITE WITH GOOGLE PAGE CREATOR

SITE CONTENT PANE
Recent Site Activity: This helps to display the various activities that had been performed on certain web pages by listing the time, date and the name of the user who made the changes.

Pages: From here, you can view the various web pages that have been created.

Attachment: Fresh files like images and other documents can be uploadviewdownload,rename, replace and remove from here.

Templates: This page handles the standard templates of the site and you can includedisable,enable and remove any of your templates from here.

SITE SETTING
General Setting: From the site setting page, changes can be made to site name (title of the site), site description and matured content display option, landing page, statistic (analytics), site display languages and other actions.

Sharing: From this page, you can release access to your site by defining roles. I.e. you can specify people you would like to have access to the site and also place restrictions on them. Note that contacts can be selected from your Google account directly from this page.
Monetise Pane: This provides Adsense (AdSense ads) tool that you can place on your site for monetary gain. How? It enables you to earn money by placing targeted text and image ads on your site.

Google automatically chooses which ads to show based on your sites’ content and users and you earn money when visitors view or click on these. It is advisable not to enable this tool until you are sure of what you would like to achieve with it because “all that glitters…”

Web Address: This page displays your current web address and new web address can also be included to the site from here.

SITE APPEARANCE
Web Templates and Web Layouts: It is fairly easy to get started on a website with Google’s web design offering. You can select a design from a variety of web templates and standard layouts and make changes to the size of the columns for proper definition on the page.
You can also change the arrangement of your menu item either by adding more menus or changing the position.
Changing the Appearance of Your Text (Colors & Fonts): From the site Manager page, you can make changes to the colors and font of various areas on the site, e.g. background, sidebar gadget, content area and the navigation gadget area.
Theme: Google was able to provide numerous themes that you can choose from to make your site attractive with well defined colors and feel. You can preview each of the themes before applying your desired choice directly from this page.

OTHER FUNCTIONALITIES
Adding Images, Cropping, and Resizing: Included in the web page builder is the facility to insert images from either another website or from your computer. I was able to upload .jpg images using the image picker tool which also has the ability to move, crop, resize, and even change contrast and brightness of the image as desired by you.

Inserting Links: The web page wizard allows you to insert links to other websites. There is also a simple-to-use facility to link to pages that you have created within the Page Creator system, as well as to files you have already uploaded. If you are creating a link to a new page on your site, you will not have to mess about with getting the filename correct. The web editor handles this behind the scenes for you.

HTML TITLE Tag: When your page is created, Page Creator automatically forms your

Gadgets, Extensions and Web Apps: The interface also allows you to add gadgets and other Google functional tools to your website, such as a calendar, Google search box, etc. This may or may not appeal to you, depending on the purpose of your website, but it is right at your disposal.

Publishing Your Site: Publishing your website is as simple as clicking a button that says “Publish”. That’s it. You don’t have to mess around with FTP settings (the stumbling block for many newbie’s) or finding a web host (Google Pages is your host).

Online Web Builder Freezes: You might (like I have) experience some unresponsive downtime and the only way out might be to quit and re-login again or to go to “My Account” and re-enter the editor. Until this bug is fixed, or even when it is fixed, I would advise that you save your work regularly.

Service Uptime and Responsiveness seems good.

In Conclusion  Google Web Creator looks very promising. It has a simple, uncluttered interface that makes it easy for newcomers to quickly get their website published. Users can easily benefit from the selection of web templates and standard layouts to easily create their site. The developers appear to have put in some thought into the utility of the editor for the new webmaster, automating things that normally confuse them, such as automatically creating a TITLE tag from the user’s own title for the page. Other aspects of the service also show the same consideration given to usability – for example it is easy to add a link to another page and create the page that it links to without having to worry about filenames. The web builder automatically takes care of building the correct link to the page.

All in all, I would say that this free web service is useful for a novice who wants to create a simple website for fun, a group of students who want to handle their projects online, small entrepreneurs as well as professionals willing to maximize the various tools that Google has got to offer and also develop on it. It provides most of the rudimentary facilities for creating and publishing a website, and for the most part, makes the process simple. Among its benefits, it is possible to add other functionalities to one’s site like we were able to do on LagosGTUG site with the addition of an Event Calendar and the Blog tab. Winky!