In my django app I have postgis database. I tried to get a polygon as a SVG, so I could represent that polygon in HTML using the SVG standard.
I use the following query: SELECT ST_AsSVG(geom) from country_limit cl where cl.id=3;
And It returned the following result:
M -85.941653 -12.285635 L -85.941653 -12.291673 -85.927577 -12.291673 -85.927577 -12.285635 Z
But when I try to represent that result inside an SVG, in HTML, It does not display the polygon. Here is my code.
<svg height="210" width="400">
<path d="M -85.941653 -12.285635 L -85.941653 -12.291673 -85.927577 -12.291673 -85.927577 -12.285635 Z" />
</svg>
How can I use the result from postgis ST_AsSVG to represent a geometry as SVG in HTML
CodePudding user response:
Your shape is
- very very very small
- outside the usual drawing area since it has negative co-ordinates
Both of these issues can be solved by using an appropriate viewBox.
<svg height="210" width="400" viewBox="-85.942 -12.292 0.05 0.05">
<path d="M -85.941653 -12.285635 L -85.941653 -12.291673 -85.927577 -12.291673 -85.927577 -12.285635 Z" />
</svg>