Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProgGis
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
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
Jakob Severin Steffensen Hjelseth
ProgGis
Commits
fcc6e163
Commit
fcc6e163
authored
1 year ago
by
Jakob Severin Steffensen Hjelseth
Browse files
Options
Downloads
Patches
Plain Diff
Ferdigstille
parent
fd511662
No related branches found
Branches containing commit
No related tags found
2 merge requests
!37
Dev
,
!36
Resolve "Intersect"
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
index.html
+13
-1
13 additions, 1 deletion
index.html
javascript/difference.js
+1
-1
1 addition, 1 deletion
javascript/difference.js
javascript/intersect.js
+28
-0
28 additions, 0 deletions
javascript/intersect.js
javascript/sidebar&boxes.js
+6
-4
6 additions, 4 deletions
javascript/sidebar&boxes.js
with
48 additions
and
6 deletions
index.html
+
13
−
1
View file @
fcc6e163
...
...
@@ -116,7 +116,7 @@
<p>
Choose a name for the new layer:
</p>
<input
id=
"differenceName"
><br>
<button
class=
"button"
style=
"font-size: 25px;"
onclick=
"difference()"
>
D
iffer
</button>
<button
class=
"button"
style=
"font-size: 25px;"
onclick=
"difference()"
>
Make d
iffer
ence
</button>
</div>
<div
id=
"dissolveBox"
class=
"box"
>
...
...
@@ -158,6 +158,17 @@
<path
d=
"M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"
/>
</svg>
</div>
<p>
Choose the first layer to intersect:
</p>
<select
id=
"intersectionSelect_1"
></select>
<p>
Choose the second layer:
</p>
<select
id=
"intersectionSelect_2"
></select>
<p>
Choose a name for the intersection:
</p>
<input
id=
"intersectionName"
><br>
<button
class=
"button"
style=
"font-size: 25px;"
onclick=
"intersection()"
>
Intersect
</button>
</div>
<div
id=
"unionBox"
class=
"box"
>
...
...
@@ -222,6 +233,7 @@
<script
src=
"javascript/dissolve.js"
></script>
<script
src=
"javascript/difference.js"
></script>
<script
src=
"javascript/turfFormatConverter.js"
></script>
<script
src=
"javascript/intersect.js"
></script>
<!-- Imported js -->
<!-- <script src="https://unpkg.com/shpjs@latest/dist/shp.js"></script> -->
...
...
This diff is collapsed.
Click to expand it.
javascript/difference.js
+
1
−
1
View file @
fcc6e163
...
...
@@ -21,7 +21,7 @@ function difference() {
updateSidebar
();
handleLayer
(
name
);
document
.
getElementById
(
"
differenceName
"
).
value
=
""
;
fillDifferenceSelect
(
);
fillD
oubleSelect
(
"
d
ifferenceSelect
"
);
}
catch
(
failure
)
{
alert
(
failure
)
}
...
...
This diff is collapsed.
Click to expand it.
javascript/intersect.js
0 → 100644
+
28
−
0
View file @
fcc6e163
function
intersection
()
{
var
input1
=
document
.
getElementById
(
"
intersectionSelect_1
"
).
value
;
var
layer1
=
overlayMaps
[
input1
].
toGeoJSON
();
var
input2
=
document
.
getElementById
(
"
intersectionSelect_2
"
).
value
;
var
layer2
=
overlayMaps
[
input2
].
toGeoJSON
();
var
name
=
document
.
getElementById
(
"
intersectionName
"
).
value
;
// Må konverteres fra feature collection til multipolygon:
var
coords1
=
featureCollectionToMultiPolygon
(
layer1
);
var
coords2
=
featureCollectionToMultiPolygon
(
layer2
);
var
multiPolygon1
=
turf
.
multiPolygon
(
coords1
);
var
multiPolygon2
=
turf
.
multiPolygon
(
coords2
);
try
{
var
intersection
=
turf
.
intersect
(
multiPolygon1
,
multiPolygon2
);
var
newLayer
=
new
L
.
GeoJSON
(
intersection
);
overlayMaps
[
name
]
=
newLayer
;
updateSidebar
();
handleLayer
(
name
);
document
.
getElementById
(
"
intersectionName
"
).
value
=
""
;
fillDoubleSelect
(
"
intersectionSelect
"
)
}
catch
(
failure
)
{
alert
(
failure
);
}
}
This diff is collapsed.
Click to expand it.
javascript/sidebar&boxes.js
+
6
−
4
View file @
fcc6e163
...
...
@@ -29,9 +29,11 @@ function openBox(id) {
if
(
id
==
"
bufferBox
"
)
{
fillSelect
(
"
bufferSelect
"
);
}
else
if
(
id
==
"
differenceBox
"
)
{
fillDifferenceSelect
(
);
fillD
oubleSelect
(
"
d
ifferenceSelect
"
);
}
else
if
(
id
==
"
dissolveBox
"
)
{
fillSelect
(
"
dissolveSelect
"
);
}
else
if
(
id
==
"
intersectionBox
"
)
{
fillDoubleSelect
(
"
intersectionSelect
"
);
}
document
.
getElementById
(
String
(
id
)).
style
.
width
=
"
40vw
"
;
...
...
@@ -63,9 +65,9 @@ function fillSelect(id) {
}
}
function
fillD
ifferenc
eSelect
()
{
var
select1
=
document
.
getElementById
(
"
differenceSelect
_1
"
);
var
select2
=
document
.
getElementById
(
"
differenceSelect
_2
"
);
function
fillD
oubl
eSelect
(
id
)
{
var
select1
=
document
.
getElementById
(
id
+
"
_1
"
);
var
select2
=
document
.
getElementById
(
id
+
"
_2
"
);
select1
.
innerHTML
=
""
;
select2
.
innerHTML
=
""
;
...
...
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