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
941aca51
Commit
941aca51
authored
4 years ago
by
David Byers
Browse files
Options
Downloads
Plain Diff
Merge branch '5-make-nominatim-url-configurable' into 'master'
Resolve "Make nominatim url configurable" Closes
#5
See merge request
!7
parents
98f5ddcd
79a719a7
No related branches found
Branches containing commit
Tags
1.3.0
Tags containing commit
1 merge request
!7
Resolve "Make nominatim url configurable"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
olc.el
+17
-3
17 additions, 3 deletions
olc.el
test/olctest.el
+21
-5
21 additions, 5 deletions
test/olctest.el
with
39 additions
and
9 deletions
Makefile
+
1
−
1
View file @
941aca51
...
...
@@ -49,4 +49,4 @@ test:
-l
olctest.el
\
-f
olctest-batch-test
\
$(
TESTS
)
\
)
)
&&
echo
"All tests passed"
This diff is collapsed.
Click to expand it.
olc.el
+
17
−
3
View file @
941aca51
...
...
@@ -3,7 +3,7 @@
;; Copyright (C) 2020 David Byers
;;
;; Author: David Byers <david.byers@liu.se>
;; Version: 1.
1
.0
;; Version: 1.
2
.0
;; Package-Requires: ((emacs "25.1"))
;; Keywords: extensions, lisp
;; URL: https://gitlab.liu.se/davby02/olc
...
...
@@ -53,6 +53,13 @@
(
declare-function
request-response-data
"request"
)
;;; Variables:
(
defvar
olc-nominatim-url
"https://nominatim.openstreetmap.org/"
"Base url for the nominatim endpoint."
)
;;; Custom errors:
...
...
@@ -209,6 +216,13 @@ raise, and args for the raised error.
(
setq
index
(
1+
index
)))
code
))))
(
defun
olc-nominatim-endpoint
(
path
)
"Build a complete url for nominatim endpoint PATH."
(
concat
olc-nominatim-url
(
if
(
=
?/
(
elt
olc-nominatim-url
(
1-
(
length
olc-nominatim-url
))))
""
"/"
)
path
))
(
defsubst
olc-clip-latitude
(
lat
)
"Clip LAT to -90,90."
(
max
-90
(
min
90
lat
)))
...
...
@@ -606,7 +620,7 @@ faster.
(
let*
((
zoom
(
floor
(
+
zoom-lo
zoom-hi
)
2
))
(
resp
(
request-response-data
(
request
"https://nominatim.openstreetmap.org/
reverse"
(
olc-nominatim-endpoint
"
reverse"
)
:params
`
((
lat
.
,
(
olc-area-lat
area
))
(
lon
.
,
(
olc-area-lon
area
))
(
zoom
.
,
zoom
)
...
...
@@ -720,7 +734,7 @@ full open location code."
;; If the code is full then return it
(
if
(
olc-is-full
code
)
(
olc-recover
code
0
0
:format
format
)
(
let
((
resp
(
request
"https://nominatim.openstreetmap.org/
search"
(
let
((
resp
(
request
(
olc-nominatim-endpoint
"
search"
)
:params
`
((
q
.
,
ref
)
(
format
.
"json"
)
(
limit
.
1
))
...
...
This diff is collapsed.
Click to expand it.
test/olctest.el
+
21
−
5
View file @
941aca51
...
...
@@ -488,14 +488,29 @@
"22+"
"Nowhere Special, Pitcairn"
))
:msg
"R1"
)
(
olc-recover-compound
"22+ Nowhere Special, Pitcairn"
))
(
olctest-expect-failure
"R2"
(
let
((
olc-nominatim-url
"https://invalid.domain/nominatim"
))
(
olctest-assert-error
(
:exp
((
olc-recover-error-reference-search-failed
"22+"
"Sweden"
))
:msg
"R2"
)
(
olc-recover-compound
"22+ Sweden"
))))
(
let
((
olc-nominatim-url
"https://invalid.domain/nominatim"
))
(
olctest-assert-error
(
:exp
((
olc-recover-error-reference-search-failed
"22+"
"Sweden"
))
:msg
"R2"
)
(
olc-recover-compound
"22+ Sweden"
)))
))
(
defun
olctest-issue-5
()
(
olctest-testcase
"issue-5"
(
olctest-string=
:exp
"https://nominatim.openstreetmap.org/search"
:act
(
olc-nominatim-endpoint
"search"
)
:msg
"1"
)
(
let
((
olc-nominatim-url
"https://nominatim.invalid"
))
(
olctest-string=
:exp
"https://nominatim.invalid/search"
:act
(
olc-nominatim-endpoint
"search"
)
:msg
"2"
))
(
let
((
olc-nominatim-url
"https://nominatim.invalid/"
))
(
olctest-string=
:exp
"https://nominatim.invalid/reverse"
:act
(
olc-nominatim-endpoint
"reverse"
)
:msg
"3"
))))
(
defvar
olctest-selected-tests
)
...
...
@@ -515,6 +530,7 @@
(
run-test
validity
)
(
run-test
localtests
)
(
run-test
errors
)
(
run-test
issue-5
)
(
run-test
issue-3
)
(
run-test
issue-2
)
(
run-test
issue-1
)
...
...
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