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
ab52bb05
Commit
ab52bb05
authored
Dec 18, 2020
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a circle and its tile intersection logic
parent
3048d545
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1528 additions
and
19 deletions
+1528
-19
circle.geojson
public/circle.geojson
+1459
-0
index.html
public/index.html
+1
-0
functions.js
public/js/functions.js
+68
-19
No files found.
public/circle.geojson
0 → 100644
View file @
ab52bb05
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-99.11891269674774,
19.433251583246246
],
[
-99.11891414757308,
19.433409417876785
],
[
-99.11891849960718,
19.43356720442937
],
[
-99.11892575152434,
19.43372489484068
],
[
-99.11893590111558,
19.433882441076697
],
[
-99.11894894528923,
19.434039795147307
],
[
-99.11896488007191,
19.434196909120935
],
[
-99.11898370060973,
19.434353735139144
],
[
-99.11900540116977,
19.434510225431207
],
[
-99.11902997514183,
19.43466633232867
],
[
-99.11905741504043,
19.434822008279863
],
[
-99.11908771250714,
19.43497720586437
],
[
-99.11912085831302,
19.435131877807514
],
[
-99.11915684236156,
19.43528597699472
],
[
-99.11919565369168,
19.435439456485884
],
[
-99.11923728048104,
19.435592269529664
],
[
-99.11928171004975,
19.435744369577726
],
[
-99.1193289288641,
19.435895710298922
],
[
-99.11937892254082,
19.436046245593406
],
[
-99.11943167585132,
19.43619592960667
],
[
-99.11948717272644,
19.436344716743502
],
[
-99.1195453962613,
19.436492561681913
],
[
-99.11960632872045,
19.436639419386893
],
[
-99.11966995154326,
19.436785245124167
],
[
-99.11973624534961,
19.436929994473804
],
[
-99.11980518994577,
19.437073623343743
],
[
-99.11987676433053,
19.437216087983245
],
[
-99.11995094670165,
19.4373573449962
],
[
-99.12002771446247,
19.437497351354352
],
[
-99.12010704422876,
19.437636064410412
],
[
-99.12018891183594,
19.43777344191103
],
[
-99.12027329234631,
19.437909442009698
],
[
-99.12036016005678,
19.438044023279467
],
[
-99.12044948850658,
19.43817714472557
],
[
-99.12054125048542,
19.438308765797938
],
[
-99.12063541804169,
19.438438846403507
],
[
-99.12073196249105,
19.43856734691847
],
[
-99.12083085442512,
19.438694228200323
],
[
-99.12093206372047,
19.438819451599798
],
[
-99.12103555954776,
19.438942978972637
],
[
-99.12114131038118,
19.439064772691204
],
[
-99.12124928400796,
19.43918479565595
],
[
-99.12135944753831,
19.43930301130672
],
[
-99.12147176741537,
19.439419383633883
],
[
-99.12158620942539,
19.439533877189298
],
[
-99.12170273870822,
19.43964645709712
],
[
-99.12182131976795,
19.43975708906442
],
[
-99.1219419164836,
19.439865739391625
],
[
-99.12206449212026,
19.439972374982798
],
[
-99.1221890093402,
19.4400769633557
],
[
-99.12231543021429,
19.440179472651703
],
[
-99.12244371623348,
19.44027987164548
],
[
-99.1225738283206,
19.440378129754528
],
[
-99.12270572684227,
19.44047421704847
],
[
-99.12283937162091,
19.440568104258194
],
[
-99.12297472194703,
19.440659762784737
],
[
-99.12311173659161,
19.440749164708027
],
[
-99.12325037381866,
19.440836282795374
],
[
-99.12339059139795,
19.440921090509764
],
[
-99.12353234661782,
19.441003562017947
],
[
-99.12367559629828,
19.4410836721983
],
[
-99.12382029680408,
19.441161396648486
],
[
-99.12396640405807,
19.441236711692888
],
[
-99.1241138735545,
19.44130959438981
],
[
-99.1242626603728,
19.44138002253848
],
[
-99.12441271919104,
19.441447974685794
],
[
-99.12456400429984,
19.44151343013288
],
[
-99.1247164696163,
19.44157636894137
],
[
-99.12487006869802,
19.44163677193949
],
[
-99.12502475475719,
19.441694620727908
],
[
-99.12518048067498,
19.44174989768532
],
[
-99.12533719901576,
19.441802585973825
],
[
-99.12549486204159,
19.441852669544065
],
[
-99.12565342172681,
19.441900133140102
],
[
-99.12581282977257,
19.441944962304056
],
[
-99.12597303762165,
19.441987143380537
],
[
-99.1261339964732,
19.442026663520778
],
[
-99.12629565729758,
19.44206351068656
],
[
-99.12645797085133,
19.44209767365388
],
[
-99.1266208876922,
19.44212914201637
],
[
-99.12678435819412,
19.44215790618846
],
[
-99.12694833256238,
19.4421839574083
],
[
-99.12711276084882,
19.442207287740445
],
[
-99.12727759296698,
19.442227890078243
],
[
-99.1274427787074,
19.442245758146026
],
[
-99.12760826775292,
19.442260886501007
],
[
-99.12777400969395,
19.442273270534937
],
[
-99.12793995404391,
19.442282906475526
],
[
-99.12810605025452,
19.442289791387573
],
[
-99.12827224773129,
19.442293923173864
],
[
-99.12843849584884,
19.442295300575818
],
[
-99.12860474396639,
19.442293923173864
],
[
-99.12877094144316,
19.442289791387573
],
[
-99.12893703765377,
19.442282906475526
],
[
-99.12910298200373,
19.442273270534937
],
[
-99.12926872394476,
19.442260886501007
],
[
-99.12943421299028,
19.442245758146026
],
[
-99.1295993987307,
19.442227890078243
],
[
-99.12976423084886,
19.442207287740445
],
[
-99.1299286591353,
19.4421839574083
],
[
-99.13009263350357,
19.44215790618846
],
[
-99.13025610400548,
19.44212914201637
],
[
-99.13041902084635,
19.44209767365388
],
[
-99.1305813344001,
19.44206351068656
],
[
-99.13074299522448,
19.442026663520778
],
[
-99.13090395407603,
19.441987143380537
],
[
-99.13106416192511,
19.441944962304056
],
[
-99.13122356997087,
19.441900133140102
],
[
-99.13138212965609,
19.441852669544065
],
[
-99.13153979268192,
19.441802585973825
],
[
-99.1316965110227,
19.44174989768532
],
[
-99.13185223694049,
19.441694620727908
],
[
-99.13200692299966,
19.44163677193949
],
[
-99.13216052208138,
19.44157636894137
],
[
-99.13231298739784,
19.44151343013288
],
[
-99.13246427250664,
19.441447974685794
],
[
-99.13261433132487,
19.44138002253848
],
[
-99.13276311814317,
19.44130959438981
],
[
-99.13291058763961,
19.441236711692888
],
[
-99.1330566948936,
19.441161396648486
],
[
-99.1332013953994,
19.4410836721983
],
[
-99.13334464507986,
19.441003562017947
],
[
-99.13348640029973,
19.440921090509764
],
[
-99.13362661787902,
19.440836282795374
],
[
-99.13376525510607,
19.440749164708027
],
[
-99.13390226975065,
19.440659762784737
],
[
-99.13403762007677,
19.440568104258194
],
[
-99.13417126485541,
19.44047421704847
],
[
-99.13430316337708,
19.440378129754528
],
[
-99.1344332754642,
19.44027987164548
],
[
-99.1345615614834,
19.440179472651703
],
[
-99.13468798235748,
19.4400769633557
],
[
-99.13481249957742,
19.439972374982798
],
[
-99.13493507521407,
19.439865739391625
],
[
-99.13505567192973,
19.43975708906442
],
[
-99.13517425298946,
19.43964645709712
],
[
-99.13529078227229,
19.439533877189298
],
[
-99.13540522428231,
19.439419383633883
],
[
-99.13551754415937,
19.43930301130672
],
[
-99.13562770768972,
19.43918479565595
],
[
-99.1357356813165,
19.439064772691204
],
[
-99.13584143214992,
19.438942978972637
],
[
-99.1359449279772,
19.438819451599798
],
[
-99.13604613727256,
19.438694228200323
],
[
-99.13614502920663,
19.43856734691847
],
[
-99.136241573656,
19.438438846403507
],
[
-99.13633574121226,
19.438308765797938
],
[
-99.1364275031911,
19.43817714472557
],
[
-99.1365168316409,
19.438044023279467
],
[
-99.13660369935137,
19.437909442009698
],
[
-99.13668807986174,
19.43777344191103
],
[
-99.13676994746892,
19.437636064410412
],
[
-99.13684927723521,
19.437497351354352
],
[
-99.13692604499603,
19.4373573449962
],
[
-99.13700022736715,
19.437216087983245
],
[
-99.13707180175192,
19.437073623343743
],
[
-99.13714074634807,
19.436929994473804
],
[
-99.13720704015442,
19.436785245124167
],
[
-99.13727066297723,
19.436639419386893
],
[
-99.13733159543638,
19.436492561681913
],
[
-99.13738981897124,
19.436344716743502
],
[
-99.13744531584636,
19.43619592960667
],
[
-99.13749806915686,
19.436046245593406
],
[
-99.13754806283357,
19.435895710298922
],
[
-99.13759528164793,
19.435744369577726
],
[
-99.13763971121664,
19.435592269529664
],
[
-99.137681338006,
19.435439456485884
],
[
-99.13772014933612,
19.43528597699472
],
[
-99.13775613338466,
19.435131877807514
],
[
-99.13778927919054,
19.43497720586437
],
[
-99.13781957665725,
19.434822008279863
],
[
-99.13784701655585,
19.43466633232867
],
[
-99.13787159052791,
19.434510225431207
],
[
-99.13789329108795,
19.434353735139144
],
[
-99.13791211162577,
19.434196909120935
],
[
-99.13792804640845,
19.434039795147307
],
[
-99.1379410905821,
19.433882441076697
],
[
-99.13795124017334,
19.43372489484068
],
[
-99.1379584920905,
19.43356720442937
],
[
-99.1379628441246,
19.433409417876785
],
[
-99.13796429494994,
19.433251583246246
],
[
-99.1379628441246,
19.433093748615708
],
[
-99.1379584920905,
19.432935962063123
],
[
-99.13795124017334,
19.432778271651813
],
[
-99.1379410905821,
19.432620725415795
],
[
-99.13792804640845,
19.432463371345186
],
[
-99.13791211162577,
19.432306257371557
],
[
-99.13789329108795,
19.43214943135335
],
[
-99.13787159052791,
19.431992941061285
],
[
-99.13784701655585,
19.43183683416382
],
[
-99.13781957665725,
19.43168115821263
],
[
-99.13778927919054,
19.43152596062812
],
[
-99.13775613338466,
19.43137128868498
],
[
-99.13772014933612,
19.431217189497772
],
[
-99.137681338006,
19.431063710006608
],
[
-99.13763971121664,
19.43091089696283
],
[
-99.13759528164793,
19.430758796914766
],
[
-99.13754806283357,
19.43060745619357
],
[
-99.13749806915686,
19.430456920899086
],
[
-99.13744531584636,
19.430307236885824
],
[
-99.13738981897124,
19.43015844974899
],
[
-99.13733159543638,
19.43001060481058
],
[
-99.13727066297723,
19.4298637471056
],
[
-99.13720704015442,
19.429717921368326
],
[
-99.13714074634807,
19.42957317201869
],
[
-99.13707180175192,
19.42942954314875
],
[
-99.13700022736715,
19.429287078509248
],
[
-99.13692604499603,
19.42914582149629
],
[
-99.13684927723521,
19.42900581513814
],
[
-99.13676994746892,
19.42886710208208
],
[
-99.13668807986174,
19.428729724581462
],
[
-99.13660369935137,
19.428593724482795
],
[
-99.1365168316409,
19.428459143213026
],
[
-99.1364275031911,
19.42832602176692
],
[
-99.13633574121226,
19.428194400694554
],
[
-99.136241573656,
19.428064320088986
],
[
-99.13614502920663,
19.42793581957402
],
[
-99.13604613727256,
19.42780893829217
],
[
-99.1359449279772,
19.427683714892694
],
[
-99.13584143214992,
19.427560187519855
],
[
-99.1357356813165,
19.42743839380129
],
[
-99.13562770768972,
19.42731837083654
],
[
-99.13551754415937,
19.427200155185773
],
[
-99.13540522428231,
19.42708378285861
],
[
-99.13529078227229,
19.426969289303194
],
[
-99.13517425298946,
19.426856709395373
],
[
-99.13505567192973,
19.426746077428074
],
[
-99.13493507521407,
19.426637427100868
],
[
-99.13481249957742,
19.426530791509695
],
[
-99.13468798235748,
19.426426203136792
],
[
-99.1345615614834,
19.42632369384079
],
[
-99.1344332754642,
19.426223294847013
],
[
-99.13430316337708,
19.426125036737965
],
[
-99.13417126485541,
19.42602894944402
],
[
-99.13403762007677,
19.4259350622343
],
[
-99.13390226975065,
19.425843403707756
],
[
-99.13376525510607,
19.425754001784465
],
[
-99.13362661787902,
19.42566688369712
],
[
-99.13348640029973,
19.425582075982728
],
[
-99.13334464507986,
19.425499604474545
],
[
-99.1332013953994,
19.425419494294193
],
[
-99.1330566948936,
19.425341769844007
],
[
-99.13291058763961,
19.425266454799605
],
[
-99.13276311814317,
19.425193572102682
],
[
-99.13261433132487,
19.425123143954014
],
[
-99.13246427250664,
19.4250551918067
],
[
-99.13231298739784,
19.424989736359613
],
[
-99.13216052208138,
19.424926797551123
],
[
-99.13200692299966,
19.424866394553003
],
[
-99.13185223694049,
19.424808545764584
],
[
-99.1316965110227,
19.424753268807173
],
[
-99.13153979268192,
19.424700580518667
],
[
-99.13138212965609,
19.424650496948427
],
[
-99.13122356997087,
19.42460303335239
],
[
-99.13106416192511,
19.424558204188436
],
[
-99.13090395407603,
19.424516023111956
],
[
-99.13074299522448,
19.424476502971714
],
[
-99.1305813344001,
19.424439655805934
],
[
-99.13041902084635,
19.424405492838613
],
[
-99.13025610400548,
19.424374024476123
],
[
-99.13009263350357,
19.424345260304033
],
[
-99.1299286591353,
19.424319209084192
],
[
-99.12976423084886,
19.424295878752048
],
[
-99.1295993987307,
19.42427527641425
],
[
-99.12943421299028,
19.424257408346467
],
[
-99.12926872394476,
19.424242279991486
],
[
-99.12910298200373,
19.424229895957556
],
[
-99.12893703765377,
19.424220260016966
],
[
-99.12877094144316,
19.42421337510492
],
[
-99.12860474396639,
19.42420924331863
],
[
-99.12843849584884,
19.424207865916674
],
[
-99.12827224773129,
19.42420924331863
],
[
-99.12810605025452,
19.42421337510492
],
[
-99.12793995404391,
19.424220260016966
],
[
-99.12777400969395,
19.424229895957556
],
[
-99.12760826775292,
19.424242279991486
],
[
-99.1274427787074,
19.424257408346467
],
[
-99.12727759296698,
19.42427527641425
],
[
-99.12711276084882,
19.424295878752048
],
[
-99.12694833256238,
19.424319209084192
],
[
-99.12678435819412,
19.424345260304033
],
[
-99.1266208876922,
19.424374024476123
],
[
-99.12645797085133,
19.424405492838613
],
[
-99.12629565729758,
19.424439655805934
],
[
-99.1261339964732,
19.424476502971714
],
[
-99.12597303762165,
19.424516023111956
],
[
-99.12581282977257,
19.424558204188436
],
[
-99.12565342172681,
19.42460303335239
],
[
-99.12549486204159,
19.424650496948427
],
[
-99.12533719901576,
19.424700580518667
],
[
-99.12518048067498,
19.424753268807173
],
[
-99.12502475475719,
19.424808545764584
],
[
-99.12487006869802,
19.424866394553003
],
[
-99.1247164696163,
19.424926797551123
],
[
-99.12456400429984,
19.424989736359613
],
[
-99.12441271919104,
19.4250551918067
],
[
-99.1242626603728,
19.425123143954014
],
[
-99.1241138735545,
19.425193572102682
],
[
-99.12396640405807,
19.425266454799605
],
[
-99.12382029680408,
19.425341769844007
],
[
-99.12367559629828,
19.425419494294193
],
[
-99.12353234661782,
19.425499604474545
],
[
-99.12339059139795,
19.425582075982728
],
[
-99.12325037381866,
19.42566688369712
],
[
-99.12311173659161,
19.425754001784465
],
[
-99.12297472194703,
19.425843403707756
],
[
-99.12283937162091,
19.4259350622343
],
[
-99.12270572684227,
19.42602894944402
],
[
-99.1225738283206,
19.426125036737965
],
[
-99.12244371623348,
19.426223294847013
],
[
-99.12231543021429,
19.42632369384079
],
[
-99.1221890093402,
19.426426203136792
],
[
-99.12206449212026,
19.426530791509695
],
[
-99.1219419164836,
19.426637427100868
],
[
-99.12182131976795,
19.426746077428074
],
[
-99.12170273870822,
19.426856709395373
],
[
-99.12158620942539,
19.426969289303194
],
[
-99.12147176741537,
19.42708378285861
],
[
-99.12135944753831,
19.427200155185773
],
[
-99.12124928400796,
19.42731837083654
],
[
-99.12114131038118,
19.42743839380129
],
[
-99.12103555954776,
19.427560187519855
],
[
-99.12093206372047,
19.427683714892694
],
[
-99.12083085442512,
19.42780893829217
],
[
-99.12073196249105,
19.42793581957402
],
[
-99.12063541804169,
19.428064320088986
],
[
-99.12054125048542,
19.428194400694554
],
[
-99.12044948850658,
19.42832602176692
],
[
-99.12036016005678,
19.428459143213026
],
[
-99.12027329234631,
19.428593724482795
],
[
-99.12018891183594,
19.428729724581462
],
[
-99.12010704422876,
19.42886710208208
],
[
-99.12002771446247,
19.42900581513814
],
[
-99.11995094670165,
19.42914582149629
],
[
-99.11987676433053,
19.429287078509248
],
[
-99.11980518994577,
19.42942954314875
],
[
-99.11973624534961,
19.42957317201869
],
[
-99.11966995154326,
19.429717921368326
],
[
-99.11960632872045,
19.4298637471056
],
[
-99.1195453962613,
19.43001060481058
],
[
-99.11948717272644,
19.43015844974899
],
[
-99.11943167585132,
19.430307236885824
],
[
-99.11937892254082,
19.430456920899086
],
[
-99.1193289288641,
19.43060745619357
],
[
-99.11928171004975,
19.430758796914766
],
[
-99.11923728048104,
19.43091089696283
],
[
-99.11919565369168,
19.431063710006608
],
[
-99.11915684236156,
19.431217189497772
],
[
-99.11912085831302,
19.43137128868498
],
[
-99.11908771250714,
19.43152596062812
],
[
-99.11905741504043,
19.43168115821263
],
[
-99.11902997514183,
19.43183683416382
],
[
-99.11900540116977,
19.431992941061285
],
[
-99.11898370060973,
19.43214943135335
],
[
-99.11896488007191,
19.432306257371557
],
[
-99.11894894528923,
19.432463371345186
],
[
-99.11893590111558,
19.432620725415795
],
[
-99.11892575152434,
19.432778271651813
],
[
-99.11891849960718,
19.432935962063123
],
[
-99.11891414757308,
19.433093748615708
],
[
-99.11891269674774,
19.433251583246246
]
]
]
}
}
]
}
\ No newline at end of file
public/index.html
View file @
ab52bb05
...
...
@@ -16,6 +16,7 @@
<div
id=
"mexmap"
></div>
<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=
"../js/functions.js"
></script>
</body>
...
...
public/js/functions.js
View file @
ab52bb05
...
...
@@ -5,10 +5,11 @@
* November-December 2020
*/
/* global mapboxgl */
/* global mapboxgl
, turf
*/
const
baseUrl
=
new
URL
(
`/data`
,
window
.
location
.
href
).
href
;
let
selectedMunis
=
[
"09002"
,
"09012"
];
let
selectedMunis
=
[{
id
:
"09002"
,
geom
:
{
coordinates
:
[[
-
99.25958633422852
,
19.34791392861453
]],
type
:
"Polygon"
}},
{
id
:
"09012"
,
geom
:
{
coordinates
:
[[
-
99.25958633422852
,
19.34791392861453
]],
type
:
"Polygon"
}}],
selectedIDs
=
selectedMunis
.
map
(
m
=>
m
.
id
);
// define MVT layer for given table and some attributes
//const mapboxLayer = (table, n, polygon, box) => {
...
...
@@ -121,7 +122,7 @@ map.on("style.load", async () => {
[
"match"
,
[
"get"
,
"municipio_cvegeo"
],
selected
Muni
s
,
selected
ID
s
,
true
,
false
]
...
...
@@ -147,7 +148,7 @@ map.on("style.load", async () => {
}
});
selected
Muni
s
.
forEach
(
muniID
=>
{
selected
ID
s
.
forEach
(
muniID
=>
{
map
.
setFeatureState
({
source
:
"dim_municipio"
,
sourceLayer
:
"dim_municipio"
,
...
...
@@ -156,9 +157,26 @@ map.on("style.load", async () => {
selected
:
true
});
});
map
.
addSource
(
'circle'
,
{
'type'
:
'geojson'
,
'data'
:
'http://localhost:8090/circle.geojson'
});
map
.
addLayer
({
'id'
:
'circle'
,
'type'
:
'fill'
,
'source'
:
'circle'
,
'layout'
:
{},
'paint'
:
{
'fill-color'
:
'#088'
,
'fill-opacity'
:
0.56
}
});
});
let
muniID
=
null
;
let
muniID
=
null
,
intersects
=
null
,
muniGeoms
=
[];
map
.
on
(
"click"
,
"denue"
,
async
e
=>
{
// flag we're only clicking denue points
...
...
@@ -183,18 +201,23 @@ map.on("click", "muni_polygon", e => {
return
;
}
// check type of click between polygons and circle
// 1. polygons that do not intersect circle - select and deselect
// 2. polygons that intersect circle - select and deselect
let
clickedMuni
=
map
.
queryRenderedFeatures
(
e
.
point
,
{
layers
:
[
"muni_polygon"
]
});
if
(
clickedMuni
.
length
!=
0
)
{
muniID
=
e
.
features
[
0
].
id
;
if
(
selectedMunis
.
includes
(
muniID
))
{
let
muniGeom
=
e
.
features
[
0
].
geometry
;
if
(
selectedMunis
.
some
(
e
=>
e
.
id
===
muniID
))
{
// if muni was clicked before
map
.
removeFeatureState
({
source
:
"dim_municipio"
,
sourceLayer
:
"dim_municipio"
,
id
:
muniID
});
selectedMunis
=
selectedMunis
.
filter
(
id
=>
id
!==
muniID
);
}
else
{
selectedMunis
.
push
(
muniID
);
// remove clicked polygon from array
selectedMunis
=
selectedMunis
.
filter
(
el
=>
el
.
id
!==
muniID
);
}
else
{
// if first time clicking muni
map
.
setFeatureState
({
source
:
"dim_municipio"
,
sourceLayer
:
"dim_municipio"
,
...
...
@@ -202,17 +225,43 @@ map.on("click", "muni_polygon", e => {
},
{
selected
:
true
});
// add clicked polygon to array
selectedMunis
.
push
({
id
:
muniID
,
geom
:
muniGeom
});
}
map
.
setFilter
(
"denue"
,
[
"all"
,[
"match"
,
[
"get"
,
"municipio_cvegeo"
],
selectedMunis
,
true
,
false
]
]
);
// get array of ids and geoms
selectedIDs
=
selectedMunis
.
map
(
a
=>
a
.
id
);
muniGeoms
=
selectedMunis
.
map
(
a
=>
a
.
geom
);
// check if selectedMunis intersect circle
let
circleLayer
=
map
.
queryRenderedFeatures
(
{
layers
:
[
"circle"
]
});
let
circleGeom
=
circleLayer
[
0
].
geometry
;
let
muniInteresects
=
selectedMunis
.
filter
(
el
=>
turf
.
intersect
(
el
.
geom
,
circleGeom
));
let
intersectedIDs
=
muniInteresects
.
map
(
a
=>
a
.
id
);
if
(
intersectedIDs
.
length
>
0
)
{
let
selectedIDs2
=
selectedIDs
.
filter
(
id
=>
intersectedIDs
.
indexOf
(
id
)
==
-
1
);
map
.
setFilter
(
"denue"
,
[
"any"
,[
"match"
,
[
"get"
,
"municipio_cvegeo"
],
selectedIDs2
,
true
,
false
],
[
'within'
,
circleGeom
]
]
);
}
else
{
map
.
setFilter
(
"denue"
,
[
"all"
,[
"match"
,
[
"get"
,
"municipio_cvegeo"
],
selectedIDs
,
true
,
false
]
]
);
}
//TODO: handle case when nothing is selected
}
});
...
...
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