With Oracle Spatial, you would typically define a set of shapes (such as points, lines, rectangles, polygons, or circles); store and register the data in the Oracle Spatial data dictionary; and then issue queries against the data to retrieve information about area, intersections, close relations, and other interpolated information.
Oracle Spatial data is primarily retrieved in very hard-to-read stored objects, such as SDO_POINT and SDO_ORDINATES. It would be useful to extract and manipulate the data directly without needing additional software packages. SVG, generated from the database, could handle this task quite easily as long as an SVG viewer is installed in a browser.
In this article, I'll show a PL/SQL package that, when called via the modplsql interface, will generate enough SVG to view the data used in the simple example from the Oracle Spatial User's Guide, chapter 2. (You can find HTML versions of the User's Guides for each major database version online at the Oracle Technology Network, where you may have to sign in.) The example defines four shapes--a rectangle, two polygons, and a circle--to represent geographical areas of marketing interest for a soft drink manufacturer. To save space, I'll support only the three types of shapes that are in this example. I won't support unit translation (meters to pixels), but I will support scrolling around the image and magnification. I also assume all data is two-dimensional for now.
The biggest challenge in translating the data to something SVG expects is the different ways of representing shapes. For example, Oracle Spatial defines a "circle" by three points along its circumference. This is useful to describe a two-dimensional circle, which may be skewed in a particular direction in three-dimensional or four-dimensional spaces. SVG expects the coordinates of a center point and a radius. The maths required is lengthy but possible, as long as those three points don't lie in a relatively straight line. A minor challenge is the fact that Oracle Spatial tends to describe data in terms of a mathematical graph, with the Y axis in an upward direction, while SVG maps the Y axis in a downward direction, so the entire graph needs to be flipped vertically.
If you install Oracle Spatial, and run the statements from chapter 2 of the Oracle Spatial User's Guide, you'll be able to compile and run the following script from modplsql. I found that "m=20" gave a nice magnification level to fit in the diagram.
Scott Stephens worked for Oracle for more than 13 years in technical support, e-commerce, marketing, and software development.






1
Rich - 30/05/05
Hi Scott,
Where is the cola_markets table and some sample data? Can I get the table ddl and some data as insert statements? Your example willnot work with out the table...
Thanks,
Rich
» Report offensive content