Welcome to Planet OSGeo

January 28, 2012

Sandro Santilli

A walk on the wild side

How topology starts making sense in PostGIS 2.0.0

by strk at January 28, 2012 12:03 AM

January 27, 2012

OpenGeo Blog

Getting Curvey

PostGIS has supported curved geometry types — CIRCULARSTRING, COMPOUNDCURVE< CURVEPOLYGON — since version 1.4, but the number of functions that directly calculate against the curved features has remained pretty small. You can generate a bounding box, or calculate a length, but that’s about it.

A COMPOUNDCURVE made up of a line string, a circular arc, and another line string.

In order to do more complex calculations like area calculation or intersections, you have to first convert the curved object into a linearized approximation, using the ST_CurveToLine function. This is fine for functions that return numbers (like ST_Area) or booleans (like ST_Intersects), but what about functions that return derived geometries?

Linearized version of the compound curve. The arc has been replaced by a regular collection of lines.

For derived geometries, the result will be linearized like the inputs. But portions of the geometry will be linearized versions of the original curves: wouldn’t it be nice to have those curves back for storage?

Yes, it would which is why ST_LineToCurve exists. The line to curve logic works on the premise that a linearized version of a curve will have a certain amount of regularity in it.

The version of the code from PostGIS 1.4 and 1.5 works by looking at the angles between successive segments. Segments that share an angle of deflection with neighbours are probably components of a circular arc. This worked OK, but the code involved a fair amount of trigonometry.

By looking at angles between edges, you can find edges that are former components of an arc.

A simpler approach used for 2.0 turned out to be looking at the circle the arc is inscribed on. Any circular arc in PostGIS is defined by a start point, mid point and end point. Between them, they imply a circle, and the center of the circle can be calculated. Any successive point which is the same distance from that center point as the arc points can be considered part of the arc.

By using the circle as a basis for comparison, each successive point needs a simple distance check, instead of a trig check.

The new code is a lot simpler, and can deal with derived segments of more variable length that the old code.

The simplest way to prove that it works is to wrap a curved geometry in multiple nests of ST_LineToCurve and ST_CurveToLine, pushing the geometry back and forth between representations. While the functions are not perfect inverses (the segmentization routine doesn’t necessarily include the middle control points of the input arcs) you can see that the space bounded by the geometries does not change.

Happy curving!

by Paul Ramsey at January 27, 2012 08:39 PM

Sean Gillies

Geoprocessing for humans: a pip requirements file

In the geospatial software I'm writing and using these days, concerns are well separated. Fiona reads and writes features. Only. Shapely provides computational geometry algorithms. Only. Pyproj (not my work, but a favorite package) transforms coordinates between spatial reference systems. Only. The separation of concerns helps keep interactions between them predictable and as a user you pay only for what you eat.

A programmer-analyst's daily work has all the above concerns (and more, probably). A pip requirements file makes installing all three packages as easy as installing a single package like osgeo.ogr. I've uploaded one to GitHub: https://gist.github.com/1689767. This Gist includes an example of using Fiona, pyproj and Shapely together. Fetching them all, assuming you've got pip and the GDAL/OGR libs and headers already on your system, is just:

$ pip install -r https://raw.github.com/gist/1689767/34dedfd28546d41f8dbd7a08ccf2c8abf9ebdf6a/mersh.txt

by Sean Gillies (sgillies@frii.com) at January 27, 2012 05:52 PM

Gary Sherman

QGIS: Running Scripts in the Python Console

The QGIS Python console is great for doing one-off tasks or experimenting with the API. Sometimes you might want to automate a task using a script, and do it without writing a full blown plugin. Currently QGIS does not have a way to load an arbitrary Python script and run it1. Until it does, this post illustrates a way you can create a script and run it from the console.

There are a couple of requirements to run a script in the console:

  1. The script must be in your PYTHONPATH
  2. Just like a QGIS plugin, the script needs a reference to qgis.utils.iface

Setting up the Environment

By default, the Python path includes the .qgis/python directory. The location depends on your platform:

  • Windows: in your home directory under .qgis\python. For example, C:\Documents and Settings\gsherman\.qgis\python
  • Linux and OS X: $HOME/.qgis/python

To see what is in your PYTHONPATH you can do the following in QGIS Python console:

import sys
sys.path

While you could use the .qgis\python directory for your custom scripts, a better way is to create a directory specifically for that purpose and add that directory to the PYTHONPATH environment variable. On Windows you can do this using the Environment Variables page in your system properties:

On Linux or OS X, you can add it to your .bash_profile, .profile, or other login script in your home directory:

export PYTHONPATH=$PYTHONPATH:/home/gsherman/qgis_scripts

Writing the Script

With the environment set, we can create scripts to automate QGIS tasks and run them from the console. For this example, we will use a simple script to load all shapefiles in a specified directory. There are a couple of ways to do this:

  1. Write a simple script with a function that accepts qgis.utils.iface as an argument, along with a path to the shapefiles
  2. Create a Python class that uses an __init__ method to store a reference to the iface object and then add methods to do the work

We will use the latter approach because it is more flexible and allows us to initialize once and then call methods without having to pass the iface object each time.

The script looks like this:

#!/usr/bin/env Python
"""Load all shapefiles in a given directory.
  This script (loader.py) runs from the QGIS Python console.
  From the console, use:
    from loader import Loader
    ldr = Loader(qgis.utils.iface)
    ldr.load_shapefiles('/my/path/to/shapefile/directory')
 
  """
from glob import glob
from os import path
 
class Loader:
    def __init__(self, iface):
        """Initialize using the qgis.utils.iface 
        object passed from the console.
 
        """
        self.iface = iface
 
    def load_shapefiles(self, shp_path):
        """Load all shapefiles found in shp_path"""
        print "Loading shapes from %s" % path.join(shp_path, "*.shp")
        shps = glob(path.join(shp_path, "*.shp"))
        for shp in shps:
            (shpdir, shpfile) = path.split(shp)
            self.iface.addVectorLayer(shp, shpfile, 'ogr' )

Running the Script

To open the console use the Plugins->Python Console menu item.

The comment at the head of the script explains how to use it.

First we import the Loader class from the script file (named loader.py). This script resides in the qgis_scripts directory that is our PYTHONPATH.

from loader import Loader

We then create an instance of Loader, passing it the reference to the iface object:

ldr = Loader(qgis.utils.iface)

This creates the Loader object and calls the __init__ method to initialize things.

Once we have an instance of Loader we can load all the shapefiles in a directory by calling the load_shapefiles method, passing it the full path to the directory containing the shapefiles:

ldr.load_shapefiles('/home/gsherman/qgis_sample_data/vmap0_shapefiles')

The load_shapefiles method uses the path to get a list of all the shapefiles and then adds them to QGIS using addVectorLayer.

Here is the result, rendered in the random colors and order that the shapefiles were loaded:

Some Notes

  • When testing a script in the console you may need to reload it as you make changes. This can be done using reload and the name of the module. In our example, reload(loader) does the trick.
  • You can add more methods to your class to do additional tasks
  • You can create a “driver” script that accepts the iface object and then initializes additional classes to do more complex tasks

1. I have plans on the drawing board to implement this feature.

by Gary Sherman at January 27, 2012 05:10 PM

Free and Open Source GIS Ramblings

Looking for Roundabouts in OSM

Roundabouts are handled interestingly in OSM: They can be both nodes or ways and represented as points, lines or polygons.

And this is how they can be downloaded for a specific area:

> wget http://open.mapquestapi.com/xapi/api/0.6/node[highway=mini_roundabout][bbox=15.86,47.95,16.88,48.70]
> wget http://open.mapquestapi.com/xapi/api/0.6/way[junction=roundabout][bbox=15.86,47.95,16.88,48.70]

Note: Not all XAPI servers are available all of the time. Check this site if the server is down: OSM Wiki – Xapi.


by underdark at January 27, 2012 11:17 AM

Cameron Shorter

Presenting at GeoNext conference



I'm speaking at the GeoNext conference, and will be answering audience questions on the topic of:
"Where to start with Geospatial Open Source Software, and how to build a business around Open Source products".
Speakers at the GeoNext conference are covering topics around emerging geospatial business trends, which are being driven by such things as mobile phones, commoditisation of data, and web 2.0 principles such as crowd sourcing. It is running in Sydney, Australia on 29 February 2012. More details here: http://geonext.com.au/
If you will be coming, then let me know and come and say hello.

