Archive for June, 2009

Published by breki on 28 Jun 2009

GroundTruth: Works With SRTM Again

Good news: I managed to update my Breki.DemLibrary code to be able to download SRTM data from the new NASA server. The next step was to update the source code for GroundTruth in order for it to be able to use the new code.

After some initial testing, I think GroundTruth is ready for a new release, so here it is: http://downloads.igorbrejc.net/osm/groundtruth/

If you notice any bugs regarding the new SRTM code, please report back.

Kosmos is the next one to be updated, although I expect a little bit more work on it since it uses an older code base. Hopefully it will be done in the next couple of days.

The other good news is that while making these changes to the SRTM code, I decided to overhaul the whole library. The main reason make the support for other sources of height data like CGIAR-CSI, viewfinderpanoramas.com, SRTM1 etc. much easier and transparent to users. I already started implementing support for these sources, but it will take some more time before the thing gets finished.

The main idea is for the DemLibrary to automatically find the best source of height data for a given area. So, for example, if you’re interested in generating contours for Alps, it will know that the best height data can be found on viewfinerpanoramas (presumably) and will download these instead of the plain old NASA’s SRTM3 cells (which contain a lot of “holes” with no height data). The library should even be able to combine various different sources into a single DEM dataset.

Published by breki on 23 Jun 2009

NASA’s SRTM Server Has Moved…

NASA moved the server containing SRTM data to a new location. Taken from their README file:

The SRTM dataset has moved. You have apparently been accessing it directly, rather than through the link specified at JPL (http://www2.jpl.nasa.gov/srtm/). The new location is http://dds.cr.usgs.gov/srtm/.Note that the directory levels have changed, so that the top level now contains the version directories. Lastly, we now only allow HTTP connections, not FTP. Sorry that we had no way to communicate these changes other than cutting off access at the old location.

The fact that they no longer provide FTP access is a big PITA for me, since all of my software (Kosmos, GroundTruth) uses FTP protocol to download the height data. I’ll need a few days of free time to write the new HTTP code, so unfortunately until then – I suggest you keep your SRTM caches on your disks.

As for Srtm2Osm, I’ll try to integrate this newly written code to it, but I cannot promise it will work – the code base has changed a lot since the time I published Srtm2Osm code on the OSM SVN server. Any volunteers?

Published by breki on 20 Jun 2009

Kosmos Gets Mentioned

I got this via Google Alerts, it’s a little bit old (April 2009), but still: Harry Wood gave a presentation of OSM to the British Computer Society, and one slide (109th actually ;) ) was dedicated to Kosmos. Which reminded me that I should probably update the Kosmos screenshot on the OSM Wiki page with some new and more interesting stuff.

Here’s the link to the presentation: http://www.slideshare.net/gssg/openstreetmap-open-licensed-geodata-1372080, there is also MP3 audio available. If you’re interested in OSM, I recommend listening through the whole presentation, it’s gives a good overview of the whole OSM area.

Published by breki on 19 Jun 2009

Making My Own Hiking Map With Kosmos

Pohorje Hiking Map

I finally invested some time into creating my own Kosmos rendering rules intended for hiking. I started from scratch, adding individual features either by copying them from existing rules or by writing new ones. I wanted to create a map that would suit my needs when hiking: distinguishing different types of hiking paths, forest tracks, marking paths that still need to be investigated (I use my own set of OSM tags for this), marking important hiking routes etc. It is quite difficult to get all these things right, so I needed a lot of experimenting before I got to this result.

The map of Pohorje reflects the data entered into OpenStreetMap during the last 2 years by a few mappers (no more than 4-5 from what I can remember). There is still a lot to be done, especially in the western part of Pohorje (which is farthest from where I live).

I haven’t been using Kosmos so much lately, so this exercise was useful – I discovered quite a few minor nuisances and ways to improve it. The biggest problem is defining actual rules, not just because they are written in wikitext, but also because they are not flexible enough. That got me into thinking of redesigning the whole rendering engine (GSS could be an option). I’ll spell out these ideas in some other post.

