Online Book Reader

Home Category

Mapping With Drupal - Alan Palazzolo [10]

By Root 314 0

-74.01329346663975,

40.74552522927475,0

-74.01417775693378,

40.70205660546712,0

-73.97852222542525,

40.70941144929174,0

-73.97336836375017,

40.72746020668423,0

-73.97442958078742,

40.74197149381666,0

-73.93018494756411,

40.79937286781991,0

-73.93626079695892,

40.83462951863233,0

-73.92487861077853,

40.85468660366949,0

-73.93505410575875,

40.85845257892458,0

-74.01329346663975,

40.74552522927475,0

Raster data


The other main way of representing and storing geospatial data is in raster format. This is the idea of storing data as a continuous surface, a grid of pixels. Raster data is most often a digital image, or set of digital images; it can be satellite imagery, or it could be an image of a street map, but the pixels can represent any value. Elevation is a good example of the difference between vector and raster data; using vector format, elevation is represented with contour lines, but in raster format, it is a digital elevation model (DEM), a continuous surface with each pixel equal to the elevation averaged across the pixel (see Figure 2-7). Digital imagery provides a very efficient way of displaying a lot of data in a fast format. It is also very stable; it looks the same in any browser.

Figure 2-7. A Digital Elevation Model map of the Sierra Nevada mountain range (image from Wikipedia)

Almost all modern web mapping uses a system of tiles (images) to provide a “Slippy Map” (pioneered by Google Maps). A “Slippy Map” is an interface where a map is displayed inside a rectangle of a particular fixed size, a viewport. You can drag the map around while remaining in that viewport and the page does not need to reload to display new sections of the map. The mechanics of this interface are based on map information stored as a set of sliced-up images (map tiles). These tiles can be loaded on demand depending on which part of the map the user is viewing, and at what zoom level. A tile set can be huge; a world map supporting a typical 256×256 image size with 18 zoom levels (at which point a baseball or football stadium fills a typical laptop screen) leads to billions of tiles. Map tiles for Drupal are discussed and illustrated later in Map Tiles.

Raster tile sets are also often generated from vector data. Tile sets from map providers like Google or Bing use their database of roads and points of interest to create raster tile sets for users to put into their application. Another example is OpenStreetMap, which provides a wiki for users all over the world to add geospatial data describing the world around them to a single vector database. OpenStreetMap is actually just the vector data—the roads and paths and points of interests, all of which is released under a license for anyone to reuse. Anyone can use this data to create raster images. The OpenStreetMap organization also produces some tile sets for people to use in their applications.

Databases


Mapping applications that need to perform spatial calculations (for example to produce a map that shows all whiskey bars within one mile of my office) will use a database that stores data in a spatial format. A spatial database is optimized to store and query geographic information, so it will be faster, for instance, to measure a distance between two points, to return all points within an area or radius, or check if two areas intersect. PostGIS does this for PostgreSQL databases, and MySQL has spatial extensions available.

Currently no Drupal 7 modules support spatial databases. Instead they store geographic data in the database as text or integers (numbers). This is a good solution for a typical Drupal installation, as most mapping websites do not need the most demanding operations. This does make it difficult and cumbersome to do spatial calculations, such as finding what lines intersect, or what points or in a polygon, or what whiskey bars are close to you.

Drupal 7’s database abstraction layer makes it easier to

Return Main Page Previous Page Next Page

®Online Book Reader