by Cameron Shorter (noreply@blogger.com) at January 27, 2012 01:46 AM

January 26, 2012

Slashgeo (FOSS articles)

OpenGeo Announces Gold Level Sponsorship for 2012 FOSS4G-NA

OpenGeo Announces Gold Level Sponsorship for 2012 FOSS4G-NA

FOSS4G North America Regional Conference to be Held in Washington, D.C.

New York, NY, January 26, 2011 OpenGeo, the organization behind the OpenGeo Suite has announced their sponsorship of the 2012 FOSS4G-NA conference. The Free and Open Source Software for Geospatial - North America (FOSS4G-NA) conference will be hosted by OSGeo North America from April 10th to 12th, 2012 at the Walter E. Washington Convention Center in Washington, D.C. Confirmed keynote speakers include Michael Byrne, CIO of the Federal Communications Commission (FCC).

OSGeo North America is the newly-formed North America chapter of OSGeo, an international not-for-profit whose mission is to support and promote the collaborative development of open geospatial technologies and data. OSGeo North America has scheduled this regional follow-up to focus on the North American open source geospatial community. Just as they did at the 2011 FOSS4G global conference in Denver, OpenGeo is once again committed to a gold level sponsorship, In addition, this year members of OpenGeo are also volunteering on the conference organizing committee.

Eddie Pickle, OpenGeo COO said "Supporting FOSS4G and OSGeo is a top priority for OpenGeo. FOSS4G is always a key forum for meeting with our friends, clients, and partners as well as for exchanging knowledge to improve open source geospatial software. A regional event in Washington, D.C. will allow us us to focus on the evolving landscape of open source geospatial in North America. We’re especially interested to see how government agencies have been adopting open source technology to address their needs." He continued "We’re also happy to announce that our own Paul Ramsey has volunteered to be the FOSS4G- NA 2012 conference chair; we know the conference will be a success with Paul at the helm."

About FOSS4G-NA 2012

FOSS4G is an annual global conference organized by OSGeo that focuses on bringing together individuals and organizations working with free and open source geospatial software; FOSS4G-NA is a regional event for North America and is being organized by the North American Regional chapter of the Open Source Geospatial Foundation (OSGeo), with additional support from members of a volunteer program and conference committee and the conference sponsors

About OpenGeo

OpenGeo is a social enterprise working to build the best web-based geospatial technology. The company brings the best practices of open source software to geospatial organizations around the world by providing enterprises with supported, tested, and integrated open source solutions to build the Geospatial Web. OpenGeo also supports open source communities by employing key developers of PostGIS, GeoServer, and OpenLayers. Since 2002, the company has provided successful consulting services and products to clients like the World Bank, Google, Ordnance Survey Great Britain, Portland TriMet, MassGIS, Landgate, and the Federal Communications Commission. OpenGeo is the geospatial division of OpenPlans, a New York-based 501(c)(3) non-profit that informs and engages communities through journalism and open source software. All of OpenGeo's revenue has been and will continue to be re-invested into innovative and useful software in support of the OpenPlans mission.

Related Links

FOSS4G-NA 2012 Conference - Washington, DC
FOSS4G 2012 - Beijing, China
OSGeo North America
Open Source Geospatial Foundation

Media Contact

David Dubovsky
+1 917-388-9077
david@foss4g-na.org

January 26, 2012 09:01 PM

Daniel Morissette

Intellectual Property vs Copyright

In the past I have often used the terms Intellectual Property and Copyright to mean essentially the same thing, without realizing that this was incorrect. Maybe that was because English is not my native language, but probably not since I have actually heard several others making the same mistake as well.

This morning in a discussion on this topic on the OSGeo Incubator mailing list, Frank Warmerdam explained the difference between the two terms and now I better understand why the terms Intellectual Property and Copyright should not be confused, especially in the context of Free and Open Source Software (FOSS).

I thought I'd share a copy of Frank's great explanation here in case it helps others better understand the distinction:
Daniel,

I believe the rationale behind avoiding the term Intellectual Property
has two parts.

First, it attempts to conflate a variety of very different legal mechanisms.
Primarily copyright, patents and trademarks.  Giving them all one name makes
it harder to separate out things we might agree with (copyright) from things
we might not (ie. Patents).

Second, it expresses these legal mechanisms in a manner that implies that
they are some sort of fundamental or manifest right rather than limited
government granted monopolies intended to serve specific needs of society
[...]
You can read the full email and the rest of the thread here.

by Daniel Morissette (noreply@blogger.com) at January 26, 2012 06:22 PM

Simone Giannecchini

Improving GeoServer SQL Server support

Dear All,
in recent times we were hired to improve GeoServer SQL Server support story.

The SQL Server store was created and maintained during spare time by Justin DeOliveira, however due to lack of production usage, and work time to pour on it, it failed to reach to the same level of robustness and speed as the best supported stores, such as Oracle and PostGIS.

Our work this week tried to close this gap with a number of little and big improvements that make the code run faster and in a more reliable way:
  • add support for connection validation (very important for SQL Azure, which is very keen on closing pooled connections in your face)
  • use binary encoding, instead of text, to transfer geometries from the database
  • support for data paging at the database level
  • make sure the rich database test suite we have in GeoTools is fully implented for SQL server, ensuring good support for use cases such as dynamic SQL views, proper date/time encoding in filters, and the like, both on the development series and on the stable series
Our develoment focused on testing the code against both SQL Server 2008 and SQL Azure. SQL Azure is the SQL database one can use in the Microsoft Azure cloud system: while it does look a lot like SQL Server 2008, it does not quite behave the same way in all cases, and requires a specific JDBC driver to work properly.

There are still some improvements missing on the table, such as geography columns support, but we're sure you'll be able to get more out of a production usage of GeoServer and SQL Server now.

Interested in sponsoring further improvements? Looking for professional support service that deliver for your group? Let us know!

The GeoSolutions team,

by Andrea Aime (noreply@blogger.com) at January 26, 2012 10:42 AM

January 25, 2012

Micha Silver

Spatialite and Excel on talking terms

The recent stable version of Spatialite, 3.0, supports linking to and importing Excel spreadsheet tables. Read on to see how it’s done.

The developers of spatialite have added a driver for *.xls files (thru the FreeXL library ). You can either link to, or import a single sheet from an Excel file provided that:

  • the file is Excel 2003 format (not the newer xml format)
  • the table is “cleanly” formated – only data in rows, no empty rows, etc.
  • the first row contains either column headers, or straight-away the first data entry

However the columns of data are imported into spatialite without any data type. If you want to specify the data type for each column, my procedure is:

  1. link to the external table (create a virtualXL table)
  2. create your own, well defined table
  3. use the SQL construct “INSERT INTO … SELECT FROM…” in order to copy all data from the linked table into your structured table.
  4. then run the spatial funtions AddGeometryColumn() and MakePoint() in order to convert the table to a spatial layer

These few steps might seems a bit complex just to get a table of data into spatialite, but this method insures that data will be structured exactly as you want.

If you’re working with spatialite from the command line, here’s the command syntax for loading an excel sheet:

.loadxl <args> Loads a XL spreadsheet (.xls) into a SpatiaLite table
arg_list: xl_path table_name
[worksheet_index [first_line_titles{0/1}]]

Note that the worksheet index begins with 0. So if you have more than one sheet in your Excel file, be sure to set the correct index for the worksheet containing the table. The last parameter indicates (by values 0 or 1) whether the first row holds column headers. So for example you could import the first sheet of an excel worksheet called ‘host_trees.xls’, which contains column headers in the first row, with the following command:

spatialite>.loadxl 'host_trees.xls' host_trees 0 1
XL loaded

3770 inserted rows
spatialite>

We’ll follow the full procedure to smoothly import a spreadsheet of longitude,latitude data and create a spatial layer with screen shots from the spatialite_gui. Suppose we begin with a table that looks like this:

Excel table of data with Longitude/Latitude loctaions

Excel table of data with Longitude/Latitude loctaions

First import the table using the VirtualXL button. This creates a link in the spatialite db to the sheet from Excel.

Importing an Excel table as VirtualXL

Importing an Excel table as VirtualXL

In the next image note that the linked data table has no types for the columns. So we’ll create our premanent table (named here ‘MyHostTrees’)within spatialite, specifying the correct data types, then we will transfer the date over from the virtual table to the permanent one. Follow the steps…

Crete a new, permanent table with correct data types