You can see my hiking rules at http://wiki.openstreetmap.org/wiki/User:Breki/Kosmos_Hiking_Rules, feel free to copy them (just don’t edit anything on the original page). Here are some screenshots taken from Kosmos:

Kosmos: Pohorje Hiking Map

Kosmos: Pohorje Hiking Map, detail

 

Published by breki on 18 Jun 2009

Fresh Catch For June 18th

These are my new delicious links for June 18th:


Published by breki on 17 Jun 2009

Fresh Catch For June 17th

These are my new delicious links for June 17th:


Published by breki on 16 Jun 2009

Gallio: Starting And Stopping Selenium Server Automatically During Testing Using AssemblyFixture

UPDATE (June 17th): I’ve updated the code, see the reasons for it at the end of the post.

In previous projects I worked on we made sure the Selenium Java server was running by manually starting it on our machines (both developers’ and build ones). This was cumbersome: restarting the build server meant we had to log on to the server after the reboot and run the Selenium server again. Of course, a lot of times we forgot to do this, which caused the build to fail.

This got me into thinking: is there a way in Gallio to specify some initialization (and cleanup) actions on the test assembly level? And of course, the answer is yes: using the AssemblyFixture attribute. This is what I like about Gallio/MbUnit: most of the time the feature requests I come up with are actually already implemented.

So anyway, you can specify this attribute on a class and then add FixtureSetUp and FixtureTearDown attributes on its methods. These will be executed on the test assembly-level: setup methods will be executed before any test fixtures have been run and teardown methods will be executed before the test assembly has been unloaded by the test runner.

I then used this nice feature to start the Selenium server and then dispose of it after tests:

[AssemblyFixture]
public class SeleniumTestingSetup : IDisposable
{
    [FixtureSetUp]
    public void Setup()
    {
        seleniumServerProcess = new Process();
        seleniumServerProcess.StartInfo.FileName = "java";
        seleniumServerProcess.StartInfo.Arguments =
            "-jar ../../../lib/Selenium/selenium-server/selenium-server.jar -port 6371";
        seleniumServerProcess.Start();
    }

    /// <summary>
    /// Performs application-defined tasks associated with freeing, releasing, or
    /// resetting unmanaged resources.
    /// </summary>
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    /// <summary>
    /// Disposes the object.
    /// </summary>
    /// <param name="disposing">If <code>false</code>, cleans up native resources. 
    /// If <code>true</code> cleans up both managed and native resources</param>
    protected virtual void Dispose(bool disposing)
    {
        if (false == disposed)
        {
            if (disposing)
                DisposeOfSeleniumServer();

            disposed = true;
        }
    }

    private void DisposeOfSeleniumServer()
    {
        if (seleniumServerProcess != null)
        {
            try
            {
                seleniumServerProcess.Kill();
                bool result = seleniumServerProcess.WaitForExit(10000);
            }
            finally 
            {
                seleniumServerProcess.Dispose();
                seleniumServerProcess = null;
            }
        }
    }

    private bool disposed;
    private Process seleniumServerProcess;
}

Note that the class is disposable – this ensures the Selenium server is stopped even if you run tests in the debugger and then force the debugger to stop before finishing the work. The Dispose method calls DisposeOfSeleniumServer, which does the actual work of killing the process and disposing of the evidence.

NOTE: This is a second version of the code. I needed to update the old one because I noticed that when running the tests in CruiseControl.NET, the Selenium server java process was not stopped properly. The only way I could stop it is by killing it, which in general isn’t a good practice. The unfortunate side effect of this “killing” is that the CruiseContol.NET service cannot be stopped normally – it also has to be killed when you need to restart it. I’ll try to solve this problem in the future.

Published by breki on 10 Jun 2009

