Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
olc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Byers
olc
Commits
ec172e17
Commit
ec172e17
authored
4 years ago
by
David Byers
Browse files
Options
Downloads
Patches
Plain Diff
Rewrote olc-decode to use integer math.
parent
58f441c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG
+3
-0
3 additions, 0 deletions
CHANGELOG
olc.el
+22
-13
22 additions, 13 deletions
olc.el
test/olctest.el
+4
-3
4 additions, 3 deletions
test/olctest.el
with
29 additions
and
16 deletions
CHANGELOG
+
3
−
0
View file @
ec172e17
2020-07-21 David Byers <david.byers@liu.se>
More integer math:
(olc-decode): Converted to use integer math.
Wrote texinfo documentation:
* olc.el (olc-parse-length): Removed.
Updated documentation comment.
...
...
This diff is collapsed.
Click to expand it.
olc.el
+
22
−
13
View file @
ec172e17
...
...
@@ -264,10 +264,13 @@ coordinates, an empty code, and so forth).
Since this function uses floating point calculations, the results
are not identical to e.g. the C++ reference implementation. The
differences, however, are extremely small."
(
let
((
parse
(
olc-parse-code
code
))
(
lat
-90.0
)
(
lon
-180.0
)
(
size
20.0
))
(
let*
((
parse
(
olc-parse-code
code
))
(
latscale
(
*
(
expt
20
4
)
(
expt
5
5
)))
(
lonscale
(
*
(
expt
20
4
)
(
expt
4
5
)))
(
lat
(
*
latscale
-90
))
(
lon
(
*
lonscale
-180
))
(
latsize
(
*
latscale
20
))
(
lonsize
(
*
lonscale
20
)))
;; We only deal with long codes
(
when
(
olc-parse-short
parse
)
...
...
@@ -275,22 +278,28 @@ differences, however, are extremely small."
;; Process the pairs
(
mapc
(
lambda
(
pair
)
(
setq
lat
(
+
lat
(
*
size
(
olc-digit-value
(
car
pair
))))
lon
(
+
lon
(
*
size
(
olc-digit-value
(
cdr
pair
))))
width
size
height
size
size
(
/
size
20.0
)))
(
setq
lat
(
+
lat
(
*
latsize
(
olc-digit-value
(
car
pair
))))
lon
(
+
lon
(
*
lonsize
(
olc-digit-value
(
cdr
pair
))))
latsize
(
/
latsize
20
)
lonsize
(
/
lonsize
20
)))
(
olc-parse-pairs
parse
))
;; I'm too tired to figure out why
(
setq
latsize
(
*
latsize
20
)
lonsize
(
*
lonsize
20
))
;; Process the grid
(
when
(
olc-parse-grid
parse
)
(
mapc
(
lambda
(
refine
)
(
setq
width
(
/
width
4.0
)
height
(
/
height
5.0
))
(
setq
latsize
(
/
latsize
5
)
lonsize
(
/
lonsize
4
))
(
let
((
coord
(
olc-digit-value
refine
)))
(
setq
lat
(
+
lat
(
*
height
(
/
coord
4
)))
lon
(
+
lon
(
*
width
(
%
coord
4
))))))
(
setq
lat
(
+
lat
(
*
latsize
(
/
coord
4
)))
lon
(
+
lon
(
*
lonsize
(
%
coord
4
))))))
(
olc-parse-grid
parse
)))
(
olc-area-create
:latlo
lat
:lonlo
lon
:lathi
(
+
lat
height
)
:lonhi
(
+
lon
width
))))
(
olc-area-create
:latlo
(
/
lat
(
float
latscale
))
:lonlo
(
/
lon
(
float
lonscale
))
:lathi
(
/
(
+
lat
latsize
)
(
float
latscale
))
:lonhi
(
/
(
+
lon
lonsize
)
(
float
lonscale
)))))
(
defun
olc-encode
(
lat
lon
len
)
...
...
This diff is collapsed.
Click to expand it.
test/olctest.el
+
4
−
3
View file @
ec172e17
...
...
@@ -18,8 +18,9 @@
(
require
'cl-lib
)
;; Decode still uses float arithmetic, so results can be slightly off
;; from the test cases. This is deemed acceptable.
;; Due to rounding and floating point representation we can't seem
;; to get closer than 1e-10 to the reference test cases, but sinze
;; it only affects decoding, that is an insignificant error level.
(
defvar
olctest-decode-tolerance
0.0000000001
)
...
...
@@ -196,7 +197,7 @@
(
defun
olctest-run-all
()
"Run all tests."
(
and
(
olctest-decode
)
(
and
(
olctest-decode
)
q
(
olctest-encode
)
(
olctest-shortcodes
)
(
olctest-validity
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment