Open SteepAtticStairs opened 2 years ago
June 10, 2022 10:30 PM EST
See the original PR comment for more specific details. This comment is meant to provide an easy way to look at my changes, so you don't only have to go digging through my super messy and unnecessarily plentiful commits.
TOTAL COMMITS SO FAR: 15 š¤¦āāļø
Summary of PR so far:
cmd/nexrad-render/main.go
gitignore
s to make working with my input and output files easiersvg
vector rendering, detailed below-v svg
draw2d
library, exactly how a png
image is created, but with svg
options. Highly inefficient, most output svg
s are over 70 MB.radar.svg
-v svgtest
TESTradar.svg
cmd/nexrad-render
called dump
. Contains a file called svgMinify.go
, using the library minify for svg minimization. works ok-ish, 95 MB svg becomes around 70 MB. not the best, and it will not compile into WASM, so I kept the code but moved it into a separate folder so it wouldn't get in the way.webapp
, live demo here
Sorry about this getting closed. I've update the repo to use main
as the new default branch.
June 14, 2022 11:15 PM EST
See the original PR comment for more specific details. This comment is meant to provide an easy way to look at my changes, so you don't only have to go digging through my super messy and unnecessarily plentiful commits.
TOTAL COMMITS SO FAR: 34 š¤¦āāļø
Summary of PR so far (things that have changed / been added since the last summary comment):
-v svg
and -v svgtest
cmd/nexrad-render
called radials
. inside the radials/split
directory there are around 70 svg files, each file containing 10 radials. This is toying with the idea I had where I assumed that if I wanted to render the radar image onto a map, it would be easier for the map to render a lot of smaller images at once than one big image.95 MB
file down to around 60 MB
.-v svg
is now gzipped into radar.svg.gz
, for further compression. Plans to gzip the radials
directory as well.-v png
webapp/map.html
, and a demo can be found here. go-nexrad
. Then, input a radar station and hit Ok
. Finally, press the picture frame button on the left hand side of the map to show and hide the image.JSON
I have here. Calculates a bounding box by getting a point 460 km
to the northwest and 460 km
to the southeast. Loads the uploaded image into that bounding box.
WEBAPP I have made a super rudimentary version of this project using
wasm
, and it was taken almost entirely from go-wasm-pdfcpu.To build the
nexrad.wasm
file yourself, runI struggled a while on Go 1.18 because I was getting some errors, but then I downgraded to 1.12 and it worked fine. Specifically
go version go1.12 darwin/amd64
.Then put the binary under the webapp directory I have made:
These instructions are just if you want to build it yourself. A live demo of what I (but mostly the author of go-wasm-pdfcpu) have done can be found here: https://steepatticstairs.github.io/go-nexrad/webapp/
I plan to do a lot more cleanup.
VECTOR RENDERING
This is very scuffed code, forgive me - I mainly work with JavaScript, not Go! But this is a basic implementation of vector rendering using the
draw2d
library. By passing the-v
flag with argumentspng
orsvg
(png is default), it will generate the relevant file.However, I think there are three major issues with the code I have written. First, the file size of these svg files are extremely large, hovering around 70 MB. I have tried to reduce the DPI, the canvas size, but nothing has worked, so I would like to try and work out a solution in the future. Any suggestions on combatting this issue would be welcome.
Second issue (fixed for now I think??)
Second, the svg image has a slight problem with rendering the pixels closest to the origin. For example, when I generate an svg file from `KLZK20220607_194517_V06` by doing `go run . -f testdata/KLZK20220607_194517_V06 -p ref -v svg`, I get this error right in the middle of the image: As you can see, there is a ring of thick pixels that shouldn't be there. This is **NOT** an issue with PNG rendering.Third, the variables
canvas
andgc
have been replaced withPNGcanvas
PNGgc
andSVGcanvas
SVGgc
, and I will explain that here. I wanted to use anif
statement, basically giving these variables their proper arguments if the user passedpng
orsvg
. For example, the correctcanvas
variable for ansvg
render would bewhile the correct variable for a
png
render would beI wanted to set these dynamically with an
if
statement, ideally something like this:However, the issue with this is that each of these variables using
:=
, which obviously means that they are declared and set in the same line, where they don't require you to specify a type. This will not work here, because you need to define the variables outside of theif
statement. You could do this by writing something likebut this would mean you would have to change the types of
canvas
andgc
for the case that the user renders ansvg
.My solution to this, of course, was to create two separate
draw2d
objects that the program will draw to simultaneously, but only one will get exported to a file š. This, of course, is not the best way to do it, because it slows down the program and it looks quite ugly. Again, any suggestions on combatting this issue would be welcome.Andrew