Crete a new, permanent table with correct data types

Now we transfer the data from the virtual table to the permanent table using the SQL construct: “INSERT (…) INTO … SELECT … FROM …”.  Here’s how it looks:

Copy data from virtual table to permanent table

Copy data from virtual table to permanent table

We continue by making this new table a spatial table with the AddGeometryColumn() function, then we populate this Geometry column using the MakePoint() function.

AddGeometryColumn

Using the AddGeometryColumn function

 

Populating the Geometry column

Populating the Geometry column

And here’s the result:

Spatial table containing data with Geometry column

Spatial table containing data with Geometry column

by Micha Silver at January 25, 2012 07:53 PM

Gary Sherman

Using the QGIS Raster Calculator

The raster calculator allows you to perform mathematical operations on each cell in a raster. This can be useful for converting and manipulating your rasters. Operators include:

  • Mathematical (+, -, *, /)
  • Trigonometric (sin, cos, tan, asin, acos, atan)
  • Comparison (<, >, =, <=, >=)
  • Logical (AND, OR)

To perform operations on a raster or rasters, they must be loaded in QGIS. The raster calculator is accessed from the Raster menu and brings up the dialog:

Let’s look a few examples.

Simple Mathematical Calculation

Doing a simple calculation is easy. In this example we have a Digital Elevation Model (ancc6) loaded in QGIS. The DEM contains elevations for a 1:63,360 quadrangle in Alaska. The coordinate system is geographic and the elevation value in each cell is in meters. If we wanted to create a raster with elevation in feet, we can use these steps to create the expression:

  1. Bring up the raster calculator
  2. Double click on ancc6@1 in the raster bands list to add it to the expression
  3. Double click the multiplication operator (*)
  4. In the expression box, type in the conversion factor for meters to feet: 3.28

This gives us the following expression:

ancc6@1 * 3.28

To complete the process, we specify a name for the output raster and the format we want to use. When you click OK, the operation will be performed and the new raster created, giving us a GeoTIFF with cell values in feet. If you leave the Add result to project box checked the output raster will be added to QGIS once the calculations are done.

If you only want to operate on a portion of a raster, you can use the extent setting to limit the area included in the calculation.

Using a Mask

Sometimes you might want to mask out part of a raster. An example might be one where you have elevations ranging from below sea level to mountain tops. If you are only interested in elevations above sea level, you can use the raster calculator to create a mask and apply it to your raster all in one step.

The expression looks like this:

(my_raster@1 >= 0) * my_raster@1

The first part of the expression in parentheses effectively says: for every cell greater than or equal to zero, set its value to 1, otherwise set it to 0. This creates the mask on the fly.

In the second part of the expression, we multiply our raster (my_raster@1) by the mask values. This sets every cell with an elevation less than zero to zero. When you click OK, the calculator will create a new raster with the mask applied.

Simulating a Rise in Seal Level

Using the raster calculator and a mask we can visually simulate a rise in sea level. To do this we simply create the mask and overlay it on the DEM or perhaps a DRG (topographic) raster.

The expression to raise sea level by 100 meters is:

ancc6@1 > 100

The output raster contains cells with either a 0 (black) or 1 (while) value:

The black areas represent everything below an elevation of 100 meters, effectively illustrating a sea level rise. When we combine this with a suitable background we can demonstrate the results:

We added the DRG for the quadrangle and overlaid it with the mask layer. Setting the transparency to 70% allows the DRG to be seen, illustrating the effect of raising sea level.

The raster calculator is a powerful tool. Check it out and see how you might use it in your analysis and map making.

by Gary Sherman at January 25, 2012 06:12 PM

Sean Gillies

Notes on learning Clojure

I'm learning Clojure and having fun with it. I never learned a Lisp in school like many programmers my age did. The one variant I did try, about 15 years ago, was Scheme. I did a little Gimp scripting with it but nothing else. I think I had to mature a bit before I could appreciate the Lisp style for what it is.

For a language that's designed to be more simple than easy, it's surprisingly easy to use Java classes in Clojure. This is the first code I've written using JTS classes in a while.

user=> (.buffer
  (.read (com.vividsolutions.jts.io.WKTReader.) "POINT (0 0)")
  1.0)
#<Polygon POLYGON ((1 0, 0.9807852804032304 -0.1950903220161282, ...))>

I assumed I'd have to write something like a Python C extension module to do this and am thrilled to be wrong.

by Sean Gillies (sgillies@frii.com) at January 25, 2012 05:13 PM

Slashgeo (FOSS articles)

Marble 1.3.0 and "Marble Touch" Released

Marble 1.3 has been released with lots of new gems: Marble — the virtual globe and world atlas — now integrates with KDE Plasma. By allowing for coordinate and bookmark searches, Marble can be opened directly from the Plasma search bar.

The new Elevation Profile shows the incline of routes, which can be edited interactively.

Stargazers can view and track Earth satellites thanks to Marble participation in the European Space Agency (ESA) Summer of Code in Space.

During Google Summer of Code, Marble gained initial support for display of .osm (OpenStreetMap) files in vector format.

Owners of the Nokia N9/N950 are the first to receive the new mobile application Marble Touch.

Further details can be found in the feature guide.

January 25, 2012 02:15 PM

Matt Sheehan

Flexible Mobile GIS Frameworks

We have spoken many times on this blog about our release of GeoMobile for ArcGIS. The link below will take you to a more detailed discussion:

http://www.webmapsolutions.com/free-mobile-arcgis-viewer-upgraded

Our logic for the release was:

To demonstrate a custom ArcGIS mobile application Build a cross platform mobile GIS app or one code base which runs on multiple platforms; iOS, [read full article]

by web maps at January 25, 2012 01:53 PM

Gavin Fleming

Confessions of an ex-Windows user

Education is undoubtedly the largest propaganda weapon in this consumerist-driven society. Having just completed matric, I realize that the first eighteen years of my life has been a period of unmitigated Windows brainwashing. It is a travesty to think how the capitalist greed of proprietary software has permeated my life for so long.

I recently began working at AfriSpatial with the intention of keeping myself busy during the holiday and earn some pocket money in the process. I was required to work in Linux which was a somewhat foreign OS to me and, afraid it would mysteriously hurt my fragile Windows PC, I installed Xubuntu OSGeo Live in a Virtual Box. At this stage life was treating me well…

One day, Windows decided to do an update which broke the harmony of my Virtual Machine by somehow preventing connection to the Internet. I wasted precious hours troubleshooting every conceivable error but this was to no avail. I had two choices: either forget about Linux and revert to the primitive ways of life before Linux or take a bold new step into a brighter future. So I actually had no choice and no more patience. I had to install Linux as a dual-boot. There was no other way.

This seemingly inconsequential event instigated a change; a purgation of conscience whose effects altered the kernel of my value system. I guess in hindsight this transmogrification was inevitable for an aspiring programmer.

Having joined the ranks of the converted Linux users, life has become so much brighter, so much more fulfilling, so much more. Gone are the days of tasteless architecture and graphics. The experience has been liberating. I blame schools for polluting their computer labs with expensive proprietary software when there are open source equivalents for just about everything (and often these ‘alternatives’ are better). Open source is undoubtedly the way forward. Anything Windows can do, Linux can do better. I am not trying to be antagonistic, just honest.

These are the confessions of an ex-Windows user.

Confessions of an ex-Windows user is a post from: AfriSpatial

by Robert Moerman at January 25, 2012 09:18 AM

GeoTools Team

AURIN Job Openings

Many of the best known GeoTools examples are popular open source projects. If you follow our user list, you will know that GeoTools is used in a wide range of environments and settings.

With that in mind, we are happy to pass along a couple of job openings from Martin Tomko and the Australian Urban Research Infrastructure Network (AURIN):
GeoTools experience is a plus; and tell Martin we sent you.

If you have a GeoTools related job post you would like us to pass along, please contact your nearest PMC member and we would be glad to help.

by Jody Garnett (noreply@blogger.com) at January 25, 2012 05:31 AM

Nathan Woodrow

Improvements to the QGIS rule based rendering

The rule based rendering in QGIS has just got a make over to improve in some of the old usability issues it used to have.  Most of the improvements are UI related. If you would like to try them out you will need to grab a copy of the latest dev build (qgis-dev in OSGeo4W)

