Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rabotnik-rules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Global Dynamic Exposure
rabotnik
rabotnik-rules
Commits
285b189d
Commit
285b189d
authored
1 year ago
by
Laurens Oostwegel
Browse files
Options
Downloads
Patches
Plain Diff
Remove rules
parent
0706e4c1
No related branches found
No related tags found
Loading
Pipeline
#71723
passed
9 months ago
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tile/01_select/obm_buildings_information/quadkey_functions.sql
+0
-108
0 additions, 108 deletions
...01_select/obm_buildings_information/quadkey_functions.sql
with
0 additions
and
108 deletions
tile/01_select/obm_buildings_information/quadkey_functions.sql
deleted
100644 → 0
+
0
−
108
View file @
0706e4c1
CREATE
OR
REPLACE
FUNCTION
tile_xy_to_quadkey
(
IN
tile_x
INT
,
IN
tile_y
INT
,
IN
levelOfDetail
INT
)
RETURNS
TEXT
LANGUAGE
plpgsql
AS
$$
DECLARE
_quadkey
TEXT
;
mask
INT
;
digit
INT
;
BEGIN
_quadkey
:
=
''
;
FOR
i
IN
REVERSE
levelOfDetail
..
1
LOOP
digit
:
=
0
;
mask
:
=
1
<<
(
i
-
1
);
CASE
(
tile_x
&
mask
)
WHEN
0
THEN
digit
=
digit
;
ELSE
digit
=
digit
+
1
;
END
CASE
;
CASE
(
tile_y
&
mask
)
WHEN
0
THEN
digit
=
digit
;
ELSE
digit
=
digit
+
2
;
END
CASE
;
_quadkey
=
CONCAT
(
_quadkey
,
digit
);
END
LOOP
;
RETURN
_quadkey
;
END
;
$$
;
CREATE
OR
REPLACE
FUNCTION
latlon_to_pixel_xy
(
IN
latitude
DOUBLE
PRECISION
,
IN
longitude
DOUBLE
PRECISION
,
IN
levelOfDetail
INT
,
OUT
pixel_x
INT
,
OUT
pixel_y
INT
)
LANGUAGE
plpgsql
AS
$$
DECLARE
x
DOUBLE
PRECISION
;
y
DOUBLE
PRECISION
;
sinLatitude
DOUBLE
PRECISION
;
mapSize
INT
;
BEGIN
latitude
:
=
Clip
(
latitude
,
-
85
.
05112878
,
85
.
05112878
);
longitude
:
=
Clip
(
longitude
,
-
180
,
180
);
x
:
=
(
longitude
+
180
)
/
360
;
sinLatitude
:
=
SIN
(
latitude
*
PI
()
/
180
);
y
:
=
0
.
5
-
LN
((
1
+
sinLatitude
)
/
(
1
-
sinLatitude
))
/
(
4
*
PI
());
mapSize
:
=
map_size
(
levelOfDetail
);
pixel_x
:
=
FLOOR
(
Clip
(
x
*
mapSize
+
0
.
5
,
0
,
mapSize
-
1
));
pixel_y
:
=
FLOOR
(
Clip
(
y
*
mapSize
+
0
.
5
,
0
,
mapSize
-
1
));
END
;
$$
;
CREATE
OR
REPLACE
FUNCTION
clip
(
n
FLOAT
,
minValue
FLOAT
,
maxValue
FLOAT
)
RETURNS
DOUBLE
PRECISION
LANGUAGE
plpgsql
AS
$$
BEGIN
RETURN
LEAST
(
GREATEST
(
n
,
minValue
),
maxValue
);
END
;
$$
;
CREATE
OR
REPLACE
FUNCTION
pixel_xy_to_tile_xy
(
IN
pixel_x
INT
,
IN
pixel_y
INT
,
OUT
tile_x
INT
,
OUT
tile_y
INT
)
LANGUAGE
plpgsql
AS
$$
BEGIN
tile_x
:
=
pixel_x
/
256
;
tile_y
:
=
pixel_y
/
256
;
END
;
$$
;
CREATE
OR
REPLACE
FUNCTION
bbox_to_quadkeys
(
IN
min_lat
DOUBLE
PRECISION
,
IN
min_lon
DOUBLE
PRECISION
,
IN
max_lat
DOUBLE
PRECISION
,
IN
max_lon
DOUBLE
PRECISION
,
IN
levelOfDetail
INT
)
RETURNS
TABLE
(
quadkey
TEXT
)
LANGUAGE
plpgsql
AS
$$
DECLARE
min_pixel_xy
RECORD
;
max_pixel_xy
RECORD
;
min_tile_xy
RECORD
;
max_tile_xy
RECORD
;
BEGIN
min_pixel_xy
=
latlon_to_pixel_xy
(
max_lat
,
min_lon
,
levelOfDetail
);
max_pixel_xy
=
latlon_to_pixel_xy
(
min_lat
,
max_lon
,
levelOfDetail
);
min_tile_xy
=
pixel_xy_to_tile_xy
(
min_pixel_xy
.
pixel_x
,
min_pixel_xy
.
pixel_y
);
max_tile_xy
=
pixel_xy_to_tile_xy
(
max_pixel_xy
.
pixel_x
,
max_pixel_xy
.
pixel_y
);
FOR
i
IN
min_tile_xy
.
tile_x
..
max_tile_xy
.
tile_x
LOOP
FOR
j
IN
min_tile_xy
.
tile_y
..
max_tile_xy
.
tile_y
LOOP
quadkey
:
=
tile_xy_to_quadkey
(
i
,
j
,
levelOfDetail
);
RETURN
next
;
END
LOOP
;
END
LOOP
;
END
;
$$
;
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