ASP.NET MVC: Use Integrated Managed Pipeline Mode

A note to myself: the IIS application under which an ASP.NET MVC application runs has to be set up to use Integrated Managed Pipeline Mode (Advanced Settings…), otherwise you’ll end up with the

HTTP Error 404.0 – Not Found

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

error for any virtual URL (other than the default one).

This of course applies to IIS 6 and above.

Published by breki on 09 Jun 2009

Fresh Catch For June 9th

These are my new delicious links for June 9th:


Published by breki on 09 Jun 2009

FxCop: How To Use It

Long Beach Harbor Patrol Say No Photography From a Public Sidewalk
Creative Commons License photo credit: Thomas Hawk

This is a second post on my “guidelines” series. Some information here is specific to the projects I’m working on, and some is more general and so applicable to any project.

FxCop is a free static source code analysis tool created by Microsoft. It analyses your built assemblies and reports any issues it encounters. It has a set of rules (which can be turned on/off) which it uses to detect these issues. FxCop comes both in the command-line form (FxCopCmd) and as a Windows GUI.

Building

The general approach in our build scripts is: the script compiles the code and then immediately runs the FxCop analysis. If it detects any issues, it automatically runs the GUI and opens the relevant FxCop project. NOTE: you need to press F5 key (rebuild project) in order for FxCop to show the latest results!

When run “headless” (on the build server), the script of course doesn’t open the GUI – it just simply fails and then kindly informs the offender via email.

Resolving Issues

There are basically three ways how to resolve issues detected by FxCop, described in the following subsections.

Fixing The Code

Fixing the code where the issue has been detected is the preferred approach.

Applying Suppression Attribute On The Code

SuppressMessageAttribute can be used to suppress reporting of a specific defect by FxCop:

[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]

You can autogenerate these suppress lines by right-clicking on the issue, selecting Copy As -> Suppress Message. This will copy the suppress attribute into the clipboard and you can then paste it into the offending code. Depending on the type of the issue, the code has to be copied either in front of a class/interface, method, property or a field.

You should only suppress issues which you think

  1. aren’t really issues
  2. aren’t relevant
  3. the offending code has been designed on purpose.

On all other occasions, it is better to fix the code.

Excluding Issues In FxCop GUI

Sometimes (in rare situations) it is difficult to suppress an issue. In that case you can exclude them in the FxCop GUI by right clicking on the issue(s) and selecting Exclude.

NOTE: if you do any excluding in the GUI, don’t forget to save the FxCop project before exiting!

Language Issues

Since FxCop checks the spelling of class, method and other names in the source code, some FxCop issues are related to English dictionary. For example, on the latest project I’m working on, FxCop reported a spelling error for classes containing the MVC string, since MVC “word” isn’t in the standard English dictionary.

This can be resolved by adding such words in the CustomDictionary.xml file which is stored in the root directory of the project’s solution:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
  <Words>
    ...
    <Recognized>
      ...
      <Word>mvc</Word>
      ...
    </Recognized>
    ...
  </Words>
  ...
</Dictionary>

Adding FxCop Analysis On New VS Projects

When creating new projects in the solution, you have to do two things:

  1. Add the CODE_ANALYSIS compilation symbol in the project (using VisualStudio). Don’t forget to add it both for Debug and Release configurations. Without this symbol, FxCop will ignore any of your Suppress attributes in the code.
  2. Add the project to the FxCop project file, example:
<Target Name="$(ProjectDir)/MyTool/bin/MyTool.dll" Analyze="True" AnalyzeAllChildren="True" />

In general, I tend not to add FxCop analysis for unit test projects because unit test classes usually violate certain rules on purpose (or by design). One example is having test methods which don’t reference class instance stuff, for which FxCop reports the “mark member as static” issue.

Finally

There are some other minor “quirks” which can occur, I’ll try to add additional guidance if/when my team members encounter them :) .

Next »