Monday, September 14, 2009

South African C# programmers in the top 3

From visualstudiomagazine.com

 

...  There's another reality to be found on Google Trends. It also lists the regions, cities, and languages where a search term is most popular. Keeping in mind that language terms are most popular with beginners and those learning a new language, it's interesting to note that the top three regions for C# are India, South Africa, and Israel (the United States is No. 10), that the seven top cities are in India and China, and that the No. 1search language is Chinese. Indeed, similar region and language trends apply across every language and dev platform I checked  ...

 

Interesting!

 

Monday, September 7, 2009

MapGuide Tooltip Tool

MapGuide Tooltips

One feature in MapGuide that some people may overlook (in terms of utility) is tooltips.

They look simple enough, you use them to display certain attributes when your mouse pointer is over a feature. But what some may not realise is how these tooltips are implemented in the AJAX (or Fusion) viewer.

These tooltips are implemented in the viewer as HTML div containers. What this means is that given some knowledge of basic HTML, you can create some really cool and powerful tooltips.

Read More

This is very good and all but you must use nested concat() functions to string together the Html to display correctly in a browser.
Well I’ve created a little tool(Download here) to help convert html to the more complex concat() string used in mapguide maestro.

All you have to do is create the html is your favorite html editor and paste the result in this tool to generate the concat string. The column names must be enclosed in brackets[].
Sample:

 <strong>Customer</strong>
<div style="border:none ; padding:8px;">
Name: [CustName]<br/>
Surname: [CustSurname]<br/>
Phone: [CustContact]<br/>
E-Mail: [CustMail]
</div>

This will generate a Concat string:

Concat(' <strong>Customer</strong>
<div style="border:none ; padding:8px;">
Name: ',Concat(CustName,Concat('<br/>
Surname: ',Concat(CustSurname,Concat('<br/>
Phone: ',Concat(CustContact,Concat('<br/>
E-Mail: ',Concat(CustMail,'
</div>'))))))))

Which in turn gets pasted in mapguide maestro tooltip and generates the appropriate tooltip.

Hope it helps.

 

Monday, August 17, 2009

MapGuide and SQL Server 2008

MapGuide and SQL Server 2008

Recently Ive been struggling to get MapGuide and Sql server to work together. After posting to the forums I got a reply: http://www.mail-archive.com/mapguide-users@lists.osgeo.org/msg11760.html. Very nice and to further explain here is a quick overview of what I did:

Step 1

Import your shape files into Sql Server I’ve used Shape2Sql available from www.sharpgis.net

Step 2

Run this query in sql to remove SRID from your features

update dbo.NAN_PARCELS set GEOM.STSrid = 0; Like described here.

Step 3

In my site I’ve used the Maestro API to load and filter my layers dynamically. This is my code behind in my default.aspx page.

        //First we connect to the MapGuide server

        string username = "Anonymous";

        string password = "";

        string layout = "Library://MyFeat/Layout/Layout.WebLayout";

        String configPath = @"C:\Program Files\OSGeo\MapGuide\Web\www\webconfig.ini";

 

        MapGuideApi.MgInitializeWebTier(configPath);

 

        Uri host = new Uri("http://localhost/mapguide/mapagent/mapagent.fcgi");

        conn = new HttpServerConnection(host, username, password, "en", true);

       

        MgUserInformation userInfo = new MgUserInformation(conn.SessionID);

        MgSiteConnection siteConnection = new MgSiteConnection();

        siteConnection.Open(userInfo);

 

        //Now I get the origanal layout that I created in the Maestro Application

        //Get the original layout

        WebLayout weblayout = conn.GetWebLayout(layout);

 

        //Get the mapDefinition

        MapDefinition mapDef = conn.GetMapDefinition(weblayout.Map.ResourceId);

 

        //get the feature source

        FeatureSource feaSource = conn.GetFeatureSource("Library://MyFeat/Data/SQL.FeatureSource");

 

        //Generate a temporary feature source

        string tempFeaDef = new ResourceIdentifier("SQL1", ResourceTypes.FeatureSource, conn.SessionID);

 

        //Save the modified FeatureSource at its new temporary location

        conn.SaveResourceAs(feaSource, tempFeaDef);

       

       

        LayerDefinition layerFeatDefinition = conn.GetLayerDefinition("Library://MyFeat/Layer/Feat.LayerDefinition");

        VectorLayerDefinitionType vectorLayerFeatDefinition = layerFeatDefinition.Item as VectorLayerDefinitionType;

        vectorLayerFeatDefinition.ResourceId = tempFeaDef;

  //Now we filter on the user name

        vectorLayerFeatDefinition.Filter = "User_ID = '" + User.Identity.Name + "'";

        //Save a copy of the layer, temporary

        string tempLayerFeatDef = new ResourceIdentifier("MyFeatLayer", ResourceTypes.LayerDefiniton, conn.SessionID);

        conn.SaveResourceAs(layerFeatDefinition, tempLayerFeatDef);

       

       

        //Create a new MapLayer object

        MapLayerType Featlayer = new MapLayerType();

 

        //Absolute minimum properties

        Featlayer.Visible = true;

        Featlayer.ResourceId = tempLayerFeatDef;

 

        //Extra properties

        Featlayer.Selectable = true;

        Featlayer.ExpandInLegend = true;

        Featlayer.ShowInLegend = true;

        Featlayer.LegendLabel = "Feats";

        Featlayer.Name = "Feat";

        //Now we add these layers to the Map

        List<MapLayerType> maplayers = new List<MapLayerType>();

 

        maplayers.Insert(0, layerLande);

        maplayers.Insert(1, Featlayer);

 

        mapDef.Layers = new MapLayerTypeCollection();

        foreach (MapLayerType mlt in maplayers)

        {

            mapDef.Layers.Add(mlt);

        }

 

        MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);

        MgResourceIdentifier resId = new MgResourceIdentifier("Library://MyFeat/Data/SQL.FeatureSource");

        String schema = featureService.DescribeSchemaAsXml(resId, "");

 

        OSGeo.MapGuide.MaestroAPI.LayerDefinition ldef = conn.GetLayerDefinition(tempLayerFeatDef);

        Topology.Geometries.IEnvelope env = null;

        //To show the correct extend filter again (Very Important)

        env = ldef.GetSpatialExtent("User_ID = '" + User.Identity.Name + "'");

        mapDef.Extents.MinX = env.MinX;

        mapDef.Extents.MinY = env.MinY;

        mapDef.Extents.MaxX = env.MaxX;
        mapDef.Extents.MaxY = env.MaxY;

       

        //create a temp map

  string tempMapDef = new ResourceIdentifier("MyMap", ResourceTypes.MapDefinition, conn.SessionID);

 

        //Save the modified map at its new temporary location

        conn.SaveResourceAs(mapDef, tempMapDef);

 

        //Generate a temporary WebLayout id

        tempWebLayout = new ResourceIdentifier("MyMap", ResourceTypes.WebLayout, conn.SessionID);

 

        //Update the WebLayout to point at the modified MapDefinition

        weblayout.Map.ResourceId = tempMapDef;

 

        //Save the modified layout at its new temporary location

        conn.SaveResourceAs(weblayout, tempWebLayout);