Main improvements include:

  • Nested rules.  If the parent rule evaluates to false none of the child rules are applied. This replaces the priority system in the old dialog.
  • Disable symbol for rules. Rules with no symbol only act as a check for the child rules e.g nothing is rendered for the rule but child rules still are (unless also disabled).
  • Drag and Drop rules (multi-selection is supported).  Rules can be dragged onto other rules in order to nest them and set up a rendering hierarchy.
  • Inline editing of rule labels, expressions, scales
  • Overall tweaks to the dialog

The new rule dialog

As you can see in the screenshot, the rules are now organized in a tree which clearly expresses which rules should be applied and when.

In the example above, all the rules under the Sealed rule will only be applied if that rule is true. The old system would have you managing all rules in one big list and dealing with priorities in order to get the rules to apply right, the new dialog is a major improvement.

And the results! As you can see below, QGIS will only render the colored squares if the Sealed rule is true otherwise it just shows a green line.

The rules applied

The work was sponsored by Ville de Morges, Switzerland and developed by Martin Dobias.  Thanks to both of them for these improvements.

More info:

Note: As this is a brand new feature there might be some bugs, or things that don’t quite work as expected. If you do find something don’t hesitate to file a bug report at hub.qgis.org so it can be fixed, or at least known about.


Filed under: Open Source, qgis Tagged: FOSSGIS, gis, map-rendering, mapping, Open Source, osgeo, qgis, Quantum GIS, styling

by Nathan at January 25, 2012 04:54 AM

January 24, 2012

Matt Sheehan

Hot Topics in Mobile GIS

We recently looked back over client and potential client feedback in 2011. There were definitely some re-occurring themes. Here we summarise some of these conversations:

1) Mining

Display in a mobile map app dynamic sensor data (click on map point and its shows current data)

2) Cultural Resource Management

“Even though GPS technology has been readily adopted [read full article]

by web maps at January 24, 2012 05:39 PM

Tyler Erickson

pyKML at the 2012 American Meteorological Society Annual Meeting

Tomorrow I am giving a talk at the American Meteorological Society Annual Meeting entitled:

Using the pyKML Library to Format Weather and Climate Data for Viewing in Google Earth

It is at 11:45, if you happen to be at the meeting.  The talk presents numerous examples of using pyKML, but because of the static format required by the conference (i.e. Powerpoint or PDF) I thought it might be useful to provide a number of links to related content. Enjoy!

pyKML:

Examples:
Misc:

by Tyler Erickson (noreply@blogger.com) at January 24, 2012 05:14 PM

GIS-Lab

OSGeo4W перешел на Python 2.7

То, чего многое давно ждали, свершилось. OSGeo4W перевели на Python 2.7.2 (до этого использовалась порядком устаревшая версия 2.5.2). Переход на версию 2.7 обусловлен длительной поддержкой этой версии, множеством исправленных ошибок а также наличием большого числа новых версий библиотек, которые не могут быть собраны с Python 2.5

Ознакомиться с тем, как проходил процесс миграции можно на специальной странице Requires Python, а также в соответсвующих тикетах #214 и #219.

Необходимо помнить, что такое глобальное изменение может повлечь за собой ошибки, кроме того, некоторые пакеты все еще не адаптированы. Если в процессе работы вы столкнетесь с ошибками, сообщайте о них.

by voltron at January 24, 2012 02:00 PM

gvSIG Team

gvSIG projects migration to our new servers finished!

English

As some of you already know, at the end of last year the OSOR project forge was closed and replaced by the new Joinup service. The projects that were available in OSOR had been migrated to Joinup.

In the case of the gvSIG project, we thought the new Joinup service was not going to fulfill our needs, so we started to prepare our own services for the source and maven repositories, as well as the trackers for bugs and feature requests.

In any case we are really grateful with the OSOR team for the services provided to the gvSIG community since during all the time we where hosted there.

The migration has been already performed, and all previous gvSIG project services are already available in the new servers:

The gvsig desktop 2.0 projects maven configuration has already been updated to point to the new servers, so you should be able to compile without problems. Also a new build has been prepared (2043), already in the new servers.

The gvsig desktop application and addons will be available also through a new downloads server. All those URLs are being updated in the projects main portal, but bear us if there is still any reference to the old OSOR locations or there are still some broken references. The development downloads page is still not working 100%.

For developers, the page about how to prepare a workspace with the gvSIG 2.0 core projects has been updated also.

Sorry everybody for any problems related to the migration. We hope we can
start working again as always from now on.

Spanish

Como algunos de vosotros ya sabéis, a finales del año pasado la forja del proyecto OSOR fue cerrada y reemplazada por el servicio Joinup. Los proyectos que estaban alojados en OSOR fueron migrados automáticamente a Joinup.

En el caso del proyecto gvSIG, pensamos que el nuevo servicio de Joinup no iba a satisfacer todas nuestras necesidades, por lo que empezamos a preparar nuestros propios servicios de repositorios de código fuente y maven, así como los trackers de errores y peticiones de mejoras.

En cualquier caso queremos agradecer encarecidamente a la gente del equipo de OSOR los servicios proporcionados a la comunidad gvSIG durante todo este tiempo.

La migración ha finalizado ya, y todos los servicios que teníamos para los proyectos gvSIG están disponibles en los nuevos servidores:

La configuración de los proyectos de maven de gvSIG desktop 2.0 has sido actualizada para hacer uso de los nuevos servidores, por lo que ya se debe poder compilar sin problemas. Además un  nuevo build (2043) ha sido preparado, ya disponible en los nuevos servidores.

La aplicación gvSIG desktop, así como los complementos de instalación, estarán disponibles a través del nuevo servidor de descargas. Todas las URLs están siendo actualizadas en el portal principal de gvSIG, aunque es posible que queden todavía algunas referencias a las antiguas ubicaciones en OSOR  o algunas referencias rotas. Además la página de descargas en desarrollo todavía no está funcionando al 100%.

Para los desarrolladores, la página sobre como preparar un espacio de trabajo con los proyectos principales de gvSIG 2.0 ha sido actualizada también.

Disculpas a todo el mundo por los problemas que haya podido causar esta migración. Esperamos que a partir de ahora todos podamos empezar a trabajar de nuevo como siempre en el proyecto.


gvSIG Team


Filed under: community, development, english, gvSIG Desktop, opinion, spanish, testing

by cordin at January 24, 2012 02:00 PM

Slashgeo (FOSS articles)

MapProxy 1.3.0 Released

We mentioned the open source MapProxy a few times since 2010, including the 1.0.0 release about a year ago. Less than two weeks ago, MapProxy 1.3.0 was released. Anyone with an interest in tile caching might be interested in reading this previous story named FOSS4G 2011: What about a Tiling Shootout?

Amongst the new features for the 1.3.0 release: "

  • RESTful WMTS: The MapProxy WMTS now also supports the RESTful API. This service also supports custom URL templates for your service.
  • CouchDB cache backend: You can now use a CouchDB as a backend for tile caches. Each cache gets stored into a separate database and you can configure the layout of the URLs of each tile. You can also add additional metadata for each tile."

by Satri at January 24, 2012 01:54 PM

Slashgeo (FOSS articles)

First FOSS4G - North America 2012 Conference in Washington DC April 10-12

For those who don't read our geospatial press releases feed, you might be interested in learning about the first FOSS4G - North America conference to be held in Washington DC in April 10-12, 2012. We mentioned in 2009 the possibility of a North American-specific FOSS4G conference to be organized by the OSGeo, it now has become reality.

From the press release: "In light of the success of last September’s international FOSS4G conference in Denver, Colorado, the newly-formed North America chapter of OSGeo, a not-for-profit organization whose mission is to support and promote the collaborative development of open geospatial technologies and data,  seized upon the opportunity to organize a regional follow-up conference focusing on the North American open source geospatial community. “2011’s event showed us that there is great interest in the region to continue the conversation and strengthen the network of individuals and organizations working the open source geospatial field,” said Paul Ramsey,  accomplished geospatial software developer and FOSS4G- NA 2012 conference chair."

by Satri at January 24, 2012 01:33 PM

gvSIG Team

Fifth Italian gvSIG Conference

From 27th to 29th June 2012, the 5th Italian gvSIG Conference (Quinte Giornate Italiane di gvSIG) [1] will be held in the “Aula Magna” of the Politecnico di Milano – Polo Territoriale di Como (via Castelnuovo, 7 – Como).

The meeting, organized by the Laboratorio di Geomatica del Politecnico di Milano – Polo Territoriale di Como and the gvSIG Association, is an interesting meeting point for changing experiences between users and developers from Italy. Seminaries and presentations are planned at the Conference.

The call for papers is now open, and proposals can be sent to the email address: giornate.italiane@gvsig.org (consult Presentation rules [2]), until May 23th.

Registration period will be opened in March 7th.

[1] http://www.gvsig.org/web/community/events/giornate-italia/2012/

[2] http://www.gvsig.org/web/community/events/giornate-italia/2012/comunicazioni


Filed under: community, events, Italian, opinion

by Mario at January 24, 2012 12:16 PM

OTB Team

OTB 3.12.0-rc1 ready for testing!

We are happy to announce that OTB and Monteverdi have entered the 3.12 release candidate stage!

You can find the source (OTB and Monteverdi) and binary packages (Monteverdi form Mac OS X and Windows) here.

Some of the notable changes in this release are:

  • Large JPEG2000 file (Pleiades-like) support and Pleiades metadata handling in OTB (more information here)
  • Efficient JPEG2000 visualisation and ROI decompression tools in Monteverdi
  • Revamp of otb applications in a generic and scalable framework (more information here) : launch applications from Command-Line, from an auto-generated QT GUI, from python, from within QGis …
  • Lots of new algorithms : Dimensionality Reduction (ICA, PCA, MNF, MAF …), change detection (MAD), Hyperspectral Unmixing, elevation map from stereo data, compare segmentation with a ground truth (Hoover) …
  • And various bug fixes.

There are a lot more new things coming with this release ! For more information, please read the complete release note available here.

As usual, Release Candidate are made to be tested and stressed, so do not hesitate to give it a try and report whatever you find suspicious on the users list, or directly on the BugTracker.

Also note that a teaser of what can be done with OTB is now available here !

Happy Testing!

Manuel, for the OTB team

by Manuel Grizonnet at January 24, 2012 09:38 AM

Tim Sutton

Simple binary raster reclassification in QGIS

The Raster Calculator in QGIS allows you to run any expression on a raster or collection of rasters. While it is definitely useful, exactly how to phrase your expression in order to reclassify a raster is not always clear. Let’s say you have a raster with values between 0 and 255, and you want everything [...]

by Rudi Thiede at January 24, 2012 09:32 AM

Sean Gillies

Shapely 1.2.14

Shapely 1.2.14 is up on PyPI: http://pypi.python.org/pypi/Shapely and the documentation has been updated: http://toblerity.github.com/shapely/. Mike Towes has made coordinate and (homogeneous) geometry sequences sliceable. For example, you can now get every other vertex of a line string or linear ring like this:

>>> from shapely.geometry import Point
>>> ring = Point(0.0, 0.0).buffer(1.0).exterior
>>> len(ring.coords)
66
>>> evens = ring.coords[::2]
>>> len(evens)
33

and a geometry collecting the odd points of another multi point geometry can be had like:

>>> from shapely.geometry import MultiPoint
>>> multi = MultiPoint(evens)
>>> len(multi)
33
>>> odds = multi[1::2]
>>> odds.geom_type
'MultiPoint'
>>> len(odds)
16
>>> list(odds)
[<shapely.geometry.point.Point object at 0x744d30>, ... ]

Heterogeneous geometry collections can't be sliced in 1.2.14. Down the road, maybe.

by Sean Gillies (sgillies@frii.com) at January 24, 2012 05:01 AM

Tyler Mitchell

Book now selling! The Geospatial Desktop

Gary's updated book is now (back) in print and listed on Amazon for sale! Covering a vast array of open source software for GIS analysis, mapping and application building. With special sections focused on Quantum GIS and GRASS GIS.

For more info see our book page or the comprehensive book website. Or just buy it on Amazon.

by spatialguru at January 24, 2012 01:55 AM

January 23, 2012

Simone Giannecchini

GWT-OpenLayers release 0.7

Dear All,
we would like to inform you that the new release 0.7 for the GWT-OpenLayers project is available.

The releases is ready for the download and can be found here.

Notable improvements with this release are as follows:
  • Upgrade to GWT 2.4.0
  • Support to Google Maps V3
  • Improved source code formatting
  • Added and fixed several base methods and bindings such WMS Params, Layer methods
Alessio Fabiani has taken care of the 0.7 release as an active committer and administrator of the project.
We would like to thank all the other committers for their dedication and hard work!

Regards,
the GeoSolutions Team.

by afabiani (noreply@blogger.com) at January 23, 2012 05:53 PM

Jackie Ng

Updated OSGeo Nabble archive link

Those of you who prefer a forum-based frontend to the mapguide-users and other OSGeo mailing lists probably had warning about the migration of the OSGeo mailing list archives by nabble.

