Thinking in GIS

a blog about GIS from a urban geogeek living at the countryside

Feed, Categories, Archives


Do you get errors in the mapscript c# tutorial?...

Posted: February 29, 2008
Categories: GIS, Windows, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

...well, this is the solution to your problems (at least I hope so).I am continuing receiving emails from people in despair that cannot successfully use this tutorial. I am sorry but I cannot answer to all this emails, so I thought to write this post in order to allow people to configure it correctly.BTW, this demo is still working since 2 years without any problems, and the code there is just the same you can download from this blog. So it must work also for you ;-)So if you just cannot use it, this is a check list:If you receive...
Read the full post

Writing the Domain Model classes: coding time (Castle MonoRail and ActiveRecord Tutorial - Part 5)

Posted: September 13, 2007
Categories: devs, Tutorials, .NET, CastleProject
Feedback: View Comments

This is the fifth post of a series started with this post about a MonoRail and ActiveRecord tutorial.With this post we will finally start to write code for our MonoRail and ActiveRecord tutorial. Here we will go on writing the model classes, and from them we will autogenerate the database schema (alternatively you could first create the database schema and then generate the classes using the generator).We need to write 5 classes for our 5 models (Album, AlbumGenre, Artist, Genre, Support). As we discussed the convention is to place them under the Models folder of our CastleProject solution.So let's create...
Read the full post

Writing the Domain Model classes: implementing Relationships (Castle MonoRail and ActiveRecord Tutorial - Part 4)

Posted: August 30, 2007
Categories: devs, Tutorials, .NET, CastleProject
Feedback: View Comments

This is the fourth post of a series started with this post about a MonoRail and ActiveRecord tutorial.Last time we wrote the Album class and we have seen how to implement the primary key mapping and simple properties mapping.With simple properties mapping I mean the class properties that will go to map simple data type in the database. Instead with complex properties I will mean the class properties that will go to map a relationship with another table in the database.For the album class there are simple properties (ID, Name and Year) and complex properties (Support, Artists and Genres).The simple...
Read the full post

Writing the Domain Model classes: implementing Identifiers and Properties (Castle MonoRail and ActiveRecord Tutorial - Part 3)

Posted: July 10, 2007
Categories: devs, .NET, CastleProject
Feedback: View Comments

This is the third post of a series started with this post about a MonoRail and ActiveRecord tutorial.There are several approaches for writing the domain model classes for a MonoRail and ActiveRecord application:Create the domain model classes from a generator, providing a database schemaCreate the domain model classes from scratchConsequently, if you have chosen to create the domain model classes from scratch, after you have created the domain model classes you can auto-generate the database schema.If instead you have already the database schema, you could opt for the first point (and maybe retouch them after the generation).For the aims of...
Read the full post

MonoRail and ActiveRecord configuration (Castle MonoRail and ActiveRecord Tutorial - Part 2)

Posted: May 27, 2007
Categories: devs, Tutorials, .NET, OOAD, CastleProject
Feedback: View Comments

This is the second post of a serie started with this post about a MonoRail and ActiveRecord tutorial.Let's start developing our sample application. The first thing we need to do is to create a .NET project configured for using the CastleProject stuff. You can go in two ways:Create a Visual Studio project with the MonoRail project wizard.The wizard will create for you the MonoRail project structure, generate the configuration elements in the web.config file and add all the necessary references to the project. You will be prompted to choose a view engine (NVelocity, Brail or ASP .Net Web Forms), if...
Read the full post

Castle MonoRail and ActiveRecord Tutorial (Part 1)

Posted: May 22, 2007
Categories: devs, Tutorials, .NET, CastleProject
Feedback: View Comments

In the last 2-3 years there were a lot of talking about agile and high-productivity development with an outstanding framework that is already in the legend, like happened to Java in the late 90s: Ruby on Rails.Given its success, many other project in the Open Source community were born trying to reproduce the beauty of the Ruby on Rails rapid and agile development framework for other environments. Just to name a few: Turbogears for Python and Grails for Java.The main features of these rapid development framework generally are:Convention over configuration PatternMVC PatternInversion of Control Containers and the Dependency Injection PatternAn...
Read the full post

Cuyahoga: "Hello World" sample module tutorial

Posted: April 30, 2007
Categories: Cuyahoga, .NET, devs, OOAD, Tutorials, CMS
Feedback: View Comments

Cuyahoga is an impressive Open Source web site framework (and CMS) with many impressive features like:RDMBS indipendency via NhibernateEnterprise architecturePlug-in architectureDeployable, using Mono, to platforms different from Windows, like Linux, Mac OS X, Solaris, unlike other popular .NET CMSSearch engine based on dotLuceneFull ASP .NET 2.0 enginelogging system via log4net (the same logging engine in zigGIS)People willing to deeply dig in Cuyahoga may download the latest release (1.5.0) source code and this basic tutorial for developing Cuyahoga modules.The problem with this tutorial is that is a bit out of date (is based on VS 2003 and on a old release...
Read the full post

PostGis WorkspaceFactory

Posted: February 21, 2007
Categories: GIS, .NET, ArcObjects, devs, PostGIS, ArcGis Desktop, ZigGis, COM
Feedback: View Comments

In my previous post I have showed you how to install and using zigGIS for adding PostGIS data into ArcMap.From the ArcMap user interface you just need to press the zigGIS button and an "Add PostGIS data" dialog will be shown to you. From there you can set a zig File path, where PostGIS connections settings are stored, and then a PostGIS layers list will be shown and you can check which layer(s) add to the map.In this post I will show how to programmatically use zigGIS and ArcObjects to add PostGIS data into ArcMap.zigGIS is a Microsoft .NET 2.0...
Read the full post

Installing zigGIS 1.1 for connecting ArcMap to PostGIS layers

Posted: February 14, 2007
Categories: GIS, .NET, ArcObjects, devs, PostGIS, ArcGis Desktop, ZigGis, COM
Feedback: View Comments

zigGIS is an Open Source PostGIS connector for ArcGIS Desktop, that enables ArcMap to add PostGIS layers in the map.Differently from other kinds of connectors, like for example PgArc, the very nice feature of zigGIS is the direct-read of PostGIS data, without the needs of proxy shapefiles. This meaning that the PostGIS features are directly readed and displayed in ArcMap from the PostGIS data source without a previous conversion to a Shapefile or personal GDB.This is a very interesting project, but still in a very early phase, in fact there are still important issues that are planned to be solved...
Read the full post

Full OSS solution vs OSS/commercial solution mix

Posted: January 19, 2007
Categories: Java, .NET, ArcObjects, devs, PostGIS, GIS, ZigGis, CMS
Feedback: View Comments

I wanted to leave a comment in this Bill Dollin's post, but after that it came out to my mind to leave a trackback to it, and going with a my own post on this subject as far as I have several things to discuss about.In the OSS jungle, it looks there are in the last times more and more solutions and projects based on commercial closed-code software. For example zigGIS, the Open Source ArcGIS connector for PostGIS, in which I am involved, is by itself an OS project tied to proprietary frameworks (Microsoft and Esri). This is many times...
Read the full post

Running and debugging unit tests with NUnit and Visual Studio

Posted: January 05, 2007
Categories: GIS, .NET, ArcObjects, devs, OOAD, Unit Test
Feedback: View Comments

For .NET developers a very usefull and free framework for unit testing is NUnit, that is a .NET implementation of the popular JUnit for Java.I am using this for unit testing zigGIS, the Open Source ArcGis Desktop connector for PostGIS in which I am currently involved.I will show you in this post how easy and powerfull is to create, run and debug unit test for a .NET library or application.After installing NUnit, you can add a reference to it in your VS solution. After doing so you are ready to implement one or more classes (fixtures) for performing unit tests.moreIn...
Read the full post

COM ArcObject passed to .NET library: how to cast, access and debug it

Posted: January 04, 2007
Categories: GIS, .NET, ArcObjects, devs, ArcGis Desktop, COM
Feedback: View Comments

Generally when developing your .NET ArcObjects library you are managing all .NET objects, because the ArcObjects are wrapped by the RCW, Runtime Callable Wrapper (preferably created by Esri, using the Primary Interoperability Assemblies, PIA, installed with ArcGIS desktop in the GAC).You can then expose your .NET library to COM by a CCW, COM callable wrapper, creating a tlb with regasm (automatically done using Visual Studio if you check the 'Register for COM interop' option, under the Build tag of project's property dialog).Using the RCW ArcObjects we are always using Managed code, so we don't get in troubles.But what if a...
Read the full post

MapFlashViewer Framework: ASP .NET Implementation (C#)

Posted: October 27, 2006
Categories: devs, MapServer, .NET, GIS, ArcIMS
Feedback: View Comments

It is very easy to get started with the MapFlashViewer Framework in the ASP .NET Implementation (C#) I talked about in this post. This implementation was written using ActiveX Connector for ArcIMS 9.0 and C# MapScript for MapServer 4.10.0. You can easily adapt the code for previous or next versions.Open the solutionYou will find several files in the C# ASP .NET project included with the solution you downloaded:A simple default.aspx web form with the MapControl user control over itA form test.aspx for debugging purpose (you don’t need unleass you are in troubles)the Controller (responsable for translating request/response to the...
Read the full post

MapFlashViewer Framework

Posted: October 26, 2006
Categories: devs, MapServer, .NET, GIS, ArcIMS
Feedback: View Comments

MapFlashViewer Framework is a simple Flash viewer for several (even any, if someone intends to write an implementation) internet map server (at the moment I wrote an implementation for Esri ArcIMS and MapServer).You can view a working demo of MapFlashViewer for Esri ArcIMS here and the same working demo (with same data) for MapServer here.Why using Flash?It has always been a pain writing web user interface for web mapping. The most common approach is to write javascript client code to perform the main GIS actions (zooming, panning, etc etc).There is also some example of Java applet GIS web interface, but...
Read the full post

MapServer Tutorial for C# mapscript (ASP .NET)

Posted: September 20, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials, Uncategorized
Feedback: View Comments

This tutorial will try to guide you step by step in implementing a GIS (Geographic Information Systems) web solution, based on Open Source software (MapServer), within the .NET Framework.The tutorial is designed to work with Visual Studio 2003 and .NET 1.1, but you will easily be able to perform all the necessary steps to complete it using another version of Visual Studio (ie: Visual Studio 2005) or other IDEs (like Visual Web Developer 2005 Express Edition or even the notepad). It will work also using .NET 2 as c# mapscript is .NET 2 compatible.The tutorial is focused to people with...
Read the full post

Adapting C# code to work indifferently with shapefile or PostGIS layers (c# mapscript tutorial, part 8)

Posted: September 14, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

In this section we will adapt the ASP .Net Tutorial to work both with shapefiles or with PostGIS layers.The only c# code that needs to be modified is only the code that updates the point layer.The tutorial is composed of basically 2 methods that update a point layer:the first method adds a point and its attributes to the point layer (AddPoint method)the second method delete all the points from the point layer (butClear_Click)After you will terminate this step the tutorial will work both with shapefiles and PostGIS layers.Adding a reference to PostgreSQL .NET dll to the Visual Studio solutionYou will...
Read the full post

Connection MapFile layer to PostGIS (c# mapscript tutorial, part 7)

Posted: August 01, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

First I am going to show the difference between connecting the MapFile to a Shapefile layer and to a PostGIS layer, then I will show how to adapt your MapFile to work with PostGIS.Shapefile ConnectionHere is a sample connection from MapFile to a shapefile called "compfun".First you need to declare the path to the shape data (SHAPEPATH).Then for each shapefile layer you have to set the shapefile's data source (DATA) that is the name of the shapefile.Here the shapefile is named compfun.shp so DATA is set to "compfun".Note that NAME can be anything, it means how in your MapFile want...
Read the full post

Migrating shapefiles to PostGIS (c# mapscript tutorial, part 6)

Posted: July 27, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

What is PostGISPostGIS is an extension for PostgreSQL RDBMS that spatially enables it for storing GIS content.It could be considered something similiar to Esri ArcSDE or Oracle Spatial.In fact PostGIS is for PostgreSQL what is Esri ArcSDE for Oracle, MS SQL Server, Informix, DB2.PostGIS is OGC compliant and is Open Source, released under the GNU General Public License.For more info about PostGIS you can take a look here.PostGIS InstallationFirst, if it is not on your RDBMS Server, you have to download and install PostgreSQL. Refer to the PostgreSQL's Web Site for doing so.After you have succesfully installed PostgreSQL, you...
Read the full post

Implementing the C# mapscript code (c# mapscript tutorial, part 5)

Posted: July 26, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

Add reference to mapscriptAdd the reference to mapscript_csharp.dll (browse to the mapscrip installation folder, for example C:ms4wApachecgi-binmapscriptcsharp):{{:MapServer:tutorial:add_reference.jpg|:mapserver:tutorial:add_reference.jpg}}Remember that if you didn't set PATH environment variable to the MapServer dlls you will need to manually copy them under the bin folder of this ASP .NET application.moreThe c# code for Default.aspx pageThis is the complete code to add for the Default.aspx page:using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Data.OleDb; //for dbf connectionusing System.IO; //for copying the point shapefilenamespace TutorialMapServer{ /// /// User Interface for c# MapServer Tutorial ///...
Read the full post

Designing the tutorial user interface (c# mapscript tutorial, part 4)

Posted: July 26, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

Create an ASP .NET C# ProjectOpen Visual Studio, create a new ASP .NET C# Project called TutorialMapServer:Insert application key value in web.configOpen web.config and add the following appSettings section under configuration section:<configuration> <appSettings> <!-- Path to MapFile --> <add key="mapFilePath" value = " C:\training\mapServerTutorial\data\csharptutorial.map" /> </appSettings> <!-- ........ --></configuration>For the key mapFilePath be sure to put the right path to the map file (also a relative path is valid).Create the main web formAdd a WebForm called...
Read the full post

Creating the MapFile and data configuration (c# mapscript tutorial, part 3)

Posted: July 03, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

Creating the MapFileFor what is a MapFile and a reference about it you can view the MapFile Reference at MapServer web site. Here you can download the data, map file and fonts needed for this tutorial. Extract data.zip wherever you think in your hard disk, for example at c:trainingmapserverTutorialdata. Open the map file named csharp_tutorial.map: MAPNAME "Zone Samples"SHAPEPATH "C:\training\mapServerTutorial\data"SIZE 400 400STATUS ONEXTENT 1143759 4417539 1146436 4420390UNITS METERS FONTSET "fonts\fonts.list" WEB IMAGEPATH "C:\Inetpub\wwwroot\temp" IMAGEURL "C:\Inetpub\wwwroot\temp"ENDSYMBOL NAME "circle" TYPE ellipse FILLED true POINTS 1 1 ENDENDLAYER NAME "compfun" TYPE...
Read the full post

Installing MapServer (c# mapscript tutorial, part 2)

Posted: July 03, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

Download MapServerDownload precompiled binaries here. For the purpose of this tutorial is indifferent if you download the MS4W for PHP4 or PHP5. (As an alternative you could download an installation toolkit like this and compile yourself MapServer, but it is more difficult).InstallationAll you need to do is to extract the zip file, for example at: C:ms4w.Here we will not mention how to install cgi MapServer, because we are using the other modality (MapScript).After doing that take a look at the structures of the directories created under C:ms4w. All the references we need in our C# ASP .NET (or Windows) application...
Read the full post

Introduction to MapServer Web GIS development environment (c# mapscript tutorial, part 1)

Posted: July 02, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials
Feedback: View Comments

What is MapServer?According to MapServer official site:MapServer is an Open Source development environment for building spatially-enabled internet applications. MapServer is not a full-featured GIS system, nor does it aspire to be. Instead, MapServer excels at rendering spatial data (maps, images, and vector data) for the web.MapServer was originally developed by the University of Minnesota (UMN) ForNet project in cooperation with NASA and the Minnesota Department of Natural Resources (MNDNR). Presently, the MapServer project is hosted by the TerraSIP project, a NASA sponsored project between the UMN and consortium of land management interests.The software is maintained by a growing number of...
Read the full post

MapScript C# Tutorial - Programming MapServer in the ASP .NET Framework

Posted: July 01, 2006
Categories: GIS, .NET, PostGIS, devs, MapServer, Tutorials, Uncategorized
Feedback: View Comments

In the next stops I will write a tutorial about programming MapServer with .NET c#.This tutorial will try to guide you step by step in implementing a GIS (Geographic Information Systems) web solution, based on Open Source software (MapServer and PostGIS), within the .NET Framework.How to download the tutorialThe tutorial's data needed to complete this tutorial are downloadable here. In any case the tutorial is made in a way that you can easily adapt to use your own data (shapefiles).Here you can find a complete working Visual Studio 2003 solution (ASP .NET 1.1) with the whole tutorial's solution. moreTake...
Read the full post