Feb
29
Do you get errors in the mapscript c# tutorial?…
Filed Under GIS, MapServer, PostGIS, devs, .NET, Tutorials, MapServer Tutorial for C# mapscript (ASP .NET), Windows | 6 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 the "Unable to load dll (mapscript)" error, look at this article from Tamas Szekeres (the mapscript c# mantainer).
Sep
13
Writing the Domain Model classes: coding time (Castle MonoRail and ActiveRecord Tutorial - Part 5)
Filed Under devs, .NET, CastleProject, Tutorials, Castle MonoRail and ActiveRecord Tutorial | 4 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 these 5 classes.
Aug
30
Writing the Domain Model classes: implementing Relationships (Castle MonoRail and ActiveRecord Tutorial - Part 4)
Filed Under devs, .NET, CastleProject, Tutorials, Castle MonoRail and ActiveRecord Tutorial | 2 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 properties are mapped to standard data types: ID (primary key) to int, Name to string, Year to Int16.
The complex properties are mapped to object types: Support to Support Object, Artists to an IList of Artist Object and Genres to an IList of Genre objects.
Now to go on with the tutorial we should continue writing the other classes (otherwise Album class will not compile), but in this part I first want to show you how to implement relationships in your class.
For a complete introduction to relationship mapping in ActiveRecord you can look here. In this tutorial we will use the most important relationship mapping kinds: BelongsTo, HasAndBelongsToMany (simple and with an attribute).
Jul
10
Writing the Domain Model classes: implementing Identifiers and Properties (Castle MonoRail and ActiveRecord Tutorial - Part 3)
Filed Under devs, .NET, CastleProject, Castle MonoRail and ActiveRecord Tutorial | Leave a Comment
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 schema
- Create the domain model classes from scratch
Consequently, 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 this tutorial, we will first write the domain model classes and then auto-generate the database schema.
These are the domain model classes: copy and paste them under the model folder (once again this is a convention, you can add them in a different place):
May
27
MonoRail and ActiveRecord configuration (Castle MonoRail and ActiveRecord Tutorial - Part 2)
Filed Under devs, .NET, OOAD, CastleProject, Tutorials, Castle MonoRail and ActiveRecord Tutorial | 1 Comment
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 to enable the Windsor inversion of control, and if you wish to create a test project for TDD (Test Driven Development).
For the purpose of this tutorial choose NVelocity, not enable Windsor and create the TDD test project. You can look at the procedure here. - If you are using another IDE than Visual Studio, or if you want to manually configure the environment, you can look at the manual procedure in the same link of the first point.
The references that will be added are:
- Castle.MonoRail.Framework.dll: The MonoRail framework, that implements for the project the MVC Pattern
- Castle.MonoRail.Framework.Views.NVelocity.dll: The view engine we have chosen
- Castle.Components.Binder.dll: The binder implementation
- Castle.Components.Common.EmailSender.dll: The email service contracts
- Castle.Components.Common.EmailSender.SmtpEmailSender.dll: The email service implementation
- Castle.Core.dll: Core functionalities shared by Castle Projects
- NVelocity.dll: The template engine
May
22
Castle MonoRail and ActiveRecord Tutorial (Part 1)
Filed Under devs, .NET, CastleProject, Tutorials, Castle MonoRail and ActiveRecord Tutorial | 9 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 Pattern
- MVC Pattern
- Inversion of Control Containers and the Dependency Injection Pattern
- An Object Relational Mapper (ORM) for the data layer management
- Code skeleton generators
I have seen many .NET developers migrating to Ruby on Rails or to others high productivity frameworks, not knowing that also for .NET (and Mono) there is already an outstanding framework for this purpose: the CastleProject.
Even if for this framework there is still not a first stable release (the main components are actually at Release Candidate 2), it offers already an excellent solution for agile and rapid development for the .NET world.
Apr
30
Cuyahoga: "Hello World" sample module tutorial
Filed Under devs, .NET, OOAD, CMS, Cuyahoga, Tutorials, Cuyahoga Tutorial | 6 Comments
Cuyahoga is an impressive open source web site framework (and CMS) with many impressive features like:
- RDMBS indipendency via NHibernate
- Enterprise architecture
- Plug-in architecture
- Deployable, using Mono, to platforms different from Windows, like Linux, Mac OS X, Solaris, unlike other popular .NET CMS
- Search engine based on DotLucene
- Full ASP .NET 2.0 engine
- logging 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 of Cuyahoga) so I thought to make this post to update the tutorial to VS 2005 and to the current stable release of Cuyahoga.
Here I am assuming that you are using VS 2005 IDE and Cuyahoga 1.5.0. You can of course use other IDEs without problems, but my post is concerned about using VS 2005.
We will create a very simple module, just showing the classic "Hello World" text. In my next posts I will write a longer tutorial with data management.
Sep
20
MapServer Tutorial for C# mapscript (ASP .NET)
Filed Under GIS, MapServer, PostGIS, devs, .NET, Tutorials, MapServer Tutorial for C# mapscript (ASP .NET) | 71 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 knowledge of C# (but can be easily implemented with .NET Visual Basic) and the .NET framework, and with some background in GIS. If you are new to GIS, a good place to start is here.
This tutorial could be easily adapted for other languages and frameworks rather than C# (or VB) and Microsoft .NET Framewok. In fact the Open Source component we are going to use (MapServer) is also available for PHP, Java and Python, and other languages.
The whole tutorial is downloadable at this address, where you can find the data (shapefiles) necessary to complete the tutorial (but you can easily adapt your data), and a complete working Visual Studio 2003 solution with this tutorial's code.
You can take a look at a working online demo of this tutorial here.
As we will implement a C# ASP .NET Application, take care about this issue (that should be solved in the future): MapServer thread safety and about plans to solve this issue.
Index of Tutorial
Introduction
1. Introduction to MapServer Web GIS development environment
2. Installing MapServer
3. Creating the MapFile and data configuration
4. Designing the tutorial user interface
5. Implementing the C# mapscript code
6. Migrating shapefiles to PostGIS
7. Connection MapFile layer to PostGIS
8. Adapting C# code to work indifferently with shapefile or PostGIS layers
And if the tutorial is not working for you (you get compilation errors, maps are not displayed, editing is not working…), please take a look here
Sep
14
Adapting C# code to work indifferently with shapefile or PostGIS layers (c# mapscript tutorial, part 8)
Filed Under GIS, MapServer, PostGIS, devs, .NET, Tutorials, MapServer Tutorial for C# mapscript (ASP .NET) | 10 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.
Aug
1
Connection MapFile layer to PostGIS (c# mapscript tutorial, part 7)
Filed Under GIS, MapServer, PostGIS, devs, .NET, Tutorials, MapServer Tutorial for C# mapscript (ASP .NET) | 9 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 Connection
Here 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 to call the shapefile layer.