web butcher

Sharing my knowledge to persuade you to share yours

articles

Archive for the ‘articles’ Category

Garmin GPS in Brazil with TrackSource

Tuesday, January 12th, 2010

Leia este artigo em português.

This post explains how to obtain a complete map of Brazil for Garmin GPS. If you are planning to travel to Brazil and you plan to bring your Garmin GPS, this post is probably useful. In my opinion Garmin is the best GPS option anywhere in the world, but Brazilian maps are not very complete. Just a few points of interest exist. For example, at Belo horizonte (my city) I cannot find most banks or malls, etc.

Fortunately there’s a project called Projeto TrackSource (site in Portuguese only). This project is a community that provides complete maps for Brazil. It contains gas stations, banks, supermarkets, movie theaters and anything else you can imagine. With TrackSource your Garmin GPS turns into a very complete and much more useful tool than that with original maps. Leaving my home for example there’s a dead end street. With the original maps it always says me to get this street as if I had a flying car. After installing TrackSource this part of street is not there anymore as expected.

I would like to encourage folks that are using TrackSource to give a donation. After testing of course :). The project is totally free and there’s a link in the main page to give a donation. As a contribution I gave R$ 20,00 through the link on the site, created this page and posted on twitter, stumbleupon and other applications to help spreading the project, what’s is not too much if compared to the benefits that trackSource offers. When we help a project like this we are giving a vote for the technology development of our country. Doing this, we are encouraging professionals of very high quality to provide new technologies by a fair price.

The equipment used in this example was the Garmin nüvi 205. I believe these steps are going to work with any other recent GPS equipment from Garmin.

Let’s go to the business. Remember that you must have the Garmin software installed on your computer before doing the steps. (You will have to navigate under a Portuguese page, not a big deal haha)

  1. Go to the download page (página de downloads) of the site and download TRC-Brasil clicking the button Mapsource (for windows) or Mapinstall (for Mac).
  2. Run the installation file you just downloaded: TRC-Brasil_v0912.exe.
  3. Run the program Garmin/MapSource.
  4. In the dropdown at top left select TRC-Brasil and click the icon “Map Tool” as you can see in this snapshot:mapsource1
  5. Using selection tool, select the entire Brazil map, like this:mapsource2
  6. Now plug your device and click Transfer->Send to Device. This will take sometime.
  7. When you’re done unplug the device and wait until it restarts. You’re done.

Now turn on your GPS and check things you know in Brazil, like cities or banks (Banco do Brasil) or whatever you want. You will notice the difference between original maps and TrackSource maps.

Talking About Privacy and Piracy

Sunday, May 24th, 2009

I would like to say my opinion about what’s happening nowadays. I don’t remember the last time I heard someone saying something like “I just bought a great CD from my favorite band”. Actually, my opinion is that the companies must stop trying to fight against that. We all know who is the winner in this battle. An old and smart phrase that I like is: “If you can’t win them join them”.

If you take a look at Google’s example you ask yourself: “How they’re probably the most valuable company in the world today with just 10 years of existing and having just free softwares?”. And the answer is: “Because they earn money with ads in the entire Internet, everyone knows their softwares and its quality and so big companies pay lots of money to them for great services. In less words, they know what you want to buy and they know who can sell such a thing”.

Last week I was having some beer at a bar and saw a guy giving one copy of his first album for each table and saying: “Feel free to make a copy for each one if you want”. I saw such a thing and thought myself that he’s a very smart guy. My friends who were with me listened to the CD and liked very much. Actually they will go if they know that it’s gonna be a show of this guy because they know they will enjoy. This example shows how a person can earn money in this scenario.

My opinion is that companies must follow those examples.

Well, just wanted to give my opinion and perhaps start a discussion on that. Comments are welcome. ;)

Building a portlet with Google Maps on Websphere Portal

Wednesday, April 1st, 2009

There’s a link on the right to download the project files so you can import it to your RAD and run. Import as a Project Interchange file. If your RAD is greater than 7.0 do the migration. Also if you prefer follow the steps below and understand how I did.

The Google Maps API license is free, the only important rule is: Everything you develop using Google Maps API have to be for public use in the web. They have also a limit of showings per day, it’s a big number, something like 200,000. You have to read the terms if you want to know more. Google has an excellent documentation about that. It’s under http://code.google.com/apis/maps/documentation/.

For using Google Maps API you also have to get an API Key here: http://code.google.com/apis/maps/signup.html. The key is nothing more than a hash code of your server’s address, so you have to create a key for each site you use that.

Using Google Maps under Websphere Portal is nothing so different from using anywhere else. First of all, lets create a Portlet Project.



Create now a simple Web Diagram with an initial action and a jsp page. We will use the initial action to simulate something like reading point coordinates from database. This is our Web Diagram:



The file index.jsp will tell struts to go to initial action through the welcome forward. For this, just put the following in the end of the file:

<logic:forward name="welcome"/>

I’ve created a Point Bean Obejct. So, lets create an ArrayList of some of these points and store it in the session. For that, in the initial action try block, put this:

// Read points from database here.
ArrayList points = new ArrayList();
points.add(new Point("-11.95908", "-51.855469"));
points.add(new Point("-23.816841","-45.365124"));
points.add(new Point("-27.586999","-48.423014"));
// Store them on session
request.getPortletSession().setAttribute("points", points);

