Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DENUE tiles
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
DENUE tiles
Commits
8c62f7b7
Commit
8c62f7b7
authored
Nov 10, 2020
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query tiles covering BBOX and filter by polygon
parent
11696c91
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
42 deletions
+21
-42
index.html
public/index.html
+1
-0
functions.js
public/js/functions.js
+20
-42
No files found.
public/index.html
View file @
8c62f7b7
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
<body>
<body>
<div
id=
"mexmap"
></div>
<div
id=
"mexmap"
></div>
<script
src=
"https://d3js.org/d3.v5.min.js"
></script>
<script
src=
"https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js"
></script>
<script
src=
"https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js"
></script>
<script
src=
'https://unpkg.com/@turf/turf/turf.min.js'
></script>
<script
src=
'https://unpkg.com/@turf/turf/turf.min.js'
></script>
<script
src=
"../js/functions.js"
></script>
<script
src=
"../js/functions.js"
></script>
...
...
public/js/functions.js
View file @
8c62f7b7
...
@@ -7,46 +7,21 @@
...
@@ -7,46 +7,21 @@
/* global mapboxgl, turf */
/* global mapboxgl, turf */
let
polygon
=
{
const
baseUrl
=
new
URL
(
`/data`
,
window
.
location
.
href
).
href
;
"type"
:
"Feature"
,
let
queryGeom
=
`
${
baseUrl
}
/query/dim_municipio?columns=st_asgeojson(box2d(st_geometryn(municipio_geom_4326,1))) box,st_asgeojson(st_geometryn(municipio_geom_4326,1)) geom&filter=municipio_cvegeo='09002'`
;
"properties"
:
{},
let
tiles
,
polygon
,
box
;
"geometry"
:
{
"type"
:
"Polygon"
,
"coordinates"
:
[
[
[
-
99.14920806884764
,
19.41608763433028
],
[
-
99.1123867034912
,
19.41608763433028
],
[
-
99.1123867034912
,
19.43818532931131
],
[
-
99.14920806884764
,
19.43818532931131
],
[
-
99.14920806884764
,
19.41608763433028
]
]
]
}
}
// define MVT layer for given table and some attributes
// define MVT layer for given table and some attributes
const
mapboxLayer
=
(
table
)
=>
{
const
mapboxLayer
=
(
table
,
polygon
,
box
)
=>
{
const
baseUrl
=
new
URL
(
`/data`
,
window
.
location
.
href
).
href
;
let
columns
=
[
"denue_nombre"
,
"sector"
,
"sector_nombre"
],
filter
=
`ST_Intersects(denue_geom_4326,ST_GeomFromGeoJSON('
${
JSON
.
stringify
(
box
)}
'))`
;
let
pbfLayer
=
{
let
pbfLayer
=
{
id
:
table
,
id
:
table
,
source
:
{
source
:
{
type
:
"vector"
,
type
:
"vector"
,
tiles
:
[
`
${
baseUrl
}
/
${
table
}
/mvt/{z}/{x}/{y}?geom_column=denue_geom_4326&columns=
denue_nombre, sector, sector_nombre
`
],
tiles
:
[
`
${
baseUrl
}
/
${
table
}
/mvt/{z}/{x}/{y}?geom_column=denue_geom_4326&columns=
${
columns
.
join
(
","
)}
&filter=
${
filter
}
`
],
maxzoom
:
19
,
maxzoom
:
19
,
minzoom
:
6
minzoom
:
6
},
},
...
@@ -54,6 +29,7 @@ const mapboxLayer = (table) => {
...
@@ -54,6 +29,7 @@ const mapboxLayer = (table) => {
type
:
"circle"
,
type
:
"circle"
,
"paint"
:
{
"paint"
:
{
//"circle-opacity": 0.5,
//"circle-opacity": 0.5,
'circle-opacity'
:
[
'case'
,
[
'within'
,
polygon
],
0.5
,
0
],
"circle-radius"
:
3.5
,
"circle-radius"
:
3.5
,
"circle-color"
:
[
"circle-color"
:
[
"interpolate"
,
"interpolate"
,
...
@@ -62,8 +38,7 @@ const mapboxLayer = (table) => {
...
@@ -62,8 +38,7 @@ const mapboxLayer = (table) => {
10
,
"rgb(49,54,149)"
,
10
,
"rgb(49,54,149)"
,
50
,
"rgb(255,255,191)"
,
50
,
"rgb(255,255,191)"
,
100
,
"rgb(158,1,66)"
100
,
"rgb(158,1,66)"
],
]
'circle-opacity'
:
[
'case'
,
[
'within'
,
polygon
],
0.5
,
0
],
}
}
}
}
return
pbfLayer
;
return
pbfLayer
;
...
@@ -73,16 +48,19 @@ let map = new mapboxgl.Map({
...
@@ -73,16 +48,19 @@ let map = new mapboxgl.Map({
container
:
'mexmap'
,
container
:
'mexmap'
,
accessToken
:
"pk.eyJ1IjoiZGV2ZWxvcGdlbyIsImEiOiJja2dwcXFic20wYnJnMzBrbG11d3dwYTkyIn0.4WwFOH6C7hDQXV9obU6mAw"
,
accessToken
:
"pk.eyJ1IjoiZGV2ZWxvcGdlbyIsImEiOiJja2dwcXFic20wYnJnMzBrbG11d3dwYTkyIn0.4WwFOH6C7hDQXV9obU6mAw"
,
style
:
'mapbox://styles/mapbox/dark-v10'
,
style
:
'mapbox://styles/mapbox/dark-v10'
,
center
:
[
-
100.94
,
21.15
],
center
:
[
-
99.18
,
19.48
],
zoom
:
7
zoom
:
12
});
});
map
.
addControl
(
new
mapboxgl
.
NavigationControl
());
map
.
addControl
(
new
mapboxgl
.
NavigationControl
());
let
tiles
=
mapboxLayer
(
"dim_denue2019"
);
map
.
on
(
"style.load"
,
async
()
=>
{
d3
.
json
(
queryGeom
).
then
(
d
=>
{
map
.
on
(
"style.load"
,
()
=>
{
polygon
=
JSON
.
parse
(
d
[
0
].
geom
);
box
=
JSON
.
parse
(
d
[
0
].
box
);
tiles
=
mapboxLayer
(
"dim_denue2019"
,
polygon
,
box
);
map
.
addLayer
(
tiles
);
map
.
addLayer
(
tiles
);
});
});
});
map
.
on
(
'click'
,
e
=>
{
map
.
on
(
'click'
,
e
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment