In order to post questions, answers, or comments, you now need a validated email address. Details on how to validate your address are in the FAQ.

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 Jun 21 '11 at 05:25

Volker%20Barth's gravatar image

Volker Barth
22.2k220331480

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

(Jun 21 '11 at 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.

answered Jun 21 '11 at 09:14

Ian%20McHardy's gravatar image

Ian McHardy
2.0k22236

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?

(Jun 21 '11 at 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.

(Jun 21 '11 at 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.)

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

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

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

Are you providing an answer to the original question, or making a comment on the question or an answer? If you are making a comment please do not post a new answer. Click "Add new comment" on the question or answer instead. If you are responding to a previous comment, click on the "reply" icon (    ) for that comment.

Follow this question

By Email:

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

By RSS:

Answers

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 (indent for sublists):
    1. Foo
    2. Bar
  • bullet list (indent for sublists):
    * Foo
    * Bar
  • to add a line break, add two spaces to where you would like the new line to be.
  • Code blocks should be indented by 4 spaces. SQL code should begin with ":::SQL" on the first line.
  • basic HTML tags are also supported

Tags:

×331
×8
×2

Asked: Jun 21 '11 at 05:25

Seen: 713 times

Last updated: Jun 21 '11 at 11:02

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link: [text](http://url.com/ "title")
  • image: ![alt text](/path/img.jpg "title")
  • numbered list (indent for sublists):
    1. Foo
    2. Bar
  • bullet list (indent for sublists):
    * Foo
    * Bar
  • to add a line break, add two spaces to where you would like the new line to be.
  • Code blocks should be indented by 4 spaces. SQL code should begin with ":::SQL" on the first line.
  • basic HTML tags are also supported