Thinking in GIS

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

Feed, Categories, Archives


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

Geometry creation with GeoTools 2 (Java): merge shapefile polygons on a common attribute (polygon geoprocessing)

Posted: June 30, 2006
Categories: devs, GeoTools, Java, GIS
Feedback: View Comments

Here I post a sample Java class I developed some months ago, working with geometry creation in GeoTools 2. This class, given an input Shapefile, will elaborate an output shapefile merging the input polygons on a common field.Geotools is an open source (LGPL) Java code library which provides standards compliant methods for the manipulation of geospatial data, for example to implement Geographic Information Systems (GIS). The Geotools library implements Open Geospatial Consortium (OGC) specifications as they are developed, in close collaboration with the GeoAPI and GeoWidgets projects. The capabilities of Geotools are presented in the feature list./* * Created on...
Read the full post

« Previous Page