I'm currently trying to draw charts with the help of SQL Anywhere's spatial data support and its SVG output methods. To combine several geometries into one document, I have to use the ST_AsSVG() method with the 'PathDataOnly=Yes' format specifier.

Now, when using ST_MultiPoint to draw sets of points, the according ST_AsSVG() method seems to deliver data for a SVG path element. While this works generally, when using a larger scale, the points are not visible as they are rendered by drawing a very narrow square (of 0.002 coordinates length).

So typically the method returns data like:

M 738,-2045 l 0.002,0 0,0.002 -0.002,0 Z
M 1365,-1432 l 0.002,0 0,0.002 -0.002,0 Z
M 2415,-1278 l 0.002,0 0,0.002 -0.002,0 Z
M 2460,-818 l 0.002,0 0,0.002 -0.002,0 Z

Obviously, the point coordinates are much larger (in my case, between 200 and 10,000) than the square dimensions.

When I manually modify the SVG data to use a larger square to draw, say by replacing "l 0.002,0 0,0.002 -0.002,0 Z" with "l 2,0 0,2 -2,0 Z", the points are drawn correctly.

Question: Is there a way (e.g. a format specifier) to adapt the square width for the ST_MultiPoint::ST_AsSVG() method?

For the moment, I have chosen to use single points instead of multipoints though this enlarged the SVG file significantly.

(For the record: Jason's blog article "SQL Graph Paper" was a great starting point - thanks!)

asked 21 Jun '11, 05:25

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

Just to add: Increasing the "stroke-width" attribute of the path element does not help.

That being said, I'm fairly new to SVG so any help...

(21 Jun '11, 05:31) Volker Barth

When using just path data there is no way to represent a point, thus the small square.

The simplest way to combine several geometries into one SVG document is to use:

select ST_Geometry::ST_ASSVGAggr( geometry_column ) from geometry_table;

If you must use PathDataOnly=Yes, then one way to workaround the problem you are seeing is to generate the SVG path data, and use REPLACE( generated_svg_data, '0.002', 2 ) before outputting the SVG document. Unfortunately, it is a bit of a kludge and isn't guaranteed to work in the future.

permanent link

answered 21 Jun '11, 09:14

Ian%20McHardy's gravatar image

Ian McHardy
accept rate: 40%

Well, as I'm drawing charts, I have to add several text elements (axis description, scale and the like) to the geometrical objects. Adding texts is beyond SQL Anywhere's spatial support, isn't it?

Therefore I think I have to build lots of parts of the document manually. REPLACE() would work but the "single point solution" works pretty well (once I had incremented DBISQL's truncation length...).

BTW: Wouldn't it be an alternative to return points/multipoints as circle elements instead of pathes?

(21 Jun '11, 09:36) Volker Barth
Replies hidden

Given that you need to add text elements, I believe you are correct that you need to use PathDataOnly=Yes. Perhaps we could add another SVG format parameter 'PathDataPointWidth' that specifies the point width/diameter for points generated with PathDataOnly=Yes.

I'm not sure what you mean by the "single point solution".

Unfortunately, the SVG circle element cannot be used within path data.

(21 Jun '11, 10:39) Ian McHardy

By "single point solution" I mean that I do not use ST_MultiPoint but add each point on its own in the way ST_Point.ST_AsSVG() with PathDataOnly=No creates point data - it does not create a path element but a rect element, and as such the minimal square size doesn't apply. FWIW, I just used the same values as ST_AsSVG() does - here for the point (10 200):

<rect width="0.1%" height="0.1%" stroke="black" stroke-width="0.4%" x="10" y="-200"/>

(Note: In contrast, ST_Point.ST_AsSVG() with PathDataOnly=Yes does create path element data even for single points, i.e. in the same way as multipoints.)

(21 Jun '11, 11:00) Volker Barth

And obviously I could use circle elements in a comparable fashion...

(21 Jun '11, 11:02) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 21 Jun '11, 05:25

question was seen: 2,652 times

last updated: 21 Jun '11, 11:02