Sunday, July 31, 2011

Tenth week of GSoC

My main task for this week was to implement the 'Function based search' functionality for geometry data. The rationale is that searching for equality or using simple comparison operators is of very less use when it comes to geometry data types. When effectively used with functions defined for geometry types they create powerful search criterion for searching.

I divided these functions mainly into two groups, 'unary functions', i.e. those that take a geometry object as its argument and 'binary functions', i.e. those that two geometry objects as arguments and  test spatial relations between them. On the implementation side, I initially added a 'Function' column for the geometry columns and with that the user is able to perform searched with 'unary functions'. For example the user choosing function ‘Dimention()’, comparison operator ‘<’ and value ‘2’ would add ‘Dimention(`<column_name>`) < 2’ to the where clause.

Later I extended the same concept to binary functions and for those, the geometry object inserted into the value field(in the form of WKT or WKB) is compared with the geometry object in the related column. To make the insertion of geometry objects for comparison easy, I attached the GIS data editor to it, so the insertion is made easy.

During the week I also fixed some of the bugs that arose in the GIS data editor due to multiple row editor being AJAXified. During the next week I will be engaged in my next task, i.e. 'Exporting GIS data into SVG, PDF and Bitmap formats'. A certain amount of work has been done related to this task and I will be completing it during the coming week.

Sunday, July 24, 2011

Ninth week of GSoC

Ninth week of GSoC was not productive as I wanted it to be. However I managed to stick to my schedule by the end of the week. 

During this week I worked on finalizing the GIS data editor. I integrated the data visualizing capabilities to the editor, so as the user edits the data visual feedback is provided. Similar to the GIS data visualizer, this provides visualizing is done with SVG and for the data related to earth's geography OpenLayers maps are used with data from OpenStreetMaps. For those browsers that do not support SVG, bitmap images are used. Here the visualization is updated with AJAX while the user is editing.


During the coming week I will be working on the 'function based search' feature which would enable GIS users to perform an advances search using the functions provided in MySQL for GIS data.

Sunday, July 17, 2011

Eighth week of GSoC

What I had on schedule for the last week was the GIS data editor. Since I had already started some work on it, basically a version for browsers that does not have JavaScript support enabled, I had a clear idea what I was going to do. During this week I worked on the Ajaxified version of the GIS data editor. The look and feel of it was inspired by the enum editor we have in PMA. 



I worked on the following features.
1) When the users clicks on the pencil icon next to a GIS data field, it asynchronously loads the GIS editor as shown in the image above.
2) When the data type is changed, correct set of input fields are loaded via AJAX and the interfaces is updated.
3) Adding new data points, inner rings, linestrings. polygons are handled with jQuery rather than having to use AJAX
4) When a value is changed the output shown at the bottom is updated.

During the next week I will be working on.
1) Fetching the visualization along with the initial loading of the GIS editor.
2) Updating the visualization when the user changes the data.
As I did previously, I will use both SVG based visualizations and visualizations based on the OpnStreetMaps. For those browsers that do not support SVG (older IE versions), I will use PNG images.

Saturday, July 9, 2011

Seventh week of GSoC

This week was spent on completing the feature 'importing GIS data from ESRI shape files'. Last week I managed to implement this feature for ESRI shape types Point, MultiPoint and PolyLine. Extending this to ESRI shape type Polygon was somewhat complicated. MultiPolygon in MySQL was the corresponding type to ESRI Polyogon. However the representation was quite different. ESRI polygons comprise of one or more outer rings and zero or more inner rings. Inner rings are differentiated from outer ones by their clockwise/anticlockwise orientation.  Hence to import them a proper mechanism to categorize each ring as inner or outer, a way to assign each inner rings to its corresponding outer ring were needed. I implemented identification of clockwise/anticlockwise orientation based on the polygon area calculation and implemented a method to determine whether a given point is inside a given polygon. My strategy was to extract a point on the surface from the inner ring and compare it with each outer to identify the correct outer ring. However I hit a dead end when I found that the MySQL function, PointOnSurface()  is not yet implemented. So I had to implement the functionality myself.

Since importing ESRI shape files involves uploading multiple files, last week, I supported this behavior with 'UploadDir' directory where the user has to upload all the relevant files to this directory before importing. Since this is not always available to the user, this week, I enhanced the feature to use ZIP archives for the same purpose. Now the user can ZIP all the files and upload them in one go and the PMA will unpack the archive to 'TempDir' directory and use these files to import data. 

Since I was bit ahead of my schedule I started implementing the GIS data editor -which is my task for the next week- few weeks back. However it turned out to be that this feature will take more time than I originally anticipated. So I will be working on that feature during the next week.

Sunday, July 3, 2011

Sixth week of GSoC

During this week I mainly focused on importing data from ESRI shape files. Actually, the task specified in my original proposal for this week was 'exporting GIS data in WKT and WKB formats'. However I felt this is of less value to the end user as it would be trivial for him to use AsText() and AsBinary() functions and then do an export. On the other hand letting the user import data from ESRI shape files, which are heavily used in the GIS arena for a quite a long time, would encourage more people to consider MySQL as a spatial database, as data migration is made easy. Hence with consent from my mentor I started working on this feature.

I used bfShapeFiles library to implement this feature. The author of this library has only implemented functionality to manipulate 2D objects in shape files. This was sufficient for our need since MySQL is anyway supporting 2D shapes only. Though it is known as shape files, referring to .shp extension, shape files consist of 3 mandatory files. .shp files contains the spatial data while a .dbf file which contains the additional data. However to manipulate .dbf files one need to have PHP dBase extension and without this only the spatial data can be imported. Right now I am looking for a parser that can be used to manipulate .dbf files without the dBase extension.

Since the import plugin architecture used in PMA is designed in such a way to support raw files as well as compressed ones I had to extend most of the methods in the library to customize it to our requirement. Since only a single file is allowed to upload in the import process, currently, we need to use the UploadDir to upload all 3 files and then use them if we need to capture data in the .dbf file. However I will be working on using ZIP archives to upload multiple files and then use them in the import process.