Home > Android, Maps, Programming > MapApp1 : Theory you need to know

MapApp1 : Theory you need to know

Welcome to the second part of my tutorial on how to create a map app for Android without using Google™ APIs :).

Series outline:

______________________________________

In this part I’ll give simple information about maps and some terms and how they are used, hopefully saving you some time of searching.

Since I’m not a geography expert, please note that some information here might not be accurate, corrections are welcome 🙂 after all I’m just a programmer who learned what he needs to accomplish his goal.

I’ll provide additional links for further reading at the end of this post.

Earth shape : although the earth isn’t a perfect sphere, some map systems treat it as a sphere, I guess that’s okay for everyday use.

Map projection : from Wikipedia: “A map projection is any method of representing the surface of a sphere or other three-dimensional body on a plane. Map projections are necessary for creating maps. All map projections distort the surface in some fashion. Depending on the purpose of the map, some distortions are acceptable and others are not; therefore different map projections exist in order to preserve some properties of the sphere-like body at the expense of other properties. There is no limit to the number of possible map projections.”

the projection used in Google Maps, Bing Maps, OpenStreetMap is a derivation of the Mercator Projection.

Mercator Projection : A cylindrical projection, the earth is projected into a cylinder

The Mercator projection

The Mercator projection is a cylindrical projection

this projection distorts the scale and area (the more you get close to the poles) but what’s good about this projection is:

  1. Since it’s cylindrical, north and south are always straight up and down, west and east always goes from left to right.
  2. It’s conformal, which means it preserves the angles locally, so relatively small objects still preserve their shapes (buildings for example).

Geographic coordinates : to represent any point on earth we need a coordinate system, A common choice of coordinates is latitude, longitude and elevation (or altitude), latitude and longitude lines make a grid covering the map

LonLat Grid

Longitude, Latitude grid

The vertical lines in the image above are the longitude lines, while the horizontal lines are the latitude lines, so to change your longitude you move west or east, to change your latitude you move north or south, remember this ;).

As you can see in the image, near the poles the distance between a latitude line and the next one increases, in other words the latitude lines aren’t linearly distributed, that will cause us some headaches later :(.

WGS84 : from Wikipedia “Latitude and longitude values can be based on different geodetic systems or datums, the most common being WGS 84, a global datum used by all GPS equipment.”

The longitude ranges from -180 (West) to +180 (East) degrees, while latitude ranges from +90 (North) to -90 (South) degrees, Maps are are usually clipped near the poles , in Bing Maps the latitude ranges from -85.05112878 to 85.05112878 this makes the map square and prevents singularity at the poles (Sorry penguins, no maps for you :().

Tile System : okay, we have our giant square map, how do you manipulate different zoom levels?

well, usually the map isn’t stored as a single image file (we’re using pre-renderd maps here), it’s actually stored as tiles, at the zoom level zero, the whole world is a single square image (usually 256*256), if we zoom to level 1 we get four equal tiles, and so on for each tile in each zoom level, it’s more like a quad tree where each node (tile) has four children (4 tiles).

So at zoom level 10, the world is made up of 4^10 tiles, that’s 1,048,576 tiles :O, 17,179,869,184 tiles at zoom level 17, so if you where thinking like “I’m gonna download the whole world map”… think again ;).

Anyway, usually all tiles have the same dimensions.

Tile System

To the left: zoom level 0
In the middle : zoom level 1
To the right : zoom level 2

Different indexing approaches exist, one of them is to give each tile x,y and z values, where the most top left tile of each zoom level has an index of x=0, y=0.

Z (obviously) means the zoom level this tile belongs to, we’ll get to these details later.

______________________________________

The next part of the tutorial will be short I guess, just a class diagram with some explanation.

If you have any questions about this tutorial or you have something to add please use comments :).

Further Reading:

Map projection:

  1. Map projection – Wikipedia
  2. Mercator Projection – Wikipedia
  3. Mercator Projection – Mathworld Wolfram

Tile System:

  1. Tiles à la Google Maps: Coordinates, Tile Bounds and Projection (much info & links)
  2. Bing maps tile system (also contains C# code for different calculations).
Advertisements
Categories: Android, Maps, Programming Tags: , ,
  1. jaggy
    07/04/2014 at 11:01 am

    hello sir,i want to create a map which consist of lat,long,heading,bearing and waypoint.to navigate a ship.i am marriner and i want to deveop it by my own,please help me to develop this project.using eclipse.i am very new beginner for this
    in advance for helping me

  2. jaggy
    07/04/2014 at 11:02 am

    in addvance thank you

  1. 12/03/2012 at 8:18 am
  2. 11/06/2012 at 3:16 am

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: