![]() ![]() answer got me most of the way there, but the features that would show on the screen were rounded to the nearest 100th, which looked TERRIBLE. Here's the trouble with rendering SVGs from geospatial data: decimal places. So, after a very long answer, I am basically suggesting that you should not use ST_AsSVG directly for anything other than very quick and dirty SVGs. ![]() As also said, you can use tools like TileMill to do the styling for you (not tested). Geoserver (with a Postgis/vector data source) supports SVG as an output format and you can use SLDs or CartoCSS within Geoserver to style them up, then just request a WMS with SVG as output format and you are done. ((SELECT ST_Envelope(ST_MakeBox2d(ST_MakePoint(0,0), st_makepoint(10,10)))), 3)Īt which point you are probably thinking, TL DR, and it is true this is a lot of work, and the case statements to make the stroke color, width, etc, could get very long and unwieldy. ((SELECT ST_Envelope(ST_MakeBox2d(ST_MakePoint(0,0), ST_MakePoint(10,10)))), 3)įinally, if you wrap all of that in array_to_string and array_agg, and add the head and footer, ie, the and, you will end up with one block of SVG representing all your geometries, eg, WITH shapes (geom, attribute) AS ( For example, WITH shapes (geom, attribute) AS ( This can be accomplished by using the concat operator and a case statement to set the formatting. So, if you want to actually create valid SVG using a Postgis query, you will need to add path tags and color, line, fill, etc formatting. See w3schools SVG Tutorial for more information. ![]() There are other geometry types in SVG, but this is what ST_AsSVG returns (see docs for the Multi version of the same).īy itself, this isn't very helpful, as you are missing the path tags and any styling information, a full example of which would look something like: M means move to, L means line to and Z means close. Which is a point, an unclosed linestring and a closed line, ie, a polygon. For example, a query with a Point, Linestring and Polygon: WITH shapes (geom, attribute) AS The Postgis function ST_AsSVG simply converts geometries into their SVG point or path equivalents, and does not allow you to add any attributes/styling directly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |