onsdag 26 januari 2011

PG Routing Shooting Star issue

screenshot43In a recent project I’m using PG Routing for routing with Navteq data. To route start to stop PGRouting comes with three different algorithms.

  • Djikstra – classic shortest path.
  • Shortest Path A* – using heuristics to find the shortest path.
  • Shortest Path Shooting Star – using heuristics with traffic rules to find the shortest path.

The Djikstra and Shortest Path A* works fine and are pretty fast after working with the network and bounding box. When trying the algorithm Shortest Path Shooting Star there are some problems. One major problem is when starting reverse direction of the first link.

Navteq’s segments starts from south. So when calculating a route on that starts off south there is a phenomena, see image. It should a straight line from the top point to the bottom point, very badly visualized.

onsdag 19 maj 2010

Tech Days 2010, blog posts and start with Bing Maps

Speaking Swedish or understand Swedish? If you are interested in BIng Maps, SharePoint, DeepEarth, Microsoft and GIS you can watch my presentation at Tech Days 2010 in Örebro, Sweden the 24th of Mars this year.

Lately Johannes Kebeck, a Bing Maps TSP blogged about my favorite project SMIL. That blog post is one post in a blog series about integrating maps into SharePoint. His latest post is about integration themetic maps from SQL Server 2008 R2.

If you are intested in starting developing with Bing Maps you should really go to Bing Maps portal. Johannes Kebeck, Chris Pendleton and BingMapsDev are people you can follow on twitter to get the latest news. Another good start is to go the developer forum. When should also have a look at Deep Earth Toolkit for Bing Maps.

onsdag 12 maj 2010

Creating a Silverlight Web Part for SharePoint 2007

In this blog post I describe an approach to add a Silverlight Web Part in SharePoint 2007. Adding Silverlight Web Parts to SharePoint can really make magic to SharePoint, i.e. maps (my personal favorite topic), Web Parts with drag and drop support from the file system etc. I always create a Silverlight project and separate and load it to a web part. I describe my favorite approach:

  1. Create a Web Part project, rename the Web Part and it’s files to something appropriate. I use Visual Studio 2008 extensions for Windows SharePoint Services 3.0 (version 1.2) in this example.
  2. Create a folder name it Templates.
  3. Create a folder name it ControlTemplates
  4. Create a folder name it YourWebPart-name.
  5. Choice File –> Add –> New Project. Choose web and give it a name.
  6. Get rid of the Default.aspx file in the web project.
  7. Add a User Control to the web project, get rid of the code behind and add your the reference to the web part assembly to the inherits of the file, example: <%@ Control Language="C#" AutoEventWireup="true"  Inherits="MyNameSpace.ClassName, AssemblyName, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=3283a693cab37f84" %> See understanding SharePoint for more info. The nice part now is that you can start designing the user control as with any .aspx-file, well almost. Add your .xap file and Silverlight.js-file to this project. 
  8. Add javascript and code for loading your silverlight control, i.e
    <div id="silverlightMultiFileUploadControlHost" >
    <object id="MultiFileUploader" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="450" height="280">
    <param name="source" value="/_controltemplates/mPost.MultiFileUpload/mpost.SilverlightMultiFileUpload.xap" />
    <param name="onerror" value="onSilverlightError" />
    <param name="initParams" value="MaxFileSizeKB=,MaxUploads=2,FileFilter=,ChunkSize=4194304,CustomParam=[site=<%=Site%>;docLib=<%=DocumentLibrary%>;httpService=<%=HttpService%>],DefaultColor=White" />
    <param name="background" value="white" />
    <param name="onload" value="pluginLoaded" />
    <param name="minRuntimeVersion" value="4.0.50401.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.5040


    1.0" style="text-decoration:none">
    <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
    </a>
    </object>
    <iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
    </div>




  9. Add properties to your .cs file. I always add a SPWeb property to access the web from the user control and make sure that the .designer.cs file has the same class name.


  10. Go back to your web part project and add the following methods:

         protected override void OnLoad(EventArgs e)

            { SilverlightWebPart


                ScriptManager scriptManager = ScriptManager.GetCurrent(Page);


                if (scriptManager == null) 
                {  scriptManager = new ScriptManager();


                    Controls.Add(scriptManager); 
                } 
            }
     
            protected override void OnPreRender(EventArgs e)

            {


                base.OnPreRender(e);


                ClientScriptManager cs = Page.ClientScript; 
                if (!cs.IsClientScriptIncludeRegistered("sl_javascript"))


                    cs.RegisterClientScriptInclude(this.GetType(), "sl_ja vascript", "~/_controltemplates/mPost.MultiFileUpload/Silverlight.js");


                if (!cs.IsClientScriptIncludeRegistered("spsl_javascript"))


                    cs.RegisterClientScriptInclude(this.GetType(), "spsl_javascript", "~/_controltemplates/mPost.MultiFileUpload/SpSilverlight.js");


            }


  11. Of course you need to change the script source to your path.


  12. Add reference System.Web.Extensions


  13. Choóse add existing item in your web part project. Add your user control as a link (we want to compile it with the web part assembly), also add a Silverlight.js and your .xap file the same way to this folder.


  14. You’re done, all you have to do now is to load the user control to the web part in the CreateChildControls method like:
    mPost.MultiFileUploadWebPart.MultiFileUploadUC uc = (mPost.MultiFileUploadWebPart.MultiFileUploadUC)
    Page.Page.LoadControl("~/_controlTemplates/mPost.MultiFileUpload/MultiFileUploadUC.ascx");
    Controls.Add(uc);




In 14 steps I can write shiny cool Silverlight web parts for SharePoint 2007. There are some steps, especially with the 5 part assembly that is a little tricky. Of course my favorite Silverlight web part is the one in SMIL and Silverlight Multi File Upload that has inspired this blog post. See http://slfileupload.codeplex.com/SourceControl/changeset/view/47874#1002455 for a working code example.




tisdag 4 maj 2010

SharePoint MultifileUpload – HTTP Handlers and “the security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”

In a current project I added a custom HTTP handler for a silverlight multifile upload web part for SharePoint. First, it’s obvious I need a client and a server pattern for make this happen. The client is just a Silverlight Web Part, nothing special nothing fancy. The server is a HTTP-handler, i.e an .ashx-file.

Integrate ASHX file into SharePoint

In order to integrate http-handler my favorite approach is to use WSPBuilder. Add a new WSPBuilder project, close it and open your .csproj file in notepad, or your favorite text editor, insert the following line right after <PropertyGroup>:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

Compile the project and find your public key token, either by writing
sn –T dll-file in the .NET console window or by just adding to dll to the GAC.

Now, all you need to do is create a directory structure in the hive 12 structure. I.e 12/Layouts, it’s common practice to add a directory after Layouts, in my case MultiFileUploadStructureMultifileUpload. The next step is just  to add Generic Handler to your solution. When you’ve done that you need to reference to your assembly in the GAC on the following pattern: AssemblyName, Version, Culture, PublicKeyToken. Example:

<%@ Assembly Name="MultiFileUpload, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a8aa1afe43cd31d3" %>

My complete markup is as follows:

<%@ Assembly Name="MultiFileUpload, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a8aa1afe43cd31d3" %>
<%@ WebHandler Language="C#" CodeBehind="MultiFileUpload.ashx.cs" Class="MultiFileUpload.MultiFileUpload" %>

By now you’re all set, you should be able to open IIS-manager and browse to the .ashx-file and open it in a web browser. Make sure the .ashx-file is at least in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS folder.

In my case I uploaded files to a document library with a Silverlight web part, in order to make that to work I needed to add:

site.AllowUnsafeUpdate = true.

This is strange because I make the call from a web browser inside SharePoint, perhaps it has something to do that it is actually a Silverlight web part?

The web part and the server code is given back to the project. http://slfileupload.codeplex.com/.

More info:MSDN, myrocode.com, Mike Poulson.

Technorati Tags: ,

söndag 25 april 2010

SMIL Part 2

List and Views become Layers

A fundamental part in SharePoint is Lists and Views. SMIL consider SharePoint as a platform where various applications can live and use all features from SharePoint, such as document management, issue tracking, integration to Microsoft Office etc. One web site in SharePoint is one application which can be customized and populated with specific data.

SMIL using lists in SharePoint almost as de-normalized tables in a databases and views are just as views in the database. Of course SharePoint cannot replace a database and there are drawbacks from not storing spatial information in a spatial database. However, the framework (Deep Earth and Bing Maps) SMIL is built on gives opportunities to make spatial operations in the client thanks to NetTopolgySuite and GeoAPI.

SMIL’s Layer Panel groups lists that contains geographic data, and shows every view as a layer. The upside of this is that layers are auto generated and published with SMIL’s GeoRss-feed by just creating a view in a SharePoint list. One upside of this approach is that SharePoint do filtering and anyone who has privileges can create new Layers for the users. Another nice thing is that person doesn’t have to be a GIS-specialist and learn a new tool. This approach is great to filter data that are stored in SharePoint as long as you don’t have to bother WHERE things are.

ListViews1

ListViews2

 

Info Window

imageIf the user hover the mouse over a SMIL symbol an info window of that item shows. The window first shows, which list, view and item title. In this case Tasks, All tasks, Task 2. Then there are two buttons. One Open button where you can open that particular list item and continue to work with that list item, the list item opens in a new window. Of course, as shown in SMIL Part 1, there are a map in the list item view that showing the position of the item. Next to the Open button there is a Select button. If the web part is connected to another list view web part the list view web part can be filtered by SMIL’s map web part. In this way, the user stays in this window.

In the drop down list, the views that is available in that lists are listed so the user can change view to get more or less information in details-section below.

Summarize

To sum up, SMIL tries to use as much as possible that is already built in SharePoint by using the concept of lists and views. The upside is that any SharePoint administrator can create new layers with this approach.

<< SMIL Part 1

onsdag 21 april 2010

SMIL Part 1

This is the first of a series of posts about SMIL. This post will be an overview and the later one will be more technical.

SMIL (SharePoint Map Integration Layer) is an open source project with the aim to geo-enable SharePoint. After all, almost all information has a location, almost 94% according to some. So geo-enable SharePoint makes sense. SMIL takes advantages of all the juicy stuff in SharePoint, document management, images, versioning, workflows etc and adds a geo-layer above SharePoint.

SMIL, is built with Bing Maps Silverlight control as map control with Deep Earth Toolkit on top.

Each list that contains geographical information, i e has SMILs custom datafield, are exposed via GeoRss-feeds. Also, the list is per default a group in a layer panel and each view in SharePoint a layer in the layer panel. There are many advantages with this approach since any SharePoint administrator or power user can build, and customize views, and filtering data from SharePoint.

SMIL- blog 1

After installation, the next blog post, you have SMIL running you can easily geo-tag any document, issue, task. For example you can start planning issues according to where they are and how an issue is in geographical relationship with issue. Or you might have resource planning tool in SharePoint and you want to know where things are. Do you have a lot of contracts for real estates - you can add them on a map. There are many applications and people tend to like maps!

List and List Items

In order to geo-reference list items in SharePoint all you have to do is to add a column with the custom data field, SMIL.Coordiante to a list. Then you can just start to add push pins to represent the location of the item or you can search for a location. If you view the item, the map is still interactive but you cannot move the pushpin, you need to edit the SharePoint item to do that – standard SharePoint.

Add column  Add metadata  Select

As mentioned SMIL using SharePoint filtering to filter data, but you can select surrounding information in SharePoint from a selected item in a map, if you have connected the Web Part to a corresponding List View Web Part. Each item has an info box on the map displaying metadata from that item inte SharePoint and you can change the view to get more or less information of that item. The idea is to have a short description view and a detailed view.

Images

SMIL also extract EXIF information from geo-tagged images and plot thumbnails on the map. If you don’t have a camera that stores coordinates along with the EXIF information you can just geo-reference them in SharePoint just as with any other list item, by using SMIL’s default geo-referencing tool.

Image

Part 2 >>

This blog will be in English from now on

Due to my work in different open source projects, Deep Earth and SMIL, this blog will know be in English from now on.