private bool insertGeoserverStyle(GeoserverClient client, string username, ColorMap colorMap) { StylesBuilder stylesBuilder = new StylesBuilder(username + '_' + colorMap.Name, colorMap.Name); foreach (var intervalRule in colorMap.GetRules()) { stylesBuilder.AddRule(intervalRule); } return(client.Post(new ModulesFactory().CreateStylesModule(stylesBuilder))); }
public void ColorMapStyle() { ColorMap colorMap = new ColorMap() { Name = "checking", Intervals = new List <Interval>() { new Interval() { Color = "#FF0000", Left = -100, Right = 0 }, new Interval() { Color = "#00FF00", Left = 0, Right = 100 } } }; StylesBuilder builder = new StylesBuilder("colormap51", "colormap51"); foreach (var rule in colorMap.GetRules()) { builder.AddRule(rule); } ModulesFactory modulesFactory = new ModulesFactory(); GeoserverClient geoserverClient = new GeoserverClient("http://localhost:8080", "admin", "geoserver"); var result = geoserverClient.Post(modulesFactory.CreateStylesModule(builder)); Assert.IsTrue(result); }
public void StylesBuilderTest() { string desiredResult = @"< 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 point</Name> <UserStyle> <Title>GeoServer SLD Cook Book: Simple point</Title> <FeatureTypeStyle> <Rule> <PointSymbolizer> <Graphic> <Mark> <WellKnownName> circle </WellKnownName> <Fill> <CssParameter name=""fill"">#FF0000</CssParameter> </Fill> </Mark> <Size>6</Size> </Graphic> </PointSymbolizer> </Rule> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>"; StylesBuilder builder = new StylesBuilder("style", "titlestyle"); builder.AddRule(new Rule { Abstract = "abstract", Name = "Rulename", Title = "Ruletitle", Filter = new Filter { FilterItems = new List <Filter.FilterItem>() { new Filter.FilterItem { PropertyName = "Height", Type = Filter.FilterItemType.PropertyIsGreaterThanOrEqualTo, Literal = "0" } } } , PointSymbolizers = new List <PointSymbolizer> { new PointSymbolizer { Graphic = new Graphic { MarkObject = new Graphic.Mark() { WellKnownNameProperty = Shape.Circle, Fill = new Fill { CssParameterArray = new List <CssParameter>() { new CssParameter { Name = "fill", Value = "#FF0000" }, new CssParameter { Name = "fill-opacity", Value = "1" } }, } } } } } }); string result = builder.ToXml(); Assert.IsNotNull(result); }
public void GeoserverServiceTest() { StylesBuilder builder = new StylesBuilder("teststyle22", "teststyle22"); builder.AddRule(new Rule { Abstract = "abstract", MaxScaleDenominator = 10, MinScaleDenominator = 10, Name = "another", Title = "another", Filter = new Filter { FilterItems = new List <Filter.FilterItem>() { new Filter.FilterItem { PropertyName = "Height", Type = Filter.FilterItemType.PropertyIsGreaterThanOrEqualTo, Literal = "0" } } } , PointSymbolizers = new List <PointSymbolizer> { new PointSymbolizer { Graphic = new Graphic { MarkObject = new Graphic.Mark() { WellKnownNameProperty = Shape.Circle, Fill = new Fill { CssParameterArray = new List <CssParameter>() { new CssParameter { Name = "fill", Value = "#FF0000" }, new CssParameter { Name = "fill-opacity", Value = "1" } }, } } } } } }); ModulesFactory modulesFactory = new ModulesFactory(); GeoserverClient geoserverClient = new GeoserverClient("http://localhost:8080", "admin", "geoserver"); var result = geoserverClient.PostAsync(modulesFactory.CreateStylesModule(builder)).Result; Assert.IsTrue(result); }