Geographic aggregation using the map tile index

When dealing with large amounts of scattered data, sometimes we need to provide a read-only query API to visualize on a map. When the amount of data is too large, say millions, it is not appropriate to return it all to the front end for processing on the browser. Some aggregation should be completed within the back-end service to return the aggregated search to the front end. Here’s how to do this with the MongoDB + tile index in Go. ...

 · 2 min · 369 words · ringsaturn

Computing AQI in Go

I write a package named aqi. Install: 1 go install github.com/ringsaturn/aqi For China’s HJ633-2012 standar: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 package main import ( "fmt" "github.com/ringsaturn/aqi" "github.com/ringsaturn/aqi/mep" ) func main() { algo := &mep.Algo{} inputs := []*aqi.Var{ { P: aqi.Pollutant_PM2_5_1H, Value: 16, }, { P: aqi.Pollutant_PM10_1H, Value: 88, }, { P: aqi.Pollutant_CO_1H, Value: 0.2, }, { P: aqi.Pollutant_SO2_1H, Value: 3, }, { P: aqi.Pollutant_NO2_1H, Value: 11, }, { P: aqi.Pollutant_O3_1H, Value: 75, }, } aqi, primaryPollutant, err := algo.Calc(inputs...) if err != nil { panic(err) } levelDesc, err := algo.AQIToDesc(aqi) if err != nil { panic(err) } fmt.Printf("aqi=%v as level=%v with primary pollutant as %v\n", aqi, levelDesc, primaryPollutant) } Output: ...

 · 1 min · 306 words · ringsaturn

Add Mathjax to Hugo

Code copy&paste from Ataias Pereira Reis’s PR adityatelange/hugo-PaperMod#140 with some modifed on toggle option. Creat two files under layouts/partials/. Create math.html: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" > MathJax.Hub.Config({ tex2jax: { inlineMath: [['$', '$'], ['\\(', '\\)']], displayMath: [['$$', '$$']], processEscapes: true, processEnvironments: true, skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'], TeX: { equationNumbers: { autoNumber: "AMS" }, extensions: ["AMSmath.js", "AMSsymbols.js"] } } }); MathJax.Hub.Queue(function () { // Fix <code> tags after MathJax finishes running. This is a // hack to overcome a shortcoming of Markdown. Discussion at // https://github.com/mojombo/jekyll/issues/199 var all = MathJax.Hub.getAllJax(), i; for (i = 0; i < all.length; i += 1) { all[i].SourceElement().parentNode.className += ' has-jax'; } }); MathJax.Hub.Config({ // Autonumbering by mathjax TeX: { equationNumbers: { autoNumber: "AMS" } } }); </script> Create extend_head.html: ...

 · 1 min · 198 words · ringsaturn