Create a bean for the points. You can use this point object to store any data from the point such as a html code with the description that will be showed when the user click the point.

package googlemapshelloworld.beans;
 
public class Point {
	private String latitude;
	private String longitude;
 
	public Point(String latitude, String longitude){
		this.latitude = latitude;
		this.longitude = longitude;
	}
 
	public String getLatitude() {
		return latitude;
	}
 
	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
 
	public String getLongitude() {
		return longitude;
	}
 
	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
 
}

The first time I used Maps in Portal I had a strange issue. In ie I got a gray screen over my map and I couldn´t see the entire map:



After doing some research I found that`s because ie has an issue about png transparency, something that Google Maps API makes use of. After navigating for a while, I found this: http://jquery.andreaseberhard.de/pngFix/

Download the pngFix.zip file and include the files on a js folder within your WebContent folder. Also load these files in your map.jsp file.

Project Explorer

<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery.pngFix.js"></script>
 
<script type="text/javascript"> 
    $(document).ready(function(){ 
        $(document).pngFix(); 
    }); 
</script>

Also include the js for Maps API and create a div tag with the size you want with the id=”map”.

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=[YOUR KEY HERE]" type="text/javascript"></script>
 
<script type="text/javascript">
setTimeout("loadMap()",1000);
 
var map;
function loadMap(){
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(-11.959, -51.8554), 4);
		map.setUIToDefault();
		loadPoints();
	}
}
 
//Function loadPoints goes here.
 
</script>
 
<div id="map" style="height:500px; width:500px"></div>

Let`s create a method to plot the points in the map. It sort of print javascript code with jsp:

function loadPoints(){ <%
	out.print("\nvar point;\nvar marker;");
	ArrayList points = (ArrayList) session.getAttribute("points");
	for (int i=0; i<points.size(); i++){
		out.println("		point = new GLatLng(" + ((Point)points.get(i)).getLatitude() + ", " + ((Point)points.get(i)).getLongitude() + ");");
		out.println("		marker = createMarker(point, 'We are here!');");
		out.println("		map.addOverlay(marker);");
	} %>
}
 
function createMarker(point, html){
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() { 
		marker.openInfoWindowHtml(html);
	});
	return marker;
}

Done.

WebSphere Portal 6 with RAD 7 Installation

Friday, March 20th, 2009

Installing WebSphere Portal can be very simple, you just have to remember some details.

In my example, we will need Portal Setup Disks, Rad Setup Disks, Rad Fix (7.0.0.4) and Rad Activation Kit (license).

Open the first cd from Portal installation and run install.bat there.



In the three initial screens, just click Next, Accept and Next again. Just select Typical installation and proceed.

In the next screen, choose your directory installation, it`s recommended that you create an IBM directory and put everything on it. In my case, I`ve chosen C:\IBM\WebSphere\AppServer. It will install Application Server.



Proceed clicking Next until you come to this screen. Here you can use your preferred names.



In the next screen, choose the administrative user and password, by default, I use “wpsadmin” for user and password.



Don’t install the Business Process Support, we will not need that.



Now, let’s install the WebSphere Portal Server. It’s recommended that you put it in the same IBM directory, like that: C:\IBM\WebSphere\PortalServer



In the next screen, you will be asked for administrative user and password for Portal, it’s recommended that you use the same that you used on Application Server.



Now, you have the option of using server as a Windows service, it’s not recommended, don’t mark nothing here. Click Next again and wait, it will start installing and will take long time.



In the end, unmark “Launch First Steps” and click Finish. Your WebSphere Application Server and WebSphere Portal Server are now installed.



Let’s now install Rational Application Developer 7 (RAD). At first, install the installation manager. Go to the radfix4 folder and run install on im.installer.win32-1.1.0 folder, it will be installed the IBM Installation Manager 1.1.



Run the Installation Manager now. Go to file/preferences and click repositories/add repositories. Locate the file diskTag.inf on disk 1 of RAD Installation to add the repository. Now go to “Install Packages”. Don’t forget changing the directories to your IBM directory.

(C:\IBM\SDP70Shared):



(C:\IBM\SDP70):



Keep going until you see the screen below. You must mark the options “Portal Tools” and “Struts Tools” here. Click Next, Install and go on.



Now, we must install the Rad fixes. Go to the installation manager in your Windows start menu. Go to file/preferences and click repositories/add repositories. Find the diskTag.inf on the radfix4 dir disk1.

It’s recommended that, in this step, you disconnected your internet to avoid Installation Manager to look for sources on the web.



Click OK. Click Update Packages and go on. Your RAD will be update to version 7.0.0.4.

We are almost done. Now, install the License. On the Installation Manager, click “Manage Licenses”, “Import Product Activation Kit”. Find the file RADLic.jar on your RAD Activation Kit directory.



Now, you have all done. You can now open your RAD by the Windows start menu. To add Websphere Portal control inside your RAD, go to Servers Tab, right-click, then click New Server. Select “Websphere Portal Server V6.0 Server”. Click Next.



Use the password you’ve created at Portal installation. Click Finish. Now you’re ready to develop struts portlets using your RAD and WebSphere Portal. Any questions, feel free to post. No login necessary.