Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
externe Matthieu
Géocontrib Frontend
Commits
54a010dc
"...git@git.neogeo.fr:geocontrib/geocontrib-frontend.git" did not exist on "072c4381c98d1068a01a6f984f6a7ad4a8b1f1b9"
Commit
54a010dc
authored
2 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
retrieve color and opacity according to empty string
parent
1e320009
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/map-service.js
+17
-39
17 additions, 39 deletions
src/services/map-service.js
src/views/FeatureType/FeatureTypeSymbology.vue
+1
-35
1 addition, 35 deletions
src/views/FeatureType/FeatureTypeSymbology.vue
with
18 additions
and
74 deletions
src/services/map-service.js
+
17
−
39
View file @
54a010dc
...
...
@@ -328,44 +328,23 @@ const mapService = {
this
.
addLayers
(
layers
);
},
retrieveFeatureColor
:
function
(
featureType
,
properties
)
{
const
colorsStyle
=
featureType
.
colors_style
;
console
.
log
(
'
colorsStyle.colors
'
,
colorsStyle
.
colors
);
//console.log('featureType.title', featureType.title);
//console.log('featureType.customfield_set', featureType.customfield_set);
//console.log('featureType', featureType);
//console.log('properties', properties);
if
(
featureType
&&
colorsStyle
&&
colorsStyle
.
custom_field_name
)
{
const
fieldType
=
featureType
.
customfield_set
.
find
((
el
)
=>
el
.
name
===
colorsStyle
.
custom_field_name
).
field_type
;
console
.
log
(
'
fieldType
'
,
fieldType
);
const
currentValue
=
properties
[
colorsStyle
.
custom_field_name
];
console
.
log
(
'
currentValue
'
,
currentValue
);
let
colorStyle
;
if
(
Object
.
entries
(
colorsStyle
.
colors
).
length
>
0
)
{
colorStyle
=
colorsStyle
.
colors
[
currentValue
];
}
else
{
//colorStyle = { Vide: , 'Non vide': }
colorStyle
=
colorsStyle
.
colors
[
currentValue
];
}
return
colorStyle
?
colorStyle
:
featureType
.
color
;
}
else
{
return
featureType
.
color
;
}
},
retrieveFeatureOpacity
:
function
(
featureType
,
properties
)
{
const
colorsStyle
=
featureType
.
colors_style
;
if
(
featureType
&&
colorsStyle
&&
colorsStyle
.
custom_field_name
)
{
const
currentValue
=
properties
[
colorsStyle
.
custom_field_name
];
//console.log('currentValue', currentValue);
if
(
currentValue
&&
colorsStyle
.
opacities
)
{
const
colorStyle
=
colorsStyle
.
opacities
[
currentValue
];
//console.log('colorsStyle', colorsStyle);
return
parseFloat
(
colorStyle
?
colorStyle
:
featureType
.
opacity
);
retrieveFeatureStyle
:
function
(
featureType
,
properties
)
{
const
{
colors_style
,
customfield_set
}
=
featureType
;
let
{
color
,
opacity
}
=
featureType
;
if
(
colors_style
&&
colors_style
.
custom_field_name
&&
customfield_set
)
{
const
fieldType
=
customfield_set
.
find
((
el
)
=>
el
.
name
===
colors_style
.
custom_field_name
).
field_type
;
const
currentValue
=
properties
[
colors_style
.
custom_field_name
];
if
(
fieldType
===
'
list
'
)
{
color
=
colors_style
.
colors
[
currentValue
];
opacity
=
colors_style
.
opacities
[
currentValue
];
}
else
if
(
fieldType
===
'
char
'
)
{
//* if the custom field is supposed to be a string
//* check if its current value is empty or not, to select a color | https://redmine.neogeo.fr/issues/14048
color
=
colors_style
.
value
.
colors
[
currentValue
?
'
Non vide
'
:
'
Vide
'
];
opacity
=
colors_style
.
value
.
opacities
[
currentValue
?
'
Non vide
'
:
'
Vide
'
];
}
}
//* parseFloat is not necessary but used for precaution
return
parseFloat
(
featureType
.
opacity
);
return
{
color
,
opacity
};
},
addVectorTileLayer
:
function
(
url
,
projectId
,
featureTypes
,
formFilters
)
{
...
...
@@ -403,15 +382,14 @@ const mapService = {
}
if
(
featureType
)
{
const
color
=
this
.
retrieveFeature
Color
(
featureType
,
properties
);
const
{
color
,
opacity
}
=
this
.
retrieveFeature
Style
(
featureType
,
properties
);
const
colorValue
=
color
.
value
&&
color
.
value
.
length
?
color
.
value
:
typeof
color
===
'
string
'
&&
color
.
length
?
color
:
'
#000000
'
;
const
rgbaColor
=
asArray
(
colorValue
);
//* set opacity from feature-type colors_style
rgbaColor
[
3
]
=
this
.
retrieveFeatureOpacity
(
featureType
,
properties
)
||
0.5
;
//opacity
rgbaColor
[
3
]
=
opacity
||
0.5
;
//opacity
const
defaultStyle
=
new
Style
(
{
...
...
This diff is collapsed.
Click to expand it.
src/views/FeatureType/FeatureTypeSymbology.vue
+
1
−
35
View file @
54a010dc
...
...
@@ -73,19 +73,6 @@
:selection.sync=
"selectedCustomfield"
/>
</span>
<!--
<select
id=
"customfield-select"
v-model=
"selectedCustomfield"
class=
"ui dropdown"
>
<option
v-for=
"customfieldList of customizableFields"
:key=
"customfieldList.name"
:value=
"customfieldList.name"
>
<span>
{{
customfieldList
.
label
}}
</span>
<span>
{{
customfieldList
.
field_type
}}
</span>
</option>
</select>
-->
</div>
<div
v-if=
"selectedCustomfield"
...
...
@@ -153,7 +140,6 @@ export default {
loading
:
false
,
error
:
null
,
success
:
null
,
//selectedCustomfield: null,
form
:
{
color
:
'
#000000
'
,
icon
:
'
circle
'
,
...
...
@@ -189,7 +175,6 @@ export default {
if
(
this
.
feature_type
)
{
let
options
=
this
.
feature_type
.
customfield_set
.
filter
(
el
=>
el
.
field_type
===
'
list
'
||
el
.
field_type
===
'
char
'
);
options
=
options
.
map
((
el
)
=>
{
console
.
log
(
el
);
return
{
name
:
[
el
.
name
,
`(
${
el
.
field_type
===
'
list
'
?
'
Liste de valeurs
'
:
'
Chaîne de caractères
'
}
)`
],
value
:
el
};
});
return
options
;
...
...
@@ -199,23 +184,14 @@ export default {
selectedFieldOptions
()
{
if
(
this
.
selectedCustomfield
)
{
const
customFieldSet
=
this
.
feature_type
.
customfield_set
.
find
(
el
=>
el
.
name
===
this
.
selectedCustomfield
);
console
.
log
(
'
customFieldSet
'
,
customFieldSet
);
if
(
customFieldSet
.
options
.
length
>
0
)
{
return
customFieldSet
.
options
;
}
else
if
(
customFieldSet
.
field_type
===
'
char
'
)
{
return
[
'
Vide
'
,
'
Non vide
'
];
}
/* const customfield_set = this.feature_type.customfield_set.find(
el => el.name === this.selectedCustomfield).options;
if (customfield_set.options) {
return customfield_set.options.length > 0 ? customfield_set.options : ['Vide', 'Non vide'];
} */
}
return
[];
},
/* selectedGetterSetter() {
} */
selectedCustomfield
:
{
get
()
{
return
this
.
form
.
colors_style
.
custom_field_name
;
...
...
@@ -229,13 +205,6 @@ export default {
},
watch
:
{
/* selectedCustomfield(newValue, oldValue) {
console.log(newValue);
if (newValue && newValue !== oldValue) {
this.selectedCustomfield = newValue.value.name;
this.form.colors_style.custom_field_name = newValue.value;
}
}, */
feature_type
(
newValue
)
{
if
(
newValue
)
{
// Init form
...
...
@@ -384,10 +353,7 @@ form {
font-weight: 600;
font-size: 1.1em;
}
// TODO : à supprimer après remplacement par dropdown
#customfield-select {
width: 50% !important;
}
#custom_types-dropdown > .dropdown {
width: 50%;
}
...
...
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