3 ms·
SVG Images from Postgres
- 8organicbits 3y agoThis really could use example visuals.
- uneekname 3y agoI wonder how practical it would be to serve slippy map tiles as SVGs, dynamically generated out of a PostGIS database kind of like this
- tuukkah 3y agoPossible yes, but probably not practical compared to serving unstyled MVT tiles out of PostGIS (ST_AsMVT) and styling them client-side with MapLibre GL JS. SVG with normal CSS is not enough for styling a map in general. For comparison, here's MapLibre style properties for MVT layers: https://maplibre.org/maplibre-style-spec/layers/ https://maplibre.org/maplibre-style-spec/layers/ Perhaps it's also solvable without the MVT tooling, but something to watch out for is what happens at tile edges: a polygon is split into two so you need to render tiles that are a bit larger than what's visible (to hide the extra seam at tile boundary); further, a map label may extend over tile boundary so you need a way to allow for that while avoiding collisions between labels from neighbouring tiles. EDIT: and these are on top of performance issues. Maps are full of detailed geometry where GL leaves SVG far behind.
- Symbiote 3y agoGeometries in MVT are just points, lines and polygons. These may be associated with zero or more key-values. The default 'viewport' (in SVG terms) is 4096x4096px, with geometries extending beyond this to allow for overlapping text labels, etc. SVG could represent anything MVT can -- but files would be much larger, as MVT is optimized to store the data efficiently.
- nologic01 3y agoSVG is such an under-appreciated graphics format. I will expand his great quote about graphics: > a two-dimensional representation to utilize the integrative capabilities of the human visual cortex into: SVG is a re-usable two-dimensional representation of data to utilize the integrative capabilities of the human visual cortex. In a sense canvas, png/jpg etc are to SVG what PDF is to HTML. An information black hole. As an example of the information-retaining quality of SVG representations you could fairly easily imagine the reverse operation: SVG Images TO Postgres.
- masklinn 3y ago> SVG is such an under-appreciated graphics format. SVG is an over-romanticised format. Support for logic makes it a major XSS vector, XML makes it inefficient, and the path langage makes it unreadable.
- asimpletune 3y agoAnd yet compared to the alternatives its advantages outweigh these flaws.
- nologic01 3y ago> the path langage makes it unreadable. at least this part seems over-the top criticism :-) Anything that can capture free-form graphical information will be unreadable. You could represent paths with points but that would make it more inefficient. The thing to keep in mind too is that because it fell out of favor the standard has not really evolved.
- masklinn 3y ago> at least this part seems over-the top criticism :-) Individually the XML and the path format are “fine”, the problem is that they’re both in the same file format. > Anything that can capture free-form graphical information will be unreadable. It’s not the question of being freeform, it’s the weird-ass single-letter command names in an attribute string. In an XML document which is otherwise self-descripting.
- nkozyra 3y agoThe path data is the most complex part of generating shapes in SVG, which is handled by postgis so I don't see a real benefit to installing an extension here.
- solarkraft 3y agoPostGIS is really really cool. I got a small look at it setting it up as a QGis backend and doing more with it is on my list. It feels a bit under-appreciated. Postgres extensions also seem like a bit of a secret weapon.
- mihaic 3y agoTrying not to be negative with any cool project, this feels like the wrong layer in which to build SVG functionality. I mean, if the path can already be generated, an intermediary executable can easily pipe that in and turn into an SVG file. That can be implemented in python, node, rust, whatever and can be given any number of styling options.
- dventimihasura 3y agoSome people might regard having one fewer moving part to be a benefit of just doing it in the database.
- sroussey 3y agoSure, sure. But the real question is, can this be utilized for unexpected use cases?