Click here to Skip to main content
Email Password   helpLost your password?

Introduction

GisMap is a .NET component for building GIS and CAM/CAD application. It's a part of MVisionTech VisiWorks data visualization framework. GisMap uses Canvas for drawing geometrical shapes and GDAL project for handling different geographical vector and raster formats.

Maps are essential to locate objects distributed over wide areas. There are many kinds of applications that require geographical presentation of data, such as trip organizers, assets management systems, fleet management, GPS tracking and many others. All these types of system constitute the GIS or Geographical Information System.

A 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 a GIS system represent the different layers in the map. Some layers represent different functional objects such as roads, counties and cities, while others represent different resolutions of the same functional layer such as hi-ways, main roads and all roads. Satellite images and aerial photography are frequently used in combination with other geometrical objects. There are different sources of geographical data, GIS system vendors use different file formats to store data in their system. Some major players in the GIS market are ESRI, MapInfo and Oracle.

GisMap uses the open source library called GDAL (Geographical Data Abstraction Layer) to access different sources of geographical data. GDAL supports most of the raster formats (images) and main vector formats via its OGR library. It also provides classes for geographical coordinate system transformation.

Geographical coordinate system is another story, there are a number of different systems, and some of them are very exotic. The reason is that the Earth is a sphere (well almost) and people like to use square coordinates when they measure things. So for measurements they use the projection of various parts of the sphere on the plane. Then these different projections originated from different places, depending on the state, country or continent is measured.

The most popular coordinate systems are WGS-84 (spherical coordinate system with longitude and latitude) and UTM a system of 60 cylindrical projections of WGS-84.

The picture above shows USA's main roads with aerial image somewhere in Texas. When the user zooms in and out the map, GisMap gets the proper image size and resolution from TerraService web services and displays the vector data from the locally stored shape files. Vector data is organized in layers, where each layer corresponds to different map resolutions. GisMap has two different views of the same geographical data, one for navigation and another for browsing. Two views are synchronized; the small blue rectangle on the navigation view shows the location of the second view.

The layer control can be used to adjust the order and visibility of different layers. For every layer the user can specify the minimum and maximum scale to switch from course view to detailed one.

GisMap has a DataGrid showing the attributes of geographical objects in the map, when the map is in "find" mode and an object has been selected GisMap brings a record related to the selected shape.

Using the code

The main purpose of having a 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);

Design

GisMap uses the Canvas component for creating graphics and GDAL data abstraction to access geographical data. For aerial photography, it uses Microsoft's TerraServise, a thing of beauty. It covers the whole of 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 the main classes of GisMap component. It uses the Canvas control and its geometrical model (GeomModel) to display maps and GDAL classes to deal with GIS data, coordinate systems and transformations.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralMy vote of 1
hm7921936
18:41 7 Oct '09  
Download source files - 473 Kb
can not debug
so many erroer in Visio Studio 2008
GeneralGDAL exception with raster images
Thabet Tech
7:00 16 Jun '09  
Hi
I used a simple code from this tutorial as the following

Canvas canvasNavi = new Canvas();

GisSelector gisSelector = new GisSelector();


OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "GeoTiff Files(*.geotif)|*.tif";
openFileDialog1.ShowDialog();
string im_fname = openFileDialog1.FileName;
if (im_fname == "")
return;



GeomModel.CanvasLayer lay1 = canvasNavi.getGeomModel().layerByName("geo_image");
if (lay1 == null)
lay1 = new GeomModel.CanvasLayer("geo_image", Color.BlueViolet, 0, true);

GDalGIS.GdalImageCanvasItem geo_im = new GdalImageCanvasItem(im_fname, lay1);



It runs correctly but,when I choose raster image I get the following exception at the last line when I call GdalImageCanvasItem

FileNotFoundexception was unhandled
Message="The specified module could not be found. (Exception from HRESULT: 0x8007007E)."


I added all references from your attachment(Demo project)
GeneralArial Photograph...
mbaocha
22:59 3 May '09  
That is an arial photograph. Can it be used to edit scatched maps?


_________________________________________________________________________________
Digital Map Nigeria | Street Level Map of Lagos Abuja Nigeria
RantAdvice...
Max_Longshaft
12:45 15 Jun '08  
I'd make sure your product buids before you publish it and if it requires specifics to get it to work, let people know what they are. Seriously - this is the most contrived solution I've ever come across and after much faffing round, I've come to the conclusion that it's probably to do with GDAL's project not building properly and not your app. After looking on their shocking website, I'm none the wiser. We programmers get a bad name for making the industry appear a black art. GDAL is the epitomy of this and the developers need to sort themselves and their product documentation out.

When I build your project, Geometry is swiss cheese. Get loads of unresolved externs that foobar the app. Tried building geometry separetly, but nothing doing. Tried copying the dll's to Debug. Ditto. The other components have multiple issues too.

Summary - GDAL sucks.Mad
Generalproblems in Visual Studio 2005
davjer
13:27 30 Aug '07  
hello
¿as I compile of visual Studio .net 2005?


very thanks

I am is programer
c++, j++

GeneralShowing locations on the map
sylvesterg
4:13 20 Mar '07  
Hi,


I have the following maps in hand

Country map - India map

States map - All the states inside the country.

I am developing a tourist website. My requirements are as follows

1. I want to show the destinations on the map - Like all the hill
stations on the country and its highlighted may be in small dots with hill
names

2. I want to show the state maps when user selects from the country.
Inside the state user will have the tourist destinations thats also to be highlighted.

3. when the user selects the destination, user will have the details about
the destinations and the hotels available in the particular destination.


Will it possible to do this programmatically through x,y coordinates as I am having the images of country and states,

or I have to go the other way?

what is the right way to do this requirement. Please suggest.

Thanks



Regards,
Sylvester G
sylvester_g_m@yahoo.com

GeneralCould not generate GDAL.DLL
benhchen
12:30 1 Feb '06  
SmileFailed to generate GDAL.DLL due to compiling error of missing header file.
Followed your instruction to use MS VS6 and GDAL120, it came to python22 and I downloaded it from web and compiled it again and this time it gave me "unistd.h" missing.

I don't know how many dependency files will pop-up.

If you could, tell me where I could access 2 DLL files (GdalImage, Geometry) ?
so that I could continue to build the rest C# projects.

Thanks, Ben (benhchen@comcast.net)

GeneralMissing "gdal-priv.h"
benhchen
6:05 27 Jan '06  
Eduard,

After I downloaded the "Painter-src" and tried to build the "GdalImage", I got missing file error message "gdal-priv.h". Where I can get this file so that I could continue build the rest C# projects.





Thanks, Ben
(bchen@efw.com)
GeneralRe: Missing "gdal-priv.h"
Eduard Baranovsky
5:46 30 Jan '06  
Hi Ben,

I'm sorry for inconvinience, this package depends on GDAL library which I didn't include in the build.

You can download it at http://www.gdal.org/dl/gdal120.zip.

I think you should build it with VC6:
nmake -f makefile.vc
and then install it:
nmake -f makefile.vc devinstall
which by default creates: c:\GdalBuild folder with all headers and libraries my package is looking for.

In the next version I will include GDAL (now version 1.3.1) as a part of GisMap distribution.

Thanks,
Eduard.



Generallicense of source code
mpaul42
7:50 21 Nov '05  
Hi,

I would like to use some of your code published within your article, especifically the wrapper libs to GDAL. But I have not found any license or file header comments regarding this issue.:(
Do you want me to mark everything as a derived work and put a URL to the original article, or all the other round "do whatever you want, but do not mention my name." Unsure
Btw: very good stuff, much faster than the official SWIG bindings to GDAL

Best Regards,

Michael Paul
GeneralRe: license of source code
Eduard Baranovsky
6:28 23 Nov '05  
Hi Michael,

I released it under GPL license, however if you need GDAL bindings only (GDalGIS and GdalImage) you can use it as LGPL (then your derived project does not have to be open source).
In next release release of GisMap I changed DllImport calls for GDAL binding to managed C++ wrapers, but I left the same interface and it does not effect performance.
I will appreciate if you put some reference to the article in your derived project but it's up to you.

Thanks for using my code,
Eduard.
GeneralRe: license of source code
John Cardinal
6:59 7 Nov '07  
Eduard Baranovsky wrote:
I released it under GPL license,


Wow, that kills it for a lot of us. That's a shame, it looked interesting but I can look no further. Sorry to hear that.


More people died from worry than ever bled to death. - RAH



GeneralI wasn't aware...
Andy_CAnfield
14:40 31 Oct '05  
I wasn't aware that GDAL/OGR had C# bindings. Did you do the C# bindings yourself? If not where do I get them at or are they in the regular cvs with all the other source and I just haven't noticed it?
GeneralRe: I wasn't aware...
Eduard Baranovsky
3:55 1 Nov '05  
I did it myself.
For some of the functions I used .NET System.Runtime.InteropServices library (see GDalGIS namespace in GisMap source code) and for others I used managed C++ (see GdalImage namespace).
GeneralCool stuff!!!
Paul Voicu
11:47 31 Oct '05  
Cool stuff Ed! I would be curious, like everybody else of course, to see the content of the links that are currently brokenFrown
I'll check it later to see if the links are working.

GeneralRe: Cool stuff!!!
Eduard Baranovsky
4:28 1 Nov '05  
Thanks Paul,
I did it because you did't like MapObjects very much Smile.
I fixed links to my website, it has some other projects I'm working on.

GeneralHelping new users
SteveAbbott
23:32 30 Oct '05  
Your work seems to be amazing, but it's a bit tricky for new users to test out.
1 In the binary download it would be helpful if you could include a .wsc example as I couldn't even begin to see how I could get any GIS data into the program (though no doubt it's obvious when you know how).
2 As I wanted to see your individual elements in the context of a working whole I loaded VisiWorks.sln. There are a couple of problems. The first is messages about the code being under 'source control'. I'm sure there's a standard way to tell the solution to forget about this, but I can't remember what it is. The second is that on compilation there are a zillion error messages about GDalGis and GDalimage namespaces not being found. I assume that I can fix this by looking around for various dlls and ocxs but it would be helpful if there were some 'ReadMe' to help folk like me.

