-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreproj.erl
47 lines (43 loc) · 1.17 KB
/
reproj.erl
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
%
% @doc Reproject Datas
%
% @author Rodolphe Quiedeville <[email protected]>
% [http://rodolphe.quiedeville.org]
%
% @copyright 2013,2014 Rodolphe Quiedeville
%
% @reference https://github.com/greenelephantlabs/proj4erl
%
% @doc
% Dynamic variables :
% - wms_proj
% @end
-module(reproj).
-export([tmstowms/1]).
-export([reproj/3]).
% @doc Convert list_url DynVar to list of coord
%
%
tmstowms({_Pid, DynVars})->
Urls = slippymap:tmstowms({_Pid, DynVars}),
Proj = newproj(DynVars),
case Proj of
"epsg:4326" -> Urls;
_ -> reproj("epsg:4326", Proj, Urls)
end.
reproj(From, To, Datas)->
{ok, WGS84} = proj4:init("+init="++From),
{ok, NewProj} = proj4:init("+init="++To),
case is_list(Datas) of
true -> P2 = lists:map(fun(X)->
{ok, P} = proj4:transform(WGS84, NewProj, X),
P
end, Datas);
_ -> {ok, P2} = proj4:transform(WGS84, NewProj, Datas)
end,
P2.
newproj(DynVars)->
case ts_dynvars:lookup(wms_proj, DynVars) of
{ok, Proj} -> Proj;
false -> ""
end.