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
c21e59ce
Commit
c21e59ce
authored
1 year ago
by
Jakob Severin Steffensen Hjelseth
Browse files
Options
Downloads
Patches
Plain Diff
Fix
parent
2578a442
No related branches found
No related tags found
1 merge request
!68
Resolve "Input Polygon"
Pipeline
#238967
passed
1 year ago
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
javascript/buffer.js
+1
-1
1 addition, 1 deletion
javascript/buffer.js
javascript/dissolve.js
+1
-1
1 addition, 1 deletion
javascript/dissolve.js
javascript/turfFormatConverter.js
+32
-25
32 additions, 25 deletions
javascript/turfFormatConverter.js
with
34 additions
and
27 deletions
javascript/buffer.js
+
1
−
1
View file @
c21e59ce
...
...
@@ -38,7 +38,7 @@ function makeBuffer() {
if
(
document
.
getElementById
(
"
bufferCheck
"
).
checked
)
{
// Om en har huket av for at en skal 'dissolve' gjøres det
// Dette er nytt:
if
(
isMultiPolygon
(
buffer
))
{
// Kan ikke sende MultiPolygon inn i dissolved
buffer
=
m
ultiPolygon
ToFeatureCollection
(
buffer
);
buffer
=
fixM
ultiPolygon
s
(
buffer
);
}
// #
var
dissolved
=
turf
.
dissolve
(
buffer
);
...
...
This diff is collapsed.
Click to expand it.
javascript/dissolve.js
+
1
−
1
View file @
c21e59ce
...
...
@@ -24,7 +24,7 @@ function doDissolve() {
try
{
// Dette er nytt:
if
(
isMultiPolygon
(
layer
))
{
layer
=
m
ultiPolygon
ToFeatureCollection
(
layer
);
layer
=
fixM
ultiPolygon
s
(
layer
);
}
//#
...
...
This diff is collapsed.
Click to expand it.
javascript/turfFormatConverter.js
+
32
−
25
View file @
c21e59ce
...
...
@@ -40,41 +40,48 @@ function isMultiPolygon(layer) { // Inneholder 'layer' features som er MultiPoly
return
false
;
}
function
multiPolygonToFeatureCollection
(
layer
)
{
// Funksjon som gjør om features i 'layer' til FeatureCollection istedenfor MultiPolygon
function
multiPolygonToFeatureCollection
(
layer
)
{
// Funksjon som gjør om features i 'layer' til FeatureCollection istedenfor MultiPolygon
// 'layer' er her et GeoJSON-lag
more
=
false
;
for
(
var
i
=
0
;
i
<
layer
[
"
geometry
"
][
"
coordinates
"
].
length
;
i
++
)
{
var
geometry
=
{
"
type
"
:
"
Polygon
"
,
"
coordinates
"
:
layer
[
"
geometry
"
][
"
coordinates
"
][
i
]
};
features
.
push
(
turf
.
feature
(
geometry
));
}
try
{
if
(
layer
[
"
features
"
])
{
more
=
true
;
}
}
catch
{}
console
.
log
(
more
);
var
features
=
[];
return
turf
.
featureCollection
(
features
);
}
if
(
more
)
{
for
(
var
i
=
0
;
i
<
layer
[
"
features
"
];
i
++
)
{
for
(
var
j
=
0
;
j
<
layer
[
"
features
"
][
i
][
"
geometry
"
][
"
coordinates
"
].
length
;
j
++
)
{
console
.
log
(
layer
[
"
features
"
][
i
][
"
geometry
"
][
"
coordinates
"
][
j
]);
var
geometry
=
{
function
fixMultiPolygons
(
layer
)
{
// Annen variant som løser MultiPolygon-problemet for buffer-funksjonen
var
features
=
layer
[
"
features
"
];
var
k
=
features
.
length
;
for
(
var
i
=
0
;
i
<
k
;
i
++
)
{
if
(
features
[
i
][
"
geometry
"
][
"
type
"
]
==
"
MultiPolygon
"
)
{
var
coord
=
features
[
i
][
"
geometry
"
][
"
coordinates
"
];
features
[
i
][
"
geometry
"
][
"
type
"
]
=
"
Polygon
"
;
features
[
i
][
"
geometry
"
][
"
coordinates
"
]
=
coord
[
0
];
for
(
var
j
=
1
;
j
<
ccoord
.
length
;
j
++
)
{
newFeature
=
{};
for
(
key
in
features
[
i
])
{
if
(
key
!=
"
geometry
"
)
{
newFeature
[
key
]
=
features
[
i
][
key
];
}
}
newFeatures
[
"
geometry
"
]
=
{
"
type
"
:
"
Polygon
"
,
"
coordinates
"
:
layer
[
"
features
"
][
i
][
"
geometry
"
][
"
coordinates
"
]
[
j
]
"
coordinates
"
:
coord
[
j
]
};
features
.
push
(
turf
.
feature
(
geometry
)
);
features
.
push
(
newFeature
);
}
}
}
else
{
for
(
var
i
=
0
;
i
<
layer
[
"
geometry
"
][
"
coordinates
"
].
length
;
i
++
)
{
var
geometry
=
{
"
type
"
:
"
Polygon
"
,
"
coordinates
"
:
layer
[
"
geometry
"
][
"
coordinates
"
][
i
]
};
features
.
push
(
turf
.
feature
(
geometry
));
}
}
return
turf
.
featureCollection
(
features
);
layer
[
"
features
"
]
=
features
;
return
layer
;
}
/*
...
...
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