When English is English is English (or is it?) Building Trust
Jul 12

So you want to add your own data? – DataProviders

There are off course several ways to add your own data to the map. You could write your own dialogues, data handlers etc. and add the resulting data to the map as a featureset or raster. In MW4 one needed to do it like that. MW6 offers a neater solution: It lets you integrate your very own data provider for as exotic data formats as you like to a list of available data providers and these appear as valid data sources in the standard open file dialogue.

The principle way to do this is to add your provider, which must implement the IDataProvider interface, to the list of data providers. This is done by registering it with the data manager that handles all data addition. Using this mechanism you can concentrate on the implementation of your data provider, rather than waste time on the UI elements. Data is also correctly added to the legend and symbolised accordingly.

There is a tutorial on how to add your own RasterDataProvider to MW6 (http://www.mapwindow.org/wiki/index.php/MapWindow6:Examples:IntRasterDataProvider). To complement this tutorial, I shall extend on how to develop a sample XYZ vector data provider, which shall take any file format similar to
X,Y,Z
630014.833,4905371.152,47726.031000000
630014.608,4905371.224,47725.793000000
...

and add it to the map as a Point feature layer.

The shown format is quite arbitrary. In my own implementation I have added a dialogue, where you can specify a number of properties of the file format, such as the field separator, the order of the fields, whether the file has a header line, and whether it contains line numbers or ID fields. Often this format is called CSV; I prefer to call it XYZ, to emphasise the spatial nature of the file, and also, because the comma (as in Comma Separated Values, hence CSV) is by no means common. Often a semicolon is used instead, especially, if data originates in Europe, where the comma often serves a decimal separator. I leave it to your own creativity to accomodate any format that you wish.

I have not yet found the correct way of dealing with unrecognised data, i.e. returning a null-dataset. This will crash the application at the moment. Also, at the time of writing this, I have not found a way to add more than one file at a time, making it a very boring task of adding several to many files of the same kind.

(to be continued)

Leave a Reply

preload preload preload
When English is English is English (or is it?) Building Trust
Jul 12

So you want to add your own data? – DataProviders

There are off course several ways to add your own data to the map. You could write your own dialogues, data handlers etc. and add the resulting data to the map as a featureset or raster. In MW4 one needed to do it like that. MW6 offers a neater solution: It lets you integrate your very own data provider for as exotic data formats as you like to a list of available data providers and these appear as valid data sources in the standard open file dialogue.

The principle way to do this is to add your provider, which must implement the IDataProvider interface, to the list of data providers. This is done by registering it with the data manager that handles all data addition. Using this mechanism you can concentrate on the implementation of your data provider, rather than waste time on the UI elements. Data is also correctly added to the legend and symbolised accordingly.

There is a tutorial on how to add your own RasterDataProvider to MW6 (http://www.mapwindow.org/wiki/index.php/MapWindow6:Examples:IntRasterDataProvider). To complement this tutorial, I shall extend on how to develop a sample XYZ vector data provider, which shall take any file format similar to
X,Y,Z
630014.833,4905371.152,47726.031000000
630014.608,4905371.224,47725.793000000
...

and add it to the map as a Point feature layer.

The shown format is quite arbitrary. In my own implementation I have added a dialogue, where you can specify a number of properties of the file format, such as the field separator, the order of the fields, whether the file has a header line, and whether it contains line numbers or ID fields. Often this format is called CSV; I prefer to call it XYZ, to emphasise the spatial nature of the file, and also, because the comma (as in Comma Separated Values, hence CSV) is by no means common. Often a semicolon is used instead, especially, if data originates in Europe, where the comma often serves a decimal separator. I leave it to your own creativity to accomodate any format that you wish.

I have not yet found the correct way of dealing with unrecognised data, i.e. returning a null-dataset. This will crash the application at the moment. Also, at the time of writing this, I have not found a way to add more than one file at a time, making it a very boring task of adding several to many files of the same kind.

(to be continued)

Leave a Reply

Copyright © Geo-Marine Consult, 2009. All Rights Reserved!