It is, of course, not your fault that I'm having problems. You must have been working on this powerful suite of tools for ages and you are completely familiar with all their interactions. It's when people encounter them nervously for the first time that they need lots of help.

I look forward to trying out your amazing work.

Many thanks





Steve Abbott
GeneralRe: Helping new users
Eduard Baranovsky
5:24 31 Oct '05  
Thank you Steve for your appreciation of my humble work.

I'm terribly sorry for inconvinience caused by broken links in the source code and Visual Source Safe errors. I'm going to fix it as soon as I can.
I will also provide some explanations to the source to make it more friendly to use.
Although it looks like I spent ages on development of these tools I did not, it's just a beginning and more is to come.

Thanks again,
Eduard.
GeneralRe: Helping new users
Eduard Baranovsky
17:57 31 Oct '05  
Steve,
I fixed sources so you can download it now,
I added readme file as initial manual for the project.

Eduard.
GeneralRe: Helping new users
SteveAbbott
22:37 31 Oct '05  
I'm afraid that I'm still confused. If I click on VisWorks.sln I still get the message that it's under source control (I can fix this by editing the .sln so this isn't a real problem) but I still don't see what I have to do in order to use the key controls:
1. CanvasControl - generic 2D graphics presentaion and drawing component.
2. GisControl (includes GisMap) - GIS layers selector and map view controls.
3. WorkSpace - layout manager, creates placeholders for visualization controls
4. VisiBlocks - adapters around visualization controls for connection with layout manager.

If I go to the original sub-projects I find, for example, that GisControl offers to create Geometry.dll and if I open CanvasControl.csproj it also offers to create Geometry .dll. etc. If I try to compile any of them I get various problems. I don't see why VisWorks.sln doesn't compile everything and create the correct .dll links.

I'm sure this is my ignorance about how these complex projects fit together, but usually I don't have a problem creating a bunch of .dlls and making references to them. Where am I going wrong?

One other detail - the downloads near the top don't have the correct file sizes. The Bin is quite large, for example.

Sorry to sound negative when you've created something so marvellous!


Steve
GeneralRe: Helping new users
Eduard Baranovsky
4:41 2 Nov '05  
Steve,
I tried to download sources and see what problems you have.

1. It complains on VSS missing stuff. You can press OK on error box and it will work eventually.
2. Building problems. Some how I did not have any. There are 8 projects in VisiWorks solutions: one executable VisiWorksApp (should be start up project) and 7 dlls it depends on. When you build solution VS should handle all dependencies and compile dlls in right order.
3. The only problem that I found, when you run application there are 2 external dlls missing: gdal12.dll and proj.dll. You can get it from binary zip and drop it to ...\WINDOWS\SYSTEM32\ or ...\VisiWorks\VisiDataWs\bin\Debug

Code compiled with VisualStudio .NET 2003 and .NET framework 1.1.
I tested it on Windows XP and 2000.

If you still have problems, please let me know.
Eduard.
GeneralRe: Helping new users
simondeanm
15:52 1 Dec '05  
Eduard,

I am having trouble compiling this as well. The output says I am missing a reference to gdal_priv.h

Output is as follows.

GdalImage.cpp(8) : fatal error C1083: Cannot open include file: 'gdal_priv.h': No such file or directory

Am I missing a library? I have followed the instructions from the previous threads.

Simon
GeneralRe: Helping new users
Eduard Baranovsky
4:36 5 Dec '05  
Sorry about it Simon,
I missed this points compleely.
This package depends on GDAL library version 1.2.0.
You can download it at http://www.gdal.org/dl/gdal120.zip.
I think you should build it with VC6:
nmake -f makefile.vc
and then install it:
nmake -f makefile.vc devinstall
which by default creates: c:\GdalBuild folder with all headers and libraries my package is looking for.
In the next version I will include GDAL (now version 1.3.1) as a part of GisMap distribution.
If you have problems with building GDAL let me know I'll build it for you and put on my web site.

Thanks,
Eduard.
QuestionRe: Helping new users
windrzej
4:17 20 Dec '05  
when i call
m_spatial_src_ref = new GDalGIS.SpatialReference();
I always have null reference, could anybody tell me why ?



AnswerRe: Helping new users
windrzej
1:02 22 Dec '05  
I wrote a new application in vc6.0 using only gdal.lib and everythig works fine Smile


Last Updated 30 Oct 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010