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
a84a9b7e
Commit
a84a9b7e
authored
4 years ago
by
David Byers
Browse files
Options
Downloads
Patches
Plain Diff
Complete the fix for
#1
parent
4eedef44
No related branches found
No related tags found
1 merge request
!3
Complete the fix for #1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG
+6
-0
6 additions, 0 deletions
CHANGELOG
olc.el
+14
-8
14 additions, 8 deletions
olc.el
test/olctest.el
+25
-11
25 additions, 11 deletions
test/olctest.el
with
45 additions
and
19 deletions
CHANGELOG
+
6
−
0
View file @
a84a9b7e
2020-07-23 David Byers <david.byers@liu.se>
2020-07-23 David Byers <david.byers@liu.se>
Fix issue #1 more properly:
* olc.el (olc-recover): Honor format arg when dealing with full
codes.
(olc-recover-compound): Defer to olc-recover when dealing with
full codes.
Fix issue #1 (olc-recover-compound fails on full codes):
Fix issue #1 (olc-recover-compound fails on full codes):
* test/olctest.el: Improved test macros. Tests for issue 1.
* test/olctest.el: Improved test macros. Tests for issue 1.
...
...
This diff is collapsed.
Click to expand it.
olc.el
+
14
−
8
View file @
a84a9b7e
...
@@ -519,7 +519,11 @@ If FORMAT is `area' (or any other value), the returned value is an
...
@@ -519,7 +519,11 @@ If FORMAT is `area' (or any other value), the returned value is an
full open location code."
full open location code."
(
let
((
parse
(
olc-parse-code
code
)))
(
let
((
parse
(
olc-parse-code
code
)))
(
if
(
olc-is-full
parse
)
(
if
(
olc-is-full
parse
)
(
upcase
code
)
(
if
(
eq
format
'latlon
)
(
let
((
area
(
olc-decode
parse
)))
(
cons
(
olc-area-lat
area
)
(
olc-area-lon
area
)))
(
upcase
code
))
(
setq
lat
(
olc-clip-latitude
lat
)
(
setq
lat
(
olc-clip-latitude
lat
)
lon
(
olc-normalize-longitude
lon
))
lon
(
olc-normalize-longitude
lon
))
(
let*
((
padlen
(
-
(
olc-parse-precision
parse
)
(
let*
((
padlen
(
-
(
olc-parse-precision
parse
)
...
@@ -559,19 +563,21 @@ full open location code."
...
@@ -559,19 +563,21 @@ full open location code."
;; Make sure we can do requests
;; Make sure we can do requests
(
unless
(
fboundp
'request
)
(
signal
'void-function
'request
))
(
unless
(
fboundp
'request
)
(
signal
'void-function
'request
))
;; Check types (defer check of ref
;; Check types (defer check of ref
)
(
cl-check-type
code
stringp
)
(
cl-check-type
code
stringp
)
(
cl-check-type
format
(
member
latlon
area
nil
))
(
cl-check-type
format
(
member
latlon
area
nil
))
(
if
(
string-match
"^\\(\\S-+\\)\\s-+\\(.*\\)$"
code
)
;; Process code and check ref
(
progn
(
cl-check-type
ref
null
)
(
cond
((
string-match
"^\\(\\S-+\\)\\s-+\\(.*\\)$"
code
)
(
setq
ref
(
match-string
2
code
)
(
progn
(
cl-check-type
ref
null
)
code
(
match-string
1
code
)))
(
setq
ref
(
match-string
2
code
)
(
cl-check-type
ref
stringp
))
code
(
match-string
1
code
))))
((
olc-is-full
code
))
(
t
(
cl-check-type
ref
stringp
)))
;; If the code is full then return it
;; If the code is full then return it
(
if
(
olc-is-full
code
)
(
if
(
olc-is-full
code
)
code
(
olc-recover
code
0
0
:format
format
)
(
let
((
resp
(
request
"https://nominatim.openstreetmap.org/search"
(
let
((
resp
(
request
"https://nominatim.openstreetmap.org/search"
:params
`
((
q
.
,
ref
)
:params
`
((
q
.
,
ref
)
(
format
.
"json"
)
(
format
.
"json"
)
...
...
This diff is collapsed.
Click to expand it.
test/olctest.el
+
25
−
11
View file @
a84a9b7e
...
@@ -240,10 +240,34 @@
...
@@ -240,10 +240,34 @@
(
defun
olctest-issue-1
()
(
defun
olctest-issue-1
()
(
olctest-testcase
"local:issue-1"
(
olctest-testcase
"local:issue-1"
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F1"
)
(
olc-recover-compound
nil
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F2"
)
(
olc-recover-compound
"+9C Sweden"
:ref
"Norway"
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F3"
)
(
olc-recover-compound
"+9C"
:ref
nil
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F4"
)
(
olc-recover-compound
"+9C Sweden"
:format
'undefined
))
(
olctest-string=
:exp
"9FFV9VH8+9C"
:act
(
olc-recover-compound
"9FFV9VH8+9C"
)
:msg
"O1"
)
(
olctest-string=
:exp
"9FFV9VH8+9C"
(
olctest-string=
:exp
"9FFV9VH8+9C"
:act
(
olc-recover-compound
"9FFV9VH8+9C"
:ref
"Antarctica"
)
:act
(
olc-recover-compound
"9FFV9VH8+9C"
:ref
"Antarctica"
)
:msg
"O1"
)
:msg
"O1"
)
(
olctest-equal
:exp
'
(
-89.99875
.
-179.99875
)
:act
(
olc-recover
"22222222+"
0
0
:format
'latlon
)
:msg
"O4"
)
(
olctest-equal
:exp
'
(
-89.99875
.
-179.99875
)
:act
(
olc-recover-compound
"22222222+"
:format
'latlon
)
:msg
"O4"
)
(
olctest-string=
:exp
"9FFPMGGC+9C"
(
olctest-string=
:exp
"9FFPMGGC+9C"
:act
(
olc-recover-compound
"+9C Sweden"
)
:act
(
olc-recover-compound
"+9C Sweden"
)
:msg
"O2"
)
:msg
"O2"
)
...
@@ -252,17 +276,7 @@
...
@@ -252,17 +276,7 @@
:act
(
olc-recover-compound
"+9C"
:ref
"Sweden"
)
:act
(
olc-recover-compound
"+9C"
:ref
"Sweden"
)
:msg
"O3"
)
:msg
"O3"
)
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F1"
)
))
(
olc-recover-compound
nil
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F2"
)
(
olc-recover-compound
"+9C Sweden"
:ref
"Norway"
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F3"
)
(
olc-recover-compound
"+9C"
:ref
nil
))
(
olctest-assert-error
(
:exp
(
wrong-type-argument
)
:msg
"F4"
)
(
olc-recover-compound
"+9C Sweden"
:format
'undefined
))))
(
defun
olctest-run-all
()
(
defun
olctest-run-all
()
...
...
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