Showing posts with label ESRI shape files. Show all posts
Showing posts with label ESRI shape files. Show all posts

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.