| FOSSLC is a non-profit organization that specializes in technology and know-how to record conferences with excellent quality. Click on the icons below to view great videos from communities we are actively involved with: | ||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||
New AsGML Implementation Plan
A recap of our obstacle:
The original plan to implement the asGML/asKML/asJSON functions for Ingres Geospatial was to build Ingres with GDAL(OGR) library and use GDAL(OGR) library's existing as* functions (WKB->OGR GEOM->GML/KML/JSON). However, after we implemented the functions in aduspatial.c with the as* functions and tried to build Ingres, the generated libraries (libq.so, libframe.so ,etc...) would require a link to libgdal.so library in order to call the OGR_ExportAsGML() function. But libgdal.so, when compiled with the withIngres option turned on, actually requires the libq.so and libframe.so libraries to build. So we are faced with the circular link problem to build Ingres with GDAL.
Andrew has decided that trying to build with OGR is not a feasible option and we should move on to implementing the as* functions ourselves.
Implementation Plan:
From this page: http://community.ingres.com/wiki/SpatialFunctions, I have learned that Ingres Geospatial internal GEOM objects are basically just WKB with some additional information. I did a google search on parsers/algorithms to convert WKB to GML directly but no luck. However, after reading through the implementations for other functions (eg. Distance) in aduspatial.c and the GEOS api, I discovered the following:
- The function Distance in Ingres is implemented by calling the GEOS api distance functions on the two Ingres GEOM objects, which are first stripped into WKB and converted into GEOS Geometry objects.
- The GEOS api contains functions that return the actual data for its geometry objects (for example, to get x and y coordinates of a point)
- OGR's convert to gml function has implementation for each type of geometry object, to take in data (eg. x and y) and convert to the corresponding GML string
Therefore, for each of the geometry type listed in http://community.ingres.com/wiki/SpatialFunctions, I could first strip the GEOM to WKB, then convert into GEOS geometry, then obtain the detailed data, and lastly use OGR's code to generate the GML.
I plan to start with making the Point geometry first from start to finish, then move onto the more complicated geometry types. My final exams will finish on December 22th. Here is my planned timeline:
Dec 17th, have GEOM->actual data completed for Point.
Dec 20th, have actual data->gml completed for Point.
Dec 30th, have LineString, LinearRing, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection conversion completed.
Jan 5th, integrate all functions
Jan 7th, finish testing and submit to Andrew
Based on the code I've read so far, I feel that two areas might cause trouble for me:
- Using the OGR functions without the GDAL GEOM objects require knowing the structure for each object, there isn't much documentation so I'd have to figure out myself
- GEOS api also isn't well documented, I would need to figure out myself the data structure for the different geometries (for example, what is a interior ring and exterior ring for a polygon?)
- yorkhua's blog
- Login to post comments








Comments
The GEOS api function stubs
The GEOS api function stubs (although it seems you have already found them) can be found in [geos source dir]/trunk/capi/geos_c.h and for use examples I searched in the aduspatial.c file.
The basic structure for the code will probably be the same as for asText, and if you haven't already, you can simply reference the function geom_to_text in aduspatial.c. You can also reference my changes for AsSVG in this commit: https://github.com/JordanChin89/Ingres/commit/71860f2c85bc658480cf132d4baa701ccff54af0#diff-1
As for polygon, it is described as a single exterior ring, with N number of interior rings (N can be 0) that are used to describe "holes" in the polygon.
By the way, I did not add support for GeometryCollection because postgis does not support them for AsSVG at the moment.
- Jordan