on 2011 Jun 21 6:25 AM
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!)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.
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.)
User | Count |
---|---|
76 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.