Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fc5e811
added command flag to specify svg or png output
SteepAtticStairs Jun 7, 2022
656b57c
re-added renderLabel function
SteepAtticStairs Jun 7, 2022
3493d42
more 'efficient' if statements and timer
SteepAtticStairs Jun 8, 2022
8a5565e
pb is broken
SteepAtticStairs Jun 8, 2022
8d4b796
updated gitignore
SteepAtticStairs Jun 8, 2022
130527d
added webapp to master branch
SteepAtticStairs Jun 8, 2022
204c210
halfhearted fix to svg thick pixel issue
SteepAtticStairs Jun 9, 2022
243ba7b
finally fixed the thick pixel ring
SteepAtticStairs Jun 9, 2022
f02e41a
added radar file downloader to index.html
SteepAtticStairs Jun 9, 2022
8b683c6
added library that does ok job at minifying svg
SteepAtticStairs Jun 10, 2022
a6984b9
removed svg minifier and moved its file because of wasm compiler issues
SteepAtticStairs Jun 10, 2022
bfee57d
added new getbitofsvg function
SteepAtticStairs Jun 10, 2022
261720f
added experimental -v svgtest flag for experimental svg testing
SteepAtticStairs Jun 10, 2022
59dfc11
improved experimental svg
SteepAtticStairs Jun 11, 2022
49fc573
updated webapp with new changes
SteepAtticStairs Jun 11, 2022
002fd68
fixed webapp bug
SteepAtticStairs Jun 11, 2022
e079488
updated webapp help text
SteepAtticStairs Jun 11, 2022
572d337
svgtest flag now creates directory with files for each individual radial
SteepAtticStairs Jun 11, 2022
ed10c12
svgtest now actually generates full svg
SteepAtticStairs Jun 12, 2022
8faa456
radial tweaks
SteepAtticStairs Jun 12, 2022
2166076
small tweaks including transparent png background
SteepAtticStairs Jun 13, 2022
428fd5b
Merge branch 'master' into master
SteepAtticStairs Jun 13, 2022
ddb01bb
updated webapp from new changes bwiggs made
SteepAtticStairs Jun 13, 2022
898a1e9
regex that removes all transparent circle lines
SteepAtticStairs Jun 13, 2022
3190d50
Merge branch 'bwiggs:master' into master
SteepAtticStairs Jun 13, 2022
e28ad80
normal svg rendering now generates around 70 radial files in a directory
SteepAtticStairs Jun 13, 2022
b75b839
added test code to gzip the output svg file
SteepAtticStairs Jun 13, 2022
266ae18
-v svg flag now gzips radar.svg
SteepAtticStairs Jun 13, 2022
5f8a6d0
svg no longer renders transparent colors - huge size reduction
SteepAtticStairs Jun 14, 2022
34f2b2a
added svg changes to webapp
SteepAtticStairs Jun 14, 2022
65a19cd
Merge branch 'bwiggs:master' into master
SteepAtticStairs Jun 14, 2022
75120fe
added leaflet map page to webapp directory
SteepAtticStairs Jun 15, 2022
b915f36
fixed links
SteepAtticStairs Jun 15, 2022
557bd38
gave credit for the geo calculator js file
SteepAtticStairs Jun 15, 2022
41cce71
updated map center bounds function
SteepAtticStairs Jun 16, 2022
69d0635
map page now logs bounding box
SteepAtticStairs Jun 17, 2022
1053901
added function for generating master json of bounding boxes
SteepAtticStairs Jun 17, 2022
48c0cd0
added test code for rendering tif images
SteepAtticStairs Jun 19, 2022
b8a55cf
upload a gzipped tiff file and it will display it
SteepAtticStairs Jun 19, 2022
1e094d4
gzipped tiff tweaks
SteepAtticStairs Jun 19, 2022
d1976b6
reset map page
SteepAtticStairs Jun 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
data/
vendor/
*.png
nids/samples
*.svg
nids/samples
testdata/
.DS_Store
7 changes: 6 additions & 1 deletion cmd/nexrad-render/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
nexrad-render
radials
out/
*.gif
*.png
*.ar2v
*.tar
*.tar
*.wasm
*.gz
*.tar.gz
*.zip
124 changes: 124 additions & 0 deletions cmd/nexrad-render/dump/svgMinify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package main

import (
"fmt"
"io/ioutil"
"log"
"math"
"os"
"strconv"

"github.com/tdewolff/minify/v2"
"github.com/tdewolff/minify/v2/svg"
)

func minifySvg(largeInputFile string, outputFile string) {
// read the input file
content, err := ioutil.ReadFile(largeInputFile)
if err != nil {
log.Fatal(err)
}
text := string(content)
//textSmaller := text[0:100]
//fmt.Println(textSmaller)

// minify the large file
m := minify.New()
m.Add("image/svg+xml", &svg.Minifier{
Precision: 10,
})
//in := "Because my coffee was too cold, I heated it in the microwave."
out, err := m.String("image/svg+xml", text)
if err != nil {
log.Fatal(err)
}

// writes minified content to another file
f, err := os.Create(outputFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
_, err2 := f.WriteString(out)
if err2 != nil {
log.Fatal(err2)
}

// gets the filesize of each file
// large file
largeinfo, err := os.Stat(largeInputFile)
if err != nil {
log.Fatal(err)
}
largeFileSizeInt := largeinfo.Size()
largeFileSize := HumanFileSize(float64(largeFileSizeInt))
//largeFileSize := strconv.Itoa(int(largeFileSizeInt))
// output file
outputinfo, err := os.Stat(outputFile)
if err != nil {
log.Fatal(err)
}
outputFileSizeInt := outputinfo.Size()
outputFileSize := HumanFileSize(float64(outputFileSizeInt))
//outputFileSize := strconv.Itoa(int(outputFileSizeInt))

fmt.Println("Minified", largeInputFile, "(" + largeFileSize + ")", "->", outputFile, "(" + outputFileSize + ")")
}

/*
* Convert bytes to human readable format
* https://hakk.dev/docs/golang-convert-file-size-human-readable/
*/
var (
suffixes [5]string
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
digit := pow * val
_, div := math.Modf(digit)
if div >= roundOn {
round = math.Ceil(digit)
} else {
round = math.Floor(digit)
}
newVal = round / pow
return
}
func HumanFileSize(size float64) string {
//fmt.Println(size)
suffixes[0] = "B"
suffixes[1] = "KB"
suffixes[2] = "MB"
suffixes[3] = "GB"
suffixes[4] = "TB"

base := math.Log(size)/math.Log(1024)
getSize := Round(math.Pow(1024, base - math.Floor(base)), .5, 2)
//fmt.Println(int(math.Floor(base)))
getSuffix := suffixes[int(math.Floor(base))]
return strconv.FormatFloat(getSize, 'f', -1, 64)+" "+string(getSuffix)
}

func getBitOfSvg(inputFile string, outputFile string, firstN int) {
// read the input file
content, err := ioutil.ReadFile(inputFile)
if err != nil {
log.Fatal(err)
}
text := string(content)
textSmaller := text[0:firstN]
//fmt.Println(textSmaller)
// writes minified content to another file
f, err := os.Create(outputFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
_, err2 := f.WriteString(textSmaller)
if err2 != nil {
log.Fatal(err2)
}

fmt.Println("Extracted first", firstN, "chars of svg to", outputFile)
}
Loading