Oracle Spatial is an integrated set of functions, data structures, and tables that aid in storing and retrieving spatial data. That data describes shapes and their geometric relationships in two-dimensional, three-dimensional, or four-dimensional space.

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.

Related links

Comments

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

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

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 ... more

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!