Step 4

My main problem was finding the correct extends of the selected geometry using the layers filters, and to load it after the filter was processed otherwise all the data in my database would be loaded, and will filter after the load which will really impact the performance. Please write a comment if you know of a better way of doing this.

 

Tuesday, August 11, 2009

MapGuide Open Source





We are using MGos(MapGuide Open Source) and the .net Framework to develop our Projects.


Some info on MGos

MapGuide Open Source is a web-based platform that enables users to quickly develop and deploy web mapping applications and geospatial web services.


MapGuide features an interactive viewer that includes support for feature selection, property inspection, map tips, and operations such as buffer, select within, and measure.


MapGuide includes an XML database for managing content, and supports most popular geospatial file formats, databases, and standards.


MapGuide can be deployed on Linux or Windows, supports Apache and IIS web servers, and offers extensive PHP, .NET, Java, and JavaScript APIs for application development. MapGuide Open Source is licensed under the LGPL.


Some info on .net Framework

The .NET Framework is Microsoft's platform for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. By providing you with a comprehensive and consistent programming model and a common set of APIs, the .NET Framework helps you to build applications that work the way you want, in the programming language you prefer, across software, services, and devices.


Using these two technologies we can deliver great GIS applications.

What is GIS?

What is GIS?

Ok for you guys that’s wondering what is gis? Putting it really simple, you know those cool websites and programs showing you the world like Google earth, Microsoft Virtual Earth etc. Well that’s gis.

Gis is simply the world displayed on a computer screen, which can help us understand, interpret, question and visualize data that can reveal patterns, trends, relationships and many more.

We can analyze real-world problems more easily to name a few: A water department can manage their pipe lines, A Tourist department can produce maps for tourist paths, A fire fighting team can predict the spread of a fire using weather data. And off course you can find the shortest route to your favourite restourant using gis.

Other quotes to answer “What is GIS?” from: http://gislounge.com/what-is-gis/

“In the strictest sense, a GIS is a computer system capable of assembling, storing, manipulating, and displaying geographically referenced information, i.e. data identified according to their locations. Practitioners also regard the total GIS as including operating personnel and the data that go into the system.” USGS

A geographic information system (GIS) is a computer-based tool for mapping and analyzing things that exist and events that happen on earth. GIS technology integrates common database operations such as query and statistical analysis with the unique visualization and geographic analysis benefits offered by maps.” ESRI

“GIS is an integrated system of computer hardware, software, and trained personnel linking topographic, demographic, utility, facility, image and other resource data that is geographically referenced.” NASAGIS has already affected most of us in some way without us even realizing it. If you’ve ever using an Internet mapping program to find directions, congratulations, you’ve personally used GIS. The new supermarket chain on the corner was probably located using GIS to determine the most effective place to meet customer demand.

Introduction

It only seems fair to you my readers to introduce myself:

My name is Quintin aka Worshond and I am a GIS programmer working for a company specializing in geographic systems for farmers.
Truth to be told I started this blog to keep track of my learning as I go deeper into the exiting world of GIS.

I am a experienced .net developer specializing in c# and love challenges so if you are interested in my findings and crazy times i will likely post, keep coming back for more. Well that’s about as much info on me lets start the gis engines! O yea before I forget: Please excuse the English spelling and grammar not my best quality hehe.