Well, in addition to breaking every existing mailing list link (I bet you all the nabble posts I've linked from this blog are completely broken now!), the old archive no longer gives you the link to the new archive location. Real smart move by Nabble!

Well in case anyone is wondering, here's the new link before nabble took it down along with the old archive: http://osgeo-org.1560.n6.nabble.com/

What's even funny is the notice at the top of the new archive location

We have moved the OSGeo.org archives to this location. Please update your bookmarks.

And just who is going to be able to read that? Certainly not the people who have been inconvenienced by this ill-thought out move!

/rant

by Jackie Ng (noreply@blogger.com) at January 23, 2012 01:57 PM

Jackie Ng

How to: Use mg-desktop in your own .net applications

Here I am, talking about mg-desktop and how it's the next best thing since sliced bread, but I haven't even explained how you can go about using it in your own .net applications! This post aims to rectify this problem.

This post will aim to show you how to create a simple .net WinForms application that displays a map from the Sheboygan sample data set with a basic selection handler. The final application will look like so:



Before we get started, make sure you have the following:
  • Visual Studio 2008 or newer (I'm using the express edition for this post)
  • The latest binary release of mg-desktop
Knowledge of the official MapGuide .net API is also assumed here because most of what you know about the official API is equally applicable to mg-desktop.

So fire up Visual Studio and let's get started!

1. Download mg-desktop

Download the latest binary release of mg-desktop and extract this archive to a directory of your choice. We will be referring to files in this location for the rest of this post.

2. Set up the Visual Studio Toolbox

In order to facilitate drag-and-drop of the map viewer component, we need to register the mg-desktop viewer component into the Visual Studio Toolbox. To do this, right click the toolbox and select Choose Items



This will bring up the Choose Toolbox Items dialog, click the browse button


Browse to the directory you extracted mg-desktop into and select the OSGeo.MapGuide.Viewer.dll assembly. This will add our viewer components to the list of available components.

The components for reference, are:
  • MgMapViewer - This is the map viewer component
  • MgLegend - This is the legend component which can control the display and visibility of layers in the map viewer. This component is optional
  • MgPropertyPane - This is the component for displaying attributes of selected features on the map viewer. This component is optional
  • MgDefaultToolbar - This is a component containing a common list of functions for interacting with the map viewer (zoom, pan, select, etc). This component is optional. You can roll your own map viewer toolbar, but that requires a lot of boilerplate to set up. This component is provided for convenience.


Ensure these components are ticked and click OK to add these components to the Visual Studio Toolbox. 

3. Create a new WinForms project

NOTE: The mg-desktop map viewer is a WinForms component. You can technically use this component in a WPF application using the WPF-WinForms interop libraries, but that is beyond the scope of this tutorial.

Now we create our WinForms application. Select File - New Project and select the Windows Forms Application template.


4. Build our main form

If you look at the Visual Studio Toolbox, your components should now be visible whenever the WinForms designer is active



Drag and drop the MgDefaultToolbar component into the main form



Now drag and drop a StatusStrip component into the main form. 



Add 4 labels to this status strip. These labels will be used to show the following:
  1. The current mouse coordinates
  2. Any status messages sent by the viewer
  3. The current scale
  4. The size of the map



Now add a SplitContainer to the main part of the form




Add a second SplitContainer to the left side of this form with horizontal orientation




Now we can drag and drop the remaining components. Set all components to Dock = Fill to occupy the full space of its container
  • Drag and Drop the MgLegend to the top-left panel
  • Drag and Drop the MgPropertyPane to the bottom-left panel
  • Finally, drag and drop the MgMapViewer to the main panel



Modify the properties of the lblMessage label as such:
  • Spring = true
  • TextAlign = MiddleLeft
This will ensure this label takes the maximum space in the status bar




Now we need to write some code.

5. Wire-up the viewer components

Now switch to the code view for Form1. Start by adding importing the OSGeo.MapGuide.Viewer namespace

   1:  using OSGeo.MapGuide.Viewer;

To show map viewer status messages, we need this form to implement the IMapStatusBar interface. This adds the following methods to our form

   1:  public void SetCursorPositionMessage(string message)
   2:  {
   3:      
   4:  }
   5:   
   6:  public void SetFeatureSelectedMessage(string message)
   7:  {
   8:      
   9:  }
  10:   
  11:  public void SetMapScaleMessage(string message)
  12:  {
  13:      
  14:  }
  15:   
  16:  public void SetMapSizeMessage(string message)
  17:  {
  18:      
  19:  }

These methods should be self explanatory. Simply connect the message parameter to its respective label

   1:  public void SetCursorPositionMessage(string message)
   2:  {
   3:      lblCoordinates.Text = message;
   4:  }
   5:   
   6:  public void SetFeatureSelectedMessage(string message)
   7:  {
   8:      lblMessage.Text = message;
   9:  }
  10:   
  11:  public void SetMapScaleMessage(string message)
  12:  {
  13:      lblScale.Text = message;
  14:  }
  15:   
  16:  public void SetMapSizeMessage(string message)
  17:  {
  18:      lblSize.Text = message;
  19:  }

Now how do we tie all of these components (viewer, toolbar, legend, property pane) together? We use a MapViewerController to do this. Override the OnLoad method like so:

   1:  protected override void OnLoad(EventArgs e)
   2:  {
   3:      new MapViewerController(mgMapViewer1,          //The MgMapViewer
   4:                              mgLegend1,             //The MgLegend
   5:                              this,                  //The IMapStatusBar
   6:                              mgPropertyPane1,       //The MgPropertyPane
   7:                              mgDefaultToolbar1);    //The MgDefaultToolbar
   8:  }

That one line (5 if you want to be pedantic), magically ties all our viewer components together. The MapViewerController basically handles all the plumbing so that your viewer components will properly communicate with each other. Some examples, include:
  • Selecting an object in the MgMapViewer will populate the MgPropertyPane with attributes of the selected feature
  • Ticking a layer on/off in the MgLegend will trigger a refresh of the MgMapViewer
The MapViewerController automagically sets up all of this for you.

Now we have a viewer that's all set up, now to load some data into it. 

6. Code - Initialization

Before we show you how to do this, let's take a segway for a moment. Because we need to cover an important aspect of the mg-desktop API. 

Like the official API, the mg-desktop API is driven by service classes. In mg-desktop, the following services are provided:
  • MgdResourceService (inherits from MgResourceService)
  • MgdFeatureService (inherits from MgFeatureService)
  • MgRenderingService
  • MgDrawingService
  • MgTileService
In the official API, you would access these services via a MgSiteConnection object. For mg-desktop we use the MgServiceFactory class to create instances of these services. For example, here's how you would create an instance of MgdFeatureService

   1:  MgServiceFactory factory = new MgServiceFactory();
   2:  MgdFeatureService featureService = (MgdFeatureService)factory.CreateService(MgServiceType.FeatureService);

Other service classes are created in a similar fashion. You would then use these service classes in the same fashion as you would with the official API.

Also like the official API, we need to initialize the whole thing through a config file first before we can use any of the classes in the API. In our case, the file is Platform.ini, and we initialize like so:

   1:  MgPlatform.Initialize("Platform.ini");

With that out of the way, we can start writing some code. First we need to add some references to the project. Add the following references from your mg-desktop directory
  • OSGeo.MapGuide.Foundation.dll
  • OSGeo.MapGuide.Geometry.dll
  • OSGeo.MapGuide.PlatformBase.dll
  • OSGeo.MapGuide.Desktop.dll
  • OSGeo.MapGuide.Viewer.Desktop.dll
Be sure to set these references (and OSGeo.MapGuide.Viewer) to (Copy Local = false)

Now in our application's entry point, insert our call to initialize the API. Also hook the application's exit event to MgPlatform.Terminate(), which does some library cleanup. Program.cs should look like this

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Windows.Forms;
   5:  using OSGeo.MapGuide;
   6:   
   7:  namespace MgDesktopSample
   8:  {
   9:      static class Program
  10:      {
  11:          /// <summary>
  12:          /// The main entry point for the application.
  13:          /// </summary>
  14:          [STAThread]
  15:          static void Main()
  16:          {
  17:              MgPlatform.Initialize("Platform.ini");
  18:              Application.ApplicationExit += new EventHandler(OnApplicationExit);
  19:              Application.EnableVisualStyles();
  20:              Application.SetCompatibleTextRenderingDefault(false);
  21:              Application.Run(new Form1());
  22:          }
  23:   
  24:          static void OnApplicationExit(object sender, EventArgs e)
  25:          {
  26:              MgPlatform.Terminate();
  27:          }
  28:      }
  29:  }


7. Code - Load a package and map


Now back in our main form, we modify the overridden OnLoad to do the following:
  • Check the existence of the map we want to load -  Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition
  • If it doesn't exist, prompt the user for the Sheboygan.mgp package and load this package
   1:  MgServiceFactory factory = new MgServiceFactory();
   2:  MgdResourceService resSvc = (MgdResourceService)factory.CreateService(MgServiceType.ResourceService);
   3:  MgResourceIdentifier mapDefId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
   4:  //If this map definition doesn't exist, we ask the user to
   5:  //load the Sheboygan package
   6:  if (!resSvc.ResourceExists(mapDefId))
   7:  {
   8:      using (OpenFileDialog diag = new OpenFileDialog())
   9:      {
  10:          diag.Filter = "MapGuide Packages (*.mgp)|*.mgp";
  11:          if (diag.ShowDialog() == DialogResult.OK)
  12:          {
  13:              MgByteSource source = new MgByteSource(diag.FileName);
  14:              MgByteReader reader = source.GetReader();
  15:              resSvc.ApplyResourcePackage(reader);
  16:          }
  17:          else
  18:          {
  19:              //No map, nothing to do here
  20:              Application.Exit();
  21:          }
  22:      }
  23:  }

At this point, the map definition exists. So we can create a runtime map and load it into the viewer like so:

   1:  //Create our runtime map
   2:  MgdMap map = new MgdMap(mapDefId);
   3:  //We need a rendering service instance
   4:  MgRenderingService renderSvc = (MgRenderingService)factory.CreateService(MgServiceType.RenderingService);
   5:  //Create our viewer provider
   6:  MgMapViewerProvider provider = new MgDesktopMapViewerProvider(map, resSvc, renderSvc);
   7:  //Initialize our viewer with this provider
   8:  mgMapViewer1.Init(provider);

The final OnLoad method for our form looks like so:

   1:  protected override void OnLoad(EventArgs e)
   2:  {
   3:      new MapViewerController(mgMapViewer1,          //The MgMapViewer
   4:                              mgLegend1,             //The MgLegend
   5:                              this,                  //The IMapStatusBar
   6:                              mgPropertyPane1,       //The MgPropertyPane
   7:                              mgDefaultToolbar1);    //The MgDefaultToolbar
   8:   
   9:      MgServiceFactory factory = new MgServiceFactory();
  10:      MgdResourceService resSvc = (MgdResourceService)factory.CreateService(MgServiceType.ResourceService);
  11:      MgResourceIdentifier mapDefId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
  12:      //If this map definition doesn't exist, we ask the user to
  13:      //load the Sheboygan package
  14:      if (!resSvc.ResourceExists(mapDefId))
  15:      {
  16:          using (OpenFileDialog diag = new OpenFileDialog())
  17:          {
  18:              diag.Filter = "MapGuide Packages (*.mgp)|*.mgp";
  19:              if (diag.ShowDialog() == DialogResult.OK)
  20:              {
  21:                  MgByteSource source = new MgByteSource(diag.FileName);
  22:                  MgByteReader reader = source.GetReader();
  23:                  resSvc.ApplyResourcePackage(reader);
  24:              }
  25:              else
  26:              {
  27:                  //No map, nothing to do here
  28:                  Application.Exit();
  29:              }
  30:          }
  31:      }
  32:   
  33:      //Create our runtime map
  34:      MgdMap map = new MgdMap(mapDefId);
  35:      //We need a rendering service instance
  36:      MgRenderingService renderSvc = (MgRenderingService)factory.CreateService(MgServiceType.RenderingService);
  37:      //Create our viewer provider
  38:      MgMapViewerProvider provider = new MgDesktopMapViewerProvider(map, resSvc, renderSvc);
  39:      //Initialize our viewer with this provider
  40:      mgMapViewer1.Init(provider);
  41:  }

7. Set up post-build and other loose ends


Now if you've worked with the official MapGuide .net API (and this whole post assumes you do), you know that referencing the MapGuide .net assemblies does not instantly give you a working MapGuide application. That's because those .net assemblies are managed wrappers around unmanaged dlls, so you need them as well. So for the official API, you would copy all the dlls from mapviewernet into your application's output directory so that all dependencies are met.

For mg-desktop, we pretty much do the same thing, we copy everything from our mg-desktop directory to our application's output directory. Or to automate this, include an xcopy command as part of your project's post build event. Assuming you extracted the mg-desktop binaries to C:\mg-desktop, and example post build command would be like so:


This will copy all mg-desktop files (dlls, FDO, CS-Map dictionaries, etc, etc) to your application's output directory with the source directory structure intact, which is important because the default paths in Platform.ini are all relative.

If you are on a 64-bit machine, you will also need to explicitly set the CPU type of the application to x86 instead of Any CPU. If you don't do this, you will get a BadImageFormatException thrown at your face as your executable will default to 64-bit and will attempt to load a 32-bit assembly. Actually, you should do this anyway to ensure the application works on both 32-bit and 64-bit windows.

Once this is all set up, you can compile and run your application!


Go on. Have a play around. It is now a fully functional map viewer application!

8. Custom selection handling


One of the things you would probably want to do in your application is to listen for selection changes and run code in response to such changes. The MgMapViewer component exposes a SelectionChanged event for this very purpose.

So to display the address of a selected parcel, the event handler code would look like this:

   1:  private void mgMapViewer1_SelectionChanged(object sender, EventArgs e)
   2:  {
   3:      MgSelectionBase selection = mgMapViewer1.GetSelection();
   4:      MgReadOnlyLayerCollection layers = selection.GetLayers();
   5:      if (layers != null)
   6:      {
   7:          for (int i = 0; i < layers.GetCount(); i++)
   8:          {
   9:              MgLayerBase layer = layers.GetItem(i);
  10:              if (layer.Name == "Parcels") //The selected layer is parcels
  11:              {
  12:                  //Check that we only have one selected object
  13:                  int count = selection.GetSelectedFeaturesCount(layer, layer.FeatureClassName);
  14:                  if (count == 1)
  15:                  {
  16:                      MgFeatureReader reader = null;
  17:                      try
  18:                      {
  19:                          reader = selection.GetSelectedFeatures(layer, layer.FeatureClassName, false);
  20:                          if (reader.ReadNext())
  21:                          {
  22:                              //Address is in the RPROPAD property
  23:                              if (reader.IsNull("RPROPAD"))
  24:                                  MessageBox.Show("Selected parcel has no address");
  25:                              else
  26:                                  MessageBox.Show("Address: " + reader.GetString("RPROPAD"));
  27:                          }
  28:                      }
  29:                      finally //You must always close all readers, otherwise connections will leak
  30:                      {
  31:                          reader.Close();
  32:                      }
  33:                  }
  34:                  else
  35:                  {
  36:                      MessageBox.Show("Please select only one parcel");
  37:                  }
  38:                  break;
  39:              }
  40:          }
  41:      }
  42:  }

Which would result in this behaviour when selecting a parcel


Selecting multiple parcels gives you the following:


Wrapping up


Hopefully this should give you a comfortable introduction to mg-desktop and its viewer component. Where you go from here is completely up to you.

The source code for this example is available for download here

by Jackie Ng (noreply@blogger.com) at January 23, 2012 12:49 PM

Slashgeo (FOSS articles)

Slashdot Discussion: Open Source vs Proprietary GIS Solution?

Ok, I'm almost back behind the helm and I expect it's going to take me at least a week to catch up the geonews, but you'll get them.

During my absence last week, Slashdot ran a discussion named Ask Slashdot: Open Source vs Proprietary GIS Solution?

Their summary: "As the Project Manager for a non-profit looking to implement a tech project, I am running into a few dilemmas, and as a casual Slashdotter I could really use some help. I'll start with a brief explanation of the project. We research issues in Canadian Immigrants, and found that there was a lack of recent, unaggregated information. As we dug further, we found that some data was available, but there was no central repository. Therefore, we are building a web based service to collect this data, with the intent of having it display in Google Maps and then be downloadable as a CSV file that is readable in GIS software such as ESRI Arcsoft, so that data may be visualized."

Like a lot of Slashdot discussions, the value is in the moderated comments.

by Alex at January 23, 2012 03:46 AM

January 21, 2012

Maning Sambale

Helium high

Today, we had a balloon mapping experiment. For a very brief airtime, we got some really impressive images. Selecting and stitching the images took more time. But, the initial result gave as a much better imagery than what is publicly available. The crew had a great time. No tangles, no balloon burst and no gear [...]

by maning at January 21, 2012 01:39 PM

Nathan Woodrow

QGIS support for MS SQL Server 2008 – Coming Soon!

Good news!

Support for MS SQL Server 2008 in QGIS is coming soon.   A native QGIS provider for MS SQL Server is currently being worked on to make using, managing, and editing SQL Server data in QGIS just as easy as PostGIS.

The work is being sponsored by the Australian company Digital Mapping Solutions. So a very big thanks to them for this great feature!

There is no ETA on when it will be added to the main QGIS build, but the provider is currently in testing stage and hopefully will be in there soon.

So if you have been itching to try SQL Server data in QGIS, hang in there as a good solution is just around the corner.

P.S The other blog posts on this topic I used ogr, this method will still work fine after the native provider is added, however the native driver will add a nicer interface including integration into the QBrowser, better optimization for the QGIS code, and hopefully same feel as the PostGIS experience.


Filed under: Open Source, qgis Tagged: digital mapping solutions, FOSSGIS, gis, ms sql server, MS SQL Server 2008, MS SQL Spatial, ogr, Open Source, qgis, Quantum GIS

by Nathan at January 21, 2012 12:22 AM

January 19, 2012

Free and Open Source GIS Ramblings

A Guide to Beautiful Reliefs in QGIS

This week Sourcepole released a new addition to the Raster Terrain Analysis plugin: a sophisticated Relief tool. (More info in their announcement) This plugin is shipped with QGIS (developer version, not in 1.7.3 release) by default but you might have to activate it in Plugin Manager:

The plugin dialog is quite self-explanatory. You can chose the elevation file, output path and any of the numerous raster formats. The z factor is a bit more mysterious. We will have a look at that in a second. The rest of the dialog is the relief color editor. Pressing Create automatically will give you a color gradient to start with.

Relief tool dialog

But what’s the z factor good for?

I’ve tried a few different settings using free NASA SRTM data and it seems that higher values lead to a smoother relief (Please ignore the water areas):

z factor = 100 z factor = 1000 z factor = 10000 z factor = 50000 z factor = 100000

Update:

As Marco noted in the comments: The z factor is used if the x/y units are different from the z unit.

  • If everything is in meters, use z factor 1.0 (default).
  • If x/y is in degree and z in meters, use z factor 111120.
  • If x/y degree and z is feet, use z factor 370400.

In the example above SRTM rasters are in WGS84 with heights in meters. That’s why the result using a z factor of 100000 looks so good.

In my opinion the results look great even with the coarse SRTM dataset I used. Looking forward to all the great QGIS maps we will see in the future.


by underdark at January 19, 2012 08:06 PM

January 18, 2012

Jackie Ng

mg-desktop has moved

With the implementation of MapGuide RFC117, I have finally migrated the source code for mg-desktop from its current home at Google Code to the official MapGuide Subversion repository

This migration allows for the mg-desktop codebase to better integrate with the MapGuide source that it builds on top of, and allows mg-desktop to receive upstream component fixes and updates much faster and allows for sharing of component dlls with future releases of MapGuide.

Also with everything together in one place, I can finally tackle some of the more interesting things like 64-bit and Linux builds and support for the VS2010 compiler.

The existing Google Code site will remain for archival purposes, but all mg-desktop development will now take place on the official MapGuide repo.

Since we're on the subject of mg-desktop, I might as well show you a visual changelog of the changes and features added to mg-desktop since I first announced it. Most of these changes I am showing in this post are centered on the map viewer component (otherwise there wouldn't be much to show :-)). So without much further ado:

1. Tooltip queries can slow down map interaction, so the default viewer toolbar now includes a command allowing you to toggle display of feature tooltips.


2. The viewer supports customizable selection color


3. To facilitate rapid development, the viewer component works with the Visual Studio designer infrastructure. Viewer properties and behaviour can be modified like you would any other form or control. The OSGeo.MapGuide.Viewer.dll must be registered with the Visual Studio Toolbox to support this workflow.


4. The default viewer toolbar has more useful commands such as:
  • Copying the current view of the map to the clipboard (as an image)
  • Selecting by radius and polygon



5. The legend control now functions like the one in the AJAX or Fusion viewer. Supporting display of themes, and having the ability to apply theme compression (because it too has problems with processing ridiculously large themes)


6. Layer and Group items in the legend control can have context menus attached to them


7. Like the AJAX and Fusion viewers, the property pane supports scrolling through the results of a selection set and zooming into individual results



At this point we have something approaching 90% of the functionality of the AJAX and Fusion viewers. The missing 10% are apparent once you see it:

  • No support for tiled maps. The viewer control has a property that allows tiled maps to be treated as regular groups of dynamic layers as a workaround. The math to calculate what tiles to fetch escapes me right now.
  • No mouse wheel zoom. The math to do this also escapes me right now.
If these items aren't dealbreakers for you, then mg-desktop is a more than suitable platform for building disconnected desktop mapping applications using the same MapGuide and FDO technology that you are all familiar with.

