Skip to content

Commit

Permalink
read RasterSymbolizer
Browse files Browse the repository at this point in the history
  • Loading branch information
jansule committed Apr 9, 2019
1 parent 3c2c48e commit 84d0961
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 1 deletion.
47 changes: 47 additions & 0 deletions data/slds/raster_simpleRaster.sld
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Simple Raster</Name>
<UserStyle>
<Title>Simple Raster</Title>
<FeatureTypeStyle>
<Rule>
<Name>Small populated New Yorks</Name>
<RasterSymbolizer>
<Opacity>0.5</Opacity>
<ChannelSelection>
<RedChannel>
<SourceChannelName>1</SourceChannelName>
</RedChannel>
<BlueChannel>
<SourceChannelName>2</SourceChannelName>
<ContrastEnhancement>
<Histogram/>
<GammaValue>2</GammaValue>
</ContrastEnhancement>
</BlueChannel>
<GreenChannel>
<SourceChannelName>3</SourceChannelName>
<ContrastEnhancement>
<Normalize/>
</ContrastEnhancement>
</GreenChannel>
</ChannelSelection>
<ColorMap type="ramp">
<ColorMapEntry color="#323232" quantity="-300" label="label1" opacity="1"/>
<ColorMapEntry color="#BBBBBB" quantity="200" label="label2" opacity="1"/>
</ColorMap>
<ContrastEnhancement>
<Histogram/>
</ContrastEnhancement>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
49 changes: 49 additions & 0 deletions data/styles/raster_simpleRaster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Style } from 'geostyler-style';

const rasterSimpleRaster: Style = {
'name': 'Simple Raster',
'rules': [{
'name': 'Small populated New Yorks',
'symbolizers': [{
'kind': 'Raster',
'opacity': 0.5,
'channelSelection': {
'redChannel': {
'sourceChannelName': '1'
},
'blueChannel': {
'sourceChannelName': '2',
'contrastEnhancement': {
'enhancementType': 'histogram',
'gammaValue': 2
}
},
'greenChannel': {
'sourceChannelName': '3',
'contrastEnhancement': {
'enhancementType': 'normalize'
}
}
},
'colorMap': {
'type': 'ramp',
'colorMapEntries': [{
'color': '#323232',
'quantity': -300,
'label': 'label1',
'opacity': 1
}, {
'color': '#BBBBBB',
'quantity': 200,
'label': 'label2',
'opacity': 1
}]
},
'contrastEnhancement': {
'enhancementType': 'histogram'
}
}]
}]
};

export default rasterSimpleRaster;
115 changes: 115 additions & 0 deletions data/xml2jsObjects/raster_simpleRaster.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"StyledLayerDescriptor": {
"$": {
"version": "1.0.0",
"xsi:schemaLocation": "http://www.opengis.net/sld StyledLayerDescriptor.xsd",
"xmlns": "http://www.opengis.net/sld",
"xmlns:ogc": "http://www.opengis.net/ogc",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
},
"NamedLayer": [
{
"Name": [
"Simple Raster"
],
"UserStyle": [
{
"Title": [
"Simple Raster"
],
"FeatureTypeStyle": [
{
"Rule": [
{
"RasterSymbolizer": [
{
"Opacity": [
"0.5"
],
"ChannelSelection": [
{
"RedChannel": [
{
"SourceChannelName": [
"1"
]
}
],
"BlueChannel": [
{
"SourceChannelName": [
"2"
],
"ContrastEnhancement": [
{
"Histogram": [
""
],
"GammaValue": [
"2"
]
}
]
}
],
"GreenChannel": [
{
"SourceChannelName": [
"3"
],
"ContrastEnhancement": [
{
"Normalize": [
""
]
}
]
}
]
}
],
"ColorMap": [
{
"$": {
"type": "ramp"
},
"ColorMapEntry": [
{
"$": {
"color": "#323232",
"quantity": "-300",
"label": "label1",
"opacity": "1"
}
},
{
"$": {
"color": "#BBBBBB",
"quantity": "200",
"label": "label2",
"opacity": "1"
}
}
]
}
],
"ContrastEnhancement": [
{
"Histogram": [
""
]
}
]
}
]
}
]
}
]
}
]
}
]
}
}
10 changes: 10 additions & 0 deletions src/SldStyleParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import point_simplecross from '../data/styles/point_simplecross';
import point_simplex from '../data/styles/point_simplex';
import point_simpleslash from '../data/styles/point_simpleslash';
import point_styledLabel_literalPlaceholder from '../data/styles/point_styledLabel_literalPlaceholder';
import raster_simpleraster from '../data/styles/raster_simpleRaster';

it('SldStyleParser is defined', () => {
expect(SldStyleParser).toBeDefined();
Expand Down Expand Up @@ -227,6 +228,15 @@ describe('SldStyleParser implements StyleParser', () => {
expect(geoStylerStyle).toEqual(point_styledlabel);
});
});
it('can read a SLD RasterSymbolizer', () => {
expect.assertions(2);
const sld = fs.readFileSync('./data/slds/raster_simpleRaster.sld', 'utf8');
return styleParser.readStyle(sld)
.then((geoStylerStyle: Style) => {
expect(geoStylerStyle).toBeDefined();
expect(geoStylerStyle).toEqual(raster_simpleraster);
});
});
it('can read a SLD style with a filter', () => {
expect.assertions(2);
const sld = fs.readFileSync( './data/slds/point_simplepoint_filter.sld', 'utf8');
Expand Down
Loading

0 comments on commit 84d0961

Please sign in to comment.