-
Notifications
You must be signed in to change notification settings - Fork 27
Geostyler style handler #1487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geostyler style handler #1487
Changes from 1 commit
2e073d7
fafee3b
0770829
857fcb9
aa81520
1cbdedc
2d51121
b4dd951
f6475b6
6bc1f9d
9f734c5
133689b
30b3a5a
79d668d
5422b46
7145fbc
0dd3bcf
886d048
3e5b11a
bb384b0
920bcf7
dfd91aa
3b2ec53
a508ce2
d259476
d426a19
88cc0a1
b50f400
2157d51
6302209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { OlStyleParser as OpenLayersParser } from 'geostyler-openlayers-parser'; | ||
| import LegendRenderer from 'geostyler-legend/dist/LegendRenderer/LegendRenderer'; | ||
|
|
||
| import { Style as GeoStylerStyle, WriteStyleResult } from 'geostyler-style'; | ||
| import LegendRenderer from 'geostyler-legend/dist/LegendRenderer/LegendRenderer'; | ||
| import { OlStyleParser as OpenLayersParser } from 'geostyler-openlayers-parser'; | ||
| import { | ||
| Style as GeoStylerStyle, | ||
| IconSymbolizer, | ||
| LineSymbolizer, | ||
| MarkSymbolizer, | ||
| WriteStyleResult | ||
| } from 'geostyler-style'; | ||
| import { Observable, from, map } from 'rxjs'; | ||
|
|
||
| import { StyleSourceType } from '../shared'; | ||
|
|
||
| @Injectable({ | ||
|
|
@@ -57,11 +64,13 @@ export class GeostylerStyleService { | |
| height: number = 300 | ||
| ): Observable<string> { | ||
| // todo define height automatically? | ||
| const layerDescriptors: GeoStylerStyle[] = | ||
| this.transferLayersToLegend(styles); | ||
| const renderer = new LegendRenderer({ | ||
| maxColumnWidth: 300, | ||
| maxColumnHeight: 300, | ||
| overflow: 'auto', | ||
| styles, | ||
| styles: layerDescriptors, | ||
| size: [width, height], | ||
| hideRect: true | ||
| }); | ||
|
|
@@ -81,5 +90,43 @@ export class GeostylerStyleService { | |
| }) | ||
| ); | ||
| } | ||
|
|
||
| private transferLayersToLegend(styles: GeoStylerStyle[]) { | ||
| var stylesCopy = [...styles]; | ||
| const layerDescriptorsList: GeoStylerStyle[] = []; | ||
| for (var index in stylesCopy) { | ||
| var DescriptorLayerRulesAdapted = []; | ||
| let descriptorLayerName = stylesCopy[index].name; | ||
| stylesCopy[index].rules.forEach(function (styleRule) { | ||
|
||
| var styleRuleSymbolizersAdapted = []; | ||
| styleRule.symbolizers.forEach(function (styleRuleSymbolizer) { | ||
| switch (styleRuleSymbolizer.kind) { | ||
| case 'Mark': | ||
| (styleRuleSymbolizer as MarkSymbolizer).radius = 10; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. crée une doc dans l'entete de la méthode de la raison d'imposer des tailles maximale au radius, width et size /*
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. faire pour chaque méthode svp |
||
| break; | ||
| case 'Line': | ||
| (styleRuleSymbolizer as LineSymbolizer).width = 3; | ||
| break; | ||
| case 'Icon': | ||
| (styleRuleSymbolizer as IconSymbolizer).size = 15; | ||
| default: | ||
| break; | ||
| } | ||
| styleRuleSymbolizersAdapted.push(styleRuleSymbolizer); | ||
| }); | ||
| DescriptorLayerRulesAdapted.push({ | ||
| name: styleRule.name, | ||
| symbolizers: styleRuleSymbolizersAdapted | ||
| }); | ||
| }); | ||
| let styleNoRadius: any = { | ||
| name: descriptorLayerName, | ||
| rules: DescriptorLayerRulesAdapted | ||
| }; | ||
| layerDescriptorsList.push(styleNoRadius); | ||
| } | ||
| return layerDescriptorsList; | ||
| } | ||
|
|
||
| private hoverStyleToGeostyler() {} | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changer vers un foreach si applicable?