|
the open source for machine vision and data visualization |
| |
Map component for bulding GIS system (GisMap)by Eduard Baranovsky IntroductionGeogrpahical map is essential to locate objects distributed over wide area. There are many kinds of application that requires geographical presentation of data, such as trip organizers, assets management systems, fleet mamagement, GPS tracking and many others. All this type of systems called GIS or Geographical Information System. Classical GIS system consists of tables with data records related to objects and geometrical shapes representing the objects such as polygons and polylines. Tables in GIS system represents different layers in the map. Some layers represents different functional objects such as roads, counties and cyties, when others represents different resolution of the same functional layer such as hi-ways, main roads and all roads. Sattelite images and aerial photography are frequintly used in combination with other geometrical objects. There are different sources of geographical data, GIS system vendors uses different file formats to store data in their system. Some major players in GIS market are ESRI, MapInfo and Oracle. GisMap uses open source library called GDAL (Geographical Data Abstraction Layer) to access different sources of geographical data. GDAL supports most of raster formats (images) and main vector formats via its OGR library. It also provides classes for geographical coordinate systems transformation. Geographical coordinate systems is another story, there are huge amount of different systems some of them are very exotic. The reason for it that Earth is a sphear (well almost) and people like to use square coordinates when they mesure things. So for mesurements they use projection of parts of the sphear to the plain, then different projections originated in different places, depending on state, country or continent needed to be mesured. The most populare coordinate systems are WGS-84 (spherical coordinate system with longitude and latitude) and UTM a system of 60 cylindric projections of WGS-84.
The picture above shows USA main roads with aerial image somewhere in Texas. When user zoom in and out the map, GisMap get proper image size and resolution from TerraService web services and display vector data from localy stored shape files. Vector data is orgonized in layers, where each layer corresponds to different map resolution. GisMap has two different views of the same geographical data, one for navigation and another for browsing. Two views are syncronized, the small blue rectangle on navigation view shows location of the second vew. Layers control can be used to ajust order and visibility of different layers. For every layers user can specify minimum and maximum scale to swith from course view to detailed one.
GisMap has data grid showing attribures of geographcial objects in the map, when the map in "find" mode and an object had been selected GisMap brings a record related to the selected shape.
Using codeThe main purpose of having Map component is using it in other applications.
// first we need a canvas to draw our maps:
Canvas canvasGIS = new Canvas();
...
// then we create an object GisSelector that binds graphical shape representation with its tabular data:
GisSelector gisSelector = new GisSelector();
gisSelector.setCanvas(canvasGIS);
...
// To open vector geographical data (ESRI shape file for example) we use GisSelector,
// openGisFile returns list of data layers availible in the file
ArrayList al = gisSelector.openGisFile(fname);
...
// To open GeoTif images or other raster formats supportes by GDAL library
// we need to create image shape object derived from CanvasItem and attach it to the canvas:
GeomModel.CanvasLayer lay1 = new GeomModel.CanvasLayer("geo_image",Color.BlueViolet,0,true);
GDalGIS.GdalImageCanvasItem geo_im = new GdalImageCanvasItem(im_fname,lay1);
canvasGIS.AddShape(geo_im);
...
// There is another image object that encapsulates TerraService aireal photography Web Services:
GeomModel.CanvasLayer lay2 = new GeomModel.CanvasLayer("terra_image",Color.BlueViolet,0,true);
TerraService.TerraServiceImage t_im = new TerraService.TerraServiceImage("http:// terraserver-usa.com/ogcmap.ashx",lay2);
this.canvasGIS.AddShape(t_im);
DesignGisMap uses Canvas component to create graphics and GDAL data abstraction to access geographcial data. For aerial photography it uses Microsoft TerraServise a thing of buity, it covers entire USA with 1m per pixel resolution. GisMap uses OpenGIS Web Map standard (OGC Web Map Server) to access the data. The class diagram below shows main classes of GisMap component. It uses Canvas conrol and its geometrical model (GeomModel) to display maps and GDAL classes to deal with GIS data, coordinate systems and transformations.
|