by Jackie Ng (noreply@blogger.com) at January 18, 2012 05:53 PM

Jo Cook

Personal musings on the authority of OpenStreetMap

There has been a lot of fairly excitable posting recently about the continuing rise of OpenStreetMap, and how it’s now being used in place of Google Maps,  in particular since Google started charging for data. People have been talking about how “authoritative” crowd-sourced spatial data can be, and to be honest, I’ve found that the discussions seem to have missed the point a little bit. For me at least. So- here’s a few of my personal thoughts about OpenStreetMap and why it will be a while before I will consider it authoritative at least.

Firstly, a caveat. I love OpenStreetMap data and the whole ecosystem of “stuff” that has evolved around it. I contribute occasionally, though not as often as I’d like to. I’m pleased that it has forced the “traditional” data providers to reconsider what they offer, and perhaps to raise their game. I think it’s one of the main reasons why the idea of “open data” is so well known that even my Gran knows about it.

However, in the process of trying out WalkingPapers (my favourite addition to the OpenStreetMap ecosphere), I printed out the area around my house- in the centre of Lancaster. Not London, I admit, but still in the centre of a city. My road wasn’t on there. Read on, before you give up in disgust, saying “pah, you should just correct any errors you find”. How did I know my road was missing? There wasn’t an unfinished stub, with a note saying “I went home for my tea and I’ll finish this section tomorrow”, it was as if my road did not exist. I only knew my road was missing because I live there, and I have no readily available tools to help me judge the accuracy of an area that I am not familiar with. So, the idea that the end-user should correct any errors they find doesn’t really hold because you’re not always going to know that there’s an error!

I am aware that the traditional data providers do not produce totally error-free data. However, I would expect Ordnance Survey (for example) to have a workflow for their surveyors that doesn’t allow them to simply give up when they get bored or have to go home for their tea, or perhaps not survey a street because they don’t go down it very often.  I can also go to the site and find published information on positional accuracy if I need it. I guess I’m equating “authority” with trust, or reliability, and the issue is less about what’s there, than what’s not there.

When OpenStreetMap is being used as a static base map, by which I mean a backdrop to the information your map is really about, this is less of an issue. But, if like me, you come from a discipline where maps are collections of data to be manipulated and analysed, then you need to be able to trust your data a little more, or at least have a quantitative understanding of what the error is likely to be.

I know that this is not an easy question to answer, and I know people are trying to figure out ways of answering it. I also know it’s not that important for a lot of people, but I would like to see a more nuanced debate- I think that would be better for OpenStreetMap in the end.

by Archaeogeek at January 18, 2012 04:49 PM

Jackie Ng

Some useful tools for debugging your MapGuide Applications

A common problem with MapGuide development is trying to dig into the state of the runtime map, especially when trying to figure out why the new layer you've added to your runtime map is not showing. Here's some useful tools to help you peek into the runtime map.

1. mapinfo.aspx


Get the script here (you will also need the supporting viewresourcecontent.aspx script as well)


This was a script I wrote while porting over the MapGuide Developer's Guide samples to .net (which will be bundled with the next MapGuide Open Source release in *all* languages, instead of just PHP) to help me debug a mysterious bug where newly added layers are shown on the map, but not in the viewer legend. The script accepts two URL parameters:

  • MAPNAME - The name of the runtime map
  • SESSION - The current session id
Invoking this script, gives you a nice detailed view about the state of the given runtime map

You'll notice that the resource ids are hyperlinked. These links call into viewresourcecontent.aspx, which basically shows you the resource content of the hyperlinked resource id.

To set this up, drop mapinfo.aspx and viewresourcecontent.aspx into a directory of your choice. Set this directory up as an application in IIS, then create a bin directory and drop in the MapGuide dlls from your mapviewernet directory.

Then to invoke this script, enter http://url-to-your-directory/mapinfo.aspx?MAPNAME=theMapName&SESSION=your-mapguide-session-id

Because this script takes a MAPNAME and a SESSION parameter. It can automatically be used as an Invoke URL command in your Web Layout. Just create an Invoke URL command that points to mapinfo.aspx, attach it to a toolbar or menu and it is ready to be used in your Web Layout for instant debugging!

2. Runtime Map Inspector

Coming in the next release of Maestro, is a Runtime Map Inspector tool which fulfils the same purpose as mapinfo.aspx. Invoking the tool will bring up the familiar Maestro login (which you are advised to use the Administrator login as that can peek into any user's session repository). Once logged in, a new window will appear where you can fill in the required Map Name and Session ID and then click the Load Map button to bring up the runtime map.


The Runtime Map Inspector will be available in the next release under Tools - Runtime Map Inspector, or by running the RtMapInspector.exe


Hopefully, these new tools will make your MapGuide development experience that much more simpler (if it isn't already!)

by Jackie Ng (noreply@blogger.com) at January 18, 2012 04:47 PM

OpenGeo Blog

GeoExt Code Sprint – Spring 2012

OpenGeo is always eager to help advance open source geospatial software projects. When Andreas Hocevar told us that the GeoExt community was planning a code sprint for GeoExt 2.0 we were happy to get involved. The sprint is still in the planning stages and, unfortunately, not fully funded. Though many have contributed, we’re hoping others will join us in sponsoring this event.

GeoEXT and ExtJS 4
GeoExt enables building desktop-like GIS applications through the web. It is a Javascript framework that combines the GIS functionality of OpenLayers with the user interface of the ExtJS library provided by Sencha. GeoExt currently works with ExtJS 3 but that does not utilize the new features in ExtJS 4 (charting, harmonized API with Sencha Touch for mobile applications, and others). The upcoming code sprint will target developing GeoExt 2.0 to work with ExtJS 4 in order to leverage the newest features.

Participants
Representatives from the following companies have confirmed attendance and sponsorship:

These organizations have provided core developers for GeoExt 1.x and have experience as service providers building applications with ExtJS 4. We’re excited to work with them again as we help develop GeoExt 2.0

Sponsor search
A week-long gathering of eight developers calls for a budget of $52,000. This covers travel, accommodations and partly the developers themselves. While much of this cost is being borne by the participating organizations we have not been able to close the gap.

We are looking for sponsors to help. Sponsors will be named explicitly and are encouraged  to input their priorities for desired functionality in GeoExt 2.0.

Call for sponsorship
The participating organizations would like to invite all organizations and users utilizing GeoExt to sponsor the code sprint. Becoming a sponsor ensures the benefits from the new functions that will be implemented.

If you have questions or interest in sponsoring the code sprint please contact us at inquiry@opengeo.org

by David Dubovsky at January 18, 2012 03:30 PM

Jude Mwenda

A Perspective on East Africa’s Developer Remuneration-(Kenya)

It been ages! I know and I am sorry. Things got buffallo and thick. Reminds me of Dj Watene of Strathmore school. Well this has been a pending post until we had this conversation with one @g33kmate. Now my sample space consisted of people who filled in a questionnaire(ex campus mates). If you did not …

Continue reading »

by Jude Mwenda at January 18, 2012 03:50 AM