-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ysld generate styles break kml output formats [GEOS-8885] (#3042)
* placemark fill defaults for opacity and color * placemark null expression checks * Add additional null checks * tests for icon properties * fix for dynamic color generation test
- Loading branch information
1 parent
62b0e49
commit 4a2da2c
Showing
7 changed files
with
217 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/kml/src/test/java/org/geoserver/kml/decorator/PlacemarkStyleDecoratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,67 @@ | |||
/* | |||
* (c) 2018 Open Source Geospatial Foundation - all rights reserved | |||
* | |||
* This code is licensed under the GPL 2.0 license, available at the root application directory. | |||
*/ | |||
package org.geoserver.kml.decorator; | |||
|
|||
import de.micromata.opengis.kml.v_2_2_0.Placemark; | |||
import java.awt.Color; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import org.geoserver.kml.KmlEncodingContext; | |||
import org.geoserver.kml.decorator.PlacemarkStyleDecoratorFactory.PlacemarkStyleDecorator; | |||
import org.geoserver.kml.icons.IconTestSupport; | |||
import org.geotools.data.DataUtilities; | |||
import org.geotools.data.simple.SimpleFeatureCollection; | |||
import org.geotools.styling.TextSymbolizer; | |||
import org.junit.Test; | |||
import org.opengis.feature.simple.SimpleFeatureType; | |||
|
|||
public class PlacemarkStyleDecoratorTest extends IconTestSupport { | |||
|
|||
/** | |||
* Test partial style transformation. | |||
* | |||
* <p>The YSLD parser is not supplying the same defaults as the SLD parser, producing styles | |||
* that violate some of the (perfectly sensible SLD 1.0) assumptions made by | |||
* PlacemarkStyleDecorator. | |||
*/ | |||
@Test | |||
public void testYSLDTextSymbolizerEncoding() { | |||
TextSymbolizer text = | |||
text("text", "NAME", font("Arial Black", null, "bold", 8), fill(Color.white, null)); | |||
|
|||
PlacemarkStyleDecoratorFactory.PlacemarkStyleDecorator decorator = | |||
new PlacemarkStyleDecorator(); | |||
|
|||
KmlEncodingContext context = new FakeKmlEncodingContext(featureType); | |||
SimpleFeatureCollection collection = DataUtilities.collection(fieldIs1); | |||
context.setCurrentFeatureCollection(collection); | |||
context.setCurrentFeature(fieldIs1); | |||
context.setCurrentSymbolizers(Collections.singletonList(text)); | |||
|
|||
Placemark placemark = new Placemark(); | |||
decorator.decorate(placemark, context); | |||
} | |||
|
|||
public static class FakeKmlEncodingContext extends KmlEncodingContext { | |||
private SimpleFeatureType featureType; | |||
|
|||
public FakeKmlEncodingContext(SimpleFeatureType featureType) { | |||
this.featureType = featureType; | |||
} | |||
|
|||
public List<SimpleFeatureType> getFeatureTypes() { | |||
List<SimpleFeatureType> results = new ArrayList<SimpleFeatureType>(); | |||
results.add(featureType); | |||
return results; | |||
} | |||
|
|||
@Override | |||
public SimpleFeatureType getCurrentFeatureType() { | |||